elements-kit 0.26.7 → 0.27.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/dist/await.d.mts +1 -1
- package/dist/{children-C2OkLfJM.d.mts → children-CB8W0ANY.d.mts} +8 -0
- package/dist/{element-Bwxltm6M.mjs → element-DgQvp-49.mjs} +1 -1
- package/dist/for.d.mts +1 -1
- package/dist/for.mjs +1 -1
- package/dist/{fragment-DbiYZ5rL.mjs → fragment-BJfcQdsL.mjs} +31 -10
- package/dist/{hot-DXg5S-Va.mjs → hot-Zl0s17uq.mjs} +1 -1
- package/dist/hydrate/index.mjs +1 -1
- package/dist/{hydrate-3id6HROs.mjs → hydrate-ICXw1FIY.mjs} +16 -8
- package/dist/integrations/astro-client.mjs +2 -2
- package/dist/integrations/astro-server.mjs +2 -2
- package/dist/integrations/astro-slots.mjs +2 -2
- package/dist/integrations/hmr-runtime.mjs +2 -2
- package/dist/integrations/svg.d.mts +67 -0
- package/dist/integrations/svg.mjs +162 -0
- package/dist/jsx-runtime/dev.d.mts +1 -1
- package/dist/jsx-runtime/dev.mjs +2 -2
- package/dist/jsx-runtime/index.d.mts +1 -1
- package/dist/jsx-runtime/index.mjs +2 -2
- package/dist/server/index.mjs +1 -1
- package/dist/{server-3O_3GbAe.mjs → server-Qm9JTZ-J.mjs} +2 -2
- package/package.json +2 -6
package/dist/await.d.mts
CHANGED
|
@@ -166,6 +166,8 @@ type ComponentProps<T extends JSX$1.ElementType | JSX$1.ElementClass> = T extend
|
|
|
166
166
|
type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/jsx-runtime/fragment.d.ts
|
|
169
|
+
/** Namespaces the HTML parser enters only on seeing an `<svg>`/`<math>` tag. */
|
|
170
|
+
type ForeignNamespace = "svg" | "mathml";
|
|
169
171
|
/**
|
|
170
172
|
* Used by the JSX transform for `<>...</>` fragments.
|
|
171
173
|
*
|
|
@@ -181,11 +183,17 @@ type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
|
|
|
181
183
|
* region boundary. Reactive sources re-render the region on change. This is
|
|
182
184
|
* the library's only raw-HTML sink: the string is NOT escaped — sanitize
|
|
183
185
|
* untrusted input at the call site. `<script>` tags never execute.
|
|
186
|
+
*
|
|
187
|
+
* `ns` marks the markup as interior foreign content —
|
|
188
|
+
* `<svg><Fragment html ns="svg">{interior}</Fragment></svg>`. Generated code is
|
|
189
|
+
* the expected caller (the SVG plugin knows the namespace at build time). The
|
|
190
|
+
* server ignores it; the string is already inside its parent there.
|
|
184
191
|
*/
|
|
185
192
|
declare function Fragment(props: Props<{
|
|
186
193
|
children?: Children;
|
|
187
194
|
}> | {
|
|
188
195
|
html: true;
|
|
196
|
+
ns?: ForeignNamespace;
|
|
189
197
|
children: MaybeReactive<string>;
|
|
190
198
|
}): DocumentFragment;
|
|
191
199
|
//#endregion
|
|
@@ -619,4 +619,4 @@ function renderNode(node) {
|
|
|
619
619
|
return renderNode(node.render());
|
|
620
620
|
}
|
|
621
621
|
//#endregion
|
|
622
|
-
export { applyProps as a, AttrAliases as c,
|
|
622
|
+
export { applyProps as a, AttrAliases as c, MATHML_NAMESPACE as d, Properties as f, setRenderer as i, BooleanAttributes as l, disposeElement as n, mountChild as o, SVG_NAMESPACE as p, getRenderer as r, resolveChild as s, createElement as t, ChildProperties as u };
|
package/dist/for.d.mts
CHANGED
package/dist/for.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as untracked, S as trigger, _ as onCleanup, d as effectScope, u as effect, x as signal } from "./lib-DYypKhxk.mjs";
|
|
2
2
|
import "./signals/index.mjs";
|
|
3
|
-
import { n as disposeElement } from "./element-
|
|
3
|
+
import { n as disposeElement } from "./element-DgQvp-49.mjs";
|
|
4
4
|
//#region src/for.ts
|
|
5
5
|
/**
|
|
6
6
|
* Keyed list renderer. See {@link ForProps} for prop details.
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { _ as onCleanup, u as effect } from "./lib-DYypKhxk.mjs";
|
|
2
2
|
import "./signals/index.mjs";
|
|
3
|
-
import { o as mountChild } from "./element-
|
|
3
|
+
import { d as MATHML_NAMESPACE, o as mountChild, p as SVG_NAMESPACE } from "./element-DgQvp-49.mjs";
|
|
4
4
|
import { Slot } from "./slot.mjs";
|
|
5
5
|
//#region src/jsx-runtime/fragment.ts
|
|
6
|
+
const ForeignRoots = {
|
|
7
|
+
svg: [SVG_NAMESPACE, "svg"],
|
|
8
|
+
mathml: [MATHML_NAMESPACE, "math"]
|
|
9
|
+
};
|
|
6
10
|
/**
|
|
7
|
-
* Parse an HTML string script-inertly
|
|
8
|
-
*
|
|
9
|
-
*
|
|
11
|
+
* Parse an HTML string script-inertly — `<script>` never executes. Sanitizing
|
|
12
|
+
* the input is the caller's responsibility.
|
|
13
|
+
*
|
|
14
|
+
* `ns` parses against a detached root of that namespace, so an interior
|
|
15
|
+
* fragment lands in SVG/MathML rather than XHTML. The element is the parser's
|
|
16
|
+
* context, not a text wrapper, so a stray `</svg>` can't escape the region.
|
|
10
17
|
*/
|
|
11
|
-
function parseHtml(html) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
function parseHtml(html, ns) {
|
|
19
|
+
if (ns === void 0) {
|
|
20
|
+
const template = document.createElement("template");
|
|
21
|
+
template.innerHTML = html;
|
|
22
|
+
return template.content;
|
|
23
|
+
}
|
|
24
|
+
const [namespace, root] = ForeignRoots[ns];
|
|
25
|
+
const host = document.createElementNS(namespace, root);
|
|
26
|
+
host.innerHTML = html;
|
|
27
|
+
const fragment = document.createDocumentFragment();
|
|
28
|
+
fragment.append(...host.childNodes);
|
|
29
|
+
return fragment;
|
|
15
30
|
}
|
|
16
31
|
/**
|
|
17
32
|
* Used by the JSX transform for `<>...</>` fragments.
|
|
@@ -28,20 +43,26 @@ function parseHtml(html) {
|
|
|
28
43
|
* region boundary. Reactive sources re-render the region on change. This is
|
|
29
44
|
* the library's only raw-HTML sink: the string is NOT escaped — sanitize
|
|
30
45
|
* untrusted input at the call site. `<script>` tags never execute.
|
|
46
|
+
*
|
|
47
|
+
* `ns` marks the markup as interior foreign content —
|
|
48
|
+
* `<svg><Fragment html ns="svg">{interior}</Fragment></svg>`. Generated code is
|
|
49
|
+
* the expected caller (the SVG plugin knows the namespace at build time). The
|
|
50
|
+
* server ignores it; the string is already inside its parent there.
|
|
31
51
|
*/
|
|
32
52
|
function Fragment(props) {
|
|
33
53
|
const fragment = document.createDocumentFragment();
|
|
34
54
|
if ("html" in props && props.html) {
|
|
55
|
+
const ns = "ns" in props ? props.ns : void 0;
|
|
35
56
|
const slot = new Slot();
|
|
36
57
|
fragment.appendChild(slot.get());
|
|
37
58
|
const source = props.children;
|
|
38
59
|
if (typeof source === "function") {
|
|
39
60
|
effect(() => {
|
|
40
61
|
const value = source();
|
|
41
|
-
slot.set(parseHtml(value == null ? "" : String(value)));
|
|
62
|
+
slot.set(parseHtml(value == null ? "" : String(value), ns));
|
|
42
63
|
});
|
|
43
64
|
onCleanup(() => slot.clear());
|
|
44
|
-
} else if (source != null) slot.set(parseHtml(String(source)));
|
|
65
|
+
} else if (source != null) slot.set(parseHtml(String(source), ns));
|
|
45
66
|
return fragment;
|
|
46
67
|
}
|
|
47
68
|
const raw = props.children;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as onCleanup, u as effect, x as signal } from "./lib-DYypKhxk.mjs";
|
|
2
2
|
import "./signals/index.mjs";
|
|
3
|
-
import { r as getRenderer, t as createElement } from "./element-
|
|
3
|
+
import { r as getRenderer, t as createElement } from "./element-DgQvp-49.mjs";
|
|
4
4
|
import { Slot } from "./slot.mjs";
|
|
5
5
|
import { HMR_CELLS_SLOT, HMR_SLOT } from "./integrations/hmr-slot.mjs";
|
|
6
6
|
//#region src/jsx-runtime/hot.ts
|
package/dist/hydrate/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as hydrate } from "../hydrate-
|
|
1
|
+
import { t as hydrate } from "../hydrate-ICXw1FIY.mjs";
|
|
2
2
|
export { hydrate };
|
|
@@ -2,10 +2,10 @@ import { C as untracked, _ as onCleanup, d as effectScope, n as CLAIM, t as ASYN
|
|
|
2
2
|
import { isReactive } from "./signals/index.mjs";
|
|
3
3
|
import { isReactivePromiseLike } from "./utilities/promise.mjs";
|
|
4
4
|
import { flushDeferredAsyncRuns, isAsyncLike } from "./utilities/async.mjs";
|
|
5
|
-
import { a as applyProps, i as setRenderer, s as resolveChild, t as createElement } from "./element-
|
|
5
|
+
import { a as applyProps, i as setRenderer, s as resolveChild, t as createElement } from "./element-DgQvp-49.mjs";
|
|
6
6
|
import { Slot } from "./slot.mjs";
|
|
7
7
|
import { For, isForComponent } from "./for.mjs";
|
|
8
|
-
import { n as isFragmentComponent, r as parseHtml, t as Fragment } from "./fragment-
|
|
8
|
+
import { n as isFragmentComponent, r as parseHtml, t as Fragment } from "./fragment-BJfcQdsL.mjs";
|
|
9
9
|
//#region src/hydrate/claim.ts
|
|
10
10
|
let hydrationContext = null;
|
|
11
11
|
function setHydrationContext(ctx) {
|
|
@@ -28,7 +28,8 @@ const claimRenderer = { jsx(type, props) {
|
|
|
28
28
|
[VNODE]: true,
|
|
29
29
|
kind: "frag",
|
|
30
30
|
children: props.children,
|
|
31
|
-
html: props.html === true
|
|
31
|
+
html: props.html === true,
|
|
32
|
+
ns: props.ns
|
|
32
33
|
};
|
|
33
34
|
if (isForComponent(type)) return {
|
|
34
35
|
[VNODE]: true,
|
|
@@ -66,7 +67,7 @@ function walkChild(cur, c, om) {
|
|
|
66
67
|
if (c == null || typeof c === "boolean") return;
|
|
67
68
|
if (isVNode(c)) {
|
|
68
69
|
if (c.kind === "frag") {
|
|
69
|
-
if (c.html) return claimRawRegion(cur, c.children, om);
|
|
70
|
+
if (c.html) return claimRawRegion(cur, c.children, c.ns, om);
|
|
70
71
|
return walkList(cur, c.children, om);
|
|
71
72
|
}
|
|
72
73
|
if (c.kind === "for") return claimFor(cur, c, om);
|
|
@@ -196,11 +197,11 @@ function claimMarkerRange(cur, open, close) {
|
|
|
196
197
|
return null;
|
|
197
198
|
}
|
|
198
199
|
/** `<Fragment html>` region: adopt the server markup between the markers. */
|
|
199
|
-
function claimRawRegion(cur, source, om) {
|
|
200
|
+
function claimRawRegion(cur, source, ns, om) {
|
|
200
201
|
const claimed = cur.node?.nodeType === Node.COMMENT_NODE && cur.node.data === "{";
|
|
201
202
|
const slot = claimSlot(cur, om);
|
|
202
203
|
if (typeof source !== "function") {
|
|
203
|
-
if (!claimed && source != null) slot.set(parseHtml(String(source)));
|
|
204
|
+
if (!claimed && source != null) slot.set(parseHtml(String(source), ns));
|
|
204
205
|
return;
|
|
205
206
|
}
|
|
206
207
|
let first = claimed;
|
|
@@ -210,7 +211,7 @@ function claimRawRegion(cur, source, om) {
|
|
|
210
211
|
first = false;
|
|
211
212
|
return;
|
|
212
213
|
}
|
|
213
|
-
slot.set(parseHtml(value == null ? "" : String(value)));
|
|
214
|
+
slot.set(parseHtml(value == null ? "" : String(value), ns));
|
|
214
215
|
});
|
|
215
216
|
onCleanup(() => slot.clear());
|
|
216
217
|
}
|
|
@@ -306,7 +307,14 @@ function buildVNode(v) {
|
|
|
306
307
|
if ("children" in props) props.children = buildChildValue(props.children);
|
|
307
308
|
return createElement(v.tag, props);
|
|
308
309
|
}
|
|
309
|
-
if (v.kind === "frag")
|
|
310
|
+
if (v.kind === "frag") {
|
|
311
|
+
if (v.html) return Fragment({
|
|
312
|
+
html: true,
|
|
313
|
+
ns: v.ns,
|
|
314
|
+
children: v.children
|
|
315
|
+
});
|
|
316
|
+
return Fragment({ children: (() => buildChildValue(v.children)) });
|
|
317
|
+
}
|
|
310
318
|
return createElement(For, v.props);
|
|
311
319
|
}
|
|
312
320
|
function buildChildValue(c) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as createElement } from "../element-
|
|
1
|
+
import { t as createElement } from "../element-DgQvp-49.mjs";
|
|
2
2
|
import { render } from "../render.mjs";
|
|
3
|
-
import { t as hydrate } from "../hydrate-
|
|
3
|
+
import { t as hydrate } from "../hydrate-ICXw1FIY.mjs";
|
|
4
4
|
import { withSlotProps } from "./astro-slots.mjs";
|
|
5
5
|
import { HMR_SLOT } from "./hmr-slot.mjs";
|
|
6
6
|
//#region src/integrations/astro-client.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { y as setInertEffects } from "../lib-DYypKhxk.mjs";
|
|
2
|
-
import { i as setRenderer, t as createElement } from "../element-
|
|
2
|
+
import { i as setRenderer, t as createElement } from "../element-DgQvp-49.mjs";
|
|
3
3
|
import { withSlotProps } from "./astro-slots.mjs";
|
|
4
|
-
import { i as serverJsx, n as renderToString, r as SNode } from "../server-
|
|
4
|
+
import { i as serverJsx, n as renderToString, r as SNode } from "../server-Qm9JTZ-J.mjs";
|
|
5
5
|
//#region src/integrations/astro-server.ts
|
|
6
6
|
/**
|
|
7
7
|
* Decide whether `Component` is an elements-kit component. Invoked by Astro
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as createElement } from "../element-
|
|
2
|
-
import { t as Fragment } from "../fragment-
|
|
1
|
+
import { t as createElement } from "../element-DgQvp-49.mjs";
|
|
2
|
+
import { t as Fragment } from "../fragment-BJfcQdsL.mjs";
|
|
3
3
|
//#region src/integrations/astro-slots.ts
|
|
4
4
|
/**
|
|
5
5
|
* @internal Map Astro's pre-rendered slot HTML (`Record<name, html>`) into
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as createElement } from "../element-
|
|
1
|
+
import { t as createElement } from "../element-DgQvp-49.mjs";
|
|
2
2
|
import { render } from "../render.mjs";
|
|
3
3
|
import { HMR_SLOT } from "./hmr-slot.mjs";
|
|
4
|
-
import { n as updateCells } from "../hot-
|
|
4
|
+
import { n as updateCells } from "../hot-Zl0s17uq.mjs";
|
|
5
5
|
//#region src/integrations/hmr-runtime.ts
|
|
6
6
|
const slot = globalThis;
|
|
7
7
|
const records = /* @__PURE__ */ new Set();
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//#region src/integrations/svg.d.ts
|
|
2
|
+
interface ElementsKitSvgPlugin {
|
|
3
|
+
name: string;
|
|
4
|
+
enforce: "pre";
|
|
5
|
+
load(id: string): Promise<string | undefined>;
|
|
6
|
+
}
|
|
7
|
+
interface ElementsKitSvgOptions {
|
|
8
|
+
/** Ids this plugin claims. Default: any path ending `.svg?ek`. */
|
|
9
|
+
include?: RegExp;
|
|
10
|
+
/** Ids to leave alone even when `include` matches. */
|
|
11
|
+
exclude?: RegExp;
|
|
12
|
+
/**
|
|
13
|
+
* Strip the root's `width`/`height` and default `fill` to `currentColor`, so
|
|
14
|
+
* an icon sizes with the font and follows text color. Turn off for artwork
|
|
15
|
+
* that carries its own palette and intrinsic size.
|
|
16
|
+
*/
|
|
17
|
+
normalize?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Parsed root `<svg>` open tag plus everything between it and `</svg>`. */
|
|
20
|
+
interface SvgSource {
|
|
21
|
+
attributes: Record<string, string>;
|
|
22
|
+
inner: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Vite plugin: import an SVG file as an elements-kit component.
|
|
26
|
+
*
|
|
27
|
+
* `import Close from "./close.svg?ek"` yields a function component rendering
|
|
28
|
+
* the file's root `<svg>` as a real elements-kit element — so `class`,
|
|
29
|
+
* `style:`, `on:`, `ref` and reactive props all work — with the interior
|
|
30
|
+
* markup passed through verbatim.
|
|
31
|
+
*
|
|
32
|
+
* Server rendering needs no special case: the generated module builds its tree
|
|
33
|
+
* through `jsx`, which dispatches to whichever renderer is active, and the
|
|
34
|
+
* interior rides the raw-HTML sink that the hydration claim walk already knows.
|
|
35
|
+
*
|
|
36
|
+
* Register it yourself in `vite.config` (or `astro.config`'s `vite.plugins`).
|
|
37
|
+
* Coexists with vite-plugin-svgr — the `?ek` and `?react` queries claim
|
|
38
|
+
* different ids.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // vite.config.ts
|
|
43
|
+
* import { defineConfig } from "vite";
|
|
44
|
+
* import elementsKitSvg from "elements-kit/integrations/svg";
|
|
45
|
+
*
|
|
46
|
+
* export default defineConfig({ plugins: [elementsKitSvg()] });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* ```tsx
|
|
50
|
+
* import Close from "@material-symbols/svg-300/outlined/close.svg?ek";
|
|
51
|
+
*
|
|
52
|
+
* <button class="unset x-button" aria-label="Close">
|
|
53
|
+
* <Close class="x-icon" />
|
|
54
|
+
* </button>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function elementsKitSvg(options?: ElementsKitSvgOptions): ElementsKitSvgPlugin;
|
|
58
|
+
declare function generateModule(source: string, {
|
|
59
|
+
normalize: shouldNormalize,
|
|
60
|
+
name
|
|
61
|
+
}?: {
|
|
62
|
+
normalize?: boolean | undefined;
|
|
63
|
+
name?: string | undefined;
|
|
64
|
+
}): string;
|
|
65
|
+
declare function parseSvg(source: string): SvgSource;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { ElementsKitSvgOptions, ElementsKitSvgPlugin, SvgSource, elementsKitSvg as default, generateModule, parseSvg };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
//#region src/integrations/svg.ts
|
|
3
|
+
const DEFAULT_INCLUDE = /\.svg\?(?:.*&)?ek(?:&|$)/;
|
|
4
|
+
const QUERY = /[?#].*$/s;
|
|
5
|
+
/**
|
|
6
|
+
* Vite plugin: import an SVG file as an elements-kit component.
|
|
7
|
+
*
|
|
8
|
+
* `import Close from "./close.svg?ek"` yields a function component rendering
|
|
9
|
+
* the file's root `<svg>` as a real elements-kit element — so `class`,
|
|
10
|
+
* `style:`, `on:`, `ref` and reactive props all work — with the interior
|
|
11
|
+
* markup passed through verbatim.
|
|
12
|
+
*
|
|
13
|
+
* Server rendering needs no special case: the generated module builds its tree
|
|
14
|
+
* through `jsx`, which dispatches to whichever renderer is active, and the
|
|
15
|
+
* interior rides the raw-HTML sink that the hydration claim walk already knows.
|
|
16
|
+
*
|
|
17
|
+
* Register it yourself in `vite.config` (or `astro.config`'s `vite.plugins`).
|
|
18
|
+
* Coexists with vite-plugin-svgr — the `?ek` and `?react` queries claim
|
|
19
|
+
* different ids.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // vite.config.ts
|
|
24
|
+
* import { defineConfig } from "vite";
|
|
25
|
+
* import elementsKitSvg from "elements-kit/integrations/svg";
|
|
26
|
+
*
|
|
27
|
+
* export default defineConfig({ plugins: [elementsKitSvg()] });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import Close from "@material-symbols/svg-300/outlined/close.svg?ek";
|
|
32
|
+
*
|
|
33
|
+
* <button class="unset x-button" aria-label="Close">
|
|
34
|
+
* <Close class="x-icon" />
|
|
35
|
+
* </button>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function elementsKitSvg(options = {}) {
|
|
39
|
+
const { include = DEFAULT_INCLUDE, exclude, normalize: shouldNormalize = true } = options;
|
|
40
|
+
return {
|
|
41
|
+
name: "elements-kit:svg",
|
|
42
|
+
enforce: "pre",
|
|
43
|
+
async load(id) {
|
|
44
|
+
if (!include.test(id)) return;
|
|
45
|
+
if (exclude?.test(id)) return;
|
|
46
|
+
const filePath = id.replace(QUERY, "");
|
|
47
|
+
return generateModule(await fs.readFile(filePath, "utf8"), {
|
|
48
|
+
normalize: shouldNormalize,
|
|
49
|
+
name: componentName(filePath)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function generateModule(source, { normalize: shouldNormalize = true, name = "Svg" } = {}) {
|
|
55
|
+
const { attributes, inner } = parseSvg(source);
|
|
56
|
+
const attrs = shouldNormalize ? normalize(attributes) : attributes;
|
|
57
|
+
const hasInner = inner.trim() !== "";
|
|
58
|
+
const child = hasInner ? `, children: _jsx(_Fragment, { html: true, ns: "svg", children: ${JSON.stringify(inner)} })` : "";
|
|
59
|
+
return `import { ${hasInner ? "jsx as _jsx, Fragment as _Fragment" : "jsx as _jsx"} } from "elements-kit/jsx-runtime";
|
|
60
|
+
const ATTRS = ${JSON.stringify(attrs)};
|
|
61
|
+
export default function ${name}(props) {
|
|
62
|
+
return _jsx("svg", { ...ATTRS, ...props${child} });
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Drop the intrinsic size so CSS owns it, and inherit text color unless the
|
|
68
|
+
* file already paints itself. `viewBox` stays — without it the icon has no
|
|
69
|
+
* aspect ratio to scale by.
|
|
70
|
+
*/
|
|
71
|
+
function normalize(attributes) {
|
|
72
|
+
const { width: _w, height: _h, ...rest } = attributes;
|
|
73
|
+
return "fill" in rest ? rest : {
|
|
74
|
+
...rest,
|
|
75
|
+
fill: "currentColor"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** `outlined/close.svg` → `CloseSvg`; always a valid JS identifier. */
|
|
79
|
+
function componentName(filePath) {
|
|
80
|
+
const pascal = (filePath.split(/[\\/]/).pop()?.replace(/\.svg$/, "") ?? "").split(/[^a-zA-Z0-9]+/).filter(Boolean).map((part) => part[0].toUpperCase() + part.slice(1)).join("");
|
|
81
|
+
return /^[A-Za-z]/.test(pascal) ? `${pascal}Svg` : "Svg";
|
|
82
|
+
}
|
|
83
|
+
function parseSvg(source) {
|
|
84
|
+
let i = skipPreamble(source, 0);
|
|
85
|
+
if (!/^<svg[\s/>]/.test(source.slice(i))) throw new Error("elements-kit:svg — expected the file to start with an <svg> root element.");
|
|
86
|
+
i += 4;
|
|
87
|
+
const attributes = {};
|
|
88
|
+
let selfClosing = false;
|
|
89
|
+
for (;;) {
|
|
90
|
+
while (i < source.length && isSpace(source[i])) i++;
|
|
91
|
+
if (i >= source.length) throw new Error("elements-kit:svg — unterminated <svg> open tag.");
|
|
92
|
+
if (source[i] === ">") {
|
|
93
|
+
i++;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
if (source[i] === "/" && source[i + 1] === ">") {
|
|
97
|
+
selfClosing = true;
|
|
98
|
+
i += 2;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
const nameStart = i;
|
|
102
|
+
while (i < source.length && !isSpace(source[i]) && !"=/>".includes(source[i])) i++;
|
|
103
|
+
const name = source.slice(nameStart, i);
|
|
104
|
+
if (!name) throw new Error("elements-kit:svg — malformed attribute in <svg> open tag.");
|
|
105
|
+
while (i < source.length && isSpace(source[i])) i++;
|
|
106
|
+
if (source[i] !== "=") {
|
|
107
|
+
attributes[name] = "";
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
i++;
|
|
111
|
+
while (i < source.length && isSpace(source[i])) i++;
|
|
112
|
+
const quote = source[i];
|
|
113
|
+
if (quote === "\"" || quote === "'") {
|
|
114
|
+
i++;
|
|
115
|
+
const valueStart = i;
|
|
116
|
+
while (i < source.length && source[i] !== quote) i++;
|
|
117
|
+
attributes[name] = source.slice(valueStart, i);
|
|
118
|
+
i++;
|
|
119
|
+
} else {
|
|
120
|
+
const valueStart = i;
|
|
121
|
+
while (i < source.length && !isSpace(source[i]) && source[i] !== ">") i++;
|
|
122
|
+
attributes[name] = source.slice(valueStart, i);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (selfClosing) return {
|
|
126
|
+
attributes,
|
|
127
|
+
inner: ""
|
|
128
|
+
};
|
|
129
|
+
const close = source.lastIndexOf("</svg>");
|
|
130
|
+
if (close < i) throw new Error("elements-kit:svg — missing closing </svg> tag.");
|
|
131
|
+
return {
|
|
132
|
+
attributes,
|
|
133
|
+
inner: source.slice(i, close)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** Advance past leading whitespace, `<?xml …?>`, `<!DOCTYPE …>` and comments. */
|
|
137
|
+
function skipPreamble(source, from) {
|
|
138
|
+
let i = from;
|
|
139
|
+
for (;;) {
|
|
140
|
+
while (i < source.length && isSpace(source[i])) i++;
|
|
141
|
+
const rest = source.slice(i);
|
|
142
|
+
if (rest.startsWith("<?")) {
|
|
143
|
+
const end = source.indexOf("?>", i);
|
|
144
|
+
if (end === -1) break;
|
|
145
|
+
i = end + 2;
|
|
146
|
+
} else if (rest.startsWith("<!--")) {
|
|
147
|
+
const end = source.indexOf("-->", i);
|
|
148
|
+
if (end === -1) break;
|
|
149
|
+
i = end + 3;
|
|
150
|
+
} else if (rest.startsWith("<!")) {
|
|
151
|
+
const end = source.indexOf(">", i);
|
|
152
|
+
if (end === -1) break;
|
|
153
|
+
i = end + 1;
|
|
154
|
+
} else break;
|
|
155
|
+
}
|
|
156
|
+
return i;
|
|
157
|
+
}
|
|
158
|
+
function isSpace(char) {
|
|
159
|
+
return char === " " || char === " " || char === "\n" || char === "\r";
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
export { elementsKitSvg as default, generateModule, parseSvg };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children } from "../children-
|
|
1
|
+
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children } from "../children-CB8W0ANY.mjs";
|
|
2
2
|
import { n as ComputedProps, r as MaybeReactive } from "../index-B1FHAd5T.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/jsx-runtime/hot.d.ts
|
package/dist/jsx-runtime/dev.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Fragment } from "../fragment-
|
|
2
|
-
import { t as createHotElement } from "../hot-
|
|
1
|
+
import { t as Fragment } from "../fragment-BJfcQdsL.mjs";
|
|
2
|
+
import { t as createHotElement } from "../hot-Zl0s17uq.mjs";
|
|
3
3
|
import "./index.mjs";
|
|
4
4
|
export { Fragment, createHotElement as h, createHotElement as jsx, createHotElement as jsxDEV, createHotElement as jsxs };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children, u as createElement } from "../children-
|
|
1
|
+
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children, u as createElement } from "../children-CB8W0ANY.mjs";
|
|
2
2
|
import { n as ComputedProps, r as MaybeReactive } from "../index-B1FHAd5T.mjs";
|
|
3
3
|
export { type Children, ComponentClass, ComponentFn, type ComputedProps, Fragment, JSX, type MaybeReactive, type MaybeReactiveProps, type Props, type PropsOf, type Require, createElement as h, createElement as jsx, createElement as jsxDEV, createElement as jsxs };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as createElement } from "../element-
|
|
2
|
-
import { t as Fragment } from "../fragment-
|
|
1
|
+
import { t as createElement } from "../element-DgQvp-49.mjs";
|
|
2
|
+
import { t as Fragment } from "../fragment-BJfcQdsL.mjs";
|
|
3
3
|
export { Fragment, createElement as h, createElement as jsx, createElement as jsxDEV, createElement as jsxs };
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as renderToString, t as renderToStream } from "../server-
|
|
1
|
+
import { n as renderToString, t as renderToStream } from "../server-Qm9JTZ-J.mjs";
|
|
2
2
|
export { renderToStream, renderToString };
|
|
@@ -2,9 +2,9 @@ import { C as untracked, y as setInertEffects } from "./lib-DYypKhxk.mjs";
|
|
|
2
2
|
import { isReactive } from "./signals/index.mjs";
|
|
3
3
|
import { isReactivePromiseLike } from "./utilities/promise.mjs";
|
|
4
4
|
import { isAsyncLike } from "./utilities/async.mjs";
|
|
5
|
-
import { c as AttrAliases,
|
|
5
|
+
import { c as AttrAliases, f as Properties, i as setRenderer, l as BooleanAttributes, u as ChildProperties } from "./element-DgQvp-49.mjs";
|
|
6
6
|
import { isForComponent } from "./for.mjs";
|
|
7
|
-
import { n as isFragmentComponent } from "./fragment-
|
|
7
|
+
import { n as isFragmentComponent } from "./fragment-BJfcQdsL.mjs";
|
|
8
8
|
//#region src/server/escape.ts
|
|
9
9
|
function escapeDelim(s, delim, escDelim) {
|
|
10
10
|
let iDelim = s.indexOf(delim);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elements-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.27.0",
|
|
5
5
|
"description": "A lightweight reactive UI library that transforms native HTMLElements into reactive components with signals. Ideal for framework-agnostic applications and web components.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"webcomponents",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
"main": "./dist/index.mjs",
|
|
32
32
|
"types": "./dist/index.d.mts",
|
|
33
33
|
"files": [
|
|
34
|
-
"dist"
|
|
35
|
-
"client.d.ts"
|
|
34
|
+
"dist"
|
|
36
35
|
],
|
|
37
36
|
"exports": {
|
|
38
37
|
".": {
|
|
@@ -40,9 +39,6 @@
|
|
|
40
39
|
"import": "./dist/index.mjs",
|
|
41
40
|
"types": "./dist/index.d.mts"
|
|
42
41
|
},
|
|
43
|
-
"./client": {
|
|
44
|
-
"types": "./client.d.ts"
|
|
45
|
-
},
|
|
46
42
|
"./signals": {
|
|
47
43
|
"source": "./src/signals/index.ts",
|
|
48
44
|
"import": "./dist/signals/index.mjs",
|