@nanoporetech-digital/components 3.4.0 → 3.5.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 +12 -0
- package/dist/cjs/index-41582c2a.js +16 -12
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nano-components.cjs.js +1 -1
- package/dist/cjs/nano-demo.cjs.entry.js +291 -0
- package/dist/cjs/nano-demo.cjs.entry.js.map +1 -0
- package/dist/cjs/{nano-table-b9cdafab.js → nano-table-83e46f68.js} +486 -202
- package/dist/cjs/nano-table-83e46f68.js.map +1 -0
- package/dist/cjs/nano-table.cjs.entry.js +1 -1
- package/dist/cjs/{table.worker-291904c9.js → table.worker-525ec230.js} +3 -3
- package/dist/cjs/table.worker-525ec230.js.map +1 -0
- package/dist/cjs/table.worker-e9fb087e.js +4 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/alert/alert.helpers.js.map +1 -1
- package/dist/collection/components/demo/demo.js +284 -0
- package/dist/collection/components/demo/demo.js.map +1 -0
- package/dist/collection/components/dialog/dialog.helpers.js.map +1 -1
- package/dist/collection/components/table/table-interface.js.map +1 -1
- package/dist/collection/components/table/table.cell.js +65 -0
- package/dist/collection/components/table/table.cell.js.map +1 -0
- package/dist/collection/components/table/table.css +98 -20
- package/dist/collection/components/table/table.header.js +156 -0
- package/dist/collection/components/table/table.header.js.map +1 -0
- package/dist/collection/components/table/table.js +170 -18
- package/dist/collection/components/table/table.js.map +1 -1
- package/dist/collection/components/table/table.row.js +113 -0
- package/dist/collection/components/table/table.row.js.map +1 -0
- package/dist/collection/components/table/table.store.js +46 -9
- package/dist/collection/components/table/table.store.js.map +1 -1
- package/dist/collection/components/table/table.utils.js +230 -0
- package/dist/collection/components/table/table.utils.js.map +1 -1
- package/dist/collection/components/table/table.worker.js +1 -0
- package/dist/collection/components/table/table.worker.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/nano-demo.d.ts +11 -0
- package/dist/components/nano-demo.js +341 -0
- package/dist/components/nano-demo.js.map +1 -0
- package/dist/components/nano-table.js +2 -1247
- package/dist/components/nano-table.js.map +1 -1
- package/dist/components/table.js +1539 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/table.worker.js +2 -2
- package/dist/custom-elements/index.d.ts +6 -0
- package/dist/custom-elements/index.js +772 -204
- package/dist/custom-elements/index.js.map +1 -1
- package/dist/esm/index-3c280603.js +16 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nano-components.js +1 -1
- package/dist/esm/nano-demo.entry.js +287 -0
- package/dist/esm/nano-demo.entry.js.map +1 -0
- package/dist/esm/{nano-table-c8ef2276.js → nano-table-e2405350.js} +487 -203
- package/dist/esm/nano-table-e2405350.js.map +1 -0
- package/dist/esm/nano-table.entry.js +1 -1
- package/dist/esm/{table.worker-65438fa0.js → table.worker-739c193f.js} +3 -3
- package/dist/esm/table.worker-739c193f.js.map +1 -0
- package/dist/esm/table.worker-e9fb087e.js +4 -0
- package/dist/nano-components/index.esm.js.map +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-28fdfa6b.js +5 -0
- package/dist/nano-components/p-28fdfa6b.js.map +1 -0
- package/dist/nano-components/p-85cfb0af.entry.js +5 -0
- package/dist/nano-components/p-85cfb0af.entry.js.map +1 -0
- package/dist/nano-components/p-a71989f3.js +5 -0
- package/dist/nano-components/{p-14218d23.entry.js.map → p-a71989f3.js.map} +0 -0
- package/dist/nano-components/{p-14218d23.entry.js → p-e4a28360.entry.js} +2 -2
- package/dist/nano-components/{p-fe1f8360.js.map → p-e4a28360.entry.js.map} +0 -0
- package/dist/nano-components/p-e9fb087e.js +4 -0
- package/dist/types/components/alert/alert.helpers.d.ts +1 -1
- package/dist/types/components/demo/demo.d.ts +6 -0
- package/dist/types/components/dialog/dialog.helpers.d.ts +1 -1
- package/dist/types/components/table/table-interface.d.ts +38 -23
- package/dist/types/components/table/table.cell.d.ts +18 -0
- package/dist/types/components/table/table.d.ts +36 -1
- package/dist/types/components/table/table.header.d.ts +16 -0
- package/dist/types/components/table/table.row.d.ts +15 -0
- package/dist/types/components/table/table.utils.d.ts +99 -0
- package/dist/types/components.d.ts +50 -0
- package/docs-json.json +124 -3
- package/docs-vscode.json +17 -1
- package/package.json +2 -2
- package/dist/cjs/nano-table-b9cdafab.js.map +0 -1
- package/dist/cjs/table.worker-1fd13775.js +0 -4
- package/dist/cjs/table.worker-291904c9.js.map +0 -1
- package/dist/collection/components/table/table.children.js +0 -224
- package/dist/collection/components/table/table.children.js.map +0 -1
- package/dist/collection/components/table/table.service.js +0 -121
- package/dist/collection/components/table/table.service.js.map +0 -1
- package/dist/esm/nano-table-c8ef2276.js.map +0 -1
- package/dist/esm/table.worker-1fd13775.js +0 -4
- package/dist/esm/table.worker-65438fa0.js.map +0 -1
- package/dist/nano-components/p-1fd13775.js +0 -4
- package/dist/nano-components/p-f9349146.js +0 -5
- package/dist/nano-components/p-f9349146.js.map +0 -1
- package/dist/nano-components/p-fe1f8360.js +0 -5
- package/dist/types/components/table/table.children.d.ts +0 -30
- package/dist/types/components/table/table.service.d.ts +0 -42
@@ -2283,6 +2283,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
2283
2283
|
Cstr.is = cmpMeta.$tagName$;
|
2284
2284
|
return proxyComponent(Cstr, cmpMeta);
|
2285
2285
|
};
|
2286
|
+
const Fragment$1 = (_, children) => children;
|
2286
2287
|
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
2287
2288
|
if (listeners) {
|
2288
2289
|
listeners.map(([flags, name, method]) => {
|
@@ -10510,6 +10511,287 @@ const DatePicker = class extends H {
|
|
10510
10511
|
static get style() { return datePickerCss; }
|
10511
10512
|
};
|
10512
10513
|
|
10514
|
+
function capitalise(value) {
|
10515
|
+
if (!value)
|
10516
|
+
return '';
|
10517
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
10518
|
+
}
|
10519
|
+
function mediumDate(date) {
|
10520
|
+
if (!date)
|
10521
|
+
return undefined;
|
10522
|
+
return new Date(date).toLocaleDateString(undefined, {
|
10523
|
+
year: 'numeric',
|
10524
|
+
month: 'short',
|
10525
|
+
day: 'numeric',
|
10526
|
+
});
|
10527
|
+
}
|
10528
|
+
function currency(amount = 0, currencyCode = 'USD') {
|
10529
|
+
currencyCode = currencyCode?.toLocaleUpperCase() || 'USD';
|
10530
|
+
return new Intl.NumberFormat('en-US', {
|
10531
|
+
style: 'currency',
|
10532
|
+
currency: currencyCode,
|
10533
|
+
}).format(amount);
|
10534
|
+
}
|
10535
|
+
const Demo = class extends H {
|
10536
|
+
constructor() {
|
10537
|
+
super();
|
10538
|
+
this.__registerHost();
|
10539
|
+
this.__attachShadow();
|
10540
|
+
this.order = {
|
10541
|
+
checks: [
|
10542
|
+
{
|
10543
|
+
name: 'Compliance',
|
10544
|
+
external_id: 'CO',
|
10545
|
+
status: 'complete',
|
10546
|
+
account_info: {
|
10547
|
+
name: 'Jeongmin Song',
|
10548
|
+
email: 'js2957@cornell.edu',
|
10549
|
+
address_line_1: '930 Campus Road',
|
10550
|
+
address_line_2: 'Veterinary Medical Center C4 109',
|
10551
|
+
address_postcode: '14853',
|
10552
|
+
address_city: 'Ithaca',
|
10553
|
+
address_region: 'New York',
|
10554
|
+
address_country: 'US',
|
10555
|
+
},
|
10556
|
+
individual_name_compliance_information: {
|
10557
|
+
table: {
|
10558
|
+
names: [],
|
10559
|
+
addresses: [],
|
10560
|
+
match: false,
|
10561
|
+
false_positive: null,
|
10562
|
+
},
|
10563
|
+
},
|
10564
|
+
organization_compliance_information: {
|
10565
|
+
table: {
|
10566
|
+
names: [],
|
10567
|
+
addresses: [],
|
10568
|
+
match: false,
|
10569
|
+
false_positive: null,
|
10570
|
+
},
|
10571
|
+
},
|
10572
|
+
checks: [
|
10573
|
+
{
|
10574
|
+
label: 'Compliance check',
|
10575
|
+
external_id: 'compliance_check',
|
10576
|
+
item_type: 'pass/fail/escalate',
|
10577
|
+
answer: 'pass',
|
10578
|
+
},
|
10579
|
+
],
|
10580
|
+
further_information: [],
|
10581
|
+
attachments: [],
|
10582
|
+
notes: [],
|
10583
|
+
},
|
10584
|
+
],
|
10585
|
+
orderId: '00886434',
|
10586
|
+
createdAt: '2022-12-09T15:57:50',
|
10587
|
+
updatedAt: '2022-12-09T16:02:29',
|
10588
|
+
status: 'Processing',
|
10589
|
+
subStatus: null,
|
10590
|
+
currency: 'USD',
|
10591
|
+
customerPaymentMethod: 'CC-USD',
|
10592
|
+
paymentPlatform: 'Shop',
|
10593
|
+
dataAreaId: 'OXUS',
|
10594
|
+
defaultShippingWarehouse: null,
|
10595
|
+
deliveryContact: 'Jeongmin Song',
|
10596
|
+
deliveryMode: null,
|
10597
|
+
deliveryName: 'Cornell University',
|
10598
|
+
deliveryTerms: null,
|
10599
|
+
invoiceAccountNumber: 'C038330',
|
10600
|
+
orderAccountNumber: 'C038330',
|
10601
|
+
orderAccountName: 'Cornell University',
|
10602
|
+
originalLeadTime: null,
|
10603
|
+
salesDate: '2022-12-09T15:57:50',
|
10604
|
+
salesName: 'Cornell University',
|
10605
|
+
salesOrigin: 'Shop',
|
10606
|
+
salesOriginName: 'Main USD Store View',
|
10607
|
+
customerReference: '',
|
10608
|
+
purchaseOrder: null,
|
10609
|
+
additionalDocuments: [],
|
10610
|
+
total: 860,
|
10611
|
+
shippingAmount: 50,
|
10612
|
+
taxAmount: 0,
|
10613
|
+
projectId: null,
|
10614
|
+
deliveryPhoneNumber: '+16072533722',
|
10615
|
+
invoicePhoneNumber: '+16072533722',
|
10616
|
+
quoteNumber: null,
|
10617
|
+
customerType: 'N/A',
|
10618
|
+
invoiceAccountEmail: 'js2957@cornell.edu',
|
10619
|
+
partnerReference: null,
|
10620
|
+
sentToD365: false,
|
10621
|
+
sentToD365Status: 'unsent',
|
10622
|
+
orderAccountEmail: 'js2957@cornell.edu',
|
10623
|
+
controllingAccountNumber: 'C038330',
|
10624
|
+
controllingAccountEmail: 'js2957@cornell.edu',
|
10625
|
+
deliveryAddress: {
|
10626
|
+
street: ['930 Campus Road, Veterinary Medical Center C4 109'],
|
10627
|
+
city: 'Ithaca',
|
10628
|
+
postcode: '14853',
|
10629
|
+
region: 'New York',
|
10630
|
+
regionCode: 'NY',
|
10631
|
+
countryCode: 'US',
|
10632
|
+
},
|
10633
|
+
invoiceAddress: {
|
10634
|
+
street: ['930 Campus Road, Veterinary Medical Center C4 109'],
|
10635
|
+
city: 'Ithaca',
|
10636
|
+
postcode: '14853',
|
10637
|
+
region: 'New York',
|
10638
|
+
regionCode: 'NY',
|
10639
|
+
countryCode: 'US',
|
10640
|
+
},
|
10641
|
+
shopOrderLines: [
|
10642
|
+
{
|
10643
|
+
name: 'Flongle Flow Cell (R9.4.1)',
|
10644
|
+
sku: 'FLO-FLG001',
|
10645
|
+
quantity: 1,
|
10646
|
+
price: 810,
|
10647
|
+
total: 810,
|
10648
|
+
createdAt: '2022-12-09T15:57:50',
|
10649
|
+
updatedAt: '2022-12-09T15:57:50',
|
10650
|
+
maskSku: 'FLO-FLG001',
|
10651
|
+
productType: 'bundle',
|
10652
|
+
salesTag: 'FLGExpSP',
|
10653
|
+
requestedShippingDate: null,
|
10654
|
+
discount: 0,
|
10655
|
+
discountPercentage: 0,
|
10656
|
+
get finalSku() {
|
10657
|
+
return this.maskSku || this.sku;
|
10658
|
+
},
|
10659
|
+
includedItems: [
|
10660
|
+
{
|
10661
|
+
name: 'Flongle Flow Cell (R9.4.1)',
|
10662
|
+
sku: 'FLO-FLG001D',
|
10663
|
+
quantity: 12,
|
10664
|
+
price: 66,
|
10665
|
+
total: 792,
|
10666
|
+
createdAt: '2022-12-09T15:57:50',
|
10667
|
+
updatedAt: '2022-12-09T15:57:50',
|
10668
|
+
maskSku: 'FLO-FLG001',
|
10669
|
+
productType: 'simple',
|
10670
|
+
salesTag: 'FLGExpSP',
|
10671
|
+
requestedShippingDate: '2022-12-27T00:00:00',
|
10672
|
+
discount: 0,
|
10673
|
+
discountPercentage: 0,
|
10674
|
+
},
|
10675
|
+
{
|
10676
|
+
name: 'Flongle Flow Cell Priming Kit',
|
10677
|
+
sku: 'EXP-FSE001',
|
10678
|
+
quantity: 1,
|
10679
|
+
price: 18,
|
10680
|
+
total: 18,
|
10681
|
+
createdAt: '2022-12-09T15:57:50',
|
10682
|
+
updatedAt: '2022-12-09T15:57:50',
|
10683
|
+
maskSku: '',
|
10684
|
+
productType: 'simple',
|
10685
|
+
salesTag: 'FLGExpSP',
|
10686
|
+
requestedShippingDate: '2022-12-27T00:00:00',
|
10687
|
+
discount: 0,
|
10688
|
+
discountPercentage: 0,
|
10689
|
+
},
|
10690
|
+
],
|
10691
|
+
},
|
10692
|
+
{
|
10693
|
+
name: 'Carriage - Device shipment',
|
10694
|
+
sku: 'FREIGHT',
|
10695
|
+
quantity: 1,
|
10696
|
+
price: 50,
|
10697
|
+
total: 50,
|
10698
|
+
createdAt: '2022-12-09T15:57:50',
|
10699
|
+
updatedAt: '2022-12-09T15:57:50',
|
10700
|
+
maskSku: '',
|
10701
|
+
productType: 'virtual',
|
10702
|
+
salesTag: null,
|
10703
|
+
requestedShippingDate: '2022-12-27T00:00:00',
|
10704
|
+
discount: 0,
|
10705
|
+
discountPercentage: 0,
|
10706
|
+
get finalSku() {
|
10707
|
+
return this.maskSku || this.sku;
|
10708
|
+
},
|
10709
|
+
},
|
10710
|
+
],
|
10711
|
+
orderLines: [],
|
10712
|
+
pickedItems: [],
|
10713
|
+
packedItems: [],
|
10714
|
+
trackingNumbers: [],
|
10715
|
+
trackingUpdates: [],
|
10716
|
+
ecoOrder: false,
|
10717
|
+
revenueOrder: false,
|
10718
|
+
};
|
10719
|
+
}
|
10720
|
+
lineItemTotal(order) {
|
10721
|
+
if (!order || !order.shopOrderLines?.length)
|
10722
|
+
return;
|
10723
|
+
let total = 0;
|
10724
|
+
order.shopOrderLines.forEach((itm) => {
|
10725
|
+
if (itm.status !== 'cancelled')
|
10726
|
+
total += itm.total;
|
10727
|
+
});
|
10728
|
+
return total;
|
10729
|
+
}
|
10730
|
+
render() {
|
10731
|
+
return (h$1(Host$1, null, h$1("nano-table", { rowRender: {
|
10732
|
+
template: (_, c, TableCell) => [
|
10733
|
+
c.renderedRow,
|
10734
|
+
c.row.includedItems?.length ? (c.row.includedItems?.map((item) => {
|
10735
|
+
return (h$1("tr", { class: "child-row" }, h$1(TableCell, { header: true }, item.name), h$1(TableCell, null, capitalise(c.row.status || this.order.status)), h$1(TableCell, null, capitalise(item.sku)), h$1(TableCell, null, capitalise(item.salesTag)), h$1(TableCell, null, mediumDate(item.requestedShippingDate))));
|
10736
|
+
})) : (h$1(Fragment$1, null)),
|
10737
|
+
].flat(1),
|
10738
|
+
}, columns: [
|
10739
|
+
{
|
10740
|
+
title: 'Name',
|
10741
|
+
prop: 'name',
|
10742
|
+
pinned: 'start',
|
10743
|
+
rowHeader: true,
|
10744
|
+
},
|
10745
|
+
{
|
10746
|
+
title: 'Status',
|
10747
|
+
prop: 'status',
|
10748
|
+
cellTemplate: (_, c) => capitalise(c.cellModel || this.order.status),
|
10749
|
+
},
|
10750
|
+
{
|
10751
|
+
title: 'SKU',
|
10752
|
+
prop: 'finalSku',
|
10753
|
+
},
|
10754
|
+
{
|
10755
|
+
title: 'Sales tag',
|
10756
|
+
prop: 'salesTag',
|
10757
|
+
cellTemplate: (_, c) => c.cellModel || 'None',
|
10758
|
+
},
|
10759
|
+
{
|
10760
|
+
title: 'Requested ship date',
|
10761
|
+
prop: 'requestedShippingDate',
|
10762
|
+
cellTemplate: (_, c) => mediumDate(c.cellModel) || 'N/A',
|
10763
|
+
},
|
10764
|
+
{
|
10765
|
+
title: 'Quantity',
|
10766
|
+
prop: 'quantity',
|
10767
|
+
},
|
10768
|
+
{
|
10769
|
+
title: 'Unit price',
|
10770
|
+
prop: 'price',
|
10771
|
+
cellTemplate: (_, c) => currency(c.cellModel, this.order.currency),
|
10772
|
+
},
|
10773
|
+
{
|
10774
|
+
title: 'Discount %',
|
10775
|
+
prop: 'discountPercentage',
|
10776
|
+
cellTemplate: (_, c) => c.cellModel || 0,
|
10777
|
+
},
|
10778
|
+
{
|
10779
|
+
title: 'Line value',
|
10780
|
+
prop: 'total',
|
10781
|
+
cellTemplate: (_, c) => currency(c.cellModel, this.order.currency),
|
10782
|
+
},
|
10783
|
+
], rows: this.order.shopOrderLines, caption: `List of order line items found within order ${this.order.orderId}`, showFooter: true, footRender: {
|
10784
|
+
pinned: 'bottom',
|
10785
|
+
template: () => [
|
10786
|
+
h$1("tr", null, h$1("td", { colSpan: 6 }, "\u00A0"), h$1("th", { scope: "row", class: "tbl__pin nano-tbl__pin--end", colSpan: 3 }, h$1("div", { class: "nano-tbl__cell-content order-lines__total" }, h$1("span", { class: "order-lines__total--label" }, "Sub total:"), h$1("span", { class: "order-lines__total--num" }, currency(this.lineItemTotal(this.order), this.order.currency))))),
|
10787
|
+
h$1("tr", null, h$1("td", { colSpan: 6 }, "\u00A0"), h$1("th", { scope: "row", class: "tbl__pin nano-tbl__pin--end", colSpan: 3 }, h$1("div", { class: "nano-tbl__cell-content order-lines__total" }, h$1("span", { class: "order-lines__total--label" }, "Total order tax:"), h$1("span", { class: "order-lines__total--num" }, currency(this.order.taxAmount, this.order.currency))))),
|
10788
|
+
h$1("tr", null, h$1("td", { colSpan: 6 }, "\u00A0"), h$1("th", { scope: "row", class: "tbl__pin nano-tbl__pin--end", colSpan: 3 }, h$1("div", { class: "nano-tbl__cell-content order-lines__total" }, h$1("span", { class: "order-lines__total--label" }, "Total on order placement:"), h$1("span", { class: "order-lines__total--num" }, currency(this.order.total, this.order.currency))))),
|
10789
|
+
],
|
10790
|
+
} })));
|
10791
|
+
}
|
10792
|
+
static get style() { return ":host {display: block}\n .child-row {\n opacity: .8;\n font-style: italic;\n }"; }
|
10793
|
+
};
|
10794
|
+
|
10513
10795
|
/**
|
10514
10796
|
* Quality of life for transition handling.
|
10515
10797
|
* Adds / removes transitionend events. Resolves on complete
|
@@ -25162,16 +25444,53 @@ async function generateStore(host, columns, scrollParent) {
|
|
25162
25444
|
function getStore(host) {
|
25163
25445
|
return stores.get(host);
|
25164
25446
|
}
|
25447
|
+
function getDataType(value) {
|
25448
|
+
if (value instanceof Date) {
|
25449
|
+
return 'date';
|
25450
|
+
}
|
25451
|
+
if (['number', 'string'].includes(typeof value)) {
|
25452
|
+
return typeof value;
|
25453
|
+
}
|
25454
|
+
return 'unknown';
|
25455
|
+
}
|
25165
25456
|
function storeSetData(host, rows) {
|
25166
25457
|
const store = stores.get(host);
|
25167
25458
|
if (!store)
|
25168
25459
|
return;
|
25169
|
-
|
25170
|
-
|
25171
|
-
|
25172
|
-
|
25173
|
-
|
25174
|
-
})
|
25460
|
+
const cols = store.config.state.columns;
|
25461
|
+
const dateCols = cols
|
25462
|
+
.filter((col) => col.type === 'date')
|
25463
|
+
.reduce((prev, curr) => {
|
25464
|
+
return [...prev, curr.prop];
|
25465
|
+
}, []);
|
25466
|
+
const unknownCols = cols.filter((col) => !col.type);
|
25467
|
+
// augments data with some internal.
|
25468
|
+
// discern unknown column types
|
25469
|
+
// convert dates to numbers for worker
|
25470
|
+
rows = rows.map((row, i) => {
|
25471
|
+
// try our best to discern the column type (from first row) if unset
|
25472
|
+
if (unknownCols.length && i === 0) {
|
25473
|
+
store.config.state.columns = cols.map((col) => {
|
25474
|
+
if (unknownCols.includes(col) && row[col.prop] && !col.type) {
|
25475
|
+
col.type = getDataType(row[col.prop]);
|
25476
|
+
if (col.type === 'date')
|
25477
|
+
dateCols.push(col.prop);
|
25478
|
+
}
|
25479
|
+
return col;
|
25480
|
+
});
|
25481
|
+
}
|
25482
|
+
// convert date columns into numbers to send to our worker
|
25483
|
+
dateCols.forEach((colName) => {
|
25484
|
+
// coerce any date type;
|
25485
|
+
// Date(), timestamp, valid date string
|
25486
|
+
const coerceDate = new Date(row[colName]) ?? null;
|
25487
|
+
if (!!coerceDate && Number(coerceDate))
|
25488
|
+
row[colName] = Number(coerceDate);
|
25489
|
+
});
|
25490
|
+
row['__index'] = i;
|
25491
|
+
row['__uuid'] = cyrb53(Object.values(row).join());
|
25492
|
+
return row;
|
25493
|
+
});
|
25175
25494
|
store.data.state.rows = rows;
|
25176
25495
|
if (store.general.state.workerId)
|
25177
25496
|
return syncDataToWorker(store.general.state.workerId, rows);
|
@@ -25192,7 +25511,7 @@ async function storeSearch(host, term) {
|
|
25192
25511
|
store.data.state.rows = await workerSearch(store.general.state.workerId, term);
|
25193
25512
|
}
|
25194
25513
|
catch (e) {
|
25195
|
-
console.
|
25514
|
+
console.warn(e);
|
25196
25515
|
}
|
25197
25516
|
}
|
25198
25517
|
async function storeFilter(host, filters) {
|
@@ -25203,7 +25522,7 @@ async function storeFilter(host, filters) {
|
|
25203
25522
|
store.data.state.rows = await workerFilter(store.general.state.workerId, filters);
|
25204
25523
|
}
|
25205
25524
|
catch (e) {
|
25206
|
-
console.
|
25525
|
+
console.warn(e);
|
25207
25526
|
}
|
25208
25527
|
}
|
25209
25528
|
async function storeSort(host, prop, order) {
|
@@ -25214,7 +25533,7 @@ async function storeSort(host, prop, order) {
|
|
25214
25533
|
store.data.state.rows = await workerSort(store.general.state.workerId, prop, order);
|
25215
25534
|
}
|
25216
25535
|
catch (e) {
|
25217
|
-
console.
|
25536
|
+
console.warn(e);
|
25218
25537
|
}
|
25219
25538
|
}
|
25220
25539
|
|
@@ -25311,19 +25630,6 @@ function mergeCellProperties(rowIndex, colIndex, defaultProps) {
|
|
25311
25630
|
return props;
|
25312
25631
|
return mergeProperties(props, extra);
|
25313
25632
|
}
|
25314
|
-
/**
|
25315
|
-
* Renders a cell using a custom renderer if set.
|
25316
|
-
* @param rowIndex - the current row index being rendered
|
25317
|
-
* @param colIndex - the current column index being rendered
|
25318
|
-
* @returns - a JSX node
|
25319
|
-
*/
|
25320
|
-
function cellRender(rowIndex, colIndex) {
|
25321
|
-
const store = fetchStores();
|
25322
|
-
const columns = store.config.state.columns;
|
25323
|
-
const tpl = columns[colIndex]?.cellTemplate;
|
25324
|
-
const model = colDataModel(rowIndex, colIndex);
|
25325
|
-
return tpl ? (tpl(h, model)) : (h(Fragment, null, model.cellModel.toString()));
|
25326
|
-
}
|
25327
25633
|
/**
|
25328
25634
|
* Renders a table header (within a thead) using a custom template if set.
|
25329
25635
|
* @param col - the current column config object
|
@@ -25333,26 +25639,14 @@ function colheadFootRender(col) {
|
|
25333
25639
|
const tpl = col?.colTemplate;
|
25334
25640
|
return tpl ? (tpl(h, col)) : (h(Fragment, null, col.title));
|
25335
25641
|
}
|
25336
|
-
|
25337
|
-
function baseClasses(type, vPinned, toString = false) {
|
25338
|
-
const classes = {
|
25339
|
-
[`${CSSNAMESPACE}__${type}`]: true,
|
25340
|
-
[`${CSSNAMESPACE}__pin`]: !!vPinned,
|
25341
|
-
[`${CSSNAMESPACE}__pin--top`]: vPinned === 'top',
|
25342
|
-
[`${CSSNAMESPACE}__pin--bottom`]: vPinned === 'bottom',
|
25343
|
-
};
|
25344
|
-
if (toString) {
|
25345
|
-
let classString = '';
|
25346
|
-
Object.entries(classes).forEach(([className, on]) => {
|
25347
|
-
if (on)
|
25348
|
-
classString += className + ' ';
|
25349
|
-
});
|
25350
|
-
return classString;
|
25351
|
-
}
|
25352
|
-
return classes;
|
25353
|
-
}
|
25354
25642
|
const stickyHIOs = new WeakMap();
|
25355
25643
|
const stickyVIOs = new WeakMap();
|
25644
|
+
/**
|
25645
|
+
* Adds element to Intersection Observer. Fires when element changes on the x axis
|
25646
|
+
* @param el - an element to observe
|
25647
|
+
* @param pos - the edge to watch (start or end)
|
25648
|
+
* @param cb - callback when an intersection state changes.
|
25649
|
+
*/
|
25356
25650
|
function addHObserver(el, pos, cb) {
|
25357
25651
|
if (stickyHIOs.get(el))
|
25358
25652
|
return;
|
@@ -25367,13 +25661,13 @@ function addHObserver(el, pos, cb) {
|
|
25367
25661
|
!e.isIntersecting;
|
25368
25662
|
}
|
25369
25663
|
if (pos === 'end') {
|
25370
|
-
// console.log('refe', store.general.state.host)
|
25371
25664
|
// TODO - sort these out for RtL
|
25372
25665
|
positions.end =
|
25373
25666
|
e.boundingClientRect.right > e.boundingClientRect.width &&
|
25374
25667
|
!e.isIntersecting;
|
25375
25668
|
}
|
25376
|
-
cb
|
25669
|
+
if (!!cb)
|
25670
|
+
cb(positions);
|
25377
25671
|
}, {
|
25378
25672
|
threshold: [1],
|
25379
25673
|
rootMargin: '1px 0px 100px 0px',
|
@@ -25383,6 +25677,12 @@ function addHObserver(el, pos, cb) {
|
|
25383
25677
|
// dirty fix - wait a tick 'cos nano-size-observer isn't always ready in-time
|
25384
25678
|
setTimeout(() => observer.observe(el), 300);
|
25385
25679
|
}
|
25680
|
+
/**
|
25681
|
+
* Adds element to Intersection Observer. Fires when element changes on the y axis
|
25682
|
+
* @param el - an element to observe
|
25683
|
+
* @param pos - the edge to watch (start or end)
|
25684
|
+
* @param cb - callback when an intersection state changes.
|
25685
|
+
*/
|
25386
25686
|
function addVObserver(el, pos, cb) {
|
25387
25687
|
if (stickyVIOs.get(el))
|
25388
25688
|
return;
|
@@ -25396,11 +25696,14 @@ function addVObserver(el, pos, cb) {
|
|
25396
25696
|
e.boundingClientRect.y - (rootBounds.y + root.scrollTop) < 0 &&
|
25397
25697
|
!e.isIntersecting;
|
25398
25698
|
}
|
25399
|
-
if (pos === 'bottom')
|
25699
|
+
if (pos === 'bottom') {
|
25700
|
+
const boundingClientRect = e.target.getBoundingClientRect();
|
25400
25701
|
positions.bottom =
|
25401
|
-
|
25402
|
-
!e.isIntersecting;
|
25403
|
-
|
25702
|
+
boundingClientRect.height + boundingClientRect.y >
|
25703
|
+
rootBounds.height && !e.isIntersecting;
|
25704
|
+
}
|
25705
|
+
if (!!cb)
|
25706
|
+
cb(positions);
|
25404
25707
|
}, {
|
25405
25708
|
threshold: [1],
|
25406
25709
|
rootMargin: '0px 100px 0px 100px',
|
@@ -25409,64 +25712,183 @@ function addVObserver(el, pos, cb) {
|
|
25409
25712
|
stickyVIOs.set(el, observer);
|
25410
25713
|
requestAnimationFrame(() => observer.observe(el));
|
25411
25714
|
}
|
25412
|
-
|
25413
|
-
|
25414
|
-
|
25415
|
-
|
25416
|
-
|
25417
|
-
|
25418
|
-
|
25419
|
-
|
25420
|
-
|
25421
|
-
|
25422
|
-
|
25423
|
-
|
25424
|
-
|
25715
|
+
function headerPinClasses(type, vPinned, toString = false) {
|
25716
|
+
const classes = {
|
25717
|
+
[`${CSSNAMESPACE}__${type}`]: true,
|
25718
|
+
[`${CSSNAMESPACE}__pin`]: !!vPinned,
|
25719
|
+
[`${CSSNAMESPACE}__pin--top`]: vPinned === 'top',
|
25720
|
+
[`${CSSNAMESPACE}__pin--bottom`]: vPinned === 'bottom',
|
25721
|
+
};
|
25722
|
+
if (toString)
|
25723
|
+
return classListToStr(classes);
|
25724
|
+
return classes;
|
25725
|
+
}
|
25726
|
+
/**
|
25727
|
+
* Turns a class map {'string': boolean} to class string
|
25728
|
+
* @param classes - the class map to convert
|
25729
|
+
* @returns a class string
|
25730
|
+
*/
|
25731
|
+
function classListToStr(classes) {
|
25732
|
+
let classString = '';
|
25733
|
+
Object.entries(classes).forEach(([className, on]) => {
|
25734
|
+
if (on)
|
25735
|
+
classString += className + ' ';
|
25736
|
+
});
|
25737
|
+
return classString;
|
25738
|
+
}
|
25739
|
+
/**
|
25740
|
+
* Detects the current scroll speed as a number.
|
25741
|
+
* Use within a scroll listener
|
25742
|
+
*/
|
25743
|
+
const detectScrollSpeed = (() => {
|
25744
|
+
let lastPos;
|
25745
|
+
let newPos;
|
25746
|
+
let timer;
|
25747
|
+
let delta;
|
25748
|
+
const delay = 60; // in "ms" (higher means lower fidelity )
|
25749
|
+
const clear = () => {
|
25750
|
+
lastPos = null;
|
25751
|
+
delta = 0;
|
25752
|
+
};
|
25753
|
+
clear();
|
25754
|
+
return () => {
|
25755
|
+
newPos = window.scrollY;
|
25756
|
+
if (lastPos != null)
|
25757
|
+
delta = newPos - lastPos;
|
25758
|
+
lastPos = newPos;
|
25759
|
+
window.clearTimeout(timer);
|
25760
|
+
timer = window.setTimeout(clear, delay);
|
25761
|
+
return delta;
|
25762
|
+
};
|
25763
|
+
})();
|
25764
|
+
/**
|
25765
|
+
* Attempts to find the closes scrolling parental element
|
25766
|
+
* @param element - the element from which to traverse up the DOM
|
25767
|
+
* @returns - the closest scrolling parental element
|
25768
|
+
*/
|
25769
|
+
function findScrollParent(element) {
|
25770
|
+
let style = getComputedStyle(element);
|
25771
|
+
const excludeStaticParent = style.position === 'absolute';
|
25772
|
+
const overflowRegex = /(auto|scroll)/;
|
25773
|
+
if (style.position === 'fixed')
|
25774
|
+
return document.documentElement;
|
25775
|
+
for (let parent = element; (parent = parent.parentElement);) {
|
25776
|
+
style = getComputedStyle(parent);
|
25777
|
+
if (excludeStaticParent && style.position === 'static') {
|
25778
|
+
continue;
|
25779
|
+
}
|
25780
|
+
if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX))
|
25781
|
+
return parent;
|
25425
25782
|
}
|
25426
|
-
|
25427
|
-
|
25428
|
-
|
25429
|
-
|
25430
|
-
|
25431
|
-
|
25432
|
-
|
25433
|
-
|
25783
|
+
return document.documentElement;
|
25784
|
+
}
|
25785
|
+
/**
|
25786
|
+
* Checks whether an element is currently viewable within the viewport
|
25787
|
+
* @param el - element to check
|
25788
|
+
* @param percentVisible - the percentage of the element that should be within the viewport
|
25789
|
+
* @returns true if the element's area percentage is visible
|
25790
|
+
*/
|
25791
|
+
function isInViewport(el, percentVisible = 100) {
|
25792
|
+
const r = el.getBoundingClientRect();
|
25793
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
25794
|
+
if (!r.bottom &&
|
25795
|
+
!r.top &&
|
25796
|
+
!r.left &&
|
25797
|
+
!r.right &&
|
25798
|
+
!r.height &&
|
25799
|
+
!r.width &&
|
25800
|
+
!r.x &&
|
25801
|
+
!r.y)
|
25802
|
+
return false;
|
25803
|
+
return !(Math.floor(100 - ((r.top >= 0 ? 0 : r.top) / +-r.height) * 100) <
|
25804
|
+
percentVisible ||
|
25805
|
+
Math.floor(100 - ((r.bottom - windowHeight) / r.height) * 100) <
|
25806
|
+
percentVisible);
|
25807
|
+
}
|
25808
|
+
/**
|
25809
|
+
* Immutable array re-order
|
25810
|
+
* @param from - the index to move from
|
25811
|
+
* @param to - the index to move to
|
25812
|
+
* @param arr - the array to re-order
|
25813
|
+
* @returns - a new, re-orderd array
|
25814
|
+
*/
|
25815
|
+
function arrMove(from, to, arr) {
|
25816
|
+
const newArr = [...arr];
|
25817
|
+
const item = newArr.splice(from, 1)[0];
|
25818
|
+
newArr.splice(to, 0, item);
|
25819
|
+
return newArr;
|
25820
|
+
}
|
25821
|
+
|
25822
|
+
// TABLE HEADERS
|
25823
|
+
// (thead > tr > th, tfoot > tr > th)
|
25824
|
+
let draggingCol;
|
25825
|
+
let draggingColEle;
|
25826
|
+
let dragEnterEle;
|
25827
|
+
let draggingParent;
|
25828
|
+
const TableColHead = ({ column, headRenderer, onColumnSortClick, onColumnPinned, onColumnDrag, onColumnDrop, defaults, }) => {
|
25829
|
+
const store = fetchStores();
|
25830
|
+
// Drag to re-order columns handling
|
25831
|
+
function handleDragStart(e, column) {
|
25832
|
+
draggingCol = column;
|
25833
|
+
draggingColEle = dragEnterEle = e.target;
|
25834
|
+
draggingParent = draggingColEle.closest('.' + `${CSSNAMESPACE}__tr`);
|
25835
|
+
draggingParent.classList.add(`${CSSNAMESPACE}__dragging`);
|
25836
|
+
draggingColEle.classList.add(`${CSSNAMESPACE}__drag--start`);
|
25837
|
+
e.dataTransfer.effectAllowed = 'move';
|
25838
|
+
e.dataTransfer.setData('text/html', draggingColEle.innerHTML);
|
25839
|
+
onColumnDrag(column.prop, draggingColEle);
|
25840
|
+
}
|
25841
|
+
function handleDragEnd() {
|
25842
|
+
draggingParent.classList.remove(`${CSSNAMESPACE}__dragging`);
|
25843
|
+
draggingColEle.classList.remove(`${CSSNAMESPACE}__drag--start`);
|
25844
|
+
draggingParent
|
25845
|
+
.querySelectorAll(`.${CSSNAMESPACE}__drag-mask--active`)
|
25846
|
+
.forEach((el) => {
|
25847
|
+
el.classList.remove(`${CSSNAMESPACE}__drag-mask--active`);
|
25848
|
+
});
|
25849
|
+
draggingColEle = null;
|
25850
|
+
draggingCol = null;
|
25851
|
+
draggingParent = null;
|
25852
|
+
dragEnterEle = null;
|
25434
25853
|
}
|
25435
|
-
|
25436
|
-
|
25437
|
-
|
25438
|
-
|
25439
|
-
|
25440
|
-
|
25441
|
-
|
25854
|
+
function handleDragEnter(e) {
|
25855
|
+
if (dragEnterEle === e.target)
|
25856
|
+
return;
|
25857
|
+
e.preventDefault();
|
25858
|
+
e.stopImmediatePropagation();
|
25859
|
+
e.dataTransfer.dropEffect = 'move';
|
25860
|
+
draggingParent
|
25861
|
+
.querySelectorAll(`.${CSSNAMESPACE}__drag-mask--active`)
|
25862
|
+
.forEach((el) => {
|
25863
|
+
el.classList.remove(`${CSSNAMESPACE}__drag-mask--active`);
|
25442
25864
|
});
|
25443
|
-
|
25444
|
-
|
25445
|
-
|
25446
|
-
|
25447
|
-
if (!!node.vchildren) {
|
25448
|
-
node.vchildren = utils.map(node.vchildren, (cNode) => {
|
25449
|
-
if (['td', 'th'].includes(cNode.vtag.toString())) {
|
25450
|
-
cNode.vattrs = mergeProperties({
|
25451
|
-
class: baseClasses(cNode.vtag.toString(), pinned, true),
|
25452
|
-
ref: (th) => {
|
25453
|
-
addVObserver(th, pinned, onColumnPinned);
|
25454
|
-
},
|
25455
|
-
}, cNode.vattrs);
|
25456
|
-
}
|
25457
|
-
return cNode;
|
25458
|
-
});
|
25459
|
-
}
|
25460
|
-
}
|
25461
|
-
return node;
|
25462
|
-
});
|
25865
|
+
dragEnterEle = e.target;
|
25866
|
+
if (!dragEnterEle.classList.contains(`${CSSNAMESPACE}__drag-mask`)) {
|
25867
|
+
e.dataTransfer.dropEffect = 'none';
|
25868
|
+
return;
|
25463
25869
|
}
|
25464
|
-
|
25870
|
+
dragEnterEle.classList.add(`${CSSNAMESPACE}__drag-mask--active`);
|
25465
25871
|
}
|
25466
|
-
|
25467
|
-
|
25468
|
-
const
|
25469
|
-
|
25872
|
+
function handleDrop(e) {
|
25873
|
+
e.stopPropagation();
|
25874
|
+
const { colName } = this.dataset;
|
25875
|
+
if (colName === draggingCol.prop)
|
25876
|
+
return;
|
25877
|
+
const cols = store.config.state.columns;
|
25878
|
+
let toIndex = cols.findIndex((col) => col.prop === colName);
|
25879
|
+
const fromIndex = cols.findIndex((col) => col === draggingCol);
|
25880
|
+
if (toIndex < fromIndex &&
|
25881
|
+
this.classList.contains(`${CSSNAMESPACE}__drag-mask--end`))
|
25882
|
+
toIndex++;
|
25883
|
+
if (toIndex > fromIndex &&
|
25884
|
+
this.classList.contains(`${CSSNAMESPACE}__drag-mask--start`))
|
25885
|
+
toIndex--;
|
25886
|
+
if (toIndex === fromIndex)
|
25887
|
+
return;
|
25888
|
+
onColumnDrop(draggingCol.prop, store.config.state.columns[toIndex].prop, draggingColEle);
|
25889
|
+
}
|
25890
|
+
// Sort handling
|
25891
|
+
function handleColumnSortClick(e) {
|
25470
25892
|
let order;
|
25471
25893
|
switch (column.order) {
|
25472
25894
|
case 'asc':
|
@@ -25478,7 +25900,15 @@ const TableColHead = ({ column, headRenderer, onColumnOrderClick, onColumnPinned
|
|
25478
25900
|
default:
|
25479
25901
|
order = 'asc';
|
25480
25902
|
}
|
25481
|
-
|
25903
|
+
onColumnSortClick(order, column.prop, e.target.closest('th'));
|
25904
|
+
}
|
25905
|
+
function isSortable() {
|
25906
|
+
return ((!!defaults.sortable && column.sortable !== false) ||
|
25907
|
+
(!defaults.sortable && column.sortable === true));
|
25908
|
+
}
|
25909
|
+
function isDraggable() {
|
25910
|
+
return ((!!defaults.draggable && column.draggable !== false) ||
|
25911
|
+
(!defaults.draggable && column.draggable === true));
|
25482
25912
|
}
|
25483
25913
|
let extraProps = {};
|
25484
25914
|
if (column.columnProperties) {
|
@@ -25486,7 +25916,7 @@ const TableColHead = ({ column, headRenderer, onColumnOrderClick, onColumnPinned
|
|
25486
25916
|
}
|
25487
25917
|
const baseProps = {
|
25488
25918
|
class: {
|
25489
|
-
...
|
25919
|
+
...headerPinClasses('th', headRenderer?.pinned),
|
25490
25920
|
[`${CSSNAMESPACE}__pin--start`]: column.pinned === 'start',
|
25491
25921
|
[`${CSSNAMESPACE}__pin--end`]: column.pinned === 'end',
|
25492
25922
|
[`${CSSNAMESPACE}__ordered`]: !!column.order,
|
@@ -25498,60 +25928,106 @@ const TableColHead = ({ column, headRenderer, onColumnOrderClick, onColumnPinned
|
|
25498
25928
|
if (!content)
|
25499
25929
|
return h(Fragment, null);
|
25500
25930
|
props =
|
25501
|
-
Number(props.
|
25931
|
+
Number(props.colSpan) > 1
|
25502
25932
|
? { ...props, scope: 'colgroup' }
|
25503
25933
|
: { ...props, scope: 'col' };
|
25504
|
-
if (
|
25505
|
-
|
25506
|
-
|
25507
|
-
|
25508
|
-
|
25509
|
-
|
25510
|
-
|
25511
|
-
|
25512
|
-
|
25513
|
-
|
25514
|
-
|
25515
|
-
|
25516
|
-
|
25517
|
-
|
25518
|
-
|
25519
|
-
|
25520
|
-
!!column.filter && h("nano-icon", { name: "light/filter" }),
|
25521
|
-
!!column.order &&
|
25522
|
-
(column.order === 'desc' ? (h("nano-icon", { name: "solid/long-arrow-down" })) : (h("nano-icon", { name: "solid/long-arrow-up" }))),
|
25523
|
-
h("div", { class: `${CSSNAMESPACE}__status-icons` },
|
25524
|
-
h("nano-icon", { name: "light/chevron-down" })))));
|
25934
|
+
if (isSortable()) {
|
25935
|
+
const sort = column.order
|
25936
|
+
? column.order === 'asc'
|
25937
|
+
? 'ascending'
|
25938
|
+
: 'descending'
|
25939
|
+
: 'none';
|
25940
|
+
props = { ...props, 'aria-sort': sort };
|
25941
|
+
}
|
25942
|
+
if (isDraggable()) {
|
25943
|
+
props = {
|
25944
|
+
...props,
|
25945
|
+
draggable: true,
|
25946
|
+
onDragStart: (e) => handleDragStart(e, column),
|
25947
|
+
onDragOver: (e) => e.preventDefault(),
|
25948
|
+
onDragEnd: () => handleDragEnd(),
|
25949
|
+
};
|
25525
25950
|
}
|
25526
25951
|
return (h("th", { ...props, ref: (th) => {
|
25527
25952
|
if (['end', 'start'].includes(column.pinned))
|
25528
25953
|
addHObserver(th, column.pinned, onColumnPinned);
|
25529
25954
|
if (['top', 'bottom'].includes(headRenderer.pinned))
|
25530
25955
|
addVObserver(th, headRenderer.pinned, onColumnPinned);
|
25531
|
-
} },
|
25532
|
-
|
25956
|
+
}, key: column.prop },
|
25957
|
+
isDraggable() && [
|
25958
|
+
h("div", { class: {
|
25959
|
+
[`${CSSNAMESPACE}__drag-mask`]: true,
|
25960
|
+
[`${CSSNAMESPACE}__drag-mask--start`]: true,
|
25961
|
+
}, "data-col-name": column.prop, onDragEnter: handleDragEnter, onDrop: handleDrop, onDragOver: (e) => e.preventDefault() }),
|
25962
|
+
h("div", { class: {
|
25963
|
+
[`${CSSNAMESPACE}__drag-mask`]: true,
|
25964
|
+
[`${CSSNAMESPACE}__drag-mask--end`]: true,
|
25965
|
+
}, "data-col-name": column.prop, onDragEnter: handleDragEnter, onDrop: handleDrop, onDragOver: (e) => e.preventDefault() }),
|
25966
|
+
],
|
25967
|
+
isSortable() ? (h("button", { class: {
|
25968
|
+
[`${CSSNAMESPACE}__order-btn`]: true,
|
25969
|
+
[`${CSSNAMESPACE}__cell-content`]: true,
|
25970
|
+
}, onClick: handleColumnSortClick },
|
25533
25971
|
colheadFootRender(column),
|
25534
|
-
!!column.filter && h("nano-icon", { name: "light/
|
25972
|
+
!!column.filter && h("nano-icon", { name: "light/filter" }),
|
25973
|
+
!!column.order &&
|
25974
|
+
(column.order === 'desc' ? (h("nano-icon", { name: "solid/long-arrow-down" })) : (h("nano-icon", { name: "solid/long-arrow-up" }))),
|
25975
|
+
h("div", { class: `${CSSNAMESPACE}__status-icons` },
|
25976
|
+
h("nano-icon", { name: "light/chevron-down" })))) : (h("div", { class: `${CSSNAMESPACE}__cell-content` },
|
25977
|
+
colheadFootRender(column),
|
25978
|
+
!!column.filter && h("nano-icon", { name: "light/bars-filter" })))));
|
25979
|
+
};
|
25980
|
+
|
25981
|
+
// TABLE CELL
|
25982
|
+
// (tbody > tr > td, tbody > tr > th)
|
25983
|
+
/**
|
25984
|
+
* Renders a cell using a custom renderer if set.
|
25985
|
+
* @param rowIndex - the current row index being rendered
|
25986
|
+
* @param colIndex - the current column index being rendered
|
25987
|
+
* @returns - a JSX node
|
25988
|
+
*/
|
25989
|
+
function cellRender(rowIndex, colIndex) {
|
25990
|
+
const store = fetchStores();
|
25991
|
+
const columns = store.config.state.columns;
|
25992
|
+
const tpl = columns[colIndex]?.cellTemplate;
|
25993
|
+
const model = colDataModel(rowIndex, colIndex);
|
25994
|
+
if (!!model.cellModel && columns[colIndex].type === 'date') {
|
25995
|
+
const d = new Date(model.cellModel);
|
25996
|
+
if (d instanceof Date && !isNaN(d)) {
|
25997
|
+
model.cellModel = !tpl
|
25998
|
+
? `${new Date(model.cellModel).toLocaleDateString()} ${new Date(model.cellModel).toLocaleTimeString()}`
|
25999
|
+
: d;
|
26000
|
+
}
|
26001
|
+
}
|
26002
|
+
return tpl ? (tpl(h, model)) : (h(Fragment, null, model.cellModel?.toString()));
|
26003
|
+
}
|
26004
|
+
const baseCellClasses = (colIndex, toString = false) => {
|
26005
|
+
const store = fetchStores();
|
26006
|
+
const column = store.config.state.columns[colIndex];
|
26007
|
+
const classes = {
|
26008
|
+
[`${CSSNAMESPACE}__td`]: true,
|
26009
|
+
[`${CSSNAMESPACE}__ordered`]: !!column.order,
|
26010
|
+
[`${CSSNAMESPACE}__pin`]: !!column.pinned,
|
26011
|
+
[`${CSSNAMESPACE}__pin--start`]: column.pinned === 'start',
|
26012
|
+
[`${CSSNAMESPACE}__pin--end`]: column.pinned === 'end',
|
26013
|
+
};
|
26014
|
+
if (toString)
|
26015
|
+
return classListToStr(classes);
|
26016
|
+
return classes;
|
25535
26017
|
};
|
25536
26018
|
const TableCell = ({ rowIndex, colIndex, nestedContent, }) => {
|
25537
26019
|
const content = nestedContent || cellRender(rowIndex, colIndex);
|
25538
26020
|
if (!content)
|
25539
26021
|
return h(Fragment, null);
|
26022
|
+
let CellType = 'td';
|
25540
26023
|
const store = fetchStores();
|
25541
26024
|
const column = store.config.state.columns[colIndex];
|
25542
|
-
let CellType = 'td';
|
25543
26025
|
let props = mergeCellProperties(rowIndex, colIndex, {
|
25544
|
-
class:
|
25545
|
-
[`${CSSNAMESPACE}__td`]: true,
|
25546
|
-
[`${CSSNAMESPACE}__ordered`]: !!column.order,
|
25547
|
-
[`${CSSNAMESPACE}__pin`]: !!column.pinned,
|
25548
|
-
[`${CSSNAMESPACE}__pin--start`]: column.pinned === 'start',
|
25549
|
-
[`${CSSNAMESPACE}__pin--end`]: column.pinned === 'end',
|
25550
|
-
},
|
26026
|
+
class: baseCellClasses(colIndex),
|
25551
26027
|
});
|
25552
26028
|
if (column.rowHeader) {
|
25553
26029
|
props =
|
25554
|
-
Number(props.
|
26030
|
+
Number(props.rowSpan) > 1
|
25555
26031
|
? { ...props, scope: 'rowgroup' }
|
25556
26032
|
: { ...props, scope: 'row' };
|
25557
26033
|
CellType = 'th';
|
@@ -25562,62 +26038,113 @@ const TableCell = ({ rowIndex, colIndex, nestedContent, }) => {
|
|
25562
26038
|
h("div", { class: `${CSSNAMESPACE}__cell-content` }, content)));
|
25563
26039
|
};
|
25564
26040
|
|
25565
|
-
const
|
25566
|
-
let
|
25567
|
-
|
25568
|
-
|
25569
|
-
|
25570
|
-
const delay = 60; // in "ms" (higher means lower fidelity )
|
25571
|
-
const clear = () => {
|
25572
|
-
lastPos = null;
|
25573
|
-
delta = 0;
|
26041
|
+
const TableRow = ({ rowRenderer, rowIndex, row, onColumnPinned }, children, utils) => {
|
26042
|
+
let extraProps = {};
|
26043
|
+
const TableCell = ({ header }, children) => {
|
26044
|
+
const cell = h("div", { class: CSSNAMESPACE + '__cell-content' }, children);
|
26045
|
+
return header ? h("th", { scope: "row" }, cell) : h("td", null, cell);
|
25574
26046
|
};
|
25575
|
-
|
25576
|
-
|
25577
|
-
|
25578
|
-
|
25579
|
-
|
25580
|
-
|
25581
|
-
|
25582
|
-
|
25583
|
-
|
26047
|
+
if (!row) {
|
26048
|
+
const model = rowDataModel(rowIndex);
|
26049
|
+
row = model.row;
|
26050
|
+
}
|
26051
|
+
if (rowRenderer?.rowProperties) {
|
26052
|
+
extraProps = rowRenderer.rowProperties({ row, rowIndex }) || extraProps;
|
26053
|
+
}
|
26054
|
+
let pinned;
|
26055
|
+
if (rowRenderer?.pinned && typeof rowRenderer.pinned === 'function') {
|
26056
|
+
pinned = rowRenderer.pinned();
|
26057
|
+
}
|
26058
|
+
const baseProps = { class: headerPinClasses('tr', pinned) };
|
26059
|
+
const props = extraProps ? mergeProperties(baseProps, extraProps) : baseProps;
|
26060
|
+
const tpl = rowRenderer?.template;
|
26061
|
+
if (tpl) {
|
26062
|
+
let toRender = tpl(h, {
|
26063
|
+
renderedRow: (h("tr", { ...props, key: row.__uuid }, children)),
|
26064
|
+
row,
|
26065
|
+
rowIndex,
|
26066
|
+
}, TableCell);
|
26067
|
+
if (Array.isArray(toRender)) {
|
26068
|
+
toRender = utils.map(toRender, (node, i) => {
|
26069
|
+
if (node.vtag === 'tr') {
|
26070
|
+
if (!node.vkey)
|
26071
|
+
node.vkey = `${row.__uuid}_${i}`;
|
26072
|
+
node.vattrs = mergeProperties({ class: headerPinClasses('tr', pinned, true) }, node.vattrs);
|
26073
|
+
if (!!node.vchildren) {
|
26074
|
+
node.vchildren = utils.map(node.vchildren, (cNode, i) => {
|
26075
|
+
if (['td', 'th'].includes(cNode.vtag.toString())) {
|
26076
|
+
cNode.vattrs = mergeProperties({
|
26077
|
+
class: headerPinClasses(cNode.vtag.toString(), pinned, true) + baseCellClasses(i, true),
|
26078
|
+
ref: (th) => {
|
26079
|
+
if ((!!th && pinned === 'top') || pinned === 'bottom')
|
26080
|
+
addVObserver(th, pinned, onColumnPinned);
|
26081
|
+
if (!!th && th.classList.contains('nano-tbl__pin--end'))
|
26082
|
+
addHObserver(th, 'end', onColumnPinned);
|
26083
|
+
if (!!th && th.classList.contains('nano-tbl__pin--start'))
|
26084
|
+
addHObserver(th, 'start', onColumnPinned);
|
26085
|
+
},
|
26086
|
+
}, cNode.vattrs);
|
26087
|
+
}
|
26088
|
+
return cNode;
|
26089
|
+
});
|
26090
|
+
}
|
26091
|
+
}
|
26092
|
+
return node;
|
26093
|
+
});
|
26094
|
+
}
|
26095
|
+
return toRender;
|
26096
|
+
}
|
26097
|
+
return (h("tr", { ...props, key: row.__uuid }, children));
|
26098
|
+
};
|
26099
|
+
const TableHeadFootRow = ({ rowRenderer, onColumnPinned }, children, utils) => {
|
26100
|
+
let extraProps = {};
|
26101
|
+
if (rowRenderer.rowProperties) {
|
26102
|
+
extraProps = rowRenderer.rowProperties() || {};
|
26103
|
+
}
|
26104
|
+
const TableCell = ({ header }, children) => {
|
26105
|
+
const cell = h("div", { class: CSSNAMESPACE + '__cell-content' }, children);
|
26106
|
+
return header !== false ? h("th", { scope: "col" }, cell) : h("td", null, cell);
|
25584
26107
|
};
|
25585
|
-
|
25586
|
-
|
25587
|
-
|
25588
|
-
const
|
25589
|
-
|
25590
|
-
|
25591
|
-
|
25592
|
-
|
25593
|
-
|
25594
|
-
|
25595
|
-
|
26108
|
+
const pinned = rowRenderer.pinned || null;
|
26109
|
+
const baseProps = { class: headerPinClasses('tr', null) };
|
26110
|
+
const props = extraProps ? mergeProperties(baseProps, extraProps) : baseProps;
|
26111
|
+
const tpl = rowRenderer?.template;
|
26112
|
+
if (tpl) {
|
26113
|
+
let toRender = tpl(h, {
|
26114
|
+
renderedRow: h("tr", { ...props }, children),
|
26115
|
+
}, TableCell);
|
26116
|
+
if (Array.isArray(toRender)) {
|
26117
|
+
toRender = utils.map(toRender, (node) => {
|
26118
|
+
if (node.vtag === 'tr') {
|
26119
|
+
node.vattrs = mergeProperties({ class: headerPinClasses('tr', pinned, true) }, node.vattrs);
|
26120
|
+
if (!!node.vchildren) {
|
26121
|
+
node.vchildren = utils.map(node.vchildren, (cNode) => {
|
26122
|
+
if (['td', 'th'].includes(cNode.vtag.toString())) {
|
26123
|
+
cNode.vattrs = mergeProperties({
|
26124
|
+
class: headerPinClasses(cNode.vtag.toString(), pinned, true),
|
26125
|
+
ref: (th) => {
|
26126
|
+
if ((!!th && pinned === 'top') || pinned === 'bottom')
|
26127
|
+
addVObserver(th, pinned, onColumnPinned);
|
26128
|
+
if (!!th && th.classList.contains('nano-tbl__pin--end'))
|
26129
|
+
addHObserver(th, 'end', onColumnPinned);
|
26130
|
+
if (!!th && th.classList.contains('nano-tbl__pin--start'))
|
26131
|
+
addHObserver(th, 'start', onColumnPinned);
|
26132
|
+
},
|
26133
|
+
}, cNode.vattrs);
|
26134
|
+
}
|
26135
|
+
return cNode;
|
26136
|
+
});
|
26137
|
+
}
|
26138
|
+
}
|
26139
|
+
return node;
|
26140
|
+
});
|
25596
26141
|
}
|
25597
|
-
|
25598
|
-
return parent;
|
26142
|
+
return toRender;
|
25599
26143
|
}
|
25600
|
-
return
|
25601
|
-
}
|
25602
|
-
function isInViewport(el, percentVisible = 100) {
|
25603
|
-
const r = el.getBoundingClientRect();
|
25604
|
-
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
25605
|
-
if (!r.bottom &&
|
25606
|
-
!r.top &&
|
25607
|
-
!r.left &&
|
25608
|
-
!r.right &&
|
25609
|
-
!r.height &&
|
25610
|
-
!r.width &&
|
25611
|
-
!r.x &&
|
25612
|
-
!r.y)
|
25613
|
-
return false;
|
25614
|
-
return !(Math.floor(100 - ((r.top >= 0 ? 0 : r.top) / +-r.height) * 100) <
|
25615
|
-
percentVisible ||
|
25616
|
-
Math.floor(100 - ((r.bottom - windowHeight) / r.height) * 100) <
|
25617
|
-
percentVisible);
|
25618
|
-
}
|
26144
|
+
return h("tr", { ...props }, children);
|
26145
|
+
};
|
25619
26146
|
|
25620
|
-
const tableCss = ":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}
|
26147
|
+
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, 30%, 20vw);--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 tbody{will-change:scroll-position;visibility:visible}.nano-tbl tbody.nano-tbl__inactive{visibility:hidden}.nano-tbl th[scope=row]{font-weight:800;margin:0}.nano-tbl__pin{position:sticky;z-index:1}.nano-tbl__pin--start{inset-inline:-1px auto;transition:max-width 0.25s ease;z-index:2}.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{z-index:2;}.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{z-index:3}.sm .nano-tbl__pinned--end .nano-tbl__pin--end::after{opacity:1}.nano-tbl__pin--top{inset-block:-1px auto;z-index:3}.nano-tbl__pinned--top .nano-tbl__pin--top{z-index:4 !important}.nano-tbl__pin--bottom{inset-block:auto -1px;z-index:3}.nano-tbl__pinned--bottom .nano-tbl__pin--bottom{z-index:5 !important}.nano-tbl__pin--top.nano-tbl__pin--start{z-index:4}.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__pin--top.nano-tbl__pin--end{z-index:4}.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__pin--bottom.nano-tbl__pin--start{z-index:4}.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__pin--bottom.nano-tbl__pin--end{z-index:4}.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)}";
|
25621
26148
|
|
25622
26149
|
let id$1 = 0;
|
25623
26150
|
const Table = class extends H {
|
@@ -25628,16 +26155,18 @@ const Table = class extends H {
|
|
25628
26155
|
this.nanoTblReady = createEvent(this, "nanoTblReady", 7);
|
25629
26156
|
this.nanoTblBeforeSort = createEvent(this, "nanoTblBeforeSort", 7);
|
25630
26157
|
this.nanoTblAfterSort = createEvent(this, "nanoTblAfterSort", 7);
|
26158
|
+
this.nanoTblColDrag = createEvent(this, "nanoTblColDrag", 7);
|
26159
|
+
this.nanoTblColDrop = createEvent(this, "nanoTblColDrop", 7);
|
25631
26160
|
this.nanoTblBeforeFilter = createEvent(this, "nanoTblBeforeFilter", 7);
|
25632
26161
|
this.nanoTblAfterFilter = createEvent(this, "nanoTblAfterFilter", 7);
|
25633
26162
|
this.nanoTblBeforeSearch = createEvent(this, "nanoTblBeforeSearch", 7);
|
25634
26163
|
this.nanoTblAfterSearch = createEvent(this, "nanoTblAfterSearch", 7);
|
25635
26164
|
this.debounceSetLoading = (l) => {
|
25636
|
-
this._loading =
|
26165
|
+
this._loading = l;
|
25637
26166
|
};
|
25638
26167
|
this.renderId = 'tbl-' + id$1++;
|
25639
26168
|
this.filters = [];
|
25640
|
-
this.currentFilters = '';
|
26169
|
+
this.currentFilters = '[]';
|
25641
26170
|
this.currentSort = '';
|
25642
26171
|
this.blockIos = new WeakMap();
|
25643
26172
|
this.blockHeights = [];
|
@@ -25645,6 +26174,23 @@ const Table = class extends H {
|
|
25645
26174
|
// Scroll / IO used for hiding / showing blocks
|
25646
26175
|
this.ignoreIO = true;
|
25647
26176
|
this._isReady = false;
|
26177
|
+
this.colDrag = (column) => {
|
26178
|
+
this.nanoTblColDrag.emit({ column });
|
26179
|
+
};
|
26180
|
+
this.colDrop = (fromCol, toCol) => {
|
26181
|
+
const cols = this.store.config.state.columns;
|
26182
|
+
const toIndex = cols.findIndex((col) => col.prop === toCol);
|
26183
|
+
const fromIndex = cols.findIndex((col) => col.prop === fromCol);
|
26184
|
+
const dropEvent = this.nanoTblColDrop.emit({
|
26185
|
+
fromCol,
|
26186
|
+
toCol,
|
26187
|
+
fromIndex,
|
26188
|
+
toIndex,
|
26189
|
+
});
|
26190
|
+
if (dropEvent.defaultPrevented)
|
26191
|
+
return;
|
26192
|
+
this.store.config.state.columns = arrMove(fromIndex, toIndex, cols);
|
26193
|
+
};
|
25648
26194
|
/**
|
25649
26195
|
* Start a sort - can be cancelled by `preventDefault`
|
25650
26196
|
* @param order - column order
|
@@ -25700,7 +26246,7 @@ const Table = class extends H {
|
|
25700
26246
|
// This is a bit gross
|
25701
26247
|
// The Intersection Observer (IO) fires in an incorrect order when the scrolling is very fast
|
25702
26248
|
// i.e. we go past blocks 3, 2, 1 and land on 0, but 3 can fire as 'intersecting' after 0.
|
25703
|
-
// To fix that, we check - for
|
26249
|
+
// To fix that, we check - for realzies - if the block IS visible.
|
25704
26250
|
// BUT that test is not as sensitive to a block being visible via the IO,
|
25705
26251
|
// so doesn't always fire if scrolling slowly
|
25706
26252
|
// *sigh*
|
@@ -25733,6 +26279,10 @@ const Table = class extends H {
|
|
25733
26279
|
this.tableEle.classList.toggle(`${CSSNAMESPACE}__pinned--${key}`, applied);
|
25734
26280
|
});
|
25735
26281
|
};
|
26282
|
+
this.handleResizeChange = (e) => {
|
26283
|
+
this.tableWrapperEle.className = '';
|
26284
|
+
this.tableWrapperEle.classList.add(...(e.target.className + ' ' + `${CSSNAMESPACE}__wrap`).split(' '));
|
26285
|
+
};
|
25736
26286
|
this.type = 'table';
|
25737
26287
|
this.caption = undefined;
|
25738
26288
|
this.showCaption = false;
|
@@ -25748,6 +26298,8 @@ const Table = class extends H {
|
|
25748
26298
|
this.searchTerm = undefined;
|
25749
26299
|
this.customFilterFn = undefined;
|
25750
26300
|
this.customSortFn = undefined;
|
26301
|
+
this.defaultSort = true;
|
26302
|
+
this.defaultColDraggable = false;
|
25751
26303
|
this.blocks = [];
|
25752
26304
|
this.activeBlocks = [0, 1, 2];
|
25753
26305
|
this.measureHeight = 0;
|
@@ -25774,9 +26326,8 @@ const Table = class extends H {
|
|
25774
26326
|
this.currentFilters = '';
|
25775
26327
|
this.currentSort = '';
|
25776
26328
|
await this.columnInit();
|
25777
|
-
if (!this.isReady)
|
26329
|
+
if (!this.isReady)
|
25778
26330
|
this.setInitialBlockDimension();
|
25779
|
-
}
|
25780
26331
|
this.loading = false;
|
25781
26332
|
});
|
25782
26333
|
}
|
@@ -25824,6 +26375,14 @@ const Table = class extends H {
|
|
25824
26375
|
this.filters = [];
|
25825
26376
|
return this.filterStart(filters, additive);
|
25826
26377
|
}
|
26378
|
+
/** Remove filters from a column
|
26379
|
+
* @param columnNames - the filters to apply
|
26380
|
+
* @returns a promise which resolves when complete
|
26381
|
+
*/
|
26382
|
+
async removeFilters(columnNames) {
|
26383
|
+
this.filters = this.filters.filter((f) => !columnNames.includes(f.prop));
|
26384
|
+
return this.filterStart();
|
26385
|
+
}
|
25827
26386
|
// uses the first 'tr' of an active block as our yard stick
|
25828
26387
|
set measureEle(el) {
|
25829
26388
|
if (!el)
|
@@ -25843,13 +26402,13 @@ const Table = class extends H {
|
|
25843
26402
|
if (this.isReady)
|
25844
26403
|
requestAnimationFrame(() => this.handleReady());
|
25845
26404
|
}
|
26405
|
+
// Private Logic
|
25846
26406
|
// Listeners
|
25847
26407
|
scrollListener() {
|
25848
26408
|
// see explanation in `setupBlockIO`
|
25849
26409
|
const speed = detectScrollSpeed();
|
25850
26410
|
this.scrollSpeed = speed < 0 ? speed * -1 : speed;
|
25851
26411
|
}
|
25852
|
-
// Logic
|
25853
26412
|
handleReady() {
|
25854
26413
|
const hash = window.location.hash;
|
25855
26414
|
if (hash.length > 1) {
|
@@ -26083,19 +26642,20 @@ const Table = class extends H {
|
|
26083
26642
|
processSlots() {
|
26084
26643
|
// see if we have slot content
|
26085
26644
|
if (!this.caption && !this.host.querySelector('[slot="caption"]')) {
|
26086
|
-
console.error('For accessibility you must set a `
|
26645
|
+
console.error('For accessibility you must set a `caption` prop or use the `caption` slot');
|
26087
26646
|
}
|
26088
26647
|
}
|
26089
26648
|
// Component lifecycle
|
26090
26649
|
async componentWillLoad() {
|
26650
|
+
this.scrollParent = findScrollParent(this.host);
|
26091
26651
|
this.store = await generateStore(this.host, this.columns, this.scrollParent);
|
26092
26652
|
await this.handleRowsChange();
|
26093
26653
|
this.processSlots();
|
26094
|
-
this.setBlocks();
|
26095
26654
|
this.store.data.onChange('rows', () => this.setBlocks());
|
26655
|
+
this.setBlocks();
|
26096
26656
|
}
|
26097
26657
|
connectedCallback() {
|
26098
|
-
|
26658
|
+
this.scrollParent = findScrollParent(this.host);
|
26099
26659
|
}
|
26100
26660
|
componentDidLoad() {
|
26101
26661
|
this.setInitialBlockDimension();
|
@@ -26115,15 +26675,18 @@ const Table = class extends H {
|
|
26115
26675
|
}
|
26116
26676
|
render() {
|
26117
26677
|
this.blockElements = [];
|
26118
|
-
return (h$1(Host$1, null, h$1("div", { class: `${CSSNAMESPACE}__top-anchor`, ref: (a) => (this.topAnchorEle = a) }, "\u00A0"), h$1("nano-resize-observe", { "aria-labelledby": 'table-caption-' + this.renderId, tabindex: this.type === 'grid' ? '0' : undefined, states: "576w sm, 768w md", class: "sm md" }, h$1("div", { class: `${CSSNAMESPACE}__wrap
|
26678
|
+
return (h$1(Host$1, null, h$1("div", { class: `${CSSNAMESPACE}__top-anchor`, ref: (a) => (this.topAnchorEle = a) }, "\u00A0"), h$1("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$1("div", { class: `${CSSNAMESPACE}__wrap sm md`, ref: (div) => (this.tableWrapperEle = div) }, h$1("nano-progress-bar", { indeterminate: true, class: {
|
26119
26679
|
[`${CSSNAMESPACE}__progress-bar`]: true,
|
26120
26680
|
[`${CSSNAMESPACE}__progress-bar--show`]: this._loading,
|
26121
26681
|
} }), h$1("table", { role: this.type === 'grid' ? 'grid' : undefined, "aria-readonly": this.type === 'table' ? 'true' : undefined, "aria-rowcount": this.store.data.state.rows.length, "aria-colcount": this.store.config.state.columns.length, class: `${CSSNAMESPACE}`, ref: (tbl) => (this.tableEle = tbl) }, h$1("caption", { class: {
|
26122
26682
|
[`${CSSNAMESPACE}__caption`]: true,
|
26123
26683
|
[`${CSSNAMESPACE}__caption--hide`]: !this.showCaption,
|
26124
26684
|
}, id: 'table-caption-' + this.renderId }, h$1("slot", { name: "caption" }, this.caption)), h$1("thead", null, h$1(TableHeadFootRow, { rowRenderer: this.headRender, onColumnPinned: this.handleColumnPinned }, this.store.config.state.columns.map((colModel) => [
|
26125
|
-
h$1(TableColHead, { column: colModel, headRenderer: this.headRender,
|
26126
|
-
|
26685
|
+
h$1(TableColHead, { column: colModel, headRenderer: this.headRender, onColumnSortClick: this.sortStart, onColumnPinned: this.handleColumnPinned, onColumnDrag: this.colDrag, onColumnDrop: this.colDrop, defaults: {
|
26686
|
+
sortable: this.defaultSort,
|
26687
|
+
draggable: this.defaultColDraggable,
|
26688
|
+
} }),
|
26689
|
+
]))), this._loading && !this.blocks.length && (h$1("tbody", { class: `${CSSNAMESPACE}__active` }, [...Array(10).keys()].map((rowIndex) => (h$1("tr", null, this.store.config.state.columns.map((_colModel, colIndex) => (h$1(TableCell, { rowIndex: rowIndex, colIndex: colIndex, nestedContent: h$1("nano-skeleton", null) })))))))), !this._loading && !this.blocks.length && (h$1("tr", null, h$1("th", { class: `${CSSNAMESPACE}__th`, colSpan: this.store.config.state.columns.length }, h$1("div", { class: "nano-tbl__cell-content nano-tbl__cell-content--no-result" }, h$1("slot", { name: "no-results" }, "No results found"))))), this.blocks.map((block, blockIndex) => (h$1("tbody", { key: block.__uuid, id: `tbody-${this.renderId}-${blockIndex}`, ref: (tb) => {
|
26127
26690
|
this.blockElements.push(tb);
|
26128
26691
|
this.setupBlockIO(tb, blockIndex);
|
26129
26692
|
}, class: {
|
@@ -26131,15 +26694,18 @@ const Table = class extends H {
|
|
26131
26694
|
[`${CSSNAMESPACE}__active`]: this.activeBlocks.includes(blockIndex),
|
26132
26695
|
} }, this.activeBlocks.includes(blockIndex) ? (block.rows.map((row, i) => {
|
26133
26696
|
const rowIndex = blockIndex > 0 ? blockIndex * this.perBlock + i : i;
|
26134
|
-
return (h$1(TableRow, { rowRenderer: this.rowRender, row: row }, this.store.config.state.columns.map((_colModel, colIndex) => (h$1(TableCell, { rowIndex: rowIndex, colIndex: colIndex })))));
|
26697
|
+
return (h$1(TableRow, { rowRenderer: this.rowRender, row: row, rowIndex: rowIndex }, this.store.config.state.columns.map((_colModel, colIndex) => (h$1(TableCell, { rowIndex: rowIndex, colIndex: colIndex })))));
|
26135
26698
|
})) : (h$1("td", { colSpan: this.store.config.state.columns.length, style: {
|
26136
26699
|
height: this.getBlockHeight(blockIndex),
|
26137
26700
|
} }))))), this.showFooter && (h$1("tfoot", null, h$1(TableHeadFootRow, { rowRenderer: this.footRender, onColumnPinned: this.handleColumnPinned }, this.store.config.state.columns.map((colModel) => [
|
26138
|
-
h$1(TableColHead, { column: colModel, headRenderer: this.footRender, onColumnPinned: this.handleColumnPinned,
|
26701
|
+
h$1(TableColHead, { column: colModel, headRenderer: this.footRender, onColumnPinned: this.handleColumnPinned, onColumnSortClick: this.sortStart, defaults: {
|
26702
|
+
sortable: this.defaultSort,
|
26703
|
+
draggable: this.defaultColDraggable,
|
26704
|
+
} }),
|
26139
26705
|
]))))), !!this.blocks.length && (h$1("nano-spinner", { type: "circle", class: {
|
26140
26706
|
[`${CSSNAMESPACE}__spinner`]: true,
|
26141
26707
|
[`${CSSNAMESPACE}__spinner--show`]: this._loading,
|
26142
|
-
} })))))
|
26708
|
+
} })))));
|
26143
26709
|
}
|
26144
26710
|
get host() { return this; }
|
26145
26711
|
static get watchers() { return {
|
@@ -26332,6 +26898,7 @@ const NanoCheckboxGroup = /*@__PURE__*/proxyCustomElement(CheckboxGroup, [6,"nan
|
|
26332
26898
|
const NanoDatalist = /*@__PURE__*/proxyCustomElement(DataList, [1,"nano-datalist",{"selected":[1040],"dropDownConfig":[6160],"options":[16],"input":[1],"type":[1],"activeOptions":[2064],"open":[1028],"disableFilter":[4,"disable-filter"],"disabled":[4],"actvOptEles":[32],"connectedInput":[32],"inputLabel":[32],"hasNoResult":[32],"shouldOpen":[32],"canOpen":[32],"optionIds":[32]}]);
|
26333
26899
|
const NanoDateInput = /*@__PURE__*/proxyCustomElement(DateInput, [6,"nano-date-input",{"invalid":[2564],"validityMessage":[2049,"validity-message"],"helperText":[4,"helper-text"],"helperTextFormat":[16],"floatLabel":[4,"float-label"],"name":[1],"readonly":[4],"size":[2],"form":[1],"firstDayOfWeek":[2,"first-day-of-week"],"localization":[16],"disabled":[4],"color":[1],"autofocus":[4],"clearInput":[4,"clear-input"],"label":[1],"placeholder":[1025],"value":[1537],"validateOn":[1,"validate-on"],"showInlineError":[516,"show-inline-error"],"dateOrder":[1,"date-order"],"required":[4],"min":[1],"max":[1],"hideLabel":[4,"hide-label"],"picker":[4],"initialPickerDate":[1,"initial-picker-date"],"pickerOpen":[1540,"picker-open"],"closeAfterPicked":[4,"close-after-picked"],"dropDownConfig":[6160],"dateValue":[2064],"isDateDisabled":[16],"pattern":[32],"inputValue":[32],"_invalid":[32]}]);
|
26334
26900
|
const NanoDatePicker = /*@__PURE__*/proxyCustomElement(DatePicker, [1,"nano-date-picker",{"selectedDate":[1025,"selected-date"],"min":[1],"max":[1],"firstDayOfWeek":[2,"first-day-of-week"],"localization":[16],"color":[1],"isDateDisabled":[16],"isModal":[4,"is-modal"],"firstFocusEle":[16],"activeFocus":[32],"focusedDay":[32]}]);
|
26901
|
+
const NanoDemo = /*@__PURE__*/proxyCustomElement(Demo, [1,"nano-demo"]);
|
26335
26902
|
const NanoDetails = /*@__PURE__*/proxyCustomElement(Details, [1,"nano-details",{"label":[1],"open":[1540],"noHandle":[4,"no-handle"],"iconRotation":[2,"icon-rotation"],"color":[1],"isLoading":[32]}]);
|
26336
26903
|
const NanoDialog = /*@__PURE__*/proxyCustomElement(Dialog, [1,"nano-dialog",{"showRibbon":[4,"show-ribbon"],"open":[1540],"label":[1],"noHeader":[4,"no-header"],"noFooter":[4,"no-footer"],"noUserDismiss":[4,"no-user-dismiss"],"storeId":[1,"store-id"],"storeMethod":[1,"store-method"],"hoist":[4],"isVisible":[32],"noDismiss":[32],"hasFooter":[32]}]);
|
26337
26904
|
const NanoDrawer = /*@__PURE__*/proxyCustomElement(Drawer, [1,"nano-drawer",{"open":[1540],"label":[1],"placement":[1],"contained":[4],"noHeader":[4,"no-header"],"type":[1],"contentSelector":[1,"content-selector"],"hasFooter":[32],"isVisible":[32]}]);
|
@@ -26366,7 +26933,7 @@ const NanoSticker = /*@__PURE__*/proxyCustomElement(Sticker, [1,"nano-sticker",{
|
|
26366
26933
|
const NanoTab = /*@__PURE__*/proxyCustomElement(Tab, [1,"nano-tab",{"panel":[513],"active":[516],"disabled":[516],"closable":[4]}]);
|
26367
26934
|
const NanoTabContent = /*@__PURE__*/proxyCustomElement(TabPanel, [1,"nano-tab-content",{"name":[513],"active":[516]}]);
|
26368
26935
|
const NanoTabGroup = /*@__PURE__*/proxyCustomElement(TabGroup, [1,"nano-tab-group",{"placement":[1],"noScrollControls":[4,"no-scroll-controls"],"color":[1],"storeId":[1,"store-id"],"storeMethod":[1,"store-method"],"disableSwipe":[4,"disable-swipe"],"hasScrollControls":[32],"hideControlRight":[32],"hideControlLeft":[32],"tab":[32]},[[0,"nanoTabClose","handleTabClose"]]]);
|
26369
|
-
const NanoTable = /*@__PURE__*/proxyCustomElement(Table, [4,"nano-table",{"type":[1],"caption":[1],"showCaption":[4,"show-caption"],"loading":[6148],"placeholderSize":[2,"placeholder-size"],"rows":[16],"columns":[1040],"headRender":[16],"rowRender":[16],"footRender":[16],"showFooter":[4,"show-footer"],"perBlock":[2,"per-block"],"blocksLength":[2050,"blocks-length"],"searchTerm":[1,"search-term"],"customFilterFn":[16],"customSortFn":[16],"_loading":[32],"blocks":[32],"activeBlocks":[32],"measureHeight":[32]},[[9,"scroll","scrollListener"]]]);
|
26936
|
+
const NanoTable = /*@__PURE__*/proxyCustomElement(Table, [4,"nano-table",{"type":[1],"caption":[1],"showCaption":[4,"show-caption"],"loading":[6148],"placeholderSize":[2,"placeholder-size"],"rows":[16],"columns":[1040],"headRender":[16],"rowRender":[16],"footRender":[16],"showFooter":[4,"show-footer"],"perBlock":[2,"per-block"],"blocksLength":[2050,"blocks-length"],"searchTerm":[1,"search-term"],"customFilterFn":[16],"customSortFn":[16],"defaultSort":[4,"default-sort"],"defaultColDraggable":[4,"default-col-draggable"],"_loading":[32],"blocks":[32],"activeBlocks":[32],"measureHeight":[32]},[[9,"scroll","scrollListener"]]]);
|
26370
26937
|
const NanoTooltip = /*@__PURE__*/proxyCustomElement(Tooltip, [1,"nano-tooltip",{"content":[1],"placement":[1],"disabled":[4],"distance":[2],"open":[1540],"skidding":[2],"trigger":[1]}]);
|
26371
26938
|
const defineCustomElements = (opts) => {
|
26372
26939
|
if (typeof customElements !== 'undefined') {
|
@@ -26384,6 +26951,7 @@ const defineCustomElements = (opts) => {
|
|
26384
26951
|
NanoDatalist,
|
26385
26952
|
NanoDateInput,
|
26386
26953
|
NanoDatePicker,
|
26954
|
+
NanoDemo,
|
26387
26955
|
NanoDetails,
|
26388
26956
|
NanoDialog,
|
26389
26957
|
NanoDrawer,
|
@@ -28515,7 +29083,7 @@ const index = /*#__PURE__*/Object.freeze({
|
|
28515
29083
|
|
28516
29084
|
const workerName = 'table.worker';
|
28517
29085
|
const workerMsgId = 'stencil.table.worker';
|
28518
|
-
const workerPath = /*@__PURE__*/new URL('./assets/table.worker-
|
29086
|
+
const workerPath = /*@__PURE__*/new URL('./assets/table.worker-e9fb087e.js', import.meta.url).href;
|
28519
29087
|
const blob = new Blob(['importScripts("' + workerPath + '")'], { type: 'text/javascript' });
|
28520
29088
|
const url = URL.createObjectURL(blob);
|
28521
29089
|
const worker = /*@__PURE__*/createWorker(url, workerName, workerMsgId);
|
@@ -28529,6 +29097,6 @@ const table_worker = /*#__PURE__*/Object.freeze({
|
|
28529
29097
|
worker: worker
|
28530
29098
|
});
|
28531
29099
|
|
28532
|
-
export { NanoAccordion, NanoAlert, NanoAlgolia, NanoAlgoliaFilter, NanoAlgoliaInput, NanoAlgoliaPagination, NanoAlgoliaResults, NanoAspectRatio, NanoCheckbox, NanoCheckboxGroup, NanoDatalist, NanoDateInput, NanoDatePicker, NanoDetails, NanoDialog, NanoDrawer, NanoDropdown, NanoFieldValidator, NanoFileUpload, NanoGlobalNav, NanoGlobalNavUserProfile, NanoGlobalSearchResults, NanoGrid, NanoGridItem, NanoHero, NanoIcon, NanoIconButton, NanoImg, NanoInput, NanoMenu, NanoMenuDrawer, NanoNavItem, NanoOption, NanoProgressBar, NanoRange, NanoRating, NanoResizeObserve, NanoSelect, NanoSkeleton, NanoSlide, NanoSlides, NanoSpinner, NanoSplitPane, NanoSticker, NanoTab, NanoTabContent, NanoTabGroup, NanoTable, NanoTooltip, defineCustomElements, nanoCreateDialog, debounce$2 as nanoDebounce, getTabbableElements as nanoGetTabElements, nanoShowAlert, nanoShowToast, throttle as nanoThrottle, setAssetPath, setPlatformOptions };
|
29100
|
+
export { NanoAccordion, NanoAlert, NanoAlgolia, NanoAlgoliaFilter, NanoAlgoliaInput, NanoAlgoliaPagination, NanoAlgoliaResults, NanoAspectRatio, NanoCheckbox, NanoCheckboxGroup, NanoDatalist, NanoDateInput, NanoDatePicker, NanoDemo, NanoDetails, NanoDialog, NanoDrawer, NanoDropdown, NanoFieldValidator, NanoFileUpload, NanoGlobalNav, NanoGlobalNavUserProfile, NanoGlobalSearchResults, NanoGrid, NanoGridItem, NanoHero, NanoIcon, NanoIconButton, NanoImg, NanoInput, NanoMenu, NanoMenuDrawer, NanoNavItem, NanoOption, NanoProgressBar, NanoRange, NanoRating, NanoResizeObserve, NanoSelect, NanoSkeleton, NanoSlide, NanoSlides, NanoSpinner, NanoSplitPane, NanoSticker, NanoTab, NanoTabContent, NanoTabGroup, NanoTable, NanoTooltip, defineCustomElements, nanoCreateDialog, debounce$2 as nanoDebounce, getTabbableElements as nanoGetTabElements, nanoShowAlert, nanoShowToast, throttle as nanoThrottle, setAssetPath, setPlatformOptions };
|
28533
29101
|
|
28534
29102
|
//# sourceMappingURL=index.js.map
|