From 87db7145d516b31dc48d670880cb46d9eca6c537 Mon Sep 17 00:00:00 2001 From: nohack Date: Mon, 1 Jul 2024 17:05:38 +0800 Subject: [PATCH 1/3] Add types --- index.d.ts | 37 +++++++++++++++++++++++++++++++++++++ package.json | 3 +++ 2 files changed, 40 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..14a6b19 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,37 @@ +/// + +import { SvelteComponentTyped } from 'svelte'; + +declare module SvgIcon { + export interface SvgIconProps { + /** + * Required. An SVG path to render as an icon + */ + path: string; + /** + * This sets the size and viewbox to match the recommended size for the icon pack specified. + */ + type?: "mdi" | "simple-icons" | "default"; + /** + * The width and height of the SVG element + */ + size?: string | number; + /** + * The `viewBox` of the SVG element + */ + viewbox?: string; + /** + * One of "none", "horizontal", "vertical", or "both". Flips the icon in the specified direction(s). + */ + flip?: "none" | "horizontal" | "vertical" | "both"; + /** + * Rotates the icon by the specified value. Can be any valid [CSS angle](https://developer.mozilla.org/en-US/docs/Web/CSS/angle) value. + */ + rotate?: string | number; + } +} + +type Props = SvgIcon.SvgIconProps; + +declare class SvgIcon extends SvelteComponentTyped {} +export = SvgIcon; diff --git a/package.json b/package.json index fd4a8d4..8ca3e53 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "version": "0.1.1", "description": "Icon component for Svelte", "main": "lib/svg-icon.svelte", + "exports": { + "types": "./index.d.ts" + }, "directories": { "lib": "lib", "test": "tests" From 652f10ccb7353f65de0dcfade8e7c8a422b84c06 Mon Sep 17 00:00:00 2001 From: nohack Date: Mon, 1 Jul 2024 23:38:54 +0800 Subject: [PATCH 2/3] Fix types for restProps --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 14a6b19..752b72c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ /// -import { SvelteComponentTyped } from 'svelte'; +import { SvelteComponentTyped } from "svelte"; declare module SvgIcon { export interface SvgIconProps { @@ -31,7 +31,7 @@ declare module SvgIcon { } } -type Props = SvgIcon.SvgIconProps; +type Props = SvgIcon.SvgIconProps & { [attribute: string]: any }; declare class SvgIcon extends SvelteComponentTyped {} export = SvgIcon; From f39d1f3693fc8dc281ba1bb6c9612cc646104fa2 Mon Sep 17 00:00:00 2001 From: nohack Date: Tue, 2 Jul 2024 18:13:56 +0800 Subject: [PATCH 3/3] Fix failing to start --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ca3e53..eef11ce 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Icon component for Svelte", "main": "lib/svg-icon.svelte", "exports": { - "types": "./index.d.ts" + "types": "./index.d.ts", + "svelte": "./lib/svg-icon.svelte" }, "directories": { "lib": "lib",