@cyberalien/svg-utils 0.1.6 → 0.1.8

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.
@@ -3,6 +3,7 @@ type Types = string | Record<string, string>;
3
3
  interface Options {
4
4
  ext?: string;
5
5
  data?: Record<string, Types>;
6
+ defaultProp?: string;
6
7
  }
7
8
  /**
8
9
  * Add exports for main files to object
@@ -4,9 +4,10 @@
4
4
  function createExportsForMainFiles(data, options = {}) {
5
5
  const result = options?.data || Object.create(null);
6
6
  const ext = options.ext || "";
7
+ const defaultProp = options.defaultProp || "default";
7
8
  for (const { icon, filename, types } of data) result[`./${icon}${ext}`] = types ? {
8
9
  types: `./${types}`,
9
- default: `./${filename}`
10
+ [defaultProp]: `./${filename}`
10
11
  } : `./${filename}`;
11
12
  return result;
12
13
  }
@@ -0,0 +1,6 @@
1
+ import { IconViewBox } from "../../../svg/viewbox/types.js";
2
+ /**
3
+ * Get viewBox ratio as string
4
+ */
5
+ declare function getViewBoxRatio(viewBox: IconViewBox): string;
6
+ export { getViewBoxRatio };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get viewBox ratio as string
3
+ */
4
+ function getViewBoxRatio(viewBox) {
5
+ const ratio = viewBox.width / viewBox.height;
6
+ return (Math.ceil(ratio * 100) / 100).toFixed(2).replace(/\.?0+$/, "");
7
+ }
8
+
9
+ export { getViewBoxRatio };
@@ -0,0 +1,9 @@
1
+ import { GeneratedAssetFile } from "../../types/component.js";
2
+ import { FactoryIconData } from "../../types/data.js";
3
+ import { ComponentFactoryOptions } from "../../types/options.js";
4
+ import { FactoryComponentProps } from "../props/types.js";
5
+ /**
6
+ * Add Svelte component types
7
+ */
8
+ declare const addSvelteComponentTypes: (data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps) => string;
9
+ export { addSvelteComponentTypes };
@@ -0,0 +1,19 @@
1
+ import { addComponentTypes } from "./wrapper.js";
2
+
3
+ /**
4
+ * Add Svelte component types
5
+ */
6
+ const addSvelteComponentTypes = addComponentTypes.bind(null, `import { SvelteComponent } from "svelte";
7
+ import { SvelteHTMLElements } from "svelte/elements";
8
+
9
+ interface IconProps {
10
+ /* PROPS */
11
+ }
12
+
13
+ declare class Component extends SvelteComponent<Omit<SvelteHTMLElements['svg'], 'viewBox' | 'width' | 'height' | 'xmlns'> & IconProps & Record<\`data-\${string}\`, string>> {}
14
+
15
+ export { type IconProps };
16
+ export default Component;
17
+ `);
18
+
19
+ export { addSvelteComponentTypes };
@@ -5,5 +5,5 @@ import { FactoryComponentProps } from "../props/types.js";
5
5
  /**
6
6
  * Add Vue component types
7
7
  */
8
- declare function addVueComponentTypes(data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps): string;
8
+ declare const addVueComponentTypes: (data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps) => string;
9
9
  export { addVueComponentTypes };
@@ -0,0 +1,18 @@
1
+ import { addComponentTypes } from "./wrapper.js";
2
+
3
+ /**
4
+ * Add Vue component types
5
+ */
6
+ const addVueComponentTypes = addComponentTypes.bind(null, `import { DefineSetupFnComponent, PublicProps } from 'vue';
7
+
8
+ interface IconProps {
9
+ /* PROPS */
10
+ }
11
+
12
+ declare const Component: DefineSetupFnComponent<IconProps, {}, {}, IconProps & {}, PublicProps>;
13
+
14
+ export { type IconProps };
15
+ export default Component;
16
+ `);
17
+
18
+ export { addVueComponentTypes };
@@ -0,0 +1,9 @@
1
+ import { GeneratedAssetFile } from "../../types/component.js";
2
+ import { FactoryIconData } from "../../types/data.js";
3
+ import { ComponentFactoryOptions } from "../../types/options.js";
4
+ import { FactoryComponentProps } from "../props/types.js";
5
+ /**
6
+ * Add component types
7
+ */
8
+ declare function addComponentTypes(template: string, data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps): string;
9
+ export { addComponentTypes };
@@ -0,0 +1,18 @@
1
+ import { getGeneratedComponentTypesFilename } from "../filenames/types.js";
2
+ import { stringifyFactoryPropTypes } from "../props/ts.js";
3
+
4
+ /**
5
+ * Add component types
6
+ */
7
+ function addComponentTypes(template, data, options, assets, props) {
8
+ const propTypes = stringifyFactoryPropTypes(props);
9
+ const content = template.replace("/* PROPS */", propTypes);
10
+ const filename = getGeneratedComponentTypesFilename(data, content, options);
11
+ assets.push({
12
+ ...filename,
13
+ content
14
+ });
15
+ return filename.filename;
16
+ }
17
+
18
+ export { addComponentTypes };
@@ -1,7 +1,7 @@
1
1
  import { getComponentSizeValues } from "./helpers/content/size.js";
