@limetech/lime-elements 37.67.0 → 37.69.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 +17 -0
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-action-bar-item_2.cjs.entry.js +122 -0
- package/dist/cjs/limel-action-bar-item_2.cjs.entry.js.map +1 -0
- package/dist/cjs/{limel-action-bar_4.cjs.entry.js → limel-action-bar_2.cjs.entry.js} +2 -116
- package/dist/cjs/limel-action-bar_2.cjs.entry.js.map +1 -0
- package/dist/cjs/{limel-breadcrumbs_5.cjs.entry.js → limel-breadcrumbs_7.cjs.entry.js} +3344 -407
- package/dist/cjs/limel-breadcrumbs_7.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-callout.cjs.entry.js +1 -1
- package/dist/cjs/limel-card.cjs.entry.js +85 -0
- package/dist/cjs/limel-card.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-chart.cjs.entry.js +216 -0
- package/dist/cjs/limel-chart.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-chip_2.cjs.entry.js +1 -1
- package/dist/cjs/limel-dynamic-label_2.cjs.entry.js +91 -0
- package/dist/cjs/limel-dynamic-label_2.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-file-viewer.cjs.entry.js +1 -1
- package/dist/cjs/limel-file.cjs.entry.js +1 -1
- package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +1 -1
- package/dist/cjs/limel-icon.cjs.entry.js +208 -0
- package/dist/cjs/limel-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-linear-progress.cjs.entry.js +1 -1
- package/dist/cjs/{limel-icon_2.cjs.entry.js → limel-portal.cjs.entry.js} +1 -201
- package/dist/cjs/limel-portal.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +1 -1
- package/dist/cjs/limel-snackbar.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{translations-6c4447f4.js → translations-9ccca4b6.js} +9 -1
- package/dist/cjs/translations-9ccca4b6.js.map +1 -0
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/card/card.css +202 -0
- package/dist/collection/components/card/card.js +282 -0
- package/dist/collection/components/card/card.js.map +1 -0
- package/dist/collection/components/chart/chart.css +758 -0
- package/dist/collection/components/chart/chart.js +418 -0
- package/dist/collection/components/chart/chart.js.map +1 -0
- package/dist/collection/components/chart/chart.types.js +2 -0
- package/dist/collection/components/chart/chart.types.js.map +1 -0
- package/dist/collection/style/mixins.scss +16 -0
- package/dist/collection/translations/da.js +1 -0
- package/dist/collection/translations/da.js.map +1 -1
- package/dist/collection/translations/de.js +1 -0
- package/dist/collection/translations/de.js.map +1 -1
- package/dist/collection/translations/en.js +1 -0
- package/dist/collection/translations/en.js.map +1 -1
- package/dist/collection/translations/fi.js +1 -0
- package/dist/collection/translations/fi.js.map +1 -1
- package/dist/collection/translations/fr.js +1 -0
- package/dist/collection/translations/fr.js.map +1 -1
- package/dist/collection/translations/nl.js +1 -0
- package/dist/collection/translations/nl.js.map +1 -1
- package/dist/collection/translations/no.js +1 -0
- package/dist/collection/translations/no.js.map +1 -1
- package/dist/collection/translations/sv.js +1 -0
- package/dist/collection/translations/sv.js.map +1 -1
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-action-bar-item_2.entry.js +117 -0
- package/dist/esm/limel-action-bar-item_2.entry.js.map +1 -0
- package/dist/esm/{limel-action-bar_4.entry.js → limel-action-bar_2.entry.js} +3 -115
- package/dist/esm/limel-action-bar_2.entry.js.map +1 -0
- package/dist/esm/{limel-breadcrumbs_5.entry.js → limel-breadcrumbs_7.entry.js} +3333 -398
- package/dist/esm/limel-breadcrumbs_7.entry.js.map +1 -0
- package/dist/esm/limel-callout.entry.js +1 -1
- package/dist/esm/limel-card.entry.js +81 -0
- package/dist/esm/limel-card.entry.js.map +1 -0
- package/dist/esm/limel-chart.entry.js +212 -0
- package/dist/esm/limel-chart.entry.js.map +1 -0
- package/dist/esm/limel-chip_2.entry.js +1 -1
- package/dist/esm/limel-dynamic-label_2.entry.js +86 -0
- package/dist/esm/limel-dynamic-label_2.entry.js.map +1 -0
- package/dist/esm/limel-file-viewer.entry.js +1 -1
- package/dist/esm/limel-file.entry.js +1 -1
- package/dist/esm/limel-flatpickr-adapter.entry.js +1 -1
- package/dist/esm/limel-icon.entry.js +204 -0
- package/dist/esm/limel-icon.entry.js.map +1 -0
- package/dist/esm/limel-linear-progress.entry.js +1 -1
- package/dist/esm/{limel-icon_2.entry.js → limel-portal.entry.js} +2 -201
- package/dist/esm/limel-portal.entry.js.map +1 -0
- package/dist/esm/limel-prosemirror-adapter.entry.js +1 -1
- package/dist/esm/limel-snackbar.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{translations-26583a3b.js → translations-453e0db7.js} +9 -1
- package/dist/esm/translations-453e0db7.js.map +1 -0
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js.map +1 -1
- package/dist/lime-elements/{p-5d12d8d2.entry.js → p-0ee1d461.entry.js} +2 -2
- package/dist/lime-elements/p-18b068c9.entry.js +2 -0
- package/dist/lime-elements/p-18b068c9.entry.js.map +1 -0
- package/dist/lime-elements/{p-195df464.entry.js → p-1e99b371.entry.js} +2 -2
- package/dist/lime-elements/{p-4fd0ac1e.entry.js → p-2cbfe8f9.entry.js} +2 -2
- package/dist/lime-elements/{p-adfa2c05.entry.js → p-3fcb2b67.entry.js} +2 -2
- package/dist/lime-elements/{p-1a0aaf41.entry.js → p-488decb0.entry.js} +2 -2
- package/dist/lime-elements/p-5d08ef7d.entry.js +2 -0
- package/dist/lime-elements/p-5d08ef7d.entry.js.map +1 -0
- package/dist/lime-elements/p-7f9e0f52.entry.js +2 -0
- package/dist/lime-elements/p-7f9e0f52.entry.js.map +1 -0
- package/dist/lime-elements/p-8915fa60.js +2 -0
- package/dist/lime-elements/p-8915fa60.js.map +1 -0
- package/dist/lime-elements/p-97ae94e0.entry.js +266 -0
- package/dist/lime-elements/p-97ae94e0.entry.js.map +1 -0
- package/dist/lime-elements/{p-fbaa1b19.entry.js → p-9d2f6454.entry.js} +2 -2
- package/dist/lime-elements/p-9f8aa8e7.entry.js +2 -0
- package/dist/lime-elements/p-9f8aa8e7.entry.js.map +1 -0
- package/dist/lime-elements/{p-03eea223.entry.js → p-a451cece.entry.js} +2 -2
- package/dist/lime-elements/p-a8e24972.entry.js +2 -0
- package/dist/lime-elements/p-a8e24972.entry.js.map +1 -0
- package/dist/lime-elements/p-d696f6b8.entry.js +2 -0
- package/dist/lime-elements/p-d696f6b8.entry.js.map +1 -0
- package/dist/lime-elements/p-d93f1964.entry.js +2 -0
- package/dist/lime-elements/p-d93f1964.entry.js.map +1 -0
- package/dist/lime-elements/{p-0f484317.entry.js → p-dd031410.entry.js} +2 -2
- package/dist/lime-elements/style/mixins.scss +16 -0
- package/dist/scss/mixins.scss +16 -0
- package/dist/types/components/card/card.d.ts +75 -0
- package/dist/types/components/chart/chart.d.ts +94 -0
- package/dist/types/components/chart/chart.types.d.ts +25 -0
- package/dist/types/components.d.ts +346 -4
- package/dist/types/translations/da.d.ts +1 -0
- package/dist/types/translations/de.d.ts +1 -0
- package/dist/types/translations/en.d.ts +1 -0
- package/dist/types/translations/fi.d.ts +1 -0
- package/dist/types/translations/fr.d.ts +1 -0
- package/dist/types/translations/nl.d.ts +1 -0
- package/dist/types/translations/no.d.ts +1 -0
- package/dist/types/translations/sv.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/component-864afce0.js +0 -2447
- package/dist/cjs/component-864afce0.js.map +0 -1
- package/dist/cjs/limel-action-bar_4.cjs.entry.js.map +0 -1
- package/dist/cjs/limel-breadcrumbs_5.cjs.entry.js.map +0 -1
- package/dist/cjs/limel-dynamic-label_4.cjs.entry.js +0 -600
- package/dist/cjs/limel-dynamic-label_4.cjs.entry.js.map +0 -1
- package/dist/cjs/limel-icon_2.cjs.entry.js.map +0 -1
- package/dist/cjs/translations-6c4447f4.js.map +0 -1
- package/dist/esm/component-5e233629.js +0 -2439
- package/dist/esm/component-5e233629.js.map +0 -1
- package/dist/esm/limel-action-bar_4.entry.js.map +0 -1
- package/dist/esm/limel-breadcrumbs_5.entry.js.map +0 -1
- package/dist/esm/limel-dynamic-label_4.entry.js +0 -593
- package/dist/esm/limel-dynamic-label_4.entry.js.map +0 -1
- package/dist/esm/limel-icon_2.entry.js.map +0 -1
- package/dist/esm/translations-26583a3b.js.map +0 -1
- package/dist/lime-elements/p-61047574.entry.js +0 -2
- package/dist/lime-elements/p-61047574.entry.js.map +0 -1
- package/dist/lime-elements/p-b9b0853b.entry.js +0 -68
- package/dist/lime-elements/p-b9b0853b.entry.js.map +0 -1
- package/dist/lime-elements/p-bd261424.entry.js +0 -2
- package/dist/lime-elements/p-bd261424.entry.js.map +0 -1
- package/dist/lime-elements/p-d528606a.js +0 -200
- package/dist/lime-elements/p-d528606a.js.map +0 -1
- package/dist/lime-elements/p-e78fcffb.entry.js +0 -2
- package/dist/lime-elements/p-e78fcffb.entry.js.map +0 -1
- package/dist/lime-elements/p-fe15bcbb.js +0 -2
- package/dist/lime-elements/p-fe15bcbb.js.map +0 -1
- /package/dist/lime-elements/{p-5d12d8d2.entry.js.map → p-0ee1d461.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-195df464.entry.js.map → p-1e99b371.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-4fd0ac1e.entry.js.map → p-2cbfe8f9.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-adfa2c05.entry.js.map → p-3fcb2b67.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-1a0aaf41.entry.js.map → p-488decb0.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-fbaa1b19.entry.js.map → p-9d2f6454.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-03eea223.entry.js.map → p-a451cece.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-0f484317.entry.js.map → p-dd031410.entry.js.map} +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-d1052409.js');
|
|
6
|
+
const config = require('./config-e7e1a299.js');
|
|
7
|
+
|
|
8
|
+
class CacheStorageIconCache {
|
|
9
|
+
constructor(cache) {
|
|
10
|
+
this.promises = {};
|
|
11
|
+
this.cache = cache;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get icon data from the cache
|
|
15
|
+
*
|
|
16
|
+
* @param name - Name of the icon
|
|
17
|
+
* @param path - Path on the server where the assets are located
|
|
18
|
+
* @returns SVG markup
|
|
19
|
+
*/
|
|
20
|
+
async get(name, path = '') {
|
|
21
|
+
const cache = await this.cache;
|
|
22
|
+
const url = this.getUrl(name, path);
|
|
23
|
+
let response = await cache.match(url);
|
|
24
|
+
if (!response) {
|
|
25
|
+
response = await this.fetchData(url, cache);
|
|
26
|
+
}
|
|
27
|
+
return this.getIcon(response);
|
|
28
|
+
}
|
|
29
|
+
async fetchData(url, cache) {
|
|
30
|
+
let requestPromise = this.promises[url];
|
|
31
|
+
if (requestPromise === undefined) {
|
|
32
|
+
requestPromise = cache.add(url);
|
|
33
|
+
this.promises[url] = requestPromise;
|
|
34
|
+
}
|
|
35
|
+
await requestPromise;
|
|
36
|
+
return cache.match(url);
|
|
37
|
+
}
|
|
38
|
+
/*
|
|
39
|
+
* Get icon data from a response
|
|
40
|
+
*/
|
|
41
|
+
async getIcon(response) {
|
|
42
|
+
let svgData = await response.text();
|
|
43
|
+
// Some of the icons in the Icons8 library have hard coded black color on some of the paths.
|
|
44
|
+
// In order to apply coloring with CSS, these have to be set to 'currentColor'
|
|
45
|
+
svgData = svgData.replace(/#000000/g, 'currentColor');
|
|
46
|
+
if (!this.validSvg(svgData)) {
|
|
47
|
+
throw new Error('Invalid SVG');
|
|
48
|
+
}
|
|
49
|
+
return svgData;
|
|
50
|
+
}
|
|
51
|
+
/*
|
|
52
|
+
* Check if the given data is a valid SVG document
|
|
53
|
+
*/
|
|
54
|
+
validSvg(data) {
|
|
55
|
+
const parser = new DOMParser();
|
|
56
|
+
const svgDoc = parser.parseFromString(data, 'image/svg+xml');
|
|
57
|
+
return svgDoc.documentElement.tagName.toLowerCase() === 'svg';
|
|
58
|
+
}
|
|
59
|
+
getUrl(name, path) {
|
|
60
|
+
let iconPath = path || '';
|
|
61
|
+
if (path && !path.endsWith('/')) {
|
|
62
|
+
iconPath = `${path}/`;
|
|
63
|
+
}
|
|
64
|
+
return `${iconPath}assets/icons/${name}.svg`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class InMemoryIconCache {
|
|
69
|
+
constructor() {
|
|
70
|
+
/*
|
|
71
|
+
* Cache of all loaded SVGs
|
|
72
|
+
*/
|
|
73
|
+
this.cache = {};
|
|
74
|
+
/*
|
|
75
|
+
* Contains resolve functions for all unresolved promises that are waiting for SVG data.
|
|
76
|
+
*/
|
|
77
|
+
this.resolveFunctions = {};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get icon data from the cache
|
|
81
|
+
*
|
|
82
|
+
* @param name - Name of the icon
|
|
83
|
+
* @param path - Path on the server where the assets are located
|
|
84
|
+
* @returns SVG markup
|
|
85
|
+
*/
|
|
86
|
+
async get(name, path = '') {
|
|
87
|
+
if (!this.cache[name]) {
|
|
88
|
+
this.cache[name] = await this.getIcon(name, path);
|
|
89
|
+
}
|
|
90
|
+
return this.cache[name];
|
|
91
|
+
}
|
|
92
|
+
/*
|
|
93
|
+
* Creates and returns a promise that will be resolved when SVG data is available
|
|
94
|
+
*/
|
|
95
|
+
getIcon(name, path) {
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
if (!this.resolveFunctions[name]) {
|
|
98
|
+
this.resolveFunctions[name] = [];
|
|
99
|
+
this.fetchData(name, path);
|
|
100
|
+
}
|
|
101
|
+
this.resolveFunctions[name].push(resolve);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/*
|
|
105
|
+
* Fetch SVG data from the server
|
|
106
|
+
*/
|
|
107
|
+
async fetchData(name, path) {
|
|
108
|
+
let iconPath = path || '';
|
|
109
|
+
if (path && !path.endsWith('/')) {
|
|
110
|
+
iconPath = `${path}/`;
|
|
111
|
+
}
|
|
112
|
+
const response = await fetch(`${iconPath}assets/icons/${name}.svg`);
|
|
113
|
+
let svgData = await response.text();
|
|
114
|
+
// Some of the icons in the Icons8 library have hard coded black color on some of the paths.
|
|
115
|
+
// In order to apply coloring with CSS, these have to be set to 'currentColor'
|
|
116
|
+
svgData = svgData.replace(/#000000/g, 'currentColor');
|
|
117
|
+
if (!this.validSvg(svgData)) {
|
|
118
|
+
throw new Error('Invalid SVG');
|
|
119
|
+
}
|
|
120
|
+
this.resolvePromises(name, svgData);
|
|
121
|
+
}
|
|
122
|
+
/*
|
|
123
|
+
* Check if the given data is a valid SVG document
|
|
124
|
+
*/
|
|
125
|
+
validSvg(data) {
|
|
126
|
+
const parser = new DOMParser();
|
|
127
|
+
const svgDoc = parser.parseFromString(data, 'image/svg+xml');
|
|
128
|
+
return svgDoc.documentElement.tagName.toLowerCase() === 'svg';
|
|
129
|
+
}
|
|
130
|
+
/*
|
|
131
|
+
* Resolve all promises waiting for data for a specific icon
|
|
132
|
+
*/
|
|
133
|
+
resolvePromises(name, svgData) {
|
|
134
|
+
const resolves = this.resolveFunctions[name];
|
|
135
|
+
resolves.forEach((resolve) => {
|
|
136
|
+
resolve(svgData);
|
|
137
|
+
});
|
|
138
|
+
this.resolveFunctions[name] = null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const CACHE_NAME = '@limetech/lime-elements/icons';
|
|
143
|
+
function createIconCache() {
|
|
144
|
+
try {
|
|
145
|
+
const cache = caches.open(CACHE_NAME);
|
|
146
|
+
return new CacheStorageIconCache(cache);
|
|
147
|
+
}
|
|
148
|
+
catch (_a) {
|
|
149
|
+
return new InMemoryIconCache();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const iconCache = (() => {
|
|
153
|
+
return createIconCache();
|
|
154
|
+
})();
|
|
155
|
+
|
|
156
|
+
const iconCss = ":host{background-color:var(--icon-background-color, transparent);border-radius:50%;display:inline-block;line-height:0;box-sizing:border-box}:host svg{fill:currentColor;height:100%;pointer-events:none;width:100%}:host div{margin:var(--limel-icon-svg-margin, 0)}:host([hidden]){display:none}:host([size=x-small]){height:1rem !important;width:1rem !important}:host([size=small]){height:1.25rem !important;width:1.25rem !important}:host([size=medium]){height:1.5rem !important;width:1.5rem !important}:host([size=large]){height:1.75rem !important;width:1.75rem !important}:host([badge][size=x-small]){height:1.5rem !important;width:1.5rem !important;--limel-icon-svg-margin:0.25rem}:host([badge][size=small]){height:1.75rem !important;width:1.75rem !important;--limel-icon-svg-margin:0.25rem}:host([badge][size=medium]){height:2.5rem !important;width:2.5rem !important;--limel-icon-svg-margin:0.5rem}:host([badge][size=large]){height:2.75rem !important;width:2.75rem !important;--limel-icon-svg-margin:0.5rem}";
|
|
157
|
+
|
|
158
|
+
const Icon = class {
|
|
159
|
+
constructor(hostRef) {
|
|
160
|
+
index.registerInstance(this, hostRef);
|
|
161
|
+
this.size = undefined;
|
|
162
|
+
this.name = undefined;
|
|
163
|
+
this.badge = undefined;
|
|
164
|
+
}
|
|
165
|
+
componentDidLoad() {
|
|
166
|
+
this.loadIcon(this.name);
|
|
167
|
+
}
|
|
168
|
+
render() {
|
|
169
|
+
return index.h("div", { class: "container" });
|
|
170
|
+
}
|
|
171
|
+
async loadIcon(name) {
|
|
172
|
+
if (name === undefined || name === '') {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const svgData = await this.loadSvg(name);
|
|
176
|
+
this.renderSvg(svgData);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Load the SVG data for the icon from the icon cache
|
|
180
|
+
*
|
|
181
|
+
* @param name - name of the icon
|
|
182
|
+
* @returns the icon SVG data
|
|
183
|
+
*/
|
|
184
|
+
loadSvg(name) {
|
|
185
|
+
return iconCache.get(name, config.globalConfig.iconPath);
|
|
186
|
+
}
|
|
187
|
+
/*
|
|
188
|
+
* There is no way to style external SVG files with CSS, i.e. SVGs loaded
|
|
189
|
+
* with <img src="file.svg" /> or <object data="file.svg" type="image/svg+xml" />
|
|
190
|
+
* will remain the way they look in the file.
|
|
191
|
+
* Therefore we inject the svg as inline markup instead.
|
|
192
|
+
*/
|
|
193
|
+
renderSvg(svgData) {
|
|
194
|
+
const container = this.host.shadowRoot.querySelector('div.container');
|
|
195
|
+
if (container) {
|
|
196
|
+
container.innerHTML = svgData;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
get host() { return index.getElement(this); }
|
|
200
|
+
static get watchers() { return {
|
|
201
|
+
"name": ["loadIcon"]
|
|
202
|
+
}; }
|
|
203
|
+
};
|
|
204
|
+
Icon.style = iconCss;
|
|
205
|
+
|
|
206
|
+
exports.limel_icon = Icon;
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=limel-icon.cjs.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"limel-icon.entry.cjs.js","mappings":";;;;;;;MAAa,qBAAqB;EAQ9B,YAAY,KAAqB;IAFzB,aAAQ,GAAkC,EAAE,CAAC;IAGjD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;GACtB;;;;;;;;EASM,MAAM,GAAG,CAAC,IAAY,EAAE,IAAI,GAAG,EAAE;IACpC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEpC,IAAI,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,QAAQ,EAAE;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C,IAAI,CAAC,IAAI,CAAC,CAAC;GAC5B;EAEM,MAAM;IACT,OAAOA,iBAAK,KAAK,EAAC,WAAW,GAAG,CAAC;GACpC;EAGS,MAAM,QAAQ,CAAC,IAAY;IACjC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,EAAE;MACnC,OAAO;KACV;IAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;GAC3B;;;;;;;EAQO,OAAO,CAAC,IAAY;IACxB,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,EAAEC,mBAAY,CAAC,QAAQ,CAAC,CAAC;GACrD;;;;;;;EAQO,SAAS,CAAC,OAAe;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACtE,IAAI,SAAS,EAAE;MACX,SAAS,CAAC,SAAS,GAAG,OAAO,CAAC;KACjC;GACJ;;;;;;;;;;","names":["h","globalConfig"],"sources":["./src/global/icon-cache/cache-storage-icon-cache.ts","./src/global/icon-cache/in-memory-icon-cache.ts","./src/global/icon-cache/factory.ts","./src/components/icon/icon.scss?tag=limel-icon&encapsulation=shadow","./src/components/icon/icon.tsx"],"sourcesContent":["export class CacheStorageIconCache {\n /*\n * Cache of all loaded SVGs\n */\n private cache: Promise<Cache>;\n\n private promises: Record<string, Promise<void>> = {};\n\n constructor(cache: Promise<Cache>) {\n this.cache = cache;\n }\n\n /**\n * Get icon data from the cache\n *\n * @param name - Name of the icon\n * @param path - Path on the server where the assets are located\n * @returns SVG markup\n */\n public async get(name: string, path = ''): Promise<string> {\n const cache = await this.cache;\n const url = this.getUrl(name, path);\n\n let response = await cache.match(url);\n if (!response) {\n response = await this.fetchData(url, cache);\n }\n\n return this.getIcon(response);\n }\n\n private async fetchData(url: string, cache: Cache): Promise<Response> {\n let requestPromise = this.promises[url];\n if (requestPromise === undefined) {\n requestPromise = cache.add(url);\n this.promises[url] = requestPromise;\n }\n\n await requestPromise;\n\n return cache.match(url);\n }\n\n /*\n * Get icon data from a response\n */\n private async getIcon(response: Response): Promise<string> {\n let svgData = await response.text();\n\n // Some of the icons in the Icons8 library have hard coded black color on some of the paths.\n // In order to apply coloring with CSS, these have to be set to 'currentColor'\n svgData = svgData.replace(/#000000/g, 'currentColor');\n\n if (!this.validSvg(svgData)) {\n throw new Error('Invalid SVG');\n }\n\n return svgData;\n }\n\n /*\n * Check if the given data is a valid SVG document\n */\n private validSvg(data) {\n const parser = new DOMParser();\n const svgDoc = parser.parseFromString(data, 'image/svg+xml');\n\n return svgDoc.documentElement.tagName.toLowerCase() === 'svg';\n }\n\n private getUrl(name: string, path: string): string {\n let iconPath = path || '';\n if (path && !path.endsWith('/')) {\n iconPath = `${path}/`;\n }\n\n return `${iconPath}assets/icons/${name}.svg`;\n }\n}\n","export class InMemoryIconCache {\n /*\n * Cache of all loaded SVGs\n */\n private cache = {};\n\n /*\n * Contains resolve functions for all unresolved promises that are waiting for SVG data.\n */\n private resolveFunctions = {};\n\n /**\n * Get icon data from the cache\n *\n * @param name - Name of the icon\n * @param path - Path on the server where the assets are located\n * @returns SVG markup\n */\n public async get(name: string, path = ''): Promise<string> {\n if (!this.cache[name]) {\n this.cache[name] = await this.getIcon(name, path);\n }\n\n return this.cache[name];\n }\n\n /*\n * Creates and returns a promise that will be resolved when SVG data is available\n */\n private getIcon(name, path) {\n return new Promise((resolve) => {\n if (!this.resolveFunctions[name]) {\n this.resolveFunctions[name] = [];\n this.fetchData(name, path);\n }\n\n this.resolveFunctions[name].push(resolve);\n });\n }\n\n /*\n * Fetch SVG data from the server\n */\n private async fetchData(name, path) {\n let iconPath = path || '';\n if (path && !path.endsWith('/')) {\n iconPath = `${path}/`;\n }\n\n const response = await fetch(`${iconPath}assets/icons/${name}.svg`);\n\n let svgData = await response.text();\n\n // Some of the icons in the Icons8 library have hard coded black color on some of the paths.\n // In order to apply coloring with CSS, these have to be set to 'currentColor'\n svgData = svgData.replace(/#000000/g, 'currentColor');\n if (!this.validSvg(svgData)) {\n throw new Error('Invalid SVG');\n }\n\n this.resolvePromises(name, svgData);\n }\n\n /*\n * Check if the given data is a valid SVG document\n */\n private validSvg(data) {\n const parser = new DOMParser();\n const svgDoc = parser.parseFromString(data, 'image/svg+xml');\n\n return svgDoc.documentElement.tagName.toLowerCase() === 'svg';\n }\n\n /*\n * Resolve all promises waiting for data for a specific icon\n */\n private resolvePromises(name, svgData) {\n const resolves = this.resolveFunctions[name];\n resolves.forEach((resolve) => {\n resolve(svgData);\n });\n this.resolveFunctions[name] = null;\n }\n}\n","import { CacheStorageIconCache } from './cache-storage-icon-cache';\nimport { InMemoryIconCache } from './in-memory-icon-cache';\n\nconst CACHE_NAME = '@limetech/lime-elements/icons';\n\nfunction createIconCache() {\n try {\n const cache = caches.open(CACHE_NAME);\n\n return new CacheStorageIconCache(cache);\n } catch {\n return new InMemoryIconCache();\n }\n}\n\nexport default (() => {\n return createIconCache();\n})();\n","/**\n * @prop --icon-background-color: Background color when attribute `badge` is set to `true`. Defaults to `transparent`.\n */\n\n:host {\n background-color: var(--icon-background-color, transparent);\n border-radius: 50%;\n display: inline-block;\n line-height: 0;\n box-sizing: border-box;\n\n svg {\n fill: currentColor;\n height: 100%;\n pointer-events: none;\n width: 100%;\n }\n\n div {\n margin: var(--limel-icon-svg-margin, 0);\n }\n}\n\n:host([hidden]) {\n display: none;\n}\n\n:host([size='x-small']) {\n height: 1rem !important;\n width: 1rem !important;\n}\n:host([size='small']) {\n height: 1.25rem !important;\n width: 1.25rem !important;\n}\n:host([size='medium']) {\n height: 1.5rem !important;\n width: 1.5rem !important;\n}\n:host([size='large']) {\n height: 1.75rem !important;\n width: 1.75rem !important;\n}\n\n:host([badge][size='x-small']) {\n height: 1.5rem !important;\n width: 1.5rem !important;\n\n --limel-icon-svg-margin: 0.25rem;\n}\n:host([badge][size='small']) {\n height: 1.75rem !important;\n width: 1.75rem !important;\n\n --limel-icon-svg-margin: 0.25rem;\n}\n:host([badge][size='medium']) {\n height: 2.5rem !important;\n width: 2.5rem !important;\n\n --limel-icon-svg-margin: 0.5rem;\n}\n:host([badge][size='large']) {\n height: 2.75rem !important;\n width: 2.75rem !important;\n\n --limel-icon-svg-margin: 0.5rem;\n}\n","import { Component, Element, h, Prop, Watch } from '@stencil/core';\nimport { globalConfig } from '../../global/config';\nimport iconCache from '../../global/icon-cache/factory';\nimport { IconSize } from './icon.types';\n\n/**\n * Search for an icon and **click on it to copy its name to clipboard**.\n * <limel-example-icon-finder />\n *\n * *******\n *\n * :::important\n * To install your icon set correctly, please read the [documentation here](#/).\n * :::\n *\n * The size and color of the icon is normally set in CSS, however there are a few\n * standard sizes defined that can be used with the `size` property.\n *\n * :::note\n * There are icons included in the `@lundalogik/lime-icons8` package which are\n * designed by our designers at Lime.\n * The names of these icons start with `-lime-`, which makes them easy to\n * find using the Icon Finder tool below.\n *\n * Some of the multi-colored `-lime-` icons use our own CSS variables\n * (instead of HEX or RGB) values to visualize their colors. Thus, you must import\n * our color palette css files into your project to render the icons properly.\n * Read more about our [Color System](#/DesignGuidelines/color-system.md/)\n * and how to do this.\n * :::\n *\n * @exampleComponent limel-example-icon-name\n * @exampleComponent limel-example-icon-size\n * @exampleComponent limel-example-icon-color\n */\n@Component({\n tag: 'limel-icon',\n shadow: true,\n styleUrl: 'icon.scss',\n})\nexport class Icon {\n /**\n * Size of the icon\n */\n @Prop({ reflect: true })\n public size: IconSize;\n\n /**\n * Name of the icon\n */\n @Prop({ reflect: true })\n public name: string;\n\n /**\n * Set to `true` to give the icon a round background with some padding.\n * Only works when the `size` attribute is also set.\n */\n @Prop({ reflect: true })\n public badge: boolean;\n\n @Element()\n private host: HTMLLimelIconElement;\n\n public componentDidLoad() {\n this.loadIcon(this.name);\n }\n\n public render() {\n return <div class=\"container\" />;\n }\n\n @Watch('name')\n protected async loadIcon(name: string) {\n if (name === undefined || name === '') {\n return;\n }\n\n const svgData = await this.loadSvg(name);\n this.renderSvg(svgData);\n }\n\n /**\n * Load the SVG data for the icon from the icon cache\n *\n * @param name - name of the icon\n * @returns the icon SVG data\n */\n private loadSvg(name: string) {\n return iconCache.get(name, globalConfig.iconPath);\n }\n\n /*\n * There is no way to style external SVG files with CSS, i.e. SVGs loaded\n * with <img src=\"file.svg\" /> or <object data=\"file.svg\" type=\"image/svg+xml\" />\n * will remain the way they look in the file.\n * Therefore we inject the svg as inline markup instead.\n */\n private renderSvg(svgData: string) {\n const container = this.host.shadowRoot.querySelector('div.container');\n if (container) {\n container.innerHTML = svgData;\n }\n }\n}\n"],"version":3}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d1052409.js');
|
|
6
|
-
const translations = require('./translations-
|
|
6
|
+
const translations = require('./translations-9ccca4b6.js');
|
|
7
7
|
|
|
8
8
|
const linearProgressCss = ":host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}:host(limel-linear-progress){isolation:isolate;position:relative;overflow:hidden;display:flex;width:100%;height:0.25rem;border-radius:0.25rem;background-color:var(--background-color, rgb(var(--contrast-800), 0.5))}.progress{height:100%;width:var(--percentage, 0%);border-radius:0.25rem;background-color:var(--mdc-theme-primary)}:host(limel-linear-progress[indeterminate]) .progress{background-color:transparent;width:100%}:host(limel-linear-progress[indeterminate]) .progress:before,:host(limel-linear-progress[indeterminate]) .progress:after{will-change:left, right, opacity;content:\"\";position:absolute;inset:0;height:100%;border-radius:0.25rem;opacity:0;background-color:var(--mdc-theme-primary)}:host(limel-linear-progress[indeterminate]) .progress:before{animation:indeterminate 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite}:host(limel-linear-progress[indeterminate]) .progress:after{animation:indeterminate-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite 1.15s}@keyframes indeterminate{0%{left:-35%;right:100%;opacity:0}10%,80%{opacity:1}60%{left:100%;right:-90%}100%{left:100%;right:-90%;opacity:0}}@keyframes indeterminate-short{0%{left:-200%;right:100%;opacity:0}10%,80%{opacity:1}60%{left:107%;right:-8%}100%{left:107%;right:-8%;opacity:0}}";
|
|
9
9
|
|
|
@@ -3,205 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d1052409.js');
|
|
6
|
-
const config = require('./config-e7e1a299.js');
|
|
7
|
-
|
|
8
|
-
class CacheStorageIconCache {
|
|
9
|
-
constructor(cache) {
|
|
10
|
-
this.promises = {};
|
|
11
|
-
this.cache = cache;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get icon data from the cache
|
|
15
|
-
*
|
|
16
|
-
* @param name - Name of the icon
|
|
17
|
-
* @param path - Path on the server where the assets are located
|
|
18
|
-
* @returns SVG markup
|
|
19
|
-
*/
|
|
20
|
-
async get(name, path = '') {
|
|
21
|
-
const cache = await this.cache;
|
|
22
|
-
const url = this.getUrl(name, path);
|
|
23
|
-
let response = await cache.match(url);
|
|
24
|
-
if (!response) {
|
|
25
|
-
response = await this.fetchData(url, cache);
|
|
26
|
-
}
|
|
27
|
-
return this.getIcon(response);
|
|
28
|
-
}
|
|
29
|
-
async fetchData(url, cache) {
|
|
30
|
-
let requestPromise = this.promises[url];
|
|
31
|
-
if (requestPromise === undefined) {
|
|
32
|
-
requestPromise = cache.add(url);
|
|
33
|
-
this.promises[url] = requestPromise;
|
|
34
|
-
}
|
|
35
|
-
await requestPromise;
|
|
36
|
-
return cache.match(url);
|
|
37
|
-
}
|
|
38
|
-
/*
|
|
39
|
-
* Get icon data from a response
|
|
40
|
-
*/
|
|
41
|
-
async getIcon(response) {
|
|
42
|
-
let svgData = await response.text();
|
|
43
|
-
// Some of the icons in the Icons8 library have hard coded black color on some of the paths.
|
|
44
|
-
// In order to apply coloring with CSS, these have to be set to 'currentColor'
|
|
45
|
-
svgData = svgData.replace(/#000000/g, 'currentColor');
|
|
46
|
-
if (!this.validSvg(svgData)) {
|
|
47
|
-
throw new Error('Invalid SVG');
|
|
48
|
-
}
|
|
49
|
-
return svgData;
|
|
50
|
-
}
|
|
51
|
-
/*
|
|
52
|
-
* Check if the given data is a valid SVG document
|
|
53
|
-
*/
|
|
54
|
-
validSvg(data) {
|
|
55
|
-
const parser = new DOMParser();
|
|
56
|
-
const svgDoc = parser.parseFromString(data, 'image/svg+xml');
|
|
57
|
-
return svgDoc.documentElement.tagName.toLowerCase() === 'svg';
|
|
58
|
-
}
|
|
59
|
-
getUrl(name, path) {
|
|
60
|
-
let iconPath = path || '';
|
|
61
|
-
if (path && !path.endsWith('/')) {
|
|
62
|
-
iconPath = `${path}/`;
|
|
63
|
-
}
|
|
64
|
-
return `${iconPath}assets/icons/${name}.svg`;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
class InMemoryIconCache {
|
|
69
|
-
constructor() {
|
|
70
|
-
/*
|
|
71
|
-
* Cache of all loaded SVGs
|
|
72
|
-
*/
|
|
73
|
-
this.cache = {};
|
|
74
|
-
/*
|
|
75
|
-
* Contains resolve functions for all unresolved promises that are waiting for SVG data.
|
|
76
|
-
*/
|
|
77
|
-
this.resolveFunctions = {};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get icon data from the cache
|
|
81
|
-
*
|
|
82
|
-
* @param name - Name of the icon
|
|
83
|
-
* @param path - Path on the server where the assets are located
|
|
84
|
-
* @returns SVG markup
|
|
85
|
-
*/
|
|
86
|
-
async get(name, path = '') {
|
|
87
|
-
if (!this.cache[name]) {
|
|
88
|
-
this.cache[name] = await this.getIcon(name, path);
|
|
89
|
-
}
|
|
90
|
-
return this.cache[name];
|
|
91
|
-
}
|
|
92
|
-
/*
|
|
93
|
-
* Creates and returns a promise that will be resolved when SVG data is available
|
|
94
|
-
*/
|
|
95
|
-
getIcon(name, path) {
|
|
96
|
-
return new Promise((resolve) => {
|
|
97
|
-
if (!this.resolveFunctions[name]) {
|
|
98
|
-
this.resolveFunctions[name] = [];
|
|
99
|
-
this.fetchData(name, path);
|
|
100
|
-
}
|
|
101
|
-
this.resolveFunctions[name].push(resolve);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/*
|
|
105
|
-
* Fetch SVG data from the server
|
|
106
|
-
*/
|
|
107
|
-
async fetchData(name, path) {
|
|
108
|
-
let iconPath = path || '';
|
|
109
|
-
if (path && !path.endsWith('/')) {
|
|
110
|
-
iconPath = `${path}/`;
|
|
111
|
-
}
|
|
112
|
-
const response = await fetch(`${iconPath}assets/icons/${name}.svg`);
|
|
113
|
-
let svgData = await response.text();
|
|
114
|
-
// Some of the icons in the Icons8 library have hard coded black color on some of the paths.
|
|
115
|
-
// In order to apply coloring with CSS, these have to be set to 'currentColor'
|
|
116
|
-
svgData = svgData.replace(/#000000/g, 'currentColor');
|
|
117
|
-
if (!this.validSvg(svgData)) {
|
|
118
|
-
throw new Error('Invalid SVG');
|
|
119
|
-
}
|
|
120
|
-
this.resolvePromises(name, svgData);
|
|
121
|
-
}
|
|
122
|
-
/*
|
|
123
|
-
* Check if the given data is a valid SVG document
|
|
124
|
-
*/
|
|
125
|
-
validSvg(data) {
|
|
126
|
-
const parser = new DOMParser();
|
|
127
|
-
const svgDoc = parser.parseFromString(data, 'image/svg+xml');
|
|
128
|
-
return svgDoc.documentElement.tagName.toLowerCase() === 'svg';
|
|
129
|
-
}
|
|
130
|
-
/*
|
|
131
|
-
* Resolve all promises waiting for data for a specific icon
|
|
132
|
-
*/
|
|
133
|
-
resolvePromises(name, svgData) {
|
|
134
|
-
const resolves = this.resolveFunctions[name];
|
|
135
|
-
resolves.forEach((resolve) => {
|
|
136
|
-
resolve(svgData);
|
|
137
|
-
});
|
|
138
|
-
this.resolveFunctions[name] = null;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const CACHE_NAME = '@limetech/lime-elements/icons';
|
|
143
|
-
function createIconCache() {
|
|
144
|
-
try {
|
|
145
|
-
const cache = caches.open(CACHE_NAME);
|
|
146
|
-
return new CacheStorageIconCache(cache);
|
|
147
|
-
}
|
|
148
|
-
catch (_a) {
|
|
149
|
-
return new InMemoryIconCache();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const iconCache = (() => {
|
|
153
|
-
return createIconCache();
|
|
154
|
-
})();
|
|
155
|
-
|
|
156
|
-
const iconCss = ":host{background-color:var(--icon-background-color, transparent);border-radius:50%;display:inline-block;line-height:0;box-sizing:border-box}:host svg{fill:currentColor;height:100%;pointer-events:none;width:100%}:host div{margin:var(--limel-icon-svg-margin, 0)}:host([hidden]){display:none}:host([size=x-small]){height:1rem !important;width:1rem !important}:host([size=small]){height:1.25rem !important;width:1.25rem !important}:host([size=medium]){height:1.5rem !important;width:1.5rem !important}:host([size=large]){height:1.75rem !important;width:1.75rem !important}:host([badge][size=x-small]){height:1.5rem !important;width:1.5rem !important;--limel-icon-svg-margin:0.25rem}:host([badge][size=small]){height:1.75rem !important;width:1.75rem !important;--limel-icon-svg-margin:0.25rem}:host([badge][size=medium]){height:2.5rem !important;width:2.5rem !important;--limel-icon-svg-margin:0.5rem}:host([badge][size=large]){height:2.75rem !important;width:2.75rem !important;--limel-icon-svg-margin:0.5rem}";
|
|
157
|
-
|
|
158
|
-
const Icon = class {
|
|
159
|
-
constructor(hostRef) {
|
|
160
|
-
index.registerInstance(this, hostRef);
|
|
161
|
-
this.size = undefined;
|
|
162
|
-
this.name = undefined;
|
|
163
|
-
this.badge = undefined;
|
|
164
|
-
}
|
|
165
|
-
componentDidLoad() {
|
|
166
|
-
this.loadIcon(this.name);
|
|
167
|
-
}
|
|
168
|
-
render() {
|
|
169
|
-
return index.h("div", { class: "container" });
|
|
170
|
-
}
|
|
171
|
-
async loadIcon(name) {
|
|
172
|
-
if (name === undefined || name === '') {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const svgData = await this.loadSvg(name);
|
|
176
|
-
this.renderSvg(svgData);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Load the SVG data for the icon from the icon cache
|
|
180
|
-
*
|
|
181
|
-
* @param name - name of the icon
|
|
182
|
-
* @returns the icon SVG data
|
|
183
|
-
*/
|
|
184
|
-
loadSvg(name) {
|
|
185
|
-
return iconCache.get(name, config.globalConfig.iconPath);
|
|
186
|
-
}
|
|
187
|
-
/*
|
|
188
|
-
* There is no way to style external SVG files with CSS, i.e. SVGs loaded
|
|
189
|
-
* with <img src="file.svg" /> or <object data="file.svg" type="image/svg+xml" />
|
|
190
|
-
* will remain the way they look in the file.
|
|
191
|
-
* Therefore we inject the svg as inline markup instead.
|
|
192
|
-
*/
|
|
193
|
-
renderSvg(svgData) {
|
|
194
|
-
const container = this.host.shadowRoot.querySelector('div.container');
|
|
195
|
-
if (container) {
|
|
196
|
-
container.innerHTML = svgData;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
get host() { return index.getElement(this); }
|
|
200
|
-
static get watchers() { return {
|
|
201
|
-
"name": ["loadIcon"]
|
|
202
|
-
}; }
|
|
203
|
-
};
|
|
204
|
-
Icon.style = iconCss;
|
|
205
6
|
|
|
206
7
|
var top = 'top';
|
|
207
8
|
var bottom = 'bottom';
|
|
@@ -2246,7 +2047,6 @@ const Portal = class {
|
|
|
2246
2047
|
};
|
|
2247
2048
|
Portal.style = portalCss;
|
|
2248
2049
|
|
|
2249
|
-
exports.limel_icon = Icon;
|
|
2250
2050
|
exports.limel_portal = Portal;
|
|
2251
2051
|
|
|
2252
|
-
//# sourceMappingURL=limel-
|
|
2052
|
+
//# sourceMappingURL=limel-portal.cjs.entry.js.map
|