@svgt/core 0.1.0 → 0.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/LICENSE +21 -0
- package/README.md +52 -20
- package/dist/angular.d.ts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/frameworks.d.ts +2 -2
- package/dist/frameworks.js +1 -1
- package/dist/{index-CXQ6tq9C.d.ts → index-CFHXlo8P.d.ts} +10 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/jsx-CLs13YQ-.js +5 -0
- package/dist/{options-BjKpPC6x.d.ts → options-CMZc7e_j.d.ts} +3 -3
- package/dist/preact.d.ts +4 -0
- package/dist/preact.js +1 -0
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -4
- package/dist/solid.d.ts +4 -0
- package/dist/solid.js +1 -0
- package/dist/svelte.d.ts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/web-components.d.ts +1 -1
- package/package.json +17 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pablo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# svgt
|
|
2
2
|
|
|
3
|
-
A zero-dependency library to transform SVG into components
|
|
3
|
+
A zero-dependency library to transform SVG into frontend components.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -33,6 +33,8 @@ transform(svg, { output: { name: "ArrowLeft" } });
|
|
|
33
33
|
| Framework | `framework` value | Entry point |
|
|
34
34
|
| -------------- | ------------------ | --------------------------- |
|
|
35
35
|
| React | `"react"` | `@svgt/core/react` |
|
|
36
|
+
| Preact | `"preact"` | `@svgt/core/preact` |
|
|
37
|
+
| Solid | `"solid"` | `@svgt/core/solid` |
|
|
36
38
|
| Svelte | `"svelte"` | `@svgt/core/svelte` |
|
|
37
39
|
| Vue | `"vue"` | `@svgt/core/vue` |
|
|
38
40
|
| Angular | `"angular"` | `@svgt/core/angular` |
|
|
@@ -51,21 +53,23 @@ import {
|
|
|
51
53
|
isFramework,
|
|
52
54
|
} from "@svgt/core/frameworks";
|
|
53
55
|
|
|
54
|
-
FRAMEWORK_IDS; // ["react", "
|
|
56
|
+
FRAMEWORK_IDS; // ["react", "preact", "solid", ...]
|
|
55
57
|
FRAMEWORKS.vue.label; // "Vue"
|
|
56
58
|
FRAMEWORKS.vue.typescriptOption; // false
|
|
59
|
+
FRAMEWORKS.react.exportTypeOption; // true
|
|
60
|
+
FRAMEWORKS.vue.expandPropsOption; // false
|
|
57
61
|
|
|
58
62
|
fileName("react", "arrow-left"); // "ArrowLeft.tsx (tsx)"
|
|
59
63
|
fileName("react", "arrow-left", false); // "ArrowLeft.jsx (jsx)"
|
|
60
64
|
fileName("angular", "ArrowLeft"); // "arrow-left.component.ts"
|
|
61
65
|
```
|
|
62
66
|
|
|
63
|
-
| Export | Description
|
|
64
|
-
| --------------------------------------- |
|
|
65
|
-
| `FRAMEWORK_IDS` | Every `framework` value, in display order.
|
|
66
|
-
| `FRAMEWORKS` | Each framework's `label`, whether it accepts the `typescript` option (`typescriptOption`) and its `fileName()`.
|
|
67
|
-
| `fileName(framework, name, typescript)` | File name for a component, with `name` in PascalCase first. `typescript` defaults to `true`. The CLI uses the same names.
|
|
68
|
-
| `isFramework(value)` | Whether a string is a `framework` value. Narrows it to the `Framework` type.
|
|
67
|
+
| Export | Description |
|
|
68
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
69
|
+
| `FRAMEWORK_IDS` | Every `framework` value, in display order. |
|
|
70
|
+
| `FRAMEWORKS` | Each framework's `label`, whether it accepts the `typescript` option (`typescriptOption`), whether it uses `output.exportType` (`exportTypeOption`) and `output.expandProps` (`expandPropsOption`), and its `fileName()`. |
|
|
71
|
+
| `fileName(framework, name, typescript)` | File name for a component, with `name` in PascalCase first. `typescript` defaults to `true`. The CLI uses the same names. |
|
|
72
|
+
| `isFramework(value)` | Whether a string is a `framework` value. Narrows it to the `Framework` type. |
|
|
69
73
|
|
|
70
74
|
## Framework outputs
|
|
71
75
|
|
|
@@ -83,6 +87,34 @@ const SvgIcon = (props: SVGProps<SVGSVGElement>) => (
|
|
|
83
87
|
export default SvgIcon;
|
|
84
88
|
```
|
|
85
89
|
|
|
90
|
+
### Preact
|
|
91
|
+
|
|
92
|
+
A function component that spreads `props` onto the `<svg>`. Attributes keep their SVG names (`class`, `stroke-width`), because Preact sets them as written: `strokeWidth` only works with `preact/compat`. Inline `style` stays a string. `xlink:href` becomes `href`, and `tabindex` and numeric `aria-*` values are printed as numbers, as Preact's types expect.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import type { SVGAttributes } from "preact";
|
|
96
|
+
|
|
97
|
+
const SvgIcon = (props: SVGAttributes<SVGSVGElement>) => (
|
|
98
|
+
/// <svg ...props></svg>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export default SvgIcon;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Solid
|
|
105
|
+
|
|
106
|
+
A Solid 2 function component that spreads `props` onto the `<svg>`, which keeps them reactive. Attributes keep their SVG names (`class`, `stroke-width`, `viewBox`) and inline `style` stays a string. Solid's types declare no `xlink:*` or `xml:*` attributes, so `xlink:href` becomes `href`, `xml:lang` becomes `lang` and the rest are dropped.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import type { ComponentProps } from "@solidjs/web";
|
|
110
|
+
|
|
111
|
+
const SvgIcon = (props: ComponentProps<"svg">) => (
|
|
112
|
+
/// <svg ...props></svg>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
export default SvgIcon;
|
|
116
|
+
```
|
|
117
|
+
|
|
86
118
|
### Svelte
|
|
87
119
|
|
|
88
120
|
A Svelte 5 component that reads `$props()` and spreads them onto the `<svg>`.
|
|
@@ -200,15 +232,15 @@ transform(svg, "react", {
|
|
|
200
232
|
});
|
|
201
233
|
```
|
|
202
234
|
|
|
203
|
-
| Option | Type | Default | Frameworks
|
|
204
|
-
| -------------------- | ----------------------------------------------- | ----------- |
|
|
205
|
-
| `typescript` | `boolean` | `true` | React, Svelte, Astro, Web Components |
|
|
206
|
-
| `output.name` | `string` | `"SvgIcon"` | React, Angular, Web Components |
|
|
207
|
-
| `output.exportType` | `"default"` or `"directly"` | `"default"` | React, Web Components |
|
|
208
|
-
| `output.dimensions` | `boolean` | `true` | All
|
|
209
|
-
| `output.svgProps` | `Record<string, string>`, with `null` to remove | `{}` | All
|
|
210
|
-
| `output.expandProps` | `"start"`, `"end"` or `false` | `"end"` | React, Svelte, Astro |
|
|
211
|
-
| `preTransform` | `(svg: string) => string` | — | All
|
|
235
|
+
| Option | Type | Default | Frameworks |
|
|
236
|
+
| -------------------- | ----------------------------------------------- | ----------- | --------------------------------------------------- |
|
|
237
|
+
| `typescript` | `boolean` | `true` | React, Preact, Solid, Svelte, Astro, Web Components |
|
|
238
|
+
| `output.name` | `string` | `"SvgIcon"` | React, Preact, Solid, Angular, Web Components |
|
|
239
|
+
| `output.exportType` | `"default"` or `"directly"` | `"default"` | React, Preact, Solid, Web Components |
|
|
240
|
+
| `output.dimensions` | `boolean` | `true` | All |
|
|
241
|
+
| `output.svgProps` | `Record<string, string>`, with `null` to remove | `{}` | All |
|
|
242
|
+
| `output.expandProps` | `"start"`, `"end"` or `false` | `"end"` | React, Preact, Solid, Svelte, Astro |
|
|
243
|
+
| `preTransform` | `(svg: string) => string` | — | All |
|
|
212
244
|
|
|
213
245
|
### TypeScript
|
|
214
246
|
|
|
@@ -228,7 +260,7 @@ transform(svg, "react", { typescript: false });
|
|
|
228
260
|
transform(svg, "angular", { output: { name: "ArrowLeft" } });
|
|
229
261
|
```
|
|
230
262
|
|
|
231
|
-
- **React**: the component is `ArrowLeft`.
|
|
263
|
+
- **React**, **Preact** and **Solid**: the component is `ArrowLeft`.
|
|
232
264
|
- **Angular**: the class is `ArrowLeftComponent` (the suffix is not added twice) and the selector is `arrow-left`.
|
|
233
265
|
- **Web Components**: the class is `ArrowLeft` and the tag is `arrow-left`. Custom element names need a hyphen, so a one-word name like `Arrow` gets the tag `svg-arrow`.
|
|
234
266
|
|
|
@@ -236,10 +268,10 @@ transform(svg, "angular", { output: { name: "ArrowLeft" } });
|
|
|
236
268
|
|
|
237
269
|
### Export type
|
|
238
270
|
|
|
239
|
-
`output.exportType` sets how the component is exported, in React and Web Components:
|
|
271
|
+
`output.exportType` sets how the component is exported, in React, Preact, Solid and Web Components:
|
|
240
272
|
|
|
241
273
|
- `"default"` (default): `export default ArrowLeft;` at the end.
|
|
242
|
-
- `"directly"`: on the declaration, as `export const ArrowLeft = (props) => ...` in React and `export class ArrowLeft extends HTMLElement` in Web Components. Import it with `import { ArrowLeft } from "./ArrowLeft"`.
|
|
274
|
+
- `"directly"`: on the declaration, as `export const ArrowLeft = (props) => ...` in React, Preact and Solid, and `export class ArrowLeft extends HTMLElement` in Web Components. Import it with `import { ArrowLeft } from "./ArrowLeft"`.
|
|
243
275
|
|
|
244
276
|
```ts
|
|
245
277
|
transform(svg, "react", {
|
package/dist/angular.d.ts
CHANGED
package/dist/astro.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as TransformOptions } from "./options-
|
|
1
|
+
import { o as TransformOptions } from "./options-CMZc7e_j.js";
|
|
2
2
|
/** Convert an SVG string into an Astro component. */
|
|
3
3
|
export declare const transform: (svg: string, options?: TransformOptions) => string;
|
|
4
4
|
export type { TransformOptions };
|
package/dist/frameworks.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { FRAMEWORKS, FRAMEWORK_IDS, Framework, FrameworkInfo, TypeScriptAgnosticFramework, fileName };
|
|
1
|
+
import { a as Framework, c as fileName, i as FRAMEWORK_IDS, n as ExportTypeFramework, o as FrameworkInfo, r as FRAMEWORKS, s as TypeScriptAgnosticFramework, t as ExpandPropsFramework } from "./index-CFHXlo8P.js";
|
|
2
|
+
export { ExpandPropsFramework, ExportTypeFramework, FRAMEWORKS, FRAMEWORK_IDS, Framework, FrameworkInfo, TypeScriptAgnosticFramework, fileName };
|
package/dist/frameworks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./case-D05A9Slu.js";const n={react:{label:`React`,typescriptOption:!0,fileName:(e,t)=>`${e}.${t?`tsx`:`jsx`}`},svelte:{label:`Svelte`,typescriptOption:!0,fileName:e=>`${e}.svelte`},vue:{label:`Vue`,typescriptOption:!1,fileName:e=>`${e}.vue`},angular:{label:`Angular`,typescriptOption:!1,fileName:t=>`${e(t)}.component.ts`},astro:{label:`Astro`,typescriptOption:!0,fileName:e=>`${e}.astro`},"web-components":{label:`Web Components`,typescriptOption:!0,fileName:(t,n)=>`${e(t)}.${n?`ts`:`js`}`}},r=Object.keys(n),i=(e,r,i=!0)=>n[e].fileName(t(r),i);export{n as FRAMEWORKS,r as FRAMEWORK_IDS,i as fileName};
|
|
1
|
+
import{n as e,r as t}from"./case-D05A9Slu.js";const n={react:{label:`React`,typescriptOption:!0,exportTypeOption:!0,expandPropsOption:!0,fileName:(e,t)=>`${e}.${t?`tsx`:`jsx`}`},preact:{label:`Preact`,typescriptOption:!0,exportTypeOption:!0,expandPropsOption:!0,fileName:(e,t)=>`${e}.${t?`tsx`:`jsx`}`},solid:{label:`Solid`,typescriptOption:!0,exportTypeOption:!0,expandPropsOption:!0,fileName:(e,t)=>`${e}.${t?`tsx`:`jsx`}`},svelte:{label:`Svelte`,typescriptOption:!0,exportTypeOption:!1,expandPropsOption:!0,fileName:e=>`${e}.svelte`},vue:{label:`Vue`,typescriptOption:!1,exportTypeOption:!1,expandPropsOption:!1,fileName:e=>`${e}.vue`},angular:{label:`Angular`,typescriptOption:!1,exportTypeOption:!1,expandPropsOption:!1,fileName:t=>`${e(t)}.component.ts`},astro:{label:`Astro`,typescriptOption:!0,exportTypeOption:!1,expandPropsOption:!0,fileName:e=>`${e}.astro`},"web-components":{label:`Web Components`,typescriptOption:!0,exportTypeOption:!0,expandPropsOption:!1,fileName:(t,n)=>`${e(t)}.${n?`ts`:`js`}`}},r=Object.keys(n),i=(e,r,i=!0)=>n[e].fileName(t(r),i);export{n as FRAMEWORKS,r as FRAMEWORK_IDS,i as fileName};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
type Framework = "react" | "svelte" | "vue" | "angular" | "astro" | "web-components";
|
|
1
|
+
type Framework = "react" | "preact" | "solid" | "svelte" | "vue" | "angular" | "astro" | "web-components";
|
|
2
2
|
/** Frameworks whose output does not depend on the `typescript` option. */
|
|
3
3
|
type TypeScriptAgnosticFramework = "angular" | "vue";
|
|
4
|
+
/** Frameworks whose output depends on the `exportType` option. */
|
|
5
|
+
type ExportTypeFramework = "react" | "preact" | "solid" | "web-components";
|
|
6
|
+
/** Frameworks whose output depends on the `expandProps` option. */
|
|
7
|
+
type ExpandPropsFramework = "react" | "preact" | "solid" | "svelte" | "astro";
|
|
4
8
|
interface FrameworkInfo<F extends Framework = Framework> {
|
|
5
9
|
/** Display name, such as `"Web Components"`. */
|
|
6
10
|
label: string;
|
|
7
11
|
/** Whether `transform()` accepts the `typescript` option. */
|
|
8
12
|
typescriptOption: F extends TypeScriptAgnosticFramework ? false : true;
|
|
13
|
+
/** Whether `transform()` uses the `output.exportType` option. */
|
|
14
|
+
exportTypeOption: F extends ExportTypeFramework ? true : false;
|
|
15
|
+
/** Whether `transform()` uses the `output.expandProps` option. */
|
|
16
|
+
expandPropsOption: F extends ExpandPropsFramework ? true : false;
|
|
9
17
|
/** File name for a component, following the framework's convention. */
|
|
10
18
|
fileName: (name: string, typescript: boolean) => string;
|
|
11
19
|
}
|
|
@@ -16,4 +24,4 @@ declare const FRAMEWORK_IDS: readonly Framework[];
|
|
|
16
24
|
* `name` is converted to PascalCase first, like `output.name` in `transform()`.
|
|
17
25
|
*/
|
|
18
26
|
declare const fileName: (framework: Framework, name: string, typescript?: boolean) => string;
|
|
19
|
-
export {
|
|
27
|
+
export { Framework as a, fileName as c, FRAMEWORK_IDS as i, ExportTypeFramework as n, FrameworkInfo as o, FRAMEWORKS as r, TypeScriptAgnosticFramework as s, ExpandPropsFramework as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as PreTransform, c as SvgProps, i as OutputOptions, n as ExportType, o as TransformOptions, r as FrameworkOptions, s as ExpandProps, t as BaseTransformOptions } from "./options-
|
|
1
|
+
import { a as Framework } from "./index-CFHXlo8P.js";
|
|
2
|
+
import { a as PreTransform, c as SvgProps, i as OutputOptions, n as ExportType, o as TransformOptions, r as FrameworkOptions, s as ExpandProps, t as BaseTransformOptions } from "./options-CMZc7e_j.js";
|
|
3
3
|
/**
|
|
4
4
|
* Transform an SVG string into a component for the given framework.
|
|
5
5
|
* The `typescript` option is only accepted by frameworks it applies to.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{transform as e}from"./vue.js";import{transform as t}from"./react.js";import{transform as n}from"./
|
|
1
|
+
import{transform as e}from"./vue.js";import{transform as t}from"./react.js";import{transform as n}from"./solid.js";import{transform as r}from"./astro.js";import{transform as i}from"./preact.js";import{transform as a}from"./svelte.js";import{transform as o}from"./angular.js";import{transform as s}from"./web-components.js";const c={react:t,preact:i,solid:n,svelte:a,vue:e,angular:o,astro:r,"web-components":s},l=(e,t,n)=>{let r=c[t];if(!r)throw Error(`[svgt] Unknown framework "${t}"`);return r(e,n)};export{l as transform};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{t as e}from"./template-CSV8K9KX.js";const t=(e,t)=>t.attributes.some(({name:t})=>t===e)?null:e,n=(e,t)=>/["\\&\n{}]/.test(t)?`${e}={${JSON.stringify(t)}}`:`${e}="${t}"`,r=(t,n)=>e.has(n.name)?`{${JSON.stringify(t)}}`:t.replace(/[{}<>&]/g,e=>`{${JSON.stringify(e)}}`),i=({name:e,markup:t,params:n,imports:r,exportType:i})=>{let a=r.length?`${r.join(`
|
|
2
|
+
`)}\n\n`:``,o=`const ${e} = (${n}) => (
|
|
3
|
+
${t}
|
|
4
|
+
);
|
|
5
|
+
`;return i===`directly`?`${a}export ${o}`:`${a}${o}\nexport default ${e};\n`};export{t as i,i as n,r,n as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as Framework, s as TypeScriptAgnosticFramework } from "./index-CFHXlo8P.js";
|
|
2
2
|
interface SvgAttribute {
|
|
3
3
|
name: string;
|
|
4
4
|
value: string;
|
|
@@ -34,7 +34,7 @@ interface Customizers {
|
|
|
34
34
|
}
|
|
35
35
|
type CustomizerOptions = { [K in keyof Customizers]?: CustomizerValue<Customizers[K]>; };
|
|
36
36
|
/**
|
|
37
|
-
* How a React or Web Components component is exported:
|
|
37
|
+
* How a React, Preact, Solid or Web Components component is exported:
|
|
38
38
|
* `"default"` (`export default SvgIcon;`) or `"directly"` (`export const SvgIcon = ...`, `export class SvgIcon ...`).
|
|
39
39
|
*/
|
|
40
40
|
type ExportType = "default" | "directly";
|
|
@@ -42,7 +42,7 @@ type ExportType = "default" | "directly";
|
|
|
42
42
|
interface OutputOptions extends CustomizerOptions {
|
|
43
43
|
/** Component name. Converted to PascalCase. @default "SvgIcon" */
|
|
44
44
|
name?: string;
|
|
45
|
-
/** How the component is exported. Only React and Web Components use it. @default "default" */
|
|
45
|
+
/** How the component is exported. Only React, Preact, Solid and Web Components use it. @default "default" */
|
|
46
46
|
exportType?: ExportType;
|
|
47
47
|
}
|
|
48
48
|
/**
|
package/dist/preact.d.ts
ADDED
package/dist/preact.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,l as t,s as n}from"./template-CSV8K9KX.js";import{i as r,n as i,r as a,t as o}from"./jsx-CLs13YQ-.js";const s=(e,t)=>e===`xlink:href`?r(`href`,t):e===`xmlns:xlink`?null:e,c=/* @__PURE__ */ new Set([`tabindex`,`aria-colcount`,`aria-colindex`,`aria-colspan`,`aria-level`,`aria-posinset`,`aria-rowcount`,`aria-rowindex`,`aria-rowspan`,`aria-setsize`,`aria-valuemax`,`aria-valuemin`,`aria-valuenow`]),l=({name:e,value:t},n)=>{let r=s(e,n);return r===null?null:c.has(r)&&/^-?\d+(\.\d+)?$/.test(t)?`${r}={${t}}`:o(r,t)},u=(r,o)=>{let{root:s,name:c,typescript:u,exportType:d}=n(r,o),f=e(s,{attribute:l,text:a,spread:`{...props}`,indent:1}),p=t(s);return i({name:c,markup:f,params:p?u?`props: SVGAttributes<SVGSVGElement>`:`props`:``,imports:u&&p?[`import type { SVGAttributes } from "preact";`]:[],exportType:d})};export{u as transform};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as TransformOptions } from "./options-
|
|
1
|
+
import { o as TransformOptions } from "./options-CMZc7e_j.js";
|
|
2
2
|
/** Convert an SVG string into a React component. */
|
|
3
3
|
export declare const transform: (svg: string, options?: TransformOptions) => string;
|
|
4
4
|
export type { TransformOptions };
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import{c as e,l as t,s as n
|
|
2
|
-
${d}
|
|
3
|
-
);
|
|
4
|
-
`;return u===`directly`?`${m}export ${h}`:`${m}${h}\nexport default ${o};\n`};export{u as transform};
|
|
1
|
+
import{c as e,l as t,s as n}from"./template-CSV8K9KX.js";import{t as r}from"./case-D05A9Slu.js";import{n as i,r as a,t as o}from"./jsx-CLs13YQ-.js";const s=e=>e===`class`?`className`:e===`tabindex`?`tabIndex`:e.startsWith(`data-`)||e.startsWith(`aria-`)?e:r(e),c=e=>`{{ ${e.split(`;`).map(e=>{let t=e.indexOf(`:`);if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim();return!n||!i?null:`${n.startsWith(`--`)?JSON.stringify(n):r(n.toLowerCase().replace(/^-ms-/,`ms-`))}: ${JSON.stringify(i)}`}).filter(Boolean).join(`, `)} }}`,l=/* @__PURE__ */ new Set([`tabIndex`]),u=({name:e,value:t},n)=>{let r=s(e);if(r===`style`){let e=c(t);return n&&e.includes(`"--`)?`style={${e.slice(1,-1)} as CSSProperties}`:`style=${e}`}return l.has(r)&&/^-?\d+$/.test(t)?`${r}={${t}}`:o(r,t)},d=(r,o)=>{let{root:s,name:c,typescript:l,exportType:d}=n(r,o),f=e(s,{attribute:e=>u(e,l),text:a,spread:`{...props}`,indent:1}),p=t(s),m=[f.includes(` as CSSProperties}`)&&`CSSProperties`,p&&`SVGProps`].filter(Boolean);return i({name:c,markup:f,params:p?l?`props: SVGProps<SVGSVGElement>`:`props`:``,imports:l&&m.length?[`import type { ${m.join(`, `)} } from "react";`]:[],exportType:d})};export{d as transform};
|
package/dist/solid.d.ts
ADDED
package/dist/solid.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,l as t,s as n}from"./template-CSV8K9KX.js";import{i as r,n as i,r as a,t as o}from"./jsx-CLs13YQ-.js";const s=(e,t)=>e===`xlink:href`?r(`href`,t):e===`xml:lang`?r(`lang`,t):/^(xlink|xml|xmlns):/.test(e)?null:e,c=({name:e,value:t},n)=>{let r=s(e,n);return r===null?null:o(r,t)},l=(r,o)=>{let{root:s,name:l,typescript:u,exportType:d}=n(r,o),f=e(s,{attribute:c,text:a,spread:`{...props}`,indent:1}),p=t(s);return i({name:l,markup:f,params:p?u?`props: ComponentProps<"svg">`:`props`:``,imports:u&&p?[`import type { ComponentProps } from "@solidjs/web";`]:[],exportType:d})};export{l as transform};
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as TransformOptions } from "./options-
|
|
1
|
+
import { o as TransformOptions } from "./options-CMZc7e_j.js";
|
|
2
2
|
/** Convert an SVG string into a Svelte 5 component. */
|
|
3
3
|
export declare const transform: (svg: string, options?: TransformOptions) => string;
|
|
4
4
|
export type { TransformOptions };
|
package/dist/vue.d.ts
CHANGED
package/dist/web-components.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as TransformOptions } from "./options-
|
|
1
|
+
import { o as TransformOptions } from "./options-CMZc7e_j.js";
|
|
2
2
|
/** Convert an SVG string into a native Web Component (Custom Element). */
|
|
3
3
|
export declare const transform: (svg: string, options?: TransformOptions) => string;
|
|
4
4
|
export type { TransformOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svgt/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A zero-dependency library to transform SVG into framework components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
"types": "./dist/react.d.ts",
|
|
31
31
|
"default": "./dist/react.js"
|
|
32
32
|
},
|
|
33
|
+
"./preact": {
|
|
34
|
+
"types": "./dist/preact.d.ts",
|
|
35
|
+
"default": "./dist/preact.js"
|
|
36
|
+
},
|
|
37
|
+
"./solid": {
|
|
38
|
+
"types": "./dist/solid.d.ts",
|
|
39
|
+
"default": "./dist/solid.js"
|
|
40
|
+
},
|
|
33
41
|
"./svelte": {
|
|
34
42
|
"types": "./dist/svelte.d.ts",
|
|
35
43
|
"default": "./dist/svelte.js"
|
|
@@ -60,12 +68,18 @@
|
|
|
60
68
|
"devDependencies": {
|
|
61
69
|
"@types/node": "24.19.2",
|
|
62
70
|
"@types/react": "19.3.3",
|
|
71
|
+
"@vitest/coverage-v8": "5.1.2",
|
|
63
72
|
"tsdown": "0.23.7",
|
|
64
|
-
"typescript": "6.0.3"
|
|
73
|
+
"typescript": "6.0.3",
|
|
74
|
+
"vite": "8.4.0",
|
|
75
|
+
"vitest": "5.1.2"
|
|
65
76
|
},
|
|
66
77
|
"scripts": {
|
|
67
78
|
"build": "tsdown",
|
|
68
79
|
"dev": "tsdown --watch --no-clean",
|
|
69
|
-
"check": "tsc --noEmit"
|
|
80
|
+
"check": "tsc --noEmit",
|
|
81
|
+
"test": "vitest run",
|
|
82
|
+
"test:watch": "vitest",
|
|
83
|
+
"test:coverage": "vitest run --coverage"
|
|
70
84
|
}
|
|
71
85
|
}
|