@telperion/elements 1.1.2 → 1.2.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/.build-manifest.json +1 -1
- package/README.md +2 -0
- package/icon/icon-element.cjs +78 -7
- package/icon/icon-element.cjs.map +1 -1
- package/icon/icon-element.js +78 -7
- package/icon/icon-element.js.map +1 -1
- package/icon/index.cjs +6 -0
- package/icon/index.cjs.map +1 -1
- package/icon/index.d.cts +57 -8
- package/icon/index.d.ts +57 -8
- package/icon/index.js +1 -0
- package/icon/index.js.map +1 -1
- package/icon/thesvg-sprite.cjs +234 -0
- package/icon/thesvg-sprite.cjs.map +1 -0
- package/icon/thesvg-sprite.js +228 -0
- package/icon/thesvg-sprite.js.map +1 -0
- package/iife/icon/index.js +7 -7
- package/iife/icon/index.js.map +1 -1
- package/package.json +1 -1
package/.build-manifest.json
CHANGED
package/README.md
CHANGED
|
@@ -74,6 +74,7 @@ A framework-agnostic icon element with two families: Material Symbols and Simple
|
|
|
74
74
|
**Features:**
|
|
75
75
|
- **Material Symbols**: three variants (`outlined`, `round`, `sharp`) and all four variable-font axes exposed as attributes (`filled`, `grade`, `weight`, `optical-size`)
|
|
76
76
|
- **Simple Icons** (`family="simple-icons"`): brand icons (YouTube, LinkedIn, GitHub, …) loaded on demand from `cdn.simpleicons.org` into a single shared `<svg>` sprite — one HTTP request per slug, ever; auto `aria-label` from the brand title; `tp-icon-load` / `tp-icon-error` events; configurable base URL for self-hosting
|
|
77
|
+
- **theSVG** (`family="thesvg"`): multi-color, multi-variant brand icons from [thesvg.org](https://thesvg.org) (~5,600 SVGs). Lazy-fetched into a separate `<svg data-tp-thesvg>` sprite with per-symbol id namespacing so multi-gradient logos coexist without collisions. `variant` attribute selects `default` / `mono` / `wordmark` / …; `tp-icon-load` / `tp-icon-error` events fire with `{ slug, variant, viewBox }`; configurable base URL.
|
|
77
78
|
- Light-DOM rendering so consumer styling (Tailwind, CSS variables, color/size) "just works"
|
|
78
79
|
- Material Symbols fonts loaded via the Google Fonts CSS API — no broken hash URLs when Google rotates them; self-host friendly
|
|
79
80
|
|
|
@@ -92,6 +93,7 @@ import "@telperion/elements/icon";
|
|
|
92
93
|
<tp-icon>home</tp-icon>
|
|
93
94
|
<tp-icon variant="round" filled weight="700">favorite</tp-icon>
|
|
94
95
|
<tp-icon family="simple-icons" slug="facebook" style="color:#1877F2"></tp-icon>
|
|
96
|
+
<tp-icon family="thesvg" slug="google" variant="wordmark"></tp-icon>
|
|
95
97
|
```
|
|
96
98
|
|
|
97
99
|
[Icon Documentation →](./src/icon/README.md)
|
package/icon/icon-element.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var tslib = require('tslib');
|
|
|
4
4
|
var lit = require('lit');
|
|
5
5
|
var decorators_js = require('lit/decorators.js');
|
|
6
6
|
var simpleIconsSprite = require('./simple-icons-sprite.cjs');
|
|
7
|
+
var thesvgSprite = require('./thesvg-sprite.cjs');
|
|
7
8
|
|
|
8
9
|
const HOST_CLASSES = [
|
|
9
10
|
"font-normal",
|
|
@@ -21,7 +22,12 @@ exports.IconElement = class IconElement extends lit.LitElement {
|
|
|
21
22
|
super(...arguments);
|
|
22
23
|
/** Icon family. */
|
|
23
24
|
this.family = "material";
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Icon variant. Per-family interpretation:
|
|
27
|
+
* - `material`: `"outlined" | "round" | "sharp"` (default `"outlined"`).
|
|
28
|
+
* - `thesvg`: any theSVG variant slug, e.g. `"default"`, `"mono"`,
|
|
29
|
+
* `"wordmark"`. Defaults to `"default"` when no `variant` attribute is set.
|
|
30
|
+
*/
|
|
25
31
|
this.variant = "outlined";
|
|
26
32
|
/** Whether the glyph should be filled (FILL axis = 1). */
|
|
27
33
|
this.filled = false;
|
|
@@ -31,9 +37,9 @@ exports.IconElement = class IconElement extends lit.LitElement {
|
|
|
31
37
|
this.weight = 400;
|
|
32
38
|
/** Material Symbols opsz axis (20..48). Reflects as `optical-size` attribute. */
|
|
33
39
|
this.opticalSize = 24;
|
|
34
|
-
/** Reflected while a
|
|
40
|
+
/** Reflected while a remote icon (Simple Icons / theSVG) is being fetched. */
|
|
35
41
|
this.loading = false;
|
|
36
|
-
/** Reflected when the most recent
|
|
42
|
+
/** Reflected when the most recent remote-icon fetch failed. */
|
|
37
43
|
this.errored = false;
|
|
38
44
|
this.#requestToken = null;
|
|
39
45
|
this.#injected = null;
|
|
@@ -84,6 +90,12 @@ exports.IconElement = class IconElement extends lit.LitElement {
|
|
|
84
90
|
fill: currentColor;
|
|
85
91
|
vertical-align: -0.125em;
|
|
86
92
|
}
|
|
93
|
+
|
|
94
|
+
tp-icon[family="thesvg"] > svg {
|
|
95
|
+
height: 1em;
|
|
96
|
+
width: auto;
|
|
97
|
+
vertical-align: -0.125em;
|
|
98
|
+
}
|
|
87
99
|
`;
|
|
88
100
|
document.head.appendChild(style);
|
|
89
101
|
}
|
|
@@ -97,20 +109,36 @@ exports.IconElement = class IconElement extends lit.LitElement {
|
|
|
97
109
|
this.classList.add(...HOST_CLASSES);
|
|
98
110
|
}
|
|
99
111
|
willUpdate(changed) {
|
|
100
|
-
if (!changed.has("family") &&
|
|
112
|
+
if (!changed.has("family") &&
|
|
113
|
+
!changed.has("slug") &&
|
|
114
|
+
!changed.has("variant"))
|
|
101
115
|
return;
|
|
102
116
|
if (this.family === "simple-icons") {
|
|
103
117
|
if (this.slug) {
|
|
104
118
|
void this.#renderSimpleIcon(this.slug);
|
|
105
119
|
}
|
|
106
120
|
else {
|
|
107
|
-
this.#
|
|
121
|
+
this.#clearRemoteIcon();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (this.family === "thesvg") {
|
|
125
|
+
if (this.slug) {
|
|
126
|
+
void this.#renderTheSvg(this.slug, this.#theSvgVariant());
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.#clearRemoteIcon();
|
|
108
130
|
}
|
|
109
131
|
}
|
|
110
132
|
else if (changed.has("family")) {
|
|
111
|
-
this.#
|
|
133
|
+
this.#clearRemoteIcon();
|
|
112
134
|
}
|
|
113
135
|
}
|
|
136
|
+
#theSvgVariant() {
|
|
137
|
+
// The `variant` property defaults to `"outlined"` (a Material value).
|
|
138
|
+
// Only forward it to theSVG if the consumer set the attribute explicitly;
|
|
139
|
+
// otherwise fall back to theSVG's `"default"` variant.
|
|
140
|
+
return this.hasAttribute("variant") ? this.variant : "default";
|
|
141
|
+
}
|
|
114
142
|
render() {
|
|
115
143
|
return lit.html ``;
|
|
116
144
|
}
|
|
@@ -158,7 +186,50 @@ exports.IconElement = class IconElement extends lit.LitElement {
|
|
|
158
186
|
}));
|
|
159
187
|
}
|
|
160
188
|
}
|
|
161
|
-
#
|
|
189
|
+
async #renderTheSvg(slug, variant) {
|
|
190
|
+
const token = (this.#requestToken = Symbol("tp-icon-request"));
|
|
191
|
+
this.loading = true;
|
|
192
|
+
this.errored = false;
|
|
193
|
+
// Insert the <use> reference immediately so the symbol paints without
|
|
194
|
+
// flicker once it lands in the sprite.
|
|
195
|
+
this.#removeInjected();
|
|
196
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
197
|
+
svg.setAttribute("aria-hidden", "true");
|
|
198
|
+
const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
|
|
199
|
+
use.setAttribute("href", `#${thesvgSprite.getTheSvgSymbolId(slug, variant)}`);
|
|
200
|
+
svg.appendChild(use);
|
|
201
|
+
this.appendChild(svg);
|
|
202
|
+
this.#injected = svg;
|
|
203
|
+
try {
|
|
204
|
+
const meta = await thesvgSprite.loadTheSvgIcon(slug, variant);
|
|
205
|
+
if (this.#requestToken !== token)
|
|
206
|
+
return;
|
|
207
|
+
// Mirror the symbol's viewBox onto the outer <svg> so it has an
|
|
208
|
+
// intrinsic aspect ratio. Without this, `width: auto` from CSS falls
|
|
209
|
+
// back to the SVG default of 300x150 instead of being derived from
|
|
210
|
+
// `height: 1em` × the icon's own aspect ratio.
|
|
211
|
+
svg.setAttribute("viewBox", meta.viewBox);
|
|
212
|
+
this.loading = false;
|
|
213
|
+
this.dispatchEvent(new CustomEvent("tp-icon-load", {
|
|
214
|
+
bubbles: true,
|
|
215
|
+
composed: true,
|
|
216
|
+
detail: { slug, variant, viewBox: meta.viewBox },
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (this.#requestToken !== token)
|
|
221
|
+
return;
|
|
222
|
+
this.loading = false;
|
|
223
|
+
this.errored = true;
|
|
224
|
+
this.#removeInjected();
|
|
225
|
+
this.dispatchEvent(new CustomEvent("tp-icon-error", {
|
|
226
|
+
bubbles: true,
|
|
227
|
+
composed: true,
|
|
228
|
+
detail: { slug, variant, error },
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
#clearRemoteIcon() {
|
|
162
233
|
this.#requestToken = null;
|
|
163
234
|
this.loading = false;
|
|
164
235
|
this.errored = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-element.cjs","sources":["../../../../libs/elements/src/icon/icon-element.ts"],"sourcesContent":[null],"names":["IconElement","LitElement","html","getSimpleIconSymbolId","loadSimpleIcon","__decorate","property","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"icon-element.cjs","sources":["../../../../libs/elements/src/icon/icon-element.ts"],"sourcesContent":[null],"names":["IconElement","LitElement","html","getSimpleIconSymbolId","loadSimpleIcon","getTheSvgSymbolId","loadTheSvgIcon","__decorate","property","customElement"],"mappings":";;;;;;;;AAuCA,MAAM,YAAY,GAAG;IACnB,aAAa;IACb,YAAY;IACZ,UAAU;IACV,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,cAAc;IACd,mBAAmB;IACnB,aAAa;CACd;AAGYA,mBAAW,GAAjB,MAAM,WAAY,SAAQC,cAAU,CAAA;AAApC,IAAA,WAAA,GAAA;;;QA8DL,IAAA,CAAA,MAAM,GAA2C,UAAU;AAE3D;;;;;AAKG;QAEH,I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CAAC;;AAChC,CAAA,EAAAR,mBAAA,CAAA,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAIVO,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC7B,CAAA,EAAAR,mBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAIbO,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;;AACpD,CAAA,EAAAR,mBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIjBO,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACd,CAAA,EAAAR,mBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAIdO,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC3B,CAAA,EAAAR,mBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIhBO,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC3B,CAAA,EAAAR,mBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAnGLA,mBAAW,GAAAO,gBAAA,CAAA;IADvBE,2BAAa,CAAC,SAAS;AACX,CAAA,EAAAT,mBAAW,CA2QvB;;"}
|
package/icon/icon-element.js
CHANGED
|
@@ -2,6 +2,7 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
2
2
|
import { LitElement, html } from 'lit';
|
|
3
3
|
import { property, customElement } from 'lit/decorators.js';
|
|
4
4
|
import { getSimpleIconSymbolId, loadSimpleIcon } from './simple-icons-sprite.js';
|
|
5
|
+
import { getTheSvgSymbolId, loadTheSvgIcon } from './thesvg-sprite.js';
|
|
5
6
|
|
|
6
7
|
const HOST_CLASSES = [
|
|
7
8
|
"font-normal",
|
|
@@ -19,7 +20,12 @@ let IconElement = class IconElement extends LitElement {
|
|
|
19
20
|
super(...arguments);
|
|
20
21
|
/** Icon family. */
|
|
21
22
|
this.family = "material";
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Icon variant. Per-family interpretation:
|
|
25
|
+
* - `material`: `"outlined" | "round" | "sharp"` (default `"outlined"`).
|
|
26
|
+
* - `thesvg`: any theSVG variant slug, e.g. `"default"`, `"mono"`,
|
|
27
|
+
* `"wordmark"`. Defaults to `"default"` when no `variant` attribute is set.
|
|
28
|
+
*/
|
|
23
29
|
this.variant = "outlined";
|
|
24
30
|
/** Whether the glyph should be filled (FILL axis = 1). */
|
|
25
31
|
this.filled = false;
|
|
@@ -29,9 +35,9 @@ let IconElement = class IconElement extends LitElement {
|
|
|
29
35
|
this.weight = 400;
|
|
30
36
|
/** Material Symbols opsz axis (20..48). Reflects as `optical-size` attribute. */
|
|
31
37
|
this.opticalSize = 24;
|
|
32
|
-
/** Reflected while a
|
|
38
|
+
/** Reflected while a remote icon (Simple Icons / theSVG) is being fetched. */
|
|
33
39
|
this.loading = false;
|
|
34
|
-
/** Reflected when the most recent
|
|
40
|
+
/** Reflected when the most recent remote-icon fetch failed. */
|
|
35
41
|
this.errored = false;
|
|
36
42
|
this.#requestToken = null;
|
|
37
43
|
this.#injected = null;
|
|
@@ -82,6 +88,12 @@ let IconElement = class IconElement extends LitElement {
|
|
|
82
88
|
fill: currentColor;
|
|
83
89
|
vertical-align: -0.125em;
|
|
84
90
|
}
|
|
91
|
+
|
|
92
|
+
tp-icon[family="thesvg"] > svg {
|
|
93
|
+
height: 1em;
|
|
94
|
+
width: auto;
|
|
95
|
+
vertical-align: -0.125em;
|
|
96
|
+
}
|
|
85
97
|
`;
|
|
86
98
|
document.head.appendChild(style);
|
|
87
99
|
}
|
|
@@ -95,20 +107,36 @@ let IconElement = class IconElement extends LitElement {
|
|
|
95
107
|
this.classList.add(...HOST_CLASSES);
|
|
96
108
|
}
|
|
97
109
|
willUpdate(changed) {
|
|
98
|
-
if (!changed.has("family") &&
|
|
110
|
+
if (!changed.has("family") &&
|
|
111
|
+
!changed.has("slug") &&
|
|
112
|
+
!changed.has("variant"))
|
|
99
113
|
return;
|
|
100
114
|
if (this.family === "simple-icons") {
|
|
101
115
|
if (this.slug) {
|
|
102
116
|
void this.#renderSimpleIcon(this.slug);
|
|
103
117
|
}
|
|
104
118
|
else {
|
|
105
|
-
this.#
|
|
119
|
+
this.#clearRemoteIcon();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (this.family === "thesvg") {
|
|
123
|
+
if (this.slug) {
|
|
124
|
+
void this.#renderTheSvg(this.slug, this.#theSvgVariant());
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.#clearRemoteIcon();
|
|
106
128
|
}
|
|
107
129
|
}
|
|
108
130
|
else if (changed.has("family")) {
|
|
109
|
-
this.#
|
|
131
|
+
this.#clearRemoteIcon();
|
|
110
132
|
}
|
|
111
133
|
}
|
|
134
|
+
#theSvgVariant() {
|
|
135
|
+
// The `variant` property defaults to `"outlined"` (a Material value).
|
|
136
|
+
// Only forward it to theSVG if the consumer set the attribute explicitly;
|
|
137
|
+
// otherwise fall back to theSVG's `"default"` variant.
|
|
138
|
+
return this.hasAttribute("variant") ? this.variant : "default";
|
|
139
|
+
}
|
|
112
140
|
render() {
|
|
113
141
|
return html ``;
|
|
114
142
|
}
|
|
@@ -156,7 +184,50 @@ let IconElement = class IconElement extends LitElement {
|
|
|
156
184
|
}));
|
|
157
185
|
}
|
|
158
186
|
}
|
|
159
|
-
#
|
|
187
|
+
async #renderTheSvg(slug, variant) {
|
|
188
|
+
const token = (this.#requestToken = Symbol("tp-icon-request"));
|
|
189
|
+
this.loading = true;
|
|
190
|
+
this.errored = false;
|
|
191
|
+
// Insert the <use> reference immediately so the symbol paints without
|
|
192
|
+
// flicker once it lands in the sprite.
|
|
193
|
+
this.#removeInjected();
|
|
194
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
195
|
+
svg.setAttribute("aria-hidden", "true");
|
|
196
|
+
const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
|
|
197
|
+
use.setAttribute("href", `#${getTheSvgSymbolId(slug, variant)}`);
|
|
198
|
+
svg.appendChild(use);
|
|
199
|
+
this.appendChild(svg);
|
|
200
|
+
this.#injected = svg;
|
|
201
|
+
try {
|
|
202
|
+
const meta = await loadTheSvgIcon(slug, variant);
|
|
203
|
+
if (this.#requestToken !== token)
|
|
204
|
+
return;
|
|
205
|
+
// Mirror the symbol's viewBox onto the outer <svg> so it has an
|
|
206
|
+
// intrinsic aspect ratio. Without this, `width: auto` from CSS falls
|
|
207
|
+
// back to the SVG default of 300x150 instead of being derived from
|
|
208
|
+
// `height: 1em` × the icon's own aspect ratio.
|
|
209
|
+
svg.setAttribute("viewBox", meta.viewBox);
|
|
210
|
+
this.loading = false;
|
|
211
|
+
this.dispatchEvent(new CustomEvent("tp-icon-load", {
|
|
212
|
+
bubbles: true,
|
|
213
|
+
composed: true,
|
|
214
|
+
detail: { slug, variant, viewBox: meta.viewBox },
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
if (this.#requestToken !== token)
|
|
219
|
+
return;
|
|
220
|
+
this.loading = false;
|
|
221
|
+
this.errored = true;
|
|
222
|
+
this.#removeInjected();
|
|
223
|
+
this.dispatchEvent(new CustomEvent("tp-icon-error", {
|
|
224
|
+
bubbles: true,
|
|
225
|
+
composed: true,
|
|
226
|
+
detail: { slug, variant, error },
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
#clearRemoteIcon() {
|
|
160
231
|
this.#requestToken = null;
|
|
161
232
|
this.loading = false;
|
|
162
233
|
this.errored = false;
|
package/icon/icon-element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-element.js","sources":["../../../../libs/elements/src/icon/icon-element.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"icon-element.js","sources":["../../../../libs/elements/src/icon/icon-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAuCA,MAAM,YAAY,GAAG;IACnB,aAAa;IACb,YAAY;IACZ,UAAU;IACV,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,cAAc;IACd,mBAAmB;IACnB,aAAa;CACd;AAGM,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU,CAAA;AAApC,IAAA,WAAA,GAAA;;;QA8DL,IAAA,CAAA,MAAM,GAA2C,UAAU;AAE3D;;;;;AAKG;QAEH,IAAA,CAAA,OAAO,GAAW,UAAU;;QAI5B,IAAA,CAAA,MAAM,GAAG,KAAK;;QAId,IAAA,CAAA,KAAK,GAAG,CAAC;;QAIT,IAAA,CAAA,MAAM,GAAG,GAAG;;QAIZ,IAAA,CAAA,WAAW,GAAG,EAAE;;QAQhB,IAAA,CAAA,OAAO,GAAG,KAAK;;QAIf,IAAA,CAAA,OAAO,GAAG,KAAK;QAEf,IAAA,CAAA,aAAa,GAAkB,IAAI;QACnC,IAAA,CAAA,SAAS,GAAyB,IAAI;IAqKxC;AAxQE,IAAA;AACE,QAAA,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAEnE,KAAK,CAAC,WAAW,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDnB;AACD,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;;AA4ClC,IAAA,aAAa;AACb,IAAA,SAAS;IAEU,gBAAgB,GAAA;AACjC,QAAA,OAAO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EAAA,MAAA,CAAA;AAIhB,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AAC3B,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAnGL,WAAW,GAAA,UAAA,CAAA;IADvB,aAAa,CAAC,SAAS;AACX,CAAA,EAAA,WAAW,CA2QvB;;;;"}
|
package/icon/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var iconElement = require('./icon-element.cjs');
|
|
4
4
|
var simpleIconsSprite = require('./simple-icons-sprite.cjs');
|
|
5
|
+
var thesvgSprite = require('./thesvg-sprite.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
@@ -13,4 +14,9 @@ exports.clearSimpleIconsCache = simpleIconsSprite.clearSimpleIconsCache;
|
|
|
13
14
|
exports.getSimpleIconSymbolId = simpleIconsSprite.getSimpleIconSymbolId;
|
|
14
15
|
exports.loadSimpleIcon = simpleIconsSprite.loadSimpleIcon;
|
|
15
16
|
exports.setSimpleIconsBaseUrl = simpleIconsSprite.setSimpleIconsBaseUrl;
|
|
17
|
+
exports.clearTheSvgCache = thesvgSprite.clearTheSvgCache;
|
|
18
|
+
exports.getTheSvgSymbolId = thesvgSprite.getTheSvgSymbolId;
|
|
19
|
+
exports.listLoadedTheSvgVariants = thesvgSprite.listLoadedTheSvgVariants;
|
|
20
|
+
exports.loadTheSvgIcon = thesvgSprite.loadTheSvgIcon;
|
|
21
|
+
exports.setTheSvgBaseUrl = thesvgSprite.setTheSvgBaseUrl;
|
|
16
22
|
//# sourceMappingURL=index.cjs.map
|
package/icon/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
package/icon/index.d.cts
CHANGED
|
@@ -9,6 +9,8 @@ declare global {
|
|
|
9
9
|
* Pick icons from https://fonts.google.com/icons.
|
|
10
10
|
* - `simple-icons` — brand icons from https://simpleicons.org via
|
|
11
11
|
* `<tp-icon family="simple-icons" slug="facebook">`.
|
|
12
|
+
* - `thesvg` — multi-color brand icons from https://thesvg.org via
|
|
13
|
+
* `<tp-icon family="thesvg" slug="google" variant="mono">`.
|
|
12
14
|
*
|
|
13
15
|
* Renders into the **light DOM** so the host's utility classes are styled by
|
|
14
16
|
* the consumer's Tailwind v4 build.
|
|
@@ -27,9 +29,14 @@ declare class IconElement extends LitElement {
|
|
|
27
29
|
#private;
|
|
28
30
|
private static GLOBAL_STYLE;
|
|
29
31
|
/** Icon family. */
|
|
30
|
-
family: "material" | "simple-icons";
|
|
31
|
-
/**
|
|
32
|
-
|
|
32
|
+
family: "material" | "simple-icons" | "thesvg";
|
|
33
|
+
/**
|
|
34
|
+
* Icon variant. Per-family interpretation:
|
|
35
|
+
* - `material`: `"outlined" | "round" | "sharp"` (default `"outlined"`).
|
|
36
|
+
* - `thesvg`: any theSVG variant slug, e.g. `"default"`, `"mono"`,
|
|
37
|
+
* `"wordmark"`. Defaults to `"default"` when no `variant` attribute is set.
|
|
38
|
+
*/
|
|
39
|
+
variant: string;
|
|
33
40
|
/** Whether the glyph should be filled (FILL axis = 1). */
|
|
34
41
|
filled: boolean;
|
|
35
42
|
/** Material Symbols GRAD axis (-25..200). */
|
|
@@ -38,11 +45,11 @@ declare class IconElement extends LitElement {
|
|
|
38
45
|
weight: number;
|
|
39
46
|
/** Material Symbols opsz axis (20..48). Reflects as `optical-size` attribute. */
|
|
40
47
|
opticalSize: number;
|
|
41
|
-
/**
|
|
48
|
+
/** Slug for `simple-icons` and `thesvg` families. */
|
|
42
49
|
slug?: string;
|
|
43
|
-
/** Reflected while a
|
|
50
|
+
/** Reflected while a remote icon (Simple Icons / theSVG) is being fetched. */
|
|
44
51
|
loading: boolean;
|
|
45
|
-
/** Reflected when the most recent
|
|
52
|
+
/** Reflected when the most recent remote-icon fetch failed. */
|
|
46
53
|
errored: boolean;
|
|
47
54
|
protected createRenderRoot(): HTMLElement;
|
|
48
55
|
connectedCallback(): void;
|
|
@@ -85,5 +92,47 @@ declare function clearSimpleIconsCache(): void;
|
|
|
85
92
|
*/
|
|
86
93
|
declare function loadSimpleIcon(slug: string): Promise<SimpleIconMeta>;
|
|
87
94
|
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
interface TheSvgMeta {
|
|
96
|
+
/** Slug requested. */
|
|
97
|
+
slug: string;
|
|
98
|
+
/** Variant requested (defaults to `"default"`). */
|
|
99
|
+
variant: string;
|
|
100
|
+
/** `viewBox` copied from the source SVG (falls back to `"0 0 24 24"`). */
|
|
101
|
+
viewBox: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The DOM id used for the `<symbol>` corresponding to a given theSVG
|
|
105
|
+
* `(slug, variant)` pair. Exposed so `<tp-icon>` and tests can build matching
|
|
106
|
+
* `<use href>` references.
|
|
107
|
+
*/
|
|
108
|
+
declare function getTheSvgSymbolId(slug: string, variant?: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Override the CDN base URL used by the loader. Useful for self-hosting,
|
|
111
|
+
* offline development, or pointing at the canonical site
|
|
112
|
+
* (`https://thesvg.org/icons`). Trailing slashes are stripped.
|
|
113
|
+
*/
|
|
114
|
+
declare function setTheSvgBaseUrl(url: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Drop every cached symbol and remove the sprite from the DOM. Intended for
|
|
117
|
+
* test isolation; production code rarely needs to call this.
|
|
118
|
+
*/
|
|
119
|
+
declare function clearTheSvgCache(): void;
|
|
120
|
+
/**
|
|
121
|
+
* Inspect which variants of `slug` are currently materialised in the sprite.
|
|
122
|
+
* Reads from the DOM only — does not hit the network and does not list
|
|
123
|
+
* variants that exist on the CDN but haven't been requested yet.
|
|
124
|
+
*/
|
|
125
|
+
declare function listLoadedTheSvgVariants(slug: string): string[];
|
|
126
|
+
/**
|
|
127
|
+
* Ensure a `<symbol id="tp-thesvg-${slug}-${variant}">` exists in the global
|
|
128
|
+
* sprite. Returns a promise that resolves once the symbol is in the DOM (or
|
|
129
|
+
* immediately if it was already loaded). Safe to call repeatedly with the
|
|
130
|
+
* same `(slug, variant)` pair.
|
|
131
|
+
*
|
|
132
|
+
* Throws synchronously when either argument fails its whitelist
|
|
133
|
+
* (`slug`: `/^[a-z0-9.-]+$/`, `variant`: `/^[a-z0-9-]+$/`).
|
|
134
|
+
*/
|
|
135
|
+
declare function loadTheSvgIcon(slug: string, variant?: string): Promise<TheSvgMeta>;
|
|
136
|
+
|
|
137
|
+
export { IconElement, clearSimpleIconsCache, clearTheSvgCache, getSimpleIconSymbolId, getTheSvgSymbolId, listLoadedTheSvgVariants, loadSimpleIcon, loadTheSvgIcon, setSimpleIconsBaseUrl, setTheSvgBaseUrl };
|
|
138
|
+
export type { SimpleIconMeta, TheSvgMeta };
|
package/icon/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ declare global {
|
|
|
9
9
|
* Pick icons from https://fonts.google.com/icons.
|
|
10
10
|
* - `simple-icons` — brand icons from https://simpleicons.org via
|
|
11
11
|
* `<tp-icon family="simple-icons" slug="facebook">`.
|
|
12
|
+
* - `thesvg` — multi-color brand icons from https://thesvg.org via
|
|
13
|
+
* `<tp-icon family="thesvg" slug="google" variant="mono">`.
|
|
12
14
|
*
|
|
13
15
|
* Renders into the **light DOM** so the host's utility classes are styled by
|
|
14
16
|
* the consumer's Tailwind v4 build.
|
|
@@ -27,9 +29,14 @@ declare class IconElement extends LitElement {
|
|
|
27
29
|
#private;
|
|
28
30
|
private static GLOBAL_STYLE;
|
|
29
31
|
/** Icon family. */
|
|
30
|
-
family: "material" | "simple-icons";
|
|
31
|
-
/**
|
|
32
|
-
|
|
32
|
+
family: "material" | "simple-icons" | "thesvg";
|
|
33
|
+
/**
|
|
34
|
+
* Icon variant. Per-family interpretation:
|
|
35
|
+
* - `material`: `"outlined" | "round" | "sharp"` (default `"outlined"`).
|
|
36
|
+
* - `thesvg`: any theSVG variant slug, e.g. `"default"`, `"mono"`,
|
|
37
|
+
* `"wordmark"`. Defaults to `"default"` when no `variant` attribute is set.
|
|
38
|
+
*/
|
|
39
|
+
variant: string;
|
|
33
40
|
/** Whether the glyph should be filled (FILL axis = 1). */
|
|
34
41
|
filled: boolean;
|
|
35
42
|
/** Material Symbols GRAD axis (-25..200). */
|
|
@@ -38,11 +45,11 @@ declare class IconElement extends LitElement {
|
|
|
38
45
|
weight: number;
|
|
39
46
|
/** Material Symbols opsz axis (20..48). Reflects as `optical-size` attribute. */
|
|
40
47
|
opticalSize: number;
|
|
41
|
-
/**
|
|
48
|
+
/** Slug for `simple-icons` and `thesvg` families. */
|
|
42
49
|
slug?: string;
|
|
43
|
-
/** Reflected while a
|
|
50
|
+
/** Reflected while a remote icon (Simple Icons / theSVG) is being fetched. */
|
|
44
51
|
loading: boolean;
|
|
45
|
-
/** Reflected when the most recent
|
|
52
|
+
/** Reflected when the most recent remote-icon fetch failed. */
|
|
46
53
|
errored: boolean;
|
|
47
54
|
protected createRenderRoot(): HTMLElement;
|
|
48
55
|
connectedCallback(): void;
|
|
@@ -85,5 +92,47 @@ declare function clearSimpleIconsCache(): void;
|
|
|
85
92
|
*/
|
|
86
93
|
declare function loadSimpleIcon(slug: string): Promise<SimpleIconMeta>;
|
|
87
94
|
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
interface TheSvgMeta {
|
|
96
|
+
/** Slug requested. */
|
|
97
|
+
slug: string;
|
|
98
|
+
/** Variant requested (defaults to `"default"`). */
|
|
99
|
+
variant: string;
|
|
100
|
+
/** `viewBox` copied from the source SVG (falls back to `"0 0 24 24"`). */
|
|
101
|
+
viewBox: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The DOM id used for the `<symbol>` corresponding to a given theSVG
|
|
105
|
+
* `(slug, variant)` pair. Exposed so `<tp-icon>` and tests can build matching
|
|
106
|
+
* `<use href>` references.
|
|
107
|
+
*/
|
|
108
|
+
declare function getTheSvgSymbolId(slug: string, variant?: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Override the CDN base URL used by the loader. Useful for self-hosting,
|
|
111
|
+
* offline development, or pointing at the canonical site
|
|
112
|
+
* (`https://thesvg.org/icons`). Trailing slashes are stripped.
|
|
113
|
+
*/
|
|
114
|
+
declare function setTheSvgBaseUrl(url: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Drop every cached symbol and remove the sprite from the DOM. Intended for
|
|
117
|
+
* test isolation; production code rarely needs to call this.
|
|
118
|
+
*/
|
|
119
|
+
declare function clearTheSvgCache(): void;
|
|
120
|
+
/**
|
|
121
|
+
* Inspect which variants of `slug` are currently materialised in the sprite.
|
|
122
|
+
* Reads from the DOM only — does not hit the network and does not list
|
|
123
|
+
* variants that exist on the CDN but haven't been requested yet.
|
|
124
|
+
*/
|
|
125
|
+
declare function listLoadedTheSvgVariants(slug: string): string[];
|
|
126
|
+
/**
|
|
127
|
+
* Ensure a `<symbol id="tp-thesvg-${slug}-${variant}">` exists in the global
|
|
128
|
+
* sprite. Returns a promise that resolves once the symbol is in the DOM (or
|
|
129
|
+
* immediately if it was already loaded). Safe to call repeatedly with the
|
|
130
|
+
* same `(slug, variant)` pair.
|
|
131
|
+
*
|
|
132
|
+
* Throws synchronously when either argument fails its whitelist
|
|
133
|
+
* (`slug`: `/^[a-z0-9.-]+$/`, `variant`: `/^[a-z0-9-]+$/`).
|
|
134
|
+
*/
|
|
135
|
+
declare function loadTheSvgIcon(slug: string, variant?: string): Promise<TheSvgMeta>;
|
|
136
|
+
|
|
137
|
+
export { IconElement, clearSimpleIconsCache, clearTheSvgCache, getSimpleIconSymbolId, getTheSvgSymbolId, listLoadedTheSvgVariants, loadSimpleIcon, loadTheSvgIcon, setSimpleIconsBaseUrl, setTheSvgBaseUrl };
|
|
138
|
+
export type { SimpleIconMeta, TheSvgMeta };
|
package/icon/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { IconElement } from './icon-element.js';
|
|
2
2
|
export { clearSimpleIconsCache, getSimpleIconSymbolId, loadSimpleIcon, setSimpleIconsBaseUrl } from './simple-icons-sprite.js';
|
|
3
|
+
export { clearTheSvgCache, getTheSvgSymbolId, listLoadedTheSvgVariants, loadTheSvgIcon, setTheSvgBaseUrl } from './thesvg-sprite.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/icon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|