@liuzengwei/element-ui 2.15.5-xn.51 → 2.15.5-xn.53

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.
Files changed (76) hide show
  1. package/lib/alert.js +2 -2
  2. package/lib/area-picker.js +2 -2
  3. package/lib/aside.js +2 -2
  4. package/lib/backtop.js +2 -2
  5. package/lib/badge.js +2 -2
  6. package/lib/breadcrumb-item.js +2 -2
  7. package/lib/breadcrumb.js +2 -2
  8. package/lib/button-group.js +2 -2
  9. package/lib/button.js +2 -2
  10. package/lib/calendar.js +2 -2
  11. package/lib/card.js +2 -2
  12. package/lib/carousel-item.js +2 -2
  13. package/lib/carousel.js +2 -2
  14. package/lib/cascader-panel.js +2 -2
  15. package/lib/cascader.js +4 -4
  16. package/lib/checkbox-button.js +2 -2
  17. package/lib/checkbox-group.js +2 -2
  18. package/lib/checkbox.js +2 -2
  19. package/lib/collapse-item.js +2 -2
  20. package/lib/collapse.js +2 -2
  21. package/lib/color-picker.js +4 -4
  22. package/lib/container.js +2 -2
  23. package/lib/date-picker.js +5 -5
  24. package/lib/dialog.js +2 -2
  25. package/lib/divider.js +2 -2
  26. package/lib/drawer.js +573 -25
  27. package/lib/dropdown-item.js +2 -2
  28. package/lib/dropdown-menu.js +2 -2
  29. package/lib/element-ui.common.js +547 -20
  30. package/lib/footer.js +2 -2
  31. package/lib/form.js +2 -2
  32. package/lib/header.js +2 -2
  33. package/lib/icon.js +2 -2
  34. package/lib/image.js +2 -2
  35. package/lib/index.js +1 -1
  36. package/lib/input-number.js +2 -2
  37. package/lib/link.js +2 -2
  38. package/lib/loading.js +2 -2
  39. package/lib/main.js +2 -2
  40. package/lib/menu-item-group.js +2 -2
  41. package/lib/menu-item.js +2 -2
  42. package/lib/message-box.js +4 -4
  43. package/lib/message.js +2 -2
  44. package/lib/notification.js +2 -2
  45. package/lib/option-group.js +2 -2
  46. package/lib/page-header.js +2 -2
  47. package/lib/pagination.js +2 -2
  48. package/lib/popover.js +2 -2
  49. package/lib/progress.js +2 -2
  50. package/lib/radio-button.js +2 -2
  51. package/lib/radio-group.js +2 -2
  52. package/lib/radio.js +9 -9
  53. package/lib/rate.js +2 -2
  54. package/lib/select.js +2 -2
  55. package/lib/spinner.js +2 -2
  56. package/lib/step.js +2 -2
  57. package/lib/steps.js +2 -2
  58. package/lib/switch.js +2 -2
  59. package/lib/tab-pane.js +2 -2
  60. package/lib/table.js +4 -4
  61. package/lib/theme-chalk/drawer.css +1 -1
  62. package/lib/theme-chalk/index.css +1 -1
  63. package/lib/time-picker.js +5 -5
  64. package/lib/time-select.js +2 -2
  65. package/lib/timeline-item.js +2 -2
  66. package/lib/tooltip.js +2 -2
  67. package/lib/transfer.js +2 -2
  68. package/lib/trigger.js +5 -5
  69. package/lib/upload.js +8 -8
  70. package/package.json +1 -1
  71. package/packages/drawer/src/main.vue +321 -9
  72. package/packages/theme-chalk/lib/drawer.css +1 -1
  73. package/packages/theme-chalk/lib/index.css +1 -1
  74. package/packages/theme-chalk/src/drawer.scss +31 -0
  75. package/src/index.js +1 -1
  76. package/types/drawer.d.ts +16 -0
