@telperion/elements 1.0.0 → 1.1.1
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 +61 -0
- package/README.md +34 -8
- package/drag-drop/drag-element.cjs +59 -60
- package/drag-drop/drag-element.cjs.map +1 -0
- package/drag-drop/drag-element.js +8 -8
- package/drag-drop/drag-element.js.map +1 -1
- package/drag-drop/drag-handle-element.cjs +19 -19
- package/drag-drop/drag-handle-element.cjs.map +1 -0
- package/drag-drop/drag-handle-element.js +8 -7
- package/drag-drop/drag-handle-element.js.map +1 -1
- package/drag-drop/dropzone-element.cjs +32 -32
- package/drag-drop/dropzone-element.cjs.map +1 -0
- package/drag-drop/dropzone-element.js +6 -5
- package/drag-drop/dropzone-element.js.map +1 -1
- package/drag-drop/index.cjs +23 -11
- package/drag-drop/index.cjs.map +1 -0
- package/drag-drop/{drag-element.d.ts → index.d.cts} +73 -5
- package/drag-drop/index.d.ts +172 -6
- package/drag-drop/index.js +4 -5
- package/drag-drop/index.js.map +1 -1
- package/drag-drop/private-props.cjs +10 -6
- package/drag-drop/private-props.cjs.map +1 -0
- package/drag-drop/private-props.js +4 -3
- package/drag-drop/private-props.js.map +1 -1
- package/drag-drop/tha-drag-event.cjs +8 -6
- package/drag-drop/tha-drag-event.cjs.map +1 -0
- package/drag-drop/tha-drag-event.js +4 -2
- package/drag-drop/tha-drag-event.js.map +1 -1
- package/fesm/elements.mjs +1939 -0
- package/fesm/elements.mjs.map +1 -0
- package/icon/icon-element.cjs +136 -37
- package/icon/icon-element.cjs.map +1 -0
- package/icon/icon-element.js +105 -5
- package/icon/icon-element.js.map +1 -1
- package/icon/index.cjs +16 -5
- package/icon/index.cjs.map +1 -0
- package/icon/index.d.cts +89 -0
- package/icon/index.d.ts +89 -1
- package/icon/index.js +2 -2
- package/icon/index.js.map +1 -1
- package/icon/simple-icons-sprite.cjs +129 -0
- package/icon/simple-icons-sprite.cjs.map +1 -0
- package/icon/simple-icons-sprite.js +124 -0
- package/icon/simple-icons-sprite.js.map +1 -0
- package/iife/drag-drop/index.js +73 -0
- package/iife/drag-drop/index.js.map +1 -0
- package/iife/elements.js +180 -0
- package/iife/elements.js.map +1 -0
- package/iife/icon/index.js +35 -0
- package/iife/icon/index.js.map +1 -0
- package/iife/router/index.js +142 -0
- package/iife/router/index.js.map +1 -0
- package/index.cjs +53 -11
- package/index.cjs.map +1 -0
- package/index.d.cts +6 -0
- package/index.d.ts +6 -6
- package/index.js +10 -9
- package/index.js.map +1 -1
- package/package.json +45 -83
- package/router/history-managed.cjs +22 -18
- package/router/history-managed.cjs.map +1 -0
- package/router/history-managed.js +9 -7
- package/router/history-managed.js.map +1 -1
- package/router/history.cjs +20 -16
- package/router/history.cjs.map +1 -0
- package/router/history.js +8 -6
- package/router/history.js.map +1 -1
- package/router/index.cjs +36 -15
- package/router/index.cjs.map +1 -0
- package/router/index.d.cts +895 -0
- package/router/index.d.ts +895 -6
- package/router/index.js +6 -7
- package/router/index.js.map +1 -1
- package/router/signal-watcher-lit-element.cjs +9 -6
- package/router/signal-watcher-lit-element.cjs.map +1 -0
- package/router/signal-watcher-lit-element.js +5 -3
- package/router/signal-watcher-lit-element.js.map +1 -1
- package/router/tha-route.cjs +25 -22
- package/router/tha-route.cjs.map +1 -0
- package/router/tha-route.js +8 -7
- package/router/tha-route.js.map +1 -1
- package/router/tha-router-config.cjs +17 -17
- package/router/tha-router-config.cjs.map +1 -0
- package/router/tha-router-config.js +8 -7
- package/router/tha-router-config.js.map +1 -1
- package/router/tha-router-link.cjs +36 -36
- package/router/tha-router-link.cjs.map +1 -0
- package/router/tha-router-link.js +9 -8
- package/router/tha-router-link.js.map +1 -1
- package/router/tha-router-outlet.cjs +51 -48
- package/router/tha-router-outlet.cjs.map +1 -0
- package/router/tha-router-outlet.js +12 -11
- package/router/tha-router-outlet.js.map +1 -1
- package/router/tha-router-param.cjs +21 -21
- package/router/tha-router-param.cjs.map +1 -0
- package/router/tha-router-param.js +7 -6
- package/router/tha-router-param.js.map +1 -1
- package/router/tha-router.cjs +33 -33
- package/router/tha-router.cjs.map +1 -0
- package/router/tha-router.js +11 -10
- package/router/tha-router.js.map +1 -1
- package/bundle.js +0 -164
- package/bundle.mjs +0 -2630
- package/drag-drop/drag-handle-element.d.ts +0 -12
- package/drag-drop/dropzone-element.d.ts +0 -17
- package/drag-drop/private-props.d.ts +0 -3
- package/drag-drop/tha-drag-event.d.ts +0 -19
- package/icon/icon-element.d.ts +0 -40
- package/router/history-managed.d.ts +0 -76
- package/router/history.d.ts +0 -48
- package/router/signal-watcher-lit-element.d.ts +0 -25
- package/router/tha-route.d.ts +0 -90
- package/router/tha-router-config.d.ts +0 -223
- package/router/tha-router-link.d.ts +0 -95
- package/router/tha-router-outlet.d.ts +0 -112
- package/router/tha-router-param.d.ts +0 -226
- package/router/tha-router.d.ts +0 -69
- package/tha-url-output.cjs +0 -79
- package/tha-url-output.d.ts +0 -41
- package/tha-url-output.js +0 -78
- package/tha-url-output.js.map +0 -1
package/icon/index.d.ts
CHANGED
|
@@ -1 +1,89 @@
|
|
|
1
|
-
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
/**
|
|
6
|
+
* A framework-agnostic icon element. Supports two families:
|
|
7
|
+
*
|
|
8
|
+
* - `material` (default) — Material Symbols glyphs via font ligatures.
|
|
9
|
+
* Pick icons from https://fonts.google.com/icons.
|
|
10
|
+
* - `simple-icons` — brand icons from https://simpleicons.org via
|
|
11
|
+
* `<tp-icon family="simple-icons" slug="facebook">`.
|
|
12
|
+
*
|
|
13
|
+
* Renders into the **light DOM** so the host's utility classes are styled by
|
|
14
|
+
* the consumer's Tailwind v4 build.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```html
|
|
18
|
+
* <tp-icon>home</tp-icon>
|
|
19
|
+
* <tp-icon family="material" variant="round" filled>favorite</tp-icon>
|
|
20
|
+
* <tp-icon family="simple-icons" slug="facebook" style="color:#1877F2"></tp-icon>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
"tp-icon": IconElement;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
declare class IconElement extends LitElement {
|
|
27
|
+
#private;
|
|
28
|
+
private static GLOBAL_STYLE;
|
|
29
|
+
/** Icon family. */
|
|
30
|
+
family: "material" | "simple-icons";
|
|
31
|
+
/** Material Symbols variant. */
|
|
32
|
+
variant: "outlined" | "round" | "sharp";
|
|
33
|
+
/** Whether the glyph should be filled (FILL axis = 1). */
|
|
34
|
+
filled: boolean;
|
|
35
|
+
/** Material Symbols GRAD axis (-25..200). */
|
|
36
|
+
grade: number;
|
|
37
|
+
/** Material Symbols wght axis (100..700). */
|
|
38
|
+
weight: number;
|
|
39
|
+
/** Material Symbols opsz axis (20..48). Reflects as `optical-size` attribute. */
|
|
40
|
+
opticalSize: number;
|
|
41
|
+
/** Simple Icons slug (only used when `family="simple-icons"`). */
|
|
42
|
+
slug?: string;
|
|
43
|
+
/** Reflected while a `simple-icons` slug is being fetched. */
|
|
44
|
+
loading: boolean;
|
|
45
|
+
/** Reflected when the most recent `simple-icons` fetch failed. */
|
|
46
|
+
errored: boolean;
|
|
47
|
+
protected createRenderRoot(): HTMLElement;
|
|
48
|
+
connectedCallback(): void;
|
|
49
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
50
|
+
protected render(): TemplateResult;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface SimpleIconMeta {
|
|
54
|
+
/** Human-readable brand title taken from the CDN's `<title>` element. */
|
|
55
|
+
title: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The DOM id used for the `<symbol>` corresponding to a Simple Icons slug.
|
|
59
|
+
* Exposed so `<tp-icon>` and tests can build matching `<use href>` references.
|
|
60
|
+
*/
|
|
61
|
+
declare function getSimpleIconSymbolId(slug: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Override the CDN base URL used by the loader. Useful for self-hosting,
|
|
64
|
+
* offline development, or pointing at a regional mirror. Trailing slashes
|
|
65
|
+
* are stripped.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* setSimpleIconsBaseUrl("/assets/simple-icons");
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function setSimpleIconsBaseUrl(url: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Drop every cached symbol and remove the sprite from the DOM. Intended for
|
|
75
|
+
* test isolation; production code rarely needs to call this.
|
|
76
|
+
*/
|
|
77
|
+
declare function clearSimpleIconsCache(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Ensure a `<symbol id="tp-si-${slug}">` exists in the global sprite. Returns
|
|
80
|
+
* a promise that resolves once the symbol is in the DOM (or immediately if
|
|
81
|
+
* it was already loaded). Safe to call repeatedly with the same slug.
|
|
82
|
+
*
|
|
83
|
+
* Throws synchronously for slugs that don't match the Simple Icons slug
|
|
84
|
+
* grammar (`/^[a-z0-9.-]+$/`).
|
|
85
|
+
*/
|
|
86
|
+
declare function loadSimpleIcon(slug: string): Promise<SimpleIconMeta>;
|
|
87
|
+
|
|
88
|
+
export { IconElement, clearSimpleIconsCache, getSimpleIconSymbolId, loadSimpleIcon, setSimpleIconsBaseUrl };
|
|
89
|
+
export type { SimpleIconMeta };
|
package/icon/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { IconElement } from
|
|
2
|
-
|
|
1
|
+
export { IconElement } from './icon-element.js';
|
|
2
|
+
export { clearSimpleIconsCache, getSimpleIconSymbolId, loadSimpleIcon, setSimpleIconsBaseUrl } from './simple-icons-sprite.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/icon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Global sprite + loader for the Simple Icons family of `<tp-icon>`.
|
|
5
|
+
*
|
|
6
|
+
* On first sight of a slug we fetch `${baseUrl}/${slug}` (defaults to the
|
|
7
|
+
* official Simple Icons CDN), extract the single `<path>` and the `<title>`
|
|
8
|
+
* from the response, and append a fresh `<symbol id="tp-si-${slug}">` to a
|
|
9
|
+
* single shared `<svg>` sprite that lives at the bottom of `document.body`.
|
|
10
|
+
*
|
|
11
|
+
* Subsequent `<tp-icon family="simple-icons" slug="...">` instances reference
|
|
12
|
+
* the same symbol via `<use href="#tp-si-${slug}"/>` — no extra requests,
|
|
13
|
+
* no DOM duplication.
|
|
14
|
+
*/
|
|
15
|
+
const SLUG_PATTERN = /^[a-z0-9.-]+$/;
|
|
16
|
+
const SPRITE_MARKER = "data-tp-simple-icons";
|
|
17
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
18
|
+
let baseUrl = "https://cdn.simpleicons.org";
|
|
19
|
+
let sprite = null;
|
|
20
|
+
const inFlight = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* The DOM id used for the `<symbol>` corresponding to a Simple Icons slug.
|
|
23
|
+
* Exposed so `<tp-icon>` and tests can build matching `<use href>` references.
|
|
24
|
+
*/
|
|
25
|
+
function getSimpleIconSymbolId(slug) {
|
|
26
|
+
return `tp-si-${slug}`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Override the CDN base URL used by the loader. Useful for self-hosting,
|
|
30
|
+
* offline development, or pointing at a regional mirror. Trailing slashes
|
|
31
|
+
* are stripped.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* setSimpleIconsBaseUrl("/assets/simple-icons");
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function setSimpleIconsBaseUrl(url) {
|
|
39
|
+
baseUrl = url.replace(/\/+$/, "");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Drop every cached symbol and remove the sprite from the DOM. Intended for
|
|
43
|
+
* test isolation; production code rarely needs to call this.
|
|
44
|
+
*/
|
|
45
|
+
function clearSimpleIconsCache() {
|
|
46
|
+
inFlight.clear();
|
|
47
|
+
if (sprite && sprite.parentNode) {
|
|
48
|
+
sprite.parentNode.removeChild(sprite);
|
|
49
|
+
}
|
|
50
|
+
sprite = null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Ensure a `<symbol id="tp-si-${slug}">` exists in the global sprite. Returns
|
|
54
|
+
* a promise that resolves once the symbol is in the DOM (or immediately if
|
|
55
|
+
* it was already loaded). Safe to call repeatedly with the same slug.
|
|
56
|
+
*
|
|
57
|
+
* Throws synchronously for slugs that don't match the Simple Icons slug
|
|
58
|
+
* grammar (`/^[a-z0-9.-]+$/`).
|
|
59
|
+
*/
|
|
60
|
+
function loadSimpleIcon(slug) {
|
|
61
|
+
if (!SLUG_PATTERN.test(slug)) {
|
|
62
|
+
throw new Error(`[tp-icon] Invalid Simple Icons slug: ${JSON.stringify(slug)}`);
|
|
63
|
+
}
|
|
64
|
+
const cached = inFlight.get(slug);
|
|
65
|
+
if (cached)
|
|
66
|
+
return cached;
|
|
67
|
+
const promise = (async () => {
|
|
68
|
+
const res = await fetch(`${baseUrl}/${slug}`);
|
|
69
|
+
if (!res.ok) {
|
|
70
|
+
throw new Error(`[tp-icon] Failed to load Simple Icons slug "${slug}": ${res.status} ${res.statusText}`);
|
|
71
|
+
}
|
|
72
|
+
const text = await res.text();
|
|
73
|
+
const doc = new DOMParser().parseFromString(text, "image/svg+xml");
|
|
74
|
+
if (doc.querySelector("parsererror")) {
|
|
75
|
+
throw new Error(`[tp-icon] Failed to parse SVG for slug "${slug}"`);
|
|
76
|
+
}
|
|
77
|
+
const path = doc.querySelector("path");
|
|
78
|
+
if (!path) {
|
|
79
|
+
throw new Error(`[tp-icon] No <path> found in SVG for slug "${slug}"`);
|
|
80
|
+
}
|
|
81
|
+
const title = doc.querySelector("title")?.textContent?.trim() ?? slug;
|
|
82
|
+
const target = ensureSprite();
|
|
83
|
+
const symbol = document.createElementNS(SVG_NS, "symbol");
|
|
84
|
+
symbol.setAttribute("id", getSimpleIconSymbolId(slug));
|
|
85
|
+
symbol.setAttribute("viewBox", "0 0 24 24");
|
|
86
|
+
const titleEl = document.createElementNS(SVG_NS, "title");
|
|
87
|
+
titleEl.textContent = title;
|
|
88
|
+
symbol.appendChild(titleEl);
|
|
89
|
+
const cleanedPath = document.createElementNS(SVG_NS, "path");
|
|
90
|
+
cleanedPath.setAttribute("d", path.getAttribute("d") ?? "");
|
|
91
|
+
symbol.appendChild(cleanedPath);
|
|
92
|
+
target.appendChild(symbol);
|
|
93
|
+
return { title };
|
|
94
|
+
})();
|
|
95
|
+
// On failure, evict so a later retry can succeed.
|
|
96
|
+
promise.catch(() => {
|
|
97
|
+
if (inFlight.get(slug) === promise)
|
|
98
|
+
inFlight.delete(slug);
|
|
99
|
+
});
|
|
100
|
+
inFlight.set(slug, promise);
|
|
101
|
+
return promise;
|
|
102
|
+
}
|
|
103
|
+
function ensureSprite() {
|
|
104
|
+
if (sprite && sprite.isConnected)
|
|
105
|
+
return sprite;
|
|
106
|
+
// Survive HMR / multiple module instances: reuse an existing tagged sprite.
|
|
107
|
+
const existing = document.querySelector(`svg[${SPRITE_MARKER}]`);
|
|
108
|
+
if (existing) {
|
|
109
|
+
sprite = existing;
|
|
110
|
+
return sprite;
|
|
111
|
+
}
|
|
112
|
+
const svg = document.createElementNS(SVG_NS, "svg");
|
|
113
|
+
svg.setAttribute(SPRITE_MARKER, "");
|
|
114
|
+
svg.setAttribute("aria-hidden", "true");
|
|
115
|
+
svg.setAttribute("xmlns", SVG_NS);
|
|
116
|
+
svg.style.position = "absolute";
|
|
117
|
+
svg.style.width = "0";
|
|
118
|
+
svg.style.height = "0";
|
|
119
|
+
svg.style.overflow = "hidden";
|
|
120
|
+
document.body.appendChild(svg);
|
|
121
|
+
sprite = svg;
|
|
122
|
+
return svg;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
exports.clearSimpleIconsCache = clearSimpleIconsCache;
|
|
126
|
+
exports.getSimpleIconSymbolId = getSimpleIconSymbolId;
|
|
127
|
+
exports.loadSimpleIcon = loadSimpleIcon;
|
|
128
|
+
exports.setSimpleIconsBaseUrl = setSimpleIconsBaseUrl;
|
|
129
|
+
//# sourceMappingURL=simple-icons-sprite.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-icons-sprite.cjs","sources":["../../../../libs/elements/src/icon/simple-icons-sprite.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;AAWG;AAEH,MAAM,YAAY,GAAG,eAAe;AACpC,MAAM,aAAa,GAAG,sBAAsB;AAC5C,MAAM,MAAM,GAAG,4BAA4B;AAE3C,IAAI,OAAO,GAAG,6BAA6B;AAC3C,IAAI,MAAM,GAAyB,IAAI;AACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmC;AAO3D;;;AAGG;AACG,SAAU,qBAAqB,CAAC,IAAY,EAAA;IAChD,OAAO,CAAA,MAAA,EAAS,IAAI,CAAA,CAAE;AACxB;AAEA;;;;;;;;;AASG;AACG,SAAU,qBAAqB,CAAC,GAAW,EAAA;IAC/C,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;AACnC;AAEA;;;AAGG;SACa,qBAAqB,GAAA;IACnC,QAAQ,CAAC,KAAK,EAAE;AAChB,IAAA,IAAI,MAAM,IAAI,MAAM,CAAC,UAAU,EAAE;AAC/B,QAAA,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC;IACvC;IACA,MAAM,GAAG,IAAI;AACf;AAEA;;;;;;;AAOG;AACG,SAAU,cAAc,CAAC,IAAY,EAAA;IACzC,IAAI,CAAC,YA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A,OAAO,MAAM;IACf;IAEA,MAAM,GAAG,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC;AACnD,IAAA,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC;AACnC,IAAA,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;AACvC,IAAA,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC;AACjC,IAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU;AAC/B,IAAA,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG;AACrB,IAAA,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG;AACtB,IAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ;AAC7B,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IAE9B,MAAM,GAAG,GAAG;AACZ,IAAA,OAAO,GAAG;AACZ;;;;;;;"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Global sprite + loader for the Simple Icons family of `<tp-icon>`.
|
|
3
|
+
*
|
|
4
|
+
* On first sight of a slug we fetch `${baseUrl}/${slug}` (defaults to the
|
|
5
|
+
* official Simple Icons CDN), extract the single `<path>` and the `<title>`
|
|
6
|
+
* from the response, and append a fresh `<symbol id="tp-si-${slug}">` to a
|
|
7
|
+
* single shared `<svg>` sprite that lives at the bottom of `document.body`.
|
|
8
|
+
*
|
|
9
|
+
* Subsequent `<tp-icon family="simple-icons" slug="...">` instances reference
|
|
10
|
+
* the same symbol via `<use href="#tp-si-${slug}"/>` — no extra requests,
|
|
11
|
+
* no DOM duplication.
|
|
12
|
+
*/
|
|
13
|
+
const SLUG_PATTERN = /^[a-z0-9.-]+$/;
|
|
14
|
+
const SPRITE_MARKER = "data-tp-simple-icons";
|
|
15
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
16
|
+
let baseUrl = "https://cdn.simpleicons.org";
|
|
17
|
+
let sprite = null;
|
|
18
|
+
const inFlight = new Map();
|
|
19
|
+
/**
|
|
20
|
+
* The DOM id used for the `<symbol>` corresponding to a Simple Icons slug.
|
|
21
|
+
* Exposed so `<tp-icon>` and tests can build matching `<use href>` references.
|
|
22
|
+
*/
|
|
23
|
+
function getSimpleIconSymbolId(slug) {
|
|
24
|
+
return `tp-si-${slug}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Override the CDN base URL used by the loader. Useful for self-hosting,
|
|
28
|
+
* offline development, or pointing at a regional mirror. Trailing slashes
|
|
29
|
+
* are stripped.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* setSimpleIconsBaseUrl("/assets/simple-icons");
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function setSimpleIconsBaseUrl(url) {
|
|
37
|
+
baseUrl = url.replace(/\/+$/, "");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Drop every cached symbol and remove the sprite from the DOM. Intended for
|
|
41
|
+
* test isolation; production code rarely needs to call this.
|
|
42
|
+
*/
|
|
43
|
+
function clearSimpleIconsCache() {
|
|
44
|
+
inFlight.clear();
|
|
45
|
+
if (sprite && sprite.parentNode) {
|
|
46
|
+
sprite.parentNode.removeChild(sprite);
|
|
47
|
+
}
|
|
48
|
+
sprite = null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Ensure a `<symbol id="tp-si-${slug}">` exists in the global sprite. Returns
|
|
52
|
+
* a promise that resolves once the symbol is in the DOM (or immediately if
|
|
53
|
+
* it was already loaded). Safe to call repeatedly with the same slug.
|
|
54
|
+
*
|
|
55
|
+
* Throws synchronously for slugs that don't match the Simple Icons slug
|
|
56
|
+
* grammar (`/^[a-z0-9.-]+$/`).
|
|
57
|
+
*/
|
|
58
|
+
function loadSimpleIcon(slug) {
|
|
59
|
+
if (!SLUG_PATTERN.test(slug)) {
|
|
60
|
+
throw new Error(`[tp-icon] Invalid Simple Icons slug: ${JSON.stringify(slug)}`);
|
|
61
|
+
}
|
|
62
|
+
const cached = inFlight.get(slug);
|
|
63
|
+
if (cached)
|
|
64
|
+
return cached;
|
|
65
|
+
const promise = (async () => {
|
|
66
|
+
const res = await fetch(`${baseUrl}/${slug}`);
|
|
67
|
+
if (!res.ok) {
|
|
68
|
+
throw new Error(`[tp-icon] Failed to load Simple Icons slug "${slug}": ${res.status} ${res.statusText}`);
|
|
69
|
+
}
|
|
70
|
+
const text = await res.text();
|
|
71
|
+
const doc = new DOMParser().parseFromString(text, "image/svg+xml");
|
|
72
|
+
if (doc.querySelector("parsererror")) {
|
|
73
|
+
throw new Error(`[tp-icon] Failed to parse SVG for slug "${slug}"`);
|
|
74
|
+
}
|
|
75
|
+
const path = doc.querySelector("path");
|
|
76
|
+
if (!path) {
|
|
77
|
+
throw new Error(`[tp-icon] No <path> found in SVG for slug "${slug}"`);
|
|
78
|
+
}
|
|
79
|
+
const title = doc.querySelector("title")?.textContent?.trim() ?? slug;
|
|
80
|
+
const target = ensureSprite();
|
|
81
|
+
const symbol = document.createElementNS(SVG_NS, "symbol");
|
|
82
|
+
symbol.setAttribute("id", getSimpleIconSymbolId(slug));
|
|
83
|
+
symbol.setAttribute("viewBox", "0 0 24 24");
|
|
84
|
+
const titleEl = document.createElementNS(SVG_NS, "title");
|
|
85
|
+
titleEl.textContent = title;
|
|
86
|
+
symbol.appendChild(titleEl);
|
|
87
|
+
const cleanedPath = document.createElementNS(SVG_NS, "path");
|
|
88
|
+
cleanedPath.setAttribute("d", path.getAttribute("d") ?? "");
|
|
89
|
+
symbol.appendChild(cleanedPath);
|
|
90
|
+
target.appendChild(symbol);
|
|
91
|
+
return { title };
|
|
92
|
+
})();
|
|
93
|
+
// On failure, evict so a later retry can succeed.
|
|
94
|
+
promise.catch(() => {
|
|
95
|
+
if (inFlight.get(slug) === promise)
|
|
96
|
+
inFlight.delete(slug);
|
|
97
|
+
});
|
|
98
|
+
inFlight.set(slug, promise);
|
|
99
|
+
return promise;
|
|
100
|
+
}
|
|
101
|
+
function ensureSprite() {
|
|
102
|
+
if (sprite && sprite.isConnected)
|
|
103
|
+
return sprite;
|
|
104
|
+
// Survive HMR / multiple module instances: reuse an existing tagged sprite.
|
|
105
|
+
const existing = document.querySelector(`svg[${SPRITE_MARKER}]`);
|
|
106
|
+
if (existing) {
|
|
107
|
+
sprite = existing;
|
|
108
|
+
return sprite;
|
|
109
|
+
}
|
|
110
|
+
const svg = document.createElementNS(SVG_NS, "svg");
|
|
111
|
+
svg.setAttribute(SPRITE_MARKER, "");
|
|
112
|
+
svg.setAttribute("aria-hidden", "true");
|
|
113
|
+
svg.setAttribute("xmlns", SVG_NS);
|
|
114
|
+
svg.style.position = "absolute";
|
|
115
|
+
svg.style.width = "0";
|
|
116
|
+
svg.style.height = "0";
|
|
117
|
+
svg.style.overflow = "hidden";
|
|
118
|
+
document.body.appendChild(svg);
|
|
119
|
+
sprite = svg;
|
|
120
|
+
return svg;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { clearSimpleIconsCache, getSimpleIconSymbolId, loadSimpleIcon, setSimpleIconsBaseUrl };
|
|
124
|
+
//# sourceMappingURL=simple-icons-sprite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-icons-sprite.js","sources":["../../../../libs/elements/src/icon/simple-icons-sprite.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;AAWG;AAEH,MAAM,YAAY,GAAG,eAAe;AACpC,MAAM,aAAa,GAAG,sBAAsB;AAC5C,MAAM,MAAM,GAAG,4BAA4B;AAE3C,IAAI,OAAO,GAAG,6BAA6B;AAC3C,IAAI,MAAM,GAAyB,IAAI;AACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmC;AAO3D;;;AAGG;AACG,SAAU,qBAAqB,CAAC,IAAY,EAAA;IAChD,OAAO,CAAA,MAAA,EAA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,CAAC,KAAK,OAAO;AAAE,YAAA,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;AAC3D,IAAA,CAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;AAC3B,IAAA,OAAO,OAAO;AAChB;AAEA,SAAS,YAAY,GAAA;AACnB,IAAA,IAAI,MAAM,IAAI,MAAM,CAAC,WAAW;AAAE,QAAA,OAAO,MAAM;;IAG/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAgB,CAAA,IAAA,EAAO,aAAa,CAAA,CAAA,CAAG,CAAC;IAC/E,IAAI,QAAQ,EAAE;QACZ,MAAM,GAAG,QAAQ;AACjB,QAAA,OAAO,MAAM;IACf;IAEA,MAAM,GAAG,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC;AACnD,IAAA,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC;AACnC,IAAA,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;AACvC,IAAA,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC;AACjC,IAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU;AAC/B,IAAA,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG;AACrB,IAAA,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG;AACtB,IAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ;AAC7B,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IAE9B,MAAM,GAAG,GAAG;AACZ,IAAA,OAAO,GAAG;AACZ;;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
this.TelperionElements=this.TelperionElements||{},function(t){"use strict";function e(t,e,r,s){var n,i=arguments.length,a=i<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,s);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(a=(i<3?n(a):i>3?n(e,r,a):n(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function r(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function s(){}"function"==typeof SuppressedError&&SuppressedError;
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2019 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
const n=globalThis,i=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,a=Symbol(),o=new WeakMap;let h=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==a)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const r=void 0!==e&&1===e.length;r&&(t=o.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&o.set(e,t))}return t}toString(){return this.cssText}};const d=(t,...e)=>{const r=1===t.length?t[0]:e.reduce((e,r,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+t[s+1],t[0]);return new h(r,t,a)},l=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const r of t.cssRules)e+=r.cssText;return(t=>new h("string"==typeof t?t:t+"",void 0,a))(e)})(t):t,{is:c,defineProperty:p,getOwnPropertyDescriptor:g,getOwnPropertyNames:u,getOwnPropertySymbols:v,getPrototypeOf:f}=Object,m=globalThis,y=m.trustedTypes,E=y?y.emptyScript:"",$=m.reactiveElementPolyfillSupport,A=(t,e)=>t,_={toAttribute(t,e){switch(e){case Boolean:t=t?E:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=null!==t;break;case Number:r=null===t?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch(t){r=null}}return r}},D=(t,e)=>!c(t,e),b={attribute:!0,type:String,converter:_,reflect:!1,useDefault:!1,hasChanged:D};
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2017 Google LLC
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
*/Symbol.metadata??=Symbol("metadata"),m.litPropertyMetadata??=new WeakMap;let S=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=b){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const r=Symbol(),s=this.getPropertyDescriptor(t,r,e);void 0!==s&&p(this.prototype,t,s)}}static getPropertyDescriptor(t,e,r){const{get:s,set:n}=g(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:s,set(e){const i=s?.call(this);n?.call(this,e),this.requestUpdate(t,i,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(A("elementProperties")))return;const t=f(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(A("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(A("properties"))){const t=this.properties,e=[...u(t),...v(t)];for(const r of e)this.createProperty(r,t[r])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,r]of e)this.elementProperties.set(t,r)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const r=this._$Eu(t,e);void 0!==r&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const t of r)e.unshift(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eu(t,e){const r=e.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(i)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const r of e){const e=document.createElement("style"),s=n.litNonce;void 0!==s&&e.setAttribute("nonce",s),e.textContent=r.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){const r=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,r);if(void 0!==s&&!0===r.reflect){const n=(void 0!==r.converter?.toAttribute?r.converter:_).toAttribute(e,r.type);this._$Em=t,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(t,e){const r=this.constructor,s=r._$Eh.get(t);if(void 0!==s&&this._$Em!==s){const t=r.getPropertyOptions(s),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:_;this._$Em=s;const i=n.fromAttribute(e,t.type);this[s]=i??this._$Ej?.get(s)??i,this._$Em=null}}requestUpdate(t,e,r){if(void 0!==t){const s=this.constructor,n=this[t];if(r??=s.getPropertyOptions(t),!((r.hasChanged??D)(n,e)||r.useDefault&&r.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(s._$Eu(t,r))))return;this.C(t,e,r)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:s,wrapped:n},i){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??e??this[t]),!0!==n||void 0!==i)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),!0===s&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,r]of t){const{wrapped:t}=r,s=this[e];!0!==t||this._$AL.has(e)||void 0===s||this.C(e,void 0,r,s)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[A("elementProperties")]=new Map,S[A("finalized")]=new Map,$?.({ReactiveElement:S}),(m.reactiveElementVersions??=[]).push("2.1.1");
|
|
13
|
+
/**
|
|
14
|
+
* @license
|
|
15
|
+
* Copyright 2017 Google LLC
|
|
16
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
+
*/
|
|
18
|
+
const w=globalThis,C=w.trustedTypes,T=C?C.createPolicy("lit-html",{createHTML:t=>t}):void 0,O="$lit$",P=`lit$${Math.random().toFixed(9).slice(2)}$`,x="?"+P,R=`<${x}>`,L=document,U=()=>L.createComment(""),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,H="[ \t\n\f\r]",z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,k=/-->/g,j=/>/g,B=RegExp(`>|${H}(?:([^\\s"'>=/]+)(${H}*=${H}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),W=/'/g,G=/"/g,I=/^(?:script|style|textarea|title)$/i,Z=(t=>(e,...r)=>({_$litType$:t,strings:e,values:r}))(1),V=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),J=new WeakMap,K=L.createTreeWalker(L,129);function F(t,e){if(!N(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==T?T.createHTML(e):e}const Q=(t,e)=>{const r=t.length-1,s=[];let n,i=2===e?"<svg>":3===e?"<math>":"",a=z;for(let e=0;e<r;e++){const r=t[e];let o,h,d=-1,l=0;for(;l<r.length&&(a.lastIndex=l,h=a.exec(r),null!==h);)l=a.lastIndex,a===z?"!--"===h[1]?a=k:void 0!==h[1]?a=j:void 0!==h[2]?(I.test(h[2])&&(n=RegExp("</"+h[2],"g")),a=B):void 0!==h[3]&&(a=B):a===B?">"===h[0]?(a=n??z,d=-1):void 0===h[1]?d=-2:(d=a.lastIndex-h[2].length,o=h[1],a=void 0===h[3]?B:'"'===h[3]?G:W):a===G||a===W?a=B:a===k||a===j?a=z:(a=B,n=void 0);const c=a===B&&t[e+1].startsWith("/>")?" ":"";i+=a===z?r+R:d>=0?(s.push(o),r.slice(0,d)+O+r.slice(d)+P+c):r+P+(-2===d?e:c)}return[F(t,i+(t[r]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]};class Y{constructor({strings:t,_$litType$:e},r){let s;this.parts=[];let n=0,i=0;const a=t.length-1,o=this.parts,[h,d]=Q(t,e);if(this.el=Y.createElement(h,r),K.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(s=K.nextNode())&&o.length<a;){if(1===s.nodeType){if(s.hasAttributes())for(const t of s.getAttributeNames())if(t.endsWith(O)){const e=d[i++],r=s.getAttribute(t).split(P),a=/([.?@])?(.*)/.exec(e);o.push({type:1,index:n,name:a[2],strings:r,ctor:"."===a[1]?st:"?"===a[1]?nt:"@"===a[1]?it:rt}),s.removeAttribute(t)}else t.startsWith(P)&&(o.push({type:6,index:n}),s.removeAttribute(t));if(I.test(s.tagName)){const t=s.textContent.split(P),e=t.length-1;if(e>0){s.textContent=C?C.emptyScript:"";for(let r=0;r<e;r++)s.append(t[r],U()),K.nextNode(),o.push({type:2,index:++n});s.append(t[e],U())}}}else if(8===s.nodeType)if(s.data===x)o.push({type:2,index:n});else{let t=-1;for(;-1!==(t=s.data.indexOf(P,t+1));)o.push({type:7,index:n}),t+=P.length-1}n++}}static createElement(t,e){const r=L.createElement("template");return r.innerHTML=t,r}}function X(t,e,r=t,s){if(e===V)return e;let n=void 0!==s?r._$Co?.[s]:r._$Cl;const i=M(e)?void 0:e._$litDirective$;return n?.constructor!==i&&(n?._$AO?.(!1),void 0===i?n=void 0:(n=new i(t),n._$AT(t,r,s)),void 0!==s?(r._$Co??=[])[s]=n:r._$Cl=n),void 0!==n&&(e=X(t,n._$AS(t,e.values),n,s)),e}class tt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,s=(t?.creationScope??L).importNode(e,!0);K.currentNode=s;let n=K.nextNode(),i=0,a=0,o=r[0];for(;void 0!==o;){if(i===o.index){let e;2===o.type?e=new et(n,n.nextSibling,this,t):1===o.type?e=new o.ctor(n,o.name,o.strings,this,t):6===o.type&&(e=new at(n,this,t)),this._$AV.push(e),o=r[++a]}i!==o?.index&&(n=K.nextNode(),i++)}return K.currentNode=L,s}p(t){let e=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class et{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,s){this.type=2,this._$AH=q,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=X(this,t,e),M(t)?t===q||null==t||""===t?(this._$AH!==q&&this._$AR(),this._$AH=q):t!==this._$AH&&t!==V&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>N(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==q&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(L.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:r}=t,s="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=Y.createElement(F(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===s)this._$AH.p(e);else{const t=new tt(s,this),r=t.u(this.options);t.p(e),this.T(r),this._$AH=t}}_$AC(t){let e=J.get(t.strings);return void 0===e&&J.set(t.strings,e=new Y(t)),e}k(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,s=0;for(const n of t)s===e.length?e.push(r=new et(this.O(U()),this.O(U()),this,this.options)):r=e[s],r._$AI(n),s++;s<e.length&&(this._$AR(r&&r._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class rt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,s,n){this.type=1,this._$AH=q,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=n,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=q}_$AI(t,e=this,r,s){const n=this.strings;let i=!1;if(void 0===n)t=X(this,t,e,0),i=!M(t)||t!==this._$AH&&t!==V,i&&(this._$AH=t);else{const s=t;let a,o;for(t=n[0],a=0;a<n.length-1;a++)o=X(this,s[r+a],e,a),o===V&&(o=this._$AH[a]),i||=!M(o)||o!==this._$AH[a],o===q?t=q:t!==q&&(t+=(o??"")+n[a+1]),this._$AH[a]=o}i&&!s&&this.j(t)}j(t){t===q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class st extends rt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===q?void 0:t}}class nt extends rt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==q)}}class it extends rt{constructor(t,e,r,s,n){super(t,e,r,s,n),this.type=5}_$AI(t,e=this){if((t=X(this,t,e,0)??q)===V)return;const r=this._$AH,s=t===q&&r!==q||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==q&&(r===q||s);s&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class at{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){X(this,t)}}const ot=w.litHtmlPolyfillSupport;ot?.(Y,et),(w.litHtmlVersions??=[]).push("3.3.1");const ht=globalThis;
|
|
19
|
+
/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2017 Google LLC
|
|
22
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
+
*/class dt extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,r)=>{const s=r?.renderBefore??e;let n=s._$litPart$;if(void 0===n){const t=r?.renderBefore??null;s._$litPart$=n=new et(e.insertBefore(U(),t),t,void 0,r??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return V}}dt._$litElement$=!0,dt.finalized=!0,ht.litElementHydrateSupport?.({LitElement:dt});const lt=ht.litElementPolyfillSupport;lt?.({LitElement:dt}),(ht.litElementVersions??=[]).push("4.2.1");
|
|
24
|
+
/**
|
|
25
|
+
* @license
|
|
26
|
+
* Copyright 2017 Google LLC
|
|
27
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
+
*/
|
|
29
|
+
const ct=t=>(e,r)=>{void 0!==r?r.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)},pt={attribute:!0,type:String,converter:_,reflect:!1,hasChanged:D},gt=(t=pt,e,r)=>{const{kind:s,metadata:n}=r;let i=globalThis.litPropertyMetadata.get(n);if(void 0===i&&globalThis.litPropertyMetadata.set(n,i=new Map),"setter"===s&&((t=Object.create(t)).wrapped=!0),i.set(r.name,t),"accessor"===s){const{name:s}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(s,n,t)},init(e){return void 0!==e&&this.C(s,void 0,t,e),e}}}if("setter"===s){const{name:s}=r;return function(r){const n=this[s];e.call(this,r),this.requestUpdate(s,n,t)}}throw Error("Unsupported decorator location: "+s)};
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2017 Google LLC
|
|
33
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
+
*/function ut(t){return(e,r)=>"object"==typeof r?gt(t,e,r):((t,e,r)=>{const s=e.hasOwnProperty(r);return e.constructor.createProperty(r,t),s?Object.getOwnPropertyDescriptor(e,r):void 0})(t,e,r)}const vt=Symbol("Accept Drop"),ft=Symbol("Register Handle"),mt=Symbol("Unregister Handle");var yt,Et;class $t extends DragEvent{static#t=["thadrag","thadragstart","thadragend","thadropzoneenter","thadropzoneleave","thadropzoneover","thadropped"];static#e=["thadrop","thadropend","thadragenter","thadragleave","thadragover"];get#r(){return yt.#e.includes(this.type)?this.dropzoneTarget:yt.#t.includes(this.type)?this.dragTarget:new WeakRef(this.target)}get name(){return this.#r.deref()?.name}get dragData(){return this.dragTarget.deref()?.dragData}constructor(t,{dragTarget:e,dropzoneTarget:r},s){super(t,s),this.dragTarget=e,this.dropzoneTarget=r}acceptDrop(t){this.dragTarget.deref()?.[vt](this.dropzoneTarget,t)}}let At;yt=$t,t.DragElement=class extends dt{constructor(){super(...arguments),this.dragData={},this.preDragData={boundingRect:null,dragStartEvent:null,styles:{pointerEvents:""}},this.#s=null,this.#n=null,this.#i=new Set,this.draggingStrategy="move",this.dragging=!1,this.dragend=!1,this.draggedOver=null,this.dropAccepted=!1,this.#a=t=>{if(!this.#o(t))return t.preventDefault();t.stopPropagation(),t.dataTransfer?.setDragImage(Et.TRANSPARENT_IMAGE,0,0),t.dataTransfer.effectAllowed=this.draggingStrategy,document.addEventListener("dragover",this.#h),this.#d(t),this.#l(),function(t=s){return new Promise((e,r)=>{setTimeout(()=>{try{const r=t();e(r)}catch(t){r(t)}},0)})}().then(()=>{if(this.style.pointerEvents="none",this.dragging=!0,this.replaceClone){const t=this.#c();this.#n=new WeakRef(t),this.parentElement.insertBefore(t,this.nextSibling)}this.dispatchEvent(new $t("thadragstart",{dragTarget:new WeakRef(this)},t))})},this.#p=t=>{document.removeEventListener("dragover",this.#h),this.dragend=!0;const e=getComputedStyle(this).transitionDuration.match(/\d*\.?\d+/g)?.map(Number).some(t=>t>0),r=()=>{this.replaceClone&&this.clone?.remove(),this.style.pointerEvents=this.preDragData.styles.pointerEvents,["--tha-width","--tha-height","--tha-left","--tha-top","--tha-x","--tha-y","--tha-cx","--tha-cy"].forEach(t=>{this.style.removeProperty(t)}),["width","height","left","right","top","bottom"].forEach(t=>{this.style.removeProperty(`--tha-target-${t}`)});const e=this.#s,r=this.dropAccepted;this.dragging=!1,this.dragend=!1,this.draggedOver=null,this.dropAccepted=!1,this.#s=null,r&&e&&e.deref()?.dispatchEvent(new $t("thadropend",{dragTarget:new WeakRef(this),dropzoneTarget:e},t)),this.dispatchEvent(new $t("thadragend",{dragTarget:new WeakRef(this)},t))};e?this.addEventListener("transitionend",r,{once:!0}):r()},this.#g=t=>{const{x:e,y:r}=t;this.style.setProperty("--tha-cx",`${e}px`),this.style.setProperty("--tha-cy",`${r}px`)},this.#u=t=>{this.draggedOver=t.dropzoneTarget?.deref()?.name??""},this.#v=()=>{this.draggedOver=null}}static{Et=this}static{this.DRAG_DATA_OBSERVER=new MutationObserver(t=>{for(const{attributeName:e,target:r}of t){if(!e?.startsWith("data-drag-"))continue;const t=r;t.dragData[e.replace("data-drag-","")]=t.getAttribute(e)}})}static{this.styles=d`
|
|
35
|
+
:host {
|
|
36
|
+
--tha-diff-x: calc(var(--tha-cx) - var(--tha-x));
|
|
37
|
+
--tha-diff-y: calc(var(--tha-cy) - var(--tha-y));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:host([draggingstrategy="move"]),
|
|
41
|
+
:host([draggingstrategy="copyMove"]) {
|
|
42
|
+
transition-duration: .2s;
|
|
43
|
+
transition-timing-function: ease-out;
|
|
44
|
+
transition-property: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:host([draggingstrategy="move"][dragging]),
|
|
48
|
+
:host([draggingstrategy="copyMove"][dragging]) {
|
|
49
|
+
position: fixed;
|
|
50
|
+
width: var(--tha-width);
|
|
51
|
+
height: var(--tha-height);
|
|
52
|
+
left: calc(var(--tha-left) + var(--tha-diff-x) + var(--tha-offset-x));
|
|
53
|
+
top: calc(var(--tha-top) + var(--tha-diff-y) + var(--tha-offset-y));
|
|
54
|
+
transform-origin: calc(var(--tha-x) - var(--tha-left)) calc(var(--tha-y) - var(--tha-top));
|
|
55
|
+
z-index: 100;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([draggingstrategy="move"][dragend]),
|
|
59
|
+
:host([draggingstrategy="copyMove"][dragend]) {
|
|
60
|
+
left: var(--tha-left);
|
|
61
|
+
top: var(--tha-top);
|
|
62
|
+
transition-property: all;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([draggingstrategy="move"][dragend][dropaccepted]),
|
|
66
|
+
:host([draggingstrategy="copyMove"][dragend][dropaccepted]) {
|
|
67
|
+
left: var(--tha-target-left);
|
|
68
|
+
top: var(--tha-target-top);
|
|
69
|
+
width: var(--tha-target-width);
|
|
70
|
+
height: var(--tha-target-height);
|
|
71
|
+
}
|
|
72
|
+
`}static{this.TRANSPARENT_IMAGE=new Image(1,1),this.TRANSPARENT_IMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==";const t=this.GLOBAL_STYLE=document.createElement("style");t.innerHTML="\n @property --tha-offset-x {\n syntax: '<length>';\n initial-value: 0px;\n inherits: true;\n }\n\n @property --tha-offset-y {\n syntax: '<length>';\n initial-value: 0px;\n inherits: true;\n }\n ",document.head.appendChild(t)}#s;#n;#i;get clone(){return this.#n.deref()}connectedCallback(){super.connectedCallback(),this.draggable=!0,this.#f(),this.addEventListener("dragstart",this.#a),this.addEventListener("dragend",this.#p),this.addEventListener("drag",this.#g),this.addEventListener("thadropzoneenter",this.#u),this.addEventListener("thadropzoneleave",this.#v)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("dragstart",this.#a),this.removeEventListener("dragend",this.#p),this.removeEventListener("drag",this.#g),this.removeEventListener("thadropzoneenter",this.#u),this.removeEventListener("thadropzoneleave",this.#v)}render(){return Z`<slot></slot>`}[vt](t,e){if(this.dropAccepted=!0,this.#s=t,!e)return;const{width:r,height:s,left:n,right:i,top:a,bottom:o}=e;for(const t in{width:r,height:s,left:n,right:i,top:a,bottom:o})this.style.setProperty(`--tha-target-${t}`,`${e[t]}px`)}[ft](t){this.#i.add(t)}[mt](t){this.#i.delete(t)}#f(){Et.DRAG_DATA_OBSERVER.observe(this,{attributes:!0});for(const{name:t,value:e}of Object.values(this.attributes).filter(t=>t.name.startsWith("data-drag-")))this.dragData[t.replace("data-drag-","")]=e}#a;#p;#g;#u;#v;#c(){const t=document.createElement("tha-drag-clone");return Object.values(this.attributes).filter(t=>!["dragging","replaceclone","draggable"].includes(t.name)).forEach(e=>{t.attributes.setNamedItem(e.cloneNode())}),this.childNodes.forEach(e=>{t.appendChild(e.cloneNode(!0))}),t}#d(t){this.preDragData.boundingRect=this.getBoundingClientRect(),this.preDragData.dragStartEvent=t,this.preDragData.styles.pointerEvents=this.style.pointerEvents}#l(){const{boundingRect:{width:t,height:e,left:r,top:s},dragStartEvent:{x:n,y:i}}=this.preDragData,a={width:t,height:e,left:r,top:s,x:n,y:i};for(const t in a)this.style.setProperty(`--tha-${t}`,`${a[t]}px`)}#h(t){t.preventDefault()}#o(t){return!this.disabled&&(!this.#i.size||!!this.#i.has(t.target))}},e([ut({type:String}),r("design:type",String)],t.DragElement.prototype,"name",void 0),e([ut({type:String,reflect:!0}),r("design:type",String)],t.DragElement.prototype,"draggingStrategy",void 0),e([ut({type:String}),r("design:type",String)],t.DragElement.prototype,"dragGroup",void 0),e([ut({type:Boolean}),r("design:type",Boolean)],t.DragElement.prototype,"replaceClone",void 0),e([ut({type:Boolean,reflect:!0}),r("design:type",Object)],t.DragElement.prototype,"dragging",void 0),e([ut({type:Boolean,reflect:!0}),r("design:type",Object)],t.DragElement.prototype,"dragend",void 0),e([ut({type:String,reflect:!0}),r("design:type",Object)],t.DragElement.prototype,"draggedOver",void 0),e([ut({type:Boolean,reflect:!0}),r("design:type",Object)],t.DragElement.prototype,"dropAccepted",void 0),e([ut({type:Boolean,reflect:!0}),r("design:type",Boolean)],t.DragElement.prototype,"disabled",void 0),t.DragElement=Et=e([ct("tha-drag")],t.DragElement),document.addEventListener("thadragstart",t=>{At=t}),t.DropZoneElement=class extends dt{constructor(){super(...arguments),this.#m=0,this.accept=[],this.name="",this.itemDragged=null,this.acceptableDrag=!1,this.#y=t=>{this.accept.length&&!this.accept.includes(t.name)||(this.acceptableDrag=!0)},this.#E=()=>{this.itemDragged=null,this.acceptableDrag=!1,this.#m=0},this.#$=t=>{this.#A()&&(++this.#m>1||(this.itemDragged=At.name??"",this.#_("thadragenter","thadropzoneenter",t)))},this.#D=t=>{this.#A()&&(--this.#m>0||(this.itemDragged=null,this.#_("thadragleave","thadropzoneleave",t)))},this.#b=t=>{this.#A()&&this.#_("thadragover","thadropzoneover",t)},this.#S=t=>{this.#A()&&this.#_("thadrop","thadropped",t)}}static{this.styles=d``}#m;render(){return Z`<slot></slot>`}connectedCallback(){super.connectedCallback(),document.addEventListener("thadragstart",this.#y),document.addEventListener("thadragend",this.#E),document.addEventListener("thadropend",this.#E),this.addEventListener("dragenter",this.#$),this.addEventListener("dragleave",this.#D),this.addEventListener("dragover",this.#b),this.addEventListener("drop",this.#S)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("thadragstart",this.#y),document.removeEventListener("thadragend",this.#E),document.removeEventListener("thadropend",this.#E),this.removeEventListener("dragenter",this.#$),this.removeEventListener("dragleave",this.#D),this.removeEventListener("dragover",this.#b),this.removeEventListener("drop",this.#S)}#y;#E;#$;#D;#b;#S;#A(){return!At.name||!this.accept.length||this.accept.includes(At.name)}#_(t,e,r){const{dragTarget:s}=At,n=new WeakRef(this);this.dispatchEvent(new $t(t,{dragTarget:s,dropzoneTarget:n},r)),s.deref()?.dispatchEvent(new $t(e,{dragTarget:s,dropzoneTarget:n},r))}},e([ut({converter:t=>(t??"").split(",").map(t=>t.trim())}),r("design:type",Array)],t.DropZoneElement.prototype,"accept",void 0),e([ut({type:String}),r("design:type",Object)],t.DropZoneElement.prototype,"name",void 0),e([ut({type:String,reflect:!0}),r("design:type",Object)],t.DropZoneElement.prototype,"itemDragged",void 0),e([ut({type:Boolean,reflect:!0}),r("design:type",Object)],t.DropZoneElement.prototype,"acceptableDrag",void 0),t.DropZoneElement=e([ct("tha-dropzone")],t.DropZoneElement),t.DragHandleElement=class extends dt{get#w(){for(const e of function*(t){for(;t.parentElement;)yield t=t.parentElement}(this))if(e instanceof t.DragElement)return e;return null}connectedCallback(){super.connectedCallback(),this.draggable=!0,this.#w?.[ft](this)}disconnectedCallback(){super.disconnectedCallback(),this.#w?.[mt](this)}render(){return Z`<slot></slot>`}},t.DragHandleElement=e([ct("tha-drag-handle")],t.DragHandleElement),t.ThaDragEvent=$t}(this.TelperionElements.DragDrop=this.TelperionElements.DragDrop||{});
|
|
73
|
+
//# sourceMappingURL=index.js.map
|