element-plus
Version:
A Component Library for Vue 3
244 lines (239 loc) • 11 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var drawer = require('./drawer.js');
var vue = require('vue');
var iconsVue = require('@element-plus/icons-vue');
var index$4 = require('../../overlay/index.js');
var focusTrap = require('../../focus-trap/src/focus-trap.vue.js');
var index$3 = require('../../teleport/index.js');
var index$5 = require('../../icon/index.js');
var useResizable = require('./composables/useResizable.js');
var useDialog = require('../../dialog/src/use-dialog.js');
var index = require('../../../hooks/use-deprecated/index.js');
var index$1 = require('../../../hooks/use-namespace/index.js');
var index$2 = require('../../../hooks/use-locale/index.js');
const _hoisted_1 = ["aria-label", "aria-labelledby", "aria-describedby"];
const _hoisted_2 = ["id", "aria-level"];
const _hoisted_3 = ["aria-label"];
const _hoisted_4 = ["id"];
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{
name: "ElDrawer",
inheritAttrs: false
},
__name: "drawer",
props: drawer.drawerProps,
emits: drawer.drawerEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emit = __emit;
const slots = vue.useSlots();
index.useDeprecated(
{
scope: "el-drawer",
from: "the title slot",
replacement: "the header slot",
version: "3.0.0",
ref: "https://element-plus.org/en-US/component/drawer.html#slots"
},
vue.computed(() => !!slots.title)
);
const drawerRef = vue.ref();
const focusStartRef = vue.ref();
const draggerRef = vue.ref();
const ns = index$1.useNamespace("drawer");
const { t } = index$2.useLocale();
const {
afterEnter,
afterLeave,
beforeLeave,
visible,
rendered,
titleId,
bodyId,
zIndex,
onModalClick,
onOpenAutoFocus,
onCloseAutoFocus,
onFocusoutPrevented,
onCloseRequested,
handleClose
} = useDialog.useDialog(props, drawerRef);
const { isHorizontal, size, isResizing } = useResizable.useResizable(props, draggerRef, emit);
const penetrable = vue.computed(() => props.modalPenetrable && !props.modal);
__expose({
handleClose,
afterEnter,
afterLeave
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.unref(index$3.ElTeleport), {
to: __props.appendTo,
disabled: __props.appendTo !== "body" ? false : !__props.appendToBody
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.Transition, {
name: vue.unref(ns).b("fade"),
onAfterEnter: vue.unref(afterEnter),
onAfterLeave: vue.unref(afterLeave),
onBeforeLeave: vue.unref(beforeLeave),
persisted: ""
}, {
default: vue.withCtx(() => {
var _a;
return [
vue.withDirectives(vue.createVNode(vue.unref(index$4.ElOverlay), {
mask: __props.modal,
"overlay-class": [
vue.unref(ns).is("drawer"),
(_a = __props.modalClass) != null ? _a : "",
`${vue.unref(ns).namespace.value}-modal-drawer`,
vue.unref(ns).is("penetrable", penetrable.value)
],
"z-index": vue.unref(zIndex),
onClick: vue.unref(onModalClick)
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(focusTrap.default), {
loop: "",
trapped: vue.unref(visible),
"focus-trap-el": drawerRef.value,
"focus-start-el": focusStartRef.value,
onFocusAfterTrapped: vue.unref(onOpenAutoFocus),
onFocusAfterReleased: vue.unref(onCloseAutoFocus),
onFocusoutPrevented: vue.unref(onFocusoutPrevented),
onReleaseRequested: vue.unref(onCloseRequested)
}, {
default: vue.withCtx(() => [
vue.createElementVNode("div", vue.mergeProps({
ref_key: "drawerRef",
ref: drawerRef,
"aria-modal": "true",
"aria-label": __props.title || void 0,
"aria-labelledby": !__props.title ? vue.unref(titleId) : void 0,
"aria-describedby": vue.unref(bodyId)
}, _ctx.$attrs, {
class: [
vue.unref(ns).b(),
__props.direction,
vue.unref(visible) && "open",
vue.unref(ns).is("dragging", vue.unref(isResizing))
],
style: { [vue.unref(isHorizontal) ? "width" : "height"]: vue.unref(size) },
role: "dialog",
onClick: _cache[1] || (_cache[1] = vue.withModifiers(() => {
}, ["stop"]))
}), [
vue.createElementVNode(
"span",
{
ref_key: "focusStartRef",
ref: focusStartRef,
class: vue.normalizeClass(vue.unref(ns).e("sr-focus")),
tabindex: "-1"
},
null,
2
/* CLASS */
),
__props.withHeader ? (vue.openBlock(), vue.createElementBlock(
"header",
{
key: 0,
class: vue.normalizeClass([vue.unref(ns).e("header"), __props.headerClass])
},
[
!_ctx.$slots.title ? vue.renderSlot(_ctx.$slots, "header", {
key: 0,
close: vue.unref(handleClose),
titleId: vue.unref(titleId),
titleClass: vue.unref(ns).e("title")
}, () => [
vue.createElementVNode("span", {
id: vue.unref(titleId),
role: "heading",
"aria-level": __props.headerAriaLevel,
class: vue.normalizeClass(vue.unref(ns).e("title"))
}, vue.toDisplayString(__props.title), 11, _hoisted_2)
]) : vue.renderSlot(_ctx.$slots, "title", { key: 1 }, () => [
vue.createCommentVNode(" DEPRECATED SLOT ")
]),
__props.showClose ? (vue.openBlock(), vue.createElementBlock("button", {
key: 2,
"aria-label": vue.unref(t)("el.drawer.close"),
class: vue.normalizeClass(vue.unref(ns).e("close-btn")),
type: "button",
onClick: _cache[0] || (_cache[0] = //@ts-ignore
(...args) => vue.unref(handleClose) && vue.unref(handleClose)(...args))
}, [
vue.createVNode(vue.unref(index$5.ElIcon), {
class: vue.normalizeClass(vue.unref(ns).e("close"))
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(iconsVue.Close))
]),
_: 1
/* STABLE */
}, 8, ["class"])
], 10, _hoisted_3)) : vue.createCommentVNode("v-if", true)
],
2
/* CLASS */
)) : vue.createCommentVNode("v-if", true),
vue.unref(rendered) ? (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
id: vue.unref(bodyId),
class: vue.normalizeClass([vue.unref(ns).e("body"), __props.bodyClass])
}, [
vue.renderSlot(_ctx.$slots, "default")
], 10, _hoisted_4)) : vue.createCommentVNode("v-if", true),
_ctx.$slots.footer ? (vue.openBlock(), vue.createElementBlock(
"div",
{
key: 2,
class: vue.normalizeClass([vue.unref(ns).e("footer"), __props.footerClass])
},
[
vue.renderSlot(_ctx.$slots, "footer")
],
2
/* CLASS */
)) : vue.createCommentVNode("v-if", true),
__props.resizable ? (vue.openBlock(), vue.createElementBlock(
"div",
{
key: 3,
ref_key: "draggerRef",
ref: draggerRef,
style: vue.normalizeStyle({ zIndex: vue.unref(zIndex) }),
class: vue.normalizeClass(vue.unref(ns).e("dragger"))
},
null,
6
/* CLASS, STYLE */
)) : vue.createCommentVNode("v-if", true)
], 16, _hoisted_1)
]),
_: 3
/* FORWARDED */
}, 8, ["trapped", "focus-trap-el", "focus-start-el", "onFocusAfterTrapped", "onFocusAfterReleased", "onFocusoutPrevented", "onReleaseRequested"])
]),
_: 3
/* FORWARDED */
}, 8, ["mask", "overlay-class", "z-index", "onClick"]), [
[vue.vShow, vue.unref(visible)]
])
];
}),
_: 3
/* FORWARDED */
}, 8, ["name", "onAfterEnter", "onAfterLeave", "onBeforeLeave"])
]),
_: 3
/* FORWARDED */
}, 8, ["to", "disabled"]);
};
}
});
exports.default = _sfc_main;
//# sourceMappingURL=drawer.vue2.js.map