package/lib/drawer.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 137);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 92);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -189,7 +189,35 @@ function normalizeComponent (
189
189
 
190
190
  /***/ }),
191
191
 
192
- /***/ 137:
192
+ /***/ 14:
193
+ /***/ (function(module, exports) {
194
+
195
+ module.exports = require("@liuzengwei/element-ui/lib/utils/popup");
196
+
197
+ /***/ }),
198
+
199
+ /***/ 2:
200
+ /***/ (function(module, exports) {
201
+
202
+ module.exports = require("@liuzengwei/element-ui/lib/utils/dom");
203
+
204
+ /***/ }),
205
+
206
+ /***/ 4:
207
+ /***/ (function(module, exports) {
208
+
209
+ module.exports = require("@liuzengwei/element-ui/lib/mixins/emitter");
210
+
211
+ /***/ }),
212
+
213
+ /***/ 6:
214
+ /***/ (function(module, exports) {
215
+
216
+ module.exports = require("vue");
217
+
218
+ /***/ }),
219
+
220
+ /***/ 92:
193
221
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
194
222
 
195
223
  "use strict";
@@ -218,7 +246,10 @@ var render = function() {
218
246
  expression: "visible"
219
247
  }
220
248
  ],
221
- staticClass: "el-drawer__wrapper",
249
+ class: _vm.referenceMode
250
+ ? "el-drawer__wrapper-reference"
251
+ : "el-drawer__wrapper",
252
+ style: _vm.wrapperStyle,
222
253
  attrs: { tabindex: "-1" }
223
254
  },
