@nanoporetech-digital/components 9.1.1 → 9.1.2

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.
Files changed (38) hide show
  1. package/dist/cjs/nano-avatar_5.cjs.entry.js +1 -1
  2. package/dist/cjs/nano-breadcrumb.cjs.entry.js +1 -1
  3. package/dist/cjs/nano-collapsible-comparison.cjs.entry.js +1 -1
  4. package/dist/cjs/nano-datalist_3.cjs.entry.js +8 -6
  5. package/dist/cjs/nano-footer.cjs.entry.js +1 -1
  6. package/dist/cjs/nano-global-nav.cjs.entry.js +20 -16
  7. package/dist/cjs/nano-step-breadcrumb.cjs.entry.js +1 -1
  8. package/dist/cjs/style-CIGbDa5n.js +141 -0
  9. package/dist/collection/components/cta/cta.js +1 -1
  10. package/dist/collection/components/datalist/datalist.js +8 -6
  11. package/dist/collection/components/global-nav/global-nav.js +19 -15
  12. package/dist/collection/utils/style.js +79 -10
  13. package/dist/components/datalist.js +8 -6
  14. package/dist/components/nano-global-nav.js +19 -15
  15. package/dist/components/style.js +79 -10
  16. package/dist/esm/nano-avatar_5.entry.js +1 -1
  17. package/dist/esm/nano-breadcrumb.entry.js +1 -1
  18. package/dist/esm/nano-collapsible-comparison.entry.js +1 -1
  19. package/dist/esm/nano-datalist_3.entry.js +8 -6
  20. package/dist/esm/nano-footer.entry.js +1 -1
  21. package/dist/esm/nano-global-nav.entry.js +20 -16
  22. package/dist/esm/nano-step-breadcrumb.entry.js +1 -1
  23. package/dist/esm/style-BVRinbua.js +139 -0
  24. package/dist/nano-components/nano-avatar_5.entry.js +1 -1
  25. package/dist/nano-components/nano-breadcrumb.entry.js +1 -1
  26. package/dist/nano-components/nano-collapsible-comparison.entry.js +1 -1
  27. package/dist/nano-components/nano-datalist_3.entry.js +1 -1
  28. package/dist/nano-components/nano-footer.entry.js +1 -1
  29. package/dist/nano-components/nano-global-nav.entry.js +1 -1
  30. package/dist/nano-components/nano-step-breadcrumb.entry.js +1 -1
  31. package/dist/nano-components/style-BVRinbua.js +4 -0
  32. package/docs-json.json +7 -7
  33. package/hydrate/index.js +27 -21
  34. package/hydrate/index.mjs +27 -21
  35. package/package.json +2 -2
  36. package/dist/cjs/style-Du-L-qMa.js +0 -72
  37. package/dist/esm/style-Ds52s5za.js +0 -70
  38. package/dist/nano-components/style-Ds52s5za.js +0 -4
@@ -4,7 +4,7 @@
4
4
  import { r as registerInstance, c as createEvent, a as getElement, k as forceUpdate, d as Host } from './index-RXFO3HxS.js';
5
5
  import { h } from './renderer-B_wACs4w.js';
6
6
  import { C as ConstructibleStyle } from './constructible-style-BKXXXS9X.js';
7
- import { a as addGlobalStylesheetToShadow } from './style-Ds52s5za.js';
7
+ import { a as addGlobalStylesheetToShadow } from './style-BVRinbua.js';
8
8
 
