@react-spectrum/parcel-transformer-s2-icon 1.0.1-nightly.5002 → 1.1.0
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/IconTransformer.js +25 -62
- package/package.json +12 -5
package/IconTransformer.js
CHANGED
|
@@ -38,30 +38,38 @@ module.exports = new Transformer({
|
|
|
38
38
|
onlyMatchedOnce: false,
|
|
39
39
|
removeMatchedSelectors: true
|
|
40
40
|
},
|
|
41
|
-
cleanupIDs: {
|
|
42
|
-
prefix
|
|
43
|
-
},
|
|
44
41
|
convertPathData: {
|
|
45
42
|
makeArcs: false
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'prefixIds',
|
|
49
|
+
params: {
|
|
50
|
+
prefix
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'removeAttrs',
|
|
55
|
+
params: {
|
|
56
|
+
attrs: ['data.*']
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
]
|
|
54
60
|
},
|
|
55
61
|
replaceAttrValues: {
|
|
56
|
-
'var(--iconPrimary, #222)': `var(--iconPrimary,
|
|
57
|
-
'var(--
|
|
62
|
+
'var(--iconPrimary, #222)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`,
|
|
63
|
+
'var(--iconPrimary, #222222)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`,
|
|
64
|
+
'var(--iconPrimary, #292929)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`,
|
|
65
|
+
'var(--spectrum-global-color-gray-800, #292929)': `var(--iconPrimary, light-dark(${tokens['gray-800'].sets.light.value}, ${tokens['gray-800'].sets.dark.value}))`
|
|
58
66
|
},
|
|
59
67
|
typescript: true,
|
|
68
|
+
ref: true,
|
|
60
69
|
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx']
|
|
61
70
|
})
|
|
62
|
-
).replace('export default
|
|
63
|
-
|
|
64
|
-
let newFile = template(asset, iconName, optimized);
|
|
71
|
+
).replace('export default ForwardRef;', '');
|
|
72
|
+
let newFile = template(asset, optimized);
|
|
65
73
|
return [{
|
|
66
74
|
type: 'tsx',
|
|
67
75
|
content: newFile,
|
|
@@ -72,61 +80,16 @@ module.exports = new Transformer({
|
|
|
72
80
|
}
|
|
73
81
|
});
|
|
74
82
|
|
|
75
|
-
function template(asset,
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
.replace(/^S2_(fill|lin)_(.+)_(.+_)?(\d+)$/, (m, name) => name[0].toUpperCase() + name.slice(1));
|
|
79
|
-
let iconRename = importName;
|
|
80
|
-
if (/^[0-9]/.test(importName)) {
|
|
81
|
-
iconRename = '_' + importName;
|
|
82
|
-
}
|
|
83
|
-
let context = asset.pipeline === 'illustration' ? 'IllustrationContext' : 'IconContext';
|
|
83
|
+
function template(asset, svg) {
|
|
84
|
+
let normalizedPath = asset.filePath.replaceAll('\\', '/');
|
|
85
|
+
let fn = asset.pipeline === 'illustration' || normalizedPath.includes('@react-spectrum/s2/spectrum-illustrations') ? 'createIllustration' : 'createIcon';
|
|
84
86
|
return (
|
|
85
|
-
`
|
|
86
|
-
import {
|
|
87
|
-
import {SVGProps, useRef} from 'react';
|
|
88
|
-
import {useContextProps} from 'react-aria-components';
|
|
87
|
+
`"use client";
|
|
88
|
+
import {${fn}} from '${normalizedPath.includes('@react-spectrum/s2') ? '~/src/Icon' : '@react-spectrum/s2'}';
|
|
89
89
|
|
|
90
90
|
${svg.replace('import { SVGProps } from "react";', '')}
|
|
91
91
|
|
|
92
|
-
export default
|
|
93
|
-
let ref = useRef<SVGElement>(null);
|
|
94
|
-
let ctx;
|
|
95
|
-
// TODO: remove this default once we release RAC and use DEFAULT_SLOT.
|
|
96
|
-
[ctx, ref] = useContextProps({slot: props.slot || 'icon'} as IconContextValue, ref, ${context});
|
|
97
|
-
let {render, styles} = ctx;
|
|
98
|
-
let {
|
|
99
|
-
UNSAFE_className,
|
|
100
|
-
UNSAFE_style,
|
|
101
|
-
slot,
|
|
102
|
-
'aria-label': ariaLabel,
|
|
103
|
-
'aria-hidden': ariaHidden,
|
|
104
|
-
...otherProps
|
|
105
|
-
} = props;
|
|
106
|
-
|
|
107
|
-
if (!ariaHidden) {
|
|
108
|
-
ariaHidden = undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
let svg = (
|
|
112
|
-
<SvgComponent
|
|
113
|
-
{...otherProps}
|
|
114
|
-
focusable={false}
|
|
115
|
-
aria-label={ariaLabel}
|
|
116
|
-
aria-hidden={ariaLabel ? (ariaHidden || undefined) : true}
|
|
117
|
-
role="img"
|
|
118
|
-
data-slot={slot}
|
|
119
|
-
className={(UNSAFE_className ?? '') + ' ' + (styles || '')}
|
|
120
|
-
style={UNSAFE_style} />
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
if (render) {
|
|
124
|
-
return render(svg);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return svg;
|
|
128
|
-
}
|
|
129
|
-
|
|
92
|
+
export default /*#__PURE__*/ ${fn}(ForwardRef);
|
|
130
93
|
`
|
|
131
94
|
);
|
|
132
95
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/parcel-transformer-s2-icon",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "IconTransformer.js",
|
|
5
5
|
"engines": {
|
|
6
|
-
"parcel": "2.0.0
|
|
6
|
+
"parcel": "^2.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@adobe/spectrum-tokens": "
|
|
10
|
-
"@parcel/plugin": "2.0.0
|
|
9
|
+
"@adobe/spectrum-tokens": "14.0.0",
|
|
10
|
+
"@parcel/plugin": "^2.0.0",
|
|
11
|
+
"@svgr/core": "^8.1.0",
|
|
12
|
+
"@svgr/plugin-jsx": "^8.1.0",
|
|
13
|
+
"@svgr/plugin-svgo": "^8.1.0",
|
|
14
|
+
"prettier": "^3.6.2"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"prettier": "^3.3.3"
|
|
11
18
|
},
|
|
12
19
|
"rsp": {
|
|
13
20
|
"type": "cli"
|
|
@@ -20,5 +27,5 @@
|
|
|
20
27
|
"publishConfig": {
|
|
21
28
|
"access": "public"
|
|
22
29
|
},
|
|
23
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
|
|
24
31
|
}
|