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.
@@ -129,6 +129,174 @@ function handleMoveSelected($xeTable, evnt, args, isLeftArrow, isUpArrow, isRigh
129
129
  });
130
130
  return params;
131
131
  }
132
+ function handleCheckboxRangeEvent($xeTable, evnt, params) {
133
+ const internalData = $xeTable;
134
+ const { elemStore } = internalData;
135
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
136
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
137
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
138
+ const { column, cell } = params;
139
+ if (column.type === 'checkbox') {
140
+ let bodyWrapperElem = bodyScrollElem;
141
+ if (leftScrollElem && column.fixed === 'left') {
142
+ bodyWrapperElem = leftScrollElem;
143
+ }
144
+ else if (rightScrollElem && column.fixed === 'right') {
145
+ bodyWrapperElem = rightScrollElem;
146
+ }
147
+ if (!bodyWrapperElem) {
148
+ return;
149
+ }
150
+ const el = $xeTable.$refs.refElem;
151
+ const disX = evnt.clientX;
152
+ const disY = evnt.clientY;
153
+ const checkboxRangeElem = bodyWrapperElem.querySelector('.vxe-table--checkbox-range');
154
+ const trElem = cell.parentNode;
155
+ const selectRecords = $xeTable.getCheckboxRecords();
156
+ let lastRangeRows = [];
157
+ const marginSize = 1;
158
+ const offsetRest = getTargetOffset(evnt.target, bodyWrapperElem);
159
+ const startTop = offsetRest.offsetTop + evnt.offsetY;
160
+ const startLeft = offsetRest.offsetLeft + evnt.offsetX;
161
+ const startScrollTop = bodyWrapperElem.scrollTop;
162
+ const rowHeight = trElem.offsetHeight;
163
+ const trRect = trElem.getBoundingClientRect();
164
+ const offsetClientTop = disY - trRect.y;
165
+ let mouseScrollTimeout = null;
166
+ let isMouseScrollDown = false;
167
+ let mouseScrollSpaceSize = 1;
168
+ const triggerEvent = (type, evnt) => {
169
+ $xeTable.dispatchEvent(`checkbox-range-${type}`, {
170
+ records: () => $xeTable.getCheckboxRecords(),
171
+ reserves: () => $xeTable.getCheckboxReserveRecords()
172
+ }, evnt);
173
+ };
174
+ const handleChecked = (evnt) => {
175
+ const { clientX, clientY } = evnt;
176
+ const offsetLeft = clientX - disX;
177
+ const offsetTop = clientY - disY + (bodyWrapperElem.scrollTop - startScrollTop);
178
+ let rangeHeight = Math.abs(offsetTop);
179
+ let rangeWidth = Math.abs(offsetLeft);
180
+ let rangeTop = startTop;
181
+ let rangeLeft = startLeft;
182
+ if (offsetTop < marginSize) {
183
+ // 向上
184
+ rangeTop += offsetTop;
185
+ if (rangeTop < marginSize) {
186
+ rangeTop = marginSize;
187
+ rangeHeight = startTop;
188
+ }
189
+ }
190
+ else {
191
+ // 向下
192
+ rangeHeight = Math.min(rangeHeight, bodyWrapperElem.scrollHeight - startTop - marginSize);
193
+ }
194
+ if (offsetLeft < marginSize) {
195
+ // 向左
196
+ rangeLeft += offsetLeft;
197
+ if (rangeWidth > startLeft) {
198
+ rangeLeft = marginSize;
199
+ rangeWidth = startLeft;
200
+ }
201
+ }
202
+ else {
203
+ // 向右
204
+ rangeWidth = Math.min(rangeWidth, bodyWrapperElem.clientWidth - startLeft - marginSize);
205
+ }
206
+ checkboxRangeElem.style.height = `${rangeHeight}px`;
207
+ checkboxRangeElem.style.width = `${rangeWidth}px`;
208
+ checkboxRangeElem.style.left = `${rangeLeft}px`;
209
+ checkboxRangeElem.style.top = `${rangeTop}px`;
210
+ checkboxRangeElem.style.display = 'block';
211
+ const rangeRows = getCheckboxRangeRows($xeTable, evnt, params, trElem, trRect, offsetClientTop, offsetTop < marginSize ? -rangeHeight : rangeHeight);
212
+ // 至少滑动 10px 才能有效匹配
213
+ if (rangeHeight > 10 && rangeRows.length !== lastRangeRows.length) {
214
+ const isControlKey = hasControlKey(evnt);
215
+ lastRangeRows = rangeRows;
216
+ if (isControlKey) {
217
+ rangeRows.forEach((row) => {
218
+ $xeTable.handleBatchSelectRows([row], selectRecords.indexOf(row) === -1);
219
+ });
220
+ }
221
+ else {
222
+ $xeTable.setAllCheckboxRow(false);
223
+ $xeTable.handleCheckedCheckboxRow(rangeRows, true, false);
224
+ }
225
+ triggerEvent('change', evnt);
226
+ }
227
+ };
228
+ // 停止鼠标滚动
229
+ const stopMouseScroll = () => {
230
+ clearTimeout(mouseScrollTimeout);
231
+ mouseScrollTimeout = null;
232
+ };
233
+ // 开始鼠标滚动
234
+ const startMouseScroll = (evnt) => {
235
+ stopMouseScroll();
236
+ mouseScrollTimeout = setTimeout(() => {
237
+ if (mouseScrollTimeout) {
238
+ const { scrollLeft, scrollTop, clientHeight, scrollHeight } = bodyWrapperElem;
239
+ const topSize = Math.ceil(mouseScrollSpaceSize * 50 / rowHeight);
240
+ if (isMouseScrollDown) {
241
+ if (scrollTop + clientHeight < scrollHeight) {
242
+ $xeTable.scrollTo(scrollLeft, scrollTop + topSize);
243
+ startMouseScroll(evnt);
244
+ handleChecked(evnt);
245
+ }
246
+ else {
247
+ stopMouseScroll();
248
+ }
249
+ }
250
+ else {
251
+ if (scrollTop) {
252
+ $xeTable.scrollTo(scrollLeft, scrollTop - topSize);
253
+ startMouseScroll(evnt);
254
+ handleChecked(evnt);
255
+ }
256
+ else {
257
+ stopMouseScroll();
258
+ }
259
+ }
260
+ }
261
+ }, 50);
262
+ };
263
+ addClass(el, 'drag--range');
264
+ document.onmousemove = evnt => {
265
+ evnt.preventDefault();
266
+ evnt.stopPropagation();
267
+ const { clientY } = evnt;
268
+ const { boundingTop } = getAbsolutePos(bodyWrapperElem);
269
+ // 如果超过可视区,触发滚动
270
+ if (clientY < boundingTop) {
271
+ isMouseScrollDown = false;
272
+ mouseScrollSpaceSize = boundingTop - clientY;
273
+ if (!mouseScrollTimeout) {
274
+ startMouseScroll(evnt);
275
+ }
276
+ }
277
+ else if (clientY > boundingTop + bodyWrapperElem.clientHeight) {
278
+ isMouseScrollDown = true;
279
+ mouseScrollSpaceSize = clientY - boundingTop - bodyWrapperElem.clientHeight;
280
+ if (!mouseScrollTimeout) {
281
+ startMouseScroll(evnt);
282
+ }
283
+ }
284
+ else if (mouseScrollTimeout) {
285
+ stopMouseScroll();
286
+ }
287
+ handleChecked(evnt);
288
+ };
289
+ document.onmouseup = (evnt) => {
290
+ stopMouseScroll();
291
+ removeClass(el, 'drag--range');
292
+ checkboxRangeElem.removeAttribute('style');
293
+ document.onmousemove = null;
294
+ document.onmouseup = null;
295
+ triggerEvent('end', evnt);
296
+ };
297
+ triggerEvent('start', evnt);
298
+ }
299
+ }
132
300
  export default {
133
301
  methods: {
134
302
  // 处理 Tab 键移动
@@ -351,189 +519,24 @@ export default {
351
519
  },
352
520
  handleCellMousedownEvent(evnt, params) {
353
521
  const $xeTable = this;
354
- const { editConfig, editOpts, handleSelected, checkboxConfig, checkboxOpts, mouseConfig, mouseOpts } = this;
522
+ const props = $xeTable;
523
+ const { editConfig, checkboxConfig, mouseConfig } = props;
524
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
525
+ const mouseOpts = $xeTable.computeMouseOpts;
526
+ const editOpts = $xeTable.computeEditOpts;
355
527
  if (mouseConfig && mouseOpts.area && $xeTable.triggerCellAreaModnEvent) {
356
528
  return $xeTable.triggerCellAreaModnEvent(evnt, params);
357
529
  }
358
530
  else {
359
531
  if (checkboxConfig && checkboxOpts.range) {
360
- this.handleCheckboxRangeEvent(evnt, params);
532
+ handleCheckboxRangeEvent($xeTable, evnt, params);
361
533
  }
362
534
  if (mouseConfig && mouseOpts.selected) {
363
535
  if (!editConfig || editOpts.mode === 'cell') {
364
- handleSelected(params, evnt);
536
+ $xeTable.handleSelected(params, evnt);
365
537
  }
366
538
  }
367
539
  }
368
- },
369
- handleCheckboxRangeEvent(evnt, params) {
370
- const $xeTable = this;
371
- const internalData = $xeTable;
372
- const { elemStore } = internalData;
373
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
374
- const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
375
- const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
376
- const { column, cell } = params;
377
- if (column.type === 'checkbox') {
378
- let bodyWrapperElem = bodyScrollElem;
379
- if (leftScrollElem && column.fixed === 'left') {
380
- bodyWrapperElem = leftScrollElem;
381
- }
382
- else if (rightScrollElem && column.fixed === 'right') {
383
- bodyWrapperElem = rightScrollElem;
384
- }
385
- if (!bodyWrapperElem) {
386
- return;
387
- }
388
- const el = $xeTable.$refs.refElem;
389
- const disX = evnt.clientX;
390
- const disY = evnt.clientY;
391
- const checkboxRangeElem = bodyWrapperElem.querySelector('.vxe-table--checkbox-range');
392
- const trElem = cell.parentNode;
393
- const selectRecords = this.getCheckboxRecords();
394
- let lastRangeRows = [];
395
- const marginSize = 1;
396
- const offsetRest = getTargetOffset(evnt.target, bodyWrapperElem);
397
- const startTop = offsetRest.offsetTop + evnt.offsetY;
398
- const startLeft = offsetRest.offsetLeft + evnt.offsetX;
399
- const startScrollTop = bodyWrapperElem.scrollTop;
400
- const rowHeight = trElem.offsetHeight;
401
- const trRect = trElem.getBoundingClientRect();
402
- const offsetClientTop = disY - trRect.y;
403
- let mouseScrollTimeout = null;
404
- let isMouseScrollDown = false;
405
- let mouseScrollSpaceSize = 1;
406
- const triggerEvent = (type, evnt) => {
407
- this.emitEvent(`checkbox-range-${type}`, {
408
- records: () => this.getCheckboxRecords(),
409
- reserves: () => this.getCheckboxReserveRecords()
410
- }, evnt);
411
- };
412
- const handleChecked = (evnt) => {
413
- const { clientX, clientY } = evnt;
414
- const offsetLeft = clientX - disX;
415
- const offsetTop = clientY - disY + (bodyWrapperElem.scrollTop - startScrollTop);
416
- let rangeHeight = Math.abs(offsetTop);
417
- let rangeWidth = Math.abs(offsetLeft);
418
- let rangeTop = startTop;
419
- let rangeLeft = startLeft;
420
- if (offsetTop < marginSize) {
421
- // 向上
422
- rangeTop += offsetTop;
423
- if (rangeTop < marginSize) {
424
- rangeTop = marginSize;
425
- rangeHeight = startTop;
426
- }
427
- }
428
- else {
429
- // 向下
430
- rangeHeight = Math.min(rangeHeight, bodyWrapperElem.scrollHeight - startTop - marginSize);
431
- }
432
- if (offsetLeft < marginSize) {
433
- // 向左
434
- rangeLeft += offsetLeft;
435
- if (rangeWidth > startLeft) {
436
- rangeLeft = marginSize;
437
- rangeWidth = startLeft;
438
- }
439
- }
440
- else {
441
- // 向右
442
- rangeWidth = Math.min(rangeWidth, bodyWrapperElem.clientWidth - startLeft - marginSize);
443
- }
444
- checkboxRangeElem.style.height = `${rangeHeight}px`;
445
- checkboxRangeElem.style.width = `${rangeWidth}px`;
446
- checkboxRangeElem.style.left = `${rangeLeft}px`;
447
- checkboxRangeElem.style.top = `${rangeTop}px`;
448
- checkboxRangeElem.style.display = 'block';
449
- const rangeRows = getCheckboxRangeRows(this, evnt, params, trElem, trRect, offsetClientTop, offsetTop < marginSize ? -rangeHeight : rangeHeight);
450
- // 至少滑动 10px 才能有效匹配
451
- if (rangeHeight > 10 && rangeRows.length !== lastRangeRows.length) {
452
- const isControlKey = hasControlKey(evnt);
453
- lastRangeRows = rangeRows;
454
- if (isControlKey) {
455
- rangeRows.forEach((row) => {
456
- $xeTable.handleBatchSelectRows([row], selectRecords.indexOf(row) === -1);
457
- });
458
- }
459
- else {
460
- this.setAllCheckboxRow(false);
461
- this.handleCheckedCheckboxRow(rangeRows, true, false);
462
- }
463
- triggerEvent('change', evnt);
464
- }
465
- };
466
- // 停止鼠标滚动
467
- const stopMouseScroll = () => {
468
- clearTimeout(mouseScrollTimeout);
469
- mouseScrollTimeout = null;
470
- };
471
- // 开始鼠标滚动
472
- const startMouseScroll = (evnt) => {
473
- stopMouseScroll();
474
- mouseScrollTimeout = setTimeout(() => {
475
- if (mouseScrollTimeout) {
476
- const { scrollLeft, scrollTop, clientHeight, scrollHeight } = bodyWrapperElem;
477
- const topSize = Math.ceil(mouseScrollSpaceSize * 50 / rowHeight);
478
- if (isMouseScrollDown) {
479
- if (scrollTop + clientHeight < scrollHeight) {
480
- this.scrollTo(scrollLeft, scrollTop + topSize);
481
- startMouseScroll(evnt);
482
- handleChecked(evnt);
483
- }
484
- else {
485
- stopMouseScroll();
486
- }
487
- }
488
- else {
489
- if (scrollTop) {
490
- this.scrollTo(scrollLeft, scrollTop - topSize);
491
- startMouseScroll(evnt);
492
- handleChecked(evnt);
493
- }
494
- else {
495
- stopMouseScroll();
496
- }
497
- }
498
- }
499
- }, 50);
500
- };
501
- addClass(el, 'drag--range');
502
- document.onmousemove = evnt => {
503
- evnt.preventDefault();
504
- evnt.stopPropagation();
505
- const { clientY } = evnt;
506
- const { boundingTop } = getAbsolutePos(bodyWrapperElem);
507
- // 如果超过可视区,触发滚动
508
- if (clientY < boundingTop) {
509
- isMouseScrollDown = false;
510
- mouseScrollSpaceSize = boundingTop - clientY;
511
- if (!mouseScrollTimeout) {
512
- startMouseScroll(evnt);
513
- }
514
- }
515
- else if (clientY > boundingTop + bodyWrapperElem.clientHeight) {
516
- isMouseScrollDown = true;
517
- mouseScrollSpaceSize = clientY - boundingTop - bodyWrapperElem.clientHeight;
518
- if (!mouseScrollTimeout) {
519
- startMouseScroll(evnt);
520
- }
521
- }
522
- else if (mouseScrollTimeout) {
523
- stopMouseScroll();
524
- }
525
- handleChecked(evnt);
526
- };
527
- document.onmouseup = (evnt) => {
528
- stopMouseScroll();
529
- removeClass(el, 'drag--range');
530
- checkboxRangeElem.removeAttribute('style');
531
- document.onmousemove = null;
532
- document.onmouseup = null;
533
- triggerEvent('end', evnt);
534
- };
535
- triggerEvent('start', evnt);
536
- }
537
540
  }
538
541
  }
539
542
  };
@@ -1776,6 +1776,15 @@ export default {
1776
1776
  this.preventEvent(null, 'activated');
1777
1777
  },
1778
1778
  deactivated() {
1779
+ const $xeTable = this;
1780
+ const reactData = $xeTable;
1781
+ const internalData = $xeTable;
1782
+ const { filterStore } = reactData;
1783
+ if (filterStore.visible) {
1784
+ $xeTable.clearFilter();
1785
+ }
1786
+ $xeTable.closeTooltip();
1787
+ internalData.isActivated = false;
1779
1788
  this.preventEvent(null, 'deactivated');
1780
1789
  },
1781
1790
  beforeDestroy() {
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "3.18.0-beta.8";
3
+ export const version = "3.18.0";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"3.18.0-beta.8"}`;
3
+ const version = `table v${"3.18.0"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);