@nanoporetech-digital/components 4.9.2 → 4.9.3
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/CHANGELOG.md +12 -0
- package/dist/cjs/{nano-table-a9452165.js → nano-table-0bac0552.js} +61 -41
- package/dist/cjs/nano-table-0bac0552.js.map +1 -0
- package/dist/cjs/nano-table.cjs.entry.js +1 -1
- package/dist/cjs/{table.worker-a50cf617.js → table.worker-13b5bc18.js} +2 -2
- package/dist/cjs/table.worker-13b5bc18.js.map +1 -0
- package/dist/collection/components/table/table.js +59 -39
- package/dist/collection/components/table/table.js.map +1 -1
- package/dist/collection/components/table/table.store.js.map +1 -1
- package/dist/components/table.js +59 -39
- package/dist/components/table.js.map +1 -1
- package/dist/esm/{nano-table-14764c56.js → nano-table-ece658c4.js} +61 -41
- package/dist/esm/nano-table-ece658c4.js.map +1 -0
- package/dist/esm/nano-table.entry.js +1 -1
- package/dist/esm/{table.worker-a3dd27a2.js → table.worker-e89525d3.js} +2 -2
- package/dist/esm/table.worker-e89525d3.js.map +1 -0
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/{p-94aebbfe.js → p-11025069.js} +2 -2
- package/dist/nano-components/p-11025069.js.map +1 -0
- package/dist/nano-components/{p-0ffd130d.entry.js → p-27d5d32b.entry.js} +2 -2
- package/dist/nano-components/p-bd2d0c58.js +5 -0
- package/dist/types/components/table/table.d.ts +8 -3
- package/dist/types/components/table/table.store.d.ts +1 -0
- package/docs-json.json +1 -1
- package/hydrate/index.js +59 -39
- package/package.json +2 -2
- package/dist/cjs/nano-table-a9452165.js.map +0 -1
- package/dist/cjs/table.worker-a50cf617.js.map +0 -1
- package/dist/esm/nano-table-14764c56.js.map +0 -1
- package/dist/esm/table.worker-a3dd27a2.js.map +0 -1
- package/dist/nano-components/p-3b0e2b23.js +0 -5
- package/dist/nano-components/p-94aebbfe.js.map +0 -1
- /package/dist/nano-components/{p-0ffd130d.entry.js.map → p-27d5d32b.entry.js.map} +0 -0
- /package/dist/nano-components/{p-3b0e2b23.js.map → p-bd2d0c58.js.map} +0 -0
package/dist/components/table.js
CHANGED
@@ -983,6 +983,8 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
983
983
|
}
|
984
984
|
};
|
985
985
|
this.scrollHandler = () => {
|
986
|
+
if (!this.store.general.state.isActive)
|
987
|
+
return;
|
986
988
|
this.cacheScrollPosition = this.scrollParent.scrollTop || window.scrollY;
|
987
989
|
requestAnimationFrame(() => {
|
988
990
|
let cumulativeHeight = 0;
|
@@ -1067,7 +1069,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1067
1069
|
this.currentSort = '';
|
1068
1070
|
await this.columnInit();
|
1069
1071
|
if (!this.isReady)
|
1070
|
-
this.setInitialBlockDimension();
|
1072
|
+
requestAnimationFrame(() => this.setInitialBlockDimension());
|
1071
1073
|
this._loading = false;
|
1072
1074
|
});
|
1073
1075
|
}
|
@@ -1160,8 +1162,9 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1160
1162
|
? document
|
1161
1163
|
: this._scrollParent).removeEventListener('scroll', this.scrollHandler);
|
1162
1164
|
}
|
1163
|
-
(ele === document.documentElement ? document : ele).addEventListener('scroll', this.scrollHandler);
|
1165
|
+
(ele === document.documentElement ? document : ele).addEventListener('scroll', this.scrollHandler, { passive: true });
|
1164
1166
|
this._scrollParent = ele;
|
1167
|
+
this.setupActiveWatcher();
|
1165
1168
|
}
|
1166
1169
|
// used to fire `nanoTblBlockRendered` on block render change
|
1167
1170
|
get primaryBlockIndex() {
|
@@ -1319,56 +1322,49 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1319
1322
|
this.scrollHandler();
|
1320
1323
|
}
|
1321
1324
|
setMeasureElement() {
|
1322
|
-
|
1323
|
-
|
1325
|
+
return new Promise((resolve) => {
|
1326
|
+
readTask(() => {
|
1327
|
+
this.measureEle = this.blockElements.find((b) => { var _a; return !((_a = b === null || b === void 0 ? void 0 : b.classList) === null || _a === void 0 ? void 0 : _a.contains(`${CSSNAMESPACE}__inactive`)); });
|
1328
|
+
resolve();
|
1329
|
+
});
|
1324
1330
|
});
|
1325
1331
|
}
|
1326
1332
|
/**
|
1327
|
-
*
|
1328
|
-
*
|
1329
|
-
*
|
1333
|
+
* Makes sure we have dimensions on at least one, active tbody element.
|
1334
|
+
* We'll use this is a yard stick for inactive tbody elements in future.
|
1335
|
+
* These elements have no natural height (on account of all their rows being hidden)
|
1330
1336
|
*/
|
1331
1337
|
setInitialBlockDimension() {
|
1332
1338
|
var _a;
|
1333
1339
|
if (!((_a = this.blockElements) === null || _a === void 0 ? void 0 : _a.length))
|
1334
1340
|
return;
|
1335
1341
|
perMark('blockDims');
|
1336
|
-
const
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
resolve();
|
1357
|
-
return;
|
1358
|
-
}
|
1359
|
-
if (i === this.blockElements.length - 1)
|
1360
|
-
resolve();
|
1361
|
-
});
|
1362
|
-
}
|
1363
|
-
});
|
1342
|
+
const testForDimensions = async () => {
|
1343
|
+
await this.setMeasureElement();
|
1344
|
+
if (this.unitHeight)
|
1345
|
+
return true;
|
1346
|
+
return false;
|
1347
|
+
};
|
1348
|
+
const dimensionsReady = new Promise(async (resolve) => {
|
1349
|
+
if (await testForDimensions())
|
1350
|
+
resolve();
|
1351
|
+
else {
|
1352
|
+
// it's likely this table is hidden in the dom.
|
1353
|
+
// we need to wait until it's visible
|
1354
|
+
const observer = new IntersectionObserver(async () => {
|
1355
|
+
if (await testForDimensions()) {
|
1356
|
+
resolve();
|
1357
|
+
observer.disconnect();
|
1358
|
+
}
|
1359
|
+
}, { root: this.scrollParent });
|
1360
|
+
observer.observe(this.tableEle);
|
1361
|
+
}
|
1364
1362
|
});
|
1365
1363
|
// we're all finished.
|
1366
|
-
|
1364
|
+
dimensionsReady.then(() => {
|
1367
1365
|
perMark('blockDims', true);
|
1368
1366
|
perMark('init', true);
|
1369
|
-
requestAnimationFrame(() =>
|
1370
|
-
this.isReady = true;
|
1371
|
-
});
|
1367
|
+
requestAnimationFrame(() => (this.isReady = true));
|
1372
1368
|
});
|
1373
1369
|
}
|
1374
1370
|
/** Apply initial columns settings */
|
@@ -1472,11 +1468,29 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1472
1468
|
console.error('For accessibility you must set a `caption` prop or use the `caption` slot');
|
1473
1469
|
}
|
1474
1470
|
}
|
1471
|
+
/** Adds an IO. Makes sure our scroll listener is only active when
|
1472
|
+
* the table is in viewport */
|
1473
|
+
setupActiveWatcher() {
|
1474
|
+
if (!this.host || !this.scrollParent)
|
1475
|
+
return;
|
1476
|
+
if (this.activeWatcherIo) {
|
1477
|
+
this.activeWatcherIo.disconnect();
|
1478
|
+
this.activeWatcherIo = undefined;
|
1479
|
+
}
|
1480
|
+
const io = (this.activeWatcherIo = new IntersectionObserver(async ([e]) => {
|
1481
|
+
if (e.isIntersecting)
|
1482
|
+
this.store.general.state.isActive = true;
|
1483
|
+
else
|
1484
|
+
this.store.general.state.isActive = false;
|
1485
|
+
}, { root: this.scrollParent }));
|
1486
|
+
io.observe(this.host);
|
1487
|
+
}
|
1475
1488
|
// Component lifecycle
|
1476
1489
|
async componentWillLoad() {
|
1477
1490
|
perMark('init');
|
1478
1491
|
this.scrollParent = findScrollParent(this.host);
|
1479
1492
|
this.store = await generateStore(this.host, this.columns, this.scrollParent, this.isReady);
|
1493
|
+
this.store.general.onChange('isActive', this.scrollHandler);
|
1480
1494
|
await this.handleRowsChange();
|
1481
1495
|
this.processSlots();
|
1482
1496
|
this.store.data.onChange('rows', () => this.setBlocks());
|
@@ -1504,6 +1518,12 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1504
1518
|
this.setMeasureElement();
|
1505
1519
|
perMark('render', true);
|
1506
1520
|
}
|
1521
|
+
disconnectedCallback() {
|
1522
|
+
if (!this.activeWatcherIo)
|
1523
|
+
return;
|
1524
|
+
this.activeWatcherIo.disconnect();
|
1525
|
+
this.activeWatcherIo = undefined;
|
1526
|
+
}
|
1507
1527
|
render() {
|
1508
1528
|
this.blockElements = [];
|
1509
1529
|
return (h(Host, null, h("div", { class: `${CSSNAMESPACE}__top-anchor`, ref: (a) => (this.topAnchorEle = a) }, "\u00A0"), h("nano-resize-observe", { "aria-labelledby": 'table-caption-' + this.renderId, tabindex: this.type === 'grid' ? '0' : undefined, states: "576w sm, 768w md", class: "sm md", onNanoResizeStateChange: this.handleResizeChange }), h("div", { class: `${CSSNAMESPACE}__wrap sm md`, ref: (div) => (this.tableWrapperEle = div) }, h("nano-progress-bar", { indeterminate: true, class: {
|