ropav 0.0.11 → 0.0.13
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/README.md +3 -0
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +33 -14
- package/dist/color-input.css +19 -19
- package/dist/color-input.js +35 -17
- package/dist/components/checkbox/types.d.ts +5 -1
- package/dist/components/checkbox/useCheckbox.d.ts +1 -1
- package/dist/components/color-input/types.d.ts +4 -1
- package/dist/components/color-input/useColorInput.d.ts +1 -1
- package/dist/components/color-input/useColorInputValue.d.ts +1 -1
- package/dist/components/dialog/dialog-close.d.ts +21 -0
- package/dist/components/dialog/dialog-content.d.ts +32 -0
- package/dist/components/dialog/dialog-core.d.ts +27 -0
- package/dist/components/dialog/dialog-description.d.ts +21 -0
- package/dist/components/dialog/dialog-overlay.d.ts +21 -0
- package/dist/components/dialog/dialog-portal.d.ts +21 -0
- package/dist/components/dialog/dialog-root.d.ts +28 -0
- package/dist/components/dialog/dialog-title.d.ts +21 -0
- package/dist/components/dialog/dialog-trigger.d.ts +23 -0
- package/dist/components/dialog/index.d.ts +9 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/dialog/types.d.ts +61 -0
- package/dist/components/dropdown-menu/dropdown-menu-checkbox-item.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +34 -0
- package/dist/components/dropdown-menu/dropdown-menu-context-trigger.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu-item-indicator.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +28 -0
- package/dist/components/dropdown-menu/dropdown-menu-item.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +24 -22
- package/dist/components/dropdown-menu/dropdown-menu-label.d.ts +21 -0
- package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdown-menu-portal.d.ts +21 -0
- package/dist/components/dropdown-menu/dropdown-menu-primitive-core.d.ts +110 -0
- package/dist/components/dropdown-menu/dropdown-menu-primitives.d.ts +15 -724
- package/dist/components/dropdown-menu/dropdown-menu-radio-group.d.ts +25 -0
- package/dist/components/dropdown-menu/dropdown-menu-radio-item.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +30 -0
- package/dist/components/dropdown-menu/dropdown-menu-separator.d.ts +19 -0
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +34 -0
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +28 -0
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +28 -0
- package/dist/components/dropdown-menu/dropdown-menu-trigger.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +5 -2
- package/dist/components/dropdown-menu/index.d.ts +28 -49
- package/dist/components/dropdown-menu/index.js +2 -2
- package/dist/components/dropdown-menu/types.d.ts +8 -3
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +8 -4
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +7 -2
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +3 -3
- package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +27 -0
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +2 -0
- package/dist/components/floating/index.d.ts +3 -1
- package/dist/components/floating/index.js +3 -0
- package/dist/components/floating/types.d.ts +86 -1
- package/dist/components/floating/useFloatingPosition.d.ts +3 -26
- package/dist/components/floating/useHoverDisclosure.d.ts +2 -0
- package/dist/components/input/input.d.ts +4 -1
- package/dist/components/input/types.d.ts +3 -1
- package/dist/components/modal/index.d.ts +1 -1
- package/dist/components/modal/modal.d.ts +3 -1
- package/dist/components/modal/types.d.ts +3 -0
- package/dist/components/modal/useModal.d.ts +7 -4
- package/dist/components/number-input/types.d.ts +3 -1
- package/dist/components/number-input/useNumberInput.d.ts +2 -1
- package/dist/components/popover/usePopover.d.ts +2 -2
- package/dist/components/radio/types.d.ts +17 -1
- package/dist/components/radio/useRadio.d.ts +3 -0
- package/dist/components/select/select.d.ts +4 -1
- package/dist/components/select/types.d.ts +6 -1
- package/dist/components/select/useSelect.d.ts +3 -2
- package/dist/components/slider/index.d.ts +1 -1
- package/dist/components/slider/range-slider.d.ts +3 -3
- package/dist/components/slider/types.d.ts +11 -3
- package/dist/components/slider/useRangeSlider.d.ts +1 -1
- package/dist/components/slider/useSlider.d.ts +1 -1
- package/dist/components/switch/types.d.ts +5 -1
- package/dist/components/switch/useSwitch.d.ts +1 -1
- package/dist/components/teleport-provider/index.d.ts +1 -0
- package/dist/components/teleport-provider/index.js +2 -1
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +4 -3
- package/dist/components/textarea/types.d.ts +4 -1
- package/dist/components/textarea/useTextarea.d.ts +1 -1
- package/dist/components/toast/index.d.ts +2 -1
- package/dist/components/toast/index.js +2 -2
- package/dist/components/toast/toast-store.d.ts +2 -0
- package/dist/components/toast/types.d.ts +10 -4
- package/dist/components/toast/useToast.d.ts +2 -2
- package/dist/components/tooltip/useTooltip.d.ts +3 -3
- package/dist/composables/useOverlayLayer.d.ts +32 -0
- package/dist/dialog.js +510 -0
- package/dist/dropdown-menu.css +4 -5
- package/dist/dropdown-menu.js +1155 -886
- package/dist/floating.js +403 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -4
- package/dist/input.css +24 -24
- package/dist/input.js +21 -11
- package/dist/legacy-unlayered.css +424 -503
- package/dist/modal.css +28 -28
- package/dist/modal.js +141 -200
- package/dist/number-input.css +20 -20
- package/dist/number-input.js +44 -16
- package/dist/popover.css +4 -4
- package/dist/popover.js +29 -40
- package/dist/radio.css +18 -18
- package/dist/radio.js +96 -18
- package/dist/select.css +54 -43
- package/dist/select.js +185 -67
- package/dist/slider.css +183 -202
- package/dist/slider.js +138 -37
- package/dist/switch.css +17 -17
- package/dist/switch.js +31 -13
- package/dist/textarea.css +26 -26
- package/dist/textarea.js +19 -9
- package/dist/toast.js +110 -99
- package/dist/tooltip.css +5 -80
- package/dist/tooltip.js +11 -3
- package/dist/useControlState.js +4 -0
- package/dist/useFloatingPosition.js +86 -39
- package/dist/useFormControl.js +107 -0
- package/dist/useOverlayLayer.js +262 -0
- package/dist/useTeleportTarget.js +21 -10
- package/docs/public-floating-api.md +159 -0
- package/docs/public-styles-api.md +2 -1
- package/package.json +10 -6
- package/dist/useClickOutside.js +0 -24
package/dist/dropdown-menu.js
CHANGED
|
@@ -2,17 +2,16 @@ import './dropdown-menu.css';
|
|
|
2
2
|
import { t as bem } from "./bem.js";
|
|
3
3
|
import { n as useStylesApi, t as presence } from "./styles-api.js";
|
|
4
4
|
import { t as useRequiredInject } from "./useRequiredInject.js";
|
|
5
|
+
import { t as useOverlayLayer } from "./useOverlayLayer.js";
|
|
5
6
|
import { n as useFloatingPosition, r as useFloatingTarget, t as isElementReference } from "./useFloatingPosition.js";
|
|
6
|
-
import { n as useTeleportTarget, t as provideTeleportTarget } from "./useTeleportTarget.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
//#region src/components/dropdown-menu/dropdown-menu-primitives.ts
|
|
7
|
+
import { n as useTeleportPositioningKey, r as useTeleportTarget, t as provideTeleportTarget } from "./useTeleportTarget.js";
|
|
8
|
+
import { VaporTeleport, VaporTransition, child, computed, createComponent, createComponentWithFallback, createDynamicComponent, createFor, createIf, createSlot, createTemplateRefSetter, defineVaporComponent, extend, isRef, markRaw, mergeProps, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, ref, renderEffect, resolveComponent, setAttr, setDynamicProps, setInsertionState, setStaticTemplateRef, setStyle, setTemplateRefBinding, setText, shallowRef, template, toDisplayString, txt, unref, useAttrs, useId, watch } from "vue";
|
|
9
|
+
//#region src/components/dropdown-menu/dropdown-menu-primitive-core.ts
|
|
10
10
|
var rootKey = Symbol("dropdown-menu-root");
|
|
11
11
|
var menuKey = Symbol("dropdown-menu-content");
|
|
12
12
|
var subKey = Symbol("dropdown-menu-sub");
|
|
13
13
|
var radioGroupKey = Symbol("dropdown-menu-radio-group");
|
|
14
14
|
var checkedKey = Symbol("dropdown-menu-checked");
|
|
15
|
-
var openLayers = [];
|
|
16
15
|
function optionalAttr(value) {
|
|
17
16
|
return value || void 0;
|
|
18
17
|
}
|
|
@@ -20,10 +19,20 @@ function getFocusTarget(options) {
|
|
|
20
19
|
if (typeof options === "string") return options;
|
|
21
20
|
return options?.focus ?? "first";
|
|
22
21
|
}
|
|
23
|
-
function toHTMLElement(value) {
|
|
22
|
+
function toHTMLElement(value, fallbackId) {
|
|
24
23
|
if (typeof HTMLElement !== "undefined" && value instanceof HTMLElement) return value;
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (typeof HTMLElement === "undefined") return null;
|
|
25
|
+
const vdomElement = value?.$el;
|
|
26
|
+
if (vdomElement instanceof HTMLElement) return vdomElement;
|
|
27
|
+
const vaporBlock = value?.block;
|
|
28
|
+
if (vaporBlock instanceof HTMLElement) return vaporBlock;
|
|
29
|
+
return fallbackId && typeof document !== "undefined" ? document.getElementById(fallbackId) : null;
|
|
30
|
+
}
|
|
31
|
+
function resolveHTMLElementRef(value, fallbackId, resolve) {
|
|
32
|
+
const element = toHTMLElement(value, fallbackId);
|
|
33
|
+
resolve(element);
|
|
34
|
+
if (element || !value) return;
|
|
35
|
+
nextTick(() => resolve(toHTMLElement(value, fallbackId)));
|
|
27
36
|
}
|
|
28
37
|
function createPointRect(point) {
|
|
29
38
|
return {
|
|
@@ -78,18 +87,6 @@ function getOpenDirection(sub) {
|
|
|
78
87
|
function getCloseDirection(menu) {
|
|
79
88
|
return getPlacementSide(menu.actualPlacement.value) === "left" ? "ArrowRight" : "ArrowLeft";
|
|
80
89
|
}
|
|
81
|
-
function addOpenLayer(root) {
|
|
82
|
-
const index = openLayers.indexOf(root);
|
|
83
|
-
if (index >= 0) openLayers.splice(index, 1);
|
|
84
|
-
openLayers.push(root);
|
|
85
|
-
}
|
|
86
|
-
function removeOpenLayer(root) {
|
|
87
|
-
const index = openLayers.indexOf(root);
|
|
88
|
-
if (index >= 0) openLayers.splice(index, 1);
|
|
89
|
-
}
|
|
90
|
-
function isTopLayer(root) {
|
|
91
|
-
return openLayers[openLayers.length - 1] === root;
|
|
92
|
-
}
|
|
93
90
|
function blockDocumentClick(event) {
|
|
94
91
|
if (event.cancelable) event.preventDefault();
|
|
95
92
|
event.stopPropagation();
|
|
@@ -233,244 +230,442 @@ function createMenuContext(options) {
|
|
|
233
230
|
};
|
|
234
231
|
return context;
|
|
235
232
|
}
|
|
236
|
-
function
|
|
233
|
+
function usePrimitiveItem(componentName, props, emitSelect, options) {
|
|
234
|
+
const menu = useRequiredInject(menuKey, componentName);
|
|
235
|
+
const generatedId = useId();
|
|
236
|
+
const id = computed(() => props.id ?? `${generatedId}-item`);
|
|
237
|
+
const element = ref(null);
|
|
238
|
+
const isDisabled = computed(() => Boolean(menu.root.disabled.value || props.disabled));
|
|
239
|
+
const focused = computed(() => menu.isActive(id.value));
|
|
240
|
+
function activate(originalEvent) {
|
|
241
|
+
if (isDisabled.value) return;
|
|
242
|
+
const selectEvent = createSelectEvent(originalEvent, props.value);
|
|
243
|
+
emitSelect(selectEvent);
|
|
244
|
+
options.afterSelect?.();
|
|
245
|
+
if (!selectEvent.defaultPrevented && (props.closeOnSelect ?? options.defaultCloseOnSelect)) menu.root.close({ returnFocus: true });
|
|
246
|
+
}
|
|
247
|
+
const registration = {
|
|
248
|
+
get id() {
|
|
249
|
+
return id.value;
|
|
250
|
+
},
|
|
251
|
+
element: () => element.value,
|
|
252
|
+
disabled: () => isDisabled.value,
|
|
253
|
+
activate
|
|
254
|
+
};
|
|
255
|
+
menu.registerItem(registration);
|
|
256
|
+
watch(id, (nextId, previousId) => {
|
|
257
|
+
menu.unregisterItem(previousId);
|
|
258
|
+
menu.registerItem(registration);
|
|
259
|
+
if (menu.activeId.value === previousId) menu.activeId.value = nextId;
|
|
260
|
+
});
|
|
261
|
+
onBeforeUnmount(() => menu.unregisterItem(id.value));
|
|
262
|
+
function setElement(value) {
|
|
263
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
264
|
+
element.value = resolved;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function onPointerenter() {
|
|
268
|
+
if (isDisabled.value) return;
|
|
269
|
+
menu.closeSubmenus();
|
|
270
|
+
menu.setActive(id.value);
|
|
271
|
+
}
|
|
272
|
+
function select() {
|
|
273
|
+
activate(new Event("select"));
|
|
274
|
+
}
|
|
237
275
|
return {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
276
|
+
menu,
|
|
277
|
+
id,
|
|
278
|
+
element,
|
|
279
|
+
isDisabled,
|
|
280
|
+
focused,
|
|
281
|
+
checked: options.checked,
|
|
282
|
+
activate,
|
|
283
|
+
select,
|
|
284
|
+
setElement,
|
|
285
|
+
onPointerenter
|
|
244
286
|
};
|
|
245
287
|
}
|
|
246
|
-
|
|
247
|
-
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/components/dropdown-menu/dropdown-menu-checkbox-item.vue
|
|
290
|
+
var dropdown_menu_checkbox_item_default = /* @__PURE__ */ defineVaporComponent({
|
|
291
|
+
name: "RpDropdownMenuCheckboxItem",
|
|
292
|
+
inheritAttrs: false,
|
|
293
|
+
__name: "dropdown-menu-checkbox-item",
|
|
248
294
|
props: {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
type: Boolean,
|
|
295
|
+
modelValue: {
|
|
296
|
+
type: [Boolean, String],
|
|
252
297
|
default: void 0
|
|
253
298
|
},
|
|
254
|
-
|
|
255
|
-
type: Boolean,
|
|
299
|
+
defaultValue: {
|
|
300
|
+
type: [Boolean, String],
|
|
256
301
|
default: false
|
|
257
302
|
},
|
|
303
|
+
id: {},
|
|
304
|
+
as: { default: "button" },
|
|
258
305
|
disabled: {
|
|
259
306
|
type: Boolean,
|
|
260
307
|
default: false
|
|
261
308
|
},
|
|
262
|
-
|
|
309
|
+
destructive: {
|
|
263
310
|
type: Boolean,
|
|
264
|
-
default:
|
|
265
|
-
},
|
|
266
|
-
target: {
|
|
267
|
-
type: [String, Object],
|
|
268
|
-
default: null
|
|
311
|
+
default: false
|
|
269
312
|
},
|
|
270
|
-
|
|
271
|
-
type:
|
|
272
|
-
default:
|
|
313
|
+
closeOnSelect: {
|
|
314
|
+
type: Boolean,
|
|
315
|
+
default: false
|
|
273
316
|
}
|
|
274
317
|
},
|
|
275
|
-
emits: ["update:
|
|
276
|
-
setup(
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const reference = computed(() => activeReference.value ?? configuredReference.value);
|
|
289
|
-
const pendingFocus = ref("first");
|
|
290
|
-
const inside = /* @__PURE__ */ new Set();
|
|
291
|
-
let returnFocusElement = null;
|
|
292
|
-
function setOpen(value) {
|
|
293
|
-
if (value && disabled.value) return;
|
|
294
|
-
const previous = isOpen.value;
|
|
295
|
-
if (props.open === void 0) uncontrolledOpen.value = value;
|
|
296
|
-
if (previous !== value) emit("update:open", value);
|
|
297
|
-
}
|
|
298
|
-
function rememberFocus() {
|
|
299
|
-
if (typeof document === "undefined" || returnFocusElement) return;
|
|
300
|
-
const activeElement = document.activeElement;
|
|
301
|
-
if (activeElement instanceof HTMLElement) returnFocusElement = activeElement;
|
|
318
|
+
emits: ["select", "update:modelValue"],
|
|
319
|
+
setup(__props, { emit: __emit }) {
|
|
320
|
+
const props = __props;
|
|
321
|
+
const emit = __emit;
|
|
322
|
+
const attrs = useAttrs();
|
|
323
|
+
const uncontrolled = ref(props.defaultValue);
|
|
324
|
+
const value = computed(() => props.modelValue ?? uncontrolled.value);
|
|
325
|
+
const checked = computed(() => value.value === "indeterminate" ? "mixed" : value.value);
|
|
326
|
+
const state = computed(() => value.value === "indeterminate" ? "indeterminate" : value.value ? "checked" : "unchecked");
|
|
327
|
+
function toggleChecked() {
|
|
328
|
+
const nextValue = value.value === "indeterminate" ? true : !value.value;
|
|
329
|
+
if (props.modelValue === void 0) uncontrolled.value = nextValue;
|
|
330
|
+
emit("update:modelValue", nextValue);
|
|
302
331
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
332
|
+
provide(checkedKey, {
|
|
333
|
+
state,
|
|
334
|
+
checked: computed(() => value.value !== false)
|
|
335
|
+
});
|
|
336
|
+
const { id, isDisabled, focused, activate, select, setElement, onPointerenter } = usePrimitiveItem("RpDropdownMenuCheckboxItem", props, (event) => emit("select", event), {
|
|
337
|
+
checked,
|
|
338
|
+
defaultCloseOnSelect: false,
|
|
339
|
+
afterSelect: toggleChecked
|
|
340
|
+
});
|
|
341
|
+
function onClick(event) {
|
|
342
|
+
if (!event.defaultPrevented) activate(event);
|
|
308
343
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
344
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
345
|
+
id: id.value,
|
|
346
|
+
type: props.as === "button" ? "button" : void 0,
|
|
347
|
+
role: "menuitemcheckbox",
|
|
348
|
+
tabindex: -1,
|
|
349
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
350
|
+
"aria-disabled": optionalAttr(isDisabled.value),
|
|
351
|
+
"aria-checked": checked.value,
|
|
352
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
353
|
+
"data-focused": optionalAttr(focused.value),
|
|
354
|
+
"data-highlighted": optionalAttr(focused.value),
|
|
355
|
+
"data-state": state.value,
|
|
356
|
+
class: bem("rp-dropdown-menu__item", {
|
|
357
|
+
focused: focused.value,
|
|
358
|
+
disabled: isDisabled.value,
|
|
359
|
+
destructive: props.destructive
|
|
360
|
+
}),
|
|
361
|
+
onClick,
|
|
362
|
+
onMouseenter: onPointerenter
|
|
363
|
+
}));
|
|
364
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
365
|
+
return createSlot("default", {
|
|
366
|
+
focused: () => unref(focused),
|
|
367
|
+
disabled: () => unref(isDisabled),
|
|
368
|
+
select: () => unref(select)
|
|
369
|
+
});
|
|
370
|
+
}, { _: 8 }), 1);
|
|
371
|
+
setTemplateRefBinding(n1, () => setElement, void 0, void 0, "setElement");
|
|
372
|
+
return n1;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/components/dropdown-menu/dropdown-menu-outside.ts
|
|
377
|
+
function isNode(value) {
|
|
378
|
+
return typeof value === "object" && value !== null && "nodeType" in value;
|
|
379
|
+
}
|
|
380
|
+
function isEventWithinElement(event, element) {
|
|
381
|
+
const path = event.composedPath();
|
|
382
|
+
if (path.length > 0) return path.some((entry) => entry === element || isNode(entry) && element.contains(entry));
|
|
383
|
+
return isNode(event.target) && element.contains(event.target);
|
|
384
|
+
}
|
|
385
|
+
function isEventWithinTargets(event, targets) {
|
|
386
|
+
for (const source of targets) {
|
|
387
|
+
const target = isRef(source) ? source.value : source;
|
|
388
|
+
if (!target) continue;
|
|
389
|
+
if (typeof target === "string") {
|
|
390
|
+
if (typeof document === "undefined") continue;
|
|
391
|
+
try {
|
|
392
|
+
if ([...document.querySelectorAll(target)].some((element) => isEventWithinElement(event, element))) return true;
|
|
393
|
+
} catch {}
|
|
394
|
+
continue;
|
|
312
395
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
396
|
+
if (isEventWithinElement(event, target)) return true;
|
|
397
|
+
}
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region src/components/dropdown-menu/useDropdownMenuPrimitiveContent.ts
|
|
402
|
+
function useDropdownMenuPrimitiveContent(props, attrs, events, submenu) {
|
|
403
|
+
const componentName = submenu ? "RpDropdownMenuSubContent" : "RpDropdownMenuContent";
|
|
404
|
+
const root = useRequiredInject(rootKey, componentName);
|
|
405
|
+
const sub = submenu ? useRequiredInject(subKey, componentName) : void 0;
|
|
406
|
+
const generatedId = useId();
|
|
407
|
+
const id = computed(() => props.id ?? `${generatedId}-${submenu ? "submenu" : "menu"}`);
|
|
408
|
+
const element = ref(null);
|
|
409
|
+
const arrowElement = ref(null);
|
|
410
|
+
const defaultPlacement = submenu ? "right-start" : "bottom-start";
|
|
411
|
+
const actualPlacement = ref(props.placement ?? defaultPlacement);
|
|
412
|
+
const isOpen = computed(() => sub ? sub.isOpen.value : root.isOpen.value);
|
|
413
|
+
const reference = computed(() => sub ? sub.trigger.value : root.reference.value);
|
|
414
|
+
const teleportPositioningKey = useTeleportPositioningKey();
|
|
415
|
+
const menu = createMenuContext({
|
|
416
|
+
root,
|
|
417
|
+
element,
|
|
418
|
+
actualPlacement,
|
|
419
|
+
parentSub: sub,
|
|
420
|
+
onEscape(event) {
|
|
421
|
+
const customEvent = createCustomEvent("dropdown-menu-escape-key-down", { originalEvent: event }, event);
|
|
422
|
+
events.escapeKeyDown(customEvent);
|
|
423
|
+
if (customEvent.defaultPrevented) return;
|
|
424
|
+
if (sub) sub.close(true);
|
|
425
|
+
else root.close({ returnFocus: true });
|
|
317
426
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
427
|
+
});
|
|
428
|
+
const floating = useFloatingPosition({
|
|
429
|
+
reference,
|
|
430
|
+
floating: element,
|
|
431
|
+
arrow: arrowElement,
|
|
432
|
+
open: isOpen,
|
|
433
|
+
placement: () => props.placement ?? defaultPlacement,
|
|
434
|
+
strategy: () => props.strategy ?? "absolute",
|
|
435
|
+
offset: () => props.offset,
|
|
436
|
+
flip: () => props.avoidCollisions !== false && props.flip !== false,
|
|
437
|
+
flipOptions: () => props.flipOptions,
|
|
438
|
+
shift: () => props.avoidCollisions !== false && props.shift !== false,
|
|
439
|
+
collisionPadding: () => props.collisionPadding ?? 8,
|
|
440
|
+
autoUpdateOptions: () => props.autoUpdateOptions,
|
|
441
|
+
restartKey: teleportPositioningKey
|
|
442
|
+
});
|
|
443
|
+
watch(floating.actualPlacement, (value) => {
|
|
444
|
+
actualPlacement.value = value;
|
|
445
|
+
}, { immediate: true });
|
|
446
|
+
const shouldRender = computed(() => props.forceMount === true || isOpen.value);
|
|
447
|
+
let layerBranchCleanup;
|
|
448
|
+
provide(menuKey, menu);
|
|
449
|
+
if (sub) sub.menu = menu;
|
|
450
|
+
function setElement(value) {
|
|
451
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
452
|
+
const previous = element.value;
|
|
453
|
+
if (previous) root.unregisterInside(previous);
|
|
454
|
+
layerBranchCleanup?.();
|
|
455
|
+
layerBranchCleanup = void 0;
|
|
456
|
+
element.value = resolved;
|
|
457
|
+
if (resolved) root.registerInside(resolved);
|
|
458
|
+
if (!sub) root.layer.element.value = resolved;
|
|
459
|
+
else if (resolved) layerBranchCleanup = root.layer.registerBranch(resolved);
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function emitOutside(type, originalEvent) {
|
|
463
|
+
const outsideEvent = createOutsideEvent(originalEvent);
|
|
464
|
+
if (type === "pointer") events.pointerDownOutside(outsideEvent);
|
|
465
|
+
else events.focusOutside(outsideEvent);
|
|
466
|
+
events.interactOutside(outsideEvent);
|
|
467
|
+
return outsideEvent;
|
|
468
|
+
}
|
|
469
|
+
function onDocumentPointer(event) {
|
|
470
|
+
if (!root.layer.isTopLayer() || root.isInside(event) || isEventWithinTargets(event, props.ignore ?? [])) return;
|
|
471
|
+
const outsideEvent = emitOutside("pointer", event);
|
|
472
|
+
if (root.modal.value) {
|
|
473
|
+
if (event.cancelable) event.preventDefault();
|
|
474
|
+
event.stopPropagation();
|
|
475
|
+
if (event.type === "pointerdown") blockNextDocumentClick();
|
|
321
476
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
477
|
+
if (!outsideEvent.defaultPrevented) root.close({ returnFocus: root.modal.value });
|
|
478
|
+
}
|
|
479
|
+
function onDocumentFocus(event) {
|
|
480
|
+
if (!root.layer.isTopLayer() || root.isInside(event) || isEventWithinTargets(event, props.ignore ?? [])) return;
|
|
481
|
+
const outsideEvent = emitOutside("focus", event);
|
|
482
|
+
if (root.modal.value) {
|
|
483
|
+
if (event.cancelable) event.preventDefault();
|
|
484
|
+
event.stopPropagation();
|
|
325
485
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
486
|
+
if (!outsideEvent.defaultPrevented) root.close({ returnFocus: root.modal.value });
|
|
487
|
+
else if (root.modal.value) nextTick(menu.focusElement);
|
|
488
|
+
}
|
|
489
|
+
function setDocumentListeners(active) {
|
|
490
|
+
if (submenu || typeof document === "undefined") return;
|
|
491
|
+
const method = active ? "addEventListener" : "removeEventListener";
|
|
492
|
+
document[method]("pointerdown", onDocumentPointer, true);
|
|
493
|
+
document[method]("focusin", onDocumentFocus, true);
|
|
494
|
+
}
|
|
495
|
+
watch(isOpen, (open) => {
|
|
496
|
+
setDocumentListeners(open);
|
|
497
|
+
if (!open) {
|
|
498
|
+
menu.activeId.value = null;
|
|
499
|
+
menu.closeSubmenus();
|
|
500
|
+
return;
|
|
331
501
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
disabled,
|
|
336
|
-
modal,
|
|
337
|
-
trigger,
|
|
338
|
-
triggerId,
|
|
339
|
-
contentId,
|
|
340
|
-
reference,
|
|
341
|
-
pendingFocus,
|
|
342
|
-
open,
|
|
343
|
-
close,
|
|
344
|
-
toggle,
|
|
345
|
-
openAt,
|
|
346
|
-
setTrigger,
|
|
347
|
-
setReference(nextReference) {
|
|
348
|
-
activeReference.value = nextReference;
|
|
349
|
-
},
|
|
350
|
-
setReturnFocus(element) {
|
|
351
|
-
returnFocusElement = element;
|
|
352
|
-
},
|
|
353
|
-
registerInside(element) {
|
|
354
|
-
inside.add(element);
|
|
355
|
-
},
|
|
356
|
-
unregisterInside(element) {
|
|
357
|
-
inside.delete(element);
|
|
358
|
-
},
|
|
359
|
-
isInside(target) {
|
|
360
|
-
return target instanceof Node && [...inside].some((element) => element.contains(target));
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
const slotProps = computed(() => ({
|
|
364
|
-
isOpen: isOpen.value,
|
|
365
|
-
open,
|
|
366
|
-
close,
|
|
367
|
-
toggle,
|
|
368
|
-
openAt
|
|
369
|
-
}));
|
|
370
|
-
watch(disabled, (value) => {
|
|
371
|
-
if (value) close();
|
|
372
|
-
});
|
|
373
|
-
watch(isOpen, (value) => {
|
|
374
|
-
if (value) addOpenLayer(context);
|
|
375
|
-
else removeOpenLayer(context);
|
|
376
|
-
}, { immediate: true });
|
|
377
|
-
onBeforeUnmount(() => removeOpenLayer(context));
|
|
378
|
-
provide(rootKey, context);
|
|
379
|
-
expose({
|
|
380
|
-
open,
|
|
381
|
-
close,
|
|
382
|
-
toggle,
|
|
383
|
-
openAt
|
|
502
|
+
nextTick(() => {
|
|
503
|
+
const focus = sub ? sub.pendingFocus.value : root.pendingFocus.value;
|
|
504
|
+
menu.focus(focus || "first");
|
|
384
505
|
});
|
|
385
|
-
|
|
506
|
+
}, {
|
|
507
|
+
flush: "post",
|
|
508
|
+
immediate: true
|
|
509
|
+
});
|
|
510
|
+
onMounted(() => {
|
|
511
|
+
if (sub) sub.contentId.value = id.value;
|
|
512
|
+
else root.contentId.value = id.value;
|
|
513
|
+
if (isOpen.value) menu.focus((sub ? sub.pendingFocus.value : root.pendingFocus.value) || "first");
|
|
514
|
+
});
|
|
515
|
+
onBeforeUnmount(() => {
|
|
516
|
+
setDocumentListeners(false);
|
|
517
|
+
layerBranchCleanup?.();
|
|
518
|
+
if (element.value) root.unregisterInside(element.value);
|
|
519
|
+
if (!sub && root.layer.element.value === element.value) root.layer.element.value = null;
|
|
520
|
+
if (sub) sub.menu = null;
|
|
521
|
+
else if (root.contentId.value === id.value) root.contentId.value = void 0;
|
|
522
|
+
});
|
|
523
|
+
const placementSide = computed(() => floating.actualPlacement.value.split("-")[0]);
|
|
524
|
+
const placementAlign = computed(() => floating.actualPlacement.value.split("-")[1] ?? "center");
|
|
525
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
526
|
+
id: id.value,
|
|
527
|
+
role: "menu",
|
|
528
|
+
tabindex: -1,
|
|
529
|
+
hidden: optionalAttr(!isOpen.value),
|
|
530
|
+
class: submenu ? bem("rp-dropdown-menu__submenu", {
|
|
531
|
+
compound: true,
|
|
532
|
+
open: isOpen.value
|
|
533
|
+
}) : bem("rp-dropdown-menu__content", {
|
|
534
|
+
compound: true,
|
|
535
|
+
open: isOpen.value
|
|
536
|
+
}),
|
|
537
|
+
style: [
|
|
538
|
+
floating.floatingStyle.value,
|
|
539
|
+
{ zIndex: root.layer.zIndex.value },
|
|
540
|
+
!isOpen.value ? { display: "none" } : void 0
|
|
541
|
+
],
|
|
542
|
+
"aria-label": props.ariaLabel,
|
|
543
|
+
"aria-labelledby": props.ariaLabelledby ?? (submenu ? void 0 : root.triggerId.value),
|
|
544
|
+
"aria-describedby": props.ariaDescribedby,
|
|
545
|
+
"aria-activedescendant": menu.activeId.value ?? void 0,
|
|
546
|
+
"data-state": isOpen.value ? "open" : "closed",
|
|
547
|
+
"data-placement": floating.actualPlacement.value,
|
|
548
|
+
"data-side": placementSide.value,
|
|
549
|
+
"data-align": placementAlign.value,
|
|
550
|
+
onKeydown: menu.onKeydown
|
|
551
|
+
}));
|
|
552
|
+
function close() {
|
|
553
|
+
if (sub) sub.close(true);
|
|
554
|
+
else root.close({ returnFocus: true });
|
|
386
555
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
556
|
+
return {
|
|
557
|
+
id,
|
|
558
|
+
element,
|
|
559
|
+
arrowElement,
|
|
560
|
+
actualPlacement,
|
|
561
|
+
isOpen,
|
|
562
|
+
shouldRender,
|
|
563
|
+
placementSide,
|
|
564
|
+
rootAttrs,
|
|
565
|
+
floating,
|
|
566
|
+
setElement,
|
|
567
|
+
close
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/components/dropdown-menu/dropdown-menu-content.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
572
|
+
var t0$3 = template("<span class=rp-dropdown-menu__arrow aria-hidden=true>");
|
|
573
|
+
//#endregion
|
|
574
|
+
//#region src/components/dropdown-menu/dropdown-menu-content.vue
|
|
575
|
+
var dropdown_menu_content_default = /* @__PURE__ */ defineVaporComponent({
|
|
576
|
+
name: "RpDropdownMenuContent",
|
|
390
577
|
inheritAttrs: false,
|
|
578
|
+
__name: "dropdown-menu-content",
|
|
391
579
|
props: {
|
|
392
|
-
id:
|
|
393
|
-
as:
|
|
394
|
-
|
|
580
|
+
id: {},
|
|
581
|
+
as: { default: "div" },
|
|
582
|
+
placement: { default: "bottom-start" },
|
|
583
|
+
offset: {},
|
|
584
|
+
strategy: { default: "absolute" },
|
|
585
|
+
flip: {
|
|
395
586
|
type: Boolean,
|
|
396
|
-
default:
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
587
|
+
default: true
|
|
588
|
+
},
|
|
589
|
+
flipOptions: {},
|
|
590
|
+
shift: {
|
|
591
|
+
type: Boolean,
|
|
592
|
+
default: true
|
|
593
|
+
},
|
|
594
|
+
collisionPadding: { default: 8 },
|
|
595
|
+
autoUpdateOptions: {},
|
|
596
|
+
arrow: {
|
|
597
|
+
type: Boolean,
|
|
598
|
+
default: false
|
|
599
|
+
},
|
|
600
|
+
avoidCollisions: {
|
|
601
|
+
type: Boolean,
|
|
602
|
+
default: true
|
|
603
|
+
},
|
|
604
|
+
forceMount: {
|
|
605
|
+
type: Boolean,
|
|
606
|
+
default: false
|
|
607
|
+
},
|
|
608
|
+
ignore: {},
|
|
609
|
+
ariaLabel: {},
|
|
610
|
+
ariaLabelledby: {},
|
|
611
|
+
ariaDescribedby: {}
|
|
612
|
+
},
|
|
613
|
+
emits: [
|
|
614
|
+
"escapeKeyDown",
|
|
615
|
+
"pointerDownOutside",
|
|
616
|
+
"focusOutside",
|
|
617
|
+
"interactOutside"
|
|
618
|
+
],
|
|
619
|
+
setup(__props, { emit: __emit }) {
|
|
620
|
+
const props = __props;
|
|
621
|
+
const emit = __emit;
|
|
622
|
+
const { arrowElement, actualPlacement, isOpen, shouldRender, placementSide, rootAttrs, floating, setElement, close } = useDropdownMenuPrimitiveContent(props, useAttrs(), {
|
|
623
|
+
escapeKeyDown: (event) => emit("escapeKeyDown", event),
|
|
624
|
+
pointerDownOutside: (event) => emit("pointerDownOutside", event),
|
|
625
|
+
focusOutside: (event) => emit("focusOutside", event),
|
|
626
|
+
interactOutside: (event) => emit("interactOutside", event)
|
|
627
|
+
}, false);
|
|
628
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
629
|
+
return createIf(() => unref(shouldRender), () => {
|
|
630
|
+
const n6 = createDynamicComponent(() => __props.as, { $: [() => unref(rootAttrs)] }, extend(() => {
|
|
631
|
+
return [createIf(() => __props.arrow, () => {
|
|
632
|
+
const n4 = t0$3();
|
|
633
|
+
_setTemplateRef(n4, arrowElement, null, "arrowElement");
|
|
634
|
+
renderEffect(() => {
|
|
635
|
+
setAttr(n4, "data-side", unref(placementSide));
|
|
636
|
+
setStyle(n4, unref(floating).arrowStyle.value);
|
|
637
|
+
});
|
|
638
|
+
return n4;
|
|
639
|
+
}, null, 129), createSlot("default", {
|
|
640
|
+
isOpen: () => unref(isOpen),
|
|
641
|
+
placement: () => unref(actualPlacement),
|
|
642
|
+
close: () => unref(close)
|
|
643
|
+
})];
|
|
644
|
+
}, { _: 8 }), 1);
|
|
645
|
+
setTemplateRefBinding(n6, () => setElement, void 0, void 0, "setElement");
|
|
646
|
+
return n6;
|
|
647
|
+
});
|
|
452
648
|
}
|
|
453
649
|
});
|
|
454
|
-
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/components/dropdown-menu/dropdown-menu-context-trigger.vue
|
|
652
|
+
var dropdown_menu_context_trigger_default = /* @__PURE__ */ defineVaporComponent({
|
|
455
653
|
name: "RpDropdownMenuContextTrigger",
|
|
456
654
|
inheritAttrs: false,
|
|
655
|
+
__name: "dropdown-menu-context-trigger",
|
|
457
656
|
props: {
|
|
458
|
-
id:
|
|
459
|
-
as:
|
|
657
|
+
id: {},
|
|
658
|
+
as: { default: "span" },
|
|
460
659
|
disabled: {
|
|
461
660
|
type: Boolean,
|
|
462
661
|
default: false
|
|
463
662
|
},
|
|
464
|
-
longPressDelay: {
|
|
465
|
-
|
|
466
|
-
default: 700
|
|
467
|
-
},
|
|
468
|
-
longPressTolerance: {
|
|
469
|
-
type: Number,
|
|
470
|
-
default: 10
|
|
471
|
-
}
|
|
663
|
+
longPressDelay: { default: 700 },
|
|
664
|
+
longPressTolerance: { default: 10 }
|
|
472
665
|
},
|
|
473
|
-
setup(
|
|
666
|
+
setup(__props) {
|
|
667
|
+
const props = __props;
|
|
668
|
+
const attrs = useAttrs();
|
|
474
669
|
const root = useRequiredInject(rootKey, "RpDropdownMenuContextTrigger");
|
|
475
670
|
const generatedId = useId();
|
|
476
671
|
const id = computed(() => props.id ?? `${generatedId}-context-trigger`);
|
|
@@ -482,11 +677,13 @@ var DropdownMenuContextTrigger = defineComponent({
|
|
|
482
677
|
let longPressOpened = false;
|
|
483
678
|
let suppressUntil = 0;
|
|
484
679
|
function setElement(value) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
680
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
681
|
+
const previous = element.value;
|
|
682
|
+
if (previous) root.unregisterInside(previous);
|
|
683
|
+
element.value = resolved;
|
|
684
|
+
if (resolved) root.registerInside(resolved);
|
|
685
|
+
if (!root.triggerId.value) root.triggerId.value = id.value;
|
|
686
|
+
});
|
|
490
687
|
}
|
|
491
688
|
function clearLongPress() {
|
|
492
689
|
if (timer) clearTimeout(timer);
|
|
@@ -550,14 +747,8 @@ var DropdownMenuContextTrigger = defineComponent({
|
|
|
550
747
|
event.preventDefault();
|
|
551
748
|
event.stopPropagation();
|
|
552
749
|
}
|
|
553
|
-
|
|
554
|
-
clearLongPress();
|
|
555
|
-
if (element.value) root.unregisterInside(element.value);
|
|
556
|
-
if (root.triggerId.value === id.value) root.triggerId.value = void 0;
|
|
557
|
-
});
|
|
558
|
-
return () => h(props.as ?? "span", mergeProps(attrs, {
|
|
750
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
559
751
|
id: id.value,
|
|
560
|
-
ref: setElement,
|
|
561
752
|
"aria-controls": root.contentId.value,
|
|
562
753
|
"aria-expanded": root.isOpen.value,
|
|
563
754
|
"aria-haspopup": "menu",
|
|
@@ -571,330 +762,29 @@ var DropdownMenuContextTrigger = defineComponent({
|
|
|
571
762
|
onPointermove,
|
|
572
763
|
onPointerup: finishPointer,
|
|
573
764
|
onPointercancel: finishPointer
|
|
574
|
-
})
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
type: [String, Object],
|
|
586
|
-
default: void 0
|
|
587
|
-
},
|
|
588
|
-
teleport: {
|
|
589
|
-
type: Boolean,
|
|
590
|
-
default: true
|
|
591
|
-
},
|
|
592
|
-
disabled: {
|
|
593
|
-
type: Boolean,
|
|
594
|
-
default: false
|
|
595
|
-
}
|
|
596
|
-
},
|
|
597
|
-
setup(props, { slots }) {
|
|
598
|
-
const teleportTo = provideTeleportTarget({ get teleportTo() {
|
|
599
|
-
return props.to ?? props.teleportTo;
|
|
600
|
-
} });
|
|
601
|
-
return () => h(Teleport, {
|
|
602
|
-
to: teleportTo.value,
|
|
603
|
-
disabled: props.disabled || !props.teleport
|
|
604
|
-
}, slots.default?.());
|
|
765
|
+
}));
|
|
766
|
+
onBeforeUnmount(() => {
|
|
767
|
+
clearLongPress();
|
|
768
|
+
if (element.value) root.unregisterInside(element.value);
|
|
769
|
+
if (root.triggerId.value === id.value) root.triggerId.value = void 0;
|
|
770
|
+
});
|
|
771
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
772
|
+
return createSlot("default", { isOpen: () => unref(root).isOpen.value });
|
|
773
|
+
}, { _: 8 }), 1);
|
|
774
|
+
setTemplateRefBinding(n1, () => setElement);
|
|
775
|
+
return n1;
|
|
605
776
|
}
|
|
606
777
|
});
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
inheritAttrs: false,
|
|
611
|
-
props: {
|
|
612
|
-
id: String,
|
|
613
|
-
as: primitiveAsProp("div"),
|
|
614
|
-
placement: {
|
|
615
|
-
type: String,
|
|
616
|
-
default: submenu ? "right-start" : "bottom-start"
|
|
617
|
-
},
|
|
618
|
-
offset: {
|
|
619
|
-
type: [Number, Object],
|
|
620
|
-
default: void 0
|
|
621
|
-
},
|
|
622
|
-
strategy: {
|
|
623
|
-
type: String,
|
|
624
|
-
default: "absolute"
|
|
625
|
-
},
|
|
626
|
-
flip: {
|
|
627
|
-
type: Boolean,
|
|
628
|
-
default: true
|
|
629
|
-
},
|
|
630
|
-
shift: {
|
|
631
|
-
type: Boolean,
|
|
632
|
-
default: true
|
|
633
|
-
},
|
|
634
|
-
collisionPadding: {
|
|
635
|
-
type: [Number, Object],
|
|
636
|
-
default: 8
|
|
637
|
-
},
|
|
638
|
-
arrow: {
|
|
639
|
-
type: Boolean,
|
|
640
|
-
default: false
|
|
641
|
-
},
|
|
642
|
-
avoidCollisions: {
|
|
643
|
-
type: Boolean,
|
|
644
|
-
default: true
|
|
645
|
-
},
|
|
646
|
-
forceMount: {
|
|
647
|
-
type: Boolean,
|
|
648
|
-
default: false
|
|
649
|
-
},
|
|
650
|
-
ariaLabel: String,
|
|
651
|
-
ariaLabelledby: String,
|
|
652
|
-
ariaDescribedby: String
|
|
653
|
-
},
|
|
654
|
-
emits: [
|
|
655
|
-
"escapeKeyDown",
|
|
656
|
-
"pointerDownOutside",
|
|
657
|
-
"focusOutside",
|
|
658
|
-
"interactOutside"
|
|
659
|
-
],
|
|
660
|
-
setup(props, { attrs, emit, slots }) {
|
|
661
|
-
const root = useRequiredInject(rootKey, submenu ? "RpDropdownMenuSubContent" : "RpDropdownMenuContent");
|
|
662
|
-
const sub = submenu ? useRequiredInject(subKey, "RpDropdownMenuSubContent") : void 0;
|
|
663
|
-
const generatedId = useId();
|
|
664
|
-
const id = computed(() => props.id ?? `${generatedId}-${submenu ? "submenu" : "menu"}`);
|
|
665
|
-
const element = ref(null);
|
|
666
|
-
const arrowElement = ref(null);
|
|
667
|
-
const actualPlacement = ref(props.placement);
|
|
668
|
-
const isOpen = computed(() => sub ? sub.isOpen.value : root.isOpen.value);
|
|
669
|
-
const reference = computed(() => sub ? sub.trigger.value : root.reference.value);
|
|
670
|
-
const teleportTo = useTeleportTarget(() => void 0);
|
|
671
|
-
const menu = createMenuContext({
|
|
672
|
-
root,
|
|
673
|
-
element,
|
|
674
|
-
actualPlacement,
|
|
675
|
-
parentSub: sub,
|
|
676
|
-
onEscape(event) {
|
|
677
|
-
const customEvent = createCustomEvent("dropdown-menu-escape-key-down", { originalEvent: event }, event);
|
|
678
|
-
emit("escapeKeyDown", customEvent);
|
|
679
|
-
if (customEvent.defaultPrevented) return;
|
|
680
|
-
if (sub) sub.close(true);
|
|
681
|
-
else root.close({ returnFocus: true });
|
|
682
|
-
}
|
|
683
|
-
});
|
|
684
|
-
const floating = useFloatingPosition({
|
|
685
|
-
reference,
|
|
686
|
-
floating: element,
|
|
687
|
-
arrow: arrowElement,
|
|
688
|
-
open: isOpen,
|
|
689
|
-
placement: () => props.placement,
|
|
690
|
-
strategy: () => props.strategy,
|
|
691
|
-
offset: () => props.offset,
|
|
692
|
-
flip: () => props.avoidCollisions !== false && props.flip,
|
|
693
|
-
shift: () => props.avoidCollisions !== false && props.shift,
|
|
694
|
-
collisionPadding: () => props.collisionPadding,
|
|
695
|
-
arrowEnabled: () => !submenu && props.arrow,
|
|
696
|
-
restartKey: () => teleportTo.value
|
|
697
|
-
});
|
|
698
|
-
watch(floating.actualPlacement, (value) => {
|
|
699
|
-
actualPlacement.value = value;
|
|
700
|
-
}, { immediate: true });
|
|
701
|
-
const shouldRender = computed(() => props.forceMount || isOpen.value);
|
|
702
|
-
provide(menuKey, menu);
|
|
703
|
-
if (sub) sub.menu = menu;
|
|
704
|
-
function setElement(value) {
|
|
705
|
-
const previous = element.value;
|
|
706
|
-
if (previous) root.unregisterInside(previous);
|
|
707
|
-
element.value = toHTMLElement(value);
|
|
708
|
-
if (element.value) root.registerInside(element.value);
|
|
709
|
-
}
|
|
710
|
-
function emitOutside(type, originalEvent) {
|
|
711
|
-
const outsideEvent = createOutsideEvent(originalEvent);
|
|
712
|
-
if (type === "pointer") emit("pointerDownOutside", outsideEvent);
|
|
713
|
-
else emit("focusOutside", outsideEvent);
|
|
714
|
-
emit("interactOutside", outsideEvent);
|
|
715
|
-
return outsideEvent;
|
|
716
|
-
}
|
|
717
|
-
function onDocumentPointer(event) {
|
|
718
|
-
if (!isTopLayer(root) || root.isInside(event.target)) return;
|
|
719
|
-
const outsideEvent = emitOutside("pointer", event);
|
|
720
|
-
if (root.modal.value) {
|
|
721
|
-
if (event.cancelable) event.preventDefault();
|
|
722
|
-
event.stopPropagation();
|
|
723
|
-
if (event.type === "pointerdown") blockNextDocumentClick();
|
|
724
|
-
}
|
|
725
|
-
if (!outsideEvent.defaultPrevented) root.close({ returnFocus: root.modal.value });
|
|
726
|
-
}
|
|
727
|
-
function onDocumentFocus(event) {
|
|
728
|
-
if (!isTopLayer(root) || root.isInside(event.target)) return;
|
|
729
|
-
const outsideEvent = emitOutside("focus", event);
|
|
730
|
-
if (root.modal.value) {
|
|
731
|
-
if (event.cancelable) event.preventDefault();
|
|
732
|
-
event.stopPropagation();
|
|
733
|
-
}
|
|
734
|
-
if (!outsideEvent.defaultPrevented) root.close({ returnFocus: root.modal.value });
|
|
735
|
-
else if (root.modal.value) nextTick(menu.focusElement);
|
|
736
|
-
}
|
|
737
|
-
function setDocumentListeners(active) {
|
|
738
|
-
if (submenu || typeof document === "undefined") return;
|
|
739
|
-
const method = active ? "addEventListener" : "removeEventListener";
|
|
740
|
-
document[method]("pointerdown", onDocumentPointer, true);
|
|
741
|
-
document[method]("click", onDocumentPointer, true);
|
|
742
|
-
document[method]("focusin", onDocumentFocus, true);
|
|
743
|
-
}
|
|
744
|
-
watch(isOpen, (open) => {
|
|
745
|
-
setDocumentListeners(open);
|
|
746
|
-
if (!open) {
|
|
747
|
-
menu.activeId.value = null;
|
|
748
|
-
menu.closeSubmenus();
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
nextTick(() => {
|
|
752
|
-
const focus = sub ? sub.pendingFocus.value : root.pendingFocus.value;
|
|
753
|
-
menu.focus(focus || "first");
|
|
754
|
-
});
|
|
755
|
-
}, {
|
|
756
|
-
flush: "post",
|
|
757
|
-
immediate: true
|
|
758
|
-
});
|
|
759
|
-
onMounted(() => {
|
|
760
|
-
if (sub) sub.contentId.value = id.value;
|
|
761
|
-
else root.contentId.value = id.value;
|
|
762
|
-
if (isOpen.value) menu.focus((sub ? sub.pendingFocus.value : root.pendingFocus.value) || "first");
|
|
763
|
-
});
|
|
764
|
-
onBeforeUnmount(() => {
|
|
765
|
-
setDocumentListeners(false);
|
|
766
|
-
if (element.value) root.unregisterInside(element.value);
|
|
767
|
-
if (sub) sub.menu = null;
|
|
768
|
-
else if (root.contentId.value === id.value) root.contentId.value = void 0;
|
|
769
|
-
});
|
|
770
|
-
return () => {
|
|
771
|
-
if (!shouldRender.value) return null;
|
|
772
|
-
const placement = floating.actualPlacement.value.split("-");
|
|
773
|
-
const className = submenu ? bem("rp-dropdown-menu__submenu", {
|
|
774
|
-
compound: true,
|
|
775
|
-
open: isOpen.value
|
|
776
|
-
}) : bem("rp-dropdown-menu__content", {
|
|
777
|
-
compound: true,
|
|
778
|
-
open: isOpen.value
|
|
779
|
-
});
|
|
780
|
-
return h(props.as ?? "div", mergeProps(attrs, {
|
|
781
|
-
id: id.value,
|
|
782
|
-
ref: setElement,
|
|
783
|
-
role: "menu",
|
|
784
|
-
tabindex: -1,
|
|
785
|
-
hidden: optionalAttr(!isOpen.value),
|
|
786
|
-
class: className,
|
|
787
|
-
style: [floating.floatingStyle.value, !isOpen.value ? { display: "none" } : void 0],
|
|
788
|
-
"aria-label": props.ariaLabel,
|
|
789
|
-
"aria-labelledby": props.ariaLabelledby ?? (submenu ? void 0 : root.triggerId.value),
|
|
790
|
-
"aria-describedby": props.ariaDescribedby,
|
|
791
|
-
"aria-activedescendant": menu.activeId.value ?? void 0,
|
|
792
|
-
"data-state": isOpen.value ? "open" : "closed",
|
|
793
|
-
"data-placement": floating.actualPlacement.value,
|
|
794
|
-
"data-side": placement[0],
|
|
795
|
-
"data-align": placement[1] ?? "center",
|
|
796
|
-
onKeydown: menu.onKeydown
|
|
797
|
-
}), [!submenu && props.arrow ? h("span", {
|
|
798
|
-
ref: arrowElement,
|
|
799
|
-
class: "rp-dropdown-menu__arrow",
|
|
800
|
-
"data-side": placement[0],
|
|
801
|
-
style: floating.arrowStyle.value,
|
|
802
|
-
"aria-hidden": "true"
|
|
803
|
-
}) : null, slots.default?.({
|
|
804
|
-
isOpen: isOpen.value,
|
|
805
|
-
placement: floating.actualPlacement.value,
|
|
806
|
-
close: () => sub ? sub.close(true) : root.close({ returnFocus: true })
|
|
807
|
-
})]);
|
|
808
|
-
};
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
var DropdownMenuContent = createContentComponent(false);
|
|
813
|
-
var DropdownMenuSubContent = createContentComponent(true);
|
|
814
|
-
function usePrimitiveItem(componentName, props, emit, options) {
|
|
815
|
-
const menu = useRequiredInject(menuKey, componentName);
|
|
816
|
-
const generatedId = useId();
|
|
817
|
-
const id = computed(() => props.id ?? `${generatedId}-item`);
|
|
818
|
-
const element = ref(null);
|
|
819
|
-
const isDisabled = computed(() => Boolean(menu.root.disabled.value || props.disabled));
|
|
820
|
-
const focused = computed(() => menu.isActive(id.value));
|
|
821
|
-
function activate(originalEvent) {
|
|
822
|
-
if (isDisabled.value) return;
|
|
823
|
-
const selectEvent = createSelectEvent(originalEvent, props.value);
|
|
824
|
-
emit("select", selectEvent);
|
|
825
|
-
options.afterSelect?.();
|
|
826
|
-
if (!selectEvent.defaultPrevented && (props.closeOnSelect ?? options.defaultCloseOnSelect)) menu.root.close({ returnFocus: true });
|
|
827
|
-
}
|
|
828
|
-
const registration = {
|
|
829
|
-
get id() {
|
|
830
|
-
return id.value;
|
|
831
|
-
},
|
|
832
|
-
element: () => element.value,
|
|
833
|
-
disabled: () => isDisabled.value,
|
|
834
|
-
activate
|
|
835
|
-
};
|
|
836
|
-
menu.registerItem(registration);
|
|
837
|
-
watch(id, (nextId, previousId) => {
|
|
838
|
-
menu.unregisterItem(previousId);
|
|
839
|
-
menu.registerItem(registration);
|
|
840
|
-
if (menu.activeId.value === previousId) menu.activeId.value = nextId;
|
|
841
|
-
});
|
|
842
|
-
onBeforeUnmount(() => menu.unregisterItem(id.value));
|
|
843
|
-
function setElement(value) {
|
|
844
|
-
element.value = toHTMLElement(value);
|
|
845
|
-
}
|
|
846
|
-
function onPointerenter() {
|
|
847
|
-
if (isDisabled.value) return;
|
|
848
|
-
menu.closeSubmenus();
|
|
849
|
-
menu.setActive(id.value);
|
|
850
|
-
}
|
|
851
|
-
return {
|
|
852
|
-
menu,
|
|
853
|
-
id,
|
|
854
|
-
element,
|
|
855
|
-
isDisabled,
|
|
856
|
-
focused,
|
|
857
|
-
activate,
|
|
858
|
-
setElement,
|
|
859
|
-
render(attrs, slots) {
|
|
860
|
-
const as = props.as ?? "button";
|
|
861
|
-
return h(as, mergeProps(attrs, {
|
|
862
|
-
id: id.value,
|
|
863
|
-
ref: setElement,
|
|
864
|
-
type: as === "button" ? "button" : void 0,
|
|
865
|
-
role: options.role ?? "menuitem",
|
|
866
|
-
tabindex: -1,
|
|
867
|
-
disabled: as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
868
|
-
"aria-disabled": optionalAttr(isDisabled.value),
|
|
869
|
-
"aria-checked": options.checked?.value,
|
|
870
|
-
"data-disabled": optionalAttr(isDisabled.value),
|
|
871
|
-
"data-focused": optionalAttr(focused.value),
|
|
872
|
-
"data-highlighted": optionalAttr(focused.value),
|
|
873
|
-
"data-state": options.checked ? options.checked.value === "mixed" ? "indeterminate" : options.checked.value ? "checked" : "unchecked" : void 0,
|
|
874
|
-
class: bem("rp-dropdown-menu__item", {
|
|
875
|
-
focused: focused.value,
|
|
876
|
-
disabled: isDisabled.value,
|
|
877
|
-
destructive: props.destructive
|
|
878
|
-
}),
|
|
879
|
-
onClick: (event) => {
|
|
880
|
-
if (!event.defaultPrevented) activate(event);
|
|
881
|
-
},
|
|
882
|
-
onMouseenter: onPointerenter
|
|
883
|
-
}), slots.default?.({
|
|
884
|
-
focused: focused.value,
|
|
885
|
-
disabled: isDisabled.value,
|
|
886
|
-
select: () => activate(new Event("select"))
|
|
887
|
-
}));
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
var DropdownMenuItem$1 = defineComponent({
|
|
778
|
+
//#endregion
|
|
779
|
+
//#region src/components/dropdown-menu/dropdown-menu-item.vue
|
|
780
|
+
var dropdown_menu_item_default = /* @__PURE__ */ defineVaporComponent({
|
|
892
781
|
name: "RpDropdownMenuItem",
|
|
893
782
|
inheritAttrs: false,
|
|
783
|
+
__name: "dropdown-menu-item",
|
|
894
784
|
props: {
|
|
895
|
-
id:
|
|
896
|
-
as:
|
|
897
|
-
value:
|
|
785
|
+
id: {},
|
|
786
|
+
as: { default: "button" },
|
|
787
|
+
value: {},
|
|
898
788
|
disabled: {
|
|
899
789
|
type: Boolean,
|
|
900
790
|
default: false
|
|
@@ -909,119 +799,147 @@ var DropdownMenuItem$1 = defineComponent({
|
|
|
909
799
|
}
|
|
910
800
|
},
|
|
911
801
|
emits: ["select"],
|
|
912
|
-
setup(
|
|
913
|
-
const
|
|
914
|
-
|
|
802
|
+
setup(__props, { emit: __emit }) {
|
|
803
|
+
const props = __props;
|
|
804
|
+
const emit = __emit;
|
|
805
|
+
const attrs = useAttrs();
|
|
806
|
+
const { id, isDisabled, focused, activate, select, setElement, onPointerenter } = usePrimitiveItem("RpDropdownMenuItem", props, (event) => emit("select", event), { defaultCloseOnSelect: true });
|
|
807
|
+
function onClick(event) {
|
|
808
|
+
if (!event.defaultPrevented) activate(event);
|
|
809
|
+
}
|
|
810
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
811
|
+
id: id.value,
|
|
812
|
+
type: props.as === "button" ? "button" : void 0,
|
|
813
|
+
role: "menuitem",
|
|
814
|
+
tabindex: -1,
|
|
815
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
816
|
+
"aria-disabled": optionalAttr(isDisabled.value),
|
|
817
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
818
|
+
"data-focused": optionalAttr(focused.value),
|
|
819
|
+
"data-highlighted": optionalAttr(focused.value),
|
|
820
|
+
class: bem("rp-dropdown-menu__item", {
|
|
821
|
+
focused: focused.value,
|
|
822
|
+
disabled: isDisabled.value,
|
|
823
|
+
destructive: props.destructive
|
|
824
|
+
}),
|
|
825
|
+
onClick,
|
|
826
|
+
onMouseenter: onPointerenter
|
|
827
|
+
}));
|
|
828
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
829
|
+
return createSlot("default", {
|
|
830
|
+
focused: () => unref(focused),
|
|
831
|
+
disabled: () => unref(isDisabled),
|
|
832
|
+
select: () => unref(select)
|
|
833
|
+
});
|
|
834
|
+
}, { _: 8 }), 1);
|
|
835
|
+
setTemplateRefBinding(n1, () => setElement, void 0, void 0, "setElement");
|
|
836
|
+
return n1;
|
|
915
837
|
}
|
|
916
838
|
});
|
|
917
|
-
|
|
918
|
-
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region src/components/dropdown-menu/dropdown-menu-item-indicator.vue
|
|
841
|
+
var dropdown_menu_item_indicator_default = /* @__PURE__ */ defineVaporComponent({
|
|
842
|
+
name: "RpDropdownMenuItemIndicator",
|
|
919
843
|
inheritAttrs: false,
|
|
844
|
+
__name: "dropdown-menu-item-indicator",
|
|
920
845
|
props: {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
default: "horizontal"
|
|
846
|
+
as: { default: "span" },
|
|
847
|
+
forceMount: {
|
|
848
|
+
type: Boolean,
|
|
849
|
+
default: false
|
|
926
850
|
}
|
|
927
851
|
},
|
|
928
|
-
setup(
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
"
|
|
934
|
-
|
|
935
|
-
"data-orientation": props.orientation
|
|
852
|
+
setup(__props) {
|
|
853
|
+
const attrs = useAttrs();
|
|
854
|
+
const context = useRequiredInject(checkedKey, "RpDropdownMenuItemIndicator");
|
|
855
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
856
|
+
class: "rp-dropdown-menu__indicator",
|
|
857
|
+
"data-state": context.state.value,
|
|
858
|
+
"aria-hidden": true
|
|
936
859
|
}));
|
|
860
|
+
return createIf(() => __props.forceMount || unref(context).checked.value, () => {
|
|
861
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
862
|
+
return createSlot("default", {
|
|
863
|
+
state: () => unref(context).state.value,
|
|
864
|
+
checked: () => unref(context).checked.value
|
|
865
|
+
});
|
|
866
|
+
}, { _: 8 }), 1);
|
|
867
|
+
});
|
|
937
868
|
}
|
|
938
869
|
});
|
|
939
|
-
|
|
870
|
+
//#endregion
|
|
871
|
+
//#region src/components/dropdown-menu/dropdown-menu-label.vue
|
|
872
|
+
var dropdown_menu_label_default = /* @__PURE__ */ defineVaporComponent({
|
|
940
873
|
name: "RpDropdownMenuLabel",
|
|
941
874
|
inheritAttrs: false,
|
|
875
|
+
__name: "dropdown-menu-label",
|
|
942
876
|
props: {
|
|
943
|
-
id:
|
|
944
|
-
as:
|
|
877
|
+
id: {},
|
|
878
|
+
as: { default: "div" }
|
|
945
879
|
},
|
|
946
|
-
setup(
|
|
880
|
+
setup(__props) {
|
|
881
|
+
const props = __props;
|
|
882
|
+
const attrs = useAttrs();
|
|
947
883
|
useRequiredInject(menuKey, "RpDropdownMenuLabel");
|
|
948
|
-
|
|
884
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
949
885
|
id: props.id,
|
|
950
886
|
role: "presentation",
|
|
951
887
|
class: "rp-dropdown-menu__group-label"
|
|
952
|
-
})
|
|
888
|
+
}));
|
|
889
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
890
|
+
return createSlot();
|
|
891
|
+
}, { _: 8 }), 1);
|
|
953
892
|
}
|
|
954
893
|
});
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region src/components/dropdown-menu/dropdown-menu-portal.vue
|
|
896
|
+
var dropdown_menu_portal_default = /* @__PURE__ */ defineVaporComponent({
|
|
897
|
+
name: "RpDropdownMenuPortal",
|
|
898
|
+
__name: "dropdown-menu-portal",
|
|
958
899
|
props: {
|
|
959
|
-
|
|
960
|
-
as: primitiveAsProp("button"),
|
|
961
|
-
modelValue: {
|
|
962
|
-
type: [Boolean, String],
|
|
963
|
-
default: void 0
|
|
964
|
-
},
|
|
965
|
-
defaultValue: {
|
|
966
|
-
type: [Boolean, String],
|
|
967
|
-
default: false
|
|
968
|
-
},
|
|
900
|
+
to: { default: void 0 },
|
|
969
901
|
disabled: {
|
|
970
902
|
type: Boolean,
|
|
971
903
|
default: false
|
|
972
904
|
},
|
|
973
|
-
|
|
905
|
+
teleport: {
|
|
974
906
|
type: Boolean,
|
|
975
|
-
default:
|
|
907
|
+
default: true
|
|
976
908
|
},
|
|
977
|
-
|
|
978
|
-
type: Boolean,
|
|
979
|
-
default: false
|
|
980
|
-
}
|
|
909
|
+
teleportTo: { default: void 0 }
|
|
981
910
|
},
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
}
|
|
993
|
-
provide(checkedKey, {
|
|
994
|
-
state,
|
|
995
|
-
checked: computed(() => value.value !== false)
|
|
996
|
-
});
|
|
997
|
-
const item = usePrimitiveItem("RpDropdownMenuCheckboxItem", props, emit, {
|
|
998
|
-
role: "menuitemcheckbox",
|
|
999
|
-
checked,
|
|
1000
|
-
defaultCloseOnSelect: false,
|
|
1001
|
-
afterSelect: toggleChecked
|
|
1002
|
-
});
|
|
1003
|
-
return () => item.render(attrs, slots);
|
|
911
|
+
setup(__props) {
|
|
912
|
+
const props = __props;
|
|
913
|
+
const teleportTo = provideTeleportTarget({ get teleportTo() {
|
|
914
|
+
return props.to ?? props.teleportTo;
|
|
915
|
+
} }, () => Boolean(props.teleport && !props.disabled));
|
|
916
|
+
return createComponent(VaporTeleport, {
|
|
917
|
+
to: () => unref(teleportTo),
|
|
918
|
+
disabled: () => __props.disabled || !__props.teleport
|
|
919
|
+
}, extend(() => {
|
|
920
|
+
return createSlot();
|
|
921
|
+
}, { _: 8 }), true);
|
|
1004
922
|
}
|
|
1005
923
|
});
|
|
1006
|
-
|
|
924
|
+
//#endregion
|
|
925
|
+
//#region src/components/dropdown-menu/dropdown-menu-radio-group.vue
|
|
926
|
+
var dropdown_menu_radio_group_default = /* @__PURE__ */ defineVaporComponent({
|
|
1007
927
|
name: "RpDropdownMenuRadioGroup",
|
|
1008
928
|
inheritAttrs: false,
|
|
929
|
+
__name: "dropdown-menu-radio-group",
|
|
1009
930
|
props: {
|
|
1010
|
-
id:
|
|
1011
|
-
as:
|
|
1012
|
-
modelValue: {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1016
|
-
defaultValue: {
|
|
1017
|
-
type: [String, Number],
|
|
1018
|
-
default: null
|
|
1019
|
-
},
|
|
1020
|
-
ariaLabel: String,
|
|
1021
|
-
ariaLabelledby: String
|
|
931
|
+
id: {},
|
|
932
|
+
as: { default: "div" },
|
|
933
|
+
modelValue: { default: void 0 },
|
|
934
|
+
defaultValue: { default: null },
|
|
935
|
+
ariaLabel: {},
|
|
936
|
+
ariaLabelledby: {}
|
|
1022
937
|
},
|
|
1023
938
|
emits: ["update:modelValue"],
|
|
1024
|
-
setup(
|
|
939
|
+
setup(__props, { emit: __emit }) {
|
|
940
|
+
const props = __props;
|
|
941
|
+
const emit = __emit;
|
|
942
|
+
const attrs = useAttrs();
|
|
1025
943
|
useRequiredInject(menuKey, "RpDropdownMenuRadioGroup");
|
|
1026
944
|
const uncontrolled = ref(props.defaultValue);
|
|
1027
945
|
const value = computed(() => props.modelValue === void 0 ? uncontrolled.value : props.modelValue);
|
|
@@ -1034,25 +952,28 @@ var DropdownMenuRadioGroup = defineComponent({
|
|
|
1034
952
|
value,
|
|
1035
953
|
select
|
|
1036
954
|
});
|
|
1037
|
-
|
|
955
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1038
956
|
id: props.id,
|
|
1039
957
|
role: "group",
|
|
1040
958
|
class: "rp-dropdown-menu__radio-group",
|
|
1041
959
|
"aria-label": props.ariaLabel,
|
|
1042
960
|
"aria-labelledby": props.ariaLabelledby
|
|
1043
|
-
})
|
|
961
|
+
}));
|
|
962
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
963
|
+
return createSlot("default", { value: () => value.value });
|
|
964
|
+
}, { _: 8 }), 1);
|
|
1044
965
|
}
|
|
1045
966
|
});
|
|
1046
|
-
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/components/dropdown-menu/dropdown-menu-radio-item.vue
|
|
969
|
+
var dropdown_menu_radio_item_default = /* @__PURE__ */ defineVaporComponent({
|
|
1047
970
|
name: "RpDropdownMenuRadioItem",
|
|
1048
971
|
inheritAttrs: false,
|
|
972
|
+
__name: "dropdown-menu-radio-item",
|
|
1049
973
|
props: {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
type: [String, Number],
|
|
1054
|
-
required: true
|
|
1055
|
-
},
|
|
974
|
+
value: {},
|
|
975
|
+
id: {},
|
|
976
|
+
as: { default: "button" },
|
|
1056
977
|
disabled: {
|
|
1057
978
|
type: Boolean,
|
|
1058
979
|
default: false
|
|
@@ -1065,52 +986,235 @@ var DropdownMenuRadioItem = defineComponent({
|
|
|
1065
986
|
type: Boolean,
|
|
1066
987
|
default: false
|
|
1067
988
|
}
|
|
1068
|
-
},
|
|
1069
|
-
emits: ["select"],
|
|
1070
|
-
setup(
|
|
1071
|
-
const
|
|
1072
|
-
const
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
989
|
+
},
|
|
990
|
+
emits: ["select"],
|
|
991
|
+
setup(__props, { emit: __emit }) {
|
|
992
|
+
const props = __props;
|
|
993
|
+
const emit = __emit;
|
|
994
|
+
const attrs = useAttrs();
|
|
995
|
+
const group = useRequiredInject(radioGroupKey, "RpDropdownMenuRadioItem");
|
|
996
|
+
const isChecked = computed(() => group.value.value === props.value);
|
|
997
|
+
const checked = computed(() => isChecked.value);
|
|
998
|
+
const state = computed(() => isChecked.value ? "checked" : "unchecked");
|
|
999
|
+
provide(checkedKey, {
|
|
1000
|
+
state,
|
|
1001
|
+
checked: isChecked
|
|
1002
|
+
});
|
|
1003
|
+
const { id, isDisabled, focused, activate, select, setElement, onPointerenter } = usePrimitiveItem("RpDropdownMenuRadioItem", props, (event) => emit("select", event), {
|
|
1004
|
+
checked,
|
|
1005
|
+
defaultCloseOnSelect: false,
|
|
1006
|
+
afterSelect: () => group.select(props.value)
|
|
1007
|
+
});
|
|
1008
|
+
function onClick(event) {
|
|
1009
|
+
if (!event.defaultPrevented) activate(event);
|
|
1010
|
+
}
|
|
1011
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1012
|
+
id: id.value,
|
|
1013
|
+
type: props.as === "button" ? "button" : void 0,
|
|
1014
|
+
role: "menuitemradio",
|
|
1015
|
+
tabindex: -1,
|
|
1016
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
1017
|
+
"aria-disabled": optionalAttr(isDisabled.value),
|
|
1018
|
+
"aria-checked": checked.value,
|
|
1019
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
1020
|
+
"data-focused": optionalAttr(focused.value),
|
|
1021
|
+
"data-highlighted": optionalAttr(focused.value),
|
|
1022
|
+
"data-state": state.value,
|
|
1023
|
+
class: bem("rp-dropdown-menu__item", {
|
|
1024
|
+
focused: focused.value,
|
|
1025
|
+
disabled: isDisabled.value,
|
|
1026
|
+
destructive: props.destructive
|
|
1027
|
+
}),
|
|
1028
|
+
onClick,
|
|
1029
|
+
onMouseenter: onPointerenter
|
|
1030
|
+
}));
|
|
1031
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
1032
|
+
return createSlot("default", {
|
|
1033
|
+
focused: () => unref(focused),
|
|
1034
|
+
disabled: () => unref(isDisabled),
|
|
1035
|
+
select: () => unref(select)
|
|
1036
|
+
});
|
|
1037
|
+
}, { _: 8 }), 1);
|
|
1038
|
+
setTemplateRefBinding(n1, () => setElement, void 0, void 0, "setElement");
|
|
1039
|
+
return n1;
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
//#endregion
|
|
1043
|
+
//#region src/components/dropdown-menu/dropdown-menu-root.vue
|
|
1044
|
+
var dropdown_menu_root_default = /* @__PURE__ */ defineVaporComponent({
|
|
1045
|
+
name: "RpDropdownMenuRoot",
|
|
1046
|
+
__name: "dropdown-menu-root",
|
|
1047
|
+
props: {
|
|
1048
|
+
id: {},
|
|
1049
|
+
open: {
|
|
1050
|
+
type: Boolean,
|
|
1051
|
+
default: void 0
|
|
1052
|
+
},
|
|
1053
|
+
defaultOpen: {
|
|
1054
|
+
type: Boolean,
|
|
1055
|
+
default: false
|
|
1056
|
+
},
|
|
1057
|
+
disabled: {
|
|
1058
|
+
type: Boolean,
|
|
1059
|
+
default: false
|
|
1060
|
+
},
|
|
1061
|
+
modal: {
|
|
1062
|
+
type: Boolean,
|
|
1063
|
+
default: true
|
|
1064
|
+
},
|
|
1065
|
+
target: { default: null },
|
|
1066
|
+
virtualAnchor: { default: null }
|
|
1067
|
+
},
|
|
1068
|
+
emits: ["update:open"],
|
|
1069
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1070
|
+
const props = __props;
|
|
1071
|
+
const emit = __emit;
|
|
1072
|
+
const generatedId = useId();
|
|
1073
|
+
const id = computed(() => props.id ?? `${generatedId}-dropdown-menu`);
|
|
1074
|
+
const uncontrolledOpen = ref(props.defaultOpen);
|
|
1075
|
+
const isOpen = computed(() => props.open ?? uncontrolledOpen.value);
|
|
1076
|
+
const disabled = computed(() => props.disabled);
|
|
1077
|
+
const modal = computed(() => props.modal);
|
|
1078
|
+
const trigger = ref(null);
|
|
1079
|
+
const triggerId = ref();
|
|
1080
|
+
const contentId = ref();
|
|
1081
|
+
const activeReference = shallowRef(null);
|
|
1082
|
+
const { reference: configuredReference } = useFloatingTarget(() => props.target ?? props.virtualAnchor, trigger);
|
|
1083
|
+
const reference = computed(() => activeReference.value ?? configuredReference.value);
|
|
1084
|
+
const pendingFocus = ref("first");
|
|
1085
|
+
const contentElement = ref(null);
|
|
1086
|
+
const inside = /* @__PURE__ */ new Set();
|
|
1087
|
+
let returnFocusElement = null;
|
|
1088
|
+
const layer = useOverlayLayer({
|
|
1089
|
+
active: computed(() => isOpen.value && !disabled.value),
|
|
1090
|
+
element: contentElement,
|
|
1091
|
+
baseZIndex: 100
|
|
1092
|
+
});
|
|
1093
|
+
function setOpen(value) {
|
|
1094
|
+
if (value && disabled.value) return;
|
|
1095
|
+
const previous = isOpen.value;
|
|
1096
|
+
if (props.open === void 0) uncontrolledOpen.value = value;
|
|
1097
|
+
if (previous !== value) emit("update:open", value);
|
|
1098
|
+
}
|
|
1099
|
+
function rememberFocus() {
|
|
1100
|
+
if (typeof document === "undefined" || returnFocusElement) return;
|
|
1101
|
+
const activeElement = document.activeElement;
|
|
1102
|
+
if (activeElement instanceof HTMLElement) returnFocusElement = activeElement;
|
|
1103
|
+
}
|
|
1104
|
+
function open(options) {
|
|
1105
|
+
if (disabled.value) return;
|
|
1106
|
+
rememberFocus();
|
|
1107
|
+
pendingFocus.value = getFocusTarget(options);
|
|
1108
|
+
setOpen(true);
|
|
1109
|
+
}
|
|
1110
|
+
function focusReturnTarget() {
|
|
1111
|
+
const target = returnFocusElement ?? trigger.value;
|
|
1112
|
+
nextTick(() => target?.focus());
|
|
1113
|
+
}
|
|
1114
|
+
function close(options = {}) {
|
|
1115
|
+
setOpen(false);
|
|
1116
|
+
pendingFocus.value = false;
|
|
1117
|
+
if (options.focusTrigger || options.returnFocus) focusReturnTarget();
|
|
1118
|
+
}
|
|
1119
|
+
function toggle() {
|
|
1120
|
+
if (isOpen.value) close({ returnFocus: true });
|
|
1121
|
+
else open();
|
|
1122
|
+
}
|
|
1123
|
+
function openAt(point, options) {
|
|
1124
|
+
activeReference.value = createVirtualAnchor(point);
|
|
1125
|
+
open(options);
|
|
1126
|
+
}
|
|
1127
|
+
function setTrigger(element, nextId) {
|
|
1128
|
+
if (trigger.value && trigger.value !== element) inside.delete(trigger.value);
|
|
1129
|
+
trigger.value = element;
|
|
1130
|
+
triggerId.value = nextId;
|
|
1131
|
+
if (element) inside.add(element);
|
|
1132
|
+
}
|
|
1133
|
+
const context = {
|
|
1134
|
+
id,
|
|
1135
|
+
isOpen,
|
|
1136
|
+
disabled,
|
|
1137
|
+
modal,
|
|
1138
|
+
trigger,
|
|
1139
|
+
triggerId,
|
|
1140
|
+
contentId,
|
|
1141
|
+
reference,
|
|
1142
|
+
pendingFocus,
|
|
1143
|
+
layer,
|
|
1144
|
+
open,
|
|
1145
|
+
close,
|
|
1146
|
+
toggle,
|
|
1147
|
+
openAt,
|
|
1148
|
+
setTrigger,
|
|
1149
|
+
setReference(nextReference) {
|
|
1150
|
+
activeReference.value = nextReference;
|
|
1151
|
+
},
|
|
1152
|
+
setReturnFocus(element) {
|
|
1153
|
+
returnFocusElement = element;
|
|
1154
|
+
},
|
|
1155
|
+
registerInside(element) {
|
|
1156
|
+
inside.add(element);
|
|
1157
|
+
},
|
|
1158
|
+
unregisterInside(element) {
|
|
1159
|
+
inside.delete(element);
|
|
1160
|
+
},
|
|
1161
|
+
isInside(event) {
|
|
1162
|
+
return [...inside].some((element) => isEventWithinElement(event, element));
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
const slotProps = computed(() => ({
|
|
1166
|
+
isOpen: isOpen.value,
|
|
1167
|
+
open,
|
|
1168
|
+
close,
|
|
1169
|
+
toggle,
|
|
1170
|
+
openAt
|
|
1171
|
+
}));
|
|
1172
|
+
watch(disabled, (value) => {
|
|
1173
|
+
if (value) close();
|
|
1077
1174
|
});
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1175
|
+
watch(isOpen, (value) => {
|
|
1176
|
+
if (!value) activeReference.value = null;
|
|
1177
|
+
}, { flush: "sync" });
|
|
1178
|
+
provide(rootKey, context);
|
|
1179
|
+
__expose({
|
|
1180
|
+
open,
|
|
1181
|
+
close,
|
|
1182
|
+
toggle,
|
|
1183
|
+
openAt
|
|
1083
1184
|
});
|
|
1084
|
-
return () =>
|
|
1185
|
+
return createSlot("default", { $: [() => slotProps.value] });
|
|
1085
1186
|
}
|
|
1086
1187
|
});
|
|
1087
|
-
|
|
1088
|
-
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region src/components/dropdown-menu/dropdown-menu-separator.vue
|
|
1190
|
+
var dropdown_menu_separator_default = /* @__PURE__ */ defineVaporComponent({
|
|
1191
|
+
name: "RpDropdownMenuSeparator",
|
|
1089
1192
|
inheritAttrs: false,
|
|
1193
|
+
__name: "dropdown-menu-separator",
|
|
1090
1194
|
props: {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
default: false
|
|
1095
|
-
}
|
|
1195
|
+
id: {},
|
|
1196
|
+
as: { default: "div" },
|
|
1197
|
+
orientation: { default: "horizontal" }
|
|
1096
1198
|
},
|
|
1097
|
-
setup(
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
};
|
|
1199
|
+
setup(__props) {
|
|
1200
|
+
const props = __props;
|
|
1201
|
+
const attrs = useAttrs();
|
|
1202
|
+
useRequiredInject(menuKey, "RpDropdownMenuSeparator");
|
|
1203
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1204
|
+
id: props.id,
|
|
1205
|
+
role: "separator",
|
|
1206
|
+
"aria-orientation": props.orientation,
|
|
1207
|
+
class: "rp-dropdown-menu__separator",
|
|
1208
|
+
"data-orientation": props.orientation
|
|
1209
|
+
}));
|
|
1210
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, null, 1);
|
|
1110
1211
|
}
|
|
1111
1212
|
});
|
|
1112
|
-
|
|
1213
|
+
//#endregion
|
|
1214
|
+
//#region src/components/dropdown-menu/dropdown-menu-sub.vue
|
|
1215
|
+
var dropdown_menu_sub_default = /* @__PURE__ */ defineVaporComponent({
|
|
1113
1216
|
name: "RpDropdownMenuSub",
|
|
1217
|
+
__name: "dropdown-menu-sub",
|
|
1114
1218
|
props: {
|
|
1115
1219
|
open: {
|
|
1116
1220
|
type: Boolean,
|
|
@@ -1122,7 +1226,9 @@ var DropdownMenuSub = defineComponent({
|
|
|
1122
1226
|
}
|
|
1123
1227
|
},
|
|
1124
1228
|
emits: ["update:open"],
|
|
1125
|
-
setup(
|
|
1229
|
+
setup(__props, { emit: __emit }) {
|
|
1230
|
+
const props = __props;
|
|
1231
|
+
const emit = __emit;
|
|
1126
1232
|
const parentMenu = useRequiredInject(menuKey, "RpDropdownMenuSub");
|
|
1127
1233
|
const uncontrolled = ref(props.defaultOpen);
|
|
1128
1234
|
const isOpen = computed(() => props.open ?? uncontrolled.value);
|
|
@@ -1164,25 +1270,93 @@ var DropdownMenuSub = defineComponent({
|
|
|
1164
1270
|
if (!open) context.close(false);
|
|
1165
1271
|
});
|
|
1166
1272
|
onBeforeUnmount(() => parentMenu.unregisterSub(context));
|
|
1167
|
-
return (
|
|
1168
|
-
isOpen: isOpen.value,
|
|
1169
|
-
open: context.open,
|
|
1170
|
-
close: context.close
|
|
1273
|
+
return createSlot("default", {
|
|
1274
|
+
isOpen: () => isOpen.value,
|
|
1275
|
+
open: () => context.open,
|
|
1276
|
+
close: () => context.close
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region src/components/dropdown-menu/dropdown-menu-sub-content.vue
|
|
1282
|
+
var dropdown_menu_sub_content_default = /* @__PURE__ */ defineVaporComponent({
|
|
1283
|
+
name: "RpDropdownMenuSubContent",
|
|
1284
|
+
inheritAttrs: false,
|
|
1285
|
+
__name: "dropdown-menu-sub-content",
|
|
1286
|
+
props: {
|
|
1287
|
+
placement: { default: "right-start" },
|
|
1288
|
+
id: {},
|
|
1289
|
+
as: { default: "div" },
|
|
1290
|
+
offset: {},
|
|
1291
|
+
strategy: { default: "absolute" },
|
|
1292
|
+
flip: {
|
|
1293
|
+
type: Boolean,
|
|
1294
|
+
default: true
|
|
1295
|
+
},
|
|
1296
|
+
flipOptions: {},
|
|
1297
|
+
shift: {
|
|
1298
|
+
type: Boolean,
|
|
1299
|
+
default: true
|
|
1300
|
+
},
|
|
1301
|
+
collisionPadding: { default: 8 },
|
|
1302
|
+
autoUpdateOptions: {},
|
|
1303
|
+
avoidCollisions: {
|
|
1304
|
+
type: Boolean,
|
|
1305
|
+
default: true
|
|
1306
|
+
},
|
|
1307
|
+
forceMount: {
|
|
1308
|
+
type: Boolean,
|
|
1309
|
+
default: false
|
|
1310
|
+
},
|
|
1311
|
+
ariaLabel: {},
|
|
1312
|
+
ariaLabelledby: {},
|
|
1313
|
+
ariaDescribedby: {}
|
|
1314
|
+
},
|
|
1315
|
+
emits: [
|
|
1316
|
+
"escapeKeyDown",
|
|
1317
|
+
"pointerDownOutside",
|
|
1318
|
+
"focusOutside",
|
|
1319
|
+
"interactOutside"
|
|
1320
|
+
],
|
|
1321
|
+
setup(__props, { emit: __emit }) {
|
|
1322
|
+
const props = __props;
|
|
1323
|
+
const emit = __emit;
|
|
1324
|
+
const { actualPlacement, isOpen, shouldRender, rootAttrs, setElement, close } = useDropdownMenuPrimitiveContent(props, useAttrs(), {
|
|
1325
|
+
escapeKeyDown: (event) => emit("escapeKeyDown", event),
|
|
1326
|
+
pointerDownOutside: (event) => emit("pointerDownOutside", event),
|
|
1327
|
+
focusOutside: (event) => emit("focusOutside", event),
|
|
1328
|
+
interactOutside: (event) => emit("interactOutside", event)
|
|
1329
|
+
}, true);
|
|
1330
|
+
return createIf(() => unref(shouldRender), () => {
|
|
1331
|
+
const n3 = createDynamicComponent(() => __props.as, { $: [() => unref(rootAttrs)] }, extend(() => {
|
|
1332
|
+
return createSlot("default", {
|
|
1333
|
+
isOpen: () => unref(isOpen),
|
|
1334
|
+
placement: () => unref(actualPlacement),
|
|
1335
|
+
close: () => unref(close)
|
|
1336
|
+
});
|
|
1337
|
+
}, { _: 8 }), 1);
|
|
1338
|
+
setTemplateRefBinding(n3, () => setElement, void 0, void 0, "setElement");
|
|
1339
|
+
return n3;
|
|
1171
1340
|
});
|
|
1172
1341
|
}
|
|
1173
1342
|
});
|
|
1174
|
-
|
|
1343
|
+
//#endregion
|
|
1344
|
+
//#region src/components/dropdown-menu/dropdown-menu-sub-trigger.vue
|
|
1345
|
+
var dropdown_menu_sub_trigger_default = /* @__PURE__ */ defineVaporComponent({
|
|
1175
1346
|
name: "RpDropdownMenuSubTrigger",
|
|
1176
1347
|
inheritAttrs: false,
|
|
1348
|
+
__name: "dropdown-menu-sub-trigger",
|
|
1177
1349
|
props: {
|
|
1178
|
-
id:
|
|
1179
|
-
as:
|
|
1350
|
+
id: {},
|
|
1351
|
+
as: { default: "button" },
|
|
1180
1352
|
disabled: {
|
|
1181
1353
|
type: Boolean,
|
|
1182
1354
|
default: false
|
|
1183
1355
|
}
|
|
1184
1356
|
},
|
|
1185
|
-
setup(
|
|
1357
|
+
setup(__props) {
|
|
1358
|
+
const props = __props;
|
|
1359
|
+
const attrs = useAttrs();
|
|
1186
1360
|
const menu = useRequiredInject(menuKey, "RpDropdownMenuSubTrigger");
|
|
1187
1361
|
const sub = useRequiredInject(subKey, "RpDropdownMenuSubTrigger");
|
|
1188
1362
|
const generatedId = useId();
|
|
@@ -1201,55 +1375,133 @@ var DropdownMenuSubTrigger = defineComponent({
|
|
|
1201
1375
|
menu.registerItem(registration);
|
|
1202
1376
|
onBeforeUnmount(() => menu.unregisterItem(id.value));
|
|
1203
1377
|
function setElement(value) {
|
|
1204
|
-
|
|
1378
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
1379
|
+
sub.trigger.value = resolved;
|
|
1380
|
+
});
|
|
1205
1381
|
}
|
|
1206
1382
|
function onMouseenter() {
|
|
1207
1383
|
if (isDisabled.value) return;
|
|
1208
1384
|
menu.setActive(id.value);
|
|
1209
1385
|
sub.open(false);
|
|
1210
1386
|
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
focused: focused.value,
|
|
1230
|
-
disabled: isDisabled.value,
|
|
1231
|
-
submenu: true,
|
|
1232
|
-
open: sub.isOpen.value
|
|
1233
|
-
}),
|
|
1234
|
-
onClick: (event) => {
|
|
1235
|
-
if (!event.defaultPrevented && !isDisabled.value) sub.open("first");
|
|
1236
|
-
},
|
|
1237
|
-
onMouseenter
|
|
1238
|
-
}), slots.default?.({
|
|
1387
|
+
function onClick(event) {
|
|
1388
|
+
if (!event.defaultPrevented && !isDisabled.value) sub.open("first");
|
|
1389
|
+
}
|
|
1390
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1391
|
+
id: id.value,
|
|
1392
|
+
type: props.as === "button" ? "button" : void 0,
|
|
1393
|
+
role: "menuitem",
|
|
1394
|
+
tabindex: -1,
|
|
1395
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
1396
|
+
"aria-disabled": optionalAttr(isDisabled.value),
|
|
1397
|
+
"aria-haspopup": "menu",
|
|
1398
|
+
"aria-expanded": sub.isOpen.value,
|
|
1399
|
+
"aria-controls": sub.contentId.value,
|
|
1400
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
1401
|
+
"data-focused": optionalAttr(focused.value),
|
|
1402
|
+
"data-highlighted": optionalAttr(focused.value),
|
|
1403
|
+
"data-state": sub.isOpen.value ? "open" : "closed",
|
|
1404
|
+
class: bem("rp-dropdown-menu__item", {
|
|
1239
1405
|
focused: focused.value,
|
|
1240
1406
|
disabled: isDisabled.value,
|
|
1241
|
-
|
|
1242
|
-
open: sub.
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1407
|
+
submenu: true,
|
|
1408
|
+
open: sub.isOpen.value
|
|
1409
|
+
}),
|
|
1410
|
+
onClick,
|
|
1411
|
+
onMouseenter
|
|
1412
|
+
}));
|
|
1413
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
1414
|
+
return createSlot("default", {
|
|
1415
|
+
focused: () => focused.value,
|
|
1416
|
+
disabled: () => isDisabled.value,
|
|
1417
|
+
isOpen: () => unref(sub).isOpen.value,
|
|
1418
|
+
open: () => unref(sub).open,
|
|
1419
|
+
close: () => unref(sub).close
|
|
1420
|
+
});
|
|
1421
|
+
}, { _: 8 }), 1);
|
|
1422
|
+
setTemplateRefBinding(n1, () => setElement);
|
|
1423
|
+
return n1;
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
//#endregion
|
|
1427
|
+
//#region src/components/dropdown-menu/dropdown-menu-trigger.vue
|
|
1428
|
+
var dropdown_menu_trigger_default = /* @__PURE__ */ defineVaporComponent({
|
|
1429
|
+
name: "RpDropdownMenuTrigger",
|
|
1430
|
+
inheritAttrs: false,
|
|
1431
|
+
__name: "dropdown-menu-trigger",
|
|
1432
|
+
props: {
|
|
1433
|
+
id: {},
|
|
1434
|
+
as: { default: "button" },
|
|
1435
|
+
disabled: {
|
|
1436
|
+
type: Boolean,
|
|
1437
|
+
default: false
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
setup(__props) {
|
|
1441
|
+
const props = __props;
|
|
1442
|
+
const attrs = useAttrs();
|
|
1443
|
+
const root = useRequiredInject(rootKey, "RpDropdownMenuTrigger");
|
|
1444
|
+
const generatedId = useId();
|
|
1445
|
+
const id = computed(() => props.id ?? `${generatedId}-trigger`);
|
|
1446
|
+
const element = ref(null);
|
|
1447
|
+
const isDisabled = computed(() => root.disabled.value || props.disabled);
|
|
1448
|
+
function setElement(value) {
|
|
1449
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
1450
|
+
element.value = resolved;
|
|
1451
|
+
root.setTrigger(resolved, id.value);
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
function openWithReference(focus = "first") {
|
|
1455
|
+
root.setReference(element.value);
|
|
1456
|
+
root.setReturnFocus(element.value);
|
|
1457
|
+
root.open({ focus });
|
|
1458
|
+
}
|
|
1459
|
+
function onClick(event) {
|
|
1460
|
+
if (event.defaultPrevented || isDisabled.value) return;
|
|
1461
|
+
root.setReference(element.value);
|
|
1462
|
+
root.setReturnFocus(element.value);
|
|
1463
|
+
root.toggle();
|
|
1464
|
+
}
|
|
1465
|
+
function onKeydown(event) {
|
|
1466
|
+
if (isDisabled.value) return;
|
|
1467
|
+
if (event.key === "ArrowUp") {
|
|
1468
|
+
event.preventDefault();
|
|
1469
|
+
openWithReference("last");
|
|
1470
|
+
} else if ([
|
|
1471
|
+
"Enter",
|
|
1472
|
+
" ",
|
|
1473
|
+
"ArrowDown"
|
|
1474
|
+
].includes(event.key)) {
|
|
1475
|
+
event.preventDefault();
|
|
1476
|
+
openWithReference("first");
|
|
1477
|
+
} else if (event.key === "Escape") root.close({ focusTrigger: true });
|
|
1478
|
+
}
|
|
1479
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1480
|
+
id: id.value,
|
|
1481
|
+
type: props.as === "button" ? "button" : void 0,
|
|
1482
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
1483
|
+
"aria-controls": root.contentId.value,
|
|
1484
|
+
"aria-expanded": root.isOpen.value,
|
|
1485
|
+
"aria-haspopup": "menu",
|
|
1486
|
+
"aria-disabled": props.as === "button" ? void 0 : optionalAttr(isDisabled.value),
|
|
1487
|
+
"data-state": root.isOpen.value ? "open" : "closed",
|
|
1488
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
1489
|
+
onClick,
|
|
1490
|
+
onKeydown
|
|
1491
|
+
}));
|
|
1492
|
+
onBeforeUnmount(() => root.setTrigger(null));
|
|
1493
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
1494
|
+
return createSlot("default", { isOpen: () => unref(root).isOpen.value });
|
|
1495
|
+
}, { _: 8 }), 1);
|
|
1496
|
+
setTemplateRefBinding(n1, () => setElement);
|
|
1497
|
+
return n1;
|
|
1246
1498
|
}
|
|
1247
1499
|
});
|
|
1248
1500
|
//#endregion
|
|
1249
1501
|
//#region ~icons/lucide/chevron-right
|
|
1250
|
-
var t0$
|
|
1502
|
+
var t0$2 = template("<svg viewBox=\"0 0 24 24\"width=1.2em height=1.2em><path fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2 d=\"m9 18l6-6l-6-6\">", 3, 1);
|
|
1251
1503
|
function render(_ctx) {
|
|
1252
|
-
return t0$
|
|
1504
|
+
return t0$2();
|
|
1253
1505
|
}
|
|
1254
1506
|
var chevron_right_default = markRaw(defineVaporComponent({
|
|
1255
1507
|
name: "lucide-chevron-right",
|
|
@@ -1316,170 +1568,123 @@ function getNextEnabledIndex(items, index, direction) {
|
|
|
1316
1568
|
return enabledIndexes[enabledIndexes.length - 1];
|
|
1317
1569
|
}
|
|
1318
1570
|
//#endregion
|
|
1319
|
-
//#region src/components/dropdown-menu/dropdown-menu-
|
|
1320
|
-
var
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
var
|
|
1325
|
-
type: Function,
|
|
1326
|
-
required: true
|
|
1327
|
-
};
|
|
1328
|
-
var DropdownMenuItemRow = defineComponent({
|
|
1571
|
+
//#region src/components/dropdown-menu/dropdown-menu-item-row.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
1572
|
+
var t0$1 = template("<div>");
|
|
1573
|
+
var t1$1 = template("<div class=rp-dropdown-menu__item-wrap role=none><button></button>", 1);
|
|
1574
|
+
//#endregion
|
|
1575
|
+
//#region src/components/dropdown-menu/dropdown-menu-item-row.vue
|
|
1576
|
+
var dropdown_menu_item_row_default = /* @__PURE__ */ defineVaporComponent({
|
|
1329
1577
|
name: "RpDropdownMenuItemRow",
|
|
1578
|
+
__name: "dropdown-menu-item-row",
|
|
1330
1579
|
props: {
|
|
1331
|
-
context:
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
},
|
|
1336
|
-
focused: {
|
|
1337
|
-
type: Boolean,
|
|
1338
|
-
required: true
|
|
1339
|
-
},
|
|
1340
|
-
index: {
|
|
1341
|
-
type: Number,
|
|
1342
|
-
required: true
|
|
1343
|
-
},
|
|
1344
|
-
item: {
|
|
1345
|
-
type: Object,
|
|
1346
|
-
required: true
|
|
1347
|
-
},
|
|
1348
|
-
parentPath: {
|
|
1349
|
-
type: Array,
|
|
1350
|
-
required: true
|
|
1351
|
-
},
|
|
1352
|
-
renderItem: renderItemProp,
|
|
1353
|
-
submenuOpen: {
|
|
1354
|
-
type: Boolean,
|
|
1355
|
-
required: true
|
|
1356
|
-
}
|
|
1580
|
+
context: {},
|
|
1581
|
+
index: {},
|
|
1582
|
+
item: {},
|
|
1583
|
+
parentPath: {}
|
|
1357
1584
|
},
|
|
1358
|
-
setup(
|
|
1585
|
+
setup(__props) {
|
|
1586
|
+
const props = __props;
|
|
1359
1587
|
const path = computed(() => [...props.parentPath, props.index]);
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
role: "none"
|
|
1377
|
-
}, children);
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
});
|
|
1381
|
-
var DropdownMenuItemsList = defineComponent({
|
|
1382
|
-
name: "RpDropdownMenuItemsList",
|
|
1383
|
-
props: {
|
|
1384
|
-
context: contextProp,
|
|
1385
|
-
items: {
|
|
1386
|
-
type: Array,
|
|
1387
|
-
required: true
|
|
1388
|
-
},
|
|
1389
|
-
parentPath: {
|
|
1390
|
-
type: Array,
|
|
1391
|
-
default: () => []
|
|
1392
|
-
},
|
|
1393
|
-
renderItem: renderItemProp
|
|
1394
|
-
},
|
|
1395
|
-
setup(props) {
|
|
1396
|
-
return () => props.items.map((item, index) => {
|
|
1397
|
-
const path = [...props.parentPath, index];
|
|
1398
|
-
const hasSubmenu = hasItemSubmenu(item);
|
|
1399
|
-
return h(DropdownMenuItemRow, {
|
|
1400
|
-
key: `${getPathKey(path)}:${String(item.value)}`,
|
|
1401
|
-
context: props.context,
|
|
1402
|
-
disabled: Boolean(item.disabled),
|
|
1403
|
-
focused: props.context.isItemFocused(path),
|
|
1404
|
-
index,
|
|
1405
|
-
item,
|
|
1406
|
-
parentPath: props.parentPath,
|
|
1407
|
-
renderItem: props.renderItem,
|
|
1408
|
-
submenuOpen: hasSubmenu && props.context.isSubmenuOpen(path)
|
|
1409
|
-
});
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
});
|
|
1413
|
-
var DropdownMenuSubmenu = defineComponent({
|
|
1414
|
-
name: "RpDropdownMenuSubmenu",
|
|
1415
|
-
props: {
|
|
1416
|
-
context: contextProp,
|
|
1417
|
-
item: {
|
|
1418
|
-
type: Object,
|
|
1419
|
-
required: true
|
|
1420
|
-
},
|
|
1421
|
-
path: {
|
|
1422
|
-
type: Array,
|
|
1423
|
-
required: true
|
|
1424
|
-
},
|
|
1425
|
-
renderItem: renderItemProp
|
|
1426
|
-
},
|
|
1427
|
-
setup(props) {
|
|
1428
|
-
const element = ref(null);
|
|
1429
|
-
const floating = useFloatingPosition({
|
|
1430
|
-
reference: computed(() => props.context.getItemElement(props.path)),
|
|
1431
|
-
floating: element,
|
|
1432
|
-
open: computed(() => props.context.isSubmenuOpen(props.path)),
|
|
1588
|
+
const hasSubmenu = computed(() => hasItemSubmenu(props.item));
|
|
1589
|
+
const focused = computed(() => props.context.isItemFocused(path.value));
|
|
1590
|
+
const disabled = computed(() => Boolean(props.item.disabled));
|
|
1591
|
+
const submenuOpen = computed(() => hasSubmenu.value && props.context.isSubmenuOpen(path.value));
|
|
1592
|
+
const itemProps = computed(() => props.context.getItemProps(props.item, path.value, focused.value, disabled.value, submenuOpen.value));
|
|
1593
|
+
const publicItemProps = computed(() => ({
|
|
1594
|
+
...itemProps.value,
|
|
1595
|
+
...props.context.getPublicPartAttrs?.("item", { class: itemProps.value.class })
|
|
1596
|
+
}));
|
|
1597
|
+
const slotProps = computed(() => props.context.getItemSlotProps(props.item, path.value, focused.value, disabled.value, submenuOpen.value));
|
|
1598
|
+
const itemElement = ref(null);
|
|
1599
|
+
const submenuElement = ref(null);
|
|
1600
|
+
const { actualPlacement, floatingStyle } = useFloatingPosition({
|
|
1601
|
+
reference: itemElement,
|
|
1602
|
+
floating: submenuElement,
|
|
1603
|
+
open: submenuOpen,
|
|
1433
1604
|
placement: props.context.getSubmenuPlacement,
|
|
1434
1605
|
strategy: props.context.getStrategy,
|
|
1435
1606
|
offset: () => 4,
|
|
1436
1607
|
flip: props.context.getFlip,
|
|
1608
|
+
flipOptions: props.context.getFlipOptions,
|
|
1437
1609
|
shift: props.context.getShift,
|
|
1438
1610
|
collisionPadding: props.context.getCollisionPadding,
|
|
1439
|
-
|
|
1611
|
+
autoUpdateOptions: props.context.getAutoUpdateOptions
|
|
1440
1612
|
});
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1613
|
+
const submenuProps = computed(() => props.context.getSubmenuProps(props.item, path.value, true));
|
|
1614
|
+
const publicSubmenuProps = computed(() => ({
|
|
1615
|
+
...submenuProps.value,
|
|
1616
|
+
...props.context.getPublicPartAttrs?.("submenu", {
|
|
1617
|
+
class: submenuProps.value.class,
|
|
1618
|
+
style: floatingStyle.value
|
|
1619
|
+
})
|
|
1620
|
+
}));
|
|
1621
|
+
const placementSide = computed(() => actualPlacement.value.split("-")[0]);
|
|
1622
|
+
function getChildKey(index, child) {
|
|
1623
|
+
return `${getPathKey([...path.value, index])}:${String(child.value)}`;
|
|
1624
|
+
}
|
|
1625
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
1626
|
+
const _component_DropdownMenuItemRow__self = resolveComponent("DropdownMenuItemRow", true);
|
|
1627
|
+
const n10 = t1$1();
|
|
1628
|
+
const n1 = child(n10);
|
|
1629
|
+
renderEffect(() => setDynamicProps(n1, [publicItemProps.value]));
|
|
1630
|
+
setInsertionState(n1, null, 0);
|
|
1631
|
+
createSlot("item", { $: [() => slotProps.value] });
|
|
1632
|
+
setStaticTemplateRef(n1, itemElement, null, "itemElement");
|
|
1633
|
+
setInsertionState(n10, null, 1);
|
|
1634
|
+
createIf(() => hasSubmenu.value && submenuOpen.value, () => {
|
|
1635
|
+
const n9 = t0$1();
|
|
1636
|
+
renderEffect(() => setDynamicProps(n9, [publicSubmenuProps.value, {
|
|
1450
1637
|
"data-state": "open",
|
|
1451
|
-
"data-placement":
|
|
1452
|
-
"data-side":
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1638
|
+
"data-placement": unref(actualPlacement),
|
|
1639
|
+
"data-side": placementSide.value
|
|
1640
|
+
}]));
|
|
1641
|
+
setInsertionState(n9, null, 0);
|
|
1642
|
+
createFor(() => __props.item.children ?? [], (_for_item0, _for_key0) => {
|
|
1643
|
+
return createComponentWithFallback(_component_DropdownMenuItemRow__self, {
|
|
1644
|
+
context: () => __props.context,
|
|
1645
|
+
index: () => _for_key0.value,
|
|
1646
|
+
item: () => _for_item0.value,
|
|
1647
|
+
"parent-path": () => path.value
|
|
1648
|
+
}, { "item": extend((childSlotProps) => {
|
|
1649
|
+
return createSlot("item", { $: [() => childSlotProps] });
|
|
1650
|
+
}, { _: 8 }) });
|
|
1651
|
+
}, (child, childIndex) => getChildKey(childIndex, child), 3);
|
|
1652
|
+
_setTemplateRef(n9, submenuElement, null, "submenuElement");
|
|
1653
|
+
return n9;
|
|
1654
|
+
});
|
|
1655
|
+
return n10;
|
|
1460
1656
|
}
|
|
1461
1657
|
});
|
|
1462
|
-
|
|
1658
|
+
//#endregion
|
|
1659
|
+
//#region src/components/dropdown-menu/dropdown-menu-items.vue
|
|
1660
|
+
var dropdown_menu_items_default = /* @__PURE__ */ defineVaporComponent({
|
|
1463
1661
|
name: "RpDropdownMenuItems",
|
|
1662
|
+
__name: "dropdown-menu-items",
|
|
1464
1663
|
props: {
|
|
1465
|
-
context:
|
|
1466
|
-
items: {
|
|
1467
|
-
|
|
1468
|
-
required: true
|
|
1469
|
-
}
|
|
1664
|
+
context: {},
|
|
1665
|
+
items: {},
|
|
1666
|
+
parentPath: { default: () => [] }
|
|
1470
1667
|
},
|
|
1471
|
-
setup(
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1668
|
+
setup(__props) {
|
|
1669
|
+
const props = __props;
|
|
1670
|
+
function getItemKey(index, item) {
|
|
1671
|
+
return `${getPathKey([...props.parentPath, index])}:${String(item.value)}`;
|
|
1672
|
+
}
|
|
1673
|
+
return createFor(() => __props.items, (_for_item0, _for_key0) => {
|
|
1674
|
+
return createComponent(dropdown_menu_item_row_default, {
|
|
1675
|
+
context: () => __props.context,
|
|
1676
|
+
index: () => _for_key0.value,
|
|
1677
|
+
item: () => _for_item0.value,
|
|
1678
|
+
"parent-path": () => __props.parentPath
|
|
1679
|
+
}, { "item": extend((slotProps) => {
|
|
1680
|
+
return createSlot("item", { $: [() => slotProps] });
|
|
1681
|
+
}, { _: 8 }) });
|
|
1682
|
+
}, (item, index) => getItemKey(index, item), 2);
|
|
1478
1683
|
}
|
|
1479
1684
|
});
|
|
1480
1685
|
//#endregion
|
|
1481
1686
|
//#region src/components/dropdown-menu/useDropdownMenuDisclosure.ts
|
|
1482
|
-
function useDropdownMenuDisclosure({ props, emit, rootRef, menuRef, targetRef, uncontrolledOpen, isDisabled, isOpen, isVisible, focusedPath, resetFocus, resetSubmenus, resetHoverIntent, focusItem, focusMenu, focusTrigger }) {
|
|
1687
|
+
function useDropdownMenuDisclosure({ props, emit, rootRef, menuRef, targetRef, uncontrolledOpen, isDisabled, isOpen, isVisible, focusedPath, resetFocus, resetSubmenus, resetHoverIntent, focusItem, focusMenu, focusTrigger, layer }) {
|
|
1483
1688
|
function setOpen(nextOpen) {
|
|
1484
1689
|
if (nextOpen && isDisabled.value) return;
|
|
1485
1690
|
const previousOpen = isOpen.value;
|
|
@@ -1517,17 +1722,52 @@ function useDropdownMenuDisclosure({ props, emit, rootRef, menuRef, targetRef, u
|
|
|
1517
1722
|
focusMenu();
|
|
1518
1723
|
} else resetMenuFocus();
|
|
1519
1724
|
});
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1725
|
+
function emitOutside(type, originalEvent) {
|
|
1726
|
+
const outsideEvent = createOutsideEvent(originalEvent);
|
|
1727
|
+
if (type === "pointer") emit.pointerDownOutside?.(outsideEvent);
|
|
1728
|
+
else emit.focusOutside?.(outsideEvent);
|
|
1729
|
+
emit.interactOutside?.(outsideEvent);
|
|
1730
|
+
return outsideEvent;
|
|
1731
|
+
}
|
|
1732
|
+
function isInside(event) {
|
|
1733
|
+
return isEventWithinTargets(event, [
|
|
1734
|
+
rootRef,
|
|
1735
|
+
menuRef,
|
|
1736
|
+
targetRef,
|
|
1737
|
+
...props.ignore ?? []
|
|
1738
|
+
]);
|
|
1739
|
+
}
|
|
1740
|
+
function blockModalInteraction(event) {
|
|
1741
|
+
if (!props.modal) return;
|
|
1742
|
+
if (event.cancelable) event.preventDefault();
|
|
1743
|
+
event.stopPropagation();
|
|
1744
|
+
if (event.type === "pointerdown") blockNextDocumentClick();
|
|
1745
|
+
}
|
|
1746
|
+
function onDocumentPointerdown(event) {
|
|
1747
|
+
if (!layer.isTopLayer()) return;
|
|
1748
|
+
if (isInside(event)) return;
|
|
1749
|
+
const outsideEvent = emitOutside("pointer", event);
|
|
1750
|
+
blockModalInteraction(event);
|
|
1751
|
+
if (!outsideEvent.defaultPrevented) close({ focusTrigger: Boolean(props.modal) });
|
|
1752
|
+
}
|
|
1753
|
+
function onDocumentFocus(event) {
|
|
1754
|
+
if (!layer.isTopLayer()) return;
|
|
1755
|
+
if (isInside(event)) return;
|
|
1756
|
+
const outsideEvent = emitOutside("focus", event);
|
|
1757
|
+
blockModalInteraction(event);
|
|
1758
|
+
if (!outsideEvent.defaultPrevented) close({ focusTrigger: Boolean(props.modal) });
|
|
1759
|
+
else if (props.modal) focusMenu();
|
|
1760
|
+
}
|
|
1761
|
+
let isListening = false;
|
|
1762
|
+
function setDocumentListeners(active) {
|
|
1763
|
+
if (typeof document === "undefined" || active === isListening) return;
|
|
1764
|
+
isListening = active;
|
|
1765
|
+
const method = active ? "addEventListener" : "removeEventListener";
|
|
1766
|
+
document[method]("pointerdown", onDocumentPointerdown, true);
|
|
1767
|
+
document[method]("focusin", onDocumentFocus, true);
|
|
1768
|
+
}
|
|
1769
|
+
watch(isVisible, setDocumentListeners, { immediate: true });
|
|
1770
|
+
onBeforeUnmount(() => setDocumentListeners(false));
|
|
1531
1771
|
return {
|
|
1532
1772
|
open,
|
|
1533
1773
|
close,
|
|
@@ -1961,9 +2201,10 @@ function useDropdownMenuPortalPosition(options) {
|
|
|
1961
2201
|
strategy: () => options.props.strategy ?? "absolute",
|
|
1962
2202
|
offset: () => options.props.offset,
|
|
1963
2203
|
flip: () => options.props.flip !== false,
|
|
2204
|
+
flipOptions: () => options.props.flipOptions,
|
|
1964
2205
|
shift: () => options.props.shift !== false,
|
|
1965
2206
|
collisionPadding: () => options.props.collisionPadding ?? 8,
|
|
1966
|
-
|
|
2207
|
+
autoUpdateOptions: () => options.props.autoUpdateOptions,
|
|
1967
2208
|
restartKey: options.restartKey
|
|
1968
2209
|
});
|
|
1969
2210
|
return {
|
|
@@ -2065,8 +2306,10 @@ function useDropdownMenuRenderItems({ props, actualPlacement, items, getItemId,
|
|
|
2065
2306
|
getSubmenuPlacement: () => actualPlacement.value.endsWith("end") ? "left-start" : "right-start",
|
|
2066
2307
|
getStrategy: () => props.strategy ?? "absolute",
|
|
2067
2308
|
getFlip: () => props.flip !== false,
|
|
2309
|
+
getFlipOptions: () => props.flipOptions,
|
|
2068
2310
|
getShift: () => props.shift !== false,
|
|
2069
|
-
getCollisionPadding: () => props.collisionPadding ?? 8
|
|
2311
|
+
getCollisionPadding: () => props.collisionPadding ?? 8,
|
|
2312
|
+
getAutoUpdateOptions: () => props.autoUpdateOptions
|
|
2070
2313
|
},
|
|
2071
2314
|
getItemProps,
|
|
2072
2315
|
getItemSlotProps
|
|
@@ -2125,6 +2368,7 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2125
2368
|
const placement = computed(() => props.placement ?? "bottom-start");
|
|
2126
2369
|
const requestedTeleportTarget = computed(() => props.portalTo ?? props.teleportTo);
|
|
2127
2370
|
const teleportTo = useTeleportTarget(() => requestedTeleportTarget.value);
|
|
2371
|
+
const teleportPositioningKey = useTeleportPositioningKey();
|
|
2128
2372
|
const shouldTeleport = computed(() => props.portal ?? props.teleport !== false);
|
|
2129
2373
|
const { isExplicitTarget, reference, resolvedTarget } = useFloatingTarget(() => props.target, rootRef);
|
|
2130
2374
|
const targetElement = computed(() => isElementReference(resolvedTarget.value) ? resolvedTarget.value : null);
|
|
@@ -2132,6 +2376,11 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2132
2376
|
const isDisabled = computed(() => Boolean(props.disabled));
|
|
2133
2377
|
const isOpen = computed(() => props.open ?? uncontrolledOpen.value);
|
|
2134
2378
|
const isVisible = computed(() => isOpen.value && !isDisabled.value);
|
|
2379
|
+
const layer = useOverlayLayer({
|
|
2380
|
+
active: isVisible,
|
|
2381
|
+
element: menuRef,
|
|
2382
|
+
baseZIndex: 100
|
|
2383
|
+
});
|
|
2135
2384
|
const contentHasSubmenu = computed(() => hasNestedItems(visibleItems.value));
|
|
2136
2385
|
const isEmpty = computed(() => visibleItems.value.length === 0);
|
|
2137
2386
|
const { actualPlacement, arrowStyle, contentStyle } = useDropdownMenuPortalPosition({
|
|
@@ -2141,7 +2390,11 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2141
2390
|
arrowRef,
|
|
2142
2391
|
isVisible,
|
|
2143
2392
|
placement,
|
|
2144
|
-
restartKey: () => [
|
|
2393
|
+
restartKey: () => [
|
|
2394
|
+
shouldTeleport.value,
|
|
2395
|
+
teleportTo.value,
|
|
2396
|
+
teleportPositioningKey.value
|
|
2397
|
+
]
|
|
2145
2398
|
});
|
|
2146
2399
|
const placementSide = computed(() => actualPlacement.value.split("-")[0]);
|
|
2147
2400
|
const { focusedPath, focusedIndex, getItemAtPath, focusItem, resetFocus, isItemFocused, moveFocus } = useDropdownMenuNavigation(visibleItems);
|
|
@@ -2180,7 +2433,8 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2180
2433
|
resetHoverIntent: hoverIntent.resetHoverIntent,
|
|
2181
2434
|
focusItem,
|
|
2182
2435
|
focusMenu,
|
|
2183
|
-
focusTrigger
|
|
2436
|
+
focusTrigger,
|
|
2437
|
+
layer
|
|
2184
2438
|
});
|
|
2185
2439
|
const { open, close, toggle } = disclosure;
|
|
2186
2440
|
const { activateItem, selectItem, openSubmenu, closeSubmenu, focusHoveredItem, onTriggerClick, onTriggerKeydown, onMenuKeydown, onMenuMousemove, onMenuMouseleave } = useDropdownMenuInteractions({
|
|
@@ -2300,7 +2554,10 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2300
2554
|
activeDescendantId,
|
|
2301
2555
|
rootClass,
|
|
2302
2556
|
contentClass,
|
|
2303
|
-
contentStyle
|
|
2557
|
+
contentStyle: computed(() => ({
|
|
2558
|
+
...contentStyle.value,
|
|
2559
|
+
zIndex: layer.zIndex.value
|
|
2560
|
+
})),
|
|
2304
2561
|
arrowStyle,
|
|
2305
2562
|
actualPlacement,
|
|
2306
2563
|
placementSide,
|
|
@@ -2358,6 +2615,7 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2358
2615
|
type: Boolean,
|
|
2359
2616
|
default: false
|
|
2360
2617
|
},
|
|
2618
|
+
ignore: {},
|
|
2361
2619
|
portal: {
|
|
2362
2620
|
type: Boolean,
|
|
2363
2621
|
default: void 0
|
|
@@ -2371,11 +2629,13 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2371
2629
|
type: Boolean,
|
|
2372
2630
|
default: true
|
|
2373
2631
|
},
|
|
2632
|
+
flipOptions: {},
|
|
2374
2633
|
shift: {
|
|
2375
2634
|
type: Boolean,
|
|
2376
2635
|
default: true
|
|
2377
2636
|
},
|
|
2378
2637
|
collisionPadding: { default: 8 },
|
|
2638
|
+
autoUpdateOptions: {},
|
|
2379
2639
|
arrow: {
|
|
2380
2640
|
type: Boolean,
|
|
2381
2641
|
default: false
|
|
@@ -2388,13 +2648,22 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2388
2648
|
classNames: {},
|
|
2389
2649
|
styles: {}
|
|
2390
2650
|
},
|
|
2391
|
-
emits: [
|
|
2651
|
+
emits: [
|
|
2652
|
+
"update:open",
|
|
2653
|
+
"select",
|
|
2654
|
+
"pointerDownOutside",
|
|
2655
|
+
"focusOutside",
|
|
2656
|
+
"interactOutside"
|
|
2657
|
+
],
|
|
2392
2658
|
setup(__props, { emit: __emit }) {
|
|
2393
2659
|
const props = __props;
|
|
2394
2660
|
const emit = __emit;
|
|
2395
|
-
const { rootRef, menuRef, arrowRef, isVisible, isEmpty, visibleItems, renderContext, rootClass, contentClass, contentStyle, arrowStyle, placementSide, isTargetMode, teleportTo, shouldTeleport, contentProps, slotProps } = useDropdownMenu(props, {
|
|
2661
|
+
const { rootRef, menuRef, arrowRef, isVisible, isEmpty, visibleItems, renderContext, rootClass, contentClass, contentStyle, arrowStyle, actualPlacement, placementSide, isTargetMode, teleportTo, shouldTeleport, contentProps, slotProps } = useDropdownMenu(props, {
|
|
2396
2662
|
openChange: (open) => emit("update:open", open),
|
|
2397
|
-
select: (item, event) => emit("select", item, event)
|
|
2663
|
+
select: (item, event) => emit("select", item, event),
|
|
2664
|
+
pointerDownOutside: (event) => emit("pointerDownOutside", event),
|
|
2665
|
+
focusOutside: (event) => emit("focusOutside", event),
|
|
2666
|
+
interactOutside: (event) => emit("interactOutside", event)
|
|
2398
2667
|
});
|
|
2399
2668
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
2400
2669
|
const state = computed(() => isVisible.value ? "open" : "closed");
|
|
@@ -2423,7 +2692,7 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2423
2692
|
style: contentStyle.value
|
|
2424
2693
|
}),
|
|
2425
2694
|
"data-state": state.value,
|
|
2426
|
-
"data-placement":
|
|
2695
|
+
"data-placement": actualPlacement.value
|
|
2427
2696
|
}));
|
|
2428
2697
|
const publicRenderContext = computed(() => ({
|
|
2429
2698
|
...renderContext,
|
|
@@ -2466,7 +2735,7 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2466
2735
|
return n13;
|
|
2467
2736
|
});
|
|
2468
2737
|
setInsertionState(n26, null, 2);
|
|
2469
|
-
createComponent(
|
|
2738
|
+
createComponent(dropdown_menu_items_default, {
|
|
2470
2739
|
items: () => unref(visibleItems),
|
|
2471
2740
|
context: () => publicRenderContext.value
|
|
2472
2741
|
}, { "item": extend((itemSlotProps) => {
|
|
@@ -2518,6 +2787,6 @@ var dropdownMenuParts = [
|
|
|
2518
2787
|
];
|
|
2519
2788
|
//#endregion
|
|
2520
2789
|
//#region src/components/dropdown-menu/index.ts
|
|
2521
|
-
var DropdownMenuItem =
|
|
2790
|
+
var DropdownMenuItem = dropdown_menu_item_default;
|
|
2522
2791
|
//#endregion
|
|
2523
|
-
export {
|
|
2792
|
+
export { dropdown_menu_content_default as _, dropdown_menu_trigger_default as a, dropdown_menu_sub_default as c, dropdown_menu_radio_item_default as d, dropdown_menu_radio_group_default as f, dropdown_menu_context_trigger_default as g, dropdown_menu_item_indicator_default as h, useDropdownMenu as i, dropdown_menu_separator_default as l, dropdown_menu_label_default as m, dropdownMenuParts as n, dropdown_menu_sub_trigger_default as o, dropdown_menu_portal_default as p, dropdown_menu_default as r, dropdown_menu_sub_content_default as s, DropdownMenuItem as t, dropdown_menu_root_default as u, dropdown_menu_checkbox_item_default as v };
|