bkui-vue 2.0.1-beta.58 → 2.0.1-beta.59

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.
@@ -17624,22 +17624,28 @@ var virtualRenderProps = _objectSpread({
17624
17624
  });
17625
17625
  };
17626
17626
  var scrollTo = function scrollTo(x, y) {
17627
- instance.scrollTo({
17627
+ var _instance;
17628
+ (_instance = instance) === null || _instance === void 0 || _instance.scrollTo({
17628
17629
  x: x,
17629
17630
  y: y
17630
17631
  });
17631
17632
  };
17632
17633
  var updateScrollHeight = function updateScrollHeight(height) {
17633
- var _instance;
17634
- if ((_instance = instance) !== null && _instance !== void 0 && _instance.element) {
17635
- instance.element.scrollHeight = height;
17636
- instance.update();
17634
+ var _instance2;
17635
+ if ((_instance2 = instance) !== null && _instance2 !== void 0 && _instance2.element) {
17636
+ var _instance3, _instance4;
17637
+ ((_instance3 = instance) === null || _instance3 === void 0 ? void 0 : _instance3.element).scrollHeight = height;
17638
+ (_instance4 = instance) === null || _instance4 === void 0 || _instance4.update();
17637
17639
  }
17638
17640
  };
17639
17641
  return {
17640
17642
  init: init,
17641
17643
  instance: instance,
17642
17644
  scrollTo: scrollTo,
17645
+ update: function update() {
17646
+ var _instance5;
17647
+ return (_instance5 = instance) === null || _instance5 === void 0 ? void 0 : _instance5.update();
17648
+ },
17643
17649
  updateScrollHeight: updateScrollHeight
17644
17650
  };
17645
17651
  });
@@ -17802,10 +17808,29 @@ var VisibleRender = /*#__PURE__*/function () {
17802
17808
  this.wrapper = el;
17803
17809
  var throttleDelay = binding.value.throttleDelay;
17804
17810
  this.delay = throttleDelay;
17811
+ this.delegateWrapper = undefined;
17805
17812
  }
17806
17813
  _createClass(VisibleRender, [{
17814
+ key: "scrollHeight",
17815
+ get: function get() {
17816
+ var _this$delegateWrapper, _this$delegateWrapper2, _this$wrapper;
17817
+ return (_this$delegateWrapper = (_this$delegateWrapper2 = this.delegateWrapper) === null || _this$delegateWrapper2 === void 0 ? void 0 : _this$delegateWrapper2.scrollHeight) !== null && _this$delegateWrapper !== void 0 ? _this$delegateWrapper : (_this$wrapper = this.wrapper) === null || _this$wrapper === void 0 ? void 0 : _this$wrapper.scrollHeight;
17818
+ }
17819
+ }, {
17820
+ key: "offsetHeight",
17821
+ get: function get() {
17822
+ var _this$delegateWrapper3, _this$delegateWrapper4, _this$wrapper2;
17823
+ return (_this$delegateWrapper3 = (_this$delegateWrapper4 = this.delegateWrapper) === null || _this$delegateWrapper4 === void 0 ? void 0 : _this$delegateWrapper4.offsetHeight) !== null && _this$delegateWrapper3 !== void 0 ? _this$delegateWrapper3 : (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.offsetHeight;
17824
+ }
17825
+ }, {
17826
+ key: "setDelegateWrapper",
17827
+ value: function setDelegateWrapper(el) {
17828
+ this.delegateWrapper = el;
17829
+ }
17830
+ }, {
17807
17831
  key: "render",
17808
17832
  value: function render(e) {
17833
+ var _this$delegateWrapper5;
17809
17834
  var _this$binding$value = this.binding.value,
17810
17835
  _this$binding$value$l = _this$binding$value.lineHeight,
17811
17836
  lineHeight = _this$binding$value$l === void 0 ? 30 : _this$binding$value$l,
@@ -17817,7 +17842,7 @@ var VisibleRender = /*#__PURE__*/function () {
17817
17842
  var _e$offset, _e$offset$x, _e$offset2;
17818
17843
  var elScrollTop = (_e$offset = e.offset) === null || _e$offset === void 0 ? void 0 : _e$offset.y;
17819
17844
  var elScrollLeft = (_e$offset$x = (_e$offset2 = e.offset) === null || _e$offset2 === void 0 ? void 0 : _e$offset2.x) !== null && _e$offset$x !== void 0 ? _e$offset$x : 0;
17820
- var bottom = this.wrapper.scrollHeight - this.wrapper.offsetHeight - elScrollTop;
17845
+ var bottom = this.scrollHeight - this.offsetHeight - elScrollTop;
17821
17846
  handleScrollCallback(e, null, null, elScrollTop, elScrollTop, elScrollLeft, {
17822
17847
  bottom: bottom >= 0 ? bottom : 0,
17823
17848
  scrollbar: e
@@ -17837,7 +17862,7 @@ var VisibleRender = /*#__PURE__*/function () {
17837
17862
  groupItemCount: groupItemCount,
17838
17863
  count: count,
17839
17864
  scrollLeft: scrollLeft
17840
- }, this.wrapper, e);
17865
+ }, (_this$delegateWrapper5 = this.delegateWrapper) !== null && _this$delegateWrapper5 !== void 0 ? _this$delegateWrapper5 : this.wrapper, e);
17841
17866
  }
17842
17867
  }, {
17843
17868
  key: "executeThrottledRender",
@@ -17847,14 +17872,14 @@ var VisibleRender = /*#__PURE__*/function () {
17847
17872
  }, {
17848
17873
  key: "install",
17849
17874
  value: function install() {
17850
- var _this$wrapper;
17851
- (_this$wrapper = this.wrapper) === null || _this$wrapper === void 0 || _this$wrapper.addEventListener('scroll', this.executeThrottledRender.bind(this));
17875
+ var _this$wrapper3;
17876
+ (_this$wrapper3 = this.wrapper) === null || _this$wrapper3 === void 0 || _this$wrapper3.addEventListener('scroll', this.executeThrottledRender.bind(this));
17852
17877
  }
17853
17878
  }, {
17854
17879
  key: "uninstall",
17855
17880
  value: function uninstall() {
17856
- var _this$wrapper2, _this$wrapper2$remove;
17857
- (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 || (_this$wrapper2$remove = _this$wrapper2.removeListener) === null || _this$wrapper2$remove === void 0 || _this$wrapper2$remove.call(_this$wrapper2, 'scroll', this.executeThrottledRender.bind(this));
17881
+ var _this$wrapper4, _this$wrapper4$remove;
17882
+ (_this$wrapper4 = this.wrapper) === null || _this$wrapper4 === void 0 || (_this$wrapper4$remove = _this$wrapper4.removeListener) === null || _this$wrapper4$remove === void 0 || _this$wrapper4$remove.call(_this$wrapper4, 'scroll', this.executeThrottledRender.bind(this));
17858
17883
  }
17859
17884
  }, {
17860
17885
  key: "setBinding",
@@ -18073,11 +18098,23 @@ function virtual_render_objectSpread(e) { for (var r = 1; r < arguments.length;
18073
18098
  rendAsTag = _useTagRender.rendAsTag;
18074
18099
  return rendAsTag;
18075
18100
  }
18101
+ var refRoot = (0,external_vue_namespaceObject.ref)(null);
18102
+ /** 如果有分组状态,计算总行数 */
18103
+ var listLength = (0,external_vue_namespaceObject.ref)(0);
18104
+ /** 实际高度,根据行高和总行数计算出来的实际高度 */
18105
+ var innerHeight = (0,external_vue_namespaceObject.ref)(0);
18106
+ var contentHeight = (0,external_vue_namespaceObject.ref)(0);
18107
+ var virtualRoot = (0,external_vue_namespaceObject.ref)(null);
18076
18108
  var getRowHeightArgs = function getRowHeightArgs(startIndex) {
18077
18109
  var start = startIndex * props.groupItemCount;
18078
18110
  var end = (startIndex + 1) * props.groupItemCount;
18111
+ if (end > listLength.value) {
18112
+ var count = end - start;
18113
+ end = listLength.value;
18114
+ start = end - count;
18115
+ }
18079
18116
  return {
18080
- index: startIndex,
18117
+ index: start,
18081
18118
  rows: props.list.slice(start, end),
18082
18119
  items: [start, end],
18083
18120
  type: 'virtual'
@@ -18101,17 +18138,11 @@ function virtual_render_objectSpread(e) { for (var r = 1; r < arguments.length;
18101
18138
  scrollbar: props.scrollbar
18102
18139
  };
18103
18140
  });
18104
- var refRoot = (0,external_vue_namespaceObject.ref)(null);
18105
- /** 如果有分组状态,计算总行数 */
18106
- var listLength = (0,external_vue_namespaceObject.ref)(0);
18107
- /** 实际高度,根据行高和总行数计算出来的实际高度 */
18108
- var innerHeight = (0,external_vue_namespaceObject.ref)(0);
18109
- var contentHeight = (0,external_vue_namespaceObject.ref)(0);
18110
- var virtualRoot = (0,external_vue_namespaceObject.ref)(null);
18111
18141
  var _useScrollbar = use_scrollbar(props),
18112
18142
  init = _useScrollbar.init,
18113
18143
  scrollTo = _useScrollbar.scrollTo,
18114
- updateScrollHeight = _useScrollbar.updateScrollHeight;
18144
+ updateScrollHeight = _useScrollbar.updateScrollHeight,
18145
+ update = _useScrollbar.update;
18115
18146
  var instance = null;
18116
18147
  var pagination = (0,external_vue_namespaceObject.reactive)({
18117
18148
  startIndex: 0,
@@ -18125,9 +18156,15 @@ function virtual_render_objectSpread(e) { for (var r = 1; r < arguments.length;
18125
18156
  groupItemCount: props.groupItemCount
18126
18157
  });
18127
18158
  var calcList = (0,external_vue_namespaceObject.ref)([]);
18128
- var getLastPageIndex = function getLastPageIndex() {
18159
+ var getOffsetHeight = function getOffsetHeight() {
18160
+ if (typeof props.height === 'number') {
18161
+ return props.height;
18162
+ }
18129
18163
  // @ts-ignore
18130
- var elHeight = virtualRoot.value.offsetHeight;
18164
+ return virtualRoot.value.offsetHeight;
18165
+ };
18166
+ var getLastPageIndex = function getLastPageIndex() {
18167
+ var elHeight = getOffsetHeight();
18131
18168
  var startIndex = Math.ceil(listLength.value / props.groupItemCount);
18132
18169
  var rowsHeight = 0;
18133
18170
  var lastHeight = 0;
@@ -18236,7 +18273,11 @@ function virtual_render_objectSpread(e) { for (var r = 1; r < arguments.length;
18236
18273
  top: 0
18237
18274
  };
18238
18275
  var el = refRoot.value;
18239
- computedVirtualIndex(props.lineHeight, handleScrollCallback, pagination, el, {
18276
+ var container = typeof props.height === 'number' ? {
18277
+ scrollHeight: innerHeight.value,
18278
+ offsetHeight: props.height
18279
+ } : el;
18280
+ computedVirtualIndex(props.lineHeight, handleScrollCallback, pagination, container, {
18240
18281
  target: el
18241
18282
  });
18242
18283
  };
@@ -18292,31 +18333,50 @@ function virtual_render_objectSpread(e) { for (var r = 1; r < arguments.length;
18292
18333
  };
18293
18334
  var _useFixTop = use_fix_top(props, scrollTo),
18294
18335
  fixToTop = _useFixTop.fixToTop;
18295
- (0,external_vue_namespaceObject.watch)(function () {
18296
- return [props.list];
18297
- }, function () {
18336
+ var setDelegateEl = function setDelegateEl() {
18298
18337
  var _instance3;
18299
- (_instance3 = instance) === null || _instance3 === void 0 || _instance3.setBinding(binding);
18338
+ var el = refRoot.value;
18339
+ var container = typeof props.height === 'number' ? {
18340
+ scrollHeight: innerHeight.value,
18341
+ offsetHeight: props.height
18342
+ } : el;
18343
+ (_instance3 = instance) === null || _instance3 === void 0 || _instance3.setDelegateWrapper(container);
18344
+ };
18345
+ var updateVirtualInstance = function updateVirtualInstance() {
18346
+ var _instance4;
18347
+ (_instance4 = instance) === null || _instance4 === void 0 || _instance4.setBinding(binding);
18300
18348
  handleChangeListConfig();
18301
18349
  updateScrollHeight(contentHeight.value);
18350
+ setDelegateEl();
18351
+ update();
18302
18352
  afterListDataReset();
18303
18353
  (0,external_vue_namespaceObject.nextTick)(function () {
18304
- var _instance4;
18305
- (_instance4 = instance) === null || _instance4 === void 0 || _instance4.executeThrottledRender.call(instance, {
18354
+ var _instance5;
18355
+ (_instance5 = instance) === null || _instance5 === void 0 || _instance5.executeThrottledRender.call(instance, {
18306
18356
  offset: {
18307
18357
  x: pagination.scrollLeft,
18308
18358
  y: pagination.scrollTop
18309
18359
  }
18310
18360
  });
18311
18361
  });
18362
+ };
18363
+ (0,external_vue_namespaceObject.watch)(function () {
18364
+ return props.height;
18365
+ }, function () {
18366
+ updateVirtualInstance();
18367
+ });
18368
+ (0,external_vue_namespaceObject.watch)(function () {
18369
+ return [props.list, props.list.length];
18370
+ }, function () {
18371
+ updateVirtualInstance();
18312
18372
  }, {
18313
- immediate: true,
18314
- deep: true
18373
+ immediate: true
18315
18374
  });
18316
18375
  ctx.expose({
18317
18376
  reset: reset,
18318
18377
  scrollTo: scrollTo,
18319
18378
  fixToTop: fixToTop,
18379
+ updateScroll: update,
18320
18380
  refRoot: refRoot,
18321
18381
  refContent: refRoot
18322
18382
  });
@@ -5,6 +5,7 @@ declare const _default: (props: VirtualRenderProps) => {
5
5
  init: (target: Ref<Partial<Element> & Partial<VirtualElement>>) => void;
6
6
  instance: BkScrollbar;
7
7
  scrollTo: (x: any, y: any) => void;
8
+ update: () => void;
8
9
  updateScrollHeight: (height: number) => void;
9
10
  };
10
11
  export default _default;
@@ -16,7 +16,11 @@ export declare class VisibleRender {
16
16
  private binding;
17
17
  private wrapper;
18
18
  private delay;
19
+ private delegateWrapper;
19
20
  constructor(binding: any, el: any);
21
+ get scrollHeight(): any;
22
+ get offsetHeight(): any;
23
+ setDelegateWrapper(el: any): void;
20
24
  render(e: any): void;
21
25
  executeThrottledRender(e: any): void;
22
26
  install(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkui-vue",
3
- "version": "2.0.1-beta.58",
3
+ "version": "2.0.1-beta.59",
4
4
  "workspaces": [
5
5
  "packages/**",
6
6
  "scripts/cli",