9
9
  const stepBreadcrumbCss = ":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{display:block;--background:var(--nano-color-background-default)}.step-wrapper{container-type:inline-size}.step-list.desktop{display:flex;flex-direction:row;align-items:center;justify-content:space-between;list-style:none;padding:0;margin:0;position:relative;z-index:1}.step-list.desktop::before{content:\"\";display:block;flex-grow:1;block-size:1px;background-color:var(--nano-color-fill-neutral-weak);position:absolute;inset-block-start:50%;z-index:-1;inset-inline-start:0;inline-size:100%}.step-item-wrapper{flex:0 1 auto;display:inline-flex;align-items:center;cursor:pointer}.step-item-wrapper:last-of-type{flex:0 1 auto}.step-item-wrapper:last-of-type .step-item{padding-inline-end:0}.step-item-wrapper:first-of-type::before{display:none}.step-item-wrapper:first-of-type .step-item{padding-inline-start:0}.step-item-wrapper::before{content:\"\";grid-column:2;grid-row:1;inline-size:0.4rem;block-size:0.4rem;place-self:center end;inset-block-start:0.5px;position:relative;border-inline-end:1px solid var(--nano-color-fill-neutral-weak);border-block-end:1px solid var(--nano-color-fill-neutral-weak);rotate:-45deg}:dir(rtl) .step-item-wrapper::after{rotate:45deg}.step-item{all:unset;display:inline-flex;align-items:center;gap:var(--nano-spacing-sm);background-color:var(--background);padding:0 var(--nano-spacing-sm);position:relative}.step-item:focus-visible{outline:var(--nano-focus-ring);outline-offset:var(--nano-focus-ring-offset);z-index:1}.step-item.step-item--disabled{cursor:not-allowed}.step-item.step-item--disabled>*{opacity:0.5}.step-item-icon{font-size:var(--nano-font-size-xs);line-height:var(--nano-line-height-normal);letter-spacing:var(--nano-letter-spacing-loose);display:inline-flex;align-items:center;justify-content:center;inline-size:1.5rem;block-size:1.5rem;border-radius:var(--nano-border-radius-circle);background-color:transparent;color:var(--nano-color-text-default);border:1px solid var(--nano-color-fill-neutral-weak)}.step-item--complete .step-item-icon{background-color:var(--nano-color-fill-success);color:var(--nano-color-basic-white);border:none}.step-item--active .step-item-icon{background-color:var(--nano-color-fill-primary);color:var(--nano-color-basic-white);border:none}.step-dropdown{inline-size:100%;min-inline-size:300px}.step-trigger{all:unset;display:inline-flex;gap:var(--nano-spacing-md);align-items:center;inline-size:100%;cursor:pointer}.step-trigger-text{display:flex;flex-direction:column}.step-trigger-now{font-weight:var(--nano-font-weight-normal);font-size:var(--nano-font-size-xl);line-height:var(--nano-line-height-denser);text-wrap:balance;color:var(--nano-color-text-default)}.step-trigger-next{font-size:var(--nano-font-size-2xs);line-height:var(--nano-line-height-normal);letter-spacing:var(--nano-letter-spacing-loose);color:var(--nano-color-fill-neutral)}.step-trigger-icon{margin-inline-start:auto;color:var(--nano-color-fill-primary);transition:var(--nano-transition-x-fast) rotate}[open] .step-trigger-icon{rotate:180deg}.step-progress-circle{--size:64px;--thickness:4px;inline-size:var(--size);min-inline-size:var(--size);aspect-ratio:1/1;border-radius:50%;display:grid;place-items:center;position:relative}.step-progress-circle::before{content:\"\";position:absolute;inset:0;border-radius:50%;background:conic-gradient(var(--nano-color-fill-success) calc(var(--value) / var(--max) * 360deg), var(--nano-color-surface-neutral) 0);-webkit-mask:radial-gradient(farthest-side, transparent calc(100% - var(--thickness)), black 90%);mask:radial-gradient(farthest-side, transparent calc(100% - var(--thickness)), black 90%)}.step-progress-title{font-size:var(--nano-font-size-sm);line-height:var(--nano-line-height-normal);font-weight:var(--nano-font-weight-bold);white-space:nowrap;color:var(--nano-color-fill-neutral)}.step-progress-title strong{color:var(--nano-color-text-default)}";
10
10
 
