drawer2.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var iconsVue = require('@element-plus/icons-vue');
  5. var index$4 = require('../../overlay/index.js');
  6. var focusTrap = require('../../focus-trap/src/focus-trap.js');
  7. var index$3 = require('../../teleport/index.js');
  8. var index$5 = require('../../icon/index.js');
  9. var drawer = require('./drawer.js');
  10. var useResizable = require('./composables/useResizable.js');
  11. var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
  12. var useDialog = require('../../dialog/src/use-dialog.js');
  13. var index = require('../../../hooks/use-deprecated/index.js');
  14. var index$1 = require('../../../hooks/use-namespace/index.js');
  15. var index$2 = require('../../../hooks/use-locale/index.js');
  16. const _hoisted_1 = ["aria-label", "aria-labelledby", "aria-describedby"];
  17. const _hoisted_2 = ["id", "aria-level"];
  18. const _hoisted_3 = ["aria-label"];
  19. const _hoisted_4 = ["id"];
  20. const _sfc_main = vue.defineComponent({
  21. ...{
  22. name: "ElDrawer",
  23. inheritAttrs: false
  24. },
  25. __name: "drawer",
  26. props: drawer.drawerProps,
  27. emits: drawer.drawerEmits,
  28. setup(__props, { expose: __expose, emit: __emit }) {
  29. const props = __props;
  30. const emit = __emit;
  31. const slots = vue.useSlots();
  32. index.useDeprecated(
  33. {
  34. scope: "el-drawer",
  35. from: "the title slot",
  36. replacement: "the header slot",
  37. version: "3.0.0",
  38. ref: "https://element-plus.org/en-US/component/drawer.html#slots"
  39. },
  40. vue.computed(() => !!slots.title)
  41. );
  42. const drawerRef = vue.ref();
  43. const focusStartRef = vue.ref();
  44. const draggerRef = vue.ref();
  45. const ns = index$1.useNamespace("drawer");
  46. const { t } = index$2.useLocale();
  47. const {
  48. afterEnter,
  49. afterLeave,
  50. beforeLeave,
  51. visible,
  52. rendered,
  53. titleId,
  54. bodyId,
  55. zIndex,
  56. onModalClick,
  57. onOpenAutoFocus,
  58. onCloseAutoFocus,
  59. onFocusoutPrevented,
  60. onCloseRequested,
  61. handleClose
  62. } = useDialog.useDialog(props, drawerRef);
  63. const { isHorizontal, size, isResizing } = useResizable.useResizable(props, draggerRef, emit);
  64. const penetrable = vue.computed(() => props.modalPenetrable && !props.modal);
  65. __expose({
  66. handleClose,
  67. afterEnter,
  68. afterLeave
  69. });
  70. return (_ctx, _cache) => {
  71. return vue.openBlock(), vue.createBlock(vue.unref(index$3.ElTeleport), {
  72. to: _ctx.appendTo,
  73. disabled: _ctx.appendTo !== "body" ? false : !_ctx.appendToBody
  74. }, {
  75. default: vue.withCtx(() => [
  76. vue.createVNode(vue.Transition, {
  77. name: vue.unref(ns).b("fade"),
  78. onAfterEnter: vue.unref(afterEnter),
  79. onAfterLeave: vue.unref(afterLeave),
  80. onBeforeLeave: vue.unref(beforeLeave),
  81. persisted: ""
  82. }, {
  83. default: vue.withCtx(() => {
  84. var _a;
  85. return [
  86. vue.withDirectives(vue.createVNode(vue.unref(index$4.ElOverlay), {
  87. mask: _ctx.modal,
  88. "overlay-class": [
  89. vue.unref(ns).is("drawer"),
  90. (_a = _ctx.modalClass) != null ? _a : "",
  91. `${vue.unref(ns).namespace.value}-modal-drawer`,
  92. vue.unref(ns).is("penetrable", penetrable.value)
  93. ],
  94. "z-index": vue.unref(zIndex),
  95. onClick: vue.unref(onModalClick)
  96. }, {
  97. default: vue.withCtx(() => [
  98. vue.createVNode(vue.unref(focusTrap["default"]), {
  99. loop: "",
  100. trapped: vue.unref(visible),
  101. "focus-trap-el": drawerRef.value,
  102. "focus-start-el": focusStartRef.value,
  103. onFocusAfterTrapped: vue.unref(onOpenAutoFocus),
  104. onFocusAfterReleased: vue.unref(onCloseAutoFocus),
  105. onFocusoutPrevented: vue.unref(onFocusoutPrevented),
  106. onReleaseRequested: vue.unref(onCloseRequested)
  107. }, {
  108. default: vue.withCtx(() => [
  109. vue.createElementVNode("div", vue.mergeProps({
  110. ref_key: "drawerRef",
  111. ref: drawerRef,
  112. "aria-modal": "true",
  113. "aria-label": _ctx.title || void 0,
  114. "aria-labelledby": !_ctx.title ? vue.unref(titleId) : void 0,
  115. "aria-describedby": vue.unref(bodyId)
  116. }, _ctx.$attrs, {
  117. class: [
  118. vue.unref(ns).b(),
  119. _ctx.direction,
  120. vue.unref(visible) && "open",
  121. vue.unref(ns).is("dragging", vue.unref(isResizing))
  122. ],
  123. style: { [vue.unref(isHorizontal) ? "width" : "height"]: vue.unref(size) },
  124. role: "dialog",
  125. onClick: _cache[1] || (_cache[1] = vue.withModifiers(() => {
  126. }, ["stop"]))
  127. }), [
  128. vue.createElementVNode(
  129. "span",
  130. {
  131. ref_key: "focusStartRef",
  132. ref: focusStartRef,
  133. class: vue.normalizeClass(vue.unref(ns).e("sr-focus")),
  134. tabindex: "-1"
  135. },
  136. null,
  137. 2
  138. ),
  139. _ctx.withHeader ? (vue.openBlock(), vue.createElementBlock(
  140. "header",
  141. {
  142. key: 0,
  143. class: vue.normalizeClass([vue.unref(ns).e("header"), _ctx.headerClass])
  144. },
  145. [
  146. !_ctx.$slots.title ? vue.renderSlot(_ctx.$slots, "header", {
  147. key: 0,
  148. close: vue.unref(handleClose),
  149. titleId: vue.unref(titleId),
  150. titleClass: vue.unref(ns).e("title")
  151. }, () => [
  152. vue.createElementVNode("span", {
  153. id: vue.unref(titleId),
  154. role: "heading",
  155. "aria-level": _ctx.headerAriaLevel,
  156. class: vue.normalizeClass(vue.unref(ns).e("title"))
  157. }, vue.toDisplayString(_ctx.title), 11, _hoisted_2)
  158. ]) : vue.renderSlot(_ctx.$slots, "title", { key: 1 }, () => [
  159. vue.createCommentVNode(" DEPRECATED SLOT ")
  160. ]),
  161. _ctx.showClose ? (vue.openBlock(), vue.createElementBlock("button", {
  162. key: 2,
  163. "aria-label": vue.unref(t)("el.drawer.close"),
  164. class: vue.normalizeClass(vue.unref(ns).e("close-btn")),
  165. type: "button",
  166. onClick: _cache[0] || (_cache[0] = (...args) => vue.unref(handleClose) && vue.unref(handleClose)(...args))
  167. }, [
  168. vue.createVNode(vue.unref(index$5.ElIcon), {
  169. class: vue.normalizeClass(vue.unref(ns).e("close"))
  170. }, {
  171. default: vue.withCtx(() => [
  172. vue.createVNode(vue.unref(iconsVue.Close))
  173. ]),
  174. _: 1
  175. }, 8, ["class"])
  176. ], 10, _hoisted_3)) : vue.createCommentVNode("v-if", true)
  177. ],
  178. 2
  179. )) : vue.createCommentVNode("v-if", true),
  180. vue.unref(rendered) ? (vue.openBlock(), vue.createElementBlock("div", {
  181. key: 1,
  182. id: vue.unref(bodyId),
  183. class: vue.normalizeClass([vue.unref(ns).e("body"), _ctx.bodyClass])
  184. }, [
  185. vue.renderSlot(_ctx.$slots, "default")
  186. ], 10, _hoisted_4)) : vue.createCommentVNode("v-if", true),
  187. _ctx.$slots.footer ? (vue.openBlock(), vue.createElementBlock(
  188. "div",
  189. {
  190. key: 2,
  191. class: vue.normalizeClass([vue.unref(ns).e("footer"), _ctx.footerClass])
  192. },
  193. [
  194. vue.renderSlot(_ctx.$slots, "footer")
  195. ],
  196. 2
  197. )) : vue.createCommentVNode("v-if", true),
  198. _ctx.resizable ? (vue.openBlock(), vue.createElementBlock(
  199. "div",
  200. {
  201. key: 3,
  202. ref_key: "draggerRef",
  203. ref: draggerRef,
  204. style: vue.normalizeStyle({ zIndex: vue.unref(zIndex) }),
  205. class: vue.normalizeClass(vue.unref(ns).e("dragger"))
  206. },
  207. null,
  208. 6
  209. )) : vue.createCommentVNode("v-if", true)
  210. ], 16, _hoisted_1)
  211. ]),
  212. _: 3
  213. }, 8, ["trapped", "focus-trap-el", "focus-start-el", "onFocusAfterTrapped", "onFocusAfterReleased", "onFocusoutPrevented", "onReleaseRequested"])
  214. ]),
  215. _: 3
  216. }, 8, ["mask", "overlay-class", "z-index", "onClick"]), [
  217. [vue.vShow, vue.unref(visible)]
  218. ])
  219. ];
  220. }),
  221. _: 3
  222. }, 8, ["name", "onAfterEnter", "onAfterLeave", "onBeforeLeave"])
  223. ]),
  224. _: 3
  225. }, 8, ["to", "disabled"]);
  226. };
  227. }
  228. });
  229. var Drawer = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/drawer/src/drawer.vue"]]);
  230. exports["default"] = Drawer;
  231. //# sourceMappingURL=drawer2.js.map