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