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