vectify 2.0.5 → 2.1.1

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 (50) hide show
  1. package/README.md +12 -13
  2. package/README.zh-CN.md +12 -13
  3. package/dist/{chunk-CIKTK6HI.mjs → chunk-FS34P27H.mjs} +8 -0
  4. package/dist/{chunk-GY4VNET5.mjs → chunk-QYE23M3E.mjs} +625 -65
  5. package/dist/cli.js +676 -117
  6. package/dist/cli.mjs +3 -3
  7. package/dist/{helpers-UPZEBRGK.mjs → helpers-ZOR3OD66.mjs} +1 -1
  8. package/dist/index.d.mts +33 -2
  9. package/dist/index.d.ts +33 -2
  10. package/dist/index.js +669 -110
  11. package/dist/index.mjs +2 -2
  12. package/dist/templates/angular/component.ts.hbs +11 -2
  13. package/dist/templates/angular/createIcon.ts.hbs +11 -2
  14. package/dist/templates/astro/component.astro.hbs +12 -2
  15. package/dist/templates/astro/createIcon.astro.hbs +12 -2
  16. package/dist/templates/lit/component.js.hbs +1 -0
  17. package/dist/templates/lit/component.ts.hbs +1 -0
  18. package/dist/templates/lit/createIcon.js.hbs +12 -2
  19. package/dist/templates/lit/createIcon.ts.hbs +12 -2
  20. package/dist/templates/preact/component.jsx.hbs +1 -1
  21. package/dist/templates/preact/component.tsx.hbs +1 -1
  22. package/dist/templates/preact/createIcon.jsx.hbs +12 -3
  23. package/dist/templates/preact/createIcon.tsx.hbs +13 -3
  24. package/dist/templates/qwik/component.jsx.hbs +1 -1
  25. package/dist/templates/qwik/component.tsx.hbs +1 -1
  26. package/dist/templates/qwik/createIcon.jsx.hbs +12 -3
  27. package/dist/templates/qwik/createIcon.tsx.hbs +13 -3
  28. package/dist/templates/react/component.jsx.hbs +1 -1
  29. package/dist/templates/react/component.tsx.hbs +1 -1
  30. package/dist/templates/react/createIcon.jsx.hbs +12 -3
  31. package/dist/templates/react/createIcon.tsx.hbs +13 -3
  32. package/dist/templates/solid/component.tsx.hbs +1 -1
  33. package/dist/templates/solid/createIcon.jsx.hbs +13 -3
  34. package/dist/templates/solid/createIcon.tsx.hbs +14 -3
  35. package/dist/templates/svelte/component.js.svelte.hbs +4 -1
  36. package/dist/templates/svelte/component.ts.svelte.hbs +4 -1
  37. package/dist/templates/svelte/icon.js.svelte.hbs +23 -2
  38. package/dist/templates/svelte/icon.ts.svelte.hbs +23 -2
  39. package/dist/templates/vanilla/component.ts.hbs +1 -1
  40. package/dist/templates/vanilla/createIcon.js.hbs +12 -3
  41. package/dist/templates/vanilla/createIcon.ts.hbs +13 -3
  42. package/dist/templates/vue/component.js.vue.hbs +5 -2
  43. package/dist/templates/vue/component.ts.vue.hbs +5 -2
  44. package/dist/templates/vue/icon.js.vue.hbs +26 -2
  45. package/dist/templates/vue/icon.ts.vue.hbs +26 -2
  46. package/dist/templates/vue2/component.js.vue.hbs +4 -2
  47. package/dist/templates/vue2/component.ts.vue.hbs +5 -2
  48. package/dist/templates/vue2/icon.js.vue.hbs +25 -2
  49. package/dist/templates/vue2/icon.ts.vue.hbs +25 -2
  50. package/package.json +1 -1
@@ -7,12 +7,13 @@ export interface CreateIconProps {
7
7
  strokeWidth?: number | string
8
8
  class?: string
9
9
  title?: string
10
+ viewBox?: string
10
11
  'aria-label'?: string
11
12
  'aria-hidden'?: boolean | 'true' | 'false'
12
13
  [key: string]: any
13
14
  }
