wave-ui 1.42.0 → 1.42.1
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/dist/wave-ui.cjs.js +1 -1
- package/dist/wave-ui.css +1 -1
- package/dist/wave-ui.es.js +16 -12
- package/dist/wave-ui.umd.js +1 -1
- package/package.json +1 -1
- package/src/wave-ui/components/w-table.vue +41 -16
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
th.w-table__header(
|
|
16
16
|
v-for="(header, i) in headers"
|
|
17
17
|
:key="i"
|
|
18
|
-
@click="header.sortable !== false && sortTable(header)"
|
|
18
|
+
@click="!colResizing.dragging && header.sortable !== false && sortTable(header)"
|
|
19
19
|
:class="headerClasses(header)")
|
|
20
20
|
w-icon.w-table__header-sort(
|
|
21
21
|
v-if="header.sortable !== false && header.align === 'right'"
|
|
@@ -122,6 +122,9 @@
|
|
|
122
122
|
|
|
123
123
|
import { consoleError } from '../utils/console'
|
|
124
124
|
|
|
125
|
+
// When column resizing is on, this is the minimum cell width that we can resize to.
|
|
126
|
+
const minColumnWidth = 15
|
|
127
|
+
|
|
125
128
|
export default {
|
|
126
129
|
name: 'w-table',
|
|
127
130
|
props: {
|
|
@@ -404,15 +407,17 @@ export default {
|
|
|
404
407
|
columnEl.style.width = colWidth + deltaX + 'px'
|
|
405
408
|
nextColumnEl.style.width = nextColWidth - deltaX + 'px'
|
|
406
409
|
|
|
407
|
-
// 2. Check if we went too far (the width
|
|
408
|
-
const minWidthReached = deltaX < 0 && columnEl.offsetWidth > newColWidth
|
|
410
|
+
// 2. Check if we went too far (the width applied is different than the browser-computed one).
|
|
411
|
+
const minWidthReached = (deltaX < 0 && columnEl.offsetWidth > newColWidth) ||
|
|
412
|
+
columnEl.offsetWidth <= minColumnWidth
|
|
409
413
|
const maxWidthReached = deltaX > 0 && nextColumnEl.offsetWidth > newNextColWidth
|
|
410
414
|
|
|
411
415
|
// 3. If we went too far, correct the value of both cells widths.
|
|
412
416
|
// Make sure we don't shrink enough to push other left cells.
|
|
413
417
|
if (minWidthReached) {
|
|
414
|
-
|
|
415
|
-
|
|
418
|
+
const newWidth = Math.max(columnEl.offsetWidth, minColumnWidth)
|
|
419
|
+
columnEl.style.width = newWidth + 'px'
|
|
420
|
+
nextColumnEl.style.width = maxWidth - newWidth + 'px'
|
|
416
421
|
}
|
|
417
422
|
// Make sure we don't grow enough to push other right cells.
|
|
418
423
|
else if (maxWidthReached) {
|
|
@@ -421,19 +426,24 @@ export default {
|
|
|
421
426
|
}
|
|
422
427
|
},
|
|
423
428
|
|
|
424
|
-
onResizerMouseUp (
|
|
429
|
+
onResizerMouseUp () {
|
|
425
430
|
// Remove listeners.
|
|
426
431
|
document.removeEventListener('mousemove', this.onResizerMouseMove)
|
|
427
432
|
document.removeEventListener('mouseup', this.onResizerMouseUp)
|
|
428
433
|
|
|
429
434
|
// Reset all the variables (better for debugging).
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
435
|
+
// setTimeout 0 to make sure the sorting is not applied when releasing the mouse on a header
|
|
436
|
+
// cell after resizing.
|
|
437
|
+
// (releasing the mouse on table header triggers a click event captured by the sorting feature)
|
|
438
|
+
setTimeout(() => {
|
|
439
|
+
this.colResizing.dragging = false
|
|
440
|
+
this.colResizing.columnIndex = null
|
|
441
|
+
this.colResizing.startCursorX = null
|
|
442
|
+
this.colResizing.columnEl = null
|
|
443
|
+
this.colResizing.nextColumnEl = null
|
|
444
|
+
this.colResizing.colWidth = null
|
|
445
|
+
this.colResizing.nextColWidth = null
|
|
446
|
+
}, 0)
|
|
437
447
|
}
|
|
438
448
|
},
|
|
439
449
|
|
|
@@ -490,6 +500,10 @@ $tr-border-top: 1px;
|
|
|
490
500
|
border-collapse: collapse;
|
|
491
501
|
border: none;
|
|
492
502
|
|
|
503
|
+
&--resizable-cols {
|
|
504
|
+
table-layout: fixed; // Allow resizing beyond the cell minimum text width.
|
|
505
|
+
}
|
|
506
|
+
|
|
493
507
|
&--resizing {
|
|
494
508
|
&, * {cursor: col-resize;}
|
|
495
509
|
|
|
@@ -498,8 +512,11 @@ $tr-border-top: 1px;
|
|
|
498
512
|
|
|
499
513
|
// Table headers.
|
|
500
514
|
// ------------------------------------------------------
|
|
501
|
-
&__header {
|
|
502
|
-
|
|
515
|
+
&__header {padding: $base-increment;}
|
|
516
|
+
&__header--resizable {
|
|
517
|
+
overflow: hidden;
|
|
518
|
+
white-space: nowrap;
|
|
519
|
+
text-overflow: ellipsis;
|
|
503
520
|
}
|
|
504
521
|
|
|
505
522
|
&--fixed-header th {
|
|
@@ -596,7 +613,15 @@ $tr-border-top: 1px;
|
|
|
596
613
|
&__header:first-child, &__cell:first-child {padding-left: 2 * $base-increment;}
|
|
597
614
|
&__header:last-child, &__cell:last-child {padding-right: 2 * $base-increment;}
|
|
598
615
|
|
|
599
|
-
&--resizable-cols &__cell {
|
|
616
|
+
&--resizable-cols &__cell {
|
|
617
|
+
position: relative;
|
|
618
|
+
|
|
619
|
+
&, & * {
|
|
620
|
+
overflow: hidden;
|
|
621
|
+
// white-space: nowrap; // If you only want the content cell on a single line.
|
|
622
|
+
text-overflow: ellipsis;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
600
625
|
|
|
601
626
|
.no-data &__cell {
|
|
602
627
|
background-color: rgba(255, 255, 255, 0.2);
|