@nanoporetech-digital/components 6.0.0 → 6.1.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 +29 -0
- package/dist/cjs/index-browser.cjs-d4554470.js +39 -0
- package/dist/cjs/index-browser.cjs-d4554470.js.map +1 -0
- package/dist/cjs/nano-algolia.cjs.entry.js +8 -3
- package/dist/cjs/nano-algolia.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-global-nav.cjs.entry.js +24 -25
- package/dist/cjs/nano-global-nav.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-global-search-results.cjs.entry.js +60 -28
- package/dist/cjs/nano-global-search-results.cjs.entry.js.map +1 -1
- package/dist/cjs/{nano-table-de76385b.js → nano-table-6f48a747.js} +2 -2
- package/dist/cjs/{nano-table-de76385b.js.map → nano-table-6f48a747.js.map} +1 -1
- package/dist/cjs/nano-table.cjs.entry.js +1 -1
- package/dist/cjs/search-insights-b2bb12bd.js +50 -0
- package/dist/cjs/search-insights-b2bb12bd.js.map +1 -0
- package/dist/cjs/{table.worker-1f138ea9.js → table.worker-f3e54773.js} +2 -2
- package/dist/cjs/table.worker-f3e54773.js.map +1 -0
- package/dist/collection/components/algolia/algolia-interface.js.map +1 -1
- package/dist/collection/components/algolia/algolia.js +8 -3
- package/dist/collection/components/algolia/algolia.js.map +1 -1
- package/dist/collection/components/algolia/lib/template.js +2 -2
- package/dist/collection/components/algolia/lib/template.js.map +1 -1
- package/dist/collection/components/global-nav/global-nav-interface.js.map +1 -1
- package/dist/collection/components/global-nav/global-nav.js +25 -25
- package/dist/collection/components/global-nav/global-nav.js.map +1 -1
- package/dist/collection/components/global-search-results/global-search-results.js +62 -27
- package/dist/collection/components/global-search-results/global-search-results.js.map +1 -1
- package/dist/collection/utils/search-insights.js +46 -0
- package/dist/collection/utils/search-insights.js.map +1 -0
- package/dist/components/algolia.js +8 -3
- package/dist/components/algolia.js.map +1 -1
- package/dist/components/index-browser.cjs.js +37 -0
- package/dist/components/index-browser.cjs.js.map +1 -0
- package/dist/components/nano-global-nav.js +24 -25
- package/dist/components/nano-global-nav.js.map +1 -1
- package/dist/components/nano-global-search-results.js +60 -28
- package/dist/components/nano-global-search-results.js.map +1 -1
- package/dist/components/search-insights.js +48 -0
- package/dist/components/search-insights.js.map +1 -0
- package/dist/esm/index-browser.cjs-bf702094.js +37 -0
- package/dist/esm/index-browser.cjs-bf702094.js.map +1 -0
- package/dist/esm/nano-algolia.entry.js +8 -3
- package/dist/esm/nano-algolia.entry.js.map +1 -1
- package/dist/esm/nano-global-nav.entry.js +24 -25
- package/dist/esm/nano-global-nav.entry.js.map +1 -1
- package/dist/esm/nano-global-search-results.entry.js +60 -28
- package/dist/esm/nano-global-search-results.entry.js.map +1 -1
- package/dist/esm/{nano-table-60d90a6b.js → nano-table-fc01a927.js} +2 -2
- package/dist/esm/{nano-table-60d90a6b.js.map → nano-table-fc01a927.js.map} +1 -1
- package/dist/esm/nano-table.entry.js +1 -1
- package/dist/esm/search-insights-f64a6b4c.js +48 -0
- package/dist/esm/search-insights-f64a6b4c.js.map +1 -0
- package/dist/esm/{table.worker-326f51a7.js → table.worker-c70f6379.js} +2 -2
- package/dist/esm/table.worker-c70f6379.js.map +1 -0
- package/dist/nano-components/index-browser.cjs-bf702094.js +5 -0
- package/dist/nano-components/index-browser.cjs-bf702094.js.map +1 -0
- package/dist/nano-components/nano-algolia.entry.js +1 -1
- package/dist/nano-components/nano-algolia.entry.js.map +1 -1
- package/dist/nano-components/nano-global-nav.entry.js +1 -1
- package/dist/nano-components/nano-global-nav.entry.js.map +1 -1
- package/dist/nano-components/nano-global-search-results.entry.js +1 -1
- package/dist/nano-components/nano-global-search-results.entry.js.map +1 -1
- package/dist/nano-components/{nano-table-60d90a6b.js → nano-table-fc01a927.js} +2 -2
- package/dist/nano-components/nano-table.entry.js +1 -1
- package/dist/nano-components/search-insights-f64a6b4c.js +5 -0
- package/dist/nano-components/search-insights-f64a6b4c.js.map +1 -0
- package/dist/nano-components/{table.worker-326f51a7.js → table.worker-c70f6379.js} +2 -2
- package/dist/types/components/algolia/algolia-interface.d.ts +2 -1
- package/dist/types/components/algolia/algolia.d.ts +7 -1
- package/dist/types/components/global-nav/global-nav-interface.d.ts +1 -0
- package/dist/types/components/global-nav/global-nav.d.ts +2 -6
- package/dist/types/components/global-search-results/global-search-results.d.ts +15 -7
- package/dist/types/components.d.ts +4 -1
- package/dist/types/interface.d.ts +1 -0
- package/dist/types/utils/search-insights.d.ts +22 -0
- package/docs-json.json +2 -2
- package/hydrate/index.js +162 -47
- package/package.json +3 -2
- package/dist/cjs/table.worker-1f138ea9.js.map +0 -1
- package/dist/esm/table.worker-326f51a7.js.map +0 -1
- /package/dist/nano-components/{nano-table-60d90a6b.js.map → nano-table-fc01a927.js.map} +0 -0
- /package/dist/nano-components/{table.worker-326f51a7.js.map → table.worker-c70f6379.js.map} +0 -0
@@ -6,6 +6,7 @@ import { a as algoliasearch } from './algoliasearch-lite.esm.browser-d71a28dc.js
|
|
6
6
|
import { C as ComponentStore } from './component-store-486d9d7a.js';
|
7
7
|
import { d as debounce } from './throttle-ac4fcefa.js';
|
8
8
|
import { d as displayTransition } from './transitions-bd15e312.js';
|
9
|
+
import { s as searchInsight } from './search-insights-f64a6b4c.js';
|
9
10
|
|
10
11
|
async function clientFetch(url, { body, ...customConfig } = {}) {
|
11
12
|
const headers = {
|
@@ -156,7 +157,7 @@ const GlobalNav = class {
|
|
156
157
|
return false;
|
157
158
|
this.userMenuOpen = false;
|
158
159
|
};
|
159
|
-
// Search bar
|
160
|
+
// Search bar open / closed
|
160
161
|
this.onSearchBtnClick = (ev) => {
|
161
162
|
ev.preventDefault();
|
162
163
|
this.searchBarShown ? this.searchbarHide() : this.searchbarShow();
|
@@ -420,6 +421,7 @@ const GlobalNav = class {
|
|
420
421
|
this.cartUrl = null;
|
421
422
|
this.msgUrl = null;
|
422
423
|
this.assessSlottedContent = debounce(this.assessSlottedContent.bind(this), 10);
|
424
|
+
this.handleBarResize = debounce(this.handleBarResize.bind(this), 200);
|
423
425
|
}
|
424
426
|
handleMyAccountData() {
|
425
427
|
if (!this.myAccountData)
|
@@ -531,6 +533,11 @@ const GlobalNav = class {
|
|
531
533
|
return;
|
532
534
|
this.algoliaClient = algoliasearch(this.searchAppId, this.searchApiKey);
|
533
535
|
this.addAlgoliaIndeces();
|
536
|
+
// setup algolia analytics
|
537
|
+
searchInsight.init(this.searchAppId, this.searchApiKey).then(() => {
|
538
|
+
if (this.myAccountUser)
|
539
|
+
searchInsight.setUser(this.myAccountUser.uuid);
|
540
|
+
});
|
534
541
|
}
|
535
542
|
/** Public facing set of Algolia indices. Add to any indices we may already have (e.g. from MyAccount) */
|
536
543
|
addIndeces() {
|
@@ -594,7 +601,8 @@ const GlobalNav = class {
|
|
594
601
|
// Global DOM Events
|
595
602
|
/**
|
596
603
|
* 1) Reset threshold (item fit breakpoint) when screen is bigger than before.
|
597
|
-
* 2)
|
604
|
+
* 2) Assess the all threshold / breakpoints to see if content fits
|
605
|
+
* 3) Hide search bar whenever we resize
|
598
606
|
*/
|
599
607
|
onWindowResize() {
|
600
608
|
if (this.threshold < THRESHOLDLIMIT && window.innerWidth > this.currSize) {
|
@@ -602,6 +610,7 @@ const GlobalNav = class {
|
|
602
610
|
}
|
603
611
|
this.currSize = window.innerWidth;
|
604
612
|
this.searchbarHide();
|
613
|
+
this.handleBarResize();
|
605
614
|
}
|
606
615
|
// Burger / Overflow Menu
|
607
616
|
/* listen to nav-item secondary open / close events primarily for resizing the menu */
|
@@ -666,7 +675,7 @@ const GlobalNav = class {
|
|
666
675
|
this.el.focus();
|
667
676
|
}
|
668
677
|
}
|
669
|
-
searchbarShow() {
|
678
|
+
async searchbarShow() {
|
670
679
|
this.searchBarShown = true;
|
671
680
|
this.searchBarEl.addEventListener('transitionend', this.onSearchBarShown);
|
672
681
|
this.searchBarEl.style.display = 'block';
|
@@ -704,6 +713,7 @@ const GlobalNav = class {
|
|
704
713
|
this.algoliaSearchResults = null;
|
705
714
|
const queries = this.internalSearchIndeces.map((index) => {
|
706
715
|
return {
|
716
|
+
clickAnalytics: true,
|
707
717
|
attributesToSnippet: ['body:5', 'title:8'],
|
708
718
|
indexName: index.index,
|
709
719
|
query: this.searchValInternal,
|
@@ -753,7 +763,7 @@ const GlobalNav = class {
|
|
753
763
|
this.threshold--;
|
754
764
|
setTimeout(() => {
|
755
765
|
resolve();
|
756
|
-
},
|
766
|
+
}, 200);
|
757
767
|
});
|
758
768
|
};
|
759
769
|
// Decrease the threshold until content fits
|
@@ -800,20 +810,6 @@ const GlobalNav = class {
|
|
800
810
|
});
|
801
811
|
});
|
802
812
|
}
|
803
|
-
/**
|
804
|
-
* Attach the ResizeObserver - from which all threshold / breakpoint logic hinges
|
805
|
-
*/
|
806
|
-
attachResizeObserver() {
|
807
|
-
if (this.resizeObserver || !this.mainBarDiv)
|
808
|
-
return;
|
809
|
-
const ro = (this.resizeObserver = new ResizeObserver(() => {
|
810
|
-
if (this.mainBarDiv.scrollWidth <= this.mainBarDiv.parentElement.clientWidth) {
|
811
|
-
return;
|
812
|
-
}
|
813
|
-
this.handleBarResize();
|
814
|
-
}));
|
815
|
-
ro.observe(this.mainBarDiv);
|
816
|
-
}
|
817
813
|
// Stencil Lifecycle / Rendering
|
818
814
|
componentWillLoad() {
|
819
815
|
ComponentStore.init(this, ['searchIndex', 'searchValue'], 'url-hash', 'gns');
|
@@ -825,20 +821,15 @@ const GlobalNav = class {
|
|
825
821
|
}
|
826
822
|
componentDidLoad() {
|
827
823
|
{
|
828
|
-
this.debounceResize = debounce(this.onWindowResize.bind(this),
|
824
|
+
this.debounceResize = debounce(this.onWindowResize.bind(this), 200);
|
829
825
|
window.addEventListener('resize', this.debounceResize);
|
830
826
|
this.currSize = window.innerWidth;
|
831
827
|
}
|
832
828
|
this.initAlgoliaClient();
|
833
829
|
this.addAlgoliaIndeces();
|
834
|
-
this.attachResizeObserver();
|
835
830
|
requestAnimationFrame(() => this.handleBarResize());
|
836
831
|
}
|
837
832
|
disconnectedCallback() {
|
838
|
-
if (this.resizeObserver) {
|
839
|
-
this.resizeObserver.disconnect();
|
840
|
-
this.resizeObserver = undefined;
|
841
|
-
}
|
842
833
|
window.removeEventListener('resize', this.debounceResize);
|
843
834
|
}
|
844
835
|
// Render output
|
@@ -866,7 +857,15 @@ const GlobalNav = class {
|
|
866
857
|
let scopeSuggestions = 0;
|
867
858
|
content = (h("div", null, !currentScopeHits && (h("div", { class: "search-autocomplete-hit search-autocomplete-hit--no-result" }, "No results matching '", this.searchValInternal, "' were found in", ' ', h("strong", null, this.currentIndex.name), ". Try another phrase.")), this.autocompleteResults && [
|
868
859
|
this.autocompleteResults.hits.map((hit, i) => {
|
869
|
-
return (h("a", { role: "option", ref: (a) => this.autocompleteEles.push(a), tabindex: "-1", id: 'autocomplete-hit-' + i, href: hit.url, class: "search-autocomplete-hit", innerHTML: this.autocompleteSnippet(hit)
|
860
|
+
return (h("a", { role: "option", ref: (a) => this.autocompleteEles.push(a), tabindex: "-1", id: 'autocomplete-hit-' + i, href: hit.url, class: "search-autocomplete-hit", innerHTML: this.autocompleteSnippet(hit), onClick: () => {
|
861
|
+
searchInsight.sendClick({
|
862
|
+
index: this.currentIndex.index,
|
863
|
+
eventName: 'Global nav quick search - search result clicked',
|
864
|
+
queryID: this.autocompleteResults.queryID,
|
865
|
+
objectIDs: [hit.objectID],
|
866
|
+
positions: [i + 1],
|
867
|
+
});
|
868
|
+
} }));
|
870
869
|
}),
|
871
870
|
], (!currentScopeHits || this.currentIndex.allGroup) &&
|
872
871
|
this.scopeSearch &&
|