@nanoporetech-digital/components 8.3.2 → 8.4.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/dist/cjs/constructible-style-BsHBb9au.js +133 -0
- package/dist/cjs/{fade-BzBFJiQK.js → fade-DBuNbJEw.js} +1 -1
- package/dist/cjs/{fullscreen-Cz3eYnOp.js → fullscreen-Bk4jXSN0.js} +1 -1
- package/dist/cjs/index-DGttnXif.js +28 -16
- package/dist/cjs/{lazyload-DIFYejbf.js → lazyload-gQqOMvpr.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nano-accordion.cjs.entry.js +28 -9
- package/dist/cjs/nano-avatar_5.cjs.entry.js +11 -11
- package/dist/cjs/nano-components.cjs.js +1 -1
- package/dist/cjs/{nano-data-table-DFEflpc4.js → nano-data-table-BHQIpW0N.js} +31 -1
- package/dist/cjs/nano-data-table.cjs.entry.js +1 -1
- package/dist/cjs/nano-details.cjs.entry.js +6 -4
- package/dist/cjs/nano-field-validator.cjs.entry.js +4 -2
- package/dist/cjs/nano-footer.cjs.entry.js +2 -2
- package/dist/cjs/nano-global-nav.cjs.entry.js +21 -20
- package/dist/cjs/nano-grid-item.cjs.entry.js +1 -1
- package/dist/cjs/nano-grid_2.cjs.entry.js +6 -130
- package/dist/cjs/nano-hero.cjs.entry.js +4 -4
- package/dist/cjs/{nano-icon_3.cjs.entry.js → nano-icon-button_2.cjs.entry.js} +2 -320
- package/dist/cjs/nano-icon.cjs.entry.js +326 -0
- package/dist/cjs/nano-in-page-nav.cjs.entry.js +1 -1
- package/dist/cjs/nano-increment.cjs.entry.js +1 -1
- package/dist/cjs/nano-intersection-observe.cjs.entry.js +1 -1
- package/dist/cjs/nano-masked-overflow.cjs.entry.js +3 -3
- package/dist/cjs/nano-menu-drawer.cjs.entry.js +2 -2
- package/dist/cjs/nano-more-less.cjs.entry.js +2 -2
- package/dist/cjs/nano-rating.cjs.entry.js +4 -4
- package/dist/cjs/nano-resize-observe.cjs.entry.js +2 -2
- package/dist/cjs/nano-slide.cjs.entry.js +1 -1
- package/dist/cjs/{nano-slides-C576PTmo.js → nano-slides-C73bSG0h.js} +7 -7
- package/dist/cjs/nano-slides.cjs.entry.js +1 -1
- package/dist/cjs/nano-sortable.cjs.entry.js +1 -1
- package/dist/cjs/nano-step-accordion.cjs.entry.js +101 -0
- package/dist/cjs/nano-step-breadcrumb.cjs.entry.js +133 -0
- package/dist/cjs/nano-sticker.cjs.entry.js +2 -2
- package/dist/cjs/nano-tab-content.cjs.entry.js +2 -2
- package/dist/cjs/nano-tab.cjs.entry.js +2 -2
- package/dist/cjs/nano-table.cjs.entry.js +2 -2
- package/dist/cjs/{page-dots-Clb2QknR.js → page-dots-BLPta5z5.js} +1 -1
- package/dist/cjs/{table.worker-DxRLPmU9.js → table.worker-BeE8kdSf.js} +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/accordion/accordion.js +51 -13
- package/dist/collection/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/collection/components/data-table/table.js +1 -13
- package/dist/collection/components/details/details.js +9 -6
- package/dist/collection/components/field-validator/field-validator.js +4 -2
- package/dist/collection/components/footer/footer.css +7 -7
- package/dist/collection/components/footer/footer.js +2 -1
- package/dist/collection/components/global-nav/global-nav.js +22 -21
- package/dist/collection/components/global-search-results/global-search-results.js +4 -4
- package/dist/collection/components/grid/grid-item.js +1 -1
- package/dist/collection/components/grid/grid.js +1 -1
- package/dist/collection/components/hero/hero.js +4 -4
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/validate.js +1 -1
- package/dist/collection/components/img/img.js +3 -3
- package/dist/collection/components/in-page-nav/in-page-nav.js +1 -1
- package/dist/collection/components/increment/increment.js +1 -1
- package/dist/collection/components/intersection-observe/intersection-observe.js +1 -1
- package/dist/collection/components/masked-overflow/masked-overflow.js +3 -3
- package/dist/collection/components/menu-drawer/menu-drawer.js +2 -2
- package/dist/collection/components/more-less/more-less.js +2 -2
- package/dist/collection/components/rating/rating.js +4 -4
- package/dist/collection/components/resize-observe/resize-observe.js +2 -2
- package/dist/collection/components/select/select.js +7 -7
- package/dist/collection/components/slides/slide.js +1 -1
- package/dist/collection/components/slides/slides.js +3 -3
- package/dist/collection/components/sortable/sortable.js +1 -1
- package/dist/collection/components/step-accordion/step-accordion.css +138 -0
- package/dist/collection/components/step-accordion/step-accordion.js +190 -0
- package/dist/collection/components/step-breadcrumb/step-breadcrumb.css +231 -0
- package/dist/collection/components/step-breadcrumb/step-breadcrumb.js +222 -0
- package/dist/collection/components/sticker/sticker.js +2 -2
- package/dist/collection/components/table/table.js +2 -2
- package/dist/collection/components/tabs/tab-content.js +2 -2
- package/dist/collection/components/tabs/tab.js +2 -2
- package/dist/collection/components/tooltip/tooltip.js +2 -2
- package/dist/collection/utils/constructible-style.js +2 -2
- package/dist/collection/utils/performance.js +17 -0
- package/dist/components/accordion.js +80 -0
- package/dist/components/constructible-style.js +131 -0
- package/dist/components/details.js +6 -4
- package/dist/components/global-search-results.js +4 -4
- package/dist/components/grid.js +5 -129
- package/dist/components/icon.js +2 -2
- package/dist/components/img.js +3 -3
- package/dist/components/masked-overflow.js +3 -3
- package/dist/components/nano-accordion.js +1 -56
- package/dist/components/nano-data-table.js +30 -0
- package/dist/components/nano-field-validator.js +4 -2
- package/dist/components/nano-footer.js +2 -2
- package/dist/components/nano-global-nav.js +21 -20
- package/dist/components/nano-grid-item.js +1 -1
- package/dist/components/nano-hero.js +4 -4
- package/dist/components/nano-in-page-nav.js +1 -1
- package/dist/components/nano-increment.js +1 -1
- package/dist/components/nano-intersection-observe.js +1 -1
- package/dist/components/nano-menu-drawer.js +2 -2
- package/dist/components/nano-more-less.js +2 -2
- package/dist/components/nano-rating.js +4 -4
- package/dist/components/nano-slide.js +1 -1
- package/dist/components/nano-sortable.js +1 -1
- package/dist/components/nano-step-accordion.d.ts +11 -0
- package/dist/components/nano-step-accordion.js +141 -0
- package/dist/components/nano-step-breadcrumb.d.ts +11 -0
- package/dist/components/nano-step-breadcrumb.js +181 -0
- package/dist/components/nano-tab-content.js +2 -2
- package/dist/components/nano-tab.js +2 -2
- package/dist/components/nano-table.js +2 -2
- package/dist/components/resize-observe.js +2 -2
- package/dist/components/select.js +7 -7
- package/dist/components/slides.js +3 -3
- package/dist/components/sticker.js +2 -2
- package/dist/components/tooltip.js +2 -2
- package/dist/esm/constructible-style-B2_GfhhS.js +131 -0
- package/dist/esm/{fade-D4P3XGVa.js → fade-C0NluV0K.js} +1 -1
- package/dist/esm/{fullscreen-Cfl6LvH2.js → fullscreen-Ck_w6MCZ.js} +1 -1
- package/dist/esm/index-BM3Om9WE.js +28 -16
- package/dist/esm/{lazyload-CQYknGN2.js → lazyload-DddTyM-A.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nano-accordion.entry.js +28 -9
- package/dist/esm/nano-avatar_5.entry.js +11 -11
- package/dist/esm/nano-components.js +1 -1
- package/dist/esm/{nano-data-table-Bqk8ZUaL.js → nano-data-table-CWliPF7Y.js} +31 -1
- package/dist/esm/nano-data-table.entry.js +1 -1
- package/dist/esm/nano-details.entry.js +6 -4
- package/dist/esm/nano-field-validator.entry.js +4 -2
- package/dist/esm/nano-footer.entry.js +2 -2
- package/dist/esm/nano-global-nav.entry.js +21 -20
- package/dist/esm/nano-grid-item.entry.js +1 -1
- package/dist/esm/nano-grid_2.entry.js +7 -131
- package/dist/esm/nano-hero.entry.js +4 -4
- package/dist/esm/{nano-icon_3.entry.js → nano-icon-button_2.entry.js} +4 -321
- package/dist/esm/nano-icon.entry.js +324 -0
- package/dist/esm/nano-in-page-nav.entry.js +1 -1
- package/dist/esm/nano-increment.entry.js +1 -1
- package/dist/esm/nano-intersection-observe.entry.js +1 -1
- package/dist/esm/nano-masked-overflow.entry.js +3 -3
- package/dist/esm/nano-menu-drawer.entry.js +2 -2
- package/dist/esm/nano-more-less.entry.js +2 -2
- package/dist/esm/nano-rating.entry.js +4 -4
- package/dist/esm/nano-resize-observe.entry.js +2 -2
- package/dist/esm/nano-slide.entry.js +1 -1
- package/dist/esm/{nano-slides-DcJWApi6.js → nano-slides-BiPGpe5F.js} +7 -7
- package/dist/esm/nano-slides.entry.js +1 -1
- package/dist/esm/nano-sortable.entry.js +1 -1
- package/dist/esm/nano-step-accordion.entry.js +99 -0
- package/dist/esm/nano-step-breadcrumb.entry.js +131 -0
- package/dist/esm/nano-sticker.entry.js +2 -2
- package/dist/esm/nano-tab-content.entry.js +2 -2
- package/dist/esm/nano-tab.entry.js +2 -2
- package/dist/esm/nano-table.entry.js +2 -2
- package/dist/esm/{page-dots-kX7jiD3G.js → page-dots-WKehEjjM.js} +1 -1
- package/dist/esm/{table.worker-a52UkSRM.js → table.worker-DJks4i_l.js} +1 -1
- package/dist/nano-components/constructible-style-B2_GfhhS.js +4 -0
- package/dist/nano-components/{fade-D4P3XGVa.js → fade-C0NluV0K.js} +1 -1
- package/dist/nano-components/{fullscreen-Cfl6LvH2.js → fullscreen-Ck_w6MCZ.js} +1 -1
- package/dist/nano-components/{lazyload-CQYknGN2.js → lazyload-DddTyM-A.js} +1 -1
- package/dist/nano-components/nano-accordion.entry.js +1 -1
- package/dist/nano-components/nano-avatar_5.entry.js +1 -1
- package/dist/nano-components/nano-components.css +32 -1
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/nano-data-table-CWliPF7Y.js +4 -0
- package/dist/nano-components/nano-data-table.entry.js +1 -1
- package/dist/nano-components/nano-details.entry.js +1 -1
- package/dist/nano-components/nano-field-validator.entry.js +1 -1
- package/dist/nano-components/nano-footer.entry.js +1 -1
- package/dist/nano-components/nano-global-nav.entry.js +1 -1
- package/dist/nano-components/nano-grid-item.entry.js +1 -1
- package/dist/nano-components/nano-grid_2.entry.js +1 -1
- package/dist/nano-components/nano-hero.entry.js +1 -1
- package/dist/nano-components/nano-icon-button_2.entry.js +4 -0
- package/dist/nano-components/nano-icon.entry.js +4 -0
- package/dist/nano-components/nano-in-page-nav.entry.js +1 -1
- package/dist/nano-components/nano-increment.entry.js +1 -1
- package/dist/nano-components/nano-intersection-observe.entry.js +1 -1
- package/dist/nano-components/nano-masked-overflow.entry.js +1 -1
- package/dist/nano-components/nano-menu-drawer.entry.js +1 -1
- package/dist/nano-components/nano-more-less.entry.js +1 -1
- package/dist/nano-components/nano-rating.entry.js +1 -1
- package/dist/nano-components/nano-resize-observe.entry.js +1 -1
- package/dist/nano-components/nano-slide.entry.js +1 -1
- package/dist/nano-components/{nano-slides-DcJWApi6.js → nano-slides-BiPGpe5F.js} +3 -3
- package/dist/nano-components/nano-slides.entry.js +1 -1
- package/dist/nano-components/nano-sortable.entry.js +1 -1
- package/dist/nano-components/nano-step-accordion.entry.js +4 -0
- package/dist/nano-components/nano-step-breadcrumb.entry.js +4 -0
- package/dist/nano-components/nano-sticker.entry.js +1 -1
- package/dist/nano-components/nano-tab-content.entry.js +1 -1
- package/dist/nano-components/nano-tab.entry.js +1 -1
- package/dist/nano-components/nano-table.entry.js +1 -1
- package/dist/nano-components/{page-dots-kX7jiD3G.js → page-dots-WKehEjjM.js} +1 -1
- package/dist/nano-components/{table.worker-a52UkSRM.js → table.worker-DJks4i_l.js} +1 -1
- package/dist/stencil.config.js +1 -0
- package/dist/style/components.css +1 -1
- package/dist/style/components.css.map +1 -1
- package/dist/style/core.css +1 -1
- package/dist/style/core.css.map +1 -1
- package/dist/style/nano.css +1 -1
- package/dist/style/nano.css.map +1 -1
- package/dist/types/components/accordion/accordion.d.ts +10 -4
- package/dist/types/components/details/details.d.ts +3 -2
- package/dist/types/components/footer/footer.d.ts +1 -0
- package/dist/types/components/global-nav/global-nav.d.ts +1 -1
- package/dist/types/components/step-accordion/step-accordion.d.ts +38 -0
- package/dist/types/components/step-breadcrumb/step-breadcrumb.d.ts +37 -0
- package/dist/types/components.d.ts +174 -4
- package/dist/types/utils/performance.d.ts +1 -0
- package/docs-json.json +352 -18
- package/docs-vscode.json +41 -2
- package/hydrate/index.js +403 -98
- package/hydrate/index.mjs +403 -98
- package/package.json +2 -2
- package/dist/nano-components/nano-data-table-Bqk8ZUaL.js +0 -4
- package/dist/nano-components/nano-icon_3.entry.js +0 -4
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/generate-vue-component.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/index.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/output-vue.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/plugin.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/types.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/utils.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/stencil.config.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/stencil.config.prod.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/testing/mocks/intersection-observer.d.ts +0 -0
- /package/dist/types/builds/{x6knoJK1 → FKs_t1C_}/0/Digital/nano-components/packages/components/.stencil/wdio.conf.d.ts +0 -0
@@ -1,327 +1,10 @@
|
|
1
1
|
/*!
|
2
2
|
* Custom elements for Nanopore-Digital Web applications
|
3
3
|
*/
|
4
|
-
import {
|
4
|
+
import { r as registerInstance, g as getElement, a as Host, c as createEvent } from './index-BM3Om9WE.js';
|
5
5
|
import { h } from './renderer-BaP2L8CT.js';
|
6
6
|
import { P as Popover } from './popover-CWVbjtKn.js';
|
7
7
|
|
8
|
-
let CACHED_MAP;
|
9
|
-
const getIconMap = () => {
|
10
|
-
if (!CACHED_MAP) {
|
11
|
-
const win = window;
|
12
|
-
win.Nanoicons = win.Nanoicons || {};
|
13
|
-
CACHED_MAP = win.Nanoicons.map = win.Nanoicons.map || new Map();
|
14
|
-
}
|
15
|
-
return CACHED_MAP;
|
16
|
-
};
|
17
|
-
const getUrl = (i) => {
|
18
|
-
let url = getSrc(i.src);
|
19
|
-
if (url)
|
20
|
-
return url;
|
21
|
-
url = getName(i.name, i.icon);
|
22
|
-
if (url)
|
23
|
-
return getNamedUrl(url);
|
24
|
-
if (i.icon) {
|
25
|
-
url = getSrc(i.icon);
|
26
|
-
if (url)
|
27
|
-
return url;
|
28
|
-
}
|
29
|
-
return null;
|
30
|
-
};
|
31
|
-
const getNamedUrl = (iconName) => {
|
32
|
-
const url = getIconMap().get(iconName);
|
33
|
-
if (url)
|
34
|
-
return url;
|
35
|
-
if (iconName.startsWith('device/') || iconName.startsWith('pictogram/')) {
|
36
|
-
return getAssetPath(`../nano-assets/icon/${iconName}.svg`);
|
37
|
-
}
|
38
|
-
return getAssetPath(`../nano-assets/fontawesome-pro/svgs/${iconName}.svg`);
|
39
|
-
};
|
40
|
-
const getName = (iconName, icon) => {
|
41
|
-
if (!iconName && icon && !isSrc(icon)) {
|
42
|
-
iconName = icon;
|
43
|
-
}
|
44
|
-
if (isStr(iconName)) {
|
45
|
-
iconName = toLower(iconName);
|
46
|
-
}
|
47
|
-
if (!isStr(iconName) || iconName.trim() === '') {
|
48
|
-
return null;
|
49
|
-
}
|
50
|
-
// only allow alpha characters and dash
|
51
|
-
const invalidChars = iconName.replace(/[a-z]|-|\/|\d/gi, '');
|
52
|
-
if (invalidChars !== '') {
|
53
|
-
console.warn('invalid characters in icon name ' + iconName);
|
54
|
-
return null;
|
55
|
-
}
|
56
|
-
return iconName;
|
57
|
-
};
|
58
|
-
const getSrc = (src) => {
|
59
|
-
if (isStr(src)) {
|
60
|
-
src = src.trim();
|
61
|
-
if (isSrc(src))
|
62
|
-
return src;
|
63
|
-
}
|
64
|
-
return null;
|
65
|
-
};
|
66
|
-
const isSrc = (str) => str.length > 0 && /(\/|\.)/.test(str);
|
67
|
-
const isStr = (val) => typeof val === 'string';
|
68
|
-
const toLower = (val) => val.toLowerCase();
|
69
|
-
|
70
|
-
const validateContent = (svgContent) => {
|
71
|
-
if (svgContent) {
|
72
|
-
const div = document.createElement('div');
|
73
|
-
div.innerHTML = svgContent;
|
74
|
-
// setup this way to ensure it works on our buddy IE
|
75
|
-
for (let i = div.childNodes.length - 1; i >= 0; i--) {
|
76
|
-
if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {
|
77
|
-
div.removeChild(div.childNodes[i]);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
// must only have 1 root element
|
81
|
-
const svgElm = div.firstElementChild;
|
82
|
-
if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {
|
83
|
-
const svgClass = svgElm.getAttribute('class') || '';
|
84
|
-
svgElm.setAttribute('class', (svgClass + ' sc-nano-icon s-nano-icon svg').trim());
|
85
|
-
// root element must be an svg
|
86
|
-
// lets double check we've got valid elements
|
87
|
-
// do not allow scripts
|
88
|
-
if (isValid(svgElm)) {
|
89
|
-
return div.innerHTML;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
return '';
|
94
|
-
};
|
95
|
-
const isValid = (elm) => {
|
96
|
-
if (elm.nodeType === 1) {
|
97
|
-
if (elm.nodeName.toLowerCase() === 'script') {
|
98
|
-
return false;
|
99
|
-
}
|
100
|
-
for (let i = 0; i < elm.attributes.length; i++) {
|
101
|
-
const val = elm.attributes[i].value;
|
102
|
-
if (isStr(val) && val.toLowerCase().indexOf('on') === 0) {
|
103
|
-
return false;
|
104
|
-
}
|
105
|
-
}
|
106
|
-
for (let i = 0; i < elm.childNodes.length; i++) {
|
107
|
-
if (!isValid(elm.childNodes[i])) {
|
108
|
-
return false;
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
return true;
|
113
|
-
};
|
114
|
-
|
115
|
-
const iconContent = new Map();
|
116
|
-
const requests = new Map();
|
117
|
-
const getSvgContent = (url) => {
|
118
|
-
// see if we already have a request for this url
|
119
|
-
let req = requests.get(url);
|
120
|
-
if (!req) {
|
121
|
-
// we don't already have a request
|
122
|
-
req = fetch(url).then((rsp) => {
|
123
|
-
if (rsp.ok) {
|
124
|
-
return rsp.text().then((svgContent) => {
|
125
|
-
iconContent.set(url, validateContent(svgContent));
|
126
|
-
});
|
127
|
-
}
|
128
|
-
iconContent.set(url, '');
|
129
|
-
});
|
130
|
-
// cache for the same requests
|
131
|
-
requests.set(url, req);
|
132
|
-
}
|
133
|
-
return req;
|
134
|
-
};
|
135
|
-
|
136
|
-
const iconCss = ":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{--icon-size:1em;--primary-color:currentcolor\n --secondary-color: color-mix(in srgb, currentColor 50%, transparent);--primary-opacity:0.8;--secondary-opacity:1;display:inline-block;inline-size:var(--icon-size);block-size:var(--icon-size);min-inline-size:var(--icon-size);min-block-size:var(--icon-size);contain:strict;fill:currentcolor;box-sizing:content-box !important;transition:opacity 0.3s ease;color:currentcolor}:host .nanoicon{stroke:currentcolor}.nanoicon-fill-none{fill:none}.icon-inner,.nanoicon,svg,.svg{display:block;block-size:100%;inline-size:100%;overflow:visible}:host(.loading){opacity:0}.fa-primary{color:var(--primary-color);opacity:var(--primary-opacity, 1)}.fa-secondary{color:var(--secondary-color);opacity:var(--secondary-opacity) !important}:host(.flip-rtl) .icon-inner{transform:scaleX(-1)}:host([name^=pictogram]),:host([name^=device]){font-size:max(var(--nano-pictogram-size-medium), var(--icon-size))}:host([size=small][name^=pictogram]),:host([size=small][name^=device]){font-size:var(--nano-pictogram-size-small)}:host([size=regular]){font-size:var(--nano-icon-size-small)}:host([size=regular][name^=pictogram]),:host([size=regular][name^=device]){font-size:var(--nano-pictogram-size-medium)}:host([size=large]){font-size:var(--nano-icon-size-large)}:host([size=large][name^=pictogram]),:host([size=large][name^=device]){font-size:var(--nano-pictogram-size-large)}:host([size=xl][name^=pictogram]),:host([size=xl][name^=device]){font-size:var(--nano-pictogram-size-x-large)}:host([name^=pictogram]),:host([name^=device]),:host([color=primary]){color:var(--nano-color-primary-1100)}:host([color=neutral]){color:var(--nano-color-base-1000)}";
|
137
|
-
|
138
|
-
const Icon = class {
|
139
|
-
constructor(hostRef) {
|
140
|
-
registerInstance(this, hostRef);
|
141
|
-
this.nanoLoad = createEvent(this, "nanoLoad", 7);
|
142
|
-
this.nanoError = createEvent(this, "nanoError", 7);
|
143
|
-
}
|
144
|
-
io;
|
145
|
-
get el() { return getElement(this); }
|
146
|
-
svgContent;
|
147
|
-
isVisible = false;
|
148
|
-
isLoading = true;
|
149
|
-
/**
|
150
|
-
* Specifies the color of the icon. If not specified, the icon will inherit the color of the parent element.
|
151
|
-
*/
|
152
|
-
color;
|
153
|
-
/**
|
154
|
-
* Specifies the role to use for accessibility. Defaults to 'presentation' (invisible to screen-readers)
|
155
|
-
*/
|
156
|
-
role;
|
157
|
-
setAriaLabel() {
|
158
|
-
if (!this.ariaLabel && !this.el.ariaLabel) {
|
159
|
-
if (!this.role || this.role !== 'presentation') {
|
160
|
-
// if the role is not 'presentation' and the user did not explicitly set a role,
|
161
|
-
// let's try and derive one from the icon name
|
162
|
-
const label = getName(this.name, this.icon);
|
163
|
-
// user did not provide a label
|
164
|
-
// come up with the label based on the icon name
|
165
|
-
if (label) {
|
166
|
-
this.ariaLabel = label.split('/').slice(-1)[0].replace(/-/g, ' ');
|
167
|
-
}
|
168
|
-
}
|
169
|
-
}
|
170
|
-
else if (this.role === 'presentation') {
|
171
|
-
this.ariaLabel = undefined;
|
172
|
-
}
|
173
|
-
}
|
174
|
-
/**
|
175
|
-
* Specifies the label to use for accessibility. Defaults to the icon name.
|
176
|
-
*/
|
177
|
-
ariaLabel;
|
178
|
-
updateRole() {
|
179
|
-
// force the role to be 'img' if the aria-label is explicitly set
|
180
|
-
if (this.ariaLabel)
|
181
|
-
this.role = 'img';
|
182
|
-
else if (!this.ariaLabel)
|
183
|
-
this.role = 'presentation';
|
184
|
-
}
|
185
|
-
/**
|
186
|
-
* Specifies whether the icon should horizontally flip when `dir` is `"rtl"`.
|
187
|
-
* By default, when an 'arrow' or 'chevron' icon is used, it will flip automatically when detecting `dir="rtl"` on the document or closest ancestor.
|
188
|
-
*/
|
189
|
-
flipRtl;
|
190
|
-
/**
|
191
|
-
* Specifies which icon to use from the built-in set of icons.
|
192
|
-
*/
|
193
|
-
name;
|
194
|
-
/**
|
195
|
-
* Specifies the exact `src` of an SVG file to use.
|
196
|
-
*/
|
197
|
-
src;
|
198
|
-
/**
|
199
|
-
* A combination of both `name` and `src`. If a `src` url is detected
|
200
|
-
* it will set the `src` property. Otherwise it assumes it's a built-in named
|
201
|
-
* SVG and set the `name` property.
|
202
|
-
*/
|
203
|
-
icon;
|
204
|
-
/**
|
205
|
-
* The size of the icon. `auto` automatically sizes according to the font-size of the parent element.
|
206
|
-
* *Note*: size will be different on 'pictogram' and 'device' vs 'font awesome' icons.
|
207
|
-
*/
|
208
|
-
size = 'auto';
|
209
|
-
/**
|
210
|
-
* If enabled, nano-icon will be loaded lazily when it's visible in the viewport.
|
211
|
-
* Default, `true`.
|
212
|
-
*/
|
213
|
-
lazy = true;
|
214
|
-
loadIcon() {
|
215
|
-
if (this.isVisible) {
|
216
|
-
const url = getUrl(this);
|
217
|
-
if (url) {
|
218
|
-
if (iconContent.has(url)) {
|
219
|
-
// sync if it's already loaded
|
220
|
-
this.svgContent = iconContent.get(url);
|
221
|
-
requestAnimationFrame(() => {
|
222
|
-
this.isLoading = false;
|
223
|
-
this.nanoLoad.emit();
|
224
|
-
});
|
225
|
-
}
|
226
|
-
else {
|
227
|
-
// async if it hasn't been loaded
|
228
|
-
getSvgContent(url).then(() => {
|
229
|
-
this.svgContent = iconContent.get(url);
|
230
|
-
requestAnimationFrame(() => {
|
231
|
-
this.isLoading = false;
|
232
|
-
this.nanoLoad.emit();
|
233
|
-
});
|
234
|
-
this.setAriaLabel();
|
235
|
-
}, () => {
|
236
|
-
// error loading icon
|
237
|
-
this.nanoError.emit();
|
238
|
-
});
|
239
|
-
}
|
240
|
-
}
|
241
|
-
}
|
242
|
-
}
|
243
|
-
/** Emitted when the icon has finished loading. */
|
244
|
-
nanoLoad;
|
245
|
-
/** Emitted when the icon fails to load. */
|
246
|
-
nanoError;
|
247
|
-
waitUntilVisible(el, rootMargin, cb) {
|
248
|
-
if (this.lazy &&
|
249
|
-
typeof window !== 'undefined' &&
|
250
|
-
window.IntersectionObserver) {
|
251
|
-
const io = (this.io = new window.IntersectionObserver((data) => {
|
252
|
-
if (data[0].isIntersecting || (data[1] && data[1].isIntersecting)) {
|
253
|
-
io.disconnect();
|
254
|
-
this.io = undefined;
|
255
|
-
cb();
|
256
|
-
}
|
257
|
-
}, { rootMargin }));
|
258
|
-
io.observe(el);
|
259
|
-
}
|
260
|
-
else {
|
261
|
-
// not a browser env (e.g. node)
|
262
|
-
// or we're not loading lazily
|
263
|
-
// or env doesn't support IntersectionObserver (testing?)
|
264
|
-
// - immediately fetch icon
|
265
|
-
cb();
|
266
|
-
}
|
267
|
-
}
|
268
|
-
isRtl() {
|
269
|
-
// doc is in rtl
|
270
|
-
if (this.el.ownerDocument?.dir === 'rtl')
|
271
|
-
return true;
|
272
|
-
// html element is in rtl element
|
273
|
-
if (this.el.closest('[dir="rtl"]'))
|
274
|
-
return true;
|
275
|
-
// nested in a shadow dom - see if that host element is contained in an rtl element
|
276
|
-
const rootNode = this.el.getRootNode();
|
277
|
-
const ownerHost = rootNode.host;
|
278
|
-
if (ownerHost && ownerHost.closest('[dir="rtl"]'))
|
279
|
-
return true;
|
280
|
-
return false;
|
281
|
-
}
|
282
|
-
connectedCallback() {
|
283
|
-
// purposely do not return the promise here because loading
|
284
|
-
// the svg file should not hold up loading the app
|
285
|
-
// only load the svg if it's visible
|
286
|
-
this.waitUntilVisible(this.el, '50px', () => {
|
287
|
-
this.isVisible = true;
|
288
|
-
this.loadIcon();
|
289
|
-
});
|
290
|
-
}
|
291
|
-
disconnectedCallback() {
|
292
|
-
if (this.io) {
|
293
|
-
this.io.disconnect();
|
294
|
-
this.io = undefined;
|
295
|
-
}
|
296
|
-
}
|
297
|
-
componentWillLoad() {
|
298
|
-
this.updateRole();
|
299
|
-
this.setAriaLabel();
|
300
|
-
}
|
301
|
-
render() {
|
302
|
-
const flipRtl = this.flipRtl ||
|
303
|
-
(this.name &&
|
304
|
-
this.name.match(/right|left/) &&
|
305
|
-
(this.name.indexOf('arrow') > -1 ||
|
306
|
-
this.name.indexOf('chevron') > -1) &&
|
307
|
-
this.isRtl());
|
308
|
-
return (h(Host, { key: '754a53ed280fd9bcb1dcbec89eba4180f491d1b8', class: {
|
309
|
-
loading: this.isLoading,
|
310
|
-
'flip-rtl': !!flipRtl,
|
311
|
-
'nano-icon': true,
|
312
|
-
} }, this.svgContent ? (h("div", { class: "icon-inner", innerHTML: this.svgContent })) : (h("div", { class: "icon-inner" }))));
|
313
|
-
}
|
314
|
-
static get assetsDirs() { return ["device", "pictogram"]; }
|
315
|
-
static get watchers() { return {
|
316
|
-
"role": ["setAriaLabel"],
|
317
|
-
"ariaLabel": ["updateRole"],
|
318
|
-
"name": ["loadIcon"],
|
319
|
-
"src": ["loadIcon"],
|
320
|
-
"icon": ["loadIcon"]
|
321
|
-
}; }
|
322
|
-
};
|
323
|
-
Icon.style = iconCss;
|
324
|
-
|
325
8
|
const iconButtonCss = ":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{--border-radius:none;--active-color:var(--nano-color-neutral-800);--hover-color:var(--nano-color-primary-1100);--padding:var(--nano-spacing-xs);--box-shadow:none;--button-bg:transparent;color:currentcolor;border-radius:var(--border-radius);display:inline-block}.icon-button{flex:0 0 auto;display:flex;align-items:center;border:none;border-radius:inherit;background:inherit;font-size:inherit;color:inherit;padding:var(--padding);cursor:pointer;appearance:none;box-shadow:var(--box-shadow)}.icon-button:hover:not(.icon-button--disabled),.icon-button:focus:not(.icon-button--disabled){color:var(--hover-color)}.icon-button:active:not(.icon-button--disabled){color:var(--active-color)}.icon-button:focus-visible:not(.icon-button--disabled){outline:var(--nano-focus-ring);outline-offset:var(--nano-focus-ring-offset)}.icon-button__label{clip-path:inset(50%);block-size:1px;overflow:hidden;position:absolute;white-space:nowrap;inline-size:1px}:host([disabled]:not([disabled=false])){opacity:0.5;cursor:not-allowed}.icon-button--disabled{pointer-events:none}";
|
326
9
|
|
327
10
|
const IconButton = class {
|
@@ -636,10 +319,10 @@ const Tooltip = class {
|
|
636
319
|
this.popover.destroy();
|
637
320
|
}
|
638
321
|
render() {
|
639
|
-
return (h(Host, { key: '
|
322
|
+
return (h(Host, { key: '94758bb18228b14884cf2be79228e554de84013f', onKeyDown: this.handleKeyDown, onMouseOver: this.handleMouseOver, onMouseOut: this.handleMouseOut, onBlur: this.handleBlur, onFocus: this.handleFocus, onClick: this.handleClick, class: "nano-tooltip" }, h("slot", { key: '45589386e68d89c21abbb50513678152e8bce9d1', onSlotchange: this.handleSlotChange }), h("div", { key: '6a76c101c35d45458f0a680753a381cc95631b87', ref: (el) => (this.tooltipPositioner = el), class: "tooltip-positioner", popover: "manual" }, h("div", { key: 'd3b2cc9c9018c9a0a5dc4cef256c8b9c568cd0b4', part: "base", ref: (el) => (this.tooltip = el), class: {
|
640
323
|
tooltip: true,
|
641
324
|
'tooltip--open': this.open,
|
642
|
-
}, role: "tooltip", "aria-hidden": this.open ? 'false' : 'true' }, h("slot", { key: '
|
325
|
+
}, role: "tooltip", "aria-hidden": this.open ? 'false' : 'true' }, h("slot", { key: '1c51cdc6a7ec88107e3290b0b9750198e7176c20', name: "content", onSlotchange: () => this.setLabel() }, this.content), h("div", { key: '00f090eee000e6bba713dc21a1d53c348eb94a76', class: "tooltip-arrow", "data-popper-arrow": true })))));
|
643
326
|
}
|
644
327
|
static get watchers() { return {
|
645
328
|
"content": ["setLabel"],
|
@@ -648,4 +331,4 @@ const Tooltip = class {
|
|
648
331
|
};
|
649
332
|
Tooltip.style = tooltipCss;
|
650
333
|
|
651
|
-
export {
|
334
|
+
export { IconButton as nano_icon_button, Tooltip as nano_tooltip };
|
@@ -0,0 +1,324 @@
|
|
1
|
+
/*!
|
2
|
+
* Custom elements for Nanopore-Digital Web applications
|
3
|
+
*/
|
4
|
+
import { k as getAssetPath, r as registerInstance, c as createEvent, g as getElement, a as Host } from './index-BM3Om9WE.js';
|
5
|
+
import { h } from './renderer-BaP2L8CT.js';
|
6
|
+
|
7
|
+
let CACHED_MAP;
|
8
|
+
const getIconMap = () => {
|
9
|
+
if (!CACHED_MAP) {
|
10
|
+
const win = window;
|
11
|
+
win.Nanoicons = win.Nanoicons || {};
|
12
|
+
CACHED_MAP = win.Nanoicons.map = win.Nanoicons.map || new Map();
|
13
|
+
}
|
14
|
+
return CACHED_MAP;
|
15
|
+
};
|
16
|
+
const getUrl = (i) => {
|
17
|
+
let url = getSrc(i.src);
|
18
|
+
if (url)
|
19
|
+
return url;
|
20
|
+
url = getName(i.name, i.icon);
|
21
|
+
if (url)
|
22
|
+
return getNamedUrl(url);
|
23
|
+
if (i.icon) {
|
24
|
+
url = getSrc(i.icon);
|
25
|
+
if (url)
|
26
|
+
return url;
|
27
|
+
}
|
28
|
+
return null;
|
29
|
+
};
|
30
|
+
const getNamedUrl = (iconName) => {
|
31
|
+
const url = getIconMap().get(iconName);
|
32
|
+
if (url)
|
33
|
+
return url;
|
34
|
+
if (iconName.startsWith('device/') || iconName.startsWith('pictogram/')) {
|
35
|
+
return getAssetPath(`../nano-assets/icon/${iconName}.svg`);
|
36
|
+
}
|
37
|
+
return getAssetPath(`../nano-assets/fontawesome-pro/svgs/${iconName}.svg`);
|
38
|
+
};
|
39
|
+
const getName = (iconName, icon) => {
|
40
|
+
if (!iconName && icon && !isSrc(icon)) {
|
41
|
+
iconName = icon;
|
42
|
+
}
|
43
|
+
if (isStr(iconName)) {
|
44
|
+
iconName = toLower(iconName);
|
45
|
+
}
|
46
|
+
if (!isStr(iconName) || iconName.trim() === '') {
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
// only allow alpha characters and dash
|
50
|
+
const invalidChars = iconName.replace(/[a-z]|-|\/|\d/gi, '');
|
51
|
+
if (invalidChars !== '') {
|
52
|
+
console.warn('invalid characters in icon name ' + iconName);
|
53
|
+
return null;
|
54
|
+
}
|
55
|
+
return iconName;
|
56
|
+
};
|
57
|
+
const getSrc = (src) => {
|
58
|
+
if (isStr(src)) {
|
59
|
+
src = src.trim();
|
60
|
+
if (isSrc(src))
|
61
|
+
return src;
|
62
|
+
}
|
63
|
+
return null;
|
64
|
+
};
|
65
|
+
const isSrc = (str) => str.length > 0 && /(\/|\.)/.test(str);
|
66
|
+
const isStr = (val) => typeof val === 'string';
|
67
|
+
const toLower = (val) => val.toLowerCase();
|
68
|
+
|
69
|
+
const validateContent = (svgContent) => {
|
70
|
+
if (svgContent && document) {
|
71
|
+
const div = document.createElement('div');
|
72
|
+
div.innerHTML = svgContent;
|
73
|
+
// setup this way to ensure it works on our buddy IE
|
74
|
+
for (let i = div.childNodes.length - 1; i >= 0; i--) {
|
75
|
+
if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {
|
76
|
+
div.removeChild(div.childNodes[i]);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
// must only have 1 root element
|
80
|
+
const svgElm = div.firstElementChild;
|
81
|
+
if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {
|
82
|
+
const svgClass = svgElm.getAttribute('class') || '';
|
83
|
+
svgElm.setAttribute('class', (svgClass + ' sc-nano-icon s-nano-icon svg').trim());
|
84
|
+
// root element must be an svg
|
85
|
+
// lets double check we've got valid elements
|
86
|
+
// do not allow scripts
|
87
|
+
if (isValid(svgElm)) {
|
88
|
+
return div.innerHTML;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
return '';
|
93
|
+
};
|
94
|
+
const isValid = (elm) => {
|
95
|
+
if (elm.nodeType === 1) {
|
96
|
+
if (elm.nodeName.toLowerCase() === 'script') {
|
97
|
+
return false;
|
98
|
+
}
|
99
|
+
for (let i = 0; i < elm.attributes.length; i++) {
|
100
|
+
const val = elm.attributes[i].value;
|
101
|
+
if (isStr(val) && val.toLowerCase().indexOf('on') === 0) {
|
102
|
+
return false;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
for (let i = 0; i < elm.childNodes.length; i++) {
|
106
|
+
if (!isValid(elm.childNodes[i])) {
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
return true;
|
112
|
+
};
|
113
|
+
|
114
|
+
const iconContent = new Map();
|
115
|
+
const requests = new Map();
|
116
|
+
const getSvgContent = (url) => {
|
117
|
+
// see if we already have a request for this url
|
118
|
+
let req = requests.get(url);
|
119
|
+
if (!req) {
|
120
|
+
// we don't already have a request
|
121
|
+
req = fetch(url).then((rsp) => {
|
122
|
+
if (rsp.ok) {
|
123
|
+
return rsp.text().then((svgContent) => {
|
124
|
+
iconContent.set(url, validateContent(svgContent));
|
125
|
+
});
|
126
|
+
}
|
127
|
+
iconContent.set(url, '');
|
128
|
+
});
|
129
|
+
// cache for the same requests
|
130
|
+
requests.set(url, req);
|
131
|
+
}
|
132
|
+
return req;
|
133
|
+
};
|
134
|
+
|
135
|
+
const iconCss = ":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{--icon-size:1em;--primary-color:currentcolor\n --secondary-color: color-mix(in srgb, currentColor 50%, transparent);--primary-opacity:0.8;--secondary-opacity:1;display:inline-block;inline-size:var(--icon-size);block-size:var(--icon-size);min-inline-size:var(--icon-size);min-block-size:var(--icon-size);contain:strict;fill:currentcolor;box-sizing:content-box !important;transition:opacity 0.3s ease;color:currentcolor}:host .nanoicon{stroke:currentcolor}.nanoicon-fill-none{fill:none}.icon-inner,.nanoicon,svg,.svg{display:block;block-size:100%;inline-size:100%;overflow:visible}:host(.loading){opacity:0}.fa-primary{color:var(--primary-color);opacity:var(--primary-opacity, 1)}.fa-secondary{color:var(--secondary-color);opacity:var(--secondary-opacity) !important}:host(.flip-rtl) .icon-inner{transform:scaleX(-1)}:host([name^=pictogram]),:host([name^=device]){font-size:max(var(--nano-pictogram-size-medium), var(--icon-size))}:host([size=small][name^=pictogram]),:host([size=small][name^=device]){font-size:var(--nano-pictogram-size-small)}:host([size=regular]){font-size:var(--nano-icon-size-small)}:host([size=regular][name^=pictogram]),:host([size=regular][name^=device]){font-size:var(--nano-pictogram-size-medium)}:host([size=large]){font-size:var(--nano-icon-size-large)}:host([size=large][name^=pictogram]),:host([size=large][name^=device]){font-size:var(--nano-pictogram-size-large)}:host([size=xl][name^=pictogram]),:host([size=xl][name^=device]){font-size:var(--nano-pictogram-size-x-large)}:host([name^=pictogram]),:host([name^=device]),:host([color=primary]){color:var(--nano-color-primary-1100)}:host([color=neutral]){color:var(--nano-color-base-1000)}";
|
136
|
+
|
137
|
+
const Icon = class {
|
138
|
+
constructor(hostRef) {
|
139
|
+
registerInstance(this, hostRef);
|
140
|
+
this.nanoLoad = createEvent(this, "nanoLoad", 7);
|
141
|
+
this.nanoError = createEvent(this, "nanoError", 7);
|
142
|
+
}
|
143
|
+
io;
|
144
|
+
get el() { return getElement(this); }
|
145
|
+
svgContent;
|
146
|
+
isVisible = false;
|
147
|
+
isLoading = true;
|
148
|
+
/**
|
149
|
+
* Specifies the color of the icon. If not specified, the icon will inherit the color of the parent element.
|
150
|
+
*/
|
151
|
+
color;
|
152
|
+
/**
|
153
|
+
* Specifies the role to use for accessibility. Defaults to 'presentation' (invisible to screen-readers)
|
154
|
+
*/
|
155
|
+
role;
|
156
|
+
setAriaLabel() {
|
157
|
+
if (!this.ariaLabel && !this.el.ariaLabel) {
|
158
|
+
if (!this.role || this.role !== 'presentation') {
|
159
|
+
// if the role is not 'presentation' and the user did not explicitly set a role,
|
160
|
+
// let's try and derive one from the icon name
|
161
|
+
const label = getName(this.name, this.icon);
|
162
|
+
// user did not provide a label
|
163
|
+
// come up with the label based on the icon name
|
164
|
+
if (label) {
|
165
|
+
this.ariaLabel = label.split('/').slice(-1)[0].replace(/-/g, ' ');
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
else if (this.role === 'presentation') {
|
170
|
+
this.ariaLabel = undefined;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
/**
|
174
|
+
* Specifies the label to use for accessibility. Defaults to the icon name.
|
175
|
+
*/
|
176
|
+
ariaLabel;
|
177
|
+
updateRole() {
|
178
|
+
// force the role to be 'img' if the aria-label is explicitly set
|
179
|
+
if (this.ariaLabel)
|
180
|
+
this.role = 'img';
|
181
|
+
else if (!this.ariaLabel)
|
182
|
+
this.role = 'presentation';
|
183
|
+
}
|
184
|
+
/**
|
185
|
+
* Specifies whether the icon should horizontally flip when `dir` is `"rtl"`.
|
186
|
+
* By default, when an 'arrow' or 'chevron' icon is used, it will flip automatically when detecting `dir="rtl"` on the document or closest ancestor.
|
187
|
+
*/
|
188
|
+
flipRtl;
|
189
|
+
/**
|
190
|
+
* Specifies which icon to use from the built-in set of icons.
|
191
|
+
*/
|
192
|
+
name;
|
193
|
+
/**
|
194
|
+
* Specifies the exact `src` of an SVG file to use.
|
195
|
+
*/
|
196
|
+
src;
|
197
|
+
/**
|
198
|
+
* A combination of both `name` and `src`. If a `src` url is detected
|
199
|
+
* it will set the `src` property. Otherwise it assumes it's a built-in named
|
200
|
+
* SVG and set the `name` property.
|
201
|
+
*/
|
202
|
+
icon;
|
203
|
+
/**
|
204
|
+
* The size of the icon. `auto` automatically sizes according to the font-size of the parent element.
|
205
|
+
* *Note*: size will be different on 'pictogram' and 'device' vs 'font awesome' icons.
|
206
|
+
*/
|
207
|
+
size = 'auto';
|
208
|
+
/**
|
209
|
+
* If enabled, nano-icon will be loaded lazily when it's visible in the viewport.
|
210
|
+
* Default, `true`.
|
211
|
+
*/
|
212
|
+
lazy = true;
|
213
|
+
loadIcon() {
|
214
|
+
if (this.isVisible) {
|
215
|
+
const url = getUrl(this);
|
216
|
+
if (url) {
|
217
|
+
if (iconContent.has(url)) {
|
218
|
+
// sync if it's already loaded
|
219
|
+
this.svgContent = iconContent.get(url);
|
220
|
+
requestAnimationFrame(() => {
|
221
|
+
this.isLoading = false;
|
222
|
+
this.nanoLoad.emit();
|
223
|
+
});
|
224
|
+
}
|
225
|
+
else {
|
226
|
+
// async if it hasn't been loaded
|
227
|
+
getSvgContent(url).then(() => {
|
228
|
+
this.svgContent = iconContent.get(url);
|
229
|
+
requestAnimationFrame(() => {
|
230
|
+
this.isLoading = false;
|
231
|
+
this.nanoLoad.emit();
|
232
|
+
});
|
233
|
+
this.setAriaLabel();
|
234
|
+
}, () => {
|
235
|
+
// error loading icon
|
236
|
+
this.nanoError.emit();
|
237
|
+
});
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
/** Emitted when the icon has finished loading. */
|
243
|
+
nanoLoad;
|
244
|
+
/** Emitted when the icon fails to load. */
|
245
|
+
nanoError;
|
246
|
+
waitUntilVisible(el, rootMargin, cb) {
|
247
|
+
if (this.lazy &&
|
248
|
+
typeof window !== 'undefined' &&
|
249
|
+
window.IntersectionObserver) {
|
250
|
+
const io = (this.io = new window.IntersectionObserver((data) => {
|
251
|
+
if (data[0].isIntersecting || (data[1] && data[1].isIntersecting)) {
|
252
|
+
io.disconnect();
|
253
|
+
this.io = undefined;
|
254
|
+
cb();
|
255
|
+
}
|
256
|
+
}, { rootMargin }));
|
257
|
+
io.observe(el);
|
258
|
+
}
|
259
|
+
else {
|
260
|
+
// not a browser env (e.g. node)
|
261
|
+
// or we're not loading lazily
|
262
|
+
// or env doesn't support IntersectionObserver (testing?)
|
263
|
+
// - immediately fetch icon
|
264
|
+
cb();
|
265
|
+
}
|
266
|
+
}
|
267
|
+
isRtl() {
|
268
|
+
// doc is in rtl
|
269
|
+
if (this.el.ownerDocument?.dir === 'rtl')
|
270
|
+
return true;
|
271
|
+
// html element is in rtl element
|
272
|
+
if (this.el.closest('[dir="rtl"]'))
|
273
|
+
return true;
|
274
|
+
// nested in a shadow dom - see if that host element is contained in an rtl element
|
275
|
+
const rootNode = this.el.getRootNode();
|
276
|
+
const ownerHost = rootNode.host;
|
277
|
+
if (ownerHost && ownerHost.closest('[dir="rtl"]'))
|
278
|
+
return true;
|
279
|
+
return false;
|
280
|
+
}
|
281
|
+
connectedCallback() {
|
282
|
+
// purposely do not return the promise here because loading
|
283
|
+
// the svg file should not hold up loading the app
|
284
|
+
// only load the svg if it's visible
|
285
|
+
this.waitUntilVisible(this.el, '50px', () => {
|
286
|
+
this.isVisible = true;
|
287
|
+
this.loadIcon();
|
288
|
+
});
|
289
|
+
}
|
290
|
+
disconnectedCallback() {
|
291
|
+
if (this.io) {
|
292
|
+
this.io.disconnect();
|
293
|
+
this.io = undefined;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
componentWillLoad() {
|
297
|
+
this.updateRole();
|
298
|
+
this.setAriaLabel();
|
299
|
+
}
|
300
|
+
render() {
|
301
|
+
const flipRtl = this.flipRtl ||
|
302
|
+
(this.name &&
|
303
|
+
this.name.match(/right|left/) &&
|
304
|
+
(this.name.indexOf('arrow') > -1 ||
|
305
|
+
this.name.indexOf('chevron') > -1) &&
|
306
|
+
this.isRtl());
|
307
|
+
return (h(Host, { key: '0bc1c17119f0e49b9798a1b61a4a768f6406129f', class: {
|
308
|
+
loading: this.isLoading,
|
309
|
+
'flip-rtl': !!flipRtl,
|
310
|
+
'nano-icon': true,
|
311
|
+
} }, this.svgContent ? (h("div", { class: "icon-inner", innerHTML: this.svgContent })) : (h("div", { class: "icon-inner" }))));
|
312
|
+
}
|
313
|
+
static get assetsDirs() { return ["device", "pictogram"]; }
|
314
|
+
static get watchers() { return {
|
315
|
+
"role": ["setAriaLabel"],
|
316
|
+
"ariaLabel": ["updateRole"],
|
317
|
+
"name": ["loadIcon"],
|
318
|
+
"src": ["loadIcon"],
|
319
|
+
"icon": ["loadIcon"]
|
320
|
+
}; }
|
321
|
+
};
|
322
|
+
Icon.style = iconCss;
|
323
|
+
|
324
|
+
export { Icon as nano_icon };
|
@@ -51,7 +51,7 @@ const NanoInPageNav = class {
|
|
51
51
|
return node;
|
52
52
|
}
|
53
53
|
render() {
|
54
|
-
return (h(Host, { key: '
|
54
|
+
return (h(Host, { key: '8b88cd04f960c4c8ea7ae2dd79a6ec82694570e6', class: "nano-in-page-nav" }, h("nav", { key: '4df4a5ef8aecad356c6ad1acd9a6a886edce8139', part: "root" }, (this.slotCtrl.has('back') || this.slotCtrl.has('accessory')) && (h("div", { key: 'ed1315ac689d77ffd4005df5a6eeb01f3fc9f599', class: "header" }, h("slot", { key: '0db0fb3919268a14fb924b292302c563181e87c0', name: "back" }), h("slot", { key: '95a5fafda43239ef7cc9208efc254fb335bc9f66', name: "accessory" }))), h("div", { key: '5a273c033b193efe7d4c72c3ccfdbf30b4442eae', class: "desktop-nav" }, h("slot", { key: '7d0cff62b54d21daa5b8e7d9551a9d0ed08cfe6f' })), h("nano-details", { key: 'c337ce8ac65560e5914f8566304f9382540316f2', label: "Menu", class: "details-wrapper mobile-nav", ref: (el) => (this.mobileNavWrapper = el) }))));
|
55
55
|
}
|
56
56
|
};
|
57
57
|
NanoInPageNav.style = inPageNavCss;
|