106 lines
3.1 KiB
JavaScript
106 lines
3.1 KiB
JavaScript
import { ref, watch, nextTick, mergeProps, createVNode } from 'vue';
|
|
import { t as propsFactory, a8 as makeVOverlayProps, a9 as VDialogTransition, l as genericComponent, F as useProxiedModel, aa as useScopeId, o as useRender, ab as VOverlay, S as VDefaultsProvider, a4 as forwardRefs } from './server.mjs';
|
|
|
|
const makeVDialogProps = propsFactory({
|
|
fullscreen: Boolean,
|
|
retainFocus: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
scrollable: Boolean,
|
|
...makeVOverlayProps({
|
|
origin: "center center",
|
|
scrollStrategy: "block",
|
|
transition: {
|
|
component: VDialogTransition
|
|
},
|
|
zIndex: 2400
|
|
})
|
|
}, "VDialog");
|
|
const VDialog = genericComponent()({
|
|
name: "VDialog",
|
|
props: makeVDialogProps(),
|
|
emits: {
|
|
"update:modelValue": (value) => true,
|
|
afterEnter: () => true,
|
|
afterLeave: () => true
|
|
},
|
|
setup(props, _ref) {
|
|
let {
|
|
emit,
|
|
slots
|
|
} = _ref;
|
|
const isActive = useProxiedModel(props, "modelValue");
|
|
const {
|
|
scopeId
|
|
} = useScopeId();
|
|
const overlay = ref();
|
|
function onAfterEnter() {
|
|
var _a;
|
|
emit("afterEnter");
|
|
if (((_a = overlay.value) == null ? void 0 : _a.contentEl) && !overlay.value.contentEl.contains((void 0).activeElement)) {
|
|
overlay.value.contentEl.focus({
|
|
preventScroll: true
|
|
});
|
|
}
|
|
}
|
|
function onAfterLeave() {
|
|
emit("afterLeave");
|
|
}
|
|
watch(isActive, async (val) => {
|
|
var _a;
|
|
if (!val) {
|
|
await nextTick();
|
|
(_a = overlay.value.activatorEl) == null ? void 0 : _a.focus({
|
|
preventScroll: true
|
|
});
|
|
}
|
|
});
|
|
useRender(() => {
|
|
const overlayProps = VOverlay.filterProps(props);
|
|
const activatorProps = mergeProps({
|
|
"aria-haspopup": "dialog"
|
|
}, props.activatorProps);
|
|
const contentProps = mergeProps({
|
|
tabindex: -1
|
|
}, props.contentProps);
|
|
return createVNode(VOverlay, mergeProps({
|
|
"ref": overlay,
|
|
"class": ["v-dialog", {
|
|
"v-dialog--fullscreen": props.fullscreen,
|
|
"v-dialog--scrollable": props.scrollable
|
|
}, props.class],
|
|
"style": props.style
|
|
}, overlayProps, {
|
|
"modelValue": isActive.value,
|
|
"onUpdate:modelValue": ($event) => isActive.value = $event,
|
|
"aria-modal": "true",
|
|
"activatorProps": activatorProps,
|
|
"contentProps": contentProps,
|
|
"role": "dialog",
|
|
"onAfterEnter": onAfterEnter,
|
|
"onAfterLeave": onAfterLeave
|
|
}, scopeId), {
|
|
activator: slots.activator,
|
|
default: function() {
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return createVNode(VDefaultsProvider, {
|
|
"root": "VDialog"
|
|
}, {
|
|
default: () => {
|
|
var _a;
|
|
return [(_a = slots.default) == null ? void 0 : _a.call(slots, ...args)];
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
return forwardRefs({}, overlay);
|
|
}
|
|
});
|
|
|
|
export { VDialog as V };
|
|
//# sourceMappingURL=VDialog-Pje99w3C.mjs.map
|