@react-spectrum/parcel-transformer-s2-icon 3.0.0-nightly-d57bd8d90-240927 → 3.0.0-nightly-e60fb427c-240928

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/IconTransformer.js +4 -53
  2. package/package.json +1 -1
@@ -61,7 +61,7 @@ module.exports = new Transformer({
61
61
  plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx']
62
62
  })
63
63
  ).replace('export default ForwardRef;', '');
64
- let newFile = template(asset, iconName, optimized);
64
+ let newFile = template(asset, optimized);
65
65
  return [{
66
66
  type: 'tsx',
67
67
  content: newFile,
@@ -72,65 +72,16 @@ module.exports = new Transformer({
72
72
  }
73
73
  });
74
74
 
75
- function template(asset, iconName, svg) {
76
- let importName = iconName
77
- .replace(/^S2_Icon_(.*?)_\d+(?:x\d+)?_N$/, '$1')
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
- }
75
+ function template(asset, svg) {
83
76
  let normalizedPath = asset.filePath.replaceAll('\\', '/');
84
77
  let context = asset.pipeline === 'illustration' || normalizedPath.includes('@react-spectrum/s2/spectrum-illustrations') ? 'IllustrationContext' : 'IconContext';
85
78
  return (
86
79
  `
87
- import {IconProps, ${context}, IconContextValue} from '${normalizedPath.includes('@react-spectrum/s2') ? '~/src/Icon' : '@react-spectrum/s2'}';
88
- import {SVGProps, useRef} from 'react';
89
- import {useContextProps} from 'react-aria-components';
90
- import {SkeletonWrapper, useSkeletonIcon} from '~/src/Skeleton';
80
+ import {createIcon, ${context}} from '${normalizedPath.includes('@react-spectrum/s2') ? '~/src/Icon' : '@react-spectrum/s2'}';
91
81
 
92
82
  ${svg.replace('import { SVGProps } from "react";', '')}
93
83
 
94
- export default function ${iconRename}(props: IconProps) {
95
- let ref = useRef<SVGElement>(null);
96
- let ctx;
97
- // TODO: remove this default once we release RAC and use DEFAULT_SLOT.
98
- [ctx, ref] = useContextProps({slot: props.slot || 'icon'} as IconContextValue, ref, ${context});
99
- let {render, styles} = ctx;
100
- let {
101
- UNSAFE_className,
102
- UNSAFE_style,
103
- slot,
104
- 'aria-label': ariaLabel,
105
- 'aria-hidden': ariaHidden,
106
- ...otherProps
107
- } = props;
108
-
109
- if (!ariaHidden) {
110
- ariaHidden = undefined;
111
- }
112
-
113
- let svg = (
114
- <SkeletonWrapper>
115
- <ForwardRef
116
- {...otherProps}
117
- focusable={false}
118
- aria-label={ariaLabel}
119
- aria-hidden={ariaLabel ? (ariaHidden || undefined) : true}
120
- role="img"
121
- data-slot={slot}
122
- className={(UNSAFE_className ?? '') + ' ' + useSkeletonIcon(styles)}
123
- style={UNSAFE_style} />
124
- </SkeletonWrapper>
125
- );
126
-
127
- if (render) {
128
- return render(svg);
129
- }
130
-
131
- return svg;
132
- }
133
-
84
+ export default /*#__PURE__*/ createIcon(ForwardRef, ${context});
134
85
  `
135
86
  );
136
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/parcel-transformer-s2-icon",
3
- "version": "3.0.0-nightly-d57bd8d90-240927",
3
+ "version": "3.0.0-nightly-e60fb427c-240928",
4
4
  "main": "IconTransformer.js",
5
5
  "engines": {
6
6
  "parcel": "2.0.0-dev.1599"