@openremote/or-icon 1.8.0-snapshot.20250725070921 → 1.8.0-snapshot.20250725120000
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/README.md +61 -61
- package/dist/umd/index.bundle.js +48 -48
- package/dist/umd/index.bundle.js.map +1 -1
- package/lib/index.js +198 -49
- package/lib/or-icon-set.js +10 -1
- package/mdi-font-copy.js +17 -17
- package/mdi-iconset-generator.js +35 -35
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,49 +1,198 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html, LitElement, unsafeCSS } from "lit";
|
|
8
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
9
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
10
|
+
import { AssetModelUtil } from "@openremote/model";
|
|
11
|
+
import OrIconSet from "./or-icon-set";
|
|
12
|
+
export { OrIconSet };
|
|
13
|
+
const mdiFontStyle = require("@mdi/font/css/materialdesignicons.min.css");
|
|
14
|
+
export class IconSetAddedEvent extends CustomEvent {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(IconSetAddedEvent.NAME, {
|
|
17
|
+
bubbles: true,
|
|
18
|
+
composed: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
IconSetAddedEvent.NAME = "or-iconset-added";
|
|
23
|
+
export function createSvgIconSet(size, icons) {
|
|
24
|
+
return {
|
|
25
|
+
getIconTemplate: (name) => {
|
|
26
|
+
const iconData = icons[name];
|
|
27
|
+
if (!iconData) {
|
|
28
|
+
return html ``;
|
|
29
|
+
}
|
|
30
|
+
return html `
|
|
31
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
32
|
+
viewBox="0 0 ${size} ${size}" preserveAspectRatio="xMidYMid meet" focusable="false">
|
|
33
|
+
${unsafeSVG(iconData.startsWith("<") ? iconData : '<path xmlns="http://www.w3.org/2000/svg" d="' + iconData + '" />')}
|
|
34
|
+
</svg>
|
|
35
|
+
`;
|
|
36
|
+
},
|
|
37
|
+
onAdd: undefined
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function createMdiIconSet(managerUrl) {
|
|
41
|
+
return {
|
|
42
|
+
getIconTemplate(icon) {
|
|
43
|
+
return html `<span style="font-family: 'Material Design Icons';" class="mdi-${icon}"></span>`;
|
|
44
|
+
},
|
|
45
|
+
onAdd() {
|
|
46
|
+
// Load the material design font from the specified manager shared folder
|
|
47
|
+
// we don't use the MDI css as it contains all the icon CSS which won't be inherited by shadow DOM
|
|
48
|
+
const style = document.createElement("style");
|
|
49
|
+
style.id = "mdiFontStyle";
|
|
50
|
+
style.textContent = "@font-face {\n" +
|
|
51
|
+
" font-family: \"Material Design Icons\";\n" +
|
|
52
|
+
" src: url(\"" + managerUrl + "/shared/fonts/Material Design Icons/fonts/materialdesignicons-webfont.eot\");\n" +
|
|
53
|
+
" src: url(\"" + managerUrl + "/shared/fonts/Material Design Icons/fonts/materialdesignicons-webfont.eot\") format(\"embedded-opentype\"), url(\"" + managerUrl + "/shared/fonts/Material Design Icons/fonts/materialdesignicons-webfont.woff2\") format(\"woff2\"), url(\"" + managerUrl + "/shared/fonts/Material Design Icons/fonts/materialdesignicons-webfont.woff\") format(\"woff\"), url(\"" + managerUrl + "/shared/fonts/Material Design Icons//fonts/materialdesignicons-webfont.ttf\") format(\"truetype\");\n" +
|
|
54
|
+
" font-weight: normal;\n" +
|
|
55
|
+
" font-style: normal;\n" +
|
|
56
|
+
"}";
|
|
57
|
+
document.head.appendChild(style);
|
|
58
|
+
// const styleElem = document.createElement("link") as HTMLLinkElement;
|
|
59
|
+
// styleElem.type = "text/css";
|
|
60
|
+
// styleElem.rel = "stylesheet";
|
|
61
|
+
// styleElem.href = managerUrl + "/shared/fonts/Material Design Icons/css/materialdesignicons.min.css";
|
|
62
|
+
// document.head.appendChild(styleElem);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
class ORIconSets {
|
|
67
|
+
constructor() {
|
|
68
|
+
this._icons = {};
|
|
69
|
+
}
|
|
70
|
+
addIconSet(name, iconSet) {
|
|
71
|
+
this._icons[name] = iconSet;
|
|
72
|
+
if (!this._defaultIconSet) {
|
|
73
|
+
this._defaultIconSet = iconSet;
|
|
74
|
+
}
|
|
75
|
+
if (iconSet.onAdd) {
|
|
76
|
+
iconSet.onAdd();
|
|
77
|
+
}
|
|
78
|
+
window.dispatchEvent(new IconSetAddedEvent());
|
|
79
|
+
}
|
|
80
|
+
getIconSet(name) {
|
|
81
|
+
return this._icons[name];
|
|
82
|
+
}
|
|
83
|
+
getIconTemplate(icon) {
|
|
84
|
+
if (!icon) {
|
|
85
|
+
return html ``;
|
|
86
|
+
}
|
|
87
|
+
const parts = (icon || "").split(":");
|
|
88
|
+
const iconName = parts.pop();
|
|
89
|
+
const iconSetName = parts.pop();
|
|
90
|
+
let iconSet = this._defaultIconSet;
|
|
91
|
+
if (iconSetName) {
|
|
92
|
+
iconSet = this.getIconSet(iconSetName);
|
|
93
|
+
}
|
|
94
|
+
if (!iconName || !iconSet) {
|
|
95
|
+
return html ``;
|
|
96
|
+
}
|
|
97
|
+
return iconSet.getIconTemplate(iconName);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export const IconSets = new ORIconSets();
|
|
101
|
+
export function getAssetDescriptorIconTemplate(descriptor, fallbackColor, fallbackIcon, overrideColor, overrideIcon) {
|
|
102
|
+
const color = overrideColor ? overrideColor : AssetModelUtil.getAssetDescriptorColour(descriptor, fallbackColor);
|
|
103
|
+
let icon = overrideIcon ? overrideIcon : AssetModelUtil.getAssetDescriptorIcon(descriptor, fallbackIcon);
|
|
104
|
+
if (!icon) {
|
|
105
|
+
icon = AssetModelUtil.getAssetDescriptorIcon("ThingAsset" /* WellknownAssets.THINGASSET */);
|
|
106
|
+
}
|
|
107
|
+
return html `<or-icon style="--or-icon-fill: ${color ? "#" + color : "unset"}" icon="${icon}"></or-icon>`;
|
|
108
|
+
}
|
|
109
|
+
let OrIcon = class OrIcon extends LitElement {
|
|
110
|
+
constructor() {
|
|
111
|
+
super(...arguments);
|
|
112
|
+
this._handler = (evt) => {
|
|
113
|
+
this._updateIcon();
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// language=CSS
|
|
117
|
+
static get styles() {
|
|
118
|
+
return [
|
|
119
|
+
css `
|
|
120
|
+
:host {
|
|
121
|
+
--internal-or-icon-width: var(--or-icon-width, 24px);
|
|
122
|
+
--internal-or-icon-height: var(--or-icon-height, 24px);
|
|
123
|
+
--internal-or-icon-fill: var(--or-icon-fill, currentColor);
|
|
124
|
+
--internal-or-icon-stroke: var(--or-icon-fill, none);
|
|
125
|
+
--internal-or-icon-stroke-width: var(--or-icon-stroke-width, 0);
|
|
126
|
+
|
|
127
|
+
display: inline-block;
|
|
128
|
+
color: var(--internal-or-icon-fill);
|
|
129
|
+
fill: var(--internal-or-icon-fill);
|
|
130
|
+
stroke: var(--internal-or-icon-stroke);
|
|
131
|
+
stroke-width: var(--internal-or-icon-stroke-width);
|
|
132
|
+
vertical-align: text-bottom;
|
|
133
|
+
font-weight: normal;
|
|
134
|
+
font-style: normal;
|
|
135
|
+
font-size: var(--internal-or-icon-width);
|
|
136
|
+
line-height: 1;
|
|
137
|
+
letter-spacing: normal;
|
|
138
|
+
text-transform: none;
|
|
139
|
+
white-space: nowrap;
|
|
140
|
+
word-wrap: normal;
|
|
141
|
+
direction: ltr;
|
|
142
|
+
/* Support for all WebKit browsers. */
|
|
143
|
+
-webkit-font-smoothing: antialiased;
|
|
144
|
+
/* Support for Safari and Chrome. */
|
|
145
|
+
text-rendering: optimizeLegibility;
|
|
146
|
+
/* Support for Firefox. */
|
|
147
|
+
-moz-osx-font-smoothing: grayscale;
|
|
148
|
+
/* Support for IE. */
|
|
149
|
+
font-feature-settings: 'liga';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
:host([hidden]) {
|
|
153
|
+
display: none;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
svg {
|
|
157
|
+
pointer-events: none;
|
|
158
|
+
display: block;
|
|
159
|
+
width: var(--internal-or-icon-width);
|
|
160
|
+
height: var(--internal-or-icon-height);
|
|
161
|
+
}
|
|
162
|
+
`,
|
|
163
|
+
css `${unsafeCSS(mdiFontStyle)}`
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
render() {
|
|
167
|
+
return this._iconTemplate || html ``;
|
|
168
|
+
}
|
|
169
|
+
disconnectedCallback() {
|
|
170
|
+
super.disconnectedCallback();
|
|
171
|
+
window.removeEventListener(IconSetAddedEvent.NAME, this._handler);
|
|
172
|
+
}
|
|
173
|
+
shouldUpdate(changedProperties) {
|
|
174
|
+
if (changedProperties.has("icon")) {
|
|
175
|
+
this._updateIcon();
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
_updateIcon() {
|
|
180
|
+
this._iconTemplate = undefined;
|
|
181
|
+
window.removeEventListener(IconSetAddedEvent.NAME, this._handler);
|
|
182
|
+
this._iconTemplate = IconSets.getIconTemplate(this.icon);
|
|
183
|
+
if (this.icon && !this._iconTemplate) {
|
|
184
|
+
window.addEventListener(IconSetAddedEvent.NAME, this._handler);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
__decorate([
|
|
189
|
+
property({ type: String, reflect: true })
|
|
190
|
+
], OrIcon.prototype, "icon", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
state()
|
|
193
|
+
], OrIcon.prototype, "_iconTemplate", void 0);
|
|
194
|
+
OrIcon = __decorate([
|
|
195
|
+
customElement("or-icon")
|
|
196
|
+
], OrIcon);
|
|
197
|
+
export { OrIcon };
|
|
198
|
+
//# sourceMappingURL=index.js.map
|
package/lib/or-icon-set.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
const orIconSet = {
|
|
2
|
+
size: 24,
|
|
3
|
+
icons: {
|
|
4
|
+
"logo": "<path style='pointer-events: var(--or-icon-pointer-events, none);' fill=\"#C4D600\" d=\"m11.96125,23.85096c-6.56773,0 -11.90971,-5.34202 -11.90971,-11.90862l2.49411,0c0,5.19176 4.22389,9.41568 9.41561,9.41568c5.19053,0 9.41561,-4.22392 9.41561,-9.41568c0,-5.19176 -4.22389,-9.41568 -9.41561,-9.41568l0,-2.49413c6.56655,0 11.90971,5.34439 11.90971,11.9098c0,6.5666 -5.34316,11.90862 -11.90971,11.90862l0,0z\" /><path fill=\"#4E9D2D\" d=\"m10.25094,20.38647c-2.26848,-0.47231 -4.21822,-1.80199 -5.48741,-3.74009s-1.70892,-4.25777 -1.23545,-6.52625c0.47347,-2.26965 1.80315,-4.21822 3.74242,-5.48857c1.93926,-1.27035 4.25661,-1.70892 6.52625,-1.23545c4.68471,0.97719 7.70121,5.5828 6.72286,10.26635l-2.39994,-0.49907c0.70149,-3.36085 -1.4623,-6.66585 -4.82431,-7.36734c-1.62866,-0.33969 -3.29105,-0.02559 -4.68238,0.88645c-1.39134,0.91088 -2.34526,2.3092 -2.68495,3.93786c-0.33853,1.62633 -0.02443,3.28988 0.88645,4.68122c0.91088,1.39134 2.3092,2.34526 3.93786,2.68379l-0.50139,2.4011l0,0z\"/><path fill=\"#1D5632\"d=\"m12.03064,17.49616c-0.09524,0 -0.19048,-0.00116 -0.28457,-0.00465c-1.49833,-0.0755 -2.87818,-0.72942 -3.88636,-1.84097c-1.00818,-1.11271 -1.52156,-2.54948 -1.44722,-4.05013l2.44378,0.12196c-0.04181,0.84557 0.24856,1.65745 0.81769,2.28466c0.56681,0.62721 1.34733,0.99656 2.1929,1.03838c0.84208,0.03833 1.65629,-0.2474 2.2835,-0.81653c0.62837,-0.56797 0.99656,-1.34617 1.03954,-2.19174c0.08711,-1.74573 -1.26371,-3.23708 -3.00943,-3.3242l0.12196,-2.44378c3.09422,0.15332 5.4869,2.79455 5.33358,5.88877c-0.07434,1.49949 -0.72942,2.87818 -1.84097,3.8852c-1.04186,0.94313 -2.36945,1.45303 -3.7644,1.45303l0,0z\"/>",
|
|
5
|
+
"logo-plain": "m11.9925,23.91349c-6.58498,0 -11.94099,-5.35605 -11.94099,-11.9399l2.50066,0c0,5.20539 4.23498,9.44041 9.44033,9.44041c5.20416,0 9.44033,-4.23502 9.44033,-9.44041c0,-5.20539 -4.23498,-9.44041 -9.44033,-9.44041l0,-2.50068c6.5838,0 11.94099,5.35842 11.94099,11.94108c0,6.58385 -5.35719,11.9399 -11.94099,11.9399l0,0zm-1.80787,-3.27769c-2.31323,-0.48163 -4.30141,-1.83755 -5.59563,-3.81389s-1.74263,-4.34178 -1.25982,-6.65502c0.48281,-2.31443 1.83872,-4.30145 3.81623,-5.59686c1.97751,-1.29542 4.34056,-1.74264 6.65497,-1.25983c4.77711,0.99647 7.8531,5.69295 6.85545,10.46891l-2.44727,-0.50891c0.71532,-3.42716 -1.49114,-6.79738 -4.91946,-7.5127c-1.66078,-0.34639 -3.35596,-0.0261 -4.77474,0.90394c-1.41878,0.92886 -2.39152,2.35476 -2.73791,4.01555c-0.3452,1.65842 -0.02491,3.3548 0.90394,4.77359c0.92885,1.41879 2.35475,2.39154 4.01552,2.73675l-0.51128,2.44848l0,0zm1.81499,-2.92536c-0.09727,0 -0.19455,-0.00119 -0.29064,-0.00475c-1.53029,-0.07711 -2.93958,-0.74498 -3.96926,-1.88025c-1.02968,-1.13646 -1.55401,-2.60388 -1.47809,-4.13655l2.49591,0.12456c-0.04271,0.86361 0.25386,1.69282 0.83513,2.33341c0.5789,0.64059 1.37607,1.01783 2.23968,1.06053c0.86005,0.03915 1.69162,-0.25268 2.33221,-0.83395c0.64177,-0.58009 1.01782,-1.3749 1.06171,-2.23851c0.08897,-1.78298 -1.29066,-3.30616 -3.07362,-3.39513l0.12456,-2.49593c3.16022,0.15659 5.60394,2.85419 5.44735,6.01443c-0.07592,1.53149 -0.74498,2.9396 -1.88024,3.9681c-1.06408,0.96326 -2.41999,1.48403 -3.8447,1.48403l0,0z",
|
|
6
|
+
"marker": "<ellipse fill=\"#000\" opacity=\"0.2\" ry=\"1.5\" rx=\"4\" cy=\"22.5\" cx=\"12\" /><path style='pointer-events: var(--or-icon-pointer-events, none);' d=\"m11.999999,0a8.437501,8.344057 0 0 1 8.437501,8.344057c0,6.500779 -5.798864,6.280799 -8.437501,14.412461c-2.638637,-8.131662 -8.437501,-7.911683 -8.437501,-14.412461a8.437501,8.344057 0 0 1 8.437501,-8.344057z\" />"
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export default orIconSet;
|
|
10
|
+
//# sourceMappingURL=or-icon-set.js.map
|
package/mdi-font-copy.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// Script for copying @mdi/font files into dist dir
|
|
2
|
-
var fs = require("fs");
|
|
3
|
-
var path = require("path");
|
|
4
|
-
|
|
5
|
-
if (!fs.existsSync("dist")) {
|
|
6
|
-
fs.mkdirSync("dist");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let fontDir = path.join(path.dirname(require.resolve("@mdi/font/package.json")), "fonts");
|
|
10
|
-
let cssDir = path.join(path.dirname(require.resolve("@mdi/font/package.json")), "css");
|
|
11
|
-
|
|
12
|
-
if (!fs.existsSync("dist/Material Design Icons")) {
|
|
13
|
-
fs.mkdirSync("dist/Material Design Icons", {recursive: true});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
fs.cpSync(fontDir, "./dist/Material Design Icons/fonts", {recursive: true});
|
|
17
|
-
fs.cpSync(cssDir, "./dist/Material Design Icons/css", {recursive: true});
|
|
1
|
+
// Script for copying @mdi/font files into dist dir
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
var path = require("path");
|
|
4
|
+
|
|
5
|
+
if (!fs.existsSync("dist")) {
|
|
6
|
+
fs.mkdirSync("dist");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let fontDir = path.join(path.dirname(require.resolve("@mdi/font/package.json")), "fonts");
|
|
10
|
+
let cssDir = path.join(path.dirname(require.resolve("@mdi/font/package.json")), "css");
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync("dist/Material Design Icons")) {
|
|
13
|
+
fs.mkdirSync("dist/Material Design Icons", {recursive: true});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
fs.cpSync(fontDir, "./dist/Material Design Icons/fonts", {recursive: true});
|
|
17
|
+
fs.cpSync(cssDir, "./dist/Material Design Icons/css", {recursive: true});
|
package/mdi-iconset-generator.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
// Script for collating mdi svg icons (@mdi/svg) into a single JSON file
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
var path = require("path");
|
|
4
|
-
var xpath = require('xpath');
|
|
5
|
-
var dom = require('xmldom').DOMParser;
|
|
6
|
-
|
|
7
|
-
if (!fs.existsSync("src")){
|
|
8
|
-
fs.mkdirSync("src");
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let mdiSvgDir = path.join(path.dirname(require.resolve("@mdi/svg/package.json")), "svg");
|
|
12
|
-
if (!fs.existsSync("dist")) {
|
|
13
|
-
fs.mkdirSync("dist");
|
|
14
|
-
}
|
|
15
|
-
let mdiStream = fs.createWriteStream("./dist/mdi-icons.json" ,{flags: "w+"});
|
|
16
|
-
mdiStream.write("{\"size\":24,\"icons\":{");
|
|
17
|
-
|
|
18
|
-
let files = fs.readdirSync(mdiSvgDir).sort();
|
|
19
|
-
|
|
20
|
-
for (let i=0; i<files.length; i++) {
|
|
21
|
-
|
|
22
|
-
let file = files[i];
|
|
23
|
-
let fullPath = path.join(mdiSvgDir, file);
|
|
24
|
-
let data = fs.readFileSync(fullPath, "utf8");
|
|
25
|
-
let svg = new dom().parseFromString(data);
|
|
26
|
-
let select = xpath.useNamespaces({"svg": "http://www.w3.org/2000/svg"});
|
|
27
|
-
let pathAttrs = select("//svg:path/@d", svg);
|
|
28
|
-
let pathData = pathAttrs[0].value;
|
|
29
|
-
let name = file.substr(0, file.length-4);
|
|
30
|
-
//name = name.replace(/-([\w])/g, function (g) { return g[1].toUpperCase(); });
|
|
31
|
-
mdiStream.write("\"" + name + "\":\"" + pathData + "\"" + (i < files.length-1 ? "," : ""));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
mdiStream.write("}}");
|
|
35
|
-
mdiStream.close();
|
|
1
|
+
// Script for collating mdi svg icons (@mdi/svg) into a single JSON file
|
|
2
|
+
var fs = require('fs');
|
|
3
|
+
var path = require("path");
|
|
4
|
+
var xpath = require('xpath');
|
|
5
|
+
var dom = require('xmldom').DOMParser;
|
|
6
|
+
|
|
7
|
+
if (!fs.existsSync("src")){
|
|
8
|
+
fs.mkdirSync("src");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let mdiSvgDir = path.join(path.dirname(require.resolve("@mdi/svg/package.json")), "svg");
|
|
12
|
+
if (!fs.existsSync("dist")) {
|
|
13
|
+
fs.mkdirSync("dist");
|
|
14
|
+
}
|
|
15
|
+
let mdiStream = fs.createWriteStream("./dist/mdi-icons.json" ,{flags: "w+"});
|
|
16
|
+
mdiStream.write("{\"size\":24,\"icons\":{");
|
|
17
|
+
|
|
18
|
+
let files = fs.readdirSync(mdiSvgDir).sort();
|
|
19
|
+
|
|
20
|
+
for (let i=0; i<files.length; i++) {
|
|
21
|
+
|
|
22
|
+
let file = files[i];
|
|
23
|
+
let fullPath = path.join(mdiSvgDir, file);
|
|
24
|
+
let data = fs.readFileSync(fullPath, "utf8");
|
|
25
|
+
let svg = new dom().parseFromString(data);
|
|
26
|
+
let select = xpath.useNamespaces({"svg": "http://www.w3.org/2000/svg"});
|
|
27
|
+
let pathAttrs = select("//svg:path/@d", svg);
|
|
28
|
+
let pathData = pathAttrs[0].value;
|
|
29
|
+
let name = file.substr(0, file.length-4);
|
|
30
|
+
//name = name.replace(/-([\w])/g, function (g) { return g[1].toUpperCase(); });
|
|
31
|
+
mdiStream.write("\"" + name + "\":\"" + pathData + "\"" + (i < files.length-1 ? "," : ""));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
mdiStream.write("}}");
|
|
35
|
+
mdiStream.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openremote/or-icon",
|
|
3
|
-
"version": "1.8.0-snapshot.
|
|
3
|
+
"version": "1.8.0-snapshot.20250725120000",
|
|
4
4
|
"description": "Icon component for displaying an icon from an icon set",
|
|
5
5
|
"customElements": "custom-elements.json",
|
|
6
6
|
"main": "dist/umd/index.bundle.js",
|