@limetech/lime-elements 36.4.0-next.5 → 36.4.0-next.7
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/limel-icon.cjs.entry.js +31 -44
- package/dist/cjs/limel-list_2.cjs.entry.js +1 -1
- package/dist/cjs/limel-menu_2.cjs.entry.js +1 -1
- package/dist/collection/components/list/list.css +2 -2
- package/dist/collection/components/menu-list/menu-list.css +2 -2
- package/dist/collection/global/icon-cache.js +29 -42
- package/dist/esm/limel-icon.entry.js +31 -44
- package/dist/esm/limel-list_2.entry.js +1 -1
- package/dist/esm/limel-menu_2.entry.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-a030e9ab.entry.js → p-a3acc38f.entry.js} +1 -1
- package/dist/lime-elements/{p-f1d963ec.entry.js → p-b0bfec52.entry.js} +1 -1
- package/dist/lime-elements/p-d55d88a5.entry.js +1 -0
- package/dist/types/global/icon-cache.d.ts +6 -5
- package/package.json +5 -5
- package/dist/lime-elements/p-75d01713.entry.js +0 -1
|
@@ -865,7 +865,7 @@ limel-helper-line {
|
|
|
865
865
|
* @prop --list-grid-gap: Distance between items in a list that has `has-grid-layout` class. Defaults to `0.75rem`.
|
|
866
866
|
* @prop --list-background-color-of-odd-interactive-items: Background color of odd list items, when `has-striped-rows` class is applied to the component. Defaults to `--contrast-200`.
|
|
867
867
|
* @prop --list-background-color-of-even-interactive-items: Background color of even list items, when `has-striped-rows` class is applied to the component. Defaults to `transparent`.
|
|
868
|
-
* @prop --list-margin: Space around the list.
|
|
868
|
+
* @prop --list-margin: Space around the list. Defaults to `0.25rem`, which visualizes keyboard-focused items in a better way, as it adds some space for the outline effect;
|
|
869
869
|
*/
|
|
870
870
|
:host(limel-list) {
|
|
871
871
|
display: block;
|
|
@@ -4276,7 +4276,7 @@ a.mdc-list-item {
|
|
|
4276
4276
|
--icon-color,
|
|
4277
4277
|
rgb(var(--contrast-900))
|
|
4278
4278
|
);
|
|
4279
|
-
margin: --list-margin, 0.25rem;
|
|
4279
|
+
margin: var(--list-margin, 0.25rem);
|
|
4280
4280
|
padding: 0;
|
|
4281
4281
|
border-radius: 0.375rem;
|
|
4282
4282
|
}
|
|
@@ -937,7 +937,7 @@ limel-helper-line {
|
|
|
937
937
|
* @prop --list-grid-gap: Distance between items in a list that has `has-grid-layout` class. Defaults to `0.75rem`.
|
|
938
938
|
* @prop --list-background-color-of-odd-interactive-items: Background color of odd list items, when `has-striped-rows` class is applied to the component. Defaults to `--contrast-200`.
|
|
939
939
|
* @prop --list-background-color-of-even-interactive-items: Background color of even list items, when `has-striped-rows` class is applied to the component. Defaults to `transparent`.
|
|
940
|
-
* @prop --list-margin: Space around the list.
|
|
940
|
+
* @prop --list-margin: Space around the list. Defaults to `0.25rem`, which visualizes keyboard-focused items in a better way, as it adds some space for the outline effect;
|
|
941
941
|
*/
|
|
942
942
|
:host(limel-list) {
|
|
943
943
|
display: block;
|
|
@@ -4348,7 +4348,7 @@ a.mdc-list-item {
|
|
|
4348
4348
|
--icon-color,
|
|
4349
4349
|
rgb(var(--contrast-900))
|
|
4350
4350
|
);
|
|
4351
|
-
margin: --list-margin, 0.25rem;
|
|
4351
|
+
margin: var(--list-margin, 0.25rem);
|
|
4352
4352
|
padding: 0;
|
|
4353
4353
|
border-radius: 0.375rem;
|
|
4354
4354
|
}
|
|
@@ -1,47 +1,37 @@
|
|
|
1
|
+
const CACHE_NAME = '@limetech/lime-elements/icons';
|
|
1
2
|
export class IconCache {
|
|
2
3
|
constructor() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
this.cache = {};
|
|
7
|
-
/*
|
|
8
|
-
* Contains resolve functions for all unresolved promises that are waiting for SVG data.
|
|
9
|
-
*/
|
|
10
|
-
this.resolveFunctions = {};
|
|
4
|
+
this.promises = {};
|
|
5
|
+
this.cache = caches.open(CACHE_NAME);
|
|
11
6
|
}
|
|
12
7
|
/**
|
|
13
8
|
* Get icon data from the cache
|
|
14
9
|
* @param {string} name name of the icon
|
|
15
10
|
* @param {string} path path on the server where the assets are located
|
|
16
|
-
* @returns {string} svg markup
|
|
11
|
+
* @returns {Promise<string>} svg markup
|
|
17
12
|
*/
|
|
18
13
|
async get(name, path = '') {
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const cache = await this.cache;
|
|
15
|
+
const url = this.getUrl(name, path);
|
|
16
|
+
let response = await cache.match(url);
|
|
17
|
+
if (!response) {
|
|
18
|
+
response = await this.fetchData(url, cache);
|
|
21
19
|
}
|
|
22
|
-
return this.
|
|
20
|
+
return this.getIcon(response);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
this.resolveFunctions[name].push(resolve);
|
|
34
|
-
});
|
|
22
|
+
async fetchData(url, cache) {
|
|
23
|
+
let requestPromise = this.promises[url];
|
|
24
|
+
if (requestPromise === undefined) {
|
|
25
|
+
requestPromise = cache.add(url);
|
|
26
|
+
this.promises[url] = requestPromise;
|
|
27
|
+
}
|
|
28
|
+
await requestPromise;
|
|
29
|
+
return cache.match(url);
|
|
35
30
|
}
|
|
36
31
|
/*
|
|
37
|
-
*
|
|
32
|
+
* Get icon data from a response
|
|
38
33
|
*/
|
|
39
|
-
async
|
|
40
|
-
let iconPath = path || '';
|
|
41
|
-
if (path && !path.endsWith('/')) {
|
|
42
|
-
iconPath = `${path}/`;
|
|
43
|
-
}
|
|
44
|
-
const response = await fetch(`${iconPath}assets/icons/${name}.svg`);
|
|
34
|
+
async getIcon(response) {
|
|
45
35
|
let svgData = await response.text();
|
|
46
36
|
// Some of the icons in the Icons8 library have hard coded black color on some of the paths.
|
|
47
37
|
// In order to apply coloring with CSS, these have to be set to 'currentColor'
|
|
@@ -49,7 +39,7 @@ export class IconCache {
|
|
|
49
39
|
if (!this.validSvg(svgData)) {
|
|
50
40
|
throw new Error('Invalid SVG');
|
|
51
41
|
}
|
|
52
|
-
|
|
42
|
+
return svgData;
|
|
53
43
|
}
|
|
54
44
|
/*
|
|
55
45
|
* Check if the given data is a valid SVG document
|
|
@@ -59,18 +49,15 @@ export class IconCache {
|
|
|
59
49
|
const svgDoc = parser.parseFromString(data, 'image/svg+xml');
|
|
60
50
|
return svgDoc.documentElement.tagName.toLowerCase() === 'svg';
|
|
61
51
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
resolve(svgData);
|
|
69
|
-
});
|
|
70
|
-
this.resolveFunctions[name] = null;
|
|
52
|
+
getUrl(name, path) {
|
|
53
|
+
let iconPath = path || '';
|
|
54
|
+
if (path && !path.endsWith('/')) {
|
|
55
|
+
iconPath = `${path}/`;
|
|
56
|
+
}
|
|
57
|
+
return `${iconPath}assets/icons/${name}.svg`;
|
|
71
58
|
}
|
|
72
59
|
}
|
|
73
|
-
const
|
|
60
|
+
const iconCache = new IconCache();
|
|
74
61
|
export default (() => {
|
|
75
|
-
return
|
|
62
|
+
return iconCache;
|
|
76
63
|
})();
|
|
@@ -1,50 +1,40 @@
|
|
|
1
1
|
import { r as registerInstance, h, g as getElement } from './index-cdfd351d.js';
|
|
2
2
|
import { c as config } from './config-f7362aeb.js';
|
|
3
3
|
|
|
4
|
+
const CACHE_NAME = '@limetech/lime-elements/icons';
|
|
4
5
|
class IconCache {
|
|
5
6
|
constructor() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
this.cache = {};
|
|
10
|
-
/*
|
|
11
|
-
* Contains resolve functions for all unresolved promises that are waiting for SVG data.
|
|
12
|
-
*/
|
|
13
|
-
this.resolveFunctions = {};
|
|
7
|
+
this.promises = {};
|
|
8
|
+
this.cache = caches.open(CACHE_NAME);
|
|
14
9
|
}
|
|
15
10
|
/**
|
|
16
11
|
* Get icon data from the cache
|
|
17
12
|
* @param {string} name name of the icon
|
|
18
13
|
* @param {string} path path on the server where the assets are located
|
|
19
|
-
* @returns {string} svg markup
|
|
14
|
+
* @returns {Promise<string>} svg markup
|
|
20
15
|
*/
|
|
21
16
|
async get(name, path = '') {
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const cache = await this.cache;
|
|
18
|
+
const url = this.getUrl(name, path);
|
|
19
|
+
let response = await cache.match(url);
|
|
20
|
+
if (!response) {
|
|
21
|
+
response = await this.fetchData(url, cache);
|
|
24
22
|
}
|
|
25
|
-
return this.
|
|
23
|
+
return this.getIcon(response);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
this.resolveFunctions[name].push(resolve);
|
|
37
|
-
});
|
|
25
|
+
async fetchData(url, cache) {
|
|
26
|
+
let requestPromise = this.promises[url];
|
|
27
|
+
if (requestPromise === undefined) {
|
|
28
|
+
requestPromise = cache.add(url);
|
|
29
|
+
this.promises[url] = requestPromise;
|
|
30
|
+
}
|
|
31
|
+
await requestPromise;
|
|
32
|
+
return cache.match(url);
|
|
38
33
|
}
|
|
39
34
|
/*
|
|
40
|
-
*
|
|
35
|
+
* Get icon data from a response
|
|
41
36
|
*/
|
|
42
|
-
async
|
|
43
|
-
let iconPath = path || '';
|
|
44
|
-
if (path && !path.endsWith('/')) {
|
|
45
|
-
iconPath = `${path}/`;
|
|
46
|
-
}
|
|
47
|
-
const response = await fetch(`${iconPath}assets/icons/${name}.svg`);
|
|
37
|
+
async getIcon(response) {
|
|
48
38
|
let svgData = await response.text();
|
|
49
39
|
// Some of the icons in the Icons8 library have hard coded black color on some of the paths.
|
|
50
40
|
// In order to apply coloring with CSS, these have to be set to 'currentColor'
|
|
@@ -52,7 +42,7 @@ class IconCache {
|
|
|
52
42
|
if (!this.validSvg(svgData)) {
|
|
53
43
|
throw new Error('Invalid SVG');
|
|
54
44
|
}
|
|
55
|
-
|
|
45
|
+
return svgData;
|
|
56
46
|
}
|
|
57
47
|
/*
|
|
58
48
|
* Check if the given data is a valid SVG document
|
|
@@ -62,20 +52,17 @@ class IconCache {
|
|
|
62
52
|
const svgDoc = parser.parseFromString(data, 'image/svg+xml');
|
|
63
53
|
return svgDoc.documentElement.tagName.toLowerCase() === 'svg';
|
|
64
54
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
resolve(svgData);
|
|
72
|
-
});
|
|
73
|
-
this.resolveFunctions[name] = null;
|
|
55
|
+
getUrl(name, path) {
|
|
56
|
+
let iconPath = path || '';
|
|
57
|
+
if (path && !path.endsWith('/')) {
|
|
58
|
+
iconPath = `${path}/`;
|
|
59
|
+
}
|
|
60
|
+
return `${iconPath}assets/icons/${name}.svg`;
|
|
74
61
|
}
|
|
75
62
|
}
|
|
76
|
-
const
|
|
77
|
-
const iconCache = (() => {
|
|
78
|
-
return
|
|
63
|
+
const iconCache = new IconCache();
|
|
64
|
+
const iconCache$1 = (() => {
|
|
65
|
+
return iconCache;
|
|
79
66
|
})();
|
|
80
67
|
|
|
81
68
|
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([hidden]){display:none}:host([size=x-small]){height:0.9375rem !important;width:0.9375rem !important}:host([size=small]){height:1.25rem !important;width:1.25rem !important}:host([size=medium]){height:1.5625rem !important;width:1.5625rem !important}:host([size=large]){height:1.875rem !important;width:1.875rem !important}:host([badge][size=x-small]){height:1.4375rem !important;width:1.4375rem !important}:host([badge][size=x-small])>div{margin:0.25rem}:host([badge][size=small]){height:1.875rem !important;width:1.875rem !important}:host([badge][size=small])>div{margin:0.3125rem}:host([badge][size=medium]){height:2.5rem !important;width:2.5rem !important}:host([badge][size=medium])>div{margin:0.5rem}:host([badge][size=large]){height:2.875rem !important;width:2.875rem !important}:host([badge][size=large])>div{margin:0.5rem}";
|
|
@@ -106,7 +93,7 @@ const Icon = class {
|
|
|
106
93
|
* @returns {string} the icon SVG data
|
|
107
94
|
*/
|
|
108
95
|
loadSvg(name) {
|
|
109
|
-
return iconCache.get(name, config.iconPath);
|
|
96
|
+
return iconCache$1.get(name, config.iconPath);
|
|
110
97
|
}
|
|
111
98
|
/*
|
|
112
99
|
* There is no way to style external SVG files with CSS, i.e. SVGs loaded
|