@sparknest/ui-icons-vue 1.1.3 → 1.1.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +29 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparknest/ui-icons-vue",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Shared SVG-to-Vue icon source generator for Cedar and Maple",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.mjs CHANGED
@@ -17,7 +17,7 @@ function componentSource({ classPrefix, runtimeName, svg }) {
17
17
  }
18
18
 
19
19
  function componentIndex({ componentName, fileName }) {
20
- return `import type { App } from 'vue'\nimport _${componentName} from './${fileName}.vue'\n\nexport const ${componentName} = Object.assign(_${componentName}, {\n install(app: App) { app.component(_${componentName}.name, _${componentName}) },\n})\n`
20
+ return `import type { App } from 'vue'\nimport type { IconComponent } from '../_utils/icon-component'\nimport _${componentName} from './${fileName}.vue'\n\nexport const ${componentName}: IconComponent = Object.assign(_${componentName}, {\n install(app: App) { app.component(_${componentName}.name, _${componentName}) },\n})\n`
21
21
  }
22
22
 
23
23
  export async function generateVueIcons({
@@ -29,6 +29,33 @@ export async function generateVueIcons({
29
29
  check = false,
30
30
  }) {
31
31
  const expected = new Map()
32
+ expected.set('_utils/icon-component.ts', `import type { AllowedComponentProps, App, ComponentCustomProps, ComponentOptionsMixin, DefineComponent, VNodeProps } from 'vue'
33
+
34
+ export interface IconProps {
35
+ size?: string | number
36
+ color?: string
37
+ title?: string
38
+ strokeWidth?: number
39
+ strokeLinecap?: 'butt' | 'round' | 'square'
40
+ strokeLinejoin?: 'bevel' | 'inherit' | 'miter' | 'round'
41
+ rotate?: number
42
+ spin?: boolean
43
+ }
44
+
45
+ type IconEmits = { click: (event: MouseEvent) => any }
46
+ type IconDefaults = {
47
+ strokeWidth: number
48
+ strokeLinecap: NonNullable<IconProps['strokeLinecap']>
49
+ strokeLinejoin: NonNullable<IconProps['strokeLinejoin']>
50
+ }
51
+
52
+ export type IconComponent = DefineComponent<
53
+ IconProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, IconEmits, string,
54
+ VNodeProps & AllowedComponentProps & ComponentCustomProps,
55
+ Readonly<IconProps> & Readonly<{ onClick?: (event: MouseEvent) => any }>,
56
+ IconDefaults
57
+ > & { install(app: App): void }
58
+ `)
32
59
  expected.set('../style.css', `svg.${classPrefix}--spin {
33
60
  animation: ${classPrefix}-spin var(--${classPrefix.replace(/-svg-icon$/, '')}-icon-spin-duration, 1s) infinite linear;
34
61
  }
@@ -84,7 +111,7 @@ export async function generateVueIcons({
84
111
  expected.set(`${fileName}/index.ts`, componentIndex({ componentName, fileName }))
85
112
  }
86
113
 
87
- expected.set('index.ts', `export const iconNames = ${JSON.stringify(icons.map(({ fileName }) => fileName.slice(5)))} as const\n${icons.map(({ fileName, componentName }) => `export { ${componentName} } from './${fileName}'`).join('\n')}\n`)
114
+ expected.set('index.ts', `export type { IconComponent, IconProps } from './_utils/icon-component'\nexport const iconNames = ${JSON.stringify(icons.map(({ fileName }) => fileName.slice(5)))} as const\n${icons.map(({ fileName, componentName }) => `export { ${componentName} } from './${fileName}'`).join('\n')}\n`)
88
115
  expected.set('icons.json', `${JSON.stringify(icons, null, 2)}\n`)
89
116
  const stale = []
90
117
  for (const [target, content] of expected) {