@94ai/nf-virtual-select 3.1.26 → 3.1.28

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.
@@ -3741,7 +3741,7 @@ var dist = { exports: {} };
3741
3741
  },
3742
3742
  methods: {
3743
3743
  // get item size by id
3744
- getSize: function getSize(id2) {
3744
+ getSize: function getSize2(id2) {
3745
3745
  return this.virtual.sizes.get(id2);
3746
3746
  },
3747
3747
  // get the total number of stored (rendered) items
@@ -3758,7 +3758,7 @@ var dist = { exports: {} };
3758
3758
  }
3759
3759
  },
3760
3760
  // return client viewport size
3761
- getClientSize: function getClientSize() {
3761
+ getClientSize: function getClientSize2() {
3762
3762
  var key = this.isHorizontal ? "clientWidth" : "clientHeight";
3763
3763
  if (this.pageMode) {
3764
3764
  return document.documentElement[key] || document.body[key];
@@ -3768,7 +3768,7 @@ var dist = { exports: {} };
3768
3768
  }
3769
3769
  },
3770
3770
  // return all scroll size
3771
- getScrollSize: function getScrollSize() {
3771
+ getScrollSize: function getScrollSize2() {
3772
3772
  var key = this.isHorizontal ? "scrollWidth" : "scrollHeight";
3773
3773
  if (this.pageMode) {
3774
3774
  return document.documentElement[key] || document.body[key];
@@ -3778,7 +3778,7 @@ var dist = { exports: {} };
3778
3778
  }
3779
3779
  },
3780
3780
  // set current scroll position to a expectant offset
3781
- scrollToOffset: function scrollToOffset(offset) {
3781
+ scrollToOffset: function scrollToOffset2(offset) {
3782
3782
  if (this.pageMode) {
3783
3783
  document.body[this.directionKey] = offset;
3784
3784
  document.documentElement[this.directionKey] = offset;
@@ -3790,7 +3790,7 @@ var dist = { exports: {} };
3790
3790
  }
3791
3791
  },
3792
3792
  // set current scroll position to a expectant index
3793
- scrollToIndex: function scrollToIndex(index) {
3793
+ scrollToIndex: function scrollToIndex2(index) {
3794
3794
  if (index >= this.dataSources.length - 1) {
3795
3795
  this.scrollToBottom();
3796
3796
  } else {
@@ -3799,7 +3799,7 @@ var dist = { exports: {} };
3799
3799
  }
3800
3800
  },
3801
3801
  // set current scroll position to bottom
3802
- scrollToBottom: function scrollToBottom() {
3802
+ scrollToBottom: function scrollToBottom2() {
3803
3803
  var _this = this;
3804
3804
  var shepherd = this.$refs.shepherd;
3805
3805
  if (shepherd) {
@@ -3814,7 +3814,7 @@ var dist = { exports: {} };
3814
3814
  },
3815
3815
  // when using page mode we need update slot header size manually
3816
3816
  // taking root offset relative to the browser as slot header size
3817
- updatePageModeFront: function updatePageModeFront() {
3817
+ updatePageModeFront: function updatePageModeFront2() {
3818
3818
  var root = this.$refs.root;
3819
3819
  if (root) {
3820
3820
  var rect = root.getBoundingClientRect();
@@ -3824,7 +3824,7 @@ var dist = { exports: {} };
3824
3824
  }
3825
3825
  },
3826
3826
  // reset all state back to initial
3827
- reset: function reset() {
3827
+ reset: function reset2() {
3828
3828
  this.virtual.destroy();
3829
3829
  this.scrollToOffset(0);
3830
3830
  this.installVirtual();
@@ -9516,11 +9516,11 @@ function ownKeys2(object, enumerableOnly) {
9516
9516
  }
9517
9517
  function _objectSpread(target) {
9518
9518
  for (var i = 1; i < arguments.length; i++) {
9519
- var _context11, _context12;
9519
+ var _context12, _context13;
9520
9520
  var source = null != arguments[i] ? arguments[i] : {};
9521
- i % 2 ? _forEachInstanceProperty(_context11 = ownKeys2(Object(source), true)).call(_context11, function(key) {
9521
+ i % 2 ? _forEachInstanceProperty(_context12 = ownKeys2(Object(source), true)).call(_context12, function(key) {
9522
9522
  _defineProperty(target, key, source[key]);
9523
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context12 = ownKeys2(Object(source))).call(_context12, function(key) {
9523
+ }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context13 = ownKeys2(Object(source))).call(_context13, function(key) {
9524
9524
  _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
9525
9525
  });
9526
9526
  }
@@ -9533,9 +9533,109 @@ var _sfc_main = {
9533
9533
  },
9534
9534
  inheritAttrs: false,
9535
9535
  props: {
9536
+ offset: {
9537
+ type: Number,
9538
+ "default": 0
9539
+ },
9540
+ start: {
9541
+ type: Number,
9542
+ "default": 0
9543
+ },
9544
+ pageMode: {
9545
+ type: Boolean,
9546
+ "default": false
9547
+ },
9548
+ direction: {
9549
+ type: String,
9550
+ "default": "vertical"
9551
+ },
9552
+ topThreshold: {
9553
+ type: Number,
9554
+ "default": 0
9555
+ },
9556
+ bottomThreshold: {
9557
+ type: Number,
9558
+ "default": 0
9559
+ },
9560
+ rootTag: {
9561
+ type: String,
9562
+ "default": "div"
9563
+ },
9564
+ wrapTag: {
9565
+ type: String,
9566
+ "default": "div"
9567
+ },
9568
+ wrapStyle: {
9569
+ type: Object,
9570
+ "default": function _default2() {
9571
+ return {};
9572
+ }
9573
+ },
9574
+ itemTag: {
9575
+ type: String,
9576
+ "default": "div"
9577
+ },
9578
+ itemClass: {
9579
+ type: String,
9580
+ "default": ""
9581
+ },
9582
+ itemClassAdd: {
9583
+ type: Function
9584
+ },
9585
+ itemStyle: {
9586
+ type: Object,
9587
+ "default": function _default3() {
9588
+ return {};
9589
+ }
9590
+ },
9591
+ itemScopedSlots: {
9592
+ type: Object,
9593
+ "default": function _default4() {
9594
+ return {};
9595
+ }
9596
+ },
9597
+ headerTag: {
9598
+ type: String,
9599
+ "default": "div"
9600
+ },
9601
+ headeClass: {
9602
+ type: String,
9603
+ "default": ""
9604
+ },
9605
+ headerStyle: {
9606
+ type: Object,
9607
+ "default": function _default5() {
9608
+ return {};
9609
+ }
9610
+ },
9611
+ footerTag: {
9612
+ type: String,
9613
+ "default": "div"
9614
+ },
9615
+ footerClass: {
9616
+ type: String,
9617
+ "default": ""
9618
+ },
9619
+ footerStyle: {
9620
+ type: Object,
9621
+ "default": function _default6() {
9622
+ return {};
9623
+ }
9624
+ },
9625
+ keeps: {
9626
+ type: Number,
9627
+ "default": 30
9628
+ },
9629
+ /**
9630
+ * 每个项目的估计大小,如果它更接近平均大小,滚动条长度看起来更准确。建议指定自己计算的平均值。
9631
+ */
9632
+ estimateSize: {
9633
+ type: Number,
9634
+ "default": 50
9635
+ },
9536
9636
  value: {
9537
9637
  type: [String, Number, Array],
9538
- "default": function _default2() {
9638
+ "default": function _default7() {
9539
9639
  return "";
9540
9640
  }
9541
9641
  },
@@ -9546,7 +9646,7 @@ var _sfc_main = {
9546
9646
  // 默认['label','value']
9547
9647
  keyValue: {
9548
9648
  type: Array,
9549
- "default": function _default3() {
9649
+ "default": function _default8() {
9550
9650
  return ["label", "value"];
9551
9651
  }
9552
9652
  },
@@ -9556,7 +9656,7 @@ var _sfc_main = {
9556
9656
  },
9557
9657
  itemOptions: {
9558
9658
  type: Object,
9559
- "default": function _default4() {
9659
+ "default": function _default9() {
9560
9660
  return {
9561
9661
  options: [],
9562
9662
  virtualList: false
@@ -9569,7 +9669,7 @@ var _sfc_main = {
9569
9669
  },
9570
9670
  options: {
9571
9671
  type: Array,
9572
- "default": function _default5() {
9672
+ "default": function _default10() {
9573
9673
  return [];
9574
9674
  }
9575
9675
  },
@@ -9584,11 +9684,32 @@ var _sfc_main = {
9584
9684
  width: {
9585
9685
  type: String,
9586
9686
  "default": "240px"
9687
+ },
9688
+ height: {
9689
+ type: String,
9690
+ "default": "245px"
9691
+ },
9692
+ dataComponent: {
9693
+ type: Object
9694
+ },
9695
+ extraProps: {
9696
+ type: Object,
9697
+ "default": function _default11() {
9698
+ return {
9699
+ label: "label",
9700
+ value: "value"
9701
+ };
9702
+ }
9703
+ },
9704
+ dataKey: {
9705
+ type: [String, Function],
9706
+ "default": "templateId"
9587
9707
  }
9588
9708
  },
9589
9709
  data: function data2() {
9710
+ var _this$dataComponent;
9590
9711
  return {
9591
- itemComponent: ElOptionNode,
9712
+ itemComponent: (_this$dataComponent = this.dataComponent) !== null && _this$dataComponent !== void 0 ? _this$dataComponent : ElOptionNode,
9592
9713
  selectArr: []
9593
9714
  };
9594
9715
  },
@@ -9625,7 +9746,7 @@ var _sfc_main = {
9625
9746
  },
9626
9747
  // 绑定方法
9627
9748
  bindEvents: function bindEvents() {
9628
- var events = _objectSpread({}, this.itemOptions.events);
9749
+ var events = _objectSpread(_objectSpread({}, this.$listeners || {}), this.itemOptions.events);
9629
9750
  if (events !== null && events !== void 0 && events.change) {
9630
9751
  delete events.change;
9631
9752
  }
@@ -9636,7 +9757,7 @@ var _sfc_main = {
9636
9757
  return _objectSpread(_objectSpread(_objectSpread({
9637
9758
  size: this.size
9638
9759
  }, this.itemOptions), this.$attrs), {}, {
9639
- element: "custom-select",
9760
+ element: "el-select",
9640
9761
  virtualList: this.itemOptions.virtualList || this.virtualList,
9641
9762
  placeholder: this.itemOptions.placeholder || this.placeholder,
9642
9763
  filterable: this.itemOptions.filterable || this.filterable,
@@ -9676,12 +9797,66 @@ var _sfc_main = {
9676
9797
  this.init();
9677
9798
  },
9678
9799
  methods: {
9679
- handleFocus: function handleFocus() {
9680
- this.$emit("focus");
9800
+ reset: function reset() {
9801
+ this.$refs.virtualSelectList.reset();
9681
9802
  },
9682
- handleChange: function handleChange(event) {
9803
+ scrollToBottom: function scrollToBottom() {
9804
+ this.$refs.virtualSelectList.scrollToBottom();
9805
+ },
9806
+ scrollToIndex: function scrollToIndex(index) {
9807
+ this.$refs.virtualSelectList.scrollToIndex(index);
9808
+ },
9809
+ scrollToOffset: function scrollToOffset(offset) {
9810
+ this.$refs.virtualSelectList.scrollToOffset(offset);
9811
+ },
9812
+ getSize: function getSize(id2) {
9813
+ return this.$refs.virtualSelectList.getSize(id2);
9814
+ },
9815
+ getClientSize: function getClientSize() {
9816
+ return this.$refs.virtualSelectList.getClientSize();
9817
+ },
9818
+ getScrollSize: function getScrollSize() {
9819
+ return this.$refs.virtualSelectList.getScrollSize();
9820
+ },
9821
+ updatePageModeFront: function updatePageModeFront() {
9822
+ this.$refs.virtualSelectList.updatePageModeFront();
9823
+ },
9824
+ scroll: function scroll(event) {
9683
9825
  var _this$itemOptions$eve;
9684
- if ((_this$itemOptions$eve = this.itemOptions.events) !== null && _this$itemOptions$eve !== void 0 && _this$itemOptions$eve.change) {
9826
+ if ((_this$itemOptions$eve = this.itemOptions.events) !== null && _this$itemOptions$eve !== void 0 && _this$itemOptions$eve.scroll) {
9827
+ this.itemOptions.events.scroll(event, this);
9828
+ } else {
9829
+ this.$emit("scroll", event);
9830
+ }
9831
+ },
9832
+ totop: function totop(event) {
9833
+ var _this$itemOptions$eve2;
9834
+ if ((_this$itemOptions$eve2 = this.itemOptions.events) !== null && _this$itemOptions$eve2 !== void 0 && _this$itemOptions$eve2.totop) {
9835
+ this.itemOptions.events.totop(event, this);
9836
+ } else {
9837
+ this.$emit("totop", event);
9838
+ }
9839
+ },
9840
+ tobottom: function tobottom(event) {
9841
+ var _this$itemOptions$eve3;
9842
+ if ((_this$itemOptions$eve3 = this.itemOptions.events) !== null && _this$itemOptions$eve3 !== void 0 && _this$itemOptions$eve3.tobottom) {
9843
+ this.itemOptions.events.tobottom(event, this);
9844
+ } else {
9845
+ this.$emit("tobottom", event);
9846
+ }
9847
+ },
9848
+ resized: function resized(event) {
9849
+ var _this$itemOptions$eve4;
9850
+ if ((_this$itemOptions$eve4 = this.itemOptions.events) !== null && _this$itemOptions$eve4 !== void 0 && _this$itemOptions$eve4.resized) {
9851
+ this.itemOptions.events.resized(event, this);
9852
+ } else {
9853
+ debugger;
9854
+ this.$emit("resized", event);
9855
+ }
9856
+ },
9857
+ handleChange: function handleChange(event) {
9858
+ var _this$itemOptions$eve5;
9859
+ if ((_this$itemOptions$eve5 = this.itemOptions.events) !== null && _this$itemOptions$eve5 !== void 0 && _this$itemOptions$eve5.change) {
9685
9860
  this.itemOptions.events.change(event, this);
9686
9861
  } else {
9687
9862
  this.$emit("change", event);
@@ -9777,24 +9952,25 @@ var _sfc_main = {
9777
9952
  },
9778
9953
  visibleChange: function visibleChange(bool) {
9779
9954
  if (!bool) {
9780
- this.$refs.virtualSelectList.reset();
9955
+ this.reset();
9781
9956
  this.init();
9782
9957
  }
9783
9958
  }
9784
9959
  },
9785
9960
  beforeDestroy: function beforeDestroy() {
9786
- this.$refs.virtualSelectList.reset();
9961
+ this.reset();
9787
9962
  this.selectArr = [];
9788
9963
  },
9789
9964
  activated: function activated() {
9790
9965
  this.init();
9791
9966
  },
9792
9967
  deactivated: function deactivated() {
9793
- this.$refs.virtualSelectList.reset();
9968
+ this.reset();
9794
9969
  this.selectArr = [];
9795
9970
  }
9796
9971
  };
9797
9972
  var _sfc_render = function render2() {
9973
+ var _context11;
9798
9974
  var _vm = this, _c = _vm._self._c;
9799
9975
  return _c("div", {
9800
9976
  staticClass: "nf-virtual-select"
@@ -9820,22 +9996,45 @@ var _sfc_render = function render2() {
9820
9996
  }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_c("virtual-list", {
9821
9997
  ref: "virtualSelectList",
9822
9998
  staticClass: "nf-virtual-select-list",
9823
- style: "max-height: 245px;width: ".concat(_vm.width, "; overflow-y: auto;"),
9999
+ style: _concatInstanceProperty(_context11 = "max-height: ".concat(_vm.height, ";width: ")).call(_context11, _vm.width, "; overflow-y: auto;"),
9824
10000
  attrs: {
9825
- "data-key": "templateId",
10001
+ "offset": _vm.offset,
10002
+ "start": _vm.start,
10003
+ "page-mode": _vm.pageMode,
10004
+ "direction": _vm.direction,
10005
+ "top-threshold": _vm.topThreshold,
10006
+ "bottom-threshold": _vm.bottomThreshold,
10007
+ "root-tag": _vm.rootTag,
10008
+ "wrap-tag": _vm.wrapTag,
10009
+ "wrap-style": _vm.wrapStyle,
10010
+ "item-tag": _vm.itemTag,
10011
+ "item-class": _vm.itemClass,
10012
+ "item-class-add": _vm.itemClassAdd,
10013
+ "item-style": _vm.itemStyle,
10014
+ "item-scoped-slots": _vm.itemScopedSlots,
10015
+ "header-tag": _vm.headerTag,
10016
+ "header-class": _vm.headeClass,
10017
+ "header-style": _vm.headerStyle,
10018
+ "footer-tag": _vm.footerTag,
10019
+ "footer-class": _vm.footerClass,
10020
+ "footer-style": _vm.footerStyle,
10021
+ "data-key": _vm.dataKey,
10022
+ "estimate-size": _vm.estimateSize,
9826
10023
  "data-sources": _vm.selectArr,
9827
10024
  "data-component": _vm.itemComponent,
9828
- "keeps": 30,
9829
- "extra-props": {
9830
- label: "label",
9831
- value: "value"
9832
- }
10025
+ "keeps": _vm.keeps,
10026
+ "extra-props": _vm.extraProps
10027
+ },
10028
+ on: {
10029
+ "scroll": _vm.scroll,
10030
+ "totop": _vm.totop,
10031
+ "tobottom": _vm.tobottom,
10032
+ "resized": _vm.resized
9833
10033
  }
9834
10034
  })], 1)] : _vm.isSelect ? _c("el-select", _vm._g(_vm._b({
9835
10035
  style: "width: ".concat(_vm.width, ";"),
9836
10036
  on: {
9837
- "change": _vm.handleChange,
9838
- "focus": _vm.handleFocus
10037
+ "change": _vm.handleChange
9839
10038
  },
9840
10039
  model: {
9841
10040
  value: _vm.currentVal,