@dile/ui 3.3.0 → 3.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { html, css, LitElement } from "lit";
|
|
2
2
|
import { DileSelectableItem } from "../../../mixins/selectable/index.js";
|
|
3
|
+
import '@dile/iconlib/dile-iconlib.js';
|
|
3
4
|
|
|
4
5
|
const icons = {
|
|
5
6
|
"navigate_next": html`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>`,
|
|
@@ -9,6 +10,9 @@ const icons = {
|
|
|
9
10
|
"add": html`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>`,
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
const ICONLIB_FOLDERS = { material: 'material-icons', lucide: 'lucide-icons', fontawesome: 'fontawesome-icons' };
|
|
14
|
+
const warnedIcons = new Set();
|
|
15
|
+
|
|
12
16
|
export class DileSelectorItem extends DileSelectableItem(LitElement) {
|
|
13
17
|
|
|
14
18
|
static get styles() {
|
|
@@ -48,6 +52,13 @@ export class DileSelectorItem extends DileSelectableItem(LitElement) {
|
|
|
48
52
|
.selected .icon svg {
|
|
49
53
|
fill: var(--dile-selector-selected-icon-color, #fff);
|
|
50
54
|
}
|
|
55
|
+
.icon dile-iconlib {
|
|
56
|
+
--dile-icon-color: var(--dile-selector-icon-color, var(--dile-selector-primary-color, #039be5));
|
|
57
|
+
--dile-icon-size: var(--dile-selector-icon-size, 20px);
|
|
58
|
+
}
|
|
59
|
+
.selected .icon dile-iconlib {
|
|
60
|
+
--dile-icon-color: var(--dile-selector-selected-icon-color, #fff);
|
|
61
|
+
}
|
|
51
62
|
a {
|
|
52
63
|
display: block;
|
|
53
64
|
text-decoration: var(--dile-selector-text-decoration, none);
|
|
@@ -58,6 +69,7 @@ export class DileSelectorItem extends DileSelectableItem(LitElement) {
|
|
|
58
69
|
static get properties() {
|
|
59
70
|
return {
|
|
60
71
|
icon: { type: String },
|
|
72
|
+
iconlibIcon: { type: String },
|
|
61
73
|
href: { type: String },
|
|
62
74
|
};
|
|
63
75
|
}
|
|
@@ -83,6 +95,10 @@ export class DileSelectorItem extends DileSelectableItem(LitElement) {
|
|
|
83
95
|
? html`<div class="icon">${this.iconElement(this.icon)}</div>`
|
|
84
96
|
: ''
|
|
85
97
|
}
|
|
98
|
+
${this.iconlibIcon
|
|
99
|
+
? html`<div class="icon">${this.renderIconlibIcon(this.iconlibIcon)}</div>`
|
|
100
|
+
: ''
|
|
101
|
+
}
|
|
86
102
|
<div class="line"><slot></slot></div>
|
|
87
103
|
</article>
|
|
88
104
|
`;
|
|
@@ -91,4 +107,24 @@ export class DileSelectorItem extends DileSelectableItem(LitElement) {
|
|
|
91
107
|
return icons[icon];
|
|
92
108
|
}
|
|
93
109
|
|
|
110
|
+
renderIconlibIcon(icon) {
|
|
111
|
+
const dotIndex = icon.indexOf('.');
|
|
112
|
+
if (dotIndex === -1) {
|
|
113
|
+
return html`<dile-iconlib icon="${icon}"></dile-iconlib>`;
|
|
114
|
+
}
|
|
115
|
+
const family = icon.slice(0, dotIndex);
|
|
116
|
+
const name = icon.slice(dotIndex + 1);
|
|
117
|
+
const tagName = `dile-${family}-icon-${name}`;
|
|
118
|
+
if (customElements.get(tagName)) {
|
|
119
|
+
return html`<dile-iconlib icon="${icon}"></dile-iconlib>`;
|
|
120
|
+
}
|
|
121
|
+
if (!warnedIcons.has(icon)) {
|
|
122
|
+
warnedIcons.add(icon);
|
|
123
|
+
const folder = ICONLIB_FOLDERS[family] || family;
|
|
124
|
+
console.warn(`dile-selector-item: icon "${icon}" is not registered. Import "@dile/iconlib/${folder}/${name}.js" before using it.`);
|
|
125
|
+
}
|
|
126
|
+
customElements.whenDefined(tagName).then(() => this.requestUpdate());
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
129
|
+
|
|
94
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "UI Core components from dile-components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://dile-components.com/",
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@dile/iconlib": "^1.4.0",
|
|
24
25
|
"@dile/icons": "^2.5.1",
|
|
25
26
|
"lit": "^2.7.0 || ^3.0.0"
|
|
26
27
|
},
|
|
27
28
|
"publishConfig": {
|
|
28
29
|
"access": "public"
|
|
29
30
|
},
|
|
30
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "20981504f9a5fc7a97865f95860b76de9aa9c3f8"
|
|
31
32
|
}
|