@fortawesome/react-native-fontawesome 0.3.2 → 1.0.0-alpha.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/README.md CHANGED
@@ -8,8 +8,22 @@
8
8
 
9
9
  > Font Awesome React Native component using SVG with JS
10
10
 
11
+ ## Version Compatibility
12
+
13
+ | Library Version | Font Awesome Version | Notes |
14
+ |-----------------|---------------------|-------|
15
+ | 1.x | Font Awesome 7 | Current version, FA7 only |
16
+ | 0.3.x | Font Awesome 6 | Use for FA6 compatibility |
17
+
18
+ **Important**: The 1.x branch requires Font Awesome 7. If you're using Font Awesome 6, please use version 0.3.x of this library:
19
+
20
+ ```bash
21
+ npm install @fortawesome/react-native-fontawesome@0.3
22
+ ```
23
+
11
24
  <!-- toc -->
12
25
 
26
+ - [Version Compatibility](#version-compatibility)
13
27
  - [Documentation](#documentation)
14
28
  - [How to Help](#how-to-help)
15
29
  - [Contributors](#contributors)
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import convert from "./converter.js";
5
+ import { StyleSheet } from 'react-native';
6
+ import { icon, parse } from '@fortawesome/fontawesome-svg-core';
7
+ import log from "./logger.js";
8
+ export const DEFAULT_SIZE = 16;
9
+ export const DEFAULT_COLOR = '#000';
10
+ export const DEFAULT_SECONDARY_OPACITY = 0.4;
11
+ function objectWithKey(key, value) {
12
+ return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? {
13
+ [key]: value
14
+ } : {};
15
+ }
16
+ function normalizeIconArgs(iconArg) {
17
+ // If it's a full icon definition object (with prefix, iconName, and icon array),
18
+ // return it as-is so icon() can use it directly
19
+ if (iconArg && typeof iconArg === 'object' && 'prefix' in iconArg && 'iconName' in iconArg && 'icon' in iconArg) {
20
+ return iconArg;
21
+ }
22
+ if (parse.icon) {
23
+ return parse.icon(iconArg);
24
+ }
25
+ if (iconArg === null) {
26
+ return null;
27
+ }
28
+ if (Array.isArray(iconArg) && iconArg.length === 2) {
29
+ return {
30
+ prefix: iconArg[0],
31
+ iconName: iconArg[1]
32
+ };
33
+ }
34
+ if (typeof iconArg === 'string') {
35
+ return {
36
+ prefix: 'fas',
37
+ iconName: iconArg
38
+ };
39
+ }
40
+ return null;
41
+ }
42
+ export default function FontAwesomeIcon(props) {
43
+ const {
44
+ icon: iconArgs,
45
+ mask: maskArgs,
46
+ maskId = null,
47
+ height,
48
+ width,
49
+ size = DEFAULT_SIZE,
50
+ style: styleInput = {},
51
+ color: colorInput = null,
52
+ secondaryColor: secondaryColorInput = null,
53
+ secondaryOpacity: secondaryOpacityInput = null,
54
+ transform: transformInput = null
55
+ } = props;
56
+ const style = StyleSheet.flatten(styleInput);
57
+ const iconLookup = normalizeIconArgs(iconArgs);
58
+ const transform = objectWithKey('transform', typeof transformInput === 'string' ? parse.transform(transformInput) : transformInput);
59
+ const mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
60
+ const renderedIcon = icon(iconLookup, {
61
+ ...transform,
62
+ ...mask,
63
+ maskId: maskId ?? undefined
64
+ });
65
+ if (!renderedIcon) {
66
+ log('ERROR: icon not found for icon = ', iconArgs);
67
+ return null;
68
+ }
69
+ const {
70
+ abstract
71
+ } = renderedIcon;
72
+
73
+ // This is the color that will be passed to the "fill" prop of the Svg element
74
+ const color = colorInput || (style || {}).color || DEFAULT_COLOR;
75
+
76
+ // This is the color that will be passed to the "fill" prop of the secondary Path element child (in Duotone Icons)
77
+ // `null` value will result in using the primary color, at 40% opacity
78
+ const secondaryColor = secondaryColorInput || color;
79
+
80
+ // Secondary layer opacity should default to 0.4, unless a specific opacity value or a specific secondary color was given
81
+ const secondaryOpacity = secondaryOpacityInput || DEFAULT_SECONDARY_OPACITY;
82
+
83
+ // To avoid confusion down the line, we'll remove properties from the StyleSheet, like color, that are being overridden
84
+ // or resolved in other ways, to avoid ambiguity as to which inputs cause which outputs in the underlying rendering process.
85
+ // In other words, we don't want color (for example) to be specified via two different inputs.
86
+ // Intentionally extract and discard color from style to avoid ambiguity
87
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
88
+ const {
89
+ color: _styleColor,
90
+ ...modifiedStyle
91
+ } = style || {};
92
+ let resolvedHeight;
93
+ let resolvedWidth;
94
+ if (height || width) {
95
+ throw new Error(`Prop height and width for component ${FontAwesomeIcon.displayName} have been deprecated. ` + `Use the size prop instead like <${FontAwesomeIcon.displayName} size={${width}} />.`);
96
+ } else {
97
+ resolvedHeight = resolvedWidth = size || DEFAULT_SIZE;
98
+ }
99
+ const rootAttributes = abstract[0].attributes;
100
+ rootAttributes.height = resolvedHeight;
101
+ rootAttributes.width = resolvedWidth;
102
+ rootAttributes.style = modifiedStyle;
103
+ replaceCurrentColor(abstract[0], color, secondaryColor, secondaryOpacity);
104
+
105
+ // Expand viewBox for FA7 overflow icon support
106
+ // This must happen before percentage replacement to ensure correct dimensions
107
+ if (rootAttributes.viewBox) {
108
+ rootAttributes.viewBox = expandViewBox(rootAttributes.viewBox);
109
+ }
110
+
111
+ // Parse viewBox to get dimensions for percentage replacement
112
+ // viewBox format: "minX minY width height" e.g., "0 -32 512 576" (after expansion)
113
+ const viewBox = rootAttributes.viewBox;
114
+ if (viewBox) {
115
+ const parts = viewBox.split(' ').map(Number);
116
+ if (parts.length === 4) {
117
+ const vbWidth = parts[2];
118
+ const vbHeight = parts[3];
119
+ if (vbWidth !== undefined && vbHeight !== undefined) {
120
+ replacePercentages(abstract[0], vbWidth, vbHeight);
121
+ }
122
+ }
123
+ }
124
+
125
+ // AbstractElement input always produces a ReactElement (not string), so cast is safe
126
+ return convertCurry(abstract[0]);
127
+ }
128
+ FontAwesomeIcon.displayName = 'FontAwesomeIcon';
129
+ const convertCurry = convert.bind(null, React.createElement);
130
+ function replaceCurrentColor(obj, primaryColor, secondaryColor, secondaryOpacity) {
131
+ (obj.children || []).forEach(child => {
132
+ if (typeof child === 'string') return;
133
+ replaceFill(child, primaryColor, secondaryColor, secondaryOpacity);
134
+ if (Object.prototype.hasOwnProperty.call(child, 'attributes')) {
135
+ replaceFill(child.attributes, primaryColor, secondaryColor, secondaryOpacity);
136
+ }
137
+ if (Array.isArray(child.children) && child.children.length > 0) {
138
+ replaceCurrentColor(child, primaryColor, secondaryColor, secondaryOpacity);
139
+ }
140
+ });
141
+ }
142
+ function replaceFill(obj, primaryColor, secondaryColor, secondaryOpacity) {
143
+ if (hasPropertySetToValue(obj, 'fill', 'currentColor')) {
144
+ if (hasPropertySetToValue(obj, 'class', 'fa-primary')) {
145
+ obj.fill = primaryColor;
146
+ } else if (hasPropertySetToValue(obj, 'class', 'fa-secondary')) {
147
+ obj.fill = secondaryColor;
148
+ obj.fillOpacity = secondaryOpacity;
149
+ } else {
150
+ obj.fill = primaryColor;
151
+ }
152
+ }
153
+ }
154
+ function hasPropertySetToValue(obj, property, value) {
155
+ return Object.prototype.hasOwnProperty.call(obj, property) && obj[property] === value;
156
+ }
157
+
158
+ /**
159
+ * Expands the viewBox to accommodate Font Awesome 7 icons that overflow their standard viewBox.
160
+ * FA7 introduced icons where paths extend beyond the declared viewBox boundaries.
161
+ * React Native clips content to the viewBox (unlike web browsers which support CSS overflow: visible).
162
+ * This expansion adds vertical space by subtracting 32 from minY and adding 64 to height.
163
+ *
164
+ * @param viewBox - The original viewBox string in format "minX minY width height"
165
+ * @returns The expanded viewBox string with adjusted minY and height
166
+ */
167
+ export function expandViewBox(viewBox) {
168
+ const parts = viewBox.split(' ').map(Number);
169
+ if (parts.length !== 4) return viewBox;
170
+ const minX = parts[0];
171
+ const minY = parts[1];
172
+ const width = parts[2];
173
+ const height = parts[3];
174
+
175
+ // Validate that all parts are valid numbers
176
+ if (minX === undefined || minY === undefined || width === undefined || height === undefined || isNaN(minX) || isNaN(minY) || isNaN(width) || isNaN(height)) {
177
+ return viewBox;
178
+ }
179
+
180
+ // Expand for FA7 overflow icons: subtract 32 from minY, add 64 to height
181
+ return `${minX} ${minY - 32} ${width} ${height + 64}`;
182
+ }
183
+
184
+ /**
185
+ * react-native-svg has issues with percentage values like "100%" in masks and rects.
186
+ * This function replaces percentage values with actual numeric values based on the viewBox.
187
+ */
188
+ function replacePercentages(obj, viewBoxWidth, viewBoxHeight) {
189
+ const attrs = obj.attributes;
190
+ if (attrs) {
191
+ if (attrs.width === '100%') {
192
+ attrs.width = viewBoxWidth;
193
+ }
194
+ if (attrs.height === '100%') {
195
+ attrs.height = viewBoxHeight;
196
+ }
197
+ }
198
+ (obj.children || []).forEach(child => {
199
+ if (typeof child !== 'string') {
200
+ replacePercentages(child, viewBoxWidth, viewBoxHeight);
201
+ }
202
+ });
203
+ }
204
+ //# sourceMappingURL=FontAwesomeIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","convert","StyleSheet","icon","parse","log","DEFAULT_SIZE","DEFAULT_COLOR","DEFAULT_SECONDARY_OPACITY","objectWithKey","key","value","Array","isArray","length","normalizeIconArgs","iconArg","prefix","iconName","FontAwesomeIcon","props","iconArgs","mask","maskArgs","maskId","height","width","size","style","styleInput","color","colorInput","secondaryColor","secondaryColorInput","secondaryOpacity","secondaryOpacityInput","transform","transformInput","flatten","iconLookup","renderedIcon","undefined","abstract","_styleColor","modifiedStyle","resolvedHeight","resolvedWidth","Error","displayName","rootAttributes","attributes","replaceCurrentColor","viewBox","expandViewBox","parts","split","map","Number","vbWidth","vbHeight","replacePercentages","convertCurry","bind","createElement","obj","primaryColor","children","forEach","child","replaceFill","Object","prototype","hasOwnProperty","call","hasPropertySetToValue","fill","fillOpacity","property","minX","minY","isNaN","viewBoxWidth","viewBoxHeight","attrs"],"sourceRoot":"../../src","sources":["FontAwesomeIcon.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,gBAAa;AACjC,SAASC,UAAU,QAAQ,cAAc;AAEzC,SAASC,IAAI,EAAEC,KAAK,QAAQ,mCAAmC;AAS/D,OAAOC,GAAG,MAAM,aAAU;AAE1B,OAAO,MAAMC,YAAY,GAAG,EAAE;AAC9B,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AE,EAAE;AACvD;;AAEA;AACA;AACA;AACA;AACA,SAASmC,kBAAkBA,CACzBI,GAAoB,EACpBiB,YAAoB,EACpBC,aAAqB,EACf;EACN,MAAMC,KAAK,GAAGnB,GAAG,CAACd,UAAiD;EACnE,IAAIiC,KAAK,EAAE;IACT,IAAIA,KAAK,CAACzD,KAAK,KAAK,MAAM,EAAE;MAC1ByD,KAAK,CAACzD,KAAK,GAAGuD,YAAY;IAC5B;IACA,IAAIE,KAAK,CAAC1D,MAAM,KAAK,MAAM,EAAE;MAC3B0D,KAAK,CAAC1D,MAAM,GAAGyD,aAAa;IAC9B;EACF;EAEA,CAAClB,GAAG,CAACE,QAAQ,IAAI,EAAE,EAAEC,OAAO,CAAEC,KAAK,IAAK;IACtC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7BR,kBAAkB,CAACQ,KAAK,EAAEa,YAAY,EAAEC,aAAa,CAAC;IACxD;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ import humps from 'humps';
4
+ import { Svg, Path, Rect, Defs, Mask, G, ClipPath } from 'react-native-svg';
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- required for dynamic component lookup from FA abstract elements
6
+ const svgObjectMap = {
7
+ svg: Svg,
8
+ path: Path,
9
+ rect: Rect,
10
+ defs: Defs,
11
+ mask: Mask,
12
+ g: G,
13
+ clipPath: ClipPath
14
+ };
15
+ function convert(createElement, element) {
16
+ if (typeof element === 'string') {
17
+ return element;
18
+ }
19
+ const children = (element.children || []).map(child => {
20
+ return convert(createElement, child);
21
+ });
22
+ const mixins = Object.keys(element.attributes || {}).reduce((acc, key) => {
23
+ const val = element.attributes[key];
24
+ switch (key) {
25
+ case 'class':
26
+ case 'role':
27
+ case 'xmlns':
28
+ delete element.attributes[key];
29
+ break;
30
+ case 'focusable':
31
+ acc.attrs[key] = val === 'true';
32
+ break;
33
+ default:
34
+ if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0 || key === 'fill' && val === 'currentColor') {
35
+ delete element.attributes[key];
36
+ } else {
37
+ acc.attrs[humps.camelize(key)] = val;
38
+ }
39
+ }
40
+ return acc;
41
+ }, {
42
+ attrs: {}
43
+ });
44
+ return createElement(svgObjectMap[element.tag], {
45
+ ...mixins.attrs
46
+ }, ...children);
47
+ }
48
+ export default convert;
49
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["humps","Svg","Path","Rect","Defs","Mask","G","ClipPath","svgObjectMap","svg","path","rect","defs","mask","g","clipPath","convert","createElement","element","children","map","child","mixins","Object","keys","attributes","reduce","acc","key","val","attrs","indexOf","camelize","tag"],"sourceRoot":"../../src","sources":["converter.ts"],"mappings":";;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAEC,CAAC,EAAEC,QAAQ,QAAQ,kBAAkB;AAU3E;AACA,MAAMC,YAAsD,GAAG;EAC7DC,GAAG,EAAER,GAAG;EACRS,IAAI,EAAER,IAAI;EACVS,IAAI,EAAER,IAAI;EACVS,IAAI,EAAER,IAAI;EACVS,IAAI,EAAER,IAAI;EACVS,CAAC,EAAER,CAAC;EACJS,QAAQ,EAAER;AACZ,CAAC;AAED,SAASS,OAAOA,CACdC,aAA8B,EAC9BC,OAAiC,EAChB;EACjB,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAMC,QAAQ,GAAG,CAACD,OAAO,CAACC,QAAQ,IAAI,EAAE,EAAEC,GAAG,CAAEC,KAAK,IAAK;IACvD,OAAOL,OAAO,CAACC,aAAa,EAAEI,KAAK,CAAC;EACtC,CAAC,CAAC;EAEF,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACN,OAAO,CAACO,UAAU,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CACzD,CAACC,GAAG,EAAEC,GAAG,KAAK;IACZ,MAAMC,GAAG,GAAIX,OAAO,CAACO,UAAU,CAA6BG,GAAG,CAAC;IAChE,QAAQA,GAAG;MACT,KAAK,OAAO;MACZ,KAAK,MAAM;MACX,KAAK,OAAO;QACV,OAAQV,OAAO,CAACO,UAAU,CAA6BG,GAAG,CAAC;QAC3D;MACF,KAAK,WAAW;QACdD,GAAG,CAACG,KAAK,CAACF,GAAG,CAAC,GAAGC,GAAG,KAAK,MAAM;QAC/B;MACF;QACE,IACED,GAAG,CAACG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAC1BH,GAAG,CAACG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IACzBH,GAAG,KAAK,MAAM,IAAIC,GAAG,KAAK,cAAe,EAC1C;UACA,OAAQX,OAAO,CAACO,UAAU,CAA6BG,GAAG,CAAC;QAC7D,CAAC,MAAM;UACLD,GAAG,CAACG,KAAK,CAAC9B,KAAK,CAACgC,QAAQ,CAACJ,GAAG,CAAC,CAAC,GAAGC,GAAG;QACtC;IACJ;IACA,OAAOF,GAAG;EACZ,CAAC,EACD;IAAEG,KAAK,EAAE,CAAC;EAA6B,CACzC,CAAC;EAED,OAAOb,aAAa,CAClBT,YAAY,CAACU,OAAO,CAACe,GAAG,CAAC,EACzB;IAAE,GAAGX,MAAM,CAACQ;EAAM,CAAC,EACnB,GAAGX,QACL,CAAC;AACH;AAEA,eAAeH,OAAO","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { default as FontAwesomeIcon } from "./FontAwesomeIcon.js";
4
+ export { DEFAULT_SIZE, DEFAULT_COLOR, DEFAULT_SECONDARY_OPACITY } from "./FontAwesomeIcon.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","FontAwesomeIcon","DEFAULT_SIZE","DEFAULT_COLOR","DEFAULT_SECONDARY_OPACITY"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,eAAe,QAAQ,sBAAmB;AAC9D,SACEC,YAAY,EACZC,aAAa,EACbC,yBAAyB,QACpB,sBAAmB","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ const PRODUCTION = false;
4
+ export default function log(...args) {
5
+ if (!PRODUCTION && console && typeof console.error === 'function') {
6
+ console.error(...args);
7
+ }
8
+ }
9
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PRODUCTION","log","args","console","error"],"sourceRoot":"../../src","sources":["logger.ts"],"mappings":";;AAAA,MAAMA,UAAU,GAAG,KAAK;AAExB,eAAe,SAASC,GAAGA,CAAC,GAAGC,IAAe,EAAQ;EACpD,IAAI,CAACF,UAAU,IAAIG,OAAO,IAAI,OAAOA,OAAO,CAACC,KAAK,KAAK,UAAU,EAAE;IACjED,OAAO,CAACC,KAAK,CAAC,GAAGF,IAAI,CAAC;EACxB;AACF","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import type { StyleProp, ViewStyle } from 'react-native';
3
+ import type { Transform, IconProp } from '@fortawesome/fontawesome-svg-core';
4
+ export declare const DEFAULT_SIZE = 16;
5
+ export declare const DEFAULT_COLOR = "#000";
6
+ export declare const DEFAULT_SECONDARY_OPACITY = 0.4;
7
+ export type FontAwesomeIconStyle = StyleProp<ViewStyle> & {
8
+ color?: string;
9
+ };
10
+ export interface Props {
11
+ icon: IconProp;
12
+ /** @deprecated Use size instead */
13
+ height?: number;
14
+ /** @deprecated Use size instead */
15
+ width?: number;
16
+ size?: number;
17
+ color?: string;
18
+ secondaryColor?: string;
19
+ secondaryOpacity?: number;
20
+ mask?: IconProp;
21
+ maskId?: string;
22
+ transform?: string | Transform;
23
+ style?: FontAwesomeIconStyle;
24
+ testID?: string;
25
+ }
26
+ declare function FontAwesomeIcon(props: Props): React.ReactElement | null;
27
+ declare namespace FontAwesomeIcon {
28
+ var displayName: string;
29
+ }
30
+ export default FontAwesomeIcon;
31
+ /**
32
+ * Expands the viewBox to accommodate Font Awesome 7 icons that overflow their standard viewBox.
33
+ * FA7 introduced icons where paths extend beyond the declared viewBox boundaries.
34
+ * React Native clips content to the viewBox (unlike web browsers which support CSS overflow: visible).
35
+ * This expansion adds vertical space by subtracting 32 from minY and adding 64 to height.
36
+ *
37
+ * @param viewBox - The original viewBox string in format "minX minY width height"
38
+ * @returns The expanded viewBox string with adjusted minY and height
39
+ */
40
+ export declare function expandViewBox(viewBox: string): string;
41
+ //# sourceMappingURL=FontAwesomeIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontAwesomeIcon.d.ts","sourceRoot":"","sources":["../../../src/FontAwesomeIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EAKT,MAAM,mCAAmC,CAAC;AAG3C,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,aAAa,SAAS,CAAC;AACpC,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA2DD,iBAAwB,eAAe,CACrC,KAAK,EAAE,KAAK,GACX,KAAK,CAAC,YAAY,GAAG,IAAI,CAyG3B;kBA3GuB,eAAe;;;eAAf,eAAe;AA6KvC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAyBrD"}
@@ -0,0 +1,10 @@
1
+ import type React from 'react';
2
+ interface AbstractElement {
3
+ tag: string;
4
+ attributes?: Record<string, unknown>;
5
+ children?: (AbstractElement | string)[];
6
+ }
7
+ type CreateElementFn = typeof import('react').createElement;
8
+ declare function convert(createElement: CreateElementFn, element: AbstractElement | string): React.ReactNode;
9
+ export default convert;
10
+ //# sourceMappingURL=converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../../src/converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC;CACzC;AAED,KAAK,eAAe,GAAG,cAAc,OAAO,EAAE,aAAa,CAAC;AAa5D,iBAAS,OAAO,CACd,aAAa,EAAE,eAAe,EAC9B,OAAO,EAAE,eAAe,GAAG,MAAM,GAChC,KAAK,CAAC,SAAS,CA0CjB;AAED,eAAe,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as FontAwesomeIcon } from './FontAwesomeIcon';
2
+ export { DEFAULT_SIZE, DEFAULT_COLOR, DEFAULT_SECONDARY_OPACITY, } from './FontAwesomeIcon';
3
+ export type { Props, FontAwesomeIconStyle } from './FontAwesomeIcon';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export default function log(...args: unknown[]): void;
2
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/logger.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAIpD"}