@cypress-design/vue-icon 0.4.1 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @cypress-design/vue-icon
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`25c6260`](https://github.com/cypress-io/cypress-design/commit/25c62605be573dafafff090b47fb80091b35aea4)]:
8
+ - @cypress-design/icon-registry@0.6.0
9
+
10
+ ## 0.5.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#51](https://github.com/cypress-io/cypress-design/pull/51) [`ccd8f9a`](https://github.com/cypress-io/cypress-design/commit/ccd8f9a8feb624c0a52deaa9754c76969f43fc1e) Thanks [@elevatebart](https://github.com/elevatebart)! - in the build asset, add a comment containing all used windicss classes in the component
15
+
16
+ ### Patch Changes
17
+
18
+ - [#56](https://github.com/cypress-io/cypress-design/pull/56) [`0866c65`](https://github.com/cypress-io/cypress-design/commit/0866c654f24c36951c98468d789462748606b428) Thanks [@elevatebart](https://github.com/elevatebart)! - fix: avoid using `delete` to avoid memory leaks
19
+
20
+ * [#52](https://github.com/cypress-io/cypress-design/pull/52) [`43b53eb`](https://github.com/cypress-io/cypress-design/commit/43b53eb6bd10111629239a87374cfcc894eda0e3) Thanks [@mapsandapps](https://github.com/mapsandapps)! - New icons for statuses
21
+
22
+ * Updated dependencies [[`31aaa18`](https://github.com/cypress-io/cypress-design/commit/31aaa182c8cd415f2884289144f504183e5ab418), [`0866c65`](https://github.com/cypress-io/cypress-design/commit/0866c654f24c36951c98468d789462748606b428), [`43b53eb`](https://github.com/cypress-io/cypress-design/commit/43b53eb6bd10111629239a87374cfcc894eda0e3)]:
23
+ - @cypress-design/icon-registry@0.5.0
24
+
25
+ ## 0.4.2
26
+
27
+ ### Patch Changes
28
+
29
+ - [`e3eb9c7`](https://github.com/cypress-io/cypress-design/commit/e3eb9c7fee2d7a6e0a773e85ed4b73be04d83587) Thanks [@elevatebart](https://github.com/elevatebart)! - downgrade typescript to 4.4 for compat with app
30
+
31
+ - Updated dependencies [[`e3eb9c7`](https://github.com/cypress-io/cypress-design/commit/e3eb9c7fee2d7a6e0a773e85ed4b73be04d83587)]:
32
+ - @cypress-design/icon-registry@0.4.2
33
+
3
34
  ## 0.4.1
4
35
 
5
36
  ### Patch Changes
package/Icon.ts CHANGED
@@ -1,43 +1,11 @@
1
- import {
2
- type IconProps,
3
- type OpenIconProps,
4
- compileIcon,
5
- } from '@cypress-design/icon-registry'
6
- import { h, type SVGAttributes } from 'vue'
1
+ import { compileIcon } from '@cypress-design/icon-registry'
2
+ import type { IconProps } from '@cypress-design/icon-registry'
3
+ import { defineComponent, h } from 'vue'
4
+ import type { SVGAttributes } from 'vue'
5
+ import { compileVueIconProperties } from './compileProperties'
7
6
 
8
- export default (props: IconProps & Omit<SVGAttributes, 'name'>) => {
9
- return h('svg', compileVueIconProperties(compileIcon(props)))
10
- }
11
-
12
- export const compileVueIconProperties = ({
13
- body,
14
- compiledClasses,
15
- size,
16
- class: className,
17
- interactiveColorsOnGroup,
18
- ...attributes
19
- }: Omit<OpenIconProps, 'name'> &
20
- SVGAttributes & {
21
- body: string
22
- compiledClasses: string[]
23
- size: string
24
- interactiveColorsOnGroup?: boolean
25
- }) => {
26
- Object.keys(attributes).forEach((key) => {
27
- if (key.toLowerCase().endsWith('color')) {
28
- // @ts-ignore
29
- delete attributes[key]
30
- }
31
- })
32
- const componentProps: any = {
33
- width: size,
34
- height: size,
35
- fill: 'none',
36
- innerHTML: body,
37
- ...attributes, // add all standard attributes back to the svg tag
38
- }
39
- if (compiledClasses.length) {
40
- componentProps.class = compiledClasses.join(' ')
7
+ export default defineComponent(
8
+ (props: IconProps & Omit<SVGAttributes, 'name'>) => {
9
+ return h('svg', compileVueIconProperties(compileIcon(props)))
41
10
  }
42
- return componentProps
43
- }
11
+ )
@@ -0,0 +1,41 @@
1
+ import type { OpenIconProps } from '@cypress-design/icon-registry'
2
+ import { ICON_COLOR_PROP_NAMES } from '@cypress-design/icon-registry'
3
+ import type { SVGAttributes } from 'vue'
4
+
5
+ export const compileVueIconProperties = ({
6
+ body,
7
+ compiledClasses,
8
+ size,
9
+ class: className,
10
+ interactiveColorsOnGroup,
11
+ ...attributes
12
+ }: Omit<OpenIconProps, 'name'> &
13
+ SVGAttributes & {
14
+ body: string
15
+ compiledClasses: string[]
16
+ size: string
17
+ interactiveColorsOnGroup?: boolean
18
+ }) => {
19
+ const filteredAttributes = Object.keys(attributes).reduce(
20
+ (newAttributes, attrName) => {
21
+ if (!ICON_COLOR_PROP_NAMES.includes(attrName)) {
22
+ newAttributes[attrName] =
23
+ attributes[attrName as keyof typeof attributes]
24
+ }
25
+ return newAttributes
26
+ },
27
+ {} as Record<string, any>
28
+ )
29
+
30
+ const componentProps: any = {
31
+ width: size,
32
+ height: size,
33
+ fill: 'none',
34
+ innerHTML: body,
35
+ ...filteredAttributes, // add all standard attributes back to the svg tag
36
+ }
37
+ if (compiledClasses.length) {
38
+ componentProps.class = compiledClasses.join(' ')
39
+ }
40
+ return componentProps
41
+ }