224
255
  [
@@ -226,7 +257,10 @@ var render = function() {
226
257
  "div",
227
258
  {
228
259
  staticClass: "el-drawer__container",
229
- class: _vm.visible && "el-drawer__open",
260
+ class: [
261
+ _vm.visible && "el-drawer__open",
262
+ _vm.referenceMode && "el-drawer__reference-mode"
263
+ ],
230
264
  attrs: { role: "document", tabindex: "-1" },
231
265
  on: {
232
266
  click: function($event) {
@@ -243,10 +277,12 @@ var render = function() {
243
277
  {
244
278
  ref: "drawer",
245
279
  staticClass: "el-drawer",
246
- class: [_vm.direction, _vm.customClass],
247
- style: _vm.isHorizontal
248
- ? "width: " + _vm.drawerSize
249
- : "height: " + _vm.drawerSize,
280
+ class: [
281
+ _vm.effectiveDirection,
282
+ _vm.customClass,
283
+ _vm.referenceMode && "is-reference"
284
+ ],
285
+ style: _vm.drawerStyle,
250
286
  attrs: {
251
287
  "aria-modal": "true",
252
288
  "aria-labelledby": "el-drawer__title",
@@ -322,11 +358,218 @@ render._withStripped = true
322
358
  var popup_ = __webpack_require__(14);
323
359
  var popup_default = /*#__PURE__*/__webpack_require__.n(popup_);
324
360
 
361
+ // EXTERNAL MODULE: external "vue"
362
+ var external_vue_ = __webpack_require__(6);
363
+ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
364
+
365
+ // EXTERNAL MODULE: external "@liuzengwei/element-ui/lib/utils/dom"
366
+ var dom_ = __webpack_require__(2);
367
+
368
+ // CONCATENATED MODULE: ./src/utils/popup/popup-manager.js
369
+
370
+
371
+
372
+ var hasModal = false;
373
+ var hasInitZIndex = false;
374
+ var popup_manager_zIndex = void 0;
375
+
376
+ var popup_manager_getModal = function getModal() {
377
+ if (external_vue_default.a.prototype.$isServer) return;
378
+ var modalDom = PopupManager.modalDom;
379
+ if (modalDom) {
380
+ hasModal = true;
381
+ } else {
382
+ hasModal = false;
383
+ modalDom = document.createElement('div');
384
+ PopupManager.modalDom = modalDom;
385
+
386
+ modalDom.addEventListener('touchmove', function (event) {
387
+ event.preventDefault();
388
+ event.stopPropagation();
389
+ });
390
+
391
+ modalDom.addEventListener('click', function () {
392
+ PopupManager.doOnModalClick && PopupManager.doOnModalClick();
393
+ });
394
+ }
395
+
396
+ return modalDom;
397
+ };
398
+
399
+ var instances = {};
400
+
401
+ var PopupManager = {
402
+ modalFade: true,
403
+
404
+ getInstance: function getInstance(id) {
405
+ return instances[id];
406
+ },
407
+
408
+ register: function register(id, instance) {
409
+ if (id && instance) {
410
+ instances[id] = instance;
411
+ }
412
+ },
413
+
414
+ deregister: function deregister(id) {
415
+ if (id) {
416
+ instances[id] = null;
417
+ delete instances[id];
418
+ }
419
+ },
420
+
421
+ nextZIndex: function nextZIndex() {
422
+ return PopupManager.zIndex++;
423
+ },
424
+
425
+ modalStack: [],
426
+
427
+ doOnModalClick: function doOnModalClick() {
428
+ var topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
429
+ if (!topItem) return;
430
+
431
+ var instance = PopupManager.getInstance(topItem.id);
432
+ if (instance && instance.closeOnClickModal) {
433
+ instance.close();
434
+ }
435
+ },
436
+
437
+ openModal: function openModal(id, zIndex, dom, modalClass, modalFade) {
438
+ if (external_vue_default.a.prototype.$isServer) return;
439
+ if (!id || zIndex === undefined) return;
440
+ this.modalFade = modalFade;
441
+
442
+ var modalStack = this.modalStack;
443
+
444
+ for (var i = 0, j = modalStack.length; i < j; i++) {
445
+ var item = modalStack[i];
446
+ if (item.id === id) {
447
+ return;
448
+ }
449
+ }
450
+
451
+ var modalDom = popup_manager_getModal();
452
+
453
+ Object(dom_["addClass"])(modalDom, 'v-modal');
454
+ if (this.modalFade && !hasModal) {
455
+ Object(dom_["addClass"])(modalDom, 'v-modal-enter');
456
+ }
457
+ if (modalClass) {
458
+ var classArr = modalClass.trim().split(/\s+/);
459
+ classArr.forEach(function (item) {
460
+ return Object(dom_["addClass"])(modalDom, item);
461
+ });
462
+ }
463
+ setTimeout(function () {
464
+ Object(dom_["removeClass"])(modalDom, 'v-modal-enter');
465
+ }, 200);
466
+
467
+ if (dom && dom.parentNode && dom.parentNode.nodeType !== 11) {
468
+ dom.parentNode.appendChild(modalDom);
469
+ } else {
470
+ document.body.appendChild(modalDom);
471
+ }
472
+
473
+ if (zIndex) {
474
+ modalDom.style.zIndex = zIndex;
475
+ }
476
+ modalDom.tabIndex = 0;
477
+ modalDom.style.display = '';
478
+
479
+ this.modalStack.push({ id: id, zIndex: zIndex, modalClass: modalClass });
480
+ },
481
+
482
+ closeModal: function closeModal(id) {
483
+ var modalStack = this.modalStack;
484
+ var modalDom = popup_manager_getModal();
485
+
486
+ if (modalStack.length > 0) {
487
+ var topItem = modalStack[modalStack.length - 1];
488
+ if (topItem.id === id) {
489
+ if (topItem.modalClass) {
490
+ var classArr = topItem.modalClass.trim().split(/\s+/);
491
+ classArr.forEach(function (item) {
492
+ return Object(dom_["removeClass"])(modalDom, item);
493
+ });
494
+ }
495
+
496
+ modalStack.pop();
497
+ if (modalStack.length > 0) {
498
+ modalDom.style.zIndex = modalStack[modalStack.length - 1].zIndex;
499
+ }
500
+ } else {
501
+ for (var i = modalStack.length - 1; i >= 0; i--) {
502
+ if (modalStack[i].id === id) {
503
+ modalStack.splice(i, 1);
504
+ break;
505
+ }
506
+ }
507
+ }
508
+ }
509
+
510
+ if (modalStack.length === 0) {
511
+ if (this.modalFade) {
512
+ Object(dom_["addClass"])(modalDom, 'v-modal-leave');
513
+ }
514
+ setTimeout(function () {
515
+ if (modalStack.length === 0) {
516
+ if (modalDom.parentNode) modalDom.parentNode.removeChild(modalDom);
517
+ modalDom.style.display = 'none';
518
+ PopupManager.modalDom = undefined;
519
+ }
520
+ Object(dom_["removeClass"])(modalDom, 'v-modal-leave');
521
+ }, 200);
522
+ }
523
+ }
524
+ };
525
+
526
+ Object.defineProperty(PopupManager, 'zIndex', {
527
+ configurable: true,
528
+ get: function get() {
529
+ if (!hasInitZIndex) {
530
+ popup_manager_zIndex = popup_manager_zIndex || (external_vue_default.a.prototype.$ELEMENT || {}).zIndex || 2000;
531
+ hasInitZIndex = true;
532
+ }
533
+ return popup_manager_zIndex;
534
+ },
535
+ set: function set(value) {
536
+ popup_manager_zIndex = value;
537
+ }
538
+ });
539
+
540
+ var popup_manager_getTopPopup = function getTopPopup() {
541
+ if (external_vue_default.a.prototype.$isServer) return;
542
+ if (PopupManager.modalStack.length > 0) {
543
+ var topPopup = PopupManager.modalStack[PopupManager.modalStack.length - 1];
544
+ if (!topPopup) return;
545
+ var instance = PopupManager.getInstance(topPopup.id);
546
+
547
+ return instance;
548
+ }
549
+ };
550
+
551
+ if (!external_vue_default.a.prototype.$isServer) {
552
+ // handle `esc` key when the popup is shown
553
+ window.addEventListener('keydown', function (event) {
554
+ if (event.keyCode === 27) {
555
+ var topPopup = popup_manager_getTopPopup();
556
+
557
+ if (topPopup && topPopup.closeOnPressEscape) {
558
+ topPopup.handleClose ? topPopup.handleClose() : topPopup.handleAction ? topPopup.handleAction('cancel') : topPopup.close();
559
+ }
560
+ }
561
+ });
562
+ }
563
+
564
+ /* harmony default export */ var popup_manager = (PopupManager);
325
565
  // EXTERNAL MODULE: external "@liuzengwei/element-ui/lib/mixins/emitter"
326
566
  var emitter_ = __webpack_require__(4);
327
567
  var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
328
568
 
329
569
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/drawer/src/main.vue?vue&type=script&lang=js&
570
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
571
+
572
+ //
330
573
  //
331
574
  //
332
575
  //
@@ -379,6 +622,8 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
379
622
 
380
623
 
381
624
 
625
+
626
+
382
627
  /* harmony default export */ var mainvue_type_script_lang_js_ = ({
383
628
  name: 'ElDrawer',
384
629
  mixins: [popup_default.a, emitter_default.a],
@@ -439,6 +684,21 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
439
684
  withHeader: {
440
685
  type: Boolean,
441
686
  default: true
687
+ },
688
+ reference: {
689
+ type: [String, Object, typeof window !== 'undefined' ? window.HTMLElement : Object],
690
+ default: null
691
+ },
692
+ placement: {
693
+ type: String,
694
+ default: 'right',
695
+ validator: function validator(val) {
696
+ return ['top', 'bottom', 'left', 'right'].indexOf(val) !== -1;
697
+ }
698
+ },
699
+ offset: {
700
+ type: Number,
701
+ default: 0
442
702
  }
443
703
  },
444
704
  computed: {
@@ -447,12 +707,51 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
447
707
  },
448
708
  drawerSize: function drawerSize() {
449
709
  return typeof this.size === 'number' ? this.size + 'px' : this.size;
710
+ },
711
+ referenceMode: function referenceMode() {
712
+ return !!this.reference;
713
+ },
714
+ effectiveDirection: function effectiveDirection() {
715
+ // 在 reference 模式下,根据 placement 映射到对应的 direction
716
+ if (this.referenceMode) {
717
+ var placementToDirection = {
718
+ 'top': 'btt',
719
+ 'bottom': 'ttb',
720
+ 'left': 'ltr',
721
+ 'right': 'rtl'
722
+ };
723
+ return placementToDirection[this.placement] || 'rtl';
724
+ }
725
+ return this.direction;
726
+ },
727
+ wrapperStyle: function wrapperStyle() {
728
+ // 在 reference 模式下,将 z-index 设置在 wrapper 上,与全局模式保持一致
729
+ if (this.referenceMode && this.drawerZIndex) {
730
+ return { zIndex: this.drawerZIndex };
731
+ }
732
+ return null;
733
+ },
734
+ drawerStyle: function drawerStyle() {
735
+ if (this.referenceMode) {
736
+ var style = _extends({}, this.position);
737
+ if (this.placement === 'left' || this.placement === 'right') {
738
+ style.width = this.drawerSize;
739
+ } else {
740
+ style.height = this.drawerSize;
741
+ }
742
+ return style;
743
+ } else {
744
+ return this.isHorizontal ? 'width: ' + this.drawerSize : 'height: ' + this.drawerSize;
745
+ }
450
746
  }
451
747
  },
452
748
  data: function data() {
453
749
  return {
454
750
  closed: false,
455
- prevActiveElement: null
751
+ prevActiveElement: null,
752
+ position: {},
753
+ drawerZIndex: null,
754
+ modalZIndex: null
456
755
  };
457
756
  },
458
757
 
@@ -463,7 +762,34 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
463
762
  if (val) {
464
763
  this.closed = false;
465
764
  this.$emit('open');
466
- if (this.appendToBody) {
765
+ if (this.referenceMode) {
766
+ // z-index 已经通过 drawerStyle computed 属性设置
767
+ var referenceEl = this.getReferenceElement();
768
+ if (referenceEl) {
769
+ referenceEl.appendChild(this.$el);
770
+ }
771
+ // 在 drawer 挂载后创建 modal
772
+ this.$nextTick(function () {
773
+ // drawer 的 z-index 已经在 appendChild 前设置
774
+
775
+ // 创建/显示 modal(使用预分配的较低值)
776
+ if (_this.modal) {
777
+ _this.createReferenceModal({
778
+ modalClass: _this.modalClass,
779
+ modalFade: _this.modalFade
780
+ });
781
+ }
782
+
783
+ // 更新位置
784
+ _this.updatePosition();
785
+
786
+ // 清理可能被 PopupManager 创建的全局 modal
787
+ // 延迟执行,确保全局 modal 已经被创建后再移除
788
+ setTimeout(function () {
789
+ _this.removeGlobalModal();
790
+ }, 300);
791
+ });
792
+ } else if (this.appendToBody) {
467
793
  document.body.appendChild(this.$el);
468
794
  }
469
795
  this.prevActiveElement = document.activeElement;
@@ -474,6 +800,10 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
474
800
  this.rendered = false;
475
801
  }
476
802
  }
803
+ // 关闭 reference 模式的 modal
804
+ if (this.referenceMode) {
805
+ this.closeReferenceModal();
806
+ }
477
807
  this.$nextTick(function () {
478
808
  if (_this.prevActiveElement) {
479
809
  _this.prevActiveElement.focus();
@@ -483,6 +813,122 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
483
813
  }
484
814
  },
485
815
  methods: {
816
+ doOpen: function doOpen(props) {
817
+ // 在 reference 模式下,需要让遮罩层挂载到参考元素而不是 body
818
+ if (this.referenceMode) {
819
+ // 手动实现 doOpen 的逻辑,但将 modal 挂载到 reference 元素
820
+ if (this.$isServer) return;
821
+ if (this.willOpen && !this.willOpen()) return;
822
+ if (this.opened) return;
823
+
824
+ this._opening = true;
825
+
826
+ var dom = this.$el;
827
+ var zIndex = props.zIndex;
828
+
829
+ if (zIndex) {
830
+ popup_manager.zIndex = zIndex;
831
+ }
832
+
833
+ // modal 的创建已经移到 watch visible 中,在 drawer 挂载后执行
834
+ // 这里预先分配 z-index,确保 modal 和 drawer 的层级关系正确
835
+ // 每次打开都重新分配,避免复用时的 z-index 错乱
836
+ this.modalZIndex = popup_manager.nextZIndex();
837
+ this.drawerZIndex = popup_manager.nextZIndex();
838
+
839
+ if (Object(dom_["getStyle"])(dom, 'position') === 'static') {
840
+ dom.style.position = 'absolute';
841
+ }
842
+
843
+ // z-index 的设置已经移到 watch visible 中,在 modal 创建后设置
844
+ this.opened = true;
845
+
846
+ this.onOpen && this.onOpen();
847
+
848
+ this.doAfterOpen();
849
+ } else {
850
+ // 非 reference 模式,使用原始的 doOpen
851
+ this.$options.mixins[0].methods.doOpen.call(this, props);
852
+ }
853
+ },
854
+ createReferenceModal: function createReferenceModal(props) {
855
+ var _this2 = this;
856
+
857
+ // 创建并挂载 modal 到 reference 元素
858
+ var referenceEl = this.getReferenceElement();
859
+ if (!referenceEl) return;
860
+
861
+ // 创建或复用 modal DOM
862
+ var modalDom = this._referenceModalDom;
863
+ if (!modalDom) {
864
+ modalDom = document.createElement('div');
865
+ modalDom.className = 'v-modal';
866
+ modalDom.tabIndex = 0;
867
+
868
+ // 使用预先分配的 modal z-index,确保 drawer 已经有更高的 z-index
869
+ var modalZIndex = this.modalZIndex || popup_manager.nextZIndex();
870
+ modalDom.style.zIndex = modalZIndex;
871
+
872
+ // 关键:在 reference 模式下使用 absolute 定位,而不是 fixed
873
+ modalDom.style.position = 'absolute';
874
+ modalDom.style.left = '0';
875
+ modalDom.style.top = '0';
876
+ modalDom.style.width = '100%';
877
+ modalDom.style.height = '100%';
878
+
879
+ if (props.modalClass) {
880
+ var classArr = props.modalClass.trim().split(/\s+/);
881
+ classArr.forEach(function (cls) {
882
+ return modalDom.classList.add(cls);
883
+ });
884
+ }
885
+
886
+ // 添加淡入动画
887
+ if (props.modalFade) {
888
+ modalDom.classList.add('v-modal-enter');
889
+ setTimeout(function () {
890
+ modalDom.classList.remove('v-modal-enter');
891
+ }, 200);
892
+ }
893
+
894
+ // 直接挂载到 reference 元素内部
895
+ referenceEl.appendChild(modalDom);
896
+
897
+ // 点击 modal 时的处理
898
+ modalDom.addEventListener('click', function () {
899
+ if (_this2.closeOnClickModal) {
900
+ _this2.closeDrawer();
901
+ }
902
+ });
903
+
904
+ // 保存引用以便后续清理
905
+ this._referenceModalDom = modalDom;
906
+ } else {
907
+ // 复用 modal 时,使用预分配的 z-index
908
+ modalDom.style.display = '';
909
+ modalDom.style.zIndex = this.modalZIndex || popup_manager.nextZIndex();
910
+ }
911
+ },
912
+ closeReferenceModal: function closeReferenceModal() {
913
+ // 关闭 reference 模式的 modal
914
+ if (this._referenceModalDom) {
915
+ this._referenceModalDom.style.display = 'none';
916
+ }
917
+ },
918
+ removeGlobalModal: function removeGlobalModal() {
919
+ // 移除 PopupManager 可能创建的全局 modal(在 body 下的)
920
+ // 只在 reference 模式下调用此方法
921
+ if (this.referenceMode) {
922
+ // 查找并移除 body 下与此 drawer 关联的 modal
923
+ var globalModals = document.body.querySelectorAll('.v-modal');
924
+ globalModals.forEach(function (modal) {
925
+ // 移除 body 下的所有 modal(它们不应该存在)
926
+ if (modal.parentNode === document.body) {
927
+ document.body.removeChild(modal);
928
+ }
929
+ });
930
+ }
931
+ },
486
932
  afterEnter: function afterEnter() {
487
933
  this.$emit('opened');
488
934
  },
@@ -516,22 +962,138 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
516
962
  // pressing `ESC` will call this method, and also close the drawer.
517
963
  // This method also calls `beforeClose` if there was one.
518
964
  this.closeDrawer();
965
+ },
966
+ getReferenceElement: function getReferenceElement() {
967
+ if (typeof this.reference === 'string') {
968
+ return document.querySelector(this.reference);
969
+ } else if (this.reference && this.reference.$el) {
970
+ return this.reference.$el;
971
+ } else {
972
+ return this.reference;
973
+ }
974
+ },
975
+ updatePosition: function updatePosition() {
976
+ if (!this.referenceMode) return;
977
+
978
+ var referenceEl = this.getReferenceElement();
979
+ if (!referenceEl) {
980
+ console.warn('[ElDrawer] Reference element not found');
981
+ return;
982
+ }
983
+
984
+ // 确保参考元素有 position 样式
985
+ var computedStyle = window.getComputedStyle(referenceEl);
986
+ if (computedStyle.position === 'static') {
987
+ referenceEl.style.position = 'relative';
988
+ }
989
+
990
+ var placement = this.placement,
991
+ offset = this.offset;
992
+
993
+ var position = {};
994
+
995
+ switch (placement) {
996
+ case 'top':
997
+ position.left = '0';
998
+ position.bottom = offset + 'px';
999
+ position.top = 'auto';
1000
+ position.right = '0';
1001
+ break;
1002
+ case 'bottom':
1003
+ position.left = '0';
1004
+ position.top = offset + 'px';
1005
+ position.bottom = 'auto';
1006
+ position.right = '0';
1007
+ break;
1008
+ case 'left':
1009
+ position.top = '0';
1010
+ position.right = 'auto';
1011
+ position.left = offset + 'px';
1012
+ position.bottom = '0';
1013
+ break;
1014
+ case 'right':
1015
+ position.top = '0';
1016
+ position.left = 'auto';
1017
+ position.right = offset + 'px';
1018
+ position.bottom = '0';
1019
+ break;
1020
+ }
1021
+
1022
+ this.position = position;
1023
+ },
1024
+ handleScroll: function handleScroll() {
1025
+ if (this.referenceMode && this.visible) {
1026
+ this.updatePosition();
1027
+ }
1028
+ },
1029
+ handleResize: function handleResize() {
1030
+ if (this.referenceMode && this.visible) {
1031
+ this.updatePosition();
1032
+ }
1033
+ }
1034
+ },
1035
+ beforeMount: function beforeMount() {
1036
+ // 在 reference 模式下,我们不使用 PopupManager 的 modal
1037
+ // 设置一个内部标志来阻止 PopupManager 创建 modal
1038
+ if (this.referenceMode) {
1039
+ // 保存原始的 modal 属性
1040
+ this._originalModal = this.modal;
1041
+ // 临时将 modal 设为 false,这样 Popup mixin 的逻辑不会调用 PopupManager.openModal
1042
+ // 注意:这个技巧可能不work,因为 modal 是 prop
519
1043
  }
520
1044
  },
521
1045
  mounted: function mounted() {
522
1046
  if (this.visible) {
523
1047
  this.rendered = true;
524
1048
  this.open();
525
- if (this.appendToBody) {
1049
+ if (this.referenceMode) {
1050
+ var referenceEl = this.getReferenceElement();
1051
+ if (referenceEl) {
1052
+ referenceEl.appendChild(this.$el);
1053
+ }
1054
+ } else if (this.appendToBody) {
526
1055
  document.body.appendChild(this.$el);
527
1056
  }
528
1057
  }
1058
+ if (this.referenceMode) {
1059
+ window.addEventListener('scroll', this.handleScroll, true);
1060
+ window.addEventListener('resize', this.handleResize);
1061
+ }
1062
+ },
1063
+ beforeDestroy: function beforeDestroy() {
1064
+ // 在 reference 模式下,不使用 PopupManager 管理 modal
1065
+ // 所以需要阻止 Popup mixin 的 beforeDestroy 调用 PopupManager.closeModal
1066
+ if (!this.referenceMode) {
1067
+ // 非 reference 模式,调用 mixin 的 beforeDestroy
1068
+ if (this.$options.mixins && this.$options.mixins[0].beforeDestroy) {
1069
+ this.$options.mixins[0].beforeDestroy.call(this);
1070
+ }
1071
+ } else {
1072
+ // reference 模式,只执行必要的清理
1073
+ if (this._popupId) {
1074
+ popup_manager.deregister(this._popupId);
1075
+ // 不调用 PopupManager.closeModal,因为我们用的是自定义 modal
1076
+ }
1077
+ this.restoreBodyStyle();
1078
+ }
529
1079
  },
530
1080
  destroyed: function destroyed() {
531
1081
  // if appendToBody is true, remove DOM node after destroy
532
1082
  if (this.appendToBody && this.$el && this.$el.parentNode) {
533
1083
  this.$el.parentNode.removeChild(this.$el);
534
1084
  }
1085
+ if (this.referenceMode && this.$el && this.$el.parentNode) {
1086
+ this.$el.parentNode.removeChild(this.$el);
1087
+ }
1088
+ // 清理 reference modal
1089
+ if (this.referenceMode && this._referenceModalDom && this._referenceModalDom.parentNode) {
1090
+ this._referenceModalDom.parentNode.removeChild(this._referenceModalDom);
1091
+ this._referenceModalDom = null;
1092
+ }
1093
+ if (this.referenceMode) {
1094
+ window.removeEventListener('scroll', this.handleScroll, true);
1095
+ window.removeEventListener('resize', this.handleResize);
1096
+ }
535
1097
  }
536
1098
  });
537
1099
  // CONCATENATED MODULE: ./packages/drawer/src/main.vue?vue&type=script&lang=js&
@@ -572,20 +1134,6 @@ main.install = function (Vue) {
572
1134
 
573
1135
  /* harmony default export */ var drawer = __webpack_exports__["default"] = (main);
574
1136
 
575
- /***/ }),
576
-
577
- /***/ 14:
578
- /***/ (function(module, exports) {
579
-
580
- module.exports = require("@liuzengwei/element-ui/lib/utils/popup");
581
-
582
- /***/ }),
583
-
584
- /***/ 4:
585
- /***/ (function(module, exports) {
586
-
587
- module.exports = require("@liuzengwei/element-ui/lib/mixins/emitter");
588
-
589
1137
  /***/ })
590
1138
 
591
1139
  /******/ });