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

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/lib/drawer.js CHANGED
@@ -218,7 +218,9 @@ var render = function() {
218
218
  expression: "visible"
219
219
  }
220
220
  ],
221
- staticClass: "el-drawer__wrapper",
221
+ class: _vm.referenceMode
222
+ ? "el-drawer__wrapper-reference"
223
+ : "el-drawer__wrapper",
222
224
  attrs: { tabindex: "-1" }
223
225
  },
224
226
  [
@@ -226,7 +228,10 @@ var render = function() {
226
228
  "div",
227
229
  {
228
230
  staticClass: "el-drawer__container",
229
- class: _vm.visible && "el-drawer__open",
231
+ class: [
232
+ _vm.visible && "el-drawer__open",
233
+ _vm.referenceMode && "el-drawer__reference-mode"
234
+ ],
230
235
  attrs: { role: "document", tabindex: "-1" },
231
236
  on: {
232
237
  click: function($event) {
@@ -243,10 +248,12 @@ var render = function() {
243
248
  {
244
249
  ref: "drawer",
245
250
  staticClass: "el-drawer",
246
- class: [_vm.direction, _vm.customClass],
247
- style: _vm.isHorizontal
248
- ? "width: " + _vm.drawerSize
249
- : "height: " + _vm.drawerSize,
251
+ class: [
252
+ _vm.effectiveDirection,
253
+ _vm.customClass,
254
+ _vm.referenceMode && "is-reference"
255
+ ],
256
+ style: _vm.drawerStyle,
250
257
  attrs: {
251
258
  "aria-modal": "true",
252
259
  "aria-labelledby": "el-drawer__title",
@@ -327,6 +334,8 @@ var emitter_ = __webpack_require__(4);
327
334
  var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
328
335
 
329
336
  // 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&
337
+ 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; };
338
+
330
339
  //
331
340
  //
332
341
  //
@@ -439,6 +448,21 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
439
448
  withHeader: {
440
449
  type: Boolean,
441
450
  default: true
451
+ },
452
+ reference: {
453
+ type: [String, Object],
454
+ default: null
455
+ },
456
+ placement: {
457
+ type: String,
458
+ default: 'right',
459
+ validator: function validator(val) {
460
+ return ['top', 'bottom', 'left', 'right'].indexOf(val) !== -1;
461
+ }
462
+ },
463
+ offset: {
464
+ type: Number,
465
+ default: 0
442
466
  }
443
467
  },
444
468
  computed: {
@@ -447,12 +471,42 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
447
471
  },
448
472
  drawerSize: function drawerSize() {
449
473
  return typeof this.size === 'number' ? this.size + 'px' : this.size;
474
+ },
475
+ referenceMode: function referenceMode() {
476
+ return !!this.reference;
477
+ },
478
+ effectiveDirection: function effectiveDirection() {
479
+ // 在 reference 模式下,根据 placement 映射到对应的 direction
480
+ if (this.referenceMode) {
481
+ var placementToDirection = {
482
+ 'top': 'btt',
483
+ 'bottom': 'ttb',
484
+ 'left': 'ltr',
485
+ 'right': 'rtl'
486
+ };
487
+ return placementToDirection[this.placement] || 'rtl';
488
+ }
489
+ return this.direction;
490
+ },
491
+ drawerStyle: function drawerStyle() {
492
+ if (this.referenceMode) {
493
+ var style = _extends({}, this.position);
494
+ if (this.placement === 'left' || this.placement === 'right') {
495
+ style.width = this.drawerSize;
496
+ } else {
497
+ style.height = this.drawerSize;
498
+ }
499
+ return style;
500
+ } else {
501
+ return this.isHorizontal ? 'width: ' + this.drawerSize : 'height: ' + this.drawerSize;
502
+ }
450
503
  }
451
504
  },
452
505
  data: function data() {
453
506
  return {
454
507
  closed: false,
455
- prevActiveElement: null
508
+ prevActiveElement: null,
509
+ position: {}
456
510
  };
457
511
  },
458
512
 
@@ -463,10 +517,20 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
463
517
  if (val) {
464
518
  this.closed = false;
465
519
  this.$emit('open');
466
- if (this.appendToBody) {
520
+ if (this.referenceMode) {
521
+ var referenceEl = this.getReferenceElement();
522
+ if (referenceEl) {
523
+ referenceEl.appendChild(this.$el);
524
+ }
525
+ } else if (this.appendToBody) {
467
526
  document.body.appendChild(this.$el);
468
527
  }
469
528
  this.prevActiveElement = document.activeElement;
529
+ if (this.referenceMode) {
530
+ this.$nextTick(function () {
531
+ _this.updatePosition();
532
+ });
533
+ }
470
534
  } else {
471
535
  if (!this.closed) {
472
536
  this.$emit('close');
@@ -516,22 +580,106 @@ var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
516
580
  // pressing `ESC` will call this method, and also close the drawer.
517
581
  // This method also calls `beforeClose` if there was one.
518
582
  this.closeDrawer();
583
+ },
584
+ getReferenceElement: function getReferenceElement() {
585
+ if (typeof this.reference === 'string') {
586
+ return document.querySelector(this.reference);
587
+ } else if (this.reference && this.reference.$el) {
588
+ return this.reference.$el;
589
+ } else {
590
+ return this.reference;
591
+ }
592
+ },
593
+ updatePosition: function updatePosition() {
594
+ if (!this.referenceMode) return;
595
+
596
+ var referenceEl = this.getReferenceElement();
597
+ if (!referenceEl) {
598
+ console.warn('[ElDrawer] Reference element not found');
599
+ return;
600
+ }
601
+
602
+ // 确保参考元素有 position 样式
603
+ var computedStyle = window.getComputedStyle(referenceEl);
604
+ if (computedStyle.position === 'static') {
605
+ referenceEl.style.position = 'relative';
606
+ }
607
+
608
+ var placement = this.placement,
609
+ offset = this.offset;
610
+
611
+ var position = {};
612
+
613
+ switch (placement) {
614
+ case 'top':
615
+ position.left = '0';
616
+ position.bottom = offset + 'px';
617
+ position.top = 'auto';
618
+ position.right = '0';
619
+ break;
620
+ case 'bottom':
621
+ position.left = '0';
622
+ position.top = offset + 'px';
623
+ position.bottom = 'auto';
624
+ position.right = '0';
625
+ break;
626
+ case 'left':
627
+ position.top = '0';
628
+ position.right = 'auto';
629
+ position.left = offset + 'px';
630
+ position.bottom = '0';
631
+ break;
632
+ case 'right':
633
+ position.top = '0';
634
+ position.left = 'auto';
635
+ position.right = offset + 'px';
636
+ position.bottom = '0';
637
+ break;
638
+ }
639
+
640
+ this.position = position;
641
+ },
642
+ handleScroll: function handleScroll() {
643
+ if (this.referenceMode && this.visible) {
644
+ this.updatePosition();
645
+ }
646
+ },
647
+ handleResize: function handleResize() {
648
+ if (this.referenceMode && this.visible) {
649
+ this.updatePosition();
650
+ }
519
651
  }
520
652
  },
521
653
  mounted: function mounted() {
522
654
  if (this.visible) {
523
655
  this.rendered = true;
524
656
  this.open();
525
- if (this.appendToBody) {
657
+ if (this.referenceMode) {
658
+ var referenceEl = this.getReferenceElement();
659
+ if (referenceEl) {
660
+ referenceEl.appendChild(this.$el);
661
+ }
662
+ } else if (this.appendToBody) {
526
663
  document.body.appendChild(this.$el);
527
664
  }
528
665
  }
666
+ if (this.referenceMode) {
667
+ window.addEventListener('scroll', this.handleScroll, true);
668
+ window.addEventListener('resize', this.handleResize);
669
+ }
529
670
  },
530
671
  destroyed: function destroyed() {
531
672
  // if appendToBody is true, remove DOM node after destroy
532
673
  if (this.appendToBody && this.$el && this.$el.parentNode) {
533
674
  this.$el.parentNode.removeChild(this.$el);
534
675
  }
676
+ if (this.referenceMode && this.$el && this.$el.parentNode) {
677
+ this.$el.parentNode.removeChild(this.$el);
678
+ }
679
+ if (this.referenceMode) {
680
+ window.removeEventListener('scroll', this.handleScroll, true);
681
+ window.removeEventListener('resize', this.handleResize);
682
+ }
535
683
  }
536
684
  });
537
685
  // CONCATENATED MODULE: ./packages/drawer/src/main.vue?vue&type=script&lang=js&
@@ -41937,7 +41937,9 @@ var mainvue_type_template_id_a4885264_render = function() {
41937
41937
  expression: "visible"
41938
41938
  }
41939
41939
  ],
41940
- staticClass: "el-drawer__wrapper",
41940
+ class: _vm.referenceMode
41941
+ ? "el-drawer__wrapper-reference"
41942
+ : "el-drawer__wrapper",
41941
41943
  attrs: { tabindex: "-1" }
41942
41944
  },
41943
41945
  [
@@ -41945,7 +41947,10 @@ var mainvue_type_template_id_a4885264_render = function() {
41945
41947
  "div",
41946
41948
  {
41947
41949
  staticClass: "el-drawer__container",
41948
- class: _vm.visible && "el-drawer__open",
41950
+ class: [
41951
+ _vm.visible && "el-drawer__open",
41952
+ _vm.referenceMode && "el-drawer__reference-mode"
41953
+ ],
41949
41954
  attrs: { role: "document", tabindex: "-1" },
41950
41955
  on: {
41951
41956
  click: function($event) {
@@ -41962,10 +41967,12 @@ var mainvue_type_template_id_a4885264_render = function() {
41962
41967
  {
41963
41968
  ref: "drawer",
41964
41969
  staticClass: "el-drawer",
41965
- class: [_vm.direction, _vm.customClass],
41966
- style: _vm.isHorizontal
41967
- ? "width: " + _vm.drawerSize
41968
- : "height: " + _vm.drawerSize,
41970
+ class: [
41971
+ _vm.effectiveDirection,
41972
+ _vm.customClass,
41973
+ _vm.referenceMode && "is-reference"
41974
+ ],
41975
+ style: _vm.drawerStyle,
41969
41976
  attrs: {
41970
41977
  "aria-modal": "true",
41971
41978
  "aria-labelledby": "el-drawer__title",
@@ -42038,6 +42045,8 @@ mainvue_type_template_id_a4885264_render._withStripped = true
42038
42045
  // CONCATENATED MODULE: ./packages/drawer/src/main.vue?vue&type=template&id=a4885264&
42039
42046
 
42040
42047
  // 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&
42048
+ var mainvue_type_script_lang_js_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; };
42049
+
42041
42050
  //
42042
42051
  //
42043
42052
  //
@@ -42150,6 +42159,21 @@ mainvue_type_template_id_a4885264_render._withStripped = true
42150
42159
  withHeader: {
42151
42160
  type: Boolean,
42152
42161
  default: true
42162
+ },
42163
+ reference: {
42164
+ type: [String, Object],
42165
+ default: null
42166
+ },
42167
+ placement: {
42168
+ type: String,
42169
+ default: 'right',
42170
+ validator: function validator(val) {
42171
+ return ['top', 'bottom', 'left', 'right'].indexOf(val) !== -1;
42172
+ }
42173
+ },
42174
+ offset: {
42175
+ type: Number,
42176
+ default: 0
42153
42177
  }
42154
42178
  },
42155
42179
  computed: {
@@ -42158,12 +42182,42 @@ mainvue_type_template_id_a4885264_render._withStripped = true
42158
42182
  },
42159
42183
  drawerSize: function drawerSize() {
42160
42184
  return typeof this.size === 'number' ? this.size + 'px' : this.size;
42185
+ },
42186
+ referenceMode: function referenceMode() {
42187
+ return !!this.reference;
42188
+ },
42189
+ effectiveDirection: function effectiveDirection() {
42190
+ // 在 reference 模式下,根据 placement 映射到对应的 direction
42191
+ if (this.referenceMode) {
42192
+ var placementToDirection = {
42193
+ 'top': 'btt',
42194
+ 'bottom': 'ttb',
42195
+ 'left': 'ltr',
42196
+ 'right': 'rtl'
42197
+ };
42198
+ return placementToDirection[this.placement] || 'rtl';
42199
+ }
42200
+ return this.direction;
42201
+ },
42202
+ drawerStyle: function drawerStyle() {
42203
+ if (this.referenceMode) {
42204
+ var style = mainvue_type_script_lang_js_extends({}, this.position);
42205
+ if (this.placement === 'left' || this.placement === 'right') {
42206
+ style.width = this.drawerSize;
42207
+ } else {
42208
+ style.height = this.drawerSize;
42209
+ }
42210
+ return style;
42211
+ } else {
42212
+ return this.isHorizontal ? 'width: ' + this.drawerSize : 'height: ' + this.drawerSize;
42213
+ }
42161
42214
  }
42162
42215
  },
42163
42216
  data: function data() {
42164
42217
  return {
42165
42218
  closed: false,
42166
- prevActiveElement: null
42219
+ prevActiveElement: null,
42220
+ position: {}
42167
42221
  };
42168
42222
  },
42169
42223
 
@@ -42174,10 +42228,20 @@ mainvue_type_template_id_a4885264_render._withStripped = true
42174
42228
  if (val) {
42175
42229
  this.closed = false;
42176
42230
  this.$emit('open');
42177
- if (this.appendToBody) {
42231
+ if (this.referenceMode) {
42232
+ var referenceEl = this.getReferenceElement();
42233
+ if (referenceEl) {
42234
+ referenceEl.appendChild(this.$el);
42235
+ }
42236
+ } else if (this.appendToBody) {
42178
42237
  document.body.appendChild(this.$el);
42179
42238
  }
42180
42239
  this.prevActiveElement = document.activeElement;
42240
+ if (this.referenceMode) {
42241
+ this.$nextTick(function () {
42242
+ _this.updatePosition();
42243
+ });
42244
+ }
42181
42245
  } else {
42182
42246
  if (!this.closed) {
42183
42247
  this.$emit('close');
@@ -42227,22 +42291,106 @@ mainvue_type_template_id_a4885264_render._withStripped = true
42227
42291
  // pressing `ESC` will call this method, and also close the drawer.
42228
42292
  // This method also calls `beforeClose` if there was one.
42229
42293
  this.closeDrawer();
42294
+ },
42295
+ getReferenceElement: function getReferenceElement() {
42296
+ if (typeof this.reference === 'string') {
42297
+ return document.querySelector(this.reference);
42298
+ } else if (this.reference && this.reference.$el) {
42299
+ return this.reference.$el;
42300
+ } else {
42301
+ return this.reference;
42302
+ }
42303
+ },
42304
+ updatePosition: function updatePosition() {
42305
+ if (!this.referenceMode) return;
42306
+
42307
+ var referenceEl = this.getReferenceElement();
42308
+ if (!referenceEl) {
42309
+ console.warn('[ElDrawer] Reference element not found');
42310
+ return;
42311
+ }
42312
+
42313
+ // 确保参考元素有 position 样式
42314
+ var computedStyle = window.getComputedStyle(referenceEl);
42315
+ if (computedStyle.position === 'static') {
42316
+ referenceEl.style.position = 'relative';
42317
+ }
42318
+
42319
+ var placement = this.placement,
42320
+ offset = this.offset;
42321
+
42322
+ var position = {};
42323
+
42324
+ switch (placement) {
42325
+ case 'top':
42326
+ position.left = '0';
42327
+ position.bottom = offset + 'px';
42328
+ position.top = 'auto';
42329
+ position.right = '0';
42330
+ break;
42331
+ case 'bottom':
42332
+ position.left = '0';
42333
+ position.top = offset + 'px';
42334
+ position.bottom = 'auto';
42335
+ position.right = '0';
42336
+ break;
42337
+ case 'left':
42338
+ position.top = '0';
42339
+ position.right = 'auto';
42340
+ position.left = offset + 'px';
42341
+ position.bottom = '0';
42342
+ break;
42343
+ case 'right':
42344
+ position.top = '0';
42345
+ position.left = 'auto';
42346
+ position.right = offset + 'px';
42347
+ position.bottom = '0';
42348
+ break;
42349
+ }
42350
+
42351
+ this.position = position;
42352
+ },
42353
+ handleScroll: function handleScroll() {
42354
+ if (this.referenceMode && this.visible) {
42355
+ this.updatePosition();
42356
+ }
42357
+ },
42358
+ handleResize: function handleResize() {
42359
+ if (this.referenceMode && this.visible) {
42360
+ this.updatePosition();
42361
+ }
42230
42362
  }
42231
42363
  },
42232
42364
  mounted: function mounted() {
42233
42365
  if (this.visible) {
42234
42366
  this.rendered = true;
42235
42367
  this.open();
42236
- if (this.appendToBody) {
42368
+ if (this.referenceMode) {
42369
+ var referenceEl = this.getReferenceElement();
42370
+ if (referenceEl) {
42371
+ referenceEl.appendChild(this.$el);
42372
+ }
42373
+ } else if (this.appendToBody) {
42237
42374
  document.body.appendChild(this.$el);
42238
42375
  }
42239
42376
  }
42377
+ if (this.referenceMode) {
42378
+ window.addEventListener('scroll', this.handleScroll, true);
42379
+ window.addEventListener('resize', this.handleResize);
42380
+ }
42240
42381
  },
42241
42382
  destroyed: function destroyed() {
42242
42383
  // if appendToBody is true, remove DOM node after destroy
42243
42384
  if (this.appendToBody && this.$el && this.$el.parentNode) {
42244
42385
  this.$el.parentNode.removeChild(this.$el);
42245
42386
  }
42387
+ if (this.referenceMode && this.$el && this.$el.parentNode) {
42388
+ this.$el.parentNode.removeChild(this.$el);
42389
+ }
42390
+ if (this.referenceMode) {
42391
+ window.removeEventListener('scroll', this.handleScroll, true);
42392
+ window.removeEventListener('resize', this.handleResize);
42393
+ }
42246
42394
  }
42247
42395
  });
42248
42396
  // CONCATENATED MODULE: ./packages/drawer/src/main.vue?vue&type=script&lang=js&
@@ -49380,7 +49528,7 @@ function useCascaderAreaData() {
49380
49528
  });
49381
49529
  }
49382
49530
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/area-picker/src/main.vue?vue&type=script&lang=js&
49383
- var mainvue_type_script_lang_js_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; };
49531
+ var src_mainvue_type_script_lang_js_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; };
49384
49532
 
49385
49533
  //
49386
49534
  //
@@ -49457,7 +49605,7 @@ var mainvue_type_script_lang_js_extends = Object.assign || function (target) { f
49457
49605
  cascaderProps: function cascaderProps() {
49458
49606
  // 获取外部传入的props配置
49459
49607
  var externalProps = this.props || {};
49460
- var res = mainvue_type_script_lang_js_extends({
49608
+ var res = src_mainvue_type_script_lang_js_extends({
49461
49609
  // 从组件属性中获取checkStrictly和multiple
49462
49610
  emitPath: false,
49463
49611
  expandTrigger: 'hover',
@@ -49906,7 +50054,7 @@ mainvue_type_template_id_3cb4623f_render._withStripped = true
49906
50054
  // CONCATENATED MODULE: ./packages/trigger/src/main.vue?vue&type=template&id=3cb4623f&
49907
50055
 
49908
50056
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/trigger/src/main.vue?vue&type=script&lang=js&
49909
- var src_mainvue_type_script_lang_js_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; };
50057
+ var trigger_src_mainvue_type_script_lang_js_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; };
49910
50058
 
49911
50059
  //
49912
50060
  //
@@ -50154,7 +50302,7 @@ var stop = function stop(e) {
50154
50302
 
50155
50303
  computed: {
50156
50304
  popupStyleComputed: function popupStyleComputed() {
50157
- var style = src_mainvue_type_script_lang_js_extends({}, this.popupStyle);
50305
+ var style = trigger_src_mainvue_type_script_lang_js_extends({}, this.popupStyle);
50158
50306
 
50159
50307
  if (this.autoFitPopupWidth && this.referenceElm) {
50160
50308
  style.width = this.referenceElm.offsetWidth + 'px';
@@ -51804,7 +51952,7 @@ if (typeof window !== 'undefined' && window.Vue) {
51804
51952
  }
51805
51953
 
51806
51954
  /* harmony default export */ var src_0 = __webpack_exports__["default"] = ({
51807
- version: '2.15.5-xn.51',
51955
+ version: '2.15.5-xn.52',
51808
51956
  locale: lib_locale_default.a.use,
51809
51957
  i18n: lib_locale_default.a.i18n,
51810
51958
  install: src_install,