14
15
 
15
- export function createIcon(name: string, iconNode: IconNode[], keepColors = false) {
16
+ export function createIcon(name: string, iconNode: IconNode[], keepColors = false, defaultViewBox = '0 0 24 24') {
16
17
  return (props: CreateIconProps): JSX.Element => {
17
18
  const [local, others] = splitProps(props, [
18
19
  'size',
@@ -20,6 +21,7 @@ export function createIcon(name: string, iconNode: IconNode[], keepColors = fals
20
21
  'strokeWidth',
21
22
  'class',
22
23
  'title',
24
+ 'viewBox',
23
25
  'aria-label',
24
26
  'aria-hidden'
25
27
  ])
@@ -27,6 +29,7 @@ export function createIcon(name: string, iconNode: IconNode[], keepColors = fals
27
29
  const size = () => local.size ?? 24
28
30
  const color = () => local.color ?? 'currentColor'
29
31
  const strokeWidth = () => local.strokeWidth ?? 2
32
+ const viewBox = () => local.viewBox ?? defaultViewBox
30
33
 
31
34
  // Determine if icon should be hidden from screen readers
32
35
  const shouldHide = () => local['aria-hidden'] !== undefined
@@ -41,7 +44,15 @@ export function createIcon(name: string, iconNode: IconNode[], keepColors = fals
41
44
  let cleanedAttrs: Record<string, any>
42
45
 
43
46
  if (keepColors) {
44
- cleanedAttrs = attrs
47
+ // Keep original colors, but use currentColor for elements without fill/stroke
48
+ cleanedAttrs = { ...attrs }
49
+ const hasFill = 'fill' in attrs
50
+ const hasStroke = 'stroke' in attrs
51
+
52
+ // If element has neither fill nor stroke, apply currentColor as fill
53
+ if (!hasFill && !hasStroke) {
54
+ cleanedAttrs.fill = color()
55
+ }
45
56
  } else {
46
57
  // Track color attributes to determine icon type
47
58
  let hasFill = false
@@ -124,7 +135,7 @@ export function createIcon(name: string, iconNode: IconNode[], keepColors = fals
124
135
  <svg
125
136
  width={size()}
126
137
  height={size()}
127
- viewBox="0 0 24 24"
138
+ viewBox={viewBox()}
128
139
  aria-hidden={shouldHide()}
129
140
  aria-label={local['aria-label']}
130
141
  role={local.title || local['aria-label'] ? 'img' : undefined}
@@ -4,6 +4,9 @@
4
4
  const iconNode = [
5
5
  {{{formattedNodes}}}
6
6
  ]
7
+
8
+ const keepColors = {{keepColors}}
9
+ const viewBox = '{{viewBox}}'
7
10
  </script>
8
11
 
9
- <Icon {iconNode} {...$$restProps} />
12
+ <Icon {iconNode} {keepColors} {viewBox} {...$$restProps} />
@@ -5,6 +5,9 @@
5
5
  const iconNode: IconNode[] = [
6
6
  {{{formattedNodes}}}
7
7
  ]
8
+
9
+ const keepColors = {{keepColors}}
10
+ const viewBox = '{{viewBox}}'
8
11
  </script>
9
12
 
10
- <Icon {iconNode} {...$$restProps} />
13
+ <Icon {iconNode} {keepColors} {viewBox} {...$$restProps} />
@@ -10,6 +10,7 @@
10
10
  export let ariaLabel = ''
11
11
  export let ariaHidden = undefined
12
12
  export let keepColors = false
13
+ export let viewBox = '0 0 24 24'
13
14
 
14
15
  let svgElement
15
16
 
@@ -20,7 +21,27 @@
20
21
  $: shouldHide = ariaHidden !== undefined ? ariaHidden : (!title && !ariaLabel)
21
22
 
22
23
  // Clean icon node to apply color
23
- $: cleanedIconNode = keepColors ? iconNode : cleanIconNodes(iconNode, color, strokeWidth)
24
+ $: cleanedIconNode = keepColors ? cleanIconNodesKeepColors(iconNode, color) : cleanIconNodes(iconNode, color, strokeWidth)
25
+
26
+ function cleanIconNodesKeepColors(nodes, color) {
27
+ return nodes.map(node => {
28
+ const [type, attrs, children] = node
29
+
30
+ const cleanedAttrs = { ...attrs }
31
+
32
+ // For elements without fill or stroke, use currentColor
33
+ const hasFill = 'fill' in attrs
34
+ const hasStroke = 'stroke' in attrs
35
+
36
+ if (!hasFill && !hasStroke) {
37
+ cleanedAttrs.fill = color
38
+ }
39
+
40
+ const cleanedChildren = children ? cleanIconNodesKeepColors(children, color) : undefined
41
+
42
+ return cleanedChildren ? [type, cleanedAttrs, cleanedChildren] : [type, cleanedAttrs]
43
+ })
44
+ }
24
45
 
25
46
  function cleanIconNodes(nodes, color, strokeWidth) {
26
47
  return nodes.map(node => {
@@ -110,7 +131,7 @@
110
131
  bind:this={svgElement}
111
132
  width={size}
112
133
  height={size}
113
- viewBox="0 0 24 24"
134
+ viewBox={viewBox}
114
135
  aria-hidden={shouldHide}
115
136
  aria-label={ariaLabel || undefined}
116
137
  role={title || ariaLabel ? 'img' : undefined}
@@ -11,6 +11,7 @@
11
11
  export let ariaLabel: string = ''
12
12
  export let ariaHidden: boolean | 'true' | 'false' | undefined = undefined
13
13
  export let keepColors: boolean = false
14
+ export let viewBox: string = '0 0 24 24'
14
15
 
15
16
  let svgElement: SVGSVGElement
16
17
 
@@ -21,7 +22,27 @@
21
22
  $: shouldHide = ariaHidden !== undefined ? ariaHidden : (!title && !ariaLabel)
22
23
 
23
24
  // Clean icon node to apply color
24
- $: cleanedIconNode = keepColors ? iconNode : cleanIconNodes(iconNode, color, strokeWidth)
25
+ $: cleanedIconNode = keepColors ? cleanIconNodesKeepColors(iconNode, color) : cleanIconNodes(iconNode, color, strokeWidth)
26
+
27
+ function cleanIconNodesKeepColors(nodes: IconNode[], color: string): IconNode[] {
28
+ return nodes.map(node => {
29
+ const [type, attrs, children] = node
30
+
31
+ const cleanedAttrs: Record<string, any> = { ...attrs }
32
+
33
+ // For elements without fill or stroke, use currentColor
34
+ const hasFill = 'fill' in attrs
35
+ const hasStroke = 'stroke' in attrs
36
+
37
+ if (!hasFill && !hasStroke) {
38
+ cleanedAttrs.fill = color
39
+ }
40
+
41
+ const cleanedChildren = children ? cleanIconNodesKeepColors(children, color) : undefined
42
+
43
+ return cleanedChildren ? [type, cleanedAttrs, cleanedChildren] : [type, cleanedAttrs]
44
+ }) as IconNode[]
45
+ }
25
46
 
26
47
  function cleanIconNodes(nodes: IconNode[], color: string, strokeWidth: number | string): IconNode[] {
27
48
  return nodes.map(node => {
@@ -111,7 +132,7 @@
111
132
  bind:this={svgElement}
112
133
  width={size}
113
134
  height={size}
114
- viewBox="0 0 24 24"
135
+ viewBox={viewBox}
115
136
  aria-hidden={shouldHide}
116
137
  aria-label={ariaLabel || undefined}
117
138
  role={title || ariaLabel ? 'img' : undefined}
@@ -5,4 +5,4 @@ export const iconNode: IconNode[] = [
5
5
  {{{formattedNodes}}}
6
6
  ]
7
7
 
8
- export const {{componentName}} = createIcon('{{componentName}}', iconNode, {{keepColors}})
8
+ export const {{componentName}} = createIcon('{{componentName}}', iconNode, {{keepColors}}, '{{viewBox}}')
@@ -1,4 +1,4 @@
1
- export function createIcon(name, iconNode, keepColors = false) {
1
+ export function createIcon(name, iconNode, keepColors = false, defaultViewBox = '0 0 24 24') {
2
2
  return (options = {}) => {
3
3
  const {
4
4
  size = 24,
@@ -6,6 +6,7 @@ export function createIcon(name, iconNode, keepColors = false) {
6
6
  strokeWidth = 2,
7
7
  className = '',
8
8
  title,
9
+ viewBox = defaultViewBox,
9
10
  ariaLabel,
10
11
  ariaHidden,
11
12
  ...attrs
@@ -14,7 +15,7 @@ export function createIcon(name, iconNode, keepColors = false) {
14
15
  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
15
16
  svg.setAttribute('width', String(size))
16
17
  svg.setAttribute('height', String(size))
17
- svg.setAttribute('viewBox', '0 0 24 24')
18
+ svg.setAttribute('viewBox', viewBox)
18
19
  svg.setAttribute('class', className ? `vectify-icon ${className}` : 'vectify-icon')
19
20
 
20
21
  // Accessibility
@@ -49,7 +50,15 @@ export function createIcon(name, iconNode, keepColors = false) {
49
50
  let cleanedAttrs
50
51
 
51
52
  if (keepColors) {
52
- cleanedAttrs = nodeAttrs
53
+ // Keep original colors, but use currentColor for elements without fill/stroke
54
+ cleanedAttrs = { ...nodeAttrs }
55
+ const hasFill = 'fill' in nodeAttrs
56
+ const hasStroke = 'stroke' in nodeAttrs
57
+
58
+ // If element has neither fill nor stroke, apply currentColor as fill
59
+ if (!hasFill && !hasStroke) {
60
+ cleanedAttrs.fill = color
61
+ }
53
62
  } else {
54
63
  // Track color attributes
55
64
  let hasFill = false
@@ -4,6 +4,7 @@ export interface IconOptions {
4
4
  strokeWidth?: number | string
5
5
  className?: string
6
6
  title?: string
7
+ viewBox?: string
7
8
  ariaLabel?: string
8
9
  ariaHidden?: boolean
9
10
  [key: string]: any
@@ -11,7 +12,7 @@ export interface IconOptions {
11
12
 
12
13
  export type IconNode = [string, Record<string, any>, IconNode[]?]
13
14
 
14
- export function createIcon(name: string, iconNode: IconNode[], keepColors = false) {
15
+ export function createIcon(name: string, iconNode: IconNode[], keepColors = false, defaultViewBox = '0 0 24 24') {
15
16
  return (options: IconOptions = {}): SVGSVGElement => {
16
17
  const {
17
18
  size = 24,
@@ -19,6 +20,7 @@ export function createIcon(name: string, iconNode: IconNode[], keepColors = fals
19
20
  strokeWidth = 2,
20
21
  className = '',
21
22
  title,
23
+ viewBox = defaultViewBox,
22
24
  ariaLabel,
23
25
  ariaHidden,
24
26
  ...attrs
@@ -27,7 +29,7 @@ export function createIcon(name: string, iconNode: IconNode[], keepColors = fals
27
29
  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
28
30
  svg.setAttribute('width', String(size))
29
31
  svg.setAttribute('height', String(size))
30
- svg.setAttribute('viewBox', '0 0 24 24')
32
+ svg.setAttribute('viewBox', viewBox)
31
33
  svg.setAttribute('class', className ? `vectify-icon ${className}` : 'vectify-icon')
32
34
 
33
35
  // Accessibility
@@ -62,7 +64,15 @@ export function createIcon(name: string, iconNode: IconNode[], keepColors = fals
62
64
  let cleanedAttrs: Record<string, any>
63
65
 
64
66
  if (keepColors) {
65
- cleanedAttrs = nodeAttrs
67
+ // Keep original colors, but use currentColor for elements without fill/stroke
68
+ cleanedAttrs = { ...nodeAttrs }
69
+ const hasFill = 'fill' in nodeAttrs
70
+ const hasStroke = 'stroke' in nodeAttrs
71
+
72
+ // If element has neither fill nor stroke, apply currentColor as fill
73
+ if (!hasFill && !hasStroke) {
74
+ cleanedAttrs.fill = color
75
+ }
66
76
  } else {
67
77
  // Track color attributes
68
78
  let hasFill = false
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Icon :iconNode="iconNode" v-bind="$attrs" />
2
+ <Icon :iconNode="iconNode" :keepColors="keepColors" :viewBox="viewBox" v-bind="$attrs" />
3
3
  </template>
4
4
 
5
5
  <script>
@@ -15,7 +15,10 @@ export default defineComponent({
15
15
  {{{formattedNodes}}}
16
16
  ]
17
17
 
18
- return { iconNode }
18
+ const keepColors = {{keepColors}}
19
+ const viewBox = '{{viewBox}}'
20
+
21
+ return { iconNode, keepColors, viewBox }
19
22
  }
20
23
  })
21
24
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Icon :iconNode="iconNode" v-bind="$attrs" />
2
+ <Icon :iconNode="iconNode" :keepColors="keepColors" :viewBox="viewBox" v-bind="$attrs" />
3
3
  </template>
4
4
 
5
5
  <script lang="ts">
@@ -16,7 +16,10 @@ export default defineComponent({
16
16
  {{{formattedNodes}}}
17
17
  ]
18
18
 
19
- return { iconNode }
19
+ const keepColors = {{keepColors}}
20
+ const viewBox = '{{viewBox}}'
21
+
22
+ return { iconNode, keepColors, viewBox }
20
23
  }
21
24
  })
22
25
  </script>
@@ -2,7 +2,7 @@
2
2
  <svg
3
3
  :width="size"
4
4
  :height="size"
5
- viewBox="0 0 24 24"
5
+ :viewBox="viewBox"
6
6
  :aria-hidden="shouldHide"
7
7
  :aria-label="ariaLabel"
8
8
  :role="title || ariaLabel ? 'img' : undefined"
@@ -60,6 +60,10 @@ export default defineComponent({
60
60
  keepColors: {
61
61
  type: Boolean,
62
62
  default: false
63
+ },
64
+ viewBox: {
65
+ type: String,
66
+ default: '0 0 24 24'
63
67
  }
64
68
  },
65
69
  setup(props) {
@@ -76,12 +80,32 @@ export default defineComponent({
76
80
  // Clean icon node to apply color
77
81
  const cleanedIconNode = computed(() => {
78
82
  if (props.keepColors) {
79
- return props.iconNode
83
+ return cleanIconNodesKeepColors(props.iconNode, props.color)
80
84
  }
81
85
 
82
86
  return cleanIconNodes(props.iconNode, props.color, props.strokeWidth)
83
87
  })
84
88
 
89
+ function cleanIconNodesKeepColors(nodes, color) {
90
+ return nodes.map(node => {
91
+ const [type, attrs, children] = node
92
+
93
+ const cleanedAttrs = { ...attrs }
94
+
95
+ // For elements without fill or stroke, use currentColor
96
+ const hasFill = 'fill' in attrs
97
+ const hasStroke = 'stroke' in attrs
98
+
99
+ if (!hasFill && !hasStroke) {
100
+ cleanedAttrs.fill = color
101
+ }
102
+
103
+ const cleanedChildren = children ? cleanIconNodesKeepColors(children, color) : undefined
104
+
105
+ return [type, cleanedAttrs, cleanedChildren]
106
+ })
107
+ }
108
+
85
109
  function cleanIconNodes(nodes, color, strokeWidth) {
86
110
  return nodes.map(node => {
87
111
  const [type, attrs, children] = node
@@ -2,7 +2,7 @@
2
2
  <svg
3
3
  :width="size"
4
4
  :height="size"
5
- viewBox="0 0 24 24"
5
+ :viewBox="viewBox"
6
6
  :aria-hidden="shouldHide"
7
7
  :aria-label="ariaLabel"
8
8
  :role="title || ariaLabel ? 'img' : undefined"
@@ -62,6 +62,10 @@ export default defineComponent({
62
62
  keepColors: {
63
63
  type: Boolean,
64
64
  default: false
65
+ },
66
+ viewBox: {
67
+ type: String,
68
+ default: '0 0 24 24'
65
69
  }
66
70
  },
67
71
  setup(props) {
@@ -78,12 +82,32 @@ export default defineComponent({
78
82
  // Clean icon node to apply color
79
83
  const cleanedIconNode = computed(() => {
80
84
  if (props.keepColors) {
81
- return props.iconNode
85
+ return cleanIconNodesKeepColors(props.iconNode, props.color)
82
86
  }
83
87
 
84
88
  return cleanIconNodes(props.iconNode, props.color, props.strokeWidth)
85
89
  })
86
90
 
91
+ function cleanIconNodesKeepColors(nodes: IconNode[], color: string): IconNode[] {
92
+ return nodes.map(node => {
93
+ const [type, attrs, children] = node
94
+
95
+ const cleanedAttrs: Record<string, any> = { ...attrs }
96
+
97
+ // For elements without fill or stroke, use currentColor
98
+ const hasFill = 'fill' in attrs
99
+ const hasStroke = 'stroke' in attrs
100
+
101
+ if (!hasFill && !hasStroke) {
102
+ cleanedAttrs.fill = color
103
+ }
104
+
105
+ const cleanedChildren = children ? cleanIconNodesKeepColors(children, color) : undefined
106
+
107
+ return [type, cleanedAttrs, cleanedChildren] as IconNode
108
+ })
109
+ }
110
+
87
111
  function cleanIconNodes(nodes: IconNode[], color: string, strokeWidth: number | string): IconNode[] {
88
112
  return nodes.map(node => {
89
113
  const [type, attrs, children] = node
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Icon :iconNode="iconNode" v-bind="$attrs" />
2
+ <Icon :iconNode="iconNode" :keepColors="keepColors" :viewBox="viewBox" v-bind="$attrs" />
3
3
  </template>
4
4
 
5
5
  <script>
@@ -13,7 +13,9 @@ export default {
13
13
  return {
14
14
  iconNode: [
15
15
  {{{formattedNodes}}}
16
- ]
16
+ ],
17
+ keepColors: {{keepColors}},
18
+ viewBox: '{{viewBox}}'
17
19
  }
18
20
  }
19
21
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Icon :iconNode="iconNode" v-bind="$attrs" />
2
+ <Icon :iconNode="iconNode" :keepColors="keepColors" :viewBox="viewBox" v-bind="$attrs" />
3
3
  </template>
4
4
 
5
5
  <script lang="ts">
@@ -16,7 +16,10 @@ export default Vue.extend({
16
16
  {{{formattedNodes}}}
17
17
  ]
18
18
 
19
- return { iconNode }
19
+ const keepColors = {{keepColors}}
20
+ const viewBox = '{{viewBox}}'
21
+
22
+ return { iconNode, keepColors, viewBox }
20
23
  }
21
24
  })
22
25
  </script>
@@ -38,6 +38,10 @@ export default {
38
38
  keepColors: {
39
39
  type: Boolean,
40
40
  default: false
41
+ },
42
+ viewBox: {
43
+ type: String,
44
+ default: '0 0 24 24'
41
45
  }
42
46
  },
43
47
  computed: {
@@ -49,12 +53,31 @@ export default {
49
53
  },
50
54
  cleanedIconNode() {
51
55
  if (this.keepColors) {
52
- return this.iconNode
56
+ return this.cleanIconNodesKeepColors(this.iconNode, this.color)
53
57
  }
54
58
  return this.cleanIconNodes(this.iconNode, this.color, this.strokeWidth)
55
59
  }
56
60
  },
57
61
  methods: {
62
+ cleanIconNodesKeepColors(nodes, color) {
63
+ return nodes.map(node => {
64
+ const [type, attrs, children] = node
65
+
66
+ const cleanedAttrs = { ...attrs }
67
+
68
+ // For elements without fill or stroke, use currentColor
69
+ const hasFill = 'fill' in attrs
70
+ const hasStroke = 'stroke' in attrs
71
+
72
+ if (!hasFill && !hasStroke) {
73
+ cleanedAttrs.fill = color
74
+ }
75
+
76
+ const cleanedChildren = children ? this.cleanIconNodesKeepColors(children, color) : undefined
77
+
78
+ return [type, cleanedAttrs, cleanedChildren]
79
+ })
80
+ },
58
81
  cleanIconNodes(nodes, color, strokeWidth) {
59
82
  return nodes.map(node => {
60
83
  const [type, attrs, children] = node
@@ -126,7 +149,7 @@ export default {
126
149
  attrs: {
127
150
  width: this.size,
128
151
  height: this.size,
129
- viewBox: '0 0 24 24',
152
+ viewBox: this.viewBox,
130
153
  'aria-hidden': this.shouldHide,
131
154
  'aria-label': this.ariaLabel,
132
155
  role: this.title || this.ariaLabel ? 'img' : undefined,
@@ -41,6 +41,10 @@ export default Vue.extend({
41
41
  keepColors: {
42
42
  type: Boolean,
43
43
  default: false
44
+ },
45
+ viewBox: {
46
+ type: String,
47
+ default: '0 0 24 24'
44
48
  }
45
49
  },
46
50
  computed: {
@@ -52,12 +56,31 @@ export default Vue.extend({
52
56
  },
53
57
  cleanedIconNode(): IconNode[] {
54
58
  if (this.keepColors) {
55
- return this.iconNode
59
+ return this.cleanIconNodesKeepColors(this.iconNode, this.color)
56
60
  }
57
61
  return this.cleanIconNodes(this.iconNode, this.color, this.strokeWidth)
58
62
  }
59
63
  },
60
64
  methods: {
65
+ cleanIconNodesKeepColors(nodes: IconNode[], color: string): IconNode[] {
66
+ return nodes.map(node => {
67
+ const [type, attrs, children] = node
68
+
69
+ const cleanedAttrs: Record<string, any> = { ...attrs }
70
+
71
+ // For elements without fill or stroke, use currentColor
72
+ const hasFill = 'fill' in attrs
73
+ const hasStroke = 'stroke' in attrs
74
+
75
+ if (!hasFill && !hasStroke) {
76
+ cleanedAttrs.fill = color
77
+ }
78
+
79
+ const cleanedChildren = children ? this.cleanIconNodesKeepColors(children, color) : undefined
80
+
81
+ return [type, cleanedAttrs, cleanedChildren] as IconNode
82
+ })
83
+ },
61
84
  cleanIconNodes(nodes: IconNode[], color: string, strokeWidth: number | string): IconNode[] {
62
85
  return nodes.map(node => {
63
86
  const [type, attrs, children] = node
@@ -129,7 +152,7 @@ export default Vue.extend({
129
152
  attrs: {
130
153
  width: this.size,
131
154
  height: this.size,
132
- viewBox: '0 0 24 24',
155
+ viewBox: this.viewBox,
133
156
  'aria-hidden': this.shouldHide,
134
157
  'aria-label': this.ariaLabel,
135
158
  role: this.title || this.ariaLabel ? 'img' : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vectify",
3
- "version": "2.0.5",
3
+ "version": "2.1.1",
4
4
  "packageManager": "pnpm@9.15.9",
5
5
  "description": "A powerful command-line tool to generate React, Vue, and Svelte icon components from SVG files",
6
6
  "author": "Xiaobing Zhu <hellozxb252@gmail.com>",