@@ -0,0 +1,139 @@
1
+ /*!
2
+ * Custom elements for Nanopore-Digital Web applications
3
+ */
4
+ let cachedCSStylesheet;
5
+ // de-dupes the async fetch fallback so we only build the stylesheet once even
6
+ // if several components request it before the fetch resolves
7
+ let pendingCSStylesheet = null;
8
+ // arbitrary pieces of text that appear early in the `nano-components` stylesheet
9
+ // this is a bit fragile but does the job
10
+ const NANO_STYLESHEET_MARKERS = ['.nano-toast-stack', '.nano-theme'];
11
+ function cssTextContainsNanoMarker(cssText) {
12
+ return NANO_STYLESHEET_MARKERS.some((marker) => cssText.indexOf(marker) > -1);
13
+ }
14
+ // only cross-origin sheets whose href looks like the nano stylesheet are worth
15
+ // fetching as a fallback - this avoids pulling unrelated third-party sheets over
16
+ // the network (and into shadow roots). The `@nanoporetech-digital/style` package
17
+ // serves bundles such as `core.css` / `nano.css`.
18
+ const NANO_STYLESHEET_HREF_PATTERNS = [
19
+ '@nanoporetech-digital/style',
20
+ '/core.css',
21
+ '/nano.css',
22
+ ];
23
+ function isLikelyNanoStylesheetHref(href) {
24
+ return NANO_STYLESHEET_HREF_PATTERNS.some((pattern) => href.indexOf(pattern) > -1);
25
+ }
26
+ /**
27
+ * Adds the global nano-components stylesheets as a constructable stylesheet to a shadow root.
28
+ * This is useful when shadow DOM enabled components:
29
+ * - use css-only components
30
+ * - use themed sections within their markup (i.e. `<div class="nano-theme-darK">Always dark themed section</div>`)
31
+ *
32
+ * @param shadowRoot - The shadow root to add the stylesheet to
33
+ */
34
+ function addGlobalStylesheetToShadow(shadowRoot) {
35
+ if (!shadowRoot)
36
+ return;
37
+ if (cachedCSStylesheet) {
38
+ // we've already constructed the stylesheet
39
+ shadowRoot.adoptedStyleSheets.push(cachedCSStylesheet);
40
+ return;
41
+ }
42
+ const globalStylesheets = document.styleSheets;
43
+ let stylesheet = null;
44
+ let rule = null;
45
+ const globalStylesheet = [];
46
+ // stylesheets we couldn't read directly (typically CORS-restricted, e.g.
47
+ // served from a CDN without a `crossorigin` attribute on the `<link>`)
48
+ const inaccessibleHrefs = [];
49
+ for (stylesheet of globalStylesheets) {
50
+ if (!(stylesheet instanceof CSSStyleSheet)) {
51
+ continue;
52
+ }
53
+ let cssRules;
54
+ try {
55
+ // Attempt to access the cssRules of the stylesheet
56
+ cssRules = stylesheet?.cssRules;
57
+ // no cssRules? skip it
58
+ if (!cssRules)
59
+ continue;
60
+ }
61
+ catch {
62
+ // some stylesheets may not be accessible due to CORS or other restrictions.
63
+ // if the href looks like the nano stylesheet, remember it so we can try to
64
+ // fetch it as a fallback below - ignore unrelated third-party sheets.
65
+ if (stylesheet.href && isLikelyNanoStylesheetHref(stylesheet.href)) {
66
+ inaccessibleHrefs.push(stylesheet.href);
67
+ }
68
+ continue;
69
+ }
70
+ for (rule of cssRules) {
71
+ if (rule instanceof CSSLayerBlockRule &&
72
+ cssTextContainsNanoMarker(rule.cssText)) {
73
+ globalStylesheet.push(stylesheet);
74
+ }
75
+ }
76
+ }
77
+ if (globalStylesheet.length) {
78
+ // if we found the global stylesheet, add it to the shadow root
79
+ const sheet = new CSSStyleSheet();
80
+ for (const globalSheet of globalStylesheet) {
81
+ for (const rule of globalSheet.cssRules) {
82
+ sheet.insertRule(rule.cssText);
83
+ }
84
+ }
85
+ cachedCSStylesheet = sheet;
86
+ shadowRoot.adoptedStyleSheets.push(sheet);
87
+ return;
88
+ }
89
+ // We couldn't find the global stylesheet via the CSSOM. If there are
90
+ // CORS-restricted stylesheets (e.g. served from a CDN), fall back to
91
+ // fetching their raw text and constructing the stylesheet asynchronously.
92
+ if (inaccessibleHrefs.length) {
93
+ void adoptGlobalStylesheetFromHrefs(inaccessibleHrefs, shadowRoot);
94
+ return;
95
+ }
96
+ console.warn('No global stylesheet found');
97
+ }
98
+ /**
99
+ * Fallback for cross-origin (e.g. CDN-served) stylesheets whose rules cannot be
100
+ * read via the CSSOM. Fetches the raw CSS text and, once the nano stylesheet is
101
+ * found and constructed, adopts it into the given shadow root.
102
+ */
103
+ async function adoptGlobalStylesheetFromHrefs(hrefs, shadowRoot) {
104
+ if (!pendingCSStylesheet) {
105
+ pendingCSStylesheet = buildGlobalStylesheetFromHrefs(hrefs);
106
+ }
107
+ const sheet = await pendingCSStylesheet;
108
+ if (sheet && shadowRoot) {
109
+ shadowRoot.adoptedStyleSheets.push(sheet);
110
+ }
111
+ }
112
+ async function buildGlobalStylesheetFromHrefs(hrefs) {
113
+ // fetch all candidate stylesheets in parallel rather than one-by-one, so we
114
+ // don't serialise the network latency across multiple cross-origin sheets
115
+ const cssTexts = await Promise.all(hrefs.map(async (href) => {
116
+ try {
117
+ const response = await fetch(href);
118
+ if (!response.ok)
119
+ return null;
120
+ return await response.text();
121
+ }
122
+ catch (e) {
123
+ console.warn('Unable to fetch stylesheet:', href, e);
124
+ return null;
125
+ }
126
+ }));
127
+ // keep the original document order when picking the matching stylesheet
128
+ const cssText = cssTexts.find((text) => !!text && cssTextContainsNanoMarker(text));
129
+ if (cssText) {
130
+ const sheet = new CSSStyleSheet();
131
+ await sheet.replace(cssText);
132
+ cachedCSStylesheet = sheet;
133
+ return sheet;
134
+ }
135
+ console.warn('No global stylesheet found');
136
+ return null;
137
+ }
138
+
139
+ export { addGlobalStylesheetToShadow as a };