@danielgindi/dgtable.js 2.0.10 → 2.0.11
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/lib.cjs.js +65 -56
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +65 -56
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +65 -56
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/dist/private_types.d.ts +8 -6
- package/dist/private_types.d.ts.map +1 -1
- package/dist/rendering.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/private_types.ts +7 -6
- package/src/rendering.ts +62 -55
package/dist/lib.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/dgtable.js 2.0.
|
|
2
|
+
* @danielgindi/dgtable.js 2.0.11
|
|
3
3
|
* git://github.com/danielgindi/dgtable.js.git
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -7096,11 +7096,11 @@ function setupVirtualTable(table) {var _p$filteredRows;
|
|
|
7096
7096
|
if (column.stickyPos) {
|
|
7097
7097
|
cell.className += ' ' + stickyClassName;
|
|
7098
7098
|
cell.style.position = 'sticky';
|
|
7099
|
-
cell.style[column.stickyPos.
|
|
7099
|
+
cell.style[column.stickyPos.absDirection] = column.stickyPos.offset + 'px';
|
|
7100
7100
|
const isStickySide = isStickyColumns === null || isStickyColumns === void 0 ? void 0 : isStickyColumns.get(colIndex);
|
|
7101
|
-
if (isStickySide === '
|
|
7101
|
+
if (isStickySide === 'start' && !p.lastIsRtl || isStickySide === 'end' && p.lastIsRtl)
|
|
7102
7102
|
cell.classList.add('is-sticky-left');else
|
|
7103
|
-
if (isStickySide === '
|
|
7103
|
+
if (isStickySide === 'start' && p.lastIsRtl || isStickySide === 'end' && !p.lastIsRtl)
|
|
7104
7104
|
cell.classList.add('is-sticky-right');
|
|
7105
7105
|
}
|
|
7106
7106
|
if (allowCellPreview) {
|
|
@@ -7408,14 +7408,15 @@ function updateStickyColumnPositions(table) {var _p$scrollbarWidth;
|
|
|
7408
7408
|
const stickyClassName = tableClassName + '-sticky';
|
|
7409
7409
|
const headerRow = p.headerRow;
|
|
7410
7410
|
const rtl = isTableRtl(table);
|
|
7411
|
+
p.lastIsRtl = rtl;
|
|
7411
7412
|
const scrollbarWidth = (_p$scrollbarWidth = p.scrollbarWidth) !== null && _p$scrollbarWidth !== void 0 ? _p$scrollbarWidth : 0;
|
|
7412
7413
|
let stickColLeft = 0;
|
|
7413
7414
|
let stickColRight = 0;
|
|
7414
7415
|
let boxSizing = null;
|
|
7415
|
-
const
|
|
7416
|
-
const
|
|
7417
|
-
let
|
|
7418
|
-
let
|
|
7416
|
+
const stickiesStart = [];
|
|
7417
|
+
const stickiesEnd = [];
|
|
7418
|
+
let stickyStartGroup = null;
|
|
7419
|
+
let stickyEndGroup = [];
|
|
7419
7420
|
for (let currentCellEl = headerRow.firstElementChild; currentCellEl; currentCellEl = currentCellEl.nextElementSibling) {
|
|
7420
7421
|
const columnName = currentCellEl.getAttribute('data-column');
|
|
7421
7422
|
if (!columnName)
|
|
@@ -7440,27 +7441,27 @@ function updateStickyColumnPositions(table) {var _p$scrollbarWidth;
|
|
|
7440
7441
|
parseFloat(computedStyle.borderLeftWidth) || 0) + (
|
|
7441
7442
|
parseFloat(computedStyle.borderRightWidth) || 0);
|
|
7442
7443
|
}
|
|
7443
|
-
const
|
|
7444
|
-
if (
|
|
7445
|
-
column.stickyPos = { direction: 'left', offset: stickColLeft };
|
|
7446
|
-
currentCellEl.style.
|
|
7444
|
+
const isStart = column.sticky === 'start';
|
|
7445
|
+
if (isStart) {
|
|
7446
|
+
const stickyPos = column.stickyPos = { direction: 'start', absDirection: rtl ? 'right' : 'left', offset: stickColLeft };
|
|
7447
|
+
currentCellEl.style[stickyPos.absDirection] = stickColLeft + 'px';
|
|
7447
7448
|
stickColLeft += colFullWidth;
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7449
|
+
stickyEndGroup.length = 0;
|
|
7450
|
+
stickyStartGroup = [currentCellEl];
|
|
7451
|
+
stickiesStart.push(stickyStartGroup);
|
|
7451
7452
|
} else
|
|
7452
7453
|
{
|
|
7453
|
-
column.stickyPos = { direction: 'right', offset: stickColRight };
|
|
7454
|
-
currentCellEl.style.
|
|
7454
|
+
const stickyPos = column.stickyPos = { direction: 'end', absDirection: rtl ? 'left' : 'right', offset: stickColRight };
|
|
7455
|
+
currentCellEl.style[stickyPos.absDirection] = stickColRight + scrollbarWidth + 'px';
|
|
7455
7456
|
stickColRight += colFullWidth;
|
|
7456
|
-
|
|
7457
|
-
|
|
7457
|
+
stickiesEnd.push([currentCellEl, ...stickyEndGroup]);
|
|
7458
|
+
stickyEndGroup.length = 0;
|
|
7458
7459
|
}
|
|
7459
7460
|
} else
|
|
7460
|
-
{var
|
|
7461
|
+
{var _stickyStartGroup;
|
|
7461
7462
|
delete column.stickyPos;
|
|
7462
|
-
(
|
|
7463
|
-
|
|
7463
|
+
(_stickyStartGroup = stickyStartGroup) === null || _stickyStartGroup === void 0 || _stickyStartGroup.push(currentCellEl);
|
|
7464
|
+
stickyEndGroup === null || stickyEndGroup === void 0 || stickyEndGroup.push(currentCellEl);
|
|
7464
7465
|
if (currentCellEl.style.position === 'sticky') {
|
|
7465
7466
|
currentCellEl.classList.remove(stickyClassName);
|
|
7466
7467
|
currentCellEl.style.position = '';
|
|
@@ -7469,8 +7470,8 @@ function updateStickyColumnPositions(table) {var _p$scrollbarWidth;
|
|
|
7469
7470
|
}
|
|
7470
7471
|
}
|
|
7471
7472
|
}
|
|
7472
|
-
p.
|
|
7473
|
-
p.
|
|
7473
|
+
p.stickiesStart = stickiesStart;
|
|
7474
|
+
p.stickiesEnd = stickiesEnd;
|
|
7474
7475
|
syncHorizontalStickies(table);
|
|
7475
7476
|
}
|
|
7476
7477
|
/**
|
|
@@ -7480,20 +7481,21 @@ function syncHorizontalStickies(table) {
|
|
|
7480
7481
|
const p = table._p;
|
|
7481
7482
|
if (!p.table || !p.headerRow || !p.tbody)
|
|
7482
7483
|
return;
|
|
7483
|
-
const
|
|
7484
|
-
const
|
|
7485
|
-
const
|
|
7486
|
-
const
|
|
7487
|
-
const
|
|
7488
|
-
const
|
|
7489
|
-
if (
|
|
7484
|
+
const stickiesStart = p.stickiesStart;
|
|
7485
|
+
const stickiesEnd = p.stickiesEnd;
|
|
7486
|
+
const oldStickiesSetStart = p.stickiesSetStart;
|
|
7487
|
+
const oldStickiesSetEnd = p.stickiesSetEnd;
|
|
7488
|
+
const stickiesSetStart = p.stickiesSetStart = new Set();
|
|
7489
|
+
const stickiesSetEnd = p.stickiesSetEnd = new Set();
|
|
7490
|
+
if (stickiesStart !== null && stickiesStart !== void 0 && stickiesStart.length || stickiesEnd !== null && stickiesEnd !== void 0 && stickiesEnd.length) {
|
|
7490
7491
|
const scrollLeft = p.table.scrollLeft;
|
|
7491
7492
|
if (scrollLeft === p.lastStickyScrollLeft)
|
|
7492
7493
|
return;
|
|
7493
7494
|
p.lastStickyScrollLeft = scrollLeft;
|
|
7494
7495
|
const allHeaderCells = p.headerRow.children;
|
|
7495
7496
|
const tolerance = 1.5;
|
|
7496
|
-
const
|
|
7497
|
+
const isRtl = p.lastIsRtl;
|
|
7498
|
+
const processStickies = (stickies, isStart, indicesSet) => {
|
|
7497
7499
|
if (!stickies || !stickies.length)
|
|
7498
7500
|
return;
|
|
7499
7501
|
for (const sticky of stickies) {
|
|
@@ -7504,14 +7506,21 @@ function syncHorizontalStickies(table) {
|
|
|
7504
7506
|
if (!el || !el.getBoundingClientRect)
|
|
7505
7507
|
continue;
|
|
7506
7508
|
const sRect = el.getBoundingClientRect();
|
|
7509
|
+
const isLeft = isStart !== isRtl;
|
|
7507
7510
|
let overlapsFollowing = false;
|
|
7508
7511
|
if (first && last) {
|
|
7509
7512
|
const fRect = first.getBoundingClientRect();
|
|
7510
7513
|
const lRect = last.getBoundingClientRect();
|
|
7511
|
-
if (
|
|
7514
|
+
if (isStart) {
|
|
7515
|
+
if (isRtl)
|
|
7516
|
+
overlapsFollowing = sRect.right - tolerance > lRect.left && sRect.left + tolerance < fRect.right;else
|
|
7517
|
+
|
|
7512
7518
|
overlapsFollowing = sRect.right - tolerance > fRect.left && sRect.left + tolerance < lRect.right;
|
|
7513
7519
|
} else
|
|
7514
7520
|
{
|
|
7521
|
+
if (isRtl)
|
|
7522
|
+
overlapsFollowing = sRect.left + tolerance < fRect.right && sRect.right - tolerance > lRect.left;else
|
|
7523
|
+
|
|
7515
7524
|
overlapsFollowing = sRect.left + tolerance < lRect.right && sRect.right - tolerance > fRect.left;
|
|
7516
7525
|
}
|
|
7517
7526
|
}
|
|
@@ -7521,26 +7530,26 @@ function syncHorizontalStickies(table) {
|
|
|
7521
7530
|
}
|
|
7522
7531
|
}
|
|
7523
7532
|
};
|
|
7524
|
-
processStickies(
|
|
7525
|
-
processStickies(
|
|
7533
|
+
processStickies(stickiesStart, true, stickiesSetStart);
|
|
7534
|
+
processStickies(stickiesEnd, false, stickiesSetEnd);
|
|
7526
7535
|
}
|
|
7527
7536
|
const newStickies = [];
|
|
7528
7537
|
const removeStickies = [];
|
|
7529
|
-
for (const idx of
|
|
7530
|
-
if (!(
|
|
7531
|
-
newStickies.push({ index: idx,
|
|
7532
|
-
for (const idx of
|
|
7533
|
-
if (!(
|
|
7534
|
-
newStickies.push({ index: idx,
|
|
7535
|
-
if (
|
|
7536
|
-
for (const idx of
|
|
7537
|
-
if (!
|
|
7538
|
-
removeStickies.push({ index: idx,
|
|
7539
|
-
}
|
|
7540
|
-
if (
|
|
7541
|
-
for (const idx of
|
|
7542
|
-
if (!
|
|
7543
|
-
removeStickies.push({ index: idx,
|
|
7538
|
+
for (const idx of stickiesSetStart)
|
|
7539
|
+
if (!(oldStickiesSetStart !== null && oldStickiesSetStart !== void 0 && oldStickiesSetStart.has(idx)))
|
|
7540
|
+
newStickies.push({ index: idx, start: true });
|
|
7541
|
+
for (const idx of stickiesSetEnd)
|
|
7542
|
+
if (!(oldStickiesSetEnd !== null && oldStickiesSetEnd !== void 0 && oldStickiesSetEnd.has(idx)))
|
|
7543
|
+
newStickies.push({ index: idx, start: false });
|
|
7544
|
+
if (oldStickiesSetStart) {
|
|
7545
|
+
for (const idx of oldStickiesSetStart)
|
|
7546
|
+
if (!stickiesSetStart.has(idx))
|
|
7547
|
+
removeStickies.push({ index: idx, start: true });
|
|
7548
|
+
}
|
|
7549
|
+
if (oldStickiesSetEnd) {
|
|
7550
|
+
for (const idx of oldStickiesSetEnd)
|
|
7551
|
+
if (!stickiesSetEnd.has(idx))
|
|
7552
|
+
removeStickies.push({ index: idx, start: false });
|
|
7544
7553
|
}
|
|
7545
7554
|
if (!newStickies.length && !removeStickies.length)
|
|
7546
7555
|
return;
|
|
@@ -7548,16 +7557,16 @@ function syncHorizontalStickies(table) {
|
|
|
7548
7557
|
while (rowEl) {
|
|
7549
7558
|
const children = rowEl.children;
|
|
7550
7559
|
for (const sticky of removeStickies) {var _children$sticky$inde;
|
|
7551
|
-
(_children$sticky$inde = children[sticky.index]) === null || _children$sticky$inde === void 0 || _children$sticky$inde.classList.remove(sticky.
|
|
7560
|
+
(_children$sticky$inde = children[sticky.index]) === null || _children$sticky$inde === void 0 || _children$sticky$inde.classList.remove(sticky.start !== p.lastIsRtl ? 'is-sticky-left' : 'is-sticky-right');}
|
|
7552
7561
|
for (const sticky of newStickies) {var _children$sticky$inde2;
|
|
7553
|
-
(_children$sticky$inde2 = children[sticky.index]) === null || _children$sticky$inde2 === void 0 || _children$sticky$inde2.classList.add(sticky.
|
|
7562
|
+
(_children$sticky$inde2 = children[sticky.index]) === null || _children$sticky$inde2 === void 0 || _children$sticky$inde2.classList.add(sticky.start !== p.lastIsRtl ? 'is-sticky-left' : 'is-sticky-right');}
|
|
7554
7563
|
rowEl = rowEl.nextElementSibling;
|
|
7555
7564
|
}
|
|
7556
7565
|
p.isStickyColumns = new Map();
|
|
7557
|
-
for (const idx of
|
|
7558
|
-
p.isStickyColumns.set(idx, '
|
|
7559
|
-
for (const idx of
|
|
7560
|
-
p.isStickyColumns.set(idx, '
|
|
7566
|
+
for (const idx of stickiesSetStart)
|
|
7567
|
+
p.isStickyColumns.set(idx, 'start');
|
|
7568
|
+
for (const idx of stickiesSetEnd)
|
|
7569
|
+
p.isStickyColumns.set(idx, 'end');
|
|
7561
7570
|
}
|
|
7562
7571
|
/**
|
|
7563
7572
|
* Resize column elements
|