2
2
  import { stringifyFactoryIconContent } from "./helpers/content/stringify.js";
3
3
  import { getGeneratedComponentTypesFilename } from "./helpers/filenames/types.js";
4
- import { getIconViewBox } from "../svg/viewbox/value.js";
4
+ import { stringifyIconViewBox } from "../svg/viewbox/value.js";
5
5
  import { createFactoryImports } from "./helpers/imports/create.js";
6
6
  import { generateCSSFilesForComponent } from "./helpers/css/generate.js";
7
7
  import { stringifyFactoryImports } from "./helpers/imports/stringify.js";
@@ -18,7 +18,7 @@ function createRawComponent(data, options) {
18
18
  const props = {
19
19
  xmlns: "http://www.w3.org/2000/svg",
20
20
  ...getComponentSizeValues(options, data.viewBox),
21
- viewBox: getIconViewBox(data.viewBox)
21
+ viewBox: stringifyIconViewBox(data.viewBox)
22
22
  };
23
23
  const icon = {
24
24
  ...data.icon,
@@ -0,0 +1,12 @@
1
+ import { FactoryGeneratedComponent } from "./types/component.js";
2
+ import { FactoryIconData } from "./types/data.js";
3
+ import { ComponentFactoryOptions } from "./types/options.js";
4
+ interface SvelteOptions extends ComponentFactoryOptions {
5
+ ts?: boolean;
6
+ styles?: boolean;
7
+ }
8
+ /**
9
+ * Create Svelte component code
10
+ */
11
+ declare function createSvelteComponent(data: FactoryIconData, options: SvelteOptions): FactoryGeneratedComponent;
12
+ export { createSvelteComponent };
@@ -0,0 +1,105 @@
1
+ import { getComponentSizeValues } from "./helpers/content/size.js";
2
+ import { stringifyFactoryIconContent } from "./helpers/content/stringify.js";
3
+ import { stringifyIconViewBox } from "../svg/viewbox/value.js";
4
+ import { createFactoryImports } from "./helpers/imports/create.js";
5
+ import { generateCSSFilesForComponent } from "./helpers/css/generate.js";
6
+ import { stringifyFactoryImports } from "./helpers/imports/stringify.js";
7
+ import { stringifyFactoryProps } from "./helpers/props/stringify.js";
8
+ import { addSizeFunctionAsset } from "./helpers/functions/size.js";
9
+ import { makeSquareViewBox } from "../svg/viewbox/square.js";
10
+ import { getUsedFactoryProps, stringifyFactoryPropTypes } from "./helpers/props/ts.js";
11
+ import { addSvelteComponentTypes } from "./helpers/ts/svelte.js";
12
+ import { minifyViewBox } from "../svg/viewbox/minify.js";
13
+ import { getViewBoxRatio } from "./helpers/content/ratio.js";
14
+
15
+ /**
16
+ * Create Svelte component code
17
+ */
18
+ function createSvelteComponent(data, options) {
19
+ const useTS = options.ts ?? false;
20
+ const styleInComponent = options.styles ?? false;
21
+ const assets = [];
22
+ const imports = createFactoryImports();
23
+ const hasFallback = !!data.fallback;
24
+ if (hasFallback) imports.default["@iconify/css-svelte"] = "Icon";
25
+ const styleContent = generateCSSFilesForComponent(data.icon, imports, assets, {
26
+ ...options,
27
+ styleInComponent
28
+ });
29
+ let hasFixedSize = !!options.width && !!options.height;
30
+ const viewBox = data.viewBox;
31
+ const hasComputedViewbox = options.square && !hasFixedSize && viewBox.width !== viewBox.height;
32
+ const isStringViewBox = !hasFallback;
33
+ const hasComputedRatio = hasComputedViewbox && isStringViewBox;
34
+ if (!hasComputedViewbox && (options.width || options.height)) hasFixedSize = true;
35
+ const componentCode = [];
36
+ const props = {};
37
+ if (!hasFallback) props.xmlns = "http://www.w3.org/2000/svg";
38
+ const viewBoxPropValue = `viewBox${hasComputedViewbox ? "Computed" : ""}`;
39
+ const getViewBox = (viewBox$1) => isStringViewBox ? `'${stringifyIconViewBox(viewBox$1)}'` : JSON.stringify(minifyViewBox(viewBox$1));
40
+ if (hasComputedViewbox) componentCode.push(`const baseViewBox = ${getViewBox(viewBox)};`, `const squareViewBox = ${getViewBox(makeSquareViewBox(viewBox))};`, `let ${viewBoxPropValue} = $derived(square ? squareViewBox : baseViewBox);`);
41
+ else componentCode.push(`const ${viewBoxPropValue} = ${getViewBox(viewBox)};`);
42
+ const ratioValue = getViewBoxRatio(viewBox);
43
+ if (hasComputedRatio) componentCode.push(`let ratio = $derived(square ? 1 : ${ratioValue});`);
44
+ if (hasFixedSize) {
45
+ const sizeProps = getComponentSizeValues(options, data.viewBox);
46
+ if (!sizeProps) throw new Error("Fixed size expected, but could not be determined");
47
+ props.width = sizeProps.width;
48
+ props.height = sizeProps.height;
49
+ } else if (hasFallback) {
50
+ props.width = {
51
+ type: "string",
52
+ value: "width",
53
+ template: "width={width}"
54
+ };
55
+ props.height = {
56
+ type: "string",
57
+ value: "height",
58
+ template: "height={height}"
59
+ };
60
+ } else {
61
+ const getSizeProps = addSizeFunctionAsset(imports, assets, options);
62
+ componentCode.push(`let size = $derived(${getSizeProps}(width, height, ${hasComputedRatio ? "ratio" : ratioValue}));`);
63
+ props.width = {
64
+ type: "string",
65
+ value: "width",
66
+ template: "{...size}"
67
+ };
68
+ props.height = {
69
+ type: "string",
70
+ value: "height",
71
+ template: ""
72
+ };
73
+ }
74
+ if (options.square) props.square = { type: "boolean" };
75
+ props.viewBox = {
76
+ value: "viewBox",
77
+ template: `viewBox={${viewBoxPropValue}}`
78
+ };
79
+ componentCode.push(`const content = ${stringifyFactoryIconContent(data.icon, options)};`);
80
+ const innerHTML = hasFallback ? "" : "{@html content}";
81
+ props.content = {
82
+ value: "content",
83
+ template: hasFallback ? `content={content} fallback="${data.fallback}"` : ""
84
+ };
85
+ const usedProps = getUsedFactoryProps(props);
86
+ componentCode.unshift(`let {${[...usedProps, "...props"].join(", ")}}${useTS ? ": Props" : ""} = $props();\n`);
87
+ if (useTS) componentCode.unshift(`interface Props {\n${stringifyFactoryPropTypes(props)}\n};\n`);
88
+ const tag = hasFallback ? "Icon" : "svg";
89
+ const template = `<${tag} ${stringifyFactoryProps(props, "{prop}={{value}}")} {...props}>${innerHTML}</${tag}>`;
90
+ let content = `<script${useTS ? " lang=\"ts\"" : ""}>
91
+ ${stringifyFactoryImports(imports)}
92
+ ${componentCode.join("\n")}
93
+ <\/script>
94
+ ${template}
95
+ `;
96
+ if (styleContent) content += `<style>\n:global {\n${styleContent}\n}\n</style>\n`;
97
+ const types = addSvelteComponentTypes(data, options, assets, props);
98
+ return {
99
+ assets,
100
+ content,
101
+ types
102
+ };
103
+ }
104
+
105
+ export { createSvelteComponent };
@@ -1,14 +1,16 @@
1
1
  import { getComponentSizeValues } from "./helpers/content/size.js";
2
2
  import { stringifyFactoryIconContent } from "./helpers/content/stringify.js";
3
- import { getIconViewBox } from "../svg/viewbox/value.js";
3
+ import { stringifyIconViewBox } from "../svg/viewbox/value.js";
4
4
  import { createFactoryImports } from "./helpers/imports/create.js";
5
5
  import { generateCSSFilesForComponent } from "./helpers/css/generate.js";
6
6
  import { stringifyFactoryImports } from "./helpers/imports/stringify.js";
7
- import { getUsedFactoryProps } from "./helpers/props/ts.js";
8
- import { addVueComponentTypes } from "./helpers/vue/types.js";
9
7
  import { addSizeFunctionAsset } from "./helpers/functions/size.js";
10
- import { stringifyFactoryPropsAsJSON } from "./helpers/props/object.js";
11
8
  import { makeSquareViewBox } from "../svg/viewbox/square.js";
9
+ import { getUsedFactoryProps } from "./helpers/props/ts.js";
10
+ import { minifyViewBox } from "../svg/viewbox/minify.js";
11
+ import { getViewBoxRatio } from "./helpers/content/ratio.js";
12
+ import { addVueComponentTypes } from "./helpers/ts/vue.js";
13
+ import { stringifyFactoryPropsAsJSON } from "./helpers/props/object.js";
12
14
 
13
15
  /**
14
16
  * Create functional Vue component code
@@ -21,13 +23,23 @@ function createVueFunctionalComponent(data, options) {
21
23
  const vueNamedImports = new Set(["defineComponent", "h"]);
22
24
  imports.named["vue"] = vueNamedImports;
23
25
  generateCSSFilesForComponent(data.icon, imports, assets, options);
26
+ let hasFixedSize = !!options.width && !!options.height;
27
+ const viewBox = data.viewBox;
28
+ const hasComputedViewbox = options.square && !hasFixedSize && viewBox.width !== viewBox.height;
29
+ const isStringViewBox = !hasFallback;
30
+ const hasComputedRatio = hasComputedViewbox && isStringViewBox;
31
+ if (!hasComputedViewbox && (options.width || options.height)) hasFixedSize = true;
24
32
  const componentCode = [];
25
- const sizeProps = getComponentSizeValues(options, data.viewBox);
26
33
  const props = {};
27
34
  if (!hasFallback) props.xmlns = "http://www.w3.org/2000/svg";
28
- const viewBox = data.viewBox;
29
- const isDynanicViewBox = !sizeProps && options.square && viewBox.width !== viewBox.height;
30
- if (sizeProps) {
35
+ const getViewBox = (viewBox$1) => isStringViewBox ? `'${stringifyIconViewBox(viewBox$1)}'` : JSON.stringify(minifyViewBox(viewBox$1));
36
+ if (hasComputedViewbox) componentCode.push(`const baseViewBox = ${getViewBox(viewBox)};`, `const squareViewBox = ${getViewBox(makeSquareViewBox(viewBox))};`, `const viewBox = computed(() => props.square ? squareViewBox : baseViewBox);`);
37
+ else componentCode.push(`const viewBox = ${getViewBox(viewBox)};`);
38
+ const ratioValue = getViewBoxRatio(viewBox);
39
+ if (hasComputedRatio) componentCode.push(`const ratio = computed(() => props.square ? 1 : ${ratioValue});`);
40
+ if (hasFixedSize) {
41
+ const sizeProps = getComponentSizeValues(options, data.viewBox);
42
+ if (!sizeProps) throw new Error("Fixed size expected, but could not be determined");
31
43
  props.width = sizeProps.width;
32
44
  props.height = sizeProps.height;
33
45
  } else if (hasFallback) {
@@ -43,7 +55,7 @@ function createVueFunctionalComponent(data, options) {
43
55
  };
44
56
  } else {
45
57
  const getSizeProps = addSizeFunctionAsset(imports, assets, options);
46
- componentCode.push(`const size = computed(() => ${getSizeProps}(props.width, props.height, viewBox${isDynanicViewBox ? ".value" : ""}));`);
58
+ componentCode.push(`const size = computed(() => ${getSizeProps}(props.width, props.height, ${hasComputedRatio ? "ratio.value" : ratioValue}));`);
47
59
  vueNamedImports.add("computed");
48
60
  props.width = {
49
61
  type: "string",
@@ -57,21 +69,10 @@ function createVueFunctionalComponent(data, options) {
57
69
  };
58
70
  }
59
71
  if (options.square) props.square = { type: "boolean" };
60
- const getViewBox = (viewBox$1) => hasFallback ? JSON.stringify(viewBox$1) : `'${getIconViewBox(viewBox$1)}'`;
61
- const viewBoxValue = getViewBox(viewBox);
62
- if (isDynanicViewBox) {
63
- componentCode.unshift(`const baseViewBox = ${viewBoxValue};`, `const squareViewBox = ${getViewBox(makeSquareViewBox(viewBox))};`, `const viewBox = computed(() => props.square ? squareViewBox : baseViewBox);`);
64
- props.viewBox = {
65
- value: "viewBox",
66
- template: "viewBox: viewBox.value,"
67
- };
68
- } else {
69
- componentCode.unshift(`const viewBox = ${viewBoxValue};`);
70
- props.viewBox = {
71
- value: "viewBox",
72
- template: "viewBox,"
73
- };
74
- }
72
+ props.viewBox = {
73
+ value: "viewBox",
74
+ template: hasComputedViewbox ? "viewBox: viewBox.value," : "viewBox,"
75
+ };
75
76
  props[hasFallback ? "content" : "innerHTML"] = { value: stringifyFactoryIconContent(data.icon, options) };
76
77
  if (data.fallback) props.fallback = data.fallback;
77
78
  const types = addVueComponentTypes(data, options, assets, props);
@@ -1,14 +1,16 @@
1
1
  import { getComponentSizeValues } from "./helpers/content/size.js";
2
2
  import { stringifyFactoryIconContent } from "./helpers/content/stringify.js";
3
- import { getIconViewBox } from "../svg/viewbox/value.js";
3
+ import { stringifyIconViewBox } from "../svg/viewbox/value.js";
4
4
  import { createFactoryImports } from "./helpers/imports/create.js";
5
5
  import { generateCSSFilesForComponent } from "./helpers/css/generate.js";
6
6
  import { stringifyFactoryImports } from "./helpers/imports/stringify.js";
7
7
  import { stringifyFactoryProps } from "./helpers/props/stringify.js";
8
- import { getUsedFactoryProps, stringifyFactoryPropTypes } from "./helpers/props/ts.js";
9
- import { addVueComponentTypes } from "./helpers/vue/types.js";
10
8
  import { addSizeFunctionAsset } from "./helpers/functions/size.js";
11
9
  import { makeSquareViewBox } from "../svg/viewbox/square.js";
10
+ import { getUsedFactoryProps, stringifyFactoryPropTypes } from "./helpers/props/ts.js";
11
+ import { minifyViewBox } from "../svg/viewbox/minify.js";
12
+ import { getViewBoxRatio } from "./helpers/content/ratio.js";
13
+ import { addVueComponentTypes } from "./helpers/ts/vue.js";
12
14
 
13
15
  /**
14
16
  * Create Vue component code
@@ -26,13 +28,23 @@ function createVueComponent(data, options) {
26
28
  ...options,
27
29
  styleInComponent
28
30
  });
31
+ let hasFixedSize = !!options.width && !!options.height;
32
+ const viewBox = data.viewBox;
33
+ const hasComputedViewbox = options.square && !hasFixedSize && viewBox.width !== viewBox.height;
34
+ const isStringViewBox = !hasFallback;
35
+ const hasComputedRatio = hasComputedViewbox && isStringViewBox;
36
+ if (!hasComputedViewbox && (options.width || options.height)) hasFixedSize = true;
29
37
  const componentCode = [];
30
- const sizeProps = getComponentSizeValues(options, data.viewBox);
31
38
  const props = {};
32
39
  if (!hasFallback) props.xmlns = "http://www.w3.org/2000/svg";
33
- const viewBox = data.viewBox;
34
- const isDynanicViewBox = !sizeProps && options.square && viewBox.width !== viewBox.height;
35
- if (sizeProps) {
40
+ const getViewBox = (viewBox$1) => isStringViewBox ? `'${stringifyIconViewBox(viewBox$1)}'` : JSON.stringify(minifyViewBox(viewBox$1));
41
+ if (hasComputedViewbox) componentCode.push(`const baseViewBox = ${getViewBox(viewBox)};`, `const squareViewBox = ${getViewBox(makeSquareViewBox(viewBox))};`, `const viewBox = computed(() => props.square ? squareViewBox : baseViewBox);`);
42
+ else componentCode.push(`const viewBox = ${getViewBox(viewBox)};`);
43
+ const ratioValue = getViewBoxRatio(viewBox);
44
+ if (hasComputedRatio) componentCode.push(`const ratio = computed(() => props.square ? 1 : ${ratioValue});`);
45
+ if (hasFixedSize) {
46
+ const sizeProps = getComponentSizeValues(options, data.viewBox);
47
+ if (!sizeProps) throw new Error("Fixed size expected, but could not be determined");
36
48
  props.width = sizeProps.width;
37
49
  props.height = sizeProps.height;
38
50
  } else if (hasFallback) {
@@ -48,7 +60,7 @@ function createVueComponent(data, options) {
48
60
  };
49
61
  } else {
50
62
  const getSizeProps = addSizeFunctionAsset(imports, assets, options);
51
- componentCode.push(`const size = computed(() => ${getSizeProps}(props.width, props.height, viewBox${isDynanicViewBox ? ".value" : ""}));`);
63
+ componentCode.push(`const size = computed(() => ${getSizeProps}(props.width, props.height, ${hasComputedRatio ? "ratio.value" : ratioValue}));`);
52
64
  vueNamedImports.add("computed");
53
65
  props.width = {
54
66
  type: "string",
@@ -62,10 +74,6 @@ function createVueComponent(data, options) {
62
74
  };
63
75
  }
64
76
  if (options.square) props.square = { type: "boolean" };
65
- const getViewBox = (viewBox$1) => hasFallback ? JSON.stringify(viewBox$1) : `'${getIconViewBox(viewBox$1)}'`;
66
- const viewBoxValue = getViewBox(viewBox);
67
- if (isDynanicViewBox) componentCode.unshift(`const baseViewBox = ${viewBoxValue};`, `const squareViewBox = ${getViewBox(makeSquareViewBox(viewBox))};`, `const viewBox = computed(() => props.square ? squareViewBox : baseViewBox);`);
68
- else componentCode.unshift(`const viewBox = ${viewBoxValue};`);
69
77
  props.viewBox = {
70
78
  value: "viewBox",
71
79
  template: ":viewBox=\"viewBox\""
@@ -77,9 +85,7 @@ function createVueComponent(data, options) {
77
85
  };
78
86
  const usedProps = getUsedFactoryProps(props);
79
87
  if (usedProps.length) {
80
- const tsCode = useTS ? `<{
81
- ${stringifyFactoryPropTypes(props)}
82
- }>` : "";
88
+ const tsCode = useTS ? `<{\n${stringifyFactoryPropTypes(props)}\n}>` : "";
83
89
  componentCode.unshift(`const props = defineProps${tsCode}(${JSON.stringify(usedProps)});\n`);
84
90
  }
85
91
  const template = `<template><${hasFallback ? "Icon" : "svg"} ${stringifyFactoryProps(props, ":{prop}=\"{value}\"")} /></template>`;
@@ -2,5 +2,5 @@ import { IconViewBox } from "./types.js";
2
2
  /**
3
3
  * Convert IconViewBox to string
4
4
  */
5
- declare function getIconViewBox(viewBox: IconViewBox): string;
6
- export { getIconViewBox };
5
+ declare function stringifyIconViewBox(viewBox: IconViewBox): string;
6
+ export { stringifyIconViewBox };
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Convert IconViewBox to string
3
3
  */
4
- function getIconViewBox(viewBox) {
4
+ function stringifyIconViewBox(viewBox) {
5
5
  return `${viewBox.left ?? 0} ${viewBox.top ?? 0} ${viewBox.width} ${viewBox.height}`;
6
6
  }
7
7
 
8
- export { getIconViewBox };
8
+ export { stringifyIconViewBox };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Common functions for working with SVG used by various packages.",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "0.1.6",
6
+ "version": "0.1.8",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/cyberalien/svg-utils/issues",
9
9
  "homepage": "https://cyberalien.dev/",
@@ -1,27 +0,0 @@
1
- import { getGeneratedComponentTypesFilename } from "../filenames/types.js";
2
- import { stringifyFactoryPropTypes } from "../props/ts.js";
3
-
4
- /**
5
- * Add Vue component types
6
- */
7
- function addVueComponentTypes(data, options, assets, props) {
8
- const content = `import { DefineSetupFnComponent, PublicProps } from 'vue';
9
-
10
- interface IconProps {
11
- ${stringifyFactoryPropTypes(props)}
12
- }
13
-
14
- declare const Component: DefineSetupFnComponent<IconProps, {}, {}, IconProps & {}, PublicProps>;
15
-
16
- export { type IconProps };
17
- export default Component;
18
- `;
19
- const filename = getGeneratedComponentTypesFilename(data, content, options);
20
- assets.push({
21
- ...filename,
22
- content
23
- });
24
- return filename.filename;
25
- }
26
-
27
- export { addVueComponentTypes };