vxe-table 3.18.0-beta.8 → 3.18.0

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/index.umd.js CHANGED
@@ -2002,7 +2002,7 @@ function getClass(property, params) {
2002
2002
  ;// CONCATENATED MODULE: ./packages/ui/index.ts
2003
2003
 
2004
2004
 
2005
- const version = "3.18.0-beta.8";
2005
+ const version = "3.18.0";
2006
2006
  core_.VxeUI.version = version;
2007
2007
  core_.VxeUI.tableVersion = version;
2008
2008
  core_.VxeUI.setConfig({
@@ -2678,7 +2678,7 @@ function isNodeElement(elem) {
2678
2678
  const {
2679
2679
  log: log_log
2680
2680
  } = core_.VxeUI;
2681
- const log_version = `table v${"3.18.0-beta.8"}`;
2681
+ const log_version = `table v${"3.18.0"}`;
2682
2682
  const warnLog = log_log.create('warn', log_version);
2683
2683
  const errLog = log_log.create('error', log_version);
2684
2684
  ;// CONCATENATED MODULE: ./packages/table/src/columnInfo.ts
@@ -27122,6 +27122,182 @@ function handleMoveSelected($xeTable, evnt, args, isLeftArrow, isUpArrow, isRigh
27122
27122
  });
27123
27123
  return params;
27124
27124
  }
27125
+ function handleCheckboxRangeEvent($xeTable, evnt, params) {
27126
+ const internalData = $xeTable;
27127
+ const {
27128
+ elemStore
27129
+ } = internalData;
27130
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
27131
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
27132
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
27133
+ const {
27134
+ column,
27135
+ cell
27136
+ } = params;
27137
+ if (column.type === 'checkbox') {
27138
+ let bodyWrapperElem = bodyScrollElem;
27139
+ if (leftScrollElem && column.fixed === 'left') {
27140
+ bodyWrapperElem = leftScrollElem;
27141
+ } else if (rightScrollElem && column.fixed === 'right') {
27142
+ bodyWrapperElem = rightScrollElem;
27143
+ }
27144
+ if (!bodyWrapperElem) {
27145
+ return;
27146
+ }
27147
+ const el = $xeTable.$refs.refElem;
27148
+ const disX = evnt.clientX;
27149
+ const disY = evnt.clientY;
27150
+ const checkboxRangeElem = bodyWrapperElem.querySelector('.vxe-table--checkbox-range');
27151
+ const trElem = cell.parentNode;
27152
+ const selectRecords = $xeTable.getCheckboxRecords();
27153
+ let lastRangeRows = [];
27154
+ const marginSize = 1;
27155
+ const offsetRest = getTargetOffset(evnt.target, bodyWrapperElem);
27156
+ const startTop = offsetRest.offsetTop + evnt.offsetY;
27157
+ const startLeft = offsetRest.offsetLeft + evnt.offsetX;
27158
+ const startScrollTop = bodyWrapperElem.scrollTop;
27159
+ const rowHeight = trElem.offsetHeight;
27160
+ const trRect = trElem.getBoundingClientRect();
27161
+ const offsetClientTop = disY - trRect.y;
27162
+ let mouseScrollTimeout = null;
27163
+ let isMouseScrollDown = false;
27164
+ let mouseScrollSpaceSize = 1;
27165
+ const triggerEvent = (type, evnt) => {
27166
+ $xeTable.dispatchEvent(`checkbox-range-${type}`, {
27167
+ records: () => $xeTable.getCheckboxRecords(),
27168
+ reserves: () => $xeTable.getCheckboxReserveRecords()
27169
+ }, evnt);
27170
+ };
27171
+ const handleChecked = evnt => {
27172
+ const {
27173
+ clientX,
27174
+ clientY
27175
+ } = evnt;
27176
+ const offsetLeft = clientX - disX;
27177
+ const offsetTop = clientY - disY + (bodyWrapperElem.scrollTop - startScrollTop);
27178
+ let rangeHeight = Math.abs(offsetTop);
27179
+ let rangeWidth = Math.abs(offsetLeft);
27180
+ let rangeTop = startTop;
27181
+ let rangeLeft = startLeft;
27182
+ if (offsetTop < marginSize) {
27183
+ // 向上
27184
+ rangeTop += offsetTop;
27185
+ if (rangeTop < marginSize) {
27186
+ rangeTop = marginSize;
27187
+ rangeHeight = startTop;
27188
+ }
27189
+ } else {
27190
+ // 向下
27191
+ rangeHeight = Math.min(rangeHeight, bodyWrapperElem.scrollHeight - startTop - marginSize);
27192
+ }
27193
+ if (offsetLeft < marginSize) {
27194
+ // 向左
27195
+ rangeLeft += offsetLeft;
27196
+ if (rangeWidth > startLeft) {
27197
+ rangeLeft = marginSize;
27198
+ rangeWidth = startLeft;
27199
+ }
27200
+ } else {
27201
+ // 向右
27202
+ rangeWidth = Math.min(rangeWidth, bodyWrapperElem.clientWidth - startLeft - marginSize);
27203
+ }
27204
+ checkboxRangeElem.style.height = `${rangeHeight}px`;
27205
+ checkboxRangeElem.style.width = `${rangeWidth}px`;
27206
+ checkboxRangeElem.style.left = `${rangeLeft}px`;
27207
+ checkboxRangeElem.style.top = `${rangeTop}px`;
27208
+ checkboxRangeElem.style.display = 'block';
27209
+ const rangeRows = getCheckboxRangeRows($xeTable, evnt, params, trElem, trRect, offsetClientTop, offsetTop < marginSize ? -rangeHeight : rangeHeight);
27210
+ // 至少滑动 10px 才能有效匹配
27211
+ if (rangeHeight > 10 && rangeRows.length !== lastRangeRows.length) {
27212
+ const isControlKey = hasControlKey(evnt);
27213
+ lastRangeRows = rangeRows;
27214
+ if (isControlKey) {
27215
+ rangeRows.forEach(row => {
27216
+ $xeTable.handleBatchSelectRows([row], selectRecords.indexOf(row) === -1);
27217
+ });
27218
+ } else {
27219
+ $xeTable.setAllCheckboxRow(false);
27220
+ $xeTable.handleCheckedCheckboxRow(rangeRows, true, false);
27221
+ }
27222
+ triggerEvent('change', evnt);
27223
+ }
27224
+ };
27225
+ // 停止鼠标滚动
27226
+ const stopMouseScroll = () => {
27227
+ clearTimeout(mouseScrollTimeout);
27228
+ mouseScrollTimeout = null;
27229
+ };
27230
+ // 开始鼠标滚动
27231
+ const startMouseScroll = evnt => {
27232
+ stopMouseScroll();
27233
+ mouseScrollTimeout = setTimeout(() => {
27234
+ if (mouseScrollTimeout) {
27235
+ const {
27236
+ scrollLeft,
27237
+ scrollTop,
27238
+ clientHeight,
27239
+ scrollHeight
27240
+ } = bodyWrapperElem;
27241
+ const topSize = Math.ceil(mouseScrollSpaceSize * 50 / rowHeight);
27242
+ if (isMouseScrollDown) {
27243
+ if (scrollTop + clientHeight < scrollHeight) {
27244
+ $xeTable.scrollTo(scrollLeft, scrollTop + topSize);
27245
+ startMouseScroll(evnt);
27246
+ handleChecked(evnt);
27247
+ } else {
27248
+ stopMouseScroll();
27249
+ }
27250
+ } else {
27251
+ if (scrollTop) {
27252
+ $xeTable.scrollTo(scrollLeft, scrollTop - topSize);
27253
+ startMouseScroll(evnt);
27254
+ handleChecked(evnt);
27255
+ } else {
27256
+ stopMouseScroll();
27257
+ }
27258
+ }
27259
+ }
27260
+ }, 50);
27261
+ };
27262
+ addClass(el, 'drag--range');
27263
+ document.onmousemove = evnt => {
27264
+ evnt.preventDefault();
27265
+ evnt.stopPropagation();
27266
+ const {
27267
+ clientY
27268
+ } = evnt;
27269
+ const {
27270
+ boundingTop
27271
+ } = getAbsolutePos(bodyWrapperElem);
27272
+ // 如果超过可视区,触发滚动
27273
+ if (clientY < boundingTop) {
27274
+ isMouseScrollDown = false;
27275
+ mouseScrollSpaceSize = boundingTop - clientY;
27276
+ if (!mouseScrollTimeout) {
27277
+ startMouseScroll(evnt);
27278
+ }
27279
+ } else if (clientY > boundingTop + bodyWrapperElem.clientHeight) {
27280
+ isMouseScrollDown = true;
27281
+ mouseScrollSpaceSize = clientY - boundingTop - bodyWrapperElem.clientHeight;
27282
+ if (!mouseScrollTimeout) {
27283
+ startMouseScroll(evnt);
27284
+ }
27285
+ } else if (mouseScrollTimeout) {
27286
+ stopMouseScroll();
27287
+ }
27288
+ handleChecked(evnt);
27289
+ };
27290
+ document.onmouseup = evnt => {
27291
+ stopMouseScroll();
27292
+ removeClass(el, 'drag--range');
27293
+ checkboxRangeElem.removeAttribute('style');
27294
+ document.onmousemove = null;
27295
+ document.onmouseup = null;
27296
+ triggerEvent('end', evnt);
27297
+ };
27298
+ triggerEvent('start', evnt);
27299
+ }
27300
+ }
27125
27301
  /* harmony default export */ var keyboard_mixin = ({
27126
27302
  methods: {
27127
27303
  // 处理 Tab 键移动
@@ -27352,204 +27528,27 @@ function handleMoveSelected($xeTable, evnt, args, isLeftArrow, isUpArrow, isRigh
27352
27528
  },
27353
27529
  handleCellMousedownEvent(evnt, params) {
27354
27530
  const $xeTable = this;
27531
+ const props = $xeTable;
27355
27532
  const {
27356
27533
  editConfig,
27357
- editOpts,
27358
- handleSelected,
27359
27534
  checkboxConfig,
27360
- checkboxOpts,
27361
- mouseConfig,
27362
- mouseOpts
27363
- } = this;
27535
+ mouseConfig
27536
+ } = props;
27537
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
27538
+ const mouseOpts = $xeTable.computeMouseOpts;
27539
+ const editOpts = $xeTable.computeEditOpts;
27364
27540
  if (mouseConfig && mouseOpts.area && $xeTable.triggerCellAreaModnEvent) {
27365
27541
  return $xeTable.triggerCellAreaModnEvent(evnt, params);
27366
27542
  } else {
27367
27543
  if (checkboxConfig && checkboxOpts.range) {
27368
- this.handleCheckboxRangeEvent(evnt, params);
27544
+ handleCheckboxRangeEvent($xeTable, evnt, params);
27369
27545
  }
27370
27546
  if (mouseConfig && mouseOpts.selected) {
27371
27547
  if (!editConfig || editOpts.mode === 'cell') {
27372
- handleSelected(params, evnt);
27548
+ $xeTable.handleSelected(params, evnt);
27373
27549
  }
27374
27550
  }
27375
27551
  }
27376
- },
27377
- handleCheckboxRangeEvent(evnt, params) {
27378
- const $xeTable = this;
27379
- const internalData = $xeTable;
27380
- const {
27381
- elemStore
27382
- } = internalData;
27383
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
27384
- const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
27385
- const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
27386
- const {
27387
- column,
27388
- cell
27389
- } = params;
27390
- if (column.type === 'checkbox') {
27391
- let bodyWrapperElem = bodyScrollElem;
27392
- if (leftScrollElem && column.fixed === 'left') {
27393
- bodyWrapperElem = leftScrollElem;
27394
- } else if (rightScrollElem && column.fixed === 'right') {
27395
- bodyWrapperElem = rightScrollElem;
27396
- }
27397
- if (!bodyWrapperElem) {
27398
- return;
27399
- }
27400
- const el = $xeTable.$refs.refElem;
27401
- const disX = evnt.clientX;
27402
- const disY = evnt.clientY;
27403
- const checkboxRangeElem = bodyWrapperElem.querySelector('.vxe-table--checkbox-range');
27404
- const trElem = cell.parentNode;
27405
- const selectRecords = this.getCheckboxRecords();
27406
- let lastRangeRows = [];
27407
- const marginSize = 1;
27408
- const offsetRest = getTargetOffset(evnt.target, bodyWrapperElem);
27409
- const startTop = offsetRest.offsetTop + evnt.offsetY;
27410
- const startLeft = offsetRest.offsetLeft + evnt.offsetX;
27411
- const startScrollTop = bodyWrapperElem.scrollTop;
27412
- const rowHeight = trElem.offsetHeight;
27413
- const trRect = trElem.getBoundingClientRect();
27414
- const offsetClientTop = disY - trRect.y;
27415
- let mouseScrollTimeout = null;
27416
- let isMouseScrollDown = false;
27417
- let mouseScrollSpaceSize = 1;
27418
- const triggerEvent = (type, evnt) => {
27419
- this.emitEvent(`checkbox-range-${type}`, {
27420
- records: () => this.getCheckboxRecords(),
27421
- reserves: () => this.getCheckboxReserveRecords()
27422
- }, evnt);
27423
- };
27424
- const handleChecked = evnt => {
27425
- const {
27426
- clientX,
27427
- clientY
27428
- } = evnt;
27429
- const offsetLeft = clientX - disX;
27430
- const offsetTop = clientY - disY + (bodyWrapperElem.scrollTop - startScrollTop);
27431
- let rangeHeight = Math.abs(offsetTop);
27432
- let rangeWidth = Math.abs(offsetLeft);
27433
- let rangeTop = startTop;
27434
- let rangeLeft = startLeft;
27435
- if (offsetTop < marginSize) {
27436
- // 向上
27437
- rangeTop += offsetTop;
27438
- if (rangeTop < marginSize) {
27439
- rangeTop = marginSize;
27440
- rangeHeight = startTop;
27441
- }
27442
- } else {
27443
- // 向下
27444
- rangeHeight = Math.min(rangeHeight, bodyWrapperElem.scrollHeight - startTop - marginSize);
27445
- }
27446
- if (offsetLeft < marginSize) {
27447
- // 向左
27448
- rangeLeft += offsetLeft;
27449
- if (rangeWidth > startLeft) {
27450
- rangeLeft = marginSize;
27451
- rangeWidth = startLeft;
27452
- }
27453
- } else {
27454
- // 向右
27455
- rangeWidth = Math.min(rangeWidth, bodyWrapperElem.clientWidth - startLeft - marginSize);
27456
- }
27457
- checkboxRangeElem.style.height = `${rangeHeight}px`;
27458
- checkboxRangeElem.style.width = `${rangeWidth}px`;
27459
- checkboxRangeElem.style.left = `${rangeLeft}px`;
27460
- checkboxRangeElem.style.top = `${rangeTop}px`;
27461
- checkboxRangeElem.style.display = 'block';
27462
- const rangeRows = getCheckboxRangeRows(this, evnt, params, trElem, trRect, offsetClientTop, offsetTop < marginSize ? -rangeHeight : rangeHeight);
27463
- // 至少滑动 10px 才能有效匹配
27464
- if (rangeHeight > 10 && rangeRows.length !== lastRangeRows.length) {
27465
- const isControlKey = hasControlKey(evnt);
27466
- lastRangeRows = rangeRows;
27467
- if (isControlKey) {
27468
- rangeRows.forEach(row => {
27469
- $xeTable.handleBatchSelectRows([row], selectRecords.indexOf(row) === -1);
27470
- });
27471
- } else {
27472
- this.setAllCheckboxRow(false);
27473
- this.handleCheckedCheckboxRow(rangeRows, true, false);
27474
- }
27475
- triggerEvent('change', evnt);
27476
- }
27477
- };
27478
- // 停止鼠标滚动
27479
- const stopMouseScroll = () => {
27480
- clearTimeout(mouseScrollTimeout);
27481
- mouseScrollTimeout = null;
27482
- };
27483
- // 开始鼠标滚动
27484
- const startMouseScroll = evnt => {
27485
- stopMouseScroll();
27486
- mouseScrollTimeout = setTimeout(() => {
27487
- if (mouseScrollTimeout) {
27488
- const {
27489
- scrollLeft,
27490
- scrollTop,
27491
- clientHeight,
27492
- scrollHeight
27493
- } = bodyWrapperElem;
27494
- const topSize = Math.ceil(mouseScrollSpaceSize * 50 / rowHeight);
27495
- if (isMouseScrollDown) {
27496
- if (scrollTop + clientHeight < scrollHeight) {
27497
- this.scrollTo(scrollLeft, scrollTop + topSize);
27498
- startMouseScroll(evnt);
27499
- handleChecked(evnt);
27500
- } else {
27501
- stopMouseScroll();
27502
- }
27503
- } else {
27504
- if (scrollTop) {
27505
- this.scrollTo(scrollLeft, scrollTop - topSize);
27506
- startMouseScroll(evnt);
27507
- handleChecked(evnt);
27508
- } else {
27509
- stopMouseScroll();
27510
- }
27511
- }
27512
- }
27513
- }, 50);
27514
- };
27515
- addClass(el, 'drag--range');
27516
- document.onmousemove = evnt => {
27517
- evnt.preventDefault();
27518
- evnt.stopPropagation();
27519
- const {
27520
- clientY
27521
- } = evnt;
27522
- const {
27523
- boundingTop
27524
- } = getAbsolutePos(bodyWrapperElem);
27525
- // 如果超过可视区,触发滚动
27526
- if (clientY < boundingTop) {
27527
- isMouseScrollDown = false;
27528
- mouseScrollSpaceSize = boundingTop - clientY;
27529
- if (!mouseScrollTimeout) {
27530
- startMouseScroll(evnt);
27531
- }
27532
- } else if (clientY > boundingTop + bodyWrapperElem.clientHeight) {
27533
- isMouseScrollDown = true;
27534
- mouseScrollSpaceSize = clientY - boundingTop - bodyWrapperElem.clientHeight;
27535
- if (!mouseScrollTimeout) {
27536
- startMouseScroll(evnt);
27537
- }
27538
- } else if (mouseScrollTimeout) {
27539
- stopMouseScroll();
27540
- }
27541
- handleChecked(evnt);
27542
- };
27543
- document.onmouseup = evnt => {
27544
- stopMouseScroll();
27545
- removeClass(el, 'drag--range');
27546
- checkboxRangeElem.removeAttribute('style');
27547
- document.onmousemove = null;
27548
- document.onmouseup = null;
27549
- triggerEvent('end', evnt);
27550
- };
27551
- triggerEvent('start', evnt);
27552
- }
27553
27552
  }
27554
27553
  }
27555
27554
  });
@@ -30552,6 +30551,17 @@ function renderBody(h, $xeTable) {
30552
30551
  this.preventEvent(null, 'activated');
30553
30552
  },
30554
30553
  deactivated() {
30554
+ const $xeTable = this;
30555
+ const reactData = $xeTable;
30556
+ const internalData = $xeTable;
30557
+ const {
30558
+ filterStore
30559
+ } = reactData;
30560
+ if (filterStore.visible) {
30561
+ $xeTable.clearFilter();
30562
+ }
30563
+ $xeTable.closeTooltip();
30564
+ internalData.isActivated = false;
30555
30565
  this.preventEvent(null, 'deactivated');
30556
30566
  },
30557
30567
  beforeDestroy() {