rn-iconify 2.0.0 → 2.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/README.md +8 -2
- package/assets/logo.gif +0 -0
- package/lib/commonjs/IconRenderer.js +56 -20
- package/lib/commonjs/IconRenderer.js.map +1 -1
- package/lib/commonjs/alias/Icon.js +35 -1
- package/lib/commonjs/alias/Icon.js.map +1 -1
- package/lib/commonjs/babel/cache-writer.js +1 -1
- package/lib/commonjs/babel/cache-writer.js.map +1 -1
- package/lib/commonjs/babel/index.js +0 -1
- package/lib/commonjs/babel/index.js.map +1 -1
- package/lib/commonjs/createIconSet.js +20 -1
- package/lib/commonjs/createIconSet.js.map +1 -1
- package/lib/module/IconRenderer.js +57 -19
- package/lib/module/IconRenderer.js.map +1 -1
- package/lib/module/alias/Icon.js +35 -1
- package/lib/module/alias/Icon.js.map +1 -1
- package/lib/module/babel/cache-writer.js +1 -1
- package/lib/module/babel/cache-writer.js.map +1 -1
- package/lib/module/babel/index.js +0 -1
- package/lib/module/babel/index.js.map +1 -1
- package/lib/module/createIconSet.js +20 -1
- package/lib/module/createIconSet.js.map +1 -1
- package/lib/typescript/IconRenderer.d.ts +1 -1
- package/lib/typescript/IconRenderer.d.ts.map +1 -1
- package/lib/typescript/alias/Icon.d.ts +1 -1
- package/lib/typescript/alias/Icon.d.ts.map +1 -1
- package/lib/typescript/babel/index.d.ts +0 -1
- package/lib/typescript/babel/index.d.ts.map +1 -1
- package/lib/typescript/babel/types.d.ts +1 -1
- package/lib/typescript/components/Academicons.d.ts +1 -1
- package/lib/typescript/components/AkarIcons.d.ts +1 -1
- package/lib/typescript/components/AntDesign.d.ts +1 -1
- package/lib/typescript/components/Arcticons.d.ts +1 -1
- package/lib/typescript/components/Basil.d.ts +1 -1
- package/lib/typescript/components/Bi.d.ts +1 -1
- package/lib/typescript/components/BitcoinIcons.d.ts +1 -1
- package/lib/typescript/components/Bpmn.d.ts +1 -1
- package/lib/typescript/components/Brandico.d.ts +1 -1
- package/lib/typescript/components/Bx.d.ts +1 -1
- package/lib/typescript/components/Bxl.d.ts +1 -1
- package/lib/typescript/components/Bxs.d.ts +1 -1
- package/lib/typescript/components/Bytesize.d.ts +1 -1
- package/lib/typescript/components/Carbon.d.ts +1 -1
- package/lib/typescript/components/Catppuccin.d.ts +1 -1
- package/lib/typescript/components/Cbi.d.ts +1 -1
- package/lib/typescript/components/Charm.d.ts +1 -1
- package/lib/typescript/components/Ci.d.ts +1 -1
- package/lib/typescript/components/Cib.d.ts +1 -1
- package/lib/typescript/components/Cif.d.ts +1 -1
- package/lib/typescript/components/Cil.d.ts +1 -1
- package/lib/typescript/components/CircleFlags.d.ts +1 -1
- package/lib/typescript/components/Circum.d.ts +1 -1
- package/lib/typescript/components/Clarity.d.ts +1 -1
- package/lib/typescript/components/Codex.d.ts +1 -1
- package/lib/typescript/components/Codicon.d.ts +1 -1
- package/lib/typescript/components/Covid.d.ts +1 -1
- package/lib/typescript/components/Cryptocurrency.d.ts +1 -1
- package/lib/typescript/components/CryptocurrencyColor.d.ts +1 -1
- package/lib/typescript/components/Cuida.d.ts +1 -1
- package/lib/typescript/components/Dashicons.d.ts +1 -1
- package/lib/typescript/components/Devicon.d.ts +1 -1
- package/lib/typescript/components/DeviconPlain.d.ts +1 -1
- package/lib/typescript/components/DinkieIcons.d.ts +1 -1
- package/lib/typescript/components/DuoIcons.d.ts +1 -1
- package/lib/typescript/components/Ei.d.ts +1 -1
- package/lib/typescript/components/El.d.ts +1 -1
- package/lib/typescript/components/EmojioneMonotone.d.ts +1 -1
- package/lib/typescript/components/Entypo.d.ts +1 -1
- package/lib/typescript/components/EntypoSocial.d.ts +1 -1
- package/lib/typescript/components/EosIcons.d.ts +1 -1
- package/lib/typescript/components/Ep.d.ts +1 -1
- package/lib/typescript/components/Et.d.ts +1 -1
- package/lib/typescript/components/Eva.d.ts +1 -1
- package/lib/typescript/components/F7.d.ts +1 -1
- package/lib/typescript/components/Fa.d.ts +1 -1
- package/lib/typescript/components/Fa6Brands.d.ts +1 -1
- package/lib/typescript/components/Fa6Regular.d.ts +1 -1
- package/lib/typescript/components/Fa6Solid.d.ts +1 -1
- package/lib/typescript/components/Fa7Brands.d.ts +1 -1
- package/lib/typescript/components/Fa7Regular.d.ts +1 -1
- package/lib/typescript/components/Fa7Solid.d.ts +1 -1
- package/lib/typescript/components/FaBrands.d.ts +1 -1
- package/lib/typescript/components/FaRegular.d.ts +1 -1
- package/lib/typescript/components/FaSolid.d.ts +1 -1
- package/lib/typescript/components/Fad.d.ts +1 -1
- package/lib/typescript/components/Famicons.d.ts +1 -1
- package/lib/typescript/components/Fe.d.ts +1 -1
- package/lib/typescript/components/Feather.d.ts +1 -1
- package/lib/typescript/components/FileIcons.d.ts +1 -1
- package/lib/typescript/components/Flag.d.ts +1 -1
- package/lib/typescript/components/Flagpack.d.ts +1 -1
- package/lib/typescript/components/FlatUi.d.ts +1 -1
- package/lib/typescript/components/Flowbite.d.ts +1 -1
- package/lib/typescript/components/Fluent.d.ts +1 -1
- package/lib/typescript/components/FluentColor.d.ts +1 -1
- package/lib/typescript/components/FluentEmoji.d.ts +1 -1
- package/lib/typescript/components/FluentEmojiFlat.d.ts +1 -1
- package/lib/typescript/components/FluentEmojiHighContrast.d.ts +1 -1
- package/lib/typescript/components/FluentMdl2.d.ts +1 -1
- package/lib/typescript/components/Fontelico.d.ts +1 -1
- package/lib/typescript/components/Fontisto.d.ts +1 -1
- package/lib/typescript/components/Formkit.d.ts +1 -1
- package/lib/typescript/components/Foundation.d.ts +1 -1
- package/lib/typescript/components/Gala.d.ts +1 -1
- package/lib/typescript/components/GameIcons.d.ts +1 -1
- package/lib/typescript/components/Garden.d.ts +1 -1
- package/lib/typescript/components/Geo.d.ts +1 -1
- package/lib/typescript/components/Gg.d.ts +1 -1
- package/lib/typescript/components/Gis.d.ts +1 -1
- package/lib/typescript/components/GravityUi.d.ts +1 -1
- package/lib/typescript/components/Gridicons.d.ts +1 -1
- package/lib/typescript/components/GrommetIcons.d.ts +1 -1
- package/lib/typescript/components/Guidance.d.ts +1 -1
- package/lib/typescript/components/Healthicons.d.ts +1 -1
- package/lib/typescript/components/Heroicons.d.ts +1 -1
- package/lib/typescript/components/HeroiconsOutline.d.ts +1 -1
- package/lib/typescript/components/HeroiconsSolid.d.ts +1 -1
- package/lib/typescript/components/Hugeicons.d.ts +1 -1
- package/lib/typescript/components/Humbleicons.d.ts +1 -1
- package/lib/typescript/components/Ic.d.ts +1 -1
- package/lib/typescript/components/IcomoonFree.d.ts +1 -1
- package/lib/typescript/components/IconPark.d.ts +1 -1
- package/lib/typescript/components/IconParkOutline.d.ts +1 -1
- package/lib/typescript/components/IconParkSolid.d.ts +1 -1
- package/lib/typescript/components/IconParkTwotone.d.ts +1 -1
- package/lib/typescript/components/Iconamoon.d.ts +1 -1
- package/lib/typescript/components/Iconoir.d.ts +1 -1
- package/lib/typescript/components/Icons8.d.ts +1 -1
- package/lib/typescript/components/Il.d.ts +1 -1
- package/lib/typescript/components/Ion.d.ts +1 -1
- package/lib/typescript/components/Iwwa.d.ts +1 -1
- package/lib/typescript/components/Ix.d.ts +1 -1
- package/lib/typescript/components/Jam.d.ts +1 -1
- package/lib/typescript/components/La.d.ts +1 -1
- package/lib/typescript/components/LetsIcons.d.ts +1 -1
- package/lib/typescript/components/LineMd.d.ts +1 -1
- package/lib/typescript/components/Lineicons.d.ts +1 -1
- package/lib/typescript/components/Logos.d.ts +1 -1
- package/lib/typescript/components/Ls.d.ts +1 -1
- package/lib/typescript/components/Lsicon.d.ts +1 -1
- package/lib/typescript/components/Lucide.d.ts +1 -1
- package/lib/typescript/components/LucideLab.d.ts +1 -1
- package/lib/typescript/components/Mage.d.ts +1 -1
- package/lib/typescript/components/Majesticons.d.ts +1 -1
- package/lib/typescript/components/Maki.d.ts +1 -1
- package/lib/typescript/components/Map.d.ts +1 -1
- package/lib/typescript/components/Marketeq.d.ts +1 -1
- package/lib/typescript/components/MaterialIconTheme.d.ts +1 -1
- package/lib/typescript/components/MaterialSymbols.d.ts +1 -1
- package/lib/typescript/components/MaterialSymbolsLight.d.ts +1 -1
- package/lib/typescript/components/Mdi.d.ts +1 -1
- package/lib/typescript/components/MdiLight.d.ts +1 -1
- package/lib/typescript/components/MedicalIcon.d.ts +1 -1
- package/lib/typescript/components/Memory.d.ts +1 -1
- package/lib/typescript/components/Meteocons.d.ts +1 -1
- package/lib/typescript/components/MeteorIcons.d.ts +1 -1
- package/lib/typescript/components/Mi.d.ts +1 -1
- package/lib/typescript/components/Mingcute.d.ts +1 -1
- package/lib/typescript/components/MonoIcons.d.ts +1 -1
- package/lib/typescript/components/Mynaui.d.ts +1 -1
- package/lib/typescript/components/Nimbus.d.ts +1 -1
- package/lib/typescript/components/Nonicons.d.ts +1 -1
- package/lib/typescript/components/Nrk.d.ts +1 -1
- package/lib/typescript/components/Octicon.d.ts +1 -1
- package/lib/typescript/components/Oi.d.ts +1 -1
- package/lib/typescript/components/Ooui.d.ts +1 -1
- package/lib/typescript/components/Oui.d.ts +1 -1
- package/lib/typescript/components/Pajamas.d.ts +1 -1
- package/lib/typescript/components/Pepicons.d.ts +1 -1
- package/lib/typescript/components/PepiconsPencil.d.ts +1 -1
- package/lib/typescript/components/PepiconsPop.d.ts +1 -1
- package/lib/typescript/components/PepiconsPrint.d.ts +1 -1
- package/lib/typescript/components/Ph.d.ts +1 -1
- package/lib/typescript/components/Picon.d.ts +1 -1
- package/lib/typescript/components/Pixel.d.ts +1 -1
- package/lib/typescript/components/Pixelarticons.d.ts +1 -1
- package/lib/typescript/components/Prime.d.ts +1 -1
- package/lib/typescript/components/Proicons.d.ts +1 -1
- package/lib/typescript/components/Ps.d.ts +1 -1
- package/lib/typescript/components/QlementineIcons.d.ts +1 -1
- package/lib/typescript/components/Quill.d.ts +1 -1
- package/lib/typescript/components/RadixIcons.d.ts +1 -1
- package/lib/typescript/components/Raphael.d.ts +1 -1
- package/lib/typescript/components/Ri.d.ts +1 -1
- package/lib/typescript/components/RivetIcons.d.ts +1 -1
- package/lib/typescript/components/Roentgen.d.ts +1 -1
- package/lib/typescript/components/Si.d.ts +1 -1
- package/lib/typescript/components/SiGlyph.d.ts +1 -1
- package/lib/typescript/components/Sidekickicons.d.ts +1 -1
- package/lib/typescript/components/SimpleIcons.d.ts +1 -1
- package/lib/typescript/components/SimpleLineIcons.d.ts +1 -1
- package/lib/typescript/components/SkillIcons.d.ts +1 -1
- package/lib/typescript/components/Solar.d.ts +1 -1
- package/lib/typescript/components/Stash.d.ts +1 -1
- package/lib/typescript/components/Streamline.d.ts +1 -1
- package/lib/typescript/components/StreamlineBlock.d.ts +1 -1
- package/lib/typescript/components/StreamlineColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineCyber.d.ts +1 -1
- package/lib/typescript/components/StreamlineCyberColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineEmojis.d.ts +1 -1
- package/lib/typescript/components/StreamlineFlex.d.ts +1 -1
- package/lib/typescript/components/StreamlineFlexColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineFreehand.d.ts +1 -1
- package/lib/typescript/components/StreamlineFreehandColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineKameleonColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineLogos.d.ts +1 -1
- package/lib/typescript/components/StreamlinePixel.d.ts +1 -1
- package/lib/typescript/components/StreamlinePlump.d.ts +1 -1
- package/lib/typescript/components/StreamlinePlumpColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineSharp.d.ts +1 -1
- package/lib/typescript/components/StreamlineSharpColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineStickiesColor.d.ts +1 -1
- package/lib/typescript/components/StreamlineUltimate.d.ts +1 -1
- package/lib/typescript/components/StreamlineUltimateColor.d.ts +1 -1
- package/lib/typescript/components/Subway.d.ts +1 -1
- package/lib/typescript/components/SvgSpinners.d.ts +1 -1
- package/lib/typescript/components/SystemUicons.d.ts +1 -1
- package/lib/typescript/components/Tabler.d.ts +1 -1
- package/lib/typescript/components/Tdesign.d.ts +1 -1
- package/lib/typescript/components/Teenyicons.d.ts +1 -1
- package/lib/typescript/components/Temaki.d.ts +1 -1
- package/lib/typescript/components/Token.d.ts +1 -1
- package/lib/typescript/components/TokenBranded.d.ts +1 -1
- package/lib/typescript/components/Topcoat.d.ts +1 -1
- package/lib/typescript/components/Typcn.d.ts +1 -1
- package/lib/typescript/components/Uil.d.ts +1 -1
- package/lib/typescript/components/Uim.d.ts +1 -1
- package/lib/typescript/components/Uis.d.ts +1 -1
- package/lib/typescript/components/Uit.d.ts +1 -1
- package/lib/typescript/components/Uiw.d.ts +1 -1
- package/lib/typescript/components/Unjs.d.ts +1 -1
- package/lib/typescript/components/Vaadin.d.ts +1 -1
- package/lib/typescript/components/Vs.d.ts +1 -1
- package/lib/typescript/components/VscodeIcons.d.ts +1 -1
- package/lib/typescript/components/Websymbol.d.ts +1 -1
- package/lib/typescript/components/Weui.d.ts +1 -1
- package/lib/typescript/components/Whh.d.ts +1 -1
- package/lib/typescript/components/Wi.d.ts +1 -1
- package/lib/typescript/components/Wpf.d.ts +1 -1
- package/lib/typescript/components/Zmdi.d.ts +1 -1
- package/lib/typescript/components/Zondicons.d.ts +1 -1
- package/lib/typescript/createIconSet.d.ts +1 -1
- package/lib/typescript/createIconSet.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +56 -0
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/IconRenderer.tsx +51 -8
- package/src/alias/Icon.tsx +32 -0
- package/src/babel/cache-writer.ts +1 -1
- package/src/babel/index.ts +0 -1
- package/src/babel/types.ts +1 -1
- package/src/createIconSet.tsx +17 -0
- package/src/types/index.ts +75 -0
package/src/IconRenderer.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
|
7
|
-
import { View, StyleSheet, Animated } from 'react-native';
|
|
7
|
+
import { View, StyleSheet, Animated, Pressable } from 'react-native';
|
|
8
8
|
import { SvgXml } from 'react-native-svg';
|
|
9
9
|
import { CacheManager } from './cache/CacheManager';
|
|
10
10
|
import { fetchIcon } from './network/IconifyAPI';
|
|
@@ -32,6 +32,7 @@ export function IconRenderer({
|
|
|
32
32
|
width: propWidth,
|
|
33
33
|
height: propHeight,
|
|
34
34
|
style,
|
|
35
|
+
className,
|
|
35
36
|
rotate = 0,
|
|
36
37
|
flip,
|
|
37
38
|
fallback,
|
|
@@ -43,6 +44,13 @@ export function IconRenderer({
|
|
|
43
44
|
onError,
|
|
44
45
|
accessibilityLabel,
|
|
45
46
|
testID,
|
|
47
|
+
// Press props
|
|
48
|
+
onPress,
|
|
49
|
+
onLongPress,
|
|
50
|
+
onPressIn,
|
|
51
|
+
onPressOut,
|
|
52
|
+
disabled,
|
|
53
|
+
pressedStyle,
|
|
46
54
|
// Animation props
|
|
47
55
|
animate,
|
|
48
56
|
animationDuration,
|
|
@@ -186,15 +194,44 @@ export function IconRenderer({
|
|
|
186
194
|
// Determine if we should show placeholder/fallback
|
|
187
195
|
const shouldShowPlaceholder = (state === 'loading' && showFallback) || state === 'error';
|
|
188
196
|
|
|
197
|
+
// Check if icon should be pressable
|
|
198
|
+
const isPressable = !!(onPress || onLongPress);
|
|
199
|
+
|
|
200
|
+
// NativeWind className support - conditional spread to avoid TS errors
|
|
201
|
+
const nativeWindProps = className ? { className } : {};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Wraps content with Pressable if onPress/onLongPress is provided
|
|
205
|
+
*/
|
|
206
|
+
const wrapWithPressable = (content: React.ReactNode) => {
|
|
207
|
+
if (!isPressable) return content;
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<Pressable
|
|
211
|
+
onPress={onPress}
|
|
212
|
+
onLongPress={onLongPress}
|
|
213
|
+
onPressIn={onPressIn}
|
|
214
|
+
onPressOut={onPressOut}
|
|
215
|
+
disabled={disabled}
|
|
216
|
+
accessibilityRole="button"
|
|
217
|
+
accessibilityState={{ disabled }}
|
|
218
|
+
style={({ pressed }) => [pressed && pressedStyle]}
|
|
219
|
+
>
|
|
220
|
+
{content}
|
|
221
|
+
</Pressable>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
|
|
189
225
|
// Render placeholder or fallback during loading/error
|
|
190
226
|
if (shouldShowPlaceholder) {
|
|
191
227
|
// Priority: placeholder > fallback
|
|
192
228
|
if (placeholder !== undefined) {
|
|
193
|
-
return (
|
|
229
|
+
return wrapWithPressable(
|
|
194
230
|
<View
|
|
195
231
|
style={[{ width: iconWidth, height: iconHeight }, style]}
|
|
196
232
|
accessibilityLabel={accessibilityLabel}
|
|
197
233
|
testID={testID}
|
|
234
|
+
{...nativeWindProps}
|
|
198
235
|
>
|
|
199
236
|
<PlaceholderFactory
|
|
200
237
|
type={placeholder}
|
|
@@ -209,11 +246,12 @@ export function IconRenderer({
|
|
|
209
246
|
|
|
210
247
|
// Fallback for backwards compatibility (deprecated)
|
|
211
248
|
if (fallback) {
|
|
212
|
-
return (
|
|
249
|
+
return wrapWithPressable(
|
|
213
250
|
<View
|
|
214
251
|
style={[{ width: iconWidth, height: iconHeight }, style]}
|
|
215
252
|
accessibilityLabel={accessibilityLabel}
|
|
216
253
|
testID={testID}
|
|
254
|
+
{...nativeWindProps}
|
|
217
255
|
>
|
|
218
256
|
{fallback}
|
|
219
257
|
</View>
|
|
@@ -221,11 +259,12 @@ export function IconRenderer({
|
|
|
221
259
|
}
|
|
222
260
|
|
|
223
261
|
// Return empty view if no placeholder/fallback
|
|
224
|
-
return (
|
|
262
|
+
return wrapWithPressable(
|
|
225
263
|
<View
|
|
226
264
|
style={[{ width: iconWidth, height: iconHeight }, style]}
|
|
227
265
|
accessibilityLabel={accessibilityLabel}
|
|
228
266
|
testID={testID}
|
|
267
|
+
{...nativeWindProps}
|
|
229
268
|
/>
|
|
230
269
|
);
|
|
231
270
|
}
|
|
@@ -234,7 +273,7 @@ export function IconRenderer({
|
|
|
234
273
|
if (colorizedSvg) {
|
|
235
274
|
// Render with animation wrapper if animation is enabled
|
|
236
275
|
if (hasAnimation) {
|
|
237
|
-
return (
|
|
276
|
+
return wrapWithPressable(
|
|
238
277
|
<Animated.View
|
|
239
278
|
style={[
|
|
240
279
|
styles.container,
|
|
@@ -245,6 +284,7 @@ export function IconRenderer({
|
|
|
245
284
|
accessibilityLabel={accessibilityLabel}
|
|
246
285
|
accessibilityRole="image"
|
|
247
286
|
testID={testID}
|
|
287
|
+
{...nativeWindProps}
|
|
248
288
|
>
|
|
249
289
|
<SvgXml xml={colorizedSvg} width={iconWidth} height={iconHeight} />
|
|
250
290
|
</Animated.View>
|
|
@@ -252,7 +292,7 @@ export function IconRenderer({
|
|
|
252
292
|
}
|
|
253
293
|
|
|
254
294
|
// Render without animation
|
|
255
|
-
return (
|
|
295
|
+
return wrapWithPressable(
|
|
256
296
|
<View
|
|
257
297
|
style={[
|
|
258
298
|
styles.container,
|
|
@@ -262,6 +302,7 @@ export function IconRenderer({
|
|
|
262
302
|
accessibilityLabel={accessibilityLabel}
|
|
263
303
|
accessibilityRole="image"
|
|
264
304
|
testID={testID}
|
|
305
|
+
{...nativeWindProps}
|
|
265
306
|
>
|
|
266
307
|
<SvgXml xml={colorizedSvg} width={iconWidth} height={iconHeight} />
|
|
267
308
|
</View>
|
|
@@ -270,11 +311,12 @@ export function IconRenderer({
|
|
|
270
311
|
|
|
271
312
|
// Show placeholder immediately if set (no delay), otherwise empty view
|
|
272
313
|
if (placeholder !== undefined && state === 'loading') {
|
|
273
|
-
return (
|
|
314
|
+
return wrapWithPressable(
|
|
274
315
|
<View
|
|
275
316
|
style={[{ width: iconWidth, height: iconHeight }, style]}
|
|
276
317
|
accessibilityLabel={accessibilityLabel}
|
|
277
318
|
testID={testID}
|
|
319
|
+
{...nativeWindProps}
|
|
278
320
|
>
|
|
279
321
|
<PlaceholderFactory
|
|
280
322
|
type={placeholder}
|
|
@@ -288,11 +330,12 @@ export function IconRenderer({
|
|
|
288
330
|
}
|
|
289
331
|
|
|
290
332
|
// Return empty view while loading (before fallback delay)
|
|
291
|
-
return (
|
|
333
|
+
return wrapWithPressable(
|
|
292
334
|
<View
|
|
293
335
|
style={[{ width: iconWidth, height: iconHeight }, style]}
|
|
294
336
|
accessibilityLabel={accessibilityLabel}
|
|
295
337
|
testID={testID}
|
|
338
|
+
{...nativeWindProps}
|
|
296
339
|
/>
|
|
297
340
|
);
|
|
298
341
|
}
|
package/src/alias/Icon.tsx
CHANGED
|
@@ -43,6 +43,7 @@ export function Icon({
|
|
|
43
43
|
width,
|
|
44
44
|
height,
|
|
45
45
|
style,
|
|
46
|
+
className,
|
|
46
47
|
rotate,
|
|
47
48
|
flip,
|
|
48
49
|
fallback,
|
|
@@ -54,6 +55,21 @@ export function Icon({
|
|
|
54
55
|
onError,
|
|
55
56
|
accessibilityLabel,
|
|
56
57
|
testID,
|
|
58
|
+
// Press props
|
|
59
|
+
onPress,
|
|
60
|
+
onLongPress,
|
|
61
|
+
onPressIn,
|
|
62
|
+
onPressOut,
|
|
63
|
+
disabled,
|
|
64
|
+
pressedStyle,
|
|
65
|
+
// Animation props
|
|
66
|
+
animate,
|
|
67
|
+
animationDuration,
|
|
68
|
+
animationLoop,
|
|
69
|
+
animationEasing,
|
|
70
|
+
animationDelay,
|
|
71
|
+
autoPlay,
|
|
72
|
+
onAnimationComplete,
|
|
57
73
|
}: GenericIconProps) {
|
|
58
74
|
// Get theme defaults
|
|
59
75
|
const { theme } = useIconTheme();
|
|
@@ -93,6 +109,7 @@ export function Icon({
|
|
|
93
109
|
width={width}
|
|
94
110
|
height={height}
|
|
95
111
|
style={style}
|
|
112
|
+
className={className}
|
|
96
113
|
rotate={mergedRotate}
|
|
97
114
|
flip={mergedFlip}
|
|
98
115
|
fallback={fallback}
|
|
@@ -104,6 +121,21 @@ export function Icon({
|
|
|
104
121
|
onError={onError}
|
|
105
122
|
accessibilityLabel={accessibilityLabel ?? name}
|
|
106
123
|
testID={testID}
|
|
124
|
+
// Press props
|
|
125
|
+
onPress={onPress}
|
|
126
|
+
onLongPress={onLongPress}
|
|
127
|
+
onPressIn={onPressIn}
|
|
128
|
+
onPressOut={onPressOut}
|
|
129
|
+
disabled={disabled}
|
|
130
|
+
pressedStyle={pressedStyle}
|
|
131
|
+
// Animation props
|
|
132
|
+
animate={animate}
|
|
133
|
+
animationDuration={animationDuration}
|
|
134
|
+
animationLoop={animationLoop}
|
|
135
|
+
animationEasing={animationEasing}
|
|
136
|
+
animationDelay={animationDelay}
|
|
137
|
+
autoPlay={autoPlay}
|
|
138
|
+
onAnimationComplete={onAnimationComplete}
|
|
107
139
|
/>
|
|
108
140
|
);
|
|
109
141
|
}
|
|
@@ -260,7 +260,7 @@ export async function generateBundle(
|
|
|
260
260
|
options: BabelPluginOptions,
|
|
261
261
|
projectRoot: string
|
|
262
262
|
): Promise<void> {
|
|
263
|
-
const { outputPath = '
|
|
263
|
+
const { outputPath = 'node_modules/.cache/rn-iconify', verbose = false } = options;
|
|
264
264
|
|
|
265
265
|
if (iconNames.length === 0) {
|
|
266
266
|
if (verbose) {
|
package/src/babel/index.ts
CHANGED
package/src/babel/types.ts
CHANGED
package/src/createIconSet.tsx
CHANGED
|
@@ -61,6 +61,7 @@ export function createIconSet<T extends string>(
|
|
|
61
61
|
width,
|
|
62
62
|
height,
|
|
63
63
|
style,
|
|
64
|
+
className,
|
|
64
65
|
rotate,
|
|
65
66
|
flip,
|
|
66
67
|
fallback,
|
|
@@ -72,6 +73,13 @@ export function createIconSet<T extends string>(
|
|
|
72
73
|
onError,
|
|
73
74
|
accessibilityLabel,
|
|
74
75
|
testID,
|
|
76
|
+
// Press props
|
|
77
|
+
onPress,
|
|
78
|
+
onLongPress,
|
|
79
|
+
onPressIn,
|
|
80
|
+
onPressOut,
|
|
81
|
+
disabled,
|
|
82
|
+
pressedStyle,
|
|
75
83
|
// Animation props
|
|
76
84
|
animate,
|
|
77
85
|
animationDuration,
|
|
@@ -117,6 +125,7 @@ export function createIconSet<T extends string>(
|
|
|
117
125
|
width={width}
|
|
118
126
|
height={height}
|
|
119
127
|
style={style}
|
|
128
|
+
className={className}
|
|
120
129
|
rotate={mergedRotate}
|
|
121
130
|
flip={mergedFlip}
|
|
122
131
|
fallback={fallback}
|
|
@@ -128,6 +137,14 @@ export function createIconSet<T extends string>(
|
|
|
128
137
|
onError={onError}
|
|
129
138
|
accessibilityLabel={accessibilityLabel ?? name}
|
|
130
139
|
testID={testID}
|
|
140
|
+
// Press props
|
|
141
|
+
onPress={onPress}
|
|
142
|
+
onLongPress={onLongPress}
|
|
143
|
+
onPressIn={onPressIn}
|
|
144
|
+
onPressOut={onPressOut}
|
|
145
|
+
disabled={disabled}
|
|
146
|
+
pressedStyle={pressedStyle}
|
|
147
|
+
// Animation props
|
|
131
148
|
animate={animate}
|
|
132
149
|
animationDuration={animationDuration}
|
|
133
150
|
animationLoop={animationLoop}
|
package/src/types/index.ts
CHANGED
|
@@ -113,6 +113,81 @@ export interface IconProps<T extends string = string> {
|
|
|
113
113
|
*/
|
|
114
114
|
testID?: string;
|
|
115
115
|
|
|
116
|
+
// ─────────────────────────────────────────────────────────────────
|
|
117
|
+
// Press/Touch Props
|
|
118
|
+
// ─────────────────────────────────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Called when the icon is pressed.
|
|
122
|
+
* When provided, the icon is automatically wrapped in a Pressable component.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* <Mdi name="close" onPress={() => console.log('pressed')} />
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
onPress?: () => void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Called when the icon is long pressed.
|
|
133
|
+
* When provided (along with or without onPress), the icon is wrapped in Pressable.
|
|
134
|
+
*/
|
|
135
|
+
onLongPress?: () => void;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Called when press starts (finger down).
|
|
139
|
+
*/
|
|
140
|
+
onPressIn?: () => void;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Called when press ends (finger up).
|
|
144
|
+
*/
|
|
145
|
+
onPressOut?: () => void;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Whether the icon press is disabled.
|
|
149
|
+
* Only applicable when onPress or onLongPress is provided.
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
disabled?: boolean;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Style applied to the icon when pressed.
|
|
156
|
+
* Only applicable when onPress or onLongPress is provided.
|
|
157
|
+
* If not provided, no visual feedback is shown on press.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsx
|
|
161
|
+
* <Mdi
|
|
162
|
+
* name="settings"
|
|
163
|
+
* onPress={() => {}}
|
|
164
|
+
* pressedStyle={{ opacity: 0.5, transform: [{ scale: 0.95 }] }}
|
|
165
|
+
* />
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
pressedStyle?: StyleProp<ViewStyle>;
|
|
169
|
+
|
|
170
|
+
// ─────────────────────────────────────────────────────────────────
|
|
171
|
+
// NativeWind Support
|
|
172
|
+
// ─────────────────────────────────────────────────────────────────
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* NativeWind/Tailwind CSS class names for styling.
|
|
176
|
+
* Only works in projects with NativeWind configured.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* <Mdi name="home" className="w-6 h-6 text-blue-500" />
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @see https://www.nativewind.dev/
|
|
184
|
+
*/
|
|
185
|
+
className?: string;
|
|
186
|
+
|
|
187
|
+
// ─────────────────────────────────────────────────────────────────
|
|
188
|
+
// Animation Props
|
|
189
|
+
// ─────────────────────────────────────────────────────────────────
|
|
190
|
+
|
|
116
191
|
/**
|
|
117
192
|
* Animation to apply to the icon
|
|
118
193
|
* Can be a preset ('spin', 'pulse', 'bounce', 'shake', 'ping', 'wiggle')
|