ropav 0.0.11 → 0.0.12
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 +5 -2
- 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/floating/index.d.ts +3 -1
- package/dist/components/floating/index.js +3 -0
- package/dist/components/floating/types.d.ts +75 -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 +1141 -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 +25 -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 +7 -3
- package/dist/useControlState.js +4 -0
- package/dist/useFloatingPosition.js +71 -38
- package/dist/useFormControl.js +107 -0
- package/dist/useOverlayLayer.js +262 -0
- package/dist/useTeleportTarget.js +21 -10
- package/docs/public-floating-api.md +148 -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,438 @@ 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
|
+
shift: () => props.avoidCollisions !== false && props.shift !== false,
|
|
438
|
+
collisionPadding: () => props.collisionPadding ?? 8,
|
|
439
|
+
restartKey: teleportPositioningKey
|
|
440
|
+
});
|
|
441
|
+
watch(floating.actualPlacement, (value) => {
|
|
442
|
+
actualPlacement.value = value;
|
|
443
|
+
}, { immediate: true });
|
|
444
|
+
const shouldRender = computed(() => props.forceMount === true || isOpen.value);
|
|
445
|
+
let layerBranchCleanup;
|
|
446
|
+
provide(menuKey, menu);
|
|
447
|
+
if (sub) sub.menu = menu;
|
|
448
|
+
function setElement(value) {
|
|
449
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
450
|
+
const previous = element.value;
|
|
451
|
+
if (previous) root.unregisterInside(previous);
|
|
452
|
+
layerBranchCleanup?.();
|
|
453
|
+
layerBranchCleanup = void 0;
|
|
454
|
+
element.value = resolved;
|
|
455
|
+
if (resolved) root.registerInside(resolved);
|
|
456
|
+
if (!sub) root.layer.element.value = resolved;
|
|
457
|
+
else if (resolved) layerBranchCleanup = root.layer.registerBranch(resolved);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
function emitOutside(type, originalEvent) {
|
|
461
|
+
const outsideEvent = createOutsideEvent(originalEvent);
|
|
462
|
+
if (type === "pointer") events.pointerDownOutside(outsideEvent);
|
|
463
|
+
else events.focusOutside(outsideEvent);
|
|
464
|
+
events.interactOutside(outsideEvent);
|
|
465
|
+
return outsideEvent;
|
|
466
|
+
}
|
|
467
|
+
function onDocumentPointer(event) {
|
|
468
|
+
if (!root.layer.isTopLayer() || root.isInside(event) || isEventWithinTargets(event, props.ignore ?? [])) return;
|
|
469
|
+
const outsideEvent = emitOutside("pointer", event);
|
|
470
|
+
if (root.modal.value) {
|
|
471
|
+
if (event.cancelable) event.preventDefault();
|
|
472
|
+
event.stopPropagation();
|
|
473
|
+
if (event.type === "pointerdown") blockNextDocumentClick();
|
|
321
474
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
475
|
+
if (!outsideEvent.defaultPrevented) root.close({ returnFocus: root.modal.value });
|
|
476
|
+
}
|
|
477
|
+
function onDocumentFocus(event) {
|
|
478
|
+
if (!root.layer.isTopLayer() || root.isInside(event) || isEventWithinTargets(event, props.ignore ?? [])) return;
|
|
479
|
+
const outsideEvent = emitOutside("focus", event);
|
|
480
|
+
if (root.modal.value) {
|
|
481
|
+
if (event.cancelable) event.preventDefault();
|
|
482
|
+
event.stopPropagation();
|
|
325
483
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
484
|
+
if (!outsideEvent.defaultPrevented) root.close({ returnFocus: root.modal.value });
|
|
485
|
+
else if (root.modal.value) nextTick(menu.focusElement);
|
|
486
|
+
}
|
|
487
|
+
function setDocumentListeners(active) {
|
|
488
|
+
if (submenu || typeof document === "undefined") return;
|
|
489
|
+
const method = active ? "addEventListener" : "removeEventListener";
|
|
490
|
+
document[method]("pointerdown", onDocumentPointer, true);
|
|
491
|
+
document[method]("focusin", onDocumentFocus, true);
|
|
492
|
+
}
|
|
493
|
+
watch(isOpen, (open) => {
|
|
494
|
+
setDocumentListeners(open);
|
|
495
|
+
if (!open) {
|
|
496
|
+
menu.activeId.value = null;
|
|
497
|
+
menu.closeSubmenus();
|
|
498
|
+
return;
|
|
331
499
|
}
|
|
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
|
|
500
|
+
nextTick(() => {
|
|
501
|
+
const focus = sub ? sub.pendingFocus.value : root.pendingFocus.value;
|
|
502
|
+
menu.focus(focus || "first");
|
|
384
503
|
});
|
|
385
|
-
|
|
504
|
+
}, {
|
|
505
|
+
flush: "post",
|
|
506
|
+
immediate: true
|
|
507
|
+
});
|
|
508
|
+
onMounted(() => {
|
|
509
|
+
if (sub) sub.contentId.value = id.value;
|
|
510
|
+
else root.contentId.value = id.value;
|
|
511
|
+
if (isOpen.value) menu.focus((sub ? sub.pendingFocus.value : root.pendingFocus.value) || "first");
|
|
512
|
+
});
|
|
513
|
+
onBeforeUnmount(() => {
|
|
514
|
+
setDocumentListeners(false);
|
|
515
|
+
layerBranchCleanup?.();
|
|
516
|
+
if (element.value) root.unregisterInside(element.value);
|
|
517
|
+
if (!sub && root.layer.element.value === element.value) root.layer.element.value = null;
|
|
518
|
+
if (sub) sub.menu = null;
|
|
519
|
+
else if (root.contentId.value === id.value) root.contentId.value = void 0;
|
|
520
|
+
});
|
|
521
|
+
const placementSide = computed(() => floating.actualPlacement.value.split("-")[0]);
|
|
522
|
+
const placementAlign = computed(() => floating.actualPlacement.value.split("-")[1] ?? "center");
|
|
523
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
524
|
+
id: id.value,
|
|
525
|
+
role: "menu",
|
|
526
|
+
tabindex: -1,
|
|
527
|
+
hidden: optionalAttr(!isOpen.value),
|
|
528
|
+
class: submenu ? bem("rp-dropdown-menu__submenu", {
|
|
529
|
+
compound: true,
|
|
530
|
+
open: isOpen.value
|
|
531
|
+
}) : bem("rp-dropdown-menu__content", {
|
|
532
|
+
compound: true,
|
|
533
|
+
open: isOpen.value
|
|
534
|
+
}),
|
|
535
|
+
style: [
|
|
536
|
+
floating.floatingStyle.value,
|
|
537
|
+
{ zIndex: root.layer.zIndex.value },
|
|
538
|
+
!isOpen.value ? { display: "none" } : void 0
|
|
539
|
+
],
|
|
540
|
+
"aria-label": props.ariaLabel,
|
|
541
|
+
"aria-labelledby": props.ariaLabelledby ?? (submenu ? void 0 : root.triggerId.value),
|
|
542
|
+
"aria-describedby": props.ariaDescribedby,
|
|
543
|
+
"aria-activedescendant": menu.activeId.value ?? void 0,
|
|
544
|
+
"data-state": isOpen.value ? "open" : "closed",
|
|
545
|
+
"data-placement": floating.actualPlacement.value,
|
|
546
|
+
"data-side": placementSide.value,
|
|
547
|
+
"data-align": placementAlign.value,
|
|
548
|
+
onKeydown: menu.onKeydown
|
|
549
|
+
}));
|
|
550
|
+
function close() {
|
|
551
|
+
if (sub) sub.close(true);
|
|
552
|
+
else root.close({ returnFocus: true });
|
|
386
553
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
554
|
+
return {
|
|
555
|
+
id,
|
|
556
|
+
element,
|
|
557
|
+
arrowElement,
|
|
558
|
+
actualPlacement,
|
|
559
|
+
isOpen,
|
|
560
|
+
shouldRender,
|
|
561
|
+
placementSide,
|
|
562
|
+
rootAttrs,
|
|
563
|
+
floating,
|
|
564
|
+
setElement,
|
|
565
|
+
close
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
//#endregion
|
|
569
|
+
//#region src/components/dropdown-menu/dropdown-menu-content.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
570
|
+
var t0$3 = template("<span class=rp-dropdown-menu__arrow aria-hidden=true>");
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/components/dropdown-menu/dropdown-menu-content.vue
|
|
573
|
+
var dropdown_menu_content_default = /* @__PURE__ */ defineVaporComponent({
|
|
574
|
+
name: "RpDropdownMenuContent",
|
|
390
575
|
inheritAttrs: false,
|
|
576
|
+
__name: "dropdown-menu-content",
|
|
391
577
|
props: {
|
|
392
|
-
id:
|
|
393
|
-
as:
|
|
394
|
-
|
|
578
|
+
id: {},
|
|
579
|
+
as: { default: "div" },
|
|
580
|
+
placement: { default: "bottom-start" },
|
|
581
|
+
offset: {},
|
|
582
|
+
strategy: { default: "absolute" },
|
|
583
|
+
flip: {
|
|
395
584
|
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
|
-
|
|
585
|
+
default: true
|
|
586
|
+
},
|
|
587
|
+
shift: {
|
|
588
|
+
type: Boolean,
|
|
589
|
+
default: true
|
|
590
|
+
},
|
|
591
|
+
collisionPadding: { default: 8 },
|
|
592
|
+
arrow: {
|
|
593
|
+
type: Boolean,
|
|
594
|
+
default: false
|
|
595
|
+
},
|
|
596
|
+
avoidCollisions: {
|
|
597
|
+
type: Boolean,
|
|
598
|
+
default: true
|
|
599
|
+
},
|
|
600
|
+
forceMount: {
|
|
601
|
+
type: Boolean,
|
|
602
|
+
default: false
|
|
603
|
+
},
|
|
604
|
+
ignore: {},
|
|
605
|
+
ariaLabel: {},
|
|
606
|
+
ariaLabelledby: {},
|
|
607
|
+
ariaDescribedby: {}
|
|
608
|
+
},
|
|
609
|
+
emits: [
|
|
610
|
+
"escapeKeyDown",
|
|
611
|
+
"pointerDownOutside",
|
|
612
|
+
"focusOutside",
|
|
613
|
+
"interactOutside"
|
|
614
|
+
],
|
|
615
|
+
setup(__props, { emit: __emit }) {
|
|
616
|
+
const props = __props;
|
|
617
|
+
const emit = __emit;
|
|
618
|
+
const { arrowElement, actualPlacement, isOpen, shouldRender, placementSide, rootAttrs, floating, setElement, close } = useDropdownMenuPrimitiveContent(props, useAttrs(), {
|
|
619
|
+
escapeKeyDown: (event) => emit("escapeKeyDown", event),
|
|
620
|
+
pointerDownOutside: (event) => emit("pointerDownOutside", event),
|
|
621
|
+
focusOutside: (event) => emit("focusOutside", event),
|
|
622
|
+
interactOutside: (event) => emit("interactOutside", event)
|
|
623
|
+
}, false);
|
|
624
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
625
|
+
return createIf(() => unref(shouldRender), () => {
|
|
626
|
+
const n6 = createDynamicComponent(() => __props.as, { $: [() => unref(rootAttrs)] }, extend(() => {
|
|
627
|
+
return [createIf(() => __props.arrow, () => {
|
|
628
|
+
const n4 = t0$3();
|
|
629
|
+
_setTemplateRef(n4, arrowElement, null, "arrowElement");
|
|
630
|
+
renderEffect(() => {
|
|
631
|
+
setAttr(n4, "data-side", unref(placementSide));
|
|
632
|
+
setStyle(n4, unref(floating).arrowStyle.value);
|
|
633
|
+
});
|
|
634
|
+
return n4;
|
|
635
|
+
}, null, 129), createSlot("default", {
|
|
636
|
+
isOpen: () => unref(isOpen),
|
|
637
|
+
placement: () => unref(actualPlacement),
|
|
638
|
+
close: () => unref(close)
|
|
639
|
+
})];
|
|
640
|
+
}, { _: 8 }), 1);
|
|
641
|
+
setTemplateRefBinding(n6, () => setElement, void 0, void 0, "setElement");
|
|
642
|
+
return n6;
|
|
643
|
+
});
|
|
452
644
|
}
|
|
453
645
|
});
|
|
454
|
-
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/components/dropdown-menu/dropdown-menu-context-trigger.vue
|
|
648
|
+
var dropdown_menu_context_trigger_default = /* @__PURE__ */ defineVaporComponent({
|
|
455
649
|
name: "RpDropdownMenuContextTrigger",
|
|
456
650
|
inheritAttrs: false,
|
|
651
|
+
__name: "dropdown-menu-context-trigger",
|
|
457
652
|
props: {
|
|
458
|
-
id:
|
|
459
|
-
as:
|
|
653
|
+
id: {},
|
|
654
|
+
as: { default: "span" },
|
|
460
655
|
disabled: {
|
|
461
656
|
type: Boolean,
|
|
462
657
|
default: false
|
|
463
658
|
},
|
|
464
|
-
longPressDelay: {
|
|
465
|
-
|
|
466
|
-
default: 700
|
|
467
|
-
},
|
|
468
|
-
longPressTolerance: {
|
|
469
|
-
type: Number,
|
|
470
|
-
default: 10
|
|
471
|
-
}
|
|
659
|
+
longPressDelay: { default: 700 },
|
|
660
|
+
longPressTolerance: { default: 10 }
|
|
472
661
|
},
|
|
473
|
-
setup(
|
|
662
|
+
setup(__props) {
|
|
663
|
+
const props = __props;
|
|
664
|
+
const attrs = useAttrs();
|
|
474
665
|
const root = useRequiredInject(rootKey, "RpDropdownMenuContextTrigger");
|
|
475
666
|
const generatedId = useId();
|
|
476
667
|
const id = computed(() => props.id ?? `${generatedId}-context-trigger`);
|
|
@@ -482,11 +673,13 @@ var DropdownMenuContextTrigger = defineComponent({
|
|
|
482
673
|
let longPressOpened = false;
|
|
483
674
|
let suppressUntil = 0;
|
|
484
675
|
function setElement(value) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
676
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
677
|
+
const previous = element.value;
|
|
678
|
+
if (previous) root.unregisterInside(previous);
|
|
679
|
+
element.value = resolved;
|
|
680
|
+
if (resolved) root.registerInside(resolved);
|
|
681
|
+
if (!root.triggerId.value) root.triggerId.value = id.value;
|
|
682
|
+
});
|
|
490
683
|
}
|
|
491
684
|
function clearLongPress() {
|
|
492
685
|
if (timer) clearTimeout(timer);
|
|
@@ -550,14 +743,8 @@ var DropdownMenuContextTrigger = defineComponent({
|
|
|
550
743
|
event.preventDefault();
|
|
551
744
|
event.stopPropagation();
|
|
552
745
|
}
|
|
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, {
|
|
746
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
559
747
|
id: id.value,
|
|
560
|
-
ref: setElement,
|
|
561
748
|
"aria-controls": root.contentId.value,
|
|
562
749
|
"aria-expanded": root.isOpen.value,
|
|
563
750
|
"aria-haspopup": "menu",
|
|
@@ -571,330 +758,29 @@ var DropdownMenuContextTrigger = defineComponent({
|
|
|
571
758
|
onPointermove,
|
|
572
759
|
onPointerup: finishPointer,
|
|
573
760
|
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?.());
|
|
761
|
+
}));
|
|
762
|
+
onBeforeUnmount(() => {
|
|
763
|
+
clearLongPress();
|
|
764
|
+
if (element.value) root.unregisterInside(element.value);
|
|
765
|
+
if (root.triggerId.value === id.value) root.triggerId.value = void 0;
|
|
766
|
+
});
|
|
767
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
768
|
+
return createSlot("default", { isOpen: () => unref(root).isOpen.value });
|
|
769
|
+
}, { _: 8 }), 1);
|
|
770
|
+
setTemplateRefBinding(n1, () => setElement);
|
|
771
|
+
return n1;
|
|
605
772
|
}
|
|
606
773
|
});
|
|
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({
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/components/dropdown-menu/dropdown-menu-item.vue
|
|
776
|
+
var dropdown_menu_item_default = /* @__PURE__ */ defineVaporComponent({
|
|
892
777
|
name: "RpDropdownMenuItem",
|
|
893
778
|
inheritAttrs: false,
|
|
779
|
+
__name: "dropdown-menu-item",
|
|
894
780
|
props: {
|
|
895
|
-
id:
|
|
896
|
-
as:
|
|
897
|
-
value:
|
|
781
|
+
id: {},
|
|
782
|
+
as: { default: "button" },
|
|
783
|
+
value: {},
|
|
898
784
|
disabled: {
|
|
899
785
|
type: Boolean,
|
|
900
786
|
default: false
|
|
@@ -909,119 +795,147 @@ var DropdownMenuItem$1 = defineComponent({
|
|
|
909
795
|
}
|
|
910
796
|
},
|
|
911
797
|
emits: ["select"],
|
|
912
|
-
setup(
|
|
913
|
-
const
|
|
914
|
-
|
|
798
|
+
setup(__props, { emit: __emit }) {
|
|
799
|
+
const props = __props;
|
|
800
|
+
const emit = __emit;
|
|
801
|
+
const attrs = useAttrs();
|
|
802
|
+
const { id, isDisabled, focused, activate, select, setElement, onPointerenter } = usePrimitiveItem("RpDropdownMenuItem", props, (event) => emit("select", event), { defaultCloseOnSelect: true });
|
|
803
|
+
function onClick(event) {
|
|
804
|
+
if (!event.defaultPrevented) activate(event);
|
|
805
|
+
}
|
|
806
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
807
|
+
id: id.value,
|
|
808
|
+
type: props.as === "button" ? "button" : void 0,
|
|
809
|
+
role: "menuitem",
|
|
810
|
+
tabindex: -1,
|
|
811
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
812
|
+
"aria-disabled": optionalAttr(isDisabled.value),
|
|
813
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
814
|
+
"data-focused": optionalAttr(focused.value),
|
|
815
|
+
"data-highlighted": optionalAttr(focused.value),
|
|
816
|
+
class: bem("rp-dropdown-menu__item", {
|
|
817
|
+
focused: focused.value,
|
|
818
|
+
disabled: isDisabled.value,
|
|
819
|
+
destructive: props.destructive
|
|
820
|
+
}),
|
|
821
|
+
onClick,
|
|
822
|
+
onMouseenter: onPointerenter
|
|
823
|
+
}));
|
|
824
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
825
|
+
return createSlot("default", {
|
|
826
|
+
focused: () => unref(focused),
|
|
827
|
+
disabled: () => unref(isDisabled),
|
|
828
|
+
select: () => unref(select)
|
|
829
|
+
});
|
|
830
|
+
}, { _: 8 }), 1);
|
|
831
|
+
setTemplateRefBinding(n1, () => setElement, void 0, void 0, "setElement");
|
|
832
|
+
return n1;
|
|
915
833
|
}
|
|
916
834
|
});
|
|
917
|
-
|
|
918
|
-
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/components/dropdown-menu/dropdown-menu-item-indicator.vue
|
|
837
|
+
var dropdown_menu_item_indicator_default = /* @__PURE__ */ defineVaporComponent({
|
|
838
|
+
name: "RpDropdownMenuItemIndicator",
|
|
919
839
|
inheritAttrs: false,
|
|
840
|
+
__name: "dropdown-menu-item-indicator",
|
|
920
841
|
props: {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
default: "horizontal"
|
|
842
|
+
as: { default: "span" },
|
|
843
|
+
forceMount: {
|
|
844
|
+
type: Boolean,
|
|
845
|
+
default: false
|
|
926
846
|
}
|
|
927
847
|
},
|
|
928
|
-
setup(
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
"
|
|
934
|
-
|
|
935
|
-
"data-orientation": props.orientation
|
|
848
|
+
setup(__props) {
|
|
849
|
+
const attrs = useAttrs();
|
|
850
|
+
const context = useRequiredInject(checkedKey, "RpDropdownMenuItemIndicator");
|
|
851
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
852
|
+
class: "rp-dropdown-menu__indicator",
|
|
853
|
+
"data-state": context.state.value,
|
|
854
|
+
"aria-hidden": true
|
|
936
855
|
}));
|
|
856
|
+
return createIf(() => __props.forceMount || unref(context).checked.value, () => {
|
|
857
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
858
|
+
return createSlot("default", {
|
|
859
|
+
state: () => unref(context).state.value,
|
|
860
|
+
checked: () => unref(context).checked.value
|
|
861
|
+
});
|
|
862
|
+
}, { _: 8 }), 1);
|
|
863
|
+
});
|
|
937
864
|
}
|
|
938
865
|
});
|
|
939
|
-
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region src/components/dropdown-menu/dropdown-menu-label.vue
|
|
868
|
+
var dropdown_menu_label_default = /* @__PURE__ */ defineVaporComponent({
|
|
940
869
|
name: "RpDropdownMenuLabel",
|
|
941
870
|
inheritAttrs: false,
|
|
871
|
+
__name: "dropdown-menu-label",
|
|
942
872
|
props: {
|
|
943
|
-
id:
|
|
944
|
-
as:
|
|
873
|
+
id: {},
|
|
874
|
+
as: { default: "div" }
|
|
945
875
|
},
|
|
946
|
-
setup(
|
|
876
|
+
setup(__props) {
|
|
877
|
+
const props = __props;
|
|
878
|
+
const attrs = useAttrs();
|
|
947
879
|
useRequiredInject(menuKey, "RpDropdownMenuLabel");
|
|
948
|
-
|
|
880
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
949
881
|
id: props.id,
|
|
950
882
|
role: "presentation",
|
|
951
883
|
class: "rp-dropdown-menu__group-label"
|
|
952
|
-
})
|
|
884
|
+
}));
|
|
885
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
886
|
+
return createSlot();
|
|
887
|
+
}, { _: 8 }), 1);
|
|
953
888
|
}
|
|
954
889
|
});
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
890
|
+
//#endregion
|
|
891
|
+
//#region src/components/dropdown-menu/dropdown-menu-portal.vue
|
|
892
|
+
var dropdown_menu_portal_default = /* @__PURE__ */ defineVaporComponent({
|
|
893
|
+
name: "RpDropdownMenuPortal",
|
|
894
|
+
__name: "dropdown-menu-portal",
|
|
958
895
|
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
|
-
},
|
|
896
|
+
to: { default: void 0 },
|
|
969
897
|
disabled: {
|
|
970
898
|
type: Boolean,
|
|
971
899
|
default: false
|
|
972
900
|
},
|
|
973
|
-
|
|
901
|
+
teleport: {
|
|
974
902
|
type: Boolean,
|
|
975
|
-
default:
|
|
903
|
+
default: true
|
|
976
904
|
},
|
|
977
|
-
|
|
978
|
-
type: Boolean,
|
|
979
|
-
default: false
|
|
980
|
-
}
|
|
905
|
+
teleportTo: { default: void 0 }
|
|
981
906
|
},
|
|
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);
|
|
907
|
+
setup(__props) {
|
|
908
|
+
const props = __props;
|
|
909
|
+
const teleportTo = provideTeleportTarget({ get teleportTo() {
|
|
910
|
+
return props.to ?? props.teleportTo;
|
|
911
|
+
} }, () => Boolean(props.teleport && !props.disabled));
|
|
912
|
+
return createComponent(VaporTeleport, {
|
|
913
|
+
to: () => unref(teleportTo),
|
|
914
|
+
disabled: () => __props.disabled || !__props.teleport
|
|
915
|
+
}, extend(() => {
|
|
916
|
+
return createSlot();
|
|
917
|
+
}, { _: 8 }), true);
|
|
1004
918
|
}
|
|
1005
919
|
});
|
|
1006
|
-
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/components/dropdown-menu/dropdown-menu-radio-group.vue
|
|
922
|
+
var dropdown_menu_radio_group_default = /* @__PURE__ */ defineVaporComponent({
|
|
1007
923
|
name: "RpDropdownMenuRadioGroup",
|
|
1008
924
|
inheritAttrs: false,
|
|
925
|
+
__name: "dropdown-menu-radio-group",
|
|
1009
926
|
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
|
|
927
|
+
id: {},
|
|
928
|
+
as: { default: "div" },
|
|
929
|
+
modelValue: { default: void 0 },
|
|
930
|
+
defaultValue: { default: null },
|
|
931
|
+
ariaLabel: {},
|
|
932
|
+
ariaLabelledby: {}
|
|
1022
933
|
},
|
|
1023
934
|
emits: ["update:modelValue"],
|
|
1024
|
-
setup(
|
|
935
|
+
setup(__props, { emit: __emit }) {
|
|
936
|
+
const props = __props;
|
|
937
|
+
const emit = __emit;
|
|
938
|
+
const attrs = useAttrs();
|
|
1025
939
|
useRequiredInject(menuKey, "RpDropdownMenuRadioGroup");
|
|
1026
940
|
const uncontrolled = ref(props.defaultValue);
|
|
1027
941
|
const value = computed(() => props.modelValue === void 0 ? uncontrolled.value : props.modelValue);
|
|
@@ -1034,25 +948,28 @@ var DropdownMenuRadioGroup = defineComponent({
|
|
|
1034
948
|
value,
|
|
1035
949
|
select
|
|
1036
950
|
});
|
|
1037
|
-
|
|
951
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1038
952
|
id: props.id,
|
|
1039
953
|
role: "group",
|
|
1040
954
|
class: "rp-dropdown-menu__radio-group",
|
|
1041
955
|
"aria-label": props.ariaLabel,
|
|
1042
956
|
"aria-labelledby": props.ariaLabelledby
|
|
1043
|
-
})
|
|
957
|
+
}));
|
|
958
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
959
|
+
return createSlot("default", { value: () => value.value });
|
|
960
|
+
}, { _: 8 }), 1);
|
|
1044
961
|
}
|
|
1045
962
|
});
|
|
1046
|
-
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region src/components/dropdown-menu/dropdown-menu-radio-item.vue
|
|
965
|
+
var dropdown_menu_radio_item_default = /* @__PURE__ */ defineVaporComponent({
|
|
1047
966
|
name: "RpDropdownMenuRadioItem",
|
|
1048
967
|
inheritAttrs: false,
|
|
968
|
+
__name: "dropdown-menu-radio-item",
|
|
1049
969
|
props: {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
type: [String, Number],
|
|
1054
|
-
required: true
|
|
1055
|
-
},
|
|
970
|
+
value: {},
|
|
971
|
+
id: {},
|
|
972
|
+
as: { default: "button" },
|
|
1056
973
|
disabled: {
|
|
1057
974
|
type: Boolean,
|
|
1058
975
|
default: false
|
|
@@ -1065,52 +982,235 @@ var DropdownMenuRadioItem = defineComponent({
|
|
|
1065
982
|
type: Boolean,
|
|
1066
983
|
default: false
|
|
1067
984
|
}
|
|
1068
|
-
},
|
|
1069
|
-
emits: ["select"],
|
|
1070
|
-
setup(
|
|
1071
|
-
const
|
|
1072
|
-
const
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
985
|
+
},
|
|
986
|
+
emits: ["select"],
|
|
987
|
+
setup(__props, { emit: __emit }) {
|
|
988
|
+
const props = __props;
|
|
989
|
+
const emit = __emit;
|
|
990
|
+
const attrs = useAttrs();
|
|
991
|
+
const group = useRequiredInject(radioGroupKey, "RpDropdownMenuRadioItem");
|
|
992
|
+
const isChecked = computed(() => group.value.value === props.value);
|
|
993
|
+
const checked = computed(() => isChecked.value);
|
|
994
|
+
const state = computed(() => isChecked.value ? "checked" : "unchecked");
|
|
995
|
+
provide(checkedKey, {
|
|
996
|
+
state,
|
|
997
|
+
checked: isChecked
|
|
998
|
+
});
|
|
999
|
+
const { id, isDisabled, focused, activate, select, setElement, onPointerenter } = usePrimitiveItem("RpDropdownMenuRadioItem", props, (event) => emit("select", event), {
|
|
1000
|
+
checked,
|
|
1001
|
+
defaultCloseOnSelect: false,
|
|
1002
|
+
afterSelect: () => group.select(props.value)
|
|
1003
|
+
});
|
|
1004
|
+
function onClick(event) {
|
|
1005
|
+
if (!event.defaultPrevented) activate(event);
|
|
1006
|
+
}
|
|
1007
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1008
|
+
id: id.value,
|
|
1009
|
+
type: props.as === "button" ? "button" : void 0,
|
|
1010
|
+
role: "menuitemradio",
|
|
1011
|
+
tabindex: -1,
|
|
1012
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
1013
|
+
"aria-disabled": optionalAttr(isDisabled.value),
|
|
1014
|
+
"aria-checked": checked.value,
|
|
1015
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
1016
|
+
"data-focused": optionalAttr(focused.value),
|
|
1017
|
+
"data-highlighted": optionalAttr(focused.value),
|
|
1018
|
+
"data-state": state.value,
|
|
1019
|
+
class: bem("rp-dropdown-menu__item", {
|
|
1020
|
+
focused: focused.value,
|
|
1021
|
+
disabled: isDisabled.value,
|
|
1022
|
+
destructive: props.destructive
|
|
1023
|
+
}),
|
|
1024
|
+
onClick,
|
|
1025
|
+
onMouseenter: onPointerenter
|
|
1026
|
+
}));
|
|
1027
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
1028
|
+
return createSlot("default", {
|
|
1029
|
+
focused: () => unref(focused),
|
|
1030
|
+
disabled: () => unref(isDisabled),
|
|
1031
|
+
select: () => unref(select)
|
|
1032
|
+
});
|
|
1033
|
+
}, { _: 8 }), 1);
|
|
1034
|
+
setTemplateRefBinding(n1, () => setElement, void 0, void 0, "setElement");
|
|
1035
|
+
return n1;
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
//#endregion
|
|
1039
|
+
//#region src/components/dropdown-menu/dropdown-menu-root.vue
|
|
1040
|
+
var dropdown_menu_root_default = /* @__PURE__ */ defineVaporComponent({
|
|
1041
|
+
name: "RpDropdownMenuRoot",
|
|
1042
|
+
__name: "dropdown-menu-root",
|
|
1043
|
+
props: {
|
|
1044
|
+
id: {},
|
|
1045
|
+
open: {
|
|
1046
|
+
type: Boolean,
|
|
1047
|
+
default: void 0
|
|
1048
|
+
},
|
|
1049
|
+
defaultOpen: {
|
|
1050
|
+
type: Boolean,
|
|
1051
|
+
default: false
|
|
1052
|
+
},
|
|
1053
|
+
disabled: {
|
|
1054
|
+
type: Boolean,
|
|
1055
|
+
default: false
|
|
1056
|
+
},
|
|
1057
|
+
modal: {
|
|
1058
|
+
type: Boolean,
|
|
1059
|
+
default: true
|
|
1060
|
+
},
|
|
1061
|
+
target: { default: null },
|
|
1062
|
+
virtualAnchor: { default: null }
|
|
1063
|
+
},
|
|
1064
|
+
emits: ["update:open"],
|
|
1065
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1066
|
+
const props = __props;
|
|
1067
|
+
const emit = __emit;
|
|
1068
|
+
const generatedId = useId();
|
|
1069
|
+
const id = computed(() => props.id ?? `${generatedId}-dropdown-menu`);
|
|
1070
|
+
const uncontrolledOpen = ref(props.defaultOpen);
|
|
1071
|
+
const isOpen = computed(() => props.open ?? uncontrolledOpen.value);
|
|
1072
|
+
const disabled = computed(() => props.disabled);
|
|
1073
|
+
const modal = computed(() => props.modal);
|
|
1074
|
+
const trigger = ref(null);
|
|
1075
|
+
const triggerId = ref();
|
|
1076
|
+
const contentId = ref();
|
|
1077
|
+
const activeReference = shallowRef(null);
|
|
1078
|
+
const { reference: configuredReference } = useFloatingTarget(() => props.target ?? props.virtualAnchor, trigger);
|
|
1079
|
+
const reference = computed(() => activeReference.value ?? configuredReference.value);
|
|
1080
|
+
const pendingFocus = ref("first");
|
|
1081
|
+
const contentElement = ref(null);
|
|
1082
|
+
const inside = /* @__PURE__ */ new Set();
|
|
1083
|
+
let returnFocusElement = null;
|
|
1084
|
+
const layer = useOverlayLayer({
|
|
1085
|
+
active: computed(() => isOpen.value && !disabled.value),
|
|
1086
|
+
element: contentElement,
|
|
1087
|
+
baseZIndex: 100
|
|
1088
|
+
});
|
|
1089
|
+
function setOpen(value) {
|
|
1090
|
+
if (value && disabled.value) return;
|
|
1091
|
+
const previous = isOpen.value;
|
|
1092
|
+
if (props.open === void 0) uncontrolledOpen.value = value;
|
|
1093
|
+
if (previous !== value) emit("update:open", value);
|
|
1094
|
+
}
|
|
1095
|
+
function rememberFocus() {
|
|
1096
|
+
if (typeof document === "undefined" || returnFocusElement) return;
|
|
1097
|
+
const activeElement = document.activeElement;
|
|
1098
|
+
if (activeElement instanceof HTMLElement) returnFocusElement = activeElement;
|
|
1099
|
+
}
|
|
1100
|
+
function open(options) {
|
|
1101
|
+
if (disabled.value) return;
|
|
1102
|
+
rememberFocus();
|
|
1103
|
+
pendingFocus.value = getFocusTarget(options);
|
|
1104
|
+
setOpen(true);
|
|
1105
|
+
}
|
|
1106
|
+
function focusReturnTarget() {
|
|
1107
|
+
const target = returnFocusElement ?? trigger.value;
|
|
1108
|
+
nextTick(() => target?.focus());
|
|
1109
|
+
}
|
|
1110
|
+
function close(options = {}) {
|
|
1111
|
+
setOpen(false);
|
|
1112
|
+
pendingFocus.value = false;
|
|
1113
|
+
if (options.focusTrigger || options.returnFocus) focusReturnTarget();
|
|
1114
|
+
}
|
|
1115
|
+
function toggle() {
|
|
1116
|
+
if (isOpen.value) close({ returnFocus: true });
|
|
1117
|
+
else open();
|
|
1118
|
+
}
|
|
1119
|
+
function openAt(point, options) {
|
|
1120
|
+
activeReference.value = createVirtualAnchor(point);
|
|
1121
|
+
open(options);
|
|
1122
|
+
}
|
|
1123
|
+
function setTrigger(element, nextId) {
|
|
1124
|
+
if (trigger.value && trigger.value !== element) inside.delete(trigger.value);
|
|
1125
|
+
trigger.value = element;
|
|
1126
|
+
triggerId.value = nextId;
|
|
1127
|
+
if (element) inside.add(element);
|
|
1128
|
+
}
|
|
1129
|
+
const context = {
|
|
1130
|
+
id,
|
|
1131
|
+
isOpen,
|
|
1132
|
+
disabled,
|
|
1133
|
+
modal,
|
|
1134
|
+
trigger,
|
|
1135
|
+
triggerId,
|
|
1136
|
+
contentId,
|
|
1137
|
+
reference,
|
|
1138
|
+
pendingFocus,
|
|
1139
|
+
layer,
|
|
1140
|
+
open,
|
|
1141
|
+
close,
|
|
1142
|
+
toggle,
|
|
1143
|
+
openAt,
|
|
1144
|
+
setTrigger,
|
|
1145
|
+
setReference(nextReference) {
|
|
1146
|
+
activeReference.value = nextReference;
|
|
1147
|
+
},
|
|
1148
|
+
setReturnFocus(element) {
|
|
1149
|
+
returnFocusElement = element;
|
|
1150
|
+
},
|
|
1151
|
+
registerInside(element) {
|
|
1152
|
+
inside.add(element);
|
|
1153
|
+
},
|
|
1154
|
+
unregisterInside(element) {
|
|
1155
|
+
inside.delete(element);
|
|
1156
|
+
},
|
|
1157
|
+
isInside(event) {
|
|
1158
|
+
return [...inside].some((element) => isEventWithinElement(event, element));
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
const slotProps = computed(() => ({
|
|
1162
|
+
isOpen: isOpen.value,
|
|
1163
|
+
open,
|
|
1164
|
+
close,
|
|
1165
|
+
toggle,
|
|
1166
|
+
openAt
|
|
1167
|
+
}));
|
|
1168
|
+
watch(disabled, (value) => {
|
|
1169
|
+
if (value) close();
|
|
1077
1170
|
});
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1171
|
+
watch(isOpen, (value) => {
|
|
1172
|
+
if (!value) activeReference.value = null;
|
|
1173
|
+
}, { flush: "sync" });
|
|
1174
|
+
provide(rootKey, context);
|
|
1175
|
+
__expose({
|
|
1176
|
+
open,
|
|
1177
|
+
close,
|
|
1178
|
+
toggle,
|
|
1179
|
+
openAt
|
|
1083
1180
|
});
|
|
1084
|
-
return () =>
|
|
1181
|
+
return createSlot("default", { $: [() => slotProps.value] });
|
|
1085
1182
|
}
|
|
1086
1183
|
});
|
|
1087
|
-
|
|
1088
|
-
|
|
1184
|
+
//#endregion
|
|
1185
|
+
//#region src/components/dropdown-menu/dropdown-menu-separator.vue
|
|
1186
|
+
var dropdown_menu_separator_default = /* @__PURE__ */ defineVaporComponent({
|
|
1187
|
+
name: "RpDropdownMenuSeparator",
|
|
1089
1188
|
inheritAttrs: false,
|
|
1189
|
+
__name: "dropdown-menu-separator",
|
|
1090
1190
|
props: {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
default: false
|
|
1095
|
-
}
|
|
1191
|
+
id: {},
|
|
1192
|
+
as: { default: "div" },
|
|
1193
|
+
orientation: { default: "horizontal" }
|
|
1096
1194
|
},
|
|
1097
|
-
setup(
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
};
|
|
1195
|
+
setup(__props) {
|
|
1196
|
+
const props = __props;
|
|
1197
|
+
const attrs = useAttrs();
|
|
1198
|
+
useRequiredInject(menuKey, "RpDropdownMenuSeparator");
|
|
1199
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1200
|
+
id: props.id,
|
|
1201
|
+
role: "separator",
|
|
1202
|
+
"aria-orientation": props.orientation,
|
|
1203
|
+
class: "rp-dropdown-menu__separator",
|
|
1204
|
+
"data-orientation": props.orientation
|
|
1205
|
+
}));
|
|
1206
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, null, 1);
|
|
1110
1207
|
}
|
|
1111
1208
|
});
|
|
1112
|
-
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region src/components/dropdown-menu/dropdown-menu-sub.vue
|
|
1211
|
+
var dropdown_menu_sub_default = /* @__PURE__ */ defineVaporComponent({
|
|
1113
1212
|
name: "RpDropdownMenuSub",
|
|
1213
|
+
__name: "dropdown-menu-sub",
|
|
1114
1214
|
props: {
|
|
1115
1215
|
open: {
|
|
1116
1216
|
type: Boolean,
|
|
@@ -1122,7 +1222,9 @@ var DropdownMenuSub = defineComponent({
|
|
|
1122
1222
|
}
|
|
1123
1223
|
},
|
|
1124
1224
|
emits: ["update:open"],
|
|
1125
|
-
setup(
|
|
1225
|
+
setup(__props, { emit: __emit }) {
|
|
1226
|
+
const props = __props;
|
|
1227
|
+
const emit = __emit;
|
|
1126
1228
|
const parentMenu = useRequiredInject(menuKey, "RpDropdownMenuSub");
|
|
1127
1229
|
const uncontrolled = ref(props.defaultOpen);
|
|
1128
1230
|
const isOpen = computed(() => props.open ?? uncontrolled.value);
|
|
@@ -1164,25 +1266,91 @@ var DropdownMenuSub = defineComponent({
|
|
|
1164
1266
|
if (!open) context.close(false);
|
|
1165
1267
|
});
|
|
1166
1268
|
onBeforeUnmount(() => parentMenu.unregisterSub(context));
|
|
1167
|
-
return (
|
|
1168
|
-
isOpen: isOpen.value,
|
|
1169
|
-
open: context.open,
|
|
1170
|
-
close: context.close
|
|
1269
|
+
return createSlot("default", {
|
|
1270
|
+
isOpen: () => isOpen.value,
|
|
1271
|
+
open: () => context.open,
|
|
1272
|
+
close: () => context.close
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
});
|
|
1276
|
+
//#endregion
|
|
1277
|
+
//#region src/components/dropdown-menu/dropdown-menu-sub-content.vue
|
|
1278
|
+
var dropdown_menu_sub_content_default = /* @__PURE__ */ defineVaporComponent({
|
|
1279
|
+
name: "RpDropdownMenuSubContent",
|
|
1280
|
+
inheritAttrs: false,
|
|
1281
|
+
__name: "dropdown-menu-sub-content",
|
|
1282
|
+
props: {
|
|
1283
|
+
placement: { default: "right-start" },
|
|
1284
|
+
id: {},
|
|
1285
|
+
as: { default: "div" },
|
|
1286
|
+
offset: {},
|
|
1287
|
+
strategy: { default: "absolute" },
|
|
1288
|
+
flip: {
|
|
1289
|
+
type: Boolean,
|
|
1290
|
+
default: true
|
|
1291
|
+
},
|
|
1292
|
+
shift: {
|
|
1293
|
+
type: Boolean,
|
|
1294
|
+
default: true
|
|
1295
|
+
},
|
|
1296
|
+
collisionPadding: { default: 8 },
|
|
1297
|
+
avoidCollisions: {
|
|
1298
|
+
type: Boolean,
|
|
1299
|
+
default: true
|
|
1300
|
+
},
|
|
1301
|
+
forceMount: {
|
|
1302
|
+
type: Boolean,
|
|
1303
|
+
default: false
|
|
1304
|
+
},
|
|
1305
|
+
ariaLabel: {},
|
|
1306
|
+
ariaLabelledby: {},
|
|
1307
|
+
ariaDescribedby: {}
|
|
1308
|
+
},
|
|
1309
|
+
emits: [
|
|
1310
|
+
"escapeKeyDown",
|
|
1311
|
+
"pointerDownOutside",
|
|
1312
|
+
"focusOutside",
|
|
1313
|
+
"interactOutside"
|
|
1314
|
+
],
|
|
1315
|
+
setup(__props, { emit: __emit }) {
|
|
1316
|
+
const props = __props;
|
|
1317
|
+
const emit = __emit;
|
|
1318
|
+
const { actualPlacement, isOpen, shouldRender, rootAttrs, setElement, close } = useDropdownMenuPrimitiveContent(props, useAttrs(), {
|
|
1319
|
+
escapeKeyDown: (event) => emit("escapeKeyDown", event),
|
|
1320
|
+
pointerDownOutside: (event) => emit("pointerDownOutside", event),
|
|
1321
|
+
focusOutside: (event) => emit("focusOutside", event),
|
|
1322
|
+
interactOutside: (event) => emit("interactOutside", event)
|
|
1323
|
+
}, true);
|
|
1324
|
+
return createIf(() => unref(shouldRender), () => {
|
|
1325
|
+
const n3 = createDynamicComponent(() => __props.as, { $: [() => unref(rootAttrs)] }, extend(() => {
|
|
1326
|
+
return createSlot("default", {
|
|
1327
|
+
isOpen: () => unref(isOpen),
|
|
1328
|
+
placement: () => unref(actualPlacement),
|
|
1329
|
+
close: () => unref(close)
|
|
1330
|
+
});
|
|
1331
|
+
}, { _: 8 }), 1);
|
|
1332
|
+
setTemplateRefBinding(n3, () => setElement, void 0, void 0, "setElement");
|
|
1333
|
+
return n3;
|
|
1171
1334
|
});
|
|
1172
1335
|
}
|
|
1173
1336
|
});
|
|
1174
|
-
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region src/components/dropdown-menu/dropdown-menu-sub-trigger.vue
|
|
1339
|
+
var dropdown_menu_sub_trigger_default = /* @__PURE__ */ defineVaporComponent({
|
|
1175
1340
|
name: "RpDropdownMenuSubTrigger",
|
|
1176
1341
|
inheritAttrs: false,
|
|
1342
|
+
__name: "dropdown-menu-sub-trigger",
|
|
1177
1343
|
props: {
|
|
1178
|
-
id:
|
|
1179
|
-
as:
|
|
1344
|
+
id: {},
|
|
1345
|
+
as: { default: "button" },
|
|
1180
1346
|
disabled: {
|
|
1181
1347
|
type: Boolean,
|
|
1182
1348
|
default: false
|
|
1183
1349
|
}
|
|
1184
1350
|
},
|
|
1185
|
-
setup(
|
|
1351
|
+
setup(__props) {
|
|
1352
|
+
const props = __props;
|
|
1353
|
+
const attrs = useAttrs();
|
|
1186
1354
|
const menu = useRequiredInject(menuKey, "RpDropdownMenuSubTrigger");
|
|
1187
1355
|
const sub = useRequiredInject(subKey, "RpDropdownMenuSubTrigger");
|
|
1188
1356
|
const generatedId = useId();
|
|
@@ -1201,55 +1369,133 @@ var DropdownMenuSubTrigger = defineComponent({
|
|
|
1201
1369
|
menu.registerItem(registration);
|
|
1202
1370
|
onBeforeUnmount(() => menu.unregisterItem(id.value));
|
|
1203
1371
|
function setElement(value) {
|
|
1204
|
-
|
|
1372
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
1373
|
+
sub.trigger.value = resolved;
|
|
1374
|
+
});
|
|
1205
1375
|
}
|
|
1206
1376
|
function onMouseenter() {
|
|
1207
1377
|
if (isDisabled.value) return;
|
|
1208
1378
|
menu.setActive(id.value);
|
|
1209
1379
|
sub.open(false);
|
|
1210
1380
|
}
|
|
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?.({
|
|
1381
|
+
function onClick(event) {
|
|
1382
|
+
if (!event.defaultPrevented && !isDisabled.value) sub.open("first");
|
|
1383
|
+
}
|
|
1384
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1385
|
+
id: id.value,
|
|
1386
|
+
type: props.as === "button" ? "button" : void 0,
|
|
1387
|
+
role: "menuitem",
|
|
1388
|
+
tabindex: -1,
|
|
1389
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
1390
|
+
"aria-disabled": optionalAttr(isDisabled.value),
|
|
1391
|
+
"aria-haspopup": "menu",
|
|
1392
|
+
"aria-expanded": sub.isOpen.value,
|
|
1393
|
+
"aria-controls": sub.contentId.value,
|
|
1394
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
1395
|
+
"data-focused": optionalAttr(focused.value),
|
|
1396
|
+
"data-highlighted": optionalAttr(focused.value),
|
|
1397
|
+
"data-state": sub.isOpen.value ? "open" : "closed",
|
|
1398
|
+
class: bem("rp-dropdown-menu__item", {
|
|
1239
1399
|
focused: focused.value,
|
|
1240
1400
|
disabled: isDisabled.value,
|
|
1241
|
-
|
|
1242
|
-
open: sub.
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1401
|
+
submenu: true,
|
|
1402
|
+
open: sub.isOpen.value
|
|
1403
|
+
}),
|
|
1404
|
+
onClick,
|
|
1405
|
+
onMouseenter
|
|
1406
|
+
}));
|
|
1407
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
1408
|
+
return createSlot("default", {
|
|
1409
|
+
focused: () => focused.value,
|
|
1410
|
+
disabled: () => isDisabled.value,
|
|
1411
|
+
isOpen: () => unref(sub).isOpen.value,
|
|
1412
|
+
open: () => unref(sub).open,
|
|
1413
|
+
close: () => unref(sub).close
|
|
1414
|
+
});
|
|
1415
|
+
}, { _: 8 }), 1);
|
|
1416
|
+
setTemplateRefBinding(n1, () => setElement);
|
|
1417
|
+
return n1;
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
//#endregion
|
|
1421
|
+
//#region src/components/dropdown-menu/dropdown-menu-trigger.vue
|
|
1422
|
+
var dropdown_menu_trigger_default = /* @__PURE__ */ defineVaporComponent({
|
|
1423
|
+
name: "RpDropdownMenuTrigger",
|
|
1424
|
+
inheritAttrs: false,
|
|
1425
|
+
__name: "dropdown-menu-trigger",
|
|
1426
|
+
props: {
|
|
1427
|
+
id: {},
|
|
1428
|
+
as: { default: "button" },
|
|
1429
|
+
disabled: {
|
|
1430
|
+
type: Boolean,
|
|
1431
|
+
default: false
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
setup(__props) {
|
|
1435
|
+
const props = __props;
|
|
1436
|
+
const attrs = useAttrs();
|
|
1437
|
+
const root = useRequiredInject(rootKey, "RpDropdownMenuTrigger");
|
|
1438
|
+
const generatedId = useId();
|
|
1439
|
+
const id = computed(() => props.id ?? `${generatedId}-trigger`);
|
|
1440
|
+
const element = ref(null);
|
|
1441
|
+
const isDisabled = computed(() => root.disabled.value || props.disabled);
|
|
1442
|
+
function setElement(value) {
|
|
1443
|
+
resolveHTMLElementRef(value, id.value, (resolved) => {
|
|
1444
|
+
element.value = resolved;
|
|
1445
|
+
root.setTrigger(resolved, id.value);
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
function openWithReference(focus = "first") {
|
|
1449
|
+
root.setReference(element.value);
|
|
1450
|
+
root.setReturnFocus(element.value);
|
|
1451
|
+
root.open({ focus });
|
|
1452
|
+
}
|
|
1453
|
+
function onClick(event) {
|
|
1454
|
+
if (event.defaultPrevented || isDisabled.value) return;
|
|
1455
|
+
root.setReference(element.value);
|
|
1456
|
+
root.setReturnFocus(element.value);
|
|
1457
|
+
root.toggle();
|
|
1458
|
+
}
|
|
1459
|
+
function onKeydown(event) {
|
|
1460
|
+
if (isDisabled.value) return;
|
|
1461
|
+
if (event.key === "ArrowUp") {
|
|
1462
|
+
event.preventDefault();
|
|
1463
|
+
openWithReference("last");
|
|
1464
|
+
} else if ([
|
|
1465
|
+
"Enter",
|
|
1466
|
+
" ",
|
|
1467
|
+
"ArrowDown"
|
|
1468
|
+
].includes(event.key)) {
|
|
1469
|
+
event.preventDefault();
|
|
1470
|
+
openWithReference("first");
|
|
1471
|
+
} else if (event.key === "Escape") root.close({ focusTrigger: true });
|
|
1472
|
+
}
|
|
1473
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
1474
|
+
id: id.value,
|
|
1475
|
+
type: props.as === "button" ? "button" : void 0,
|
|
1476
|
+
disabled: props.as === "button" ? optionalAttr(isDisabled.value) : void 0,
|
|
1477
|
+
"aria-controls": root.contentId.value,
|
|
1478
|
+
"aria-expanded": root.isOpen.value,
|
|
1479
|
+
"aria-haspopup": "menu",
|
|
1480
|
+
"aria-disabled": props.as === "button" ? void 0 : optionalAttr(isDisabled.value),
|
|
1481
|
+
"data-state": root.isOpen.value ? "open" : "closed",
|
|
1482
|
+
"data-disabled": optionalAttr(isDisabled.value),
|
|
1483
|
+
onClick,
|
|
1484
|
+
onKeydown
|
|
1485
|
+
}));
|
|
1486
|
+
onBeforeUnmount(() => root.setTrigger(null));
|
|
1487
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
1488
|
+
return createSlot("default", { isOpen: () => unref(root).isOpen.value });
|
|
1489
|
+
}, { _: 8 }), 1);
|
|
1490
|
+
setTemplateRefBinding(n1, () => setElement);
|
|
1491
|
+
return n1;
|
|
1246
1492
|
}
|
|
1247
1493
|
});
|
|
1248
1494
|
//#endregion
|
|
1249
1495
|
//#region ~icons/lucide/chevron-right
|
|
1250
|
-
var t0$
|
|
1496
|
+
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
1497
|
function render(_ctx) {
|
|
1252
|
-
return t0$
|
|
1498
|
+
return t0$2();
|
|
1253
1499
|
}
|
|
1254
1500
|
var chevron_right_default = markRaw(defineVaporComponent({
|
|
1255
1501
|
name: "lucide-chevron-right",
|
|
@@ -1316,170 +1562,121 @@ function getNextEnabledIndex(items, index, direction) {
|
|
|
1316
1562
|
return enabledIndexes[enabledIndexes.length - 1];
|
|
1317
1563
|
}
|
|
1318
1564
|
//#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({
|
|
1565
|
+
//#region src/components/dropdown-menu/dropdown-menu-item-row.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
1566
|
+
var t0$1 = template("<div>");
|
|
1567
|
+
var t1$1 = template("<div class=rp-dropdown-menu__item-wrap role=none><button></button>", 1);
|
|
1568
|
+
//#endregion
|
|
1569
|
+
//#region src/components/dropdown-menu/dropdown-menu-item-row.vue
|
|
1570
|
+
var dropdown_menu_item_row_default = /* @__PURE__ */ defineVaporComponent({
|
|
1329
1571
|
name: "RpDropdownMenuItemRow",
|
|
1572
|
+
__name: "dropdown-menu-item-row",
|
|
1330
1573
|
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
|
-
}
|
|
1574
|
+
context: {},
|
|
1575
|
+
index: {},
|
|
1576
|
+
item: {},
|
|
1577
|
+
parentPath: {}
|
|
1357
1578
|
},
|
|
1358
|
-
setup(
|
|
1579
|
+
setup(__props) {
|
|
1580
|
+
const props = __props;
|
|
1359
1581
|
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)),
|
|
1582
|
+
const hasSubmenu = computed(() => hasItemSubmenu(props.item));
|
|
1583
|
+
const focused = computed(() => props.context.isItemFocused(path.value));
|
|
1584
|
+
const disabled = computed(() => Boolean(props.item.disabled));
|
|
1585
|
+
const submenuOpen = computed(() => hasSubmenu.value && props.context.isSubmenuOpen(path.value));
|
|
1586
|
+
const itemProps = computed(() => props.context.getItemProps(props.item, path.value, focused.value, disabled.value, submenuOpen.value));
|
|
1587
|
+
const publicItemProps = computed(() => ({
|
|
1588
|
+
...itemProps.value,
|
|
1589
|
+
...props.context.getPublicPartAttrs?.("item", { class: itemProps.value.class })
|
|
1590
|
+
}));
|
|
1591
|
+
const slotProps = computed(() => props.context.getItemSlotProps(props.item, path.value, focused.value, disabled.value, submenuOpen.value));
|
|
1592
|
+
const itemElement = ref(null);
|
|
1593
|
+
const submenuElement = ref(null);
|
|
1594
|
+
const { actualPlacement, floatingStyle } = useFloatingPosition({
|
|
1595
|
+
reference: itemElement,
|
|
1596
|
+
floating: submenuElement,
|
|
1597
|
+
open: submenuOpen,
|
|
1433
1598
|
placement: props.context.getSubmenuPlacement,
|
|
1434
1599
|
strategy: props.context.getStrategy,
|
|
1435
1600
|
offset: () => 4,
|
|
1436
1601
|
flip: props.context.getFlip,
|
|
1437
1602
|
shift: props.context.getShift,
|
|
1438
|
-
collisionPadding: props.context.getCollisionPadding
|
|
1439
|
-
arrowEnabled: () => false
|
|
1603
|
+
collisionPadding: props.context.getCollisionPadding
|
|
1440
1604
|
});
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1605
|
+
const submenuProps = computed(() => props.context.getSubmenuProps(props.item, path.value, true));
|
|
1606
|
+
const publicSubmenuProps = computed(() => ({
|
|
1607
|
+
...submenuProps.value,
|
|
1608
|
+
...props.context.getPublicPartAttrs?.("submenu", {
|
|
1609
|
+
class: submenuProps.value.class,
|
|
1610
|
+
style: floatingStyle.value
|
|
1611
|
+
})
|
|
1612
|
+
}));
|
|
1613
|
+
const placementSide = computed(() => actualPlacement.value.split("-")[0]);
|
|
1614
|
+
function getChildKey(index, child) {
|
|
1615
|
+
return `${getPathKey([...path.value, index])}:${String(child.value)}`;
|
|
1616
|
+
}
|
|
1617
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
1618
|
+
const _component_DropdownMenuItemRow__self = resolveComponent("DropdownMenuItemRow", true);
|
|
1619
|
+
const n10 = t1$1();
|
|
1620
|
+
const n1 = child(n10);
|
|
1621
|
+
renderEffect(() => setDynamicProps(n1, [publicItemProps.value]));
|
|
1622
|
+
setInsertionState(n1, null, 0);
|
|
1623
|
+
createSlot("item", { $: [() => slotProps.value] });
|
|
1624
|
+
setStaticTemplateRef(n1, itemElement, null, "itemElement");
|
|
1625
|
+
setInsertionState(n10, null, 1);
|
|
1626
|
+
createIf(() => hasSubmenu.value && submenuOpen.value, () => {
|
|
1627
|
+
const n9 = t0$1();
|
|
1628
|
+
renderEffect(() => setDynamicProps(n9, [publicSubmenuProps.value, {
|
|
1450
1629
|
"data-state": "open",
|
|
1451
|
-
"data-placement":
|
|
1452
|
-
"data-side":
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1630
|
+
"data-placement": unref(actualPlacement),
|
|
1631
|
+
"data-side": placementSide.value
|
|
1632
|
+
}]));
|
|
1633
|
+
setInsertionState(n9, null, 0);
|
|
1634
|
+
createFor(() => __props.item.children ?? [], (_for_item0, _for_key0) => {
|
|
1635
|
+
return createComponentWithFallback(_component_DropdownMenuItemRow__self, {
|
|
1636
|
+
context: () => __props.context,
|
|
1637
|
+
index: () => _for_key0.value,
|
|
1638
|
+
item: () => _for_item0.value,
|
|
1639
|
+
"parent-path": () => path.value
|
|
1640
|
+
}, { "item": extend((childSlotProps) => {
|
|
1641
|
+
return createSlot("item", { $: [() => childSlotProps] });
|
|
1642
|
+
}, { _: 8 }) });
|
|
1643
|
+
}, (child, childIndex) => getChildKey(childIndex, child), 3);
|
|
1644
|
+
_setTemplateRef(n9, submenuElement, null, "submenuElement");
|
|
1645
|
+
return n9;
|
|
1646
|
+
});
|
|
1647
|
+
return n10;
|
|
1460
1648
|
}
|
|
1461
1649
|
});
|
|
1462
|
-
|
|
1650
|
+
//#endregion
|
|
1651
|
+
//#region src/components/dropdown-menu/dropdown-menu-items.vue
|
|
1652
|
+
var dropdown_menu_items_default = /* @__PURE__ */ defineVaporComponent({
|
|
1463
1653
|
name: "RpDropdownMenuItems",
|
|
1654
|
+
__name: "dropdown-menu-items",
|
|
1464
1655
|
props: {
|
|
1465
|
-
context:
|
|
1466
|
-
items: {
|
|
1467
|
-
|
|
1468
|
-
required: true
|
|
1469
|
-
}
|
|
1656
|
+
context: {},
|
|
1657
|
+
items: {},
|
|
1658
|
+
parentPath: { default: () => [] }
|
|
1470
1659
|
},
|
|
1471
|
-
setup(
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1660
|
+
setup(__props) {
|
|
1661
|
+
const props = __props;
|
|
1662
|
+
function getItemKey(index, item) {
|
|
1663
|
+
return `${getPathKey([...props.parentPath, index])}:${String(item.value)}`;
|
|
1664
|
+
}
|
|
1665
|
+
return createFor(() => __props.items, (_for_item0, _for_key0) => {
|
|
1666
|
+
return createComponent(dropdown_menu_item_row_default, {
|
|
1667
|
+
context: () => __props.context,
|
|
1668
|
+
index: () => _for_key0.value,
|
|
1669
|
+
item: () => _for_item0.value,
|
|
1670
|
+
"parent-path": () => __props.parentPath
|
|
1671
|
+
}, { "item": extend((slotProps) => {
|
|
1672
|
+
return createSlot("item", { $: [() => slotProps] });
|
|
1673
|
+
}, { _: 8 }) });
|
|
1674
|
+
}, (item, index) => getItemKey(index, item), 2);
|
|
1478
1675
|
}
|
|
1479
1676
|
});
|
|
1480
1677
|
//#endregion
|
|
1481
1678
|
//#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 }) {
|
|
1679
|
+
function useDropdownMenuDisclosure({ props, emit, rootRef, menuRef, targetRef, uncontrolledOpen, isDisabled, isOpen, isVisible, focusedPath, resetFocus, resetSubmenus, resetHoverIntent, focusItem, focusMenu, focusTrigger, layer }) {
|
|
1483
1680
|
function setOpen(nextOpen) {
|
|
1484
1681
|
if (nextOpen && isDisabled.value) return;
|
|
1485
1682
|
const previousOpen = isOpen.value;
|
|
@@ -1517,17 +1714,52 @@ function useDropdownMenuDisclosure({ props, emit, rootRef, menuRef, targetRef, u
|
|
|
1517
1714
|
focusMenu();
|
|
1518
1715
|
} else resetMenuFocus();
|
|
1519
1716
|
});
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1717
|
+
function emitOutside(type, originalEvent) {
|
|
1718
|
+
const outsideEvent = createOutsideEvent(originalEvent);
|
|
1719
|
+
if (type === "pointer") emit.pointerDownOutside?.(outsideEvent);
|
|
1720
|
+
else emit.focusOutside?.(outsideEvent);
|
|
1721
|
+
emit.interactOutside?.(outsideEvent);
|
|
1722
|
+
return outsideEvent;
|
|
1723
|
+
}
|
|
1724
|
+
function isInside(event) {
|
|
1725
|
+
return isEventWithinTargets(event, [
|
|
1726
|
+
rootRef,
|
|
1727
|
+
menuRef,
|
|
1728
|
+
targetRef,
|
|
1729
|
+
...props.ignore ?? []
|
|
1730
|
+
]);
|
|
1731
|
+
}
|
|
1732
|
+
function blockModalInteraction(event) {
|
|
1733
|
+
if (!props.modal) return;
|
|
1734
|
+
if (event.cancelable) event.preventDefault();
|
|
1735
|
+
event.stopPropagation();
|
|
1736
|
+
if (event.type === "pointerdown") blockNextDocumentClick();
|
|
1737
|
+
}
|
|
1738
|
+
function onDocumentPointerdown(event) {
|
|
1739
|
+
if (!layer.isTopLayer()) return;
|
|
1740
|
+
if (isInside(event)) return;
|
|
1741
|
+
const outsideEvent = emitOutside("pointer", event);
|
|
1742
|
+
blockModalInteraction(event);
|
|
1743
|
+
if (!outsideEvent.defaultPrevented) close({ focusTrigger: Boolean(props.modal) });
|
|
1744
|
+
}
|
|
1745
|
+
function onDocumentFocus(event) {
|
|
1746
|
+
if (!layer.isTopLayer()) return;
|
|
1747
|
+
if (isInside(event)) return;
|
|
1748
|
+
const outsideEvent = emitOutside("focus", event);
|
|
1749
|
+
blockModalInteraction(event);
|
|
1750
|
+
if (!outsideEvent.defaultPrevented) close({ focusTrigger: Boolean(props.modal) });
|
|
1751
|
+
else if (props.modal) focusMenu();
|
|
1752
|
+
}
|
|
1753
|
+
let isListening = false;
|
|
1754
|
+
function setDocumentListeners(active) {
|
|
1755
|
+
if (typeof document === "undefined" || active === isListening) return;
|
|
1756
|
+
isListening = active;
|
|
1757
|
+
const method = active ? "addEventListener" : "removeEventListener";
|
|
1758
|
+
document[method]("pointerdown", onDocumentPointerdown, true);
|
|
1759
|
+
document[method]("focusin", onDocumentFocus, true);
|
|
1760
|
+
}
|
|
1761
|
+
watch(isVisible, setDocumentListeners, { immediate: true });
|
|
1762
|
+
onBeforeUnmount(() => setDocumentListeners(false));
|
|
1531
1763
|
return {
|
|
1532
1764
|
open,
|
|
1533
1765
|
close,
|
|
@@ -1963,7 +2195,6 @@ function useDropdownMenuPortalPosition(options) {
|
|
|
1963
2195
|
flip: () => options.props.flip !== false,
|
|
1964
2196
|
shift: () => options.props.shift !== false,
|
|
1965
2197
|
collisionPadding: () => options.props.collisionPadding ?? 8,
|
|
1966
|
-
arrowEnabled: () => Boolean(options.props.arrow),
|
|
1967
2198
|
restartKey: options.restartKey
|
|
1968
2199
|
});
|
|
1969
2200
|
return {
|
|
@@ -2125,6 +2356,7 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2125
2356
|
const placement = computed(() => props.placement ?? "bottom-start");
|
|
2126
2357
|
const requestedTeleportTarget = computed(() => props.portalTo ?? props.teleportTo);
|
|
2127
2358
|
const teleportTo = useTeleportTarget(() => requestedTeleportTarget.value);
|
|
2359
|
+
const teleportPositioningKey = useTeleportPositioningKey();
|
|
2128
2360
|
const shouldTeleport = computed(() => props.portal ?? props.teleport !== false);
|
|
2129
2361
|
const { isExplicitTarget, reference, resolvedTarget } = useFloatingTarget(() => props.target, rootRef);
|
|
2130
2362
|
const targetElement = computed(() => isElementReference(resolvedTarget.value) ? resolvedTarget.value : null);
|
|
@@ -2132,6 +2364,11 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2132
2364
|
const isDisabled = computed(() => Boolean(props.disabled));
|
|
2133
2365
|
const isOpen = computed(() => props.open ?? uncontrolledOpen.value);
|
|
2134
2366
|
const isVisible = computed(() => isOpen.value && !isDisabled.value);
|
|
2367
|
+
const layer = useOverlayLayer({
|
|
2368
|
+
active: isVisible,
|
|
2369
|
+
element: menuRef,
|
|
2370
|
+
baseZIndex: 100
|
|
2371
|
+
});
|
|
2135
2372
|
const contentHasSubmenu = computed(() => hasNestedItems(visibleItems.value));
|
|
2136
2373
|
const isEmpty = computed(() => visibleItems.value.length === 0);
|
|
2137
2374
|
const { actualPlacement, arrowStyle, contentStyle } = useDropdownMenuPortalPosition({
|
|
@@ -2141,7 +2378,11 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2141
2378
|
arrowRef,
|
|
2142
2379
|
isVisible,
|
|
2143
2380
|
placement,
|
|
2144
|
-
restartKey: () => [
|
|
2381
|
+
restartKey: () => [
|
|
2382
|
+
shouldTeleport.value,
|
|
2383
|
+
teleportTo.value,
|
|
2384
|
+
teleportPositioningKey.value
|
|
2385
|
+
]
|
|
2145
2386
|
});
|
|
2146
2387
|
const placementSide = computed(() => actualPlacement.value.split("-")[0]);
|
|
2147
2388
|
const { focusedPath, focusedIndex, getItemAtPath, focusItem, resetFocus, isItemFocused, moveFocus } = useDropdownMenuNavigation(visibleItems);
|
|
@@ -2180,7 +2421,8 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2180
2421
|
resetHoverIntent: hoverIntent.resetHoverIntent,
|
|
2181
2422
|
focusItem,
|
|
2182
2423
|
focusMenu,
|
|
2183
|
-
focusTrigger
|
|
2424
|
+
focusTrigger,
|
|
2425
|
+
layer
|
|
2184
2426
|
});
|
|
2185
2427
|
const { open, close, toggle } = disclosure;
|
|
2186
2428
|
const { activateItem, selectItem, openSubmenu, closeSubmenu, focusHoveredItem, onTriggerClick, onTriggerKeydown, onMenuKeydown, onMenuMousemove, onMenuMouseleave } = useDropdownMenuInteractions({
|
|
@@ -2300,7 +2542,10 @@ function useDropdownMenu(props, emit = {}) {
|
|
|
2300
2542
|
activeDescendantId,
|
|
2301
2543
|
rootClass,
|
|
2302
2544
|
contentClass,
|
|
2303
|
-
contentStyle
|
|
2545
|
+
contentStyle: computed(() => ({
|
|
2546
|
+
...contentStyle.value,
|
|
2547
|
+
zIndex: layer.zIndex.value
|
|
2548
|
+
})),
|
|
2304
2549
|
arrowStyle,
|
|
2305
2550
|
actualPlacement,
|
|
2306
2551
|
placementSide,
|
|
@@ -2358,6 +2603,7 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2358
2603
|
type: Boolean,
|
|
2359
2604
|
default: false
|
|
2360
2605
|
},
|
|
2606
|
+
ignore: {},
|
|
2361
2607
|
portal: {
|
|
2362
2608
|
type: Boolean,
|
|
2363
2609
|
default: void 0
|
|
@@ -2388,13 +2634,22 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2388
2634
|
classNames: {},
|
|
2389
2635
|
styles: {}
|
|
2390
2636
|
},
|
|
2391
|
-
emits: [
|
|
2637
|
+
emits: [
|
|
2638
|
+
"update:open",
|
|
2639
|
+
"select",
|
|
2640
|
+
"pointerDownOutside",
|
|
2641
|
+
"focusOutside",
|
|
2642
|
+
"interactOutside"
|
|
2643
|
+
],
|
|
2392
2644
|
setup(__props, { emit: __emit }) {
|
|
2393
2645
|
const props = __props;
|
|
2394
2646
|
const emit = __emit;
|
|
2395
|
-
const { rootRef, menuRef, arrowRef, isVisible, isEmpty, visibleItems, renderContext, rootClass, contentClass, contentStyle, arrowStyle, placementSide, isTargetMode, teleportTo, shouldTeleport, contentProps, slotProps } = useDropdownMenu(props, {
|
|
2647
|
+
const { rootRef, menuRef, arrowRef, isVisible, isEmpty, visibleItems, renderContext, rootClass, contentClass, contentStyle, arrowStyle, actualPlacement, placementSide, isTargetMode, teleportTo, shouldTeleport, contentProps, slotProps } = useDropdownMenu(props, {
|
|
2396
2648
|
openChange: (open) => emit("update:open", open),
|
|
2397
|
-
select: (item, event) => emit("select", item, event)
|
|
2649
|
+
select: (item, event) => emit("select", item, event),
|
|
2650
|
+
pointerDownOutside: (event) => emit("pointerDownOutside", event),
|
|
2651
|
+
focusOutside: (event) => emit("focusOutside", event),
|
|
2652
|
+
interactOutside: (event) => emit("interactOutside", event)
|
|
2398
2653
|
});
|
|
2399
2654
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
2400
2655
|
const state = computed(() => isVisible.value ? "open" : "closed");
|
|
@@ -2423,7 +2678,7 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2423
2678
|
style: contentStyle.value
|
|
2424
2679
|
}),
|
|
2425
2680
|
"data-state": state.value,
|
|
2426
|
-
"data-placement":
|
|
2681
|
+
"data-placement": actualPlacement.value
|
|
2427
2682
|
}));
|
|
2428
2683
|
const publicRenderContext = computed(() => ({
|
|
2429
2684
|
...renderContext,
|
|
@@ -2466,7 +2721,7 @@ var dropdown_menu_default = /* @__PURE__ */ defineVaporComponent({
|
|
|
2466
2721
|
return n13;
|
|
2467
2722
|
});
|
|
2468
2723
|
setInsertionState(n26, null, 2);
|
|
2469
|
-
createComponent(
|
|
2724
|
+
createComponent(dropdown_menu_items_default, {
|
|
2470
2725
|
items: () => unref(visibleItems),
|
|
2471
2726
|
context: () => publicRenderContext.value
|
|
2472
2727
|
}, { "item": extend((itemSlotProps) => {
|
|
@@ -2518,6 +2773,6 @@ var dropdownMenuParts = [
|
|
|
2518
2773
|
];
|
|
2519
2774
|
//#endregion
|
|
2520
2775
|
//#region src/components/dropdown-menu/index.ts
|
|
2521
|
-
var DropdownMenuItem =
|
|
2776
|
+
var DropdownMenuItem = dropdown_menu_item_default;
|
|
2522
2777
|
//#endregion
|
|
2523
|
-
export {
|
|
2778
|
+
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 };
|