@nanoporetech-digital/components 3.5.1 → 3.6.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.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/{date-utils-c581f187.js → date-utils-42fbcb42.js} +5 -3
- package/dist/cjs/date-utils-42fbcb42.js.map +1 -0
- package/dist/cjs/index-41582c2a.js +2 -6
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nano-components.cjs.js +1 -1
- package/dist/cjs/nano-datalist_3.cjs.entry.js +10 -5
- package/dist/cjs/nano-datalist_3.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-date-input.cjs.entry.js +1 -1
- package/dist/cjs/nano-date-picker.cjs.entry.js +1 -1
- package/dist/cjs/nano-demo.cjs.entry.js +3 -2
- package/dist/cjs/nano-demo.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-dropdown.cjs.entry.js +5 -2
- package/dist/cjs/nano-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-file-upload.cjs.entry.js +4 -0
- package/dist/cjs/nano-file-upload.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js +1 -2
- package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-icon-button.cjs.entry.js +1 -1
- package/dist/cjs/nano-icon-button.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/{nano-tooltip.cjs.entry.js → nano-progress-bar_2.cjs.entry.js} +28 -4
- package/dist/cjs/nano-progress-bar_2.cjs.entry.js.map +1 -0
- package/dist/cjs/nano-resize-observe_2.cjs.entry.js +74 -12
- package/dist/cjs/nano-resize-observe_2.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-sticker.cjs.entry.js +2 -0
- package/dist/cjs/nano-sticker.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-tab-group.cjs.entry.js +1 -1
- package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
- package/dist/cjs/{nano-table-067e0c12.js → nano-table-b031ec24.js} +164 -84
- package/dist/cjs/nano-table-b031ec24.js.map +1 -0
- package/dist/cjs/nano-table.cjs.entry.js +1 -1
- package/dist/cjs/{table.worker-a4d75c46.js → table.worker-dadd1eb0.js} +3 -3
- package/dist/cjs/table.worker-dadd1eb0.js.map +1 -0
- package/dist/{esm/table.worker-e9fb087e.js → cjs/table.worker-e2f9ccfa.js} +1 -1
- package/dist/collection/components/datalist/datalist.js +3 -3
- package/dist/collection/components/datalist/datalist.js.map +1 -1
- package/dist/collection/components/demo/demo.js +3 -2
- package/dist/collection/components/demo/demo.js.map +1 -1
- package/dist/collection/components/dropdown/dropdown.js +5 -2
- package/dist/collection/components/dropdown/dropdown.js.map +1 -1
- package/dist/collection/components/file-upload/file-upload.js +4 -0
- package/dist/collection/components/file-upload/file-upload.js.map +1 -1
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/icon.js.map +1 -1
- package/dist/collection/components/icon-button/icon-button.js +1 -1
- package/dist/collection/components/icon-button/icon-button.js.map +1 -1
- package/dist/collection/components/menu/menu.js +8 -3
- package/dist/collection/components/menu/menu.js.map +1 -1
- package/dist/collection/components/nav-item/nav-item.js +1 -2
- package/dist/collection/components/nav-item/nav-item.js.map +1 -1
- package/dist/collection/components/resize-observe/resize-observe.js +118 -14
- package/dist/collection/components/resize-observe/resize-observe.js.map +1 -1
- package/dist/collection/components/sticker/sticker.js +2 -0
- package/dist/collection/components/sticker/sticker.js.map +1 -1
- package/dist/collection/components/table/table-interface.js.map +1 -1
- package/dist/collection/components/table/table.cell.js +10 -5
- package/dist/collection/components/table/table.cell.js.map +1 -1
- package/dist/collection/components/table/table.css +9 -23
- package/dist/collection/components/table/table.js +227 -88
- package/dist/collection/components/table/table.js.map +1 -1
- package/dist/collection/components/table/table.row.js +19 -12
- package/dist/collection/components/table/table.row.js.map +1 -1
- package/dist/collection/components/table/table.store.js +1 -1
- package/dist/collection/components/table/table.store.js.map +1 -1
- package/dist/collection/components/table/table.utils.js +4 -4
- package/dist/collection/components/table/table.utils.js.map +1 -1
- package/dist/collection/components/table/table.worker.js +8 -0
- package/dist/collection/components/table/table.worker.js.map +1 -1
- package/dist/collection/components/tabs/tab-group.js +1 -1
- package/dist/collection/components/tabs/tab-group.js.map +1 -1
- package/dist/collection/components/tooltip/tooltip.js +25 -3
- package/dist/collection/components/tooltip/tooltip.js.map +1 -1
- package/dist/collection/utils/date-utils.js +4 -2
- package/dist/collection/utils/date-utils.js.map +1 -1
- package/dist/collection/utils/testing/index.js +15 -8
- package/dist/collection/utils/testing/index.js.map +1 -1
- package/dist/components/datalist.js +3 -3
- package/dist/components/datalist.js.map +1 -1
- package/dist/components/date-picker.js +4 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/dropdown.js +5 -2
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/icon-button.js +1 -1
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/icon.js.map +1 -1
- package/dist/components/menu.js +8 -3
- package/dist/components/menu.js.map +1 -1
- package/dist/components/nano-demo.js +21 -14
- package/dist/components/nano-demo.js.map +1 -1
- package/dist/components/nano-file-upload.js +4 -0
- package/dist/components/nano-file-upload.js.map +1 -1
- package/dist/components/nano-tab-group.js +1 -1
- package/dist/components/nano-tab-group.js.map +1 -1
- package/dist/components/nav-item.js +1 -2
- package/dist/components/nav-item.js.map +1 -1
- package/dist/components/resize-observe.js +80 -14
- package/dist/components/resize-observe.js.map +1 -1
- package/dist/components/sticker.js +2 -0
- package/dist/components/sticker.js.map +1 -1
- package/dist/components/table.js +187 -98
- package/dist/components/table.js.map +1 -1
- package/dist/components/table.worker.js +1 -1
- package/dist/components/tooltip.js +6 -3
- package/dist/components/tooltip.js.map +1 -1
- package/dist/custom-elements/index.js +277 -116
- package/dist/custom-elements/index.js.map +1 -1
- package/dist/esm/{date-utils-bb82b123.js → date-utils-6b7a6e1f.js} +5 -3
- package/dist/esm/date-utils-6b7a6e1f.js.map +1 -0
- package/dist/esm/index-3c280603.js +2 -6
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nano-components.js +1 -1
- package/dist/esm/nano-datalist_3.entry.js +10 -5
- package/dist/esm/nano-datalist_3.entry.js.map +1 -1
- package/dist/esm/nano-date-input.entry.js +1 -1
- package/dist/esm/nano-date-picker.entry.js +1 -1
- package/dist/esm/nano-demo.entry.js +3 -2
- package/dist/esm/nano-demo.entry.js.map +1 -1
- package/dist/esm/nano-dropdown.entry.js +5 -2
- package/dist/esm/nano-dropdown.entry.js.map +1 -1
- package/dist/esm/nano-file-upload.entry.js +4 -0
- package/dist/esm/nano-file-upload.entry.js.map +1 -1
- package/dist/esm/nano-global-nav-user-profile_3.entry.js +1 -2
- package/dist/esm/nano-global-nav-user-profile_3.entry.js.map +1 -1
- package/dist/esm/nano-icon-button.entry.js +1 -1
- package/dist/esm/nano-icon-button.entry.js.map +1 -1
- package/dist/esm/nano-icon.entry.js.map +1 -1
- package/dist/esm/{nano-tooltip.entry.js → nano-progress-bar_2.entry.js} +29 -6
- package/dist/esm/nano-progress-bar_2.entry.js.map +1 -0
- package/dist/esm/nano-resize-observe_2.entry.js +74 -12
- package/dist/esm/nano-resize-observe_2.entry.js.map +1 -1
- package/dist/esm/nano-sticker.entry.js +2 -0
- package/dist/esm/nano-sticker.entry.js.map +1 -1
- package/dist/esm/nano-tab-group.entry.js +1 -1
- package/dist/esm/nano-tab-group.entry.js.map +1 -1
- package/dist/esm/{nano-table-95921f46.js → nano-table-74d627a5.js} +164 -84
- package/dist/esm/nano-table-74d627a5.js.map +1 -0
- package/dist/esm/nano-table.entry.js +1 -1
- package/dist/esm/{table.worker-769f1441.js → table.worker-2908df63.js} +3 -3
- package/dist/esm/table.worker-2908df63.js.map +1 -0
- package/dist/{nano-components/p-e9fb087e.js → esm/table.worker-e2f9ccfa.js} +1 -1
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/nano-components.esm.js.map +1 -1
- package/dist/nano-components/p-135fed16.entry.js +5 -0
- package/dist/nano-components/p-135fed16.entry.js.map +1 -0
- package/dist/nano-components/{p-2cb4615b.entry.js → p-2a97ef51.entry.js} +2 -2
- package/dist/nano-components/{p-2cb4615b.entry.js.map → p-2a97ef51.entry.js.map} +0 -0
- package/dist/nano-components/{p-751927d1.entry.js → p-3f25fc76.entry.js} +2 -2
- package/dist/nano-components/p-3f25fc76.entry.js.map +1 -0
- package/dist/nano-components/p-5d149792.entry.js +5 -0
- package/dist/nano-components/p-5d149792.entry.js.map +1 -0
- package/dist/nano-components/p-69e5a37d.entry.js.map +1 -1
- package/dist/nano-components/p-6ad194e4.entry.js +5 -0
- package/dist/nano-components/p-6ad194e4.entry.js.map +1 -0
- package/dist/nano-components/{p-46b348b7.entry.js → p-6cb77d5c.entry.js} +2 -2
- package/dist/nano-components/{p-46b348b7.entry.js.map → p-6cb77d5c.entry.js.map} +0 -0
- package/dist/nano-components/{p-85cfb0af.entry.js → p-9a4297e1.entry.js} +2 -2
- package/dist/nano-components/p-9a4297e1.entry.js.map +1 -0
- package/dist/nano-components/{p-d1c8eca4.entry.js → p-b55ffa92.entry.js} +2 -2
- package/dist/nano-components/p-b55ffa92.entry.js.map +1 -0
- package/dist/nano-components/p-cc5e7acb.entry.js +5 -0
- package/dist/nano-components/p-cc5e7acb.entry.js.map +1 -0
- package/dist/nano-components/p-cecb9af1.js +5 -0
- package/dist/nano-components/p-cecb9af1.js.map +1 -0
- package/dist/nano-components/{p-601e18d5.entry.js → p-d5303933.entry.js} +2 -2
- package/dist/nano-components/p-d5303933.entry.js.map +1 -0
- package/dist/nano-components/{p-4f0e14b5.entry.js → p-d565991d.entry.js} +2 -2
- package/dist/nano-components/p-d565991d.entry.js.map +1 -0
- package/dist/nano-components/p-d7ed2d6e.js +5 -0
- package/dist/nano-components/p-d7ed2d6e.js.map +1 -0
- package/dist/nano-components/p-d81d40d9.js +5 -0
- package/dist/nano-components/{p-26905bca.js.map → p-d81d40d9.js.map} +0 -0
- package/dist/nano-components/{p-244223f0.entry.js → p-dc50b93c.entry.js} +2 -2
- package/dist/nano-components/p-dc50b93c.entry.js.map +1 -0
- package/dist/{cjs/table.worker-e9fb087e.js → nano-components/p-e2f9ccfa.js} +1 -1
- package/dist/nano-components/{p-fb12a45d.entry.js → p-f5ee07b3.entry.js} +2 -2
- package/dist/nano-components/{p-fb12a45d.entry.js.map → p-f5ee07b3.entry.js.map} +0 -0
- package/dist/types/components/icon/icon.d.ts +1 -1
- package/dist/types/components/menu/menu.d.ts +1 -0
- package/dist/types/components/resize-observe/resize-observe.d.ts +20 -1
- package/dist/types/components/table/table-interface.d.ts +35 -24
- package/dist/types/components/table/table.cell.d.ts +1 -1
- package/dist/types/components/table/table.d.ts +48 -15
- package/dist/types/components/table/table.row.d.ts +1 -1
- package/dist/types/components/table/table.store.d.ts +1 -1
- package/dist/types/components/table/table.utils.d.ts +1 -1
- package/dist/types/components/table/table.worker.d.ts +3 -3
- package/dist/types/components/tooltip/tooltip.d.ts +5 -0
- package/dist/types/components.d.ts +59 -14
- package/dist/types/utils/date-utils.d.ts +1 -1
- package/docs-json.json +179 -31
- package/docs-vscode.json +26 -3
- package/package.json +2 -2
- package/dist/cjs/date-utils-c581f187.js.map +0 -1
- package/dist/cjs/nano-progress-bar.cjs.entry.js +0 -33
- package/dist/cjs/nano-progress-bar.cjs.entry.js.map +0 -1
- package/dist/cjs/nano-table-067e0c12.js.map +0 -1
- package/dist/cjs/nano-tooltip.cjs.entry.js.map +0 -1
- package/dist/cjs/table.worker-a4d75c46.js.map +0 -1
- package/dist/esm/date-utils-bb82b123.js.map +0 -1
- package/dist/esm/nano-progress-bar.entry.js +0 -29
- package/dist/esm/nano-progress-bar.entry.js.map +0 -1
- package/dist/esm/nano-table-95921f46.js.map +0 -1
- package/dist/esm/nano-tooltip.entry.js.map +0 -1
- package/dist/esm/table.worker-769f1441.js.map +0 -1
- package/dist/nano-components/p-15a60f7e.js +0 -5
- package/dist/nano-components/p-15a60f7e.js.map +0 -1
- package/dist/nano-components/p-244223f0.entry.js.map +0 -1
- package/dist/nano-components/p-26905bca.js +0 -5
- package/dist/nano-components/p-4f0e14b5.entry.js.map +0 -1
- package/dist/nano-components/p-601e18d5.entry.js.map +0 -1
- package/dist/nano-components/p-751927d1.entry.js.map +0 -1
- package/dist/nano-components/p-85cfb0af.entry.js.map +0 -1
- package/dist/nano-components/p-8fc2a38d.js +0 -5
- package/dist/nano-components/p-8fc2a38d.js.map +0 -1
- package/dist/nano-components/p-9e8c9bac.entry.js +0 -5
- package/dist/nano-components/p-9e8c9bac.entry.js.map +0 -1
- package/dist/nano-components/p-a2e38472.entry.js +0 -5
- package/dist/nano-components/p-a2e38472.entry.js.map +0 -1
- package/dist/nano-components/p-b9c8b99f.entry.js +0 -5
- package/dist/nano-components/p-b9c8b99f.entry.js.map +0 -1
- package/dist/nano-components/p-d1c8eca4.entry.js.map +0 -1
- package/dist/nano-components/p-f43d1d8e.entry.js +0 -5
- package/dist/nano-components/p-f43d1d8e.entry.js.map +0 -1
- package/dist/nano-components/p-feb9f164.entry.js +0 -5
- package/dist/nano-components/p-feb9f164.entry.js.map +0 -1
package/dist/components/table.js
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
/*!
|
2
2
|
* Web Components for Nanopore digital Web Apps
|
3
3
|
*/
|
4
|
-
import { consoleError, getElement, getRenderingRef, h, Fragment, proxyCustomElement, HTMLElement, createEvent, readTask,
|
4
|
+
import { consoleError, getElement, getRenderingRef, h, Fragment, proxyCustomElement, HTMLElement, createEvent, readTask, Build, Host } from '@stencil/core/internal/client';
|
5
5
|
import { a as cyrb53 } from './math.js';
|
6
6
|
import { d as debounce } from './throttle.js';
|
7
7
|
import { c as createStore } from './index2.js';
|
8
|
-
import { d as defineCustomElement$
|
9
|
-
import { d as defineCustomElement$
|
10
|
-
import { d as defineCustomElement$
|
11
|
-
import { d as defineCustomElement$
|
12
|
-
import { d as defineCustomElement$
|
8
|
+
import { d as defineCustomElement$6 } from './icon.js';
|
9
|
+
import { d as defineCustomElement$5 } from './progress-bar.js';
|
10
|
+
import { d as defineCustomElement$4 } from './resize-observe.js';
|
11
|
+
import { d as defineCustomElement$3 } from './skeleton.js';
|
12
|
+
import { d as defineCustomElement$2 } from './spinner.js';
|
13
|
+
import { d as defineCustomElement$1 } from './tooltip.js';
|
13
14
|
|
14
15
|
const CSSNAMESPACE = 'nano-tbl';
|
15
16
|
|
@@ -213,7 +214,7 @@ function storeSetData(host, rows) {
|
|
213
214
|
row[colName] = Number(coerceDate);
|
214
215
|
});
|
215
216
|
row['__index'] = i;
|
216
|
-
row['__uuid'] = cyrb53(
|
217
|
+
row['__uuid'] = cyrb53(cols.map((c) => row[c.prop]).join());
|
217
218
|
return row;
|
218
219
|
});
|
219
220
|
store.data.state.rows = rows;
|
@@ -275,7 +276,7 @@ function colDataModel(rowIndex, colIndex) {
|
|
275
276
|
const column = columns[colIndex];
|
276
277
|
const prop = column?.prop;
|
277
278
|
const rowModel = rows[rowIndex];
|
278
|
-
const cellModel = rowModel[columns[colIndex].prop];
|
279
|
+
const cellModel = rowModel ? rowModel[columns[colIndex].prop] : '';
|
279
280
|
return {
|
280
281
|
prop,
|
281
282
|
cellModel,
|
@@ -292,9 +293,9 @@ function colDataModel(rowIndex, colIndex) {
|
|
292
293
|
function rowDataModel(rowIndex) {
|
293
294
|
const store = fetchStores();
|
294
295
|
const rows = store.data.state.rows;
|
295
|
-
const
|
296
|
+
const rowModel = rows[rowIndex];
|
296
297
|
return {
|
297
|
-
|
298
|
+
rowModel,
|
298
299
|
rowIndex,
|
299
300
|
};
|
300
301
|
}
|
@@ -361,7 +362,7 @@ function mergeCellProperties(rowIndex, colIndex, defaultProps) {
|
|
361
362
|
* @returns - a JSX node
|
362
363
|
*/
|
363
364
|
function colheadFootRender(col) {
|
364
|
-
const tpl = col?.
|
365
|
+
const tpl = col?.columnTemplate;
|
365
366
|
return tpl ? (tpl(h, col)) : (h(Fragment, null, col.title));
|
366
367
|
}
|
367
368
|
const stickyHIOs = new WeakMap();
|
@@ -724,7 +725,7 @@ function cellRender(rowIndex, colIndex) {
|
|
724
725
|
: d;
|
725
726
|
}
|
726
727
|
}
|
727
|
-
return tpl ? (tpl(h, model)) : (h(Fragment, null, model.cellModel?.toString()));
|
728
|
+
return tpl ? (tpl(h, model)) : model.cellModel ? (h(Fragment, null, model.cellModel?.toString())) : ('');
|
728
729
|
}
|
729
730
|
const baseCellClasses = (colIndex, toString = false) => {
|
730
731
|
const store = fetchStores();
|
@@ -741,9 +742,9 @@ const baseCellClasses = (colIndex, toString = false) => {
|
|
741
742
|
return classes;
|
742
743
|
};
|
743
744
|
const TableCell = ({ rowIndex, colIndex, nestedContent, }) => {
|
744
|
-
const
|
745
|
-
|
746
|
-
|
745
|
+
const Content = () => nestedContent
|
746
|
+
? nestedContent()
|
747
|
+
: cellRender(rowIndex, colIndex) || (h("span", { class: "placeholder" }, "\u00A0"));
|
747
748
|
let CellType = 'td';
|
748
749
|
const store = fetchStores();
|
749
750
|
const column = store.config.state.columns[colIndex];
|
@@ -757,24 +758,37 @@ const TableCell = ({ rowIndex, colIndex, nestedContent, }) => {
|
|
757
758
|
: { ...props, scope: 'row' };
|
758
759
|
CellType = 'th';
|
759
760
|
}
|
761
|
+
const ContentWrap = (props) => (h("div", { ...props, class: {
|
762
|
+
[`${CSSNAMESPACE}__cell-content`]: true,
|
763
|
+
[`${CSSNAMESPACE}__cell-content--wrap`]: !!column.wrap,
|
764
|
+
} },
|
765
|
+
h(Content, null)));
|
760
766
|
return (h(CellType
|
761
767
|
// role="gridcell"
|
762
|
-
, { ...props },
|
763
|
-
|
768
|
+
, { ...props }, column.autoTooltip && !column.wrap ? (h("nano-resize-observe", { notifyContentFit: "x", onNanoResizeContentFitChange: (e) => (e.target.firstElementChild.disabled =
|
769
|
+
e.detail.x) },
|
770
|
+
h("nano-tooltip", { disabled: true, hoist: true },
|
771
|
+
h(ContentWrap, null),
|
772
|
+
h("span", { slot: "content" },
|
773
|
+
h(Content, null))))) : (h(ContentWrap, null))));
|
764
774
|
};
|
765
775
|
|
766
|
-
const TableRow = ({ rowRenderer, rowIndex,
|
776
|
+
const TableRow = ({ rowRenderer, rowIndex, rowModel, onColumnPinned }, children, utils) => {
|
767
777
|
let extraProps = {};
|
768
|
-
const TableCell = ({ header }, children) => {
|
769
|
-
const cell = h("div", { class:
|
778
|
+
const TableCell = ({ header, wrap }, children) => {
|
779
|
+
const cell = (h("div", { class: {
|
780
|
+
[`${CSSNAMESPACE}__cell-content`]: true,
|
781
|
+
[`${CSSNAMESPACE}__cell-content--wrap`]: wrap,
|
782
|
+
} }, children));
|
770
783
|
return header ? h("th", { scope: "row" }, cell) : h("td", null, cell);
|
771
784
|
};
|
772
|
-
if (!
|
785
|
+
if (!rowModel) {
|
773
786
|
const model = rowDataModel(rowIndex);
|
774
|
-
|
787
|
+
rowModel = model.rowModel;
|
775
788
|
}
|
776
789
|
if (rowRenderer?.rowProperties) {
|
777
|
-
extraProps =
|
790
|
+
extraProps =
|
791
|
+
rowRenderer.rowProperties({ rowModel, rowIndex }) || extraProps;
|
778
792
|
}
|
779
793
|
let pinned;
|
780
794
|
if (rowRenderer?.pinned && typeof rowRenderer.pinned === 'function') {
|
@@ -785,15 +799,15 @@ const TableRow = ({ rowRenderer, rowIndex, row, onColumnPinned }, children, util
|
|
785
799
|
const tpl = rowRenderer?.template;
|
786
800
|
if (tpl) {
|
787
801
|
let toRender = tpl(h, {
|
788
|
-
renderedRow: (h("tr", { ...props, key:
|
789
|
-
|
802
|
+
renderedRow: (h("tr", { ...props, key: rowModel.__uuid }, children)),
|
803
|
+
rowModel,
|
790
804
|
rowIndex,
|
791
805
|
}, TableCell);
|
792
806
|
if (Array.isArray(toRender)) {
|
793
807
|
toRender = utils.map(toRender, (node, i) => {
|
794
808
|
if (node.vtag === 'tr') {
|
795
809
|
if (!node.vkey)
|
796
|
-
node.vkey = `${
|
810
|
+
node.vkey = `${rowModel.__uuid}_${i}`;
|
797
811
|
node.vattrs = mergeProperties({ class: headerPinClasses('tr', pinned, true) }, node.vattrs);
|
798
812
|
if (!!node.vchildren) {
|
799
813
|
node.vchildren = utils.map(node.vchildren, (cNode, i) => {
|
@@ -819,15 +833,18 @@ const TableRow = ({ rowRenderer, rowIndex, row, onColumnPinned }, children, util
|
|
819
833
|
}
|
820
834
|
return toRender;
|
821
835
|
}
|
822
|
-
return (h("tr", { ...props, key:
|
836
|
+
return (h("tr", { ...props, key: rowModel.__uuid }, children));
|
823
837
|
};
|
824
838
|
const TableHeadFootRow = ({ rowRenderer, onColumnPinned }, children, utils) => {
|
825
839
|
let extraProps = {};
|
826
840
|
if (rowRenderer.rowProperties) {
|
827
841
|
extraProps = rowRenderer.rowProperties() || {};
|
828
842
|
}
|
829
|
-
const TableCell = ({ header }, children) => {
|
830
|
-
const cell = h("div", { class:
|
843
|
+
const TableCell = ({ header, wrap }, children) => {
|
844
|
+
const cell = (h("div", { class: {
|
845
|
+
[`${CSSNAMESPACE}__cell-content`]: true,
|
846
|
+
[`${CSSNAMESPACE}__cell-content--wrap`]: wrap,
|
847
|
+
} }, children));
|
831
848
|
return header !== false ? h("th", { scope: "col" }, cell) : h("td", null, cell);
|
832
849
|
};
|
833
850
|
const pinned = rowRenderer.pinned || null;
|
@@ -869,7 +886,7 @@ const TableHeadFootRow = ({ rowRenderer, onColumnPinned }, children, utils) => {
|
|
869
886
|
return h("tr", { ...props }, children);
|
870
887
|
};
|
871
888
|
|
872
|
-
const tableCss = ":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}nano-table{display:block;width:100%;--max-col-width:clamp(200px,
|
889
|
+
const tableCss = ":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}nano-table{display:block;width:100%;--max-col-width:clamp(200px, 500px, 50vw);--color:var(--nano-color-mediumgrey, #68767e);--font-size:0.87rem;--cell-line-height:1.5;--thead-font-size:0.95rem;--thead-color:#455560;--tfoot-color:#455560;--border-color:#dddbda;--border-style:thin solid var(--border-color);--border-tint-color:#0084a9;--border-tint-style:3px solid var(--border-tint-color);--cell-bg-rgb:var(--nano-color-white-rgb, 255 255 255);--head-bg-rgb:250, 250, 249;--foot-bg-rgb:var(--head-bg-rgb);--th-row-bg-rgb:var(--cell-bg-rgb);--ordered-bg-rgb:var(--nano-color-offwhite-rgb, 249 249 251);--td-padding-start:0.625rem;--td-padding-end:0.625rem;--td-padding-top:0.5rem;--td-padding-bottom:0.4125rem;--th-padding-start:0.625rem;--th-padding-end:0.625rem;--th-padding-top:0.875rem;--th-padding-bottom:0.6875rem;--td-padding-v:var(--td-padding-top) var(--td-padding-bottom);--td-padding-h:var(--td-padding-start) var(--td-padding-end);--th-padding-v:var(--th-padding-top) var(--th-padding-bottom);--th-padding-h:var(--th-padding-start) var(--th-padding-end);--foot-th-padding-v:var(--td-padding-top) var(--td-padding-bottom);--foot-th-padding-h:var(--td-padding-start) var(--td-padding-end);--head-th-padding-v:var(--th-padding-top) var(--th-padding-bottom);--head-th-padding-h:var(--th-padding-start) var(--th-padding-end);--bookend-col-padding:2rem}.nano-tbl{color:var(--color);text-align:start;width:100%;font-size:var(--font-size);border-spacing:0 0;border-collapse:separate;background:rgb(var(--cell-bg-rgb));border-inline-end:1px solid transparent;border-block-start:1px solid transparent;position:relative;z-index:1}.nano-tbl__wrap{display:table;min-width:100%}.nano-tbl__top-anchor{clip:rect(1px, 1px, 1px, 1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);block-size:1px;inline-size:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;position:relative}.nano-tbl__ordered{background-color:var(--ordered-bg);border-inline-start:var(--border-style);border-inline-end:var(--border-style)}.nano-tbl__drag-mask{display:none;position:absolute;inset-block:-2px -2px;z-index:10;opacity:0;transition:0.2s ease opacity}.nano-tbl__drag-mask--start{width:calc(50% + 2px);inset-inline-start:-2px;border-inline-start:2px dashed var(--border-tint-color)}.nano-tbl__drag-mask--end{width:50%;inset-inline-end:0;border-inline-end:2px dashed var(--border-tint-color)}.nano-tbl__drag-mask--active{opacity:1}.nano-tbl__dragging .nano-tbl__drag-mask{display:block}.nano-tbl__drag--start{opacity:0.4}.nano-tbl__dragging .nano-tbl__td,.nano-tbl__dragging .nano-tbl__th{cursor:no-drop}.nano-tbl__dragging .nano-tbl__td .nano-tbl__cell-content,.nano-tbl__dragging .nano-tbl__th .nano-tbl__cell-content{pointer-events:none}.nano-tbl__order-btn{padding:0;border:none;outline:none;font:inherit;background:none;-webkit-appearance:none;appearance:none;color:inherit;display:flex;gap:10px;align-items:center;width:100%}.nano-tbl__status-icons{margin-inline:auto 10px;display:flex;gap:10px}.nano-tbl__progress-bar{font-size:0.2rem;position:sticky;inset-block-start:0;inset-inline:0;z-index:10;transition:scale 0.25s;scale:0;width:100%;height:0}.nano-tbl__progress-bar--show{scale:1;height:auto}.nano-tbl__caption--hide{clip:rect(1px, 1px, 1px, 1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);block-size:1px;inline-size:1px;margin:-1px;overflow:hidden;padding:0;position:absolute}.nano-tbl__td,.nano-tbl__th{line-height:var(--cell-line-height);text-align:start;border-block-start:var(--border-style);max-width:var(--max-col-width);background-color:rgb(var(--cell-bg-rgb))}tbody:first-of-type tr:first-child .nano-tbl__td,tbody:first-of-type tr:first-child .nano-tbl__th{border-block-start:none}tbody:last-of-type tr:last-child .nano-tbl__td,tbody:last-of-type tr:last-child .nano-tbl__th{border-block-end:var(--border-style)}.md .nano-tbl__td:first-child .nano-tbl__cell-content,.md .nano-tbl__th:first-child .nano-tbl__cell-content{padding-inline-start:var(--bookend-col-padding)}.md .nano-tbl__td:last-child .nano-tbl__cell-content,.md .nano-tbl__th:last-child .nano-tbl__cell-content{padding-inline-end:var(--bookend-col-padding)}@media (max-width: 768px){.nano-tbl__td:first-child .nano-tbl__cell-content,.nano-tbl__th:first-child .nano-tbl__cell-content{padding-inline-start:var(--td-padding-start) !important}.nano-tbl__td:last-child .nano-tbl__cell-content,.nano-tbl__th:last-child .nano-tbl__cell-content{padding-inline-end:var(--td-padding-end) !important}}thead .nano-tbl__td,thead .nano-tbl__th{color:var(--thead-color);font-weight:800;background:rgba(var(--head-bg-rgb), 90%);font-size:var(--thead-font-size);border-block-start:none !important;transition:all 0.2s ease}thead .nano-tbl__td .nano-tbl__cell-content,thead .nano-tbl__th .nano-tbl__cell-content{padding-block:var(--head-th-padding-v);padding-inline:var(--head-th-padding-h)}tfoot .nano-tbl__td,tfoot .nano-tbl__th{color:var(--tfoot-color);font-weight:800;border-block-start:none;background:rgba(var(--foot-bg-rgb), 90%);font-size:var(--thead-font-size)}tfoot .nano-tbl__td .nano-tbl__cell-content,tfoot .nano-tbl__th .nano-tbl__cell-content{padding-block:var(--foot-th-padding-v);padding-inline:var(--foot-th-padding-h)}.nano-tbl__td.nano-tbl__ordered,.nano-tbl__th.nano-tbl__ordered{background-color:rgba(var(--ordered-bg-rgb), 0.8) !important}.nano-tbl__cell-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-block:var(--td-padding-v);padding-inline:var(--td-padding-h)}.nano-tbl__cell-content--no-result{padding-block:2rem}.nano-tbl__cell-content--wrap{white-space:normal;overflow:visible}.nano-tbl tbody{will-change:scroll-position;opacity:1;transition:0.1s ease opacity;transform:translateZ(0)}.nano-tbl tbody.nano-tbl__inactive{opacity:0}.nano-tbl th[scope=row]{font-weight:800;margin:0}.nano-tbl__pin{position:sticky}.nano-tbl__pin--start{inset-inline:-1px auto;transition:max-width 0.25s ease}.nano-tbl__pin--start::after{content:\"\";position:absolute;inset:0;box-shadow:5px 1px 4px 0 rgba(0, 0, 0, 0.2);opacity:0;z-index:-1}.nano-tbl__pinned--start .nano-tbl__pin--start{z-index:2;max-width:125px !important}.sm .nano-tbl__pinned--start .nano-tbl__pin--start{max-width:var(--max-col-width) !important}.nano-tbl__pinned--start .nano-tbl__pin--start::after{opacity:1}.nano-tbl__pin--end{}.nano-tbl__pin--start+.nano-tbl__pin--end{inset-inline:auto auto}.nano-tbl__pin--start+.nano-tbl__pin--end::after{display:none}.sm .nano-tbl__pin--end{inset-inline:auto -1px !important;max-width:min(50vw, 200px)}.sm .nano-tbl__pin--end::after{display:block !important;content:\"\";position:absolute;inset:0;box-shadow:-5px 1px 4px 0 rgba(0, 0, 0, 0.2);opacity:0;z-index:-1}.sm .nano-tbl__pinned--end .nano-tbl__pin--end::after{opacity:1}.nano-tbl__pin--top{inset-block:-1px auto}.nano-tbl__pinned--top .nano-tbl__pin--top{z-index:4 !important}.nano-tbl__pin--bottom{inset-block:auto -1px}.nano-tbl__pinned--bottom .nano-tbl__pin--bottom{z-index:5 !important}.nano-tbl__pinned--start .nano-tbl__pin--top.nano-tbl__pin--start{z-index:5 !important}.nano-tbl__pinned--top.nano-tbl__pinned--start .nano-tbl__pin--top.nano-tbl__pin--start{z-index:6 !important}.nano-tbl__pinned--end .nano-tbl__pin--top.nano-tbl__pin--end{z-index:5 !important}.nano-tbl__pinned--top.nano-tbl__pinned--end .nano-tbl__pin--top.nano-tbl__pin--end{z-index:6 !important}.nano-tbl__pinned--start .nano-tbl__pin--bottom.nano-tbl__pin--start{z-index:5 !important}.nano-tbl__pinned--bottom.nano-tbl__pinned--start .nano-tbl__pin--bottom.nano-tbl__pin--start{z-index:6 !important}.nano-tbl__pinned--end .nano-tbl__pin--bottom.nano-tbl__pin--end{z-index:5 !important}.nano-tbl__pinned--bottom.nano-tbl__pinned--end .nano-tbl__pin--bottom.nano-tbl__pin--end{z-index:6 !important}.nano-tbl thead tr:last-of-type td,.nano-tbl thead tr:last-of-type th{border-block-end:var(--border-tint-style)}.nano-tbl tfoot tr:first-of-type td,.nano-tbl tfoot tr:first-of-type th{border-block-start:none}.nano-tbl tfoot tr:last-of-type td,.nano-tbl tfoot tr:last-of-type th{border-block-end:var(--border-tint-style)}.nano-tbl__pinned--bottom .nano-tbl tfoot tr.nano-tbl__pin--bottom:first-of-type td,.nano-tbl__pinned--bottom .nano-tbl tfoot tr.nano-tbl__pin--bottom:first-of-type th{border-block-start:var(--border-tint-style) !important}.nano-tbl__pinned--bottom .nano-tbl tfoot tr.nano-tbl__pin--bottom:last-of-type td,.nano-tbl__pinned--bottom .nano-tbl tfoot tr.nano-tbl__pin--bottom:last-of-type th{border-block-end:none !important}.nano-tbl .unlimited-width{max-width:none}.nano-tbl__spinner{font-size:1.5rem;transition:scale 0.25s;scale:0;padding:0.5rem;position:absolute;inset-block-end:0;inset-inline-start:calc(50% - 0.75rem);z-index:0}.nano-tbl__spinner--show{scale:1;position:sticky}.nano-tbl nano-skeleton{line-height:var(--cell-line-height)}";
|
873
890
|
|
874
891
|
function perMark(name, end = false) {
|
875
892
|
if (!Build.isDev)
|
@@ -889,8 +906,8 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
889
906
|
constructor() {
|
890
907
|
super();
|
891
908
|
this.__registerHost();
|
892
|
-
this.nanoTblBlockRendered = createEvent(this, "nanoTblBlockRendered", 7);
|
893
909
|
this.nanoTblReady = createEvent(this, "nanoTblReady", 7);
|
910
|
+
this.nanoTblBlockRendered = createEvent(this, "nanoTblBlockRendered", 7);
|
894
911
|
this.nanoTblBeforeSort = createEvent(this, "nanoTblBeforeSort", 7);
|
895
912
|
this.nanoTblAfterSort = createEvent(this, "nanoTblAfterSort", 7);
|
896
913
|
this.nanoTblColDrag = createEvent(this, "nanoTblColDrag", 7);
|
@@ -899,22 +916,33 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
899
916
|
this.nanoTblAfterFilter = createEvent(this, "nanoTblAfterFilter", 7);
|
900
917
|
this.nanoTblBeforeSearch = createEvent(this, "nanoTblBeforeSearch", 7);
|
901
918
|
this.nanoTblAfterSearch = createEvent(this, "nanoTblAfterSearch", 7);
|
919
|
+
this.nanoTblBeforeEdit = createEvent(this, "nanoTblBeforeEdit", 7);
|
902
920
|
this.debounceSetLoading = (l) => {
|
903
|
-
this.
|
921
|
+
this.internalLoading = l;
|
904
922
|
};
|
905
923
|
this.renderId = 'tbl-' + id++;
|
906
924
|
this.filters = [];
|
907
925
|
this.currentFilters = '[]';
|
908
926
|
this.currentSort = '';
|
927
|
+
this.measureHeight = 0;
|
909
928
|
this.blockIos = new WeakMap();
|
910
929
|
this.blockHeights = [];
|
911
930
|
this.unitHeight = 0;
|
912
931
|
// Scroll / IO used for hiding / showing blocks
|
913
932
|
this.ignoreIO = true;
|
914
933
|
this._isReady = false;
|
934
|
+
/**
|
935
|
+
* Fired when a column is dragged
|
936
|
+
* @param column
|
937
|
+
*/
|
915
938
|
this.colDrag = (column) => {
|
916
939
|
this.nanoTblColDrag.emit({ column });
|
917
940
|
};
|
941
|
+
/**
|
942
|
+
* Fired when a column is dropped after being dragged
|
943
|
+
* @param fromCol
|
944
|
+
* @param toCol
|
945
|
+
*/
|
918
946
|
this.colDrop = (fromCol, toCol) => {
|
919
947
|
const cols = this.store.config.state.columns;
|
920
948
|
const toIndex = cols.findIndex((col) => col.prop === toCol);
|
@@ -927,7 +955,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
927
955
|
});
|
928
956
|
if (dropEvent.defaultPrevented)
|
929
957
|
return;
|
930
|
-
this.
|
958
|
+
this.columns = arrMove(fromIndex, toIndex, cols);
|
931
959
|
};
|
932
960
|
/**
|
933
961
|
* Start a sort - can be cancelled by `preventDefault`
|
@@ -939,7 +967,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
939
967
|
// did order change?
|
940
968
|
if (this.currentSort === order + ':' + column)
|
941
969
|
return;
|
942
|
-
this.
|
970
|
+
this._loading = true;
|
943
971
|
const sortEvent = this.nanoTblBeforeSort.emit({ column: column, order });
|
944
972
|
if (sortEvent.defaultPrevented)
|
945
973
|
return;
|
@@ -949,13 +977,24 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
949
977
|
this.scrollToTop(element);
|
950
978
|
if (this.customSortFn) {
|
951
979
|
try {
|
952
|
-
await this.customSortFn(column, order);
|
953
|
-
|
980
|
+
const res = await this.customSortFn(column, order);
|
981
|
+
// if the response is 'true', the custom sort did it's thing
|
982
|
+
// handover to finish and stop loading state.
|
983
|
+
// if response is falsey, carry on to do a FE sort
|
984
|
+
if (res === true) {
|
985
|
+
this.sortComplete(order, column);
|
986
|
+
this._loading = false;
|
987
|
+
return;
|
988
|
+
}
|
954
989
|
}
|
955
990
|
catch (e) {
|
991
|
+
// if response errored, stop loading state
|
992
|
+
// clear current sort cache
|
956
993
|
console.warn('custom sort failed', e);
|
994
|
+
this.currentSort = '';
|
995
|
+
this._loading = false;
|
996
|
+
return;
|
957
997
|
}
|
958
|
-
return;
|
959
998
|
}
|
960
999
|
try {
|
961
1000
|
await storeSort(this.host, column, order);
|
@@ -966,7 +1005,8 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
966
1005
|
this.currentSort = '';
|
967
1006
|
}
|
968
1007
|
finally {
|
969
|
-
this.
|
1008
|
+
if (this.blocks.length)
|
1009
|
+
this._loading = false;
|
970
1010
|
}
|
971
1011
|
};
|
972
1012
|
/**
|
@@ -979,31 +1019,35 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
979
1019
|
if (!el || this.blockIos.has(el))
|
980
1020
|
return;
|
981
1021
|
const blockIo = new IntersectionObserver(([ioEntry]) => {
|
982
|
-
if (
|
1022
|
+
if (ioEntry.intersectionRatio === 0)
|
983
1023
|
return;
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
if (this.
|
994
|
-
|
1024
|
+
// This is a bit gross
|
1025
|
+
// The Intersection Observer (IO) fires in an incorrect order when the scrolling is very fast
|
1026
|
+
// i.e. we go past blocks 3, 2, 1 and land on 0, but 3 can fire as 'intersecting' after 0.
|
1027
|
+
// To fix that, we check - for realzies - if the block IS visible.
|
1028
|
+
// BUT that test is not as sensitive to a block being visible via the IO,
|
1029
|
+
// so doesn't always fire if scrolling slowly
|
1030
|
+
// *sigh*
|
1031
|
+
readTask(() => {
|
1032
|
+
if (this.scrollSpeed < 100 || isInViewport(el, 0.01)) {
|
1033
|
+
if (!this.ignoreIO) {
|
1034
|
+
const potentialBlocks = [
|
995
1035
|
blockIndex,
|
996
1036
|
blockIndex + 1,
|
997
1037
|
Math.max(0, blockIndex - 1),
|
998
1038
|
];
|
999
|
-
this.
|
1000
|
-
|
1001
|
-
|
1002
|
-
}
|
1003
|
-
requestAnimationFrame(() => this.setBlockHeight());
|
1039
|
+
if (potentialBlocks.toString() !== this.activeBlocks.toString()) {
|
1040
|
+
this.activeBlocks = potentialBlocks;
|
1041
|
+
this.setBlockHeight();
|
1042
|
+
}
|
1004
1043
|
}
|
1005
|
-
|
1006
|
-
|
1044
|
+
// fire the event regardless
|
1045
|
+
this.nanoTblBlockRendered.emit({
|
1046
|
+
block: blockIndex,
|
1047
|
+
totalBlocks: this.blockElements.length,
|
1048
|
+
});
|
1049
|
+
}
|
1050
|
+
});
|
1007
1051
|
}, {
|
1008
1052
|
threshold: [0],
|
1009
1053
|
root: this.scrollParent === document.scrollingElement
|
@@ -1025,7 +1069,8 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1025
1069
|
this.type = 'table';
|
1026
1070
|
this.caption = undefined;
|
1027
1071
|
this.showCaption = false;
|
1028
|
-
this.
|
1072
|
+
this.loading = undefined;
|
1073
|
+
this.internalLoading = false;
|
1029
1074
|
this.placeholderSize = 5;
|
1030
1075
|
this.rows = undefined;
|
1031
1076
|
this.columns = [];
|
@@ -1039,26 +1084,25 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1039
1084
|
this.customSortFn = undefined;
|
1040
1085
|
this.defaultSort = true;
|
1041
1086
|
this.defaultColDraggable = false;
|
1087
|
+
this.virtualTotalItems = 0;
|
1042
1088
|
this.blocks = [];
|
1043
1089
|
this.activeBlocks = [0, 1, 2];
|
1044
|
-
this.measureHeight = 0;
|
1045
1090
|
this.debounceSetLoading = debounce(this.debounceSetLoading.bind(this), 50);
|
1046
1091
|
}
|
1047
|
-
|
1048
|
-
|
1049
|
-
* or when performing custom filtering or sorting */
|
1050
|
-
get loading() {
|
1051
|
-
return this._loading;
|
1092
|
+
get _loading() {
|
1093
|
+
return this.loading !== undefined ? this.loading : this.internalLoading;
|
1052
1094
|
}
|
1053
|
-
set
|
1095
|
+
set _loading(l) {
|
1096
|
+
if (this.loading !== undefined)
|
1097
|
+
return;
|
1054
1098
|
this.debounceSetLoading(l);
|
1055
1099
|
}
|
1056
1100
|
handleRowsChange() {
|
1057
1101
|
if (!this.rows) {
|
1058
|
-
this.
|
1102
|
+
this._loading = true;
|
1059
1103
|
return;
|
1060
1104
|
}
|
1061
|
-
this.
|
1105
|
+
this._loading = true;
|
1062
1106
|
Promise.resolve(this.rows).then(async (rows) => {
|
1063
1107
|
await storeSetData(this.host, rows);
|
1064
1108
|
// reset everything
|
@@ -1067,7 +1111,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1067
1111
|
await this.columnInit();
|
1068
1112
|
if (!this.isReady)
|
1069
1113
|
this.setInitialBlockDimension();
|
1070
|
-
this.
|
1114
|
+
this._loading = false;
|
1071
1115
|
});
|
1072
1116
|
}
|
1073
1117
|
async handleColsChange() {
|
@@ -1082,6 +1126,9 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1082
1126
|
handleSearchTermChange() {
|
1083
1127
|
this.searchStart();
|
1084
1128
|
}
|
1129
|
+
virtualTotalItemsChangeHandler() {
|
1130
|
+
this.setBlocks();
|
1131
|
+
}
|
1085
1132
|
/** Remove any column sorts currently applied
|
1086
1133
|
* @returns a promise which resolves when complete */
|
1087
1134
|
async resetSorting() {
|
@@ -1122,11 +1169,25 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1122
1169
|
this.filters = this.filters.filter((f) => !columnNames.includes(f.prop));
|
1123
1170
|
return this.filterStart();
|
1124
1171
|
}
|
1172
|
+
/** Updates a row model at a given index
|
1173
|
+
* @param row - the row to update.
|
1174
|
+
* *Note* - this should come from the `col.cellTemplate` or `row.rowRender.template` `rowModel` property
|
1175
|
+
* - rows are augmented with certain properties to aid with efficient rendering
|
1176
|
+
* @param rowIndex - the row index to insert this row
|
1177
|
+
*/
|
1178
|
+
async updateRow(row, rowIndex) {
|
1179
|
+
this.rows.splice(rowIndex, 1, row);
|
1180
|
+
this.handleRowsChange();
|
1181
|
+
}
|
1125
1182
|
// uses the first 'tr' of an active block as our yard stick
|
1126
1183
|
set measureEle(el) {
|
1127
1184
|
if (!el)
|
1128
1185
|
return;
|
1129
|
-
|
1186
|
+
const potentialHeight = el.getBoundingClientRect().height;
|
1187
|
+
this.measureHeight =
|
1188
|
+
Math.abs(this.measureHeight - potentialHeight) < 5
|
1189
|
+
? this.measureHeight
|
1190
|
+
: potentialHeight;
|
1130
1191
|
this.unitHeight =
|
1131
1192
|
el.querySelector('tr')?.getBoundingClientRect().height || this.unitHeight;
|
1132
1193
|
}
|
@@ -1173,7 +1234,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1173
1234
|
perMark('sort', true);
|
1174
1235
|
}
|
1175
1236
|
async searchStart() {
|
1176
|
-
this.
|
1237
|
+
this._loading = true;
|
1177
1238
|
const sortEvent = this.nanoTblBeforeSearch.emit({ term: this.searchTerm });
|
1178
1239
|
if (sortEvent.defaultPrevented)
|
1179
1240
|
return;
|
@@ -1189,7 +1250,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1189
1250
|
console.warn('search failed', e);
|
1190
1251
|
}
|
1191
1252
|
finally {
|
1192
|
-
this.
|
1253
|
+
this._loading = false;
|
1193
1254
|
}
|
1194
1255
|
}
|
1195
1256
|
async filterStart(filters, additive = true) {
|
@@ -1206,7 +1267,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1206
1267
|
}
|
1207
1268
|
if (this.currentFilters === JSON.stringify(this.filters))
|
1208
1269
|
return;
|
1209
|
-
this.
|
1270
|
+
this._loading = true;
|
1210
1271
|
const sortEvent = this.nanoTblBeforeFilter.emit({ filters: this.filters });
|
1211
1272
|
if (sortEvent.defaultPrevented)
|
1212
1273
|
return;
|
@@ -1216,12 +1277,21 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1216
1277
|
this.scrollToTop();
|
1217
1278
|
if (this.customFilterFn) {
|
1218
1279
|
try {
|
1219
|
-
await this.customFilterFn(this.filters);
|
1220
|
-
|
1280
|
+
const res = await this.customFilterFn(this.filters);
|
1281
|
+
// if the response is 'true', the custom filter did it's thing
|
1282
|
+
// handover to finish and stop loading state.
|
1283
|
+
// if response is falsey, carry on to do a FE filter
|
1284
|
+
if (res === true) {
|
1285
|
+
this.filterComplete();
|
1286
|
+
this._loading = false;
|
1287
|
+
}
|
1221
1288
|
}
|
1222
1289
|
catch (e) {
|
1290
|
+
// if response errored, stop loading state
|
1291
|
+
// clear current sort cache
|
1223
1292
|
console.warn('custom filter failed', e);
|
1224
1293
|
this.currentFilters = '';
|
1294
|
+
this._loading = false;
|
1225
1295
|
}
|
1226
1296
|
return;
|
1227
1297
|
}
|
@@ -1233,7 +1303,7 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1233
1303
|
console.warn('filter failed', e);
|
1234
1304
|
}
|
1235
1305
|
finally {
|
1236
|
-
this.
|
1306
|
+
this._loading = false;
|
1237
1307
|
}
|
1238
1308
|
}
|
1239
1309
|
filterComplete() {
|
@@ -1325,24 +1395,34 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1325
1395
|
* These can then be hidden / shown to improve performance.
|
1326
1396
|
*/
|
1327
1397
|
setBlocks() {
|
1398
|
+
const dRows = this.store.data.state.rows;
|
1399
|
+
if (!dRows.length) {
|
1400
|
+
this.blocks = [];
|
1401
|
+
return;
|
1402
|
+
}
|
1328
1403
|
perMark('setBlocks');
|
1329
|
-
this.activeBlocks = [0, 1, 2];
|
1330
1404
|
this.ignoreIO = true;
|
1331
1405
|
let i = 1;
|
1332
|
-
const l = this.
|
1406
|
+
const l = this.virtualTotalItems > dRows.length
|
1407
|
+
? this.virtualTotalItems
|
1408
|
+
: dRows.length;
|
1333
1409
|
let rows = [];
|
1334
1410
|
const blocks = [];
|
1335
1411
|
this.blockHeights = [];
|
1336
1412
|
// old skool loop for perf
|
1337
1413
|
for (i; i <= l; i++) {
|
1338
|
-
rows.push(this.store.data.state.rows[i - 1]);
|
1414
|
+
rows.push(this.store.data.state.rows[i - 1] || { __uuid: '' });
|
1339
1415
|
if (i % this.perBlock === 0) {
|
1416
|
+
// assign a UUID for the whole block
|
1417
|
+
// for block diffing
|
1340
1418
|
blocks.push({ rows, __uuid: cyrb53(rows.map((b) => b.__uuid).join()) });
|
1341
1419
|
rows = [];
|
1342
1420
|
}
|
1343
1421
|
}
|
1344
|
-
|
1422
|
+
// any leftover rows
|
1423
|
+
if (rows.length) {
|
1345
1424
|
blocks.push({ rows, __uuid: cyrb53(rows.map((b) => b.__uuid).join()) });
|
1425
|
+
}
|
1346
1426
|
this.blocks = blocks;
|
1347
1427
|
perMark('setBlocks', true);
|
1348
1428
|
}
|
@@ -1370,11 +1450,11 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1370
1450
|
}
|
1371
1451
|
/** cache the height for all active blocks for later renders */
|
1372
1452
|
setBlockHeight() {
|
1373
|
-
|
1374
|
-
this.
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1453
|
+
this.activeBlocks.forEach((blockIndex) => {
|
1454
|
+
const el = this.blockElements[blockIndex];
|
1455
|
+
if (!el)
|
1456
|
+
return;
|
1457
|
+
readTask(() => {
|
1378
1458
|
const height = el.getBoundingClientRect().height;
|
1379
1459
|
// cache height to our block heights array
|
1380
1460
|
// for subsequent renders
|
@@ -1416,6 +1496,8 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1416
1496
|
// but we don't want it to cause renders
|
1417
1497
|
if (['rows', 'columns'].includes(stateName))
|
1418
1498
|
return false;
|
1499
|
+
if (Build.isDev)
|
1500
|
+
console.log(stateName, _newVal, _oldVal);
|
1419
1501
|
}
|
1420
1502
|
componentWillRender() {
|
1421
1503
|
perMark('render');
|
@@ -1438,15 +1520,15 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1438
1520
|
sortable: this.defaultSort,
|
1439
1521
|
draggable: this.defaultColDraggable,
|
1440
1522
|
} }),
|
1441
|
-
]))), this._loading && !this.blocks.length && (h("tbody", { class: `${CSSNAMESPACE}__active` }, [...Array(10).keys()].map((rowIndex) => (h("tr", null, this.store.config.state.columns.map((_colModel, colIndex) => (h(TableCell, { rowIndex: rowIndex, colIndex: colIndex, nestedContent: h("nano-skeleton", null) })))))))), !this._loading && !this.blocks.length && (h("tr", null, h("th", { class: `${CSSNAMESPACE}__th`, colSpan: this.store.config.state.columns.length }, h("div", { class: "nano-tbl__cell-content nano-tbl__cell-content--no-result" }, h("slot", { name: "no-results" }, "No results found"))))), this.blocks.map((block, blockIndex) => (h("tbody", { key: block.__uuid, id: `tbody-${this.renderId}-${blockIndex}`, ref: (tb) => {
|
1523
|
+
]))), this._loading && !this.blocks.length && (h("tbody", { class: `${CSSNAMESPACE}__active` }, [...Array(10).keys()].map((rowIndex) => (h("tr", null, this.store.config.state.columns.map((_colModel, colIndex) => (h(TableCell, { rowIndex: rowIndex, colIndex: colIndex, nestedContent: () => h("nano-skeleton", null) })))))))), !this._loading && !this.blocks.length && (h("tr", null, h("th", { class: `${CSSNAMESPACE}__th`, colSpan: this.store.config.state.columns.length }, h("div", { class: "nano-tbl__cell-content nano-tbl__cell-content--no-result" }, h("slot", { name: "no-results" }, "No results found"))))), this.blocks.map((block, blockIndex) => (h("tbody", { key: block.__uuid, id: `tbody-${this.renderId}-${blockIndex}`, ref: (tb) => {
|
1442
1524
|
this.blockElements.push(tb);
|
1443
|
-
this.setupBlockIO(tb, blockIndex);
|
1525
|
+
requestAnimationFrame(() => this.setupBlockIO(tb, blockIndex));
|
1444
1526
|
}, class: {
|
1445
1527
|
[`${CSSNAMESPACE}__inactive`]: !this.activeBlocks.includes(blockIndex),
|
1446
1528
|
[`${CSSNAMESPACE}__active`]: this.activeBlocks.includes(blockIndex),
|
1447
1529
|
} }, this.activeBlocks.includes(blockIndex) ? (block.rows.map((row, i) => {
|
1448
1530
|
const rowIndex = blockIndex > 0 ? blockIndex * this.perBlock + i : i;
|
1449
|
-
return (h(TableRow, { rowRenderer: this.rowRender,
|
1531
|
+
return (h(TableRow, { rowRenderer: this.rowRender, rowModel: row, rowIndex: rowIndex }, this.store.config.state.columns.map((_colModel, colIndex) => (h(TableCell, { rowIndex: rowIndex, colIndex: colIndex })))));
|
1450
1532
|
})) : (h("td", { colSpan: this.store.config.state.columns.length, style: {
|
1451
1533
|
height: this.getBlockHeight(blockIndex),
|
1452
1534
|
} }))))), this.showFooter && (h("tfoot", null, h(TableHeadFootRow, { rowRenderer: this.footRender, onColumnPinned: this.handleColumnPinned }, this.store.config.state.columns.map((colModel) => [
|
@@ -1463,16 +1545,17 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1463
1545
|
static get watchers() { return {
|
1464
1546
|
"rows": ["handleRowsChange"],
|
1465
1547
|
"columns": ["handleColsChange"],
|
1466
|
-
"searchTerm": ["handleSearchTermChange"]
|
1548
|
+
"searchTerm": ["handleSearchTermChange"],
|
1549
|
+
"virtualTotalItems": ["virtualTotalItemsChangeHandler"]
|
1467
1550
|
}; }
|
1468
1551
|
static get style() { return tableCss; }
|
1469
1552
|
}, [4, "nano-table", {
|
1470
1553
|
"type": [1],
|
1471
1554
|
"caption": [1],
|
1472
1555
|
"showCaption": [4, "show-caption"],
|
1473
|
-
"loading": [
|
1556
|
+
"loading": [4],
|
1474
1557
|
"placeholderSize": [2, "placeholder-size"],
|
1475
|
-
"rows": [
|
1558
|
+
"rows": [1040],
|
1476
1559
|
"columns": [1040],
|
1477
1560
|
"headRender": [16],
|
1478
1561
|
"rowRender": [16],
|
@@ -1485,21 +1568,22 @@ const Table = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
1485
1568
|
"customSortFn": [16],
|
1486
1569
|
"defaultSort": [4, "default-sort"],
|
1487
1570
|
"defaultColDraggable": [4, "default-col-draggable"],
|
1488
|
-
"
|
1571
|
+
"virtualTotalItems": [2, "virtual-total-items"],
|
1572
|
+
"internalLoading": [32],
|
1489
1573
|
"blocks": [32],
|
1490
1574
|
"activeBlocks": [32],
|
1491
|
-
"measureHeight": [32],
|
1492
1575
|
"resetSorting": [64],
|
1493
1576
|
"addSort": [64],
|
1494
1577
|
"resetFilters": [64],
|
1495
1578
|
"addFilters": [64],
|
1496
|
-
"removeFilters": [64]
|
1579
|
+
"removeFilters": [64],
|
1580
|
+
"updateRow": [64]
|
1497
1581
|
}, [[9, "scroll", "scrollListener"]]]);
|
1498
1582
|
function defineCustomElement() {
|
1499
1583
|
if (typeof customElements === "undefined") {
|
1500
1584
|
return;
|
1501
1585
|
}
|
1502
|
-
const components = ["nano-table", "nano-icon", "nano-progress-bar", "nano-resize-observe", "nano-skeleton", "nano-spinner"];
|
1586
|
+
const components = ["nano-table", "nano-icon", "nano-progress-bar", "nano-resize-observe", "nano-skeleton", "nano-spinner", "nano-tooltip"];
|
1503
1587
|
components.forEach(tagName => { switch (tagName) {
|
1504
1588
|
case "nano-table":
|
1505
1589
|
if (!customElements.get(tagName)) {
|
@@ -1508,25 +1592,30 @@ function defineCustomElement() {
|
|
1508
1592
|
break;
|
1509
1593
|
case "nano-icon":
|
1510
1594
|
if (!customElements.get(tagName)) {
|
1511
|
-
defineCustomElement$
|
1595
|
+
defineCustomElement$6();
|
1512
1596
|
}
|
1513
1597
|
break;
|
1514
1598
|
case "nano-progress-bar":
|
1515
1599
|
if (!customElements.get(tagName)) {
|
1516
|
-
defineCustomElement$
|
1600
|
+
defineCustomElement$5();
|
1517
1601
|
}
|
1518
1602
|
break;
|
1519
1603
|
case "nano-resize-observe":
|
1520
1604
|
if (!customElements.get(tagName)) {
|
1521
|
-
defineCustomElement$
|
1605
|
+
defineCustomElement$4();
|
1522
1606
|
}
|
1523
1607
|
break;
|
1524
1608
|
case "nano-skeleton":
|
1525
1609
|
if (!customElements.get(tagName)) {
|
1526
|
-
defineCustomElement$
|
1610
|
+
defineCustomElement$3();
|
1527
1611
|
}
|
1528
1612
|
break;
|
1529
1613
|
case "nano-spinner":
|
1614
|
+
if (!customElements.get(tagName)) {
|
1615
|
+
defineCustomElement$2();
|
1616
|
+
}
|
1617
|
+
break;
|
1618
|
+
case "nano-tooltip":
|
1530
1619
|
if (!customElements.get(tagName)) {
|
1531
1620
|
defineCustomElement$1();
|
1532
1621
|
}
|