@medely/react-fontawesome 0.0.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/LICENSE.txt +19 -0
- package/README.md +63 -0
- package/index.d.ts +54 -0
- package/index.es.js +432 -0
- package/index.js +586 -0
- package/package.json +112 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2018 Fonticons, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<a href="https://fontawesome.com">
|
|
2
|
+
<img align="right" width="100" height="100" alt="Official Javascript Component" src="https://img.fortawesome.com/349cfdf6/official-javascript-component.svg">
|
|
3
|
+
</a>
|
|
4
|
+
|
|
5
|
+
# react-fontawesome
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@fortawesome/react-fontawesome)
|
|
8
|
+
|
|
9
|
+
> Font Awesome 5 React component using SVG with JS
|
|
10
|
+
|
|
11
|
+
<!-- toc -->
|
|
12
|
+
|
|
13
|
+
- [Documentation](#documentation)
|
|
14
|
+
- [How to Help](#how-to-help)
|
|
15
|
+
- [Contributors](#contributors)
|
|
16
|
+
- [Releasing this project (only project owners can do this)](#releasing-this-project-only-project-owners-can-do-this)
|
|
17
|
+
|
|
18
|
+
<!-- tocstop -->
|
|
19
|
+
|
|
20
|
+
## Documentation
|
|
21
|
+
|
|
22
|
+
Official documentation is hosted at fontawesome.com:
|
|
23
|
+
|
|
24
|
+
[Check it out here](https://fontawesome.com/v6/docs/web/use-with/react/)
|
|
25
|
+
|
|
26
|
+
## How to Help
|
|
27
|
+
|
|
28
|
+
Review the following docs before diving in:
|
|
29
|
+
|
|
30
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
31
|
+
- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
|
|
32
|
+
|
|
33
|
+
And then:
|
|
34
|
+
|
|
35
|
+
1. Check the existing issue and see if you can help!
|
|
36
|
+
|
|
37
|
+
## Contributors
|
|
38
|
+
|
|
39
|
+
The following contributors have either helped to start this project, have contributed
|
|
40
|
+
code, are actively maintaining it (including documentation), or in other ways
|
|
41
|
+
being awesome contributors to this project. **We'd like to take a moment to recognize them.**
|
|
42
|
+
|
|
43
|
+
| Name | GitHub |
|
|
44
|
+
| ----------------- | --------------------------------------------------------- |
|
|
45
|
+
| Nate Radebaugh | [@NateRadebaugh](https://github.com/NateRadebaugh) |
|
|
46
|
+
| Kirk Ross | [@kirkbross](https://github.com/kirkbross) |
|
|
47
|
+
| Prateek Goel | [@prateekgoel](https://github.com/prateekgoel) |
|
|
48
|
+
| Naor Torgeman | [@naortor](https://github.com/naortor) |
|
|
49
|
+
| Matthew Hand | [@mmhand123](https://github.com/mmhand123) |
|
|
50
|
+
| calvinf | [@calvinf](https://github.com/calvinf) |
|
|
51
|
+
| Bill Parrott | [@chimericdream](https://github.com/chimericdream) |
|
|
52
|
+
| Mike Lynch | [@baelec](https://github.com/baelec) |
|
|
53
|
+
| Lukáš Rod | [@rodlukas](https://github.com/rodlukas) |
|
|
54
|
+
| Proudust | [@proudust](https://github.com/proudust) |
|
|
55
|
+
| Tiago Sousa | [@TiagoPortfolio](https://github.com/TiagoPortfolio) |
|
|
56
|
+
| Alexey Victorov | [@AliMamed](https://github.com/AliMamed) |
|
|
57
|
+
| Font Awesome Team | [@FortAwesome](https://github.com/orgs/FortAwesome/people)|
|
|
58
|
+
|
|
59
|
+
If we've missed someone (which is quite likely) submit a Pull Request to us and we'll get it resolved.
|
|
60
|
+
|
|
61
|
+
## Releasing this project (only project owners can do this)
|
|
62
|
+
|
|
63
|
+
See [DEVELOPMENT.md](DEVELOPMENT.md#release)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CSSProperties, SVGAttributes } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
Transform,
|
|
5
|
+
IconProp,
|
|
6
|
+
FlipProp,
|
|
7
|
+
SizeProp,
|
|
8
|
+
PullProp,
|
|
9
|
+
RotateProp,
|
|
10
|
+
FaSymbol
|
|
11
|
+
} from '../fontawesome-svg-core'
|
|
12
|
+
|
|
13
|
+
export function FontAwesomeIcon(props: FontAwesomeIconProps): JSX.Element
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use FontAwesomeIconProps
|
|
17
|
+
*/
|
|
18
|
+
export type Props = FontAwesomeIconProps
|
|
19
|
+
|
|
20
|
+
// This is identical to the version of Omit in Typescript 3.5. It is included for compatibility with older versions of Typescript.
|
|
21
|
+
type BackwardCompatibleOmit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
|
|
22
|
+
|
|
23
|
+
export interface FontAwesomeIconProps extends BackwardCompatibleOmit<SVGAttributes<SVGSVGElement>, 'children' | 'mask' | 'transform'> {
|
|
24
|
+
forwardedRef?: ((e: any) => void) | React.MutableRefObject<any> | null
|
|
25
|
+
icon: IconProp
|
|
26
|
+
mask?: IconProp
|
|
27
|
+
maskId?: string
|
|
28
|
+
className?: string
|
|
29
|
+
color?: string
|
|
30
|
+
spin?: boolean
|
|
31
|
+
spinPulse?: boolean
|
|
32
|
+
spinReverse?: boolean
|
|
33
|
+
pulse?: boolean
|
|
34
|
+
beat?: boolean
|
|
35
|
+
fade?: boolean
|
|
36
|
+
beatFade?: boolean
|
|
37
|
+
bounce?: boolean
|
|
38
|
+
shake?: boolean
|
|
39
|
+
border?: boolean
|
|
40
|
+
fixedWidth?: boolean
|
|
41
|
+
inverse?: boolean
|
|
42
|
+
listItem?: boolean
|
|
43
|
+
flip?: FlipProp
|
|
44
|
+
size?: SizeProp
|
|
45
|
+
pull?: PullProp
|
|
46
|
+
rotation?: RotateProp
|
|
47
|
+
transform?: string | Transform
|
|
48
|
+
symbol?: FaSymbol
|
|
49
|
+
style?: CSSProperties
|
|
50
|
+
tabIndex?: number;
|
|
51
|
+
title?: string;
|
|
52
|
+
titleId?: string;
|
|
53
|
+
swapOpacity?: boolean;
|
|
54
|
+
}
|
package/index.es.js
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { parse, icon } from '../fontawesome-svg-core';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
function ownKeys(object, enumerableOnly) {
|
|
6
|
+
var keys = Object.keys(object);
|
|
7
|
+
|
|
8
|
+
if (Object.getOwnPropertySymbols) {
|
|
9
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
10
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
11
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
12
|
+
})), keys.push.apply(keys, symbols);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return keys;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _objectSpread2(target) {
|
|
19
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
20
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
21
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
22
|
+
_defineProperty(target, key, source[key]);
|
|
23
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
24
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return target;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _typeof(obj) {
|
|
32
|
+
"@babel/helpers - typeof";
|
|
33
|
+
|
|
34
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
35
|
+
return typeof obj;
|
|
36
|
+
} : function (obj) {
|
|
37
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
38
|
+
}, _typeof(obj);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _defineProperty(obj, key, value) {
|
|
42
|
+
if (key in obj) {
|
|
43
|
+
Object.defineProperty(obj, key, {
|
|
44
|
+
value: value,
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
obj[key] = value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return obj;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
57
|
+
if (source == null) return {};
|
|
58
|
+
var target = {};
|
|
59
|
+
var sourceKeys = Object.keys(source);
|
|
60
|
+
var key, i;
|
|
61
|
+
|
|
62
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
63
|
+
key = sourceKeys[i];
|
|
64
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
65
|
+
target[key] = source[key];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return target;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _objectWithoutProperties(source, excluded) {
|
|
72
|
+
if (source == null) return {};
|
|
73
|
+
|
|
74
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
75
|
+
|
|
76
|
+
var key, i;
|
|
77
|
+
|
|
78
|
+
if (Object.getOwnPropertySymbols) {
|
|
79
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
80
|
+
|
|
81
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
82
|
+
key = sourceSymbolKeys[i];
|
|
83
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
84
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
85
|
+
target[key] = source[key];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return target;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function _toConsumableArray(arr) {
|
|
93
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function _arrayWithoutHoles(arr) {
|
|
97
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _iterableToArray(iter) {
|
|
101
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
105
|
+
if (!o) return;
|
|
106
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
107
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
108
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
109
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
110
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function _arrayLikeToArray(arr, len) {
|
|
114
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
115
|
+
|
|
116
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
117
|
+
|
|
118
|
+
return arr2;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function _nonIterableSpread() {
|
|
122
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Get CSS class list from a props object
|
|
126
|
+
function classList(props) {
|
|
127
|
+
var _classes;
|
|
128
|
+
|
|
129
|
+
var beat = props.beat,
|
|
130
|
+
fade = props.fade,
|
|
131
|
+
beatFade = props.beatFade,
|
|
132
|
+
bounce = props.bounce,
|
|
133
|
+
shake = props.shake,
|
|
134
|
+
flash = props.flash,
|
|
135
|
+
spin = props.spin,
|
|
136
|
+
spinPulse = props.spinPulse,
|
|
137
|
+
spinReverse = props.spinReverse,
|
|
138
|
+
pulse = props.pulse,
|
|
139
|
+
fixedWidth = props.fixedWidth,
|
|
140
|
+
inverse = props.inverse,
|
|
141
|
+
border = props.border,
|
|
142
|
+
listItem = props.listItem,
|
|
143
|
+
flip = props.flip,
|
|
144
|
+
size = props.size,
|
|
145
|
+
rotation = props.rotation,
|
|
146
|
+
pull = props.pull; // map of CSS class names to properties
|
|
147
|
+
|
|
148
|
+
var classes = (_classes = {
|
|
149
|
+
'fa-beat': beat,
|
|
150
|
+
'fa-fade': fade,
|
|
151
|
+
'fa-beat-fade': beatFade,
|
|
152
|
+
'fa-bounce': bounce,
|
|
153
|
+
'fa-shake': shake,
|
|
154
|
+
'fa-flash': flash,
|
|
155
|
+
'fa-spin': spin,
|
|
156
|
+
'fa-spin-reverse': spinReverse,
|
|
157
|
+
'fa-spin-pulse': spinPulse,
|
|
158
|
+
'fa-pulse': pulse,
|
|
159
|
+
'fa-fw': fixedWidth,
|
|
160
|
+
'fa-inverse': inverse,
|
|
161
|
+
'fa-border': border,
|
|
162
|
+
'fa-li': listItem,
|
|
163
|
+
'fa-flip': flip === true,
|
|
164
|
+
'fa-flip-horizontal': flip === 'horizontal' || flip === 'both',
|
|
165
|
+
'fa-flip-vertical': flip === 'vertical' || flip === 'both'
|
|
166
|
+
}, _defineProperty(_classes, "fa-".concat(size), typeof size !== 'undefined' && size !== null), _defineProperty(_classes, "fa-rotate-".concat(rotation), typeof rotation !== 'undefined' && rotation !== null && rotation !== 0), _defineProperty(_classes, "fa-pull-".concat(pull), typeof pull !== 'undefined' && pull !== null), _defineProperty(_classes, 'fa-swap-opacity', props.swapOpacity), _classes); // map over all the keys in the classes object
|
|
167
|
+
// return an array of the keys where the value for the key is not null
|
|
168
|
+
|
|
169
|
+
return Object.keys(classes).map(function (key) {
|
|
170
|
+
return classes[key] ? key : null;
|
|
171
|
+
}).filter(function (key) {
|
|
172
|
+
return key;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Camelize taken from humps
|
|
177
|
+
// humps is copyright © 2012+ Dom Christie
|
|
178
|
+
// Released under the MIT license.
|
|
179
|
+
// Performant way to determine if object coerces to a number
|
|
180
|
+
function _isNumerical(obj) {
|
|
181
|
+
obj = obj - 0; // eslint-disable-next-line no-self-compare
|
|
182
|
+
|
|
183
|
+
return obj === obj;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function camelize(string) {
|
|
187
|
+
if (_isNumerical(string)) {
|
|
188
|
+
return string;
|
|
189
|
+
} // eslint-disable-next-line no-useless-escape
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
|
|
193
|
+
return chr ? chr.toUpperCase() : '';
|
|
194
|
+
}); // Ensure 1st char is always lowercase
|
|
195
|
+
|
|
196
|
+
return string.substr(0, 1).toLowerCase() + string.substr(1);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var _excluded$1 = ["style"];
|
|
200
|
+
|
|
201
|
+
function capitalize(val) {
|
|
202
|
+
return val.charAt(0).toUpperCase() + val.slice(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function styleToObject(style) {
|
|
206
|
+
return style.split(';').map(function (s) {
|
|
207
|
+
return s.trim();
|
|
208
|
+
}).filter(function (s) {
|
|
209
|
+
return s;
|
|
210
|
+
}).reduce(function (acc, pair) {
|
|
211
|
+
var i = pair.indexOf(':');
|
|
212
|
+
var prop = camelize(pair.slice(0, i));
|
|
213
|
+
var value = pair.slice(i + 1).trim();
|
|
214
|
+
prop.startsWith('webkit') ? acc[capitalize(prop)] = value : acc[prop] = value;
|
|
215
|
+
return acc;
|
|
216
|
+
}, {});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function convert(createElement, element) {
|
|
220
|
+
var extraProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
221
|
+
|
|
222
|
+
if (typeof element === 'string') {
|
|
223
|
+
return element;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
var children = (element.children || []).map(function (child) {
|
|
227
|
+
return convert(createElement, child);
|
|
228
|
+
});
|
|
229
|
+
/* eslint-disable dot-notation */
|
|
230
|
+
|
|
231
|
+
var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) {
|
|
232
|
+
var val = element.attributes[key];
|
|
233
|
+
|
|
234
|
+
switch (key) {
|
|
235
|
+
case 'class':
|
|
236
|
+
acc.attrs['className'] = val;
|
|
237
|
+
delete element.attributes['class'];
|
|
238
|
+
break;
|
|
239
|
+
|
|
240
|
+
case 'style':
|
|
241
|
+
acc.attrs['style'] = styleToObject(val);
|
|
242
|
+
break;
|
|
243
|
+
|
|
244
|
+
default:
|
|
245
|
+
if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0) {
|
|
246
|
+
acc.attrs[key.toLowerCase()] = val;
|
|
247
|
+
} else {
|
|
248
|
+
acc.attrs[camelize(key)] = val;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return acc;
|
|
254
|
+
}, {
|
|
255
|
+
attrs: {}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
var _extraProps$style = extraProps.style,
|
|
259
|
+
existingStyle = _extraProps$style === void 0 ? {} : _extraProps$style,
|
|
260
|
+
remaining = _objectWithoutProperties(extraProps, _excluded$1);
|
|
261
|
+
|
|
262
|
+
mixins.attrs['style'] = _objectSpread2(_objectSpread2({}, mixins.attrs['style']), existingStyle);
|
|
263
|
+
/* eslint-enable */
|
|
264
|
+
|
|
265
|
+
return createElement.apply(void 0, [element.tag, _objectSpread2(_objectSpread2({}, mixins.attrs), remaining)].concat(_toConsumableArray(children)));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
var PRODUCTION = false;
|
|
269
|
+
|
|
270
|
+
try {
|
|
271
|
+
PRODUCTION = process.env.NODE_ENV === 'production';
|
|
272
|
+
} catch (e) {}
|
|
273
|
+
|
|
274
|
+
function log () {
|
|
275
|
+
if (!PRODUCTION && console && typeof console.error === 'function') {
|
|
276
|
+
var _console;
|
|
277
|
+
|
|
278
|
+
(_console = console).error.apply(_console, arguments);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function normalizeIconArgs(icon) {
|
|
283
|
+
// this has everything that it needs to be rendered which means it was probably imported
|
|
284
|
+
// directly from an icon svg package
|
|
285
|
+
if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName && icon.icon) {
|
|
286
|
+
return icon;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (parse.icon) {
|
|
290
|
+
return parse.icon(icon);
|
|
291
|
+
} // if the icon is null, there's nothing to do
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
if (icon === null) {
|
|
295
|
+
return null;
|
|
296
|
+
} // if the icon is an object and has a prefix and an icon name, return it
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName) {
|
|
300
|
+
return icon;
|
|
301
|
+
} // if it's an array with length of two
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
if (Array.isArray(icon) && icon.length === 2) {
|
|
305
|
+
// use the first item as prefix, second as icon name
|
|
306
|
+
return {
|
|
307
|
+
prefix: icon[0],
|
|
308
|
+
iconName: icon[1]
|
|
309
|
+
};
|
|
310
|
+
} // if it's a string, use it as the icon name
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
if (typeof icon === 'string') {
|
|
314
|
+
return {
|
|
315
|
+
prefix: 'fas',
|
|
316
|
+
iconName: icon
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// creates an object with a key of key
|
|
322
|
+
// and a value of value
|
|
323
|
+
// if certain conditions are met
|
|
324
|
+
function objectWithKey(key, value) {
|
|
325
|
+
// if the value is a non-empty array
|
|
326
|
+
// or it's not an array but it is truthy
|
|
327
|
+
// then create the object with the key and the value
|
|
328
|
+
// if not, return an empty array
|
|
329
|
+
return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? _defineProperty({}, key, value) : {};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
var _excluded = ["forwardedRef"];
|
|
333
|
+
function FontAwesomeIcon(_ref) {
|
|
334
|
+
var forwardedRef = _ref.forwardedRef,
|
|
335
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
336
|
+
|
|
337
|
+
var iconArgs = props.icon,
|
|
338
|
+
maskArgs = props.mask,
|
|
339
|
+
symbol = props.symbol,
|
|
340
|
+
className = props.className,
|
|
341
|
+
title = props.title,
|
|
342
|
+
titleId = props.titleId,
|
|
343
|
+
maskId = props.maskId;
|
|
344
|
+
var iconLookup = normalizeIconArgs(iconArgs);
|
|
345
|
+
var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(props)), _toConsumableArray(className.split(' '))));
|
|
346
|
+
var transform = objectWithKey('transform', typeof props.transform === 'string' ? parse.transform(props.transform) : props.transform);
|
|
347
|
+
var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
|
|
348
|
+
var renderedIcon = icon(iconLookup, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, classes), transform), mask), {}, {
|
|
349
|
+
symbol: symbol,
|
|
350
|
+
title: title,
|
|
351
|
+
titleId: titleId,
|
|
352
|
+
maskId: maskId
|
|
353
|
+
}));
|
|
354
|
+
|
|
355
|
+
if (!renderedIcon) {
|
|
356
|
+
log('Could not find icon', iconLookup);
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
var abstract = renderedIcon.abstract;
|
|
361
|
+
var extraProps = {
|
|
362
|
+
ref: forwardedRef
|
|
363
|
+
};
|
|
364
|
+
Object.keys(props).forEach(function (key) {
|
|
365
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
366
|
+
if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) {
|
|
367
|
+
extraProps[key] = props[key];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
return convertCurry(abstract[0], extraProps);
|
|
371
|
+
}
|
|
372
|
+
FontAwesomeIcon.displayName = 'FontAwesomeIcon';
|
|
373
|
+
FontAwesomeIcon.propTypes = {
|
|
374
|
+
beat: PropTypes.bool,
|
|
375
|
+
border: PropTypes.bool,
|
|
376
|
+
beatFade: PropTypes.bool,
|
|
377
|
+
bounce: PropTypes.bool,
|
|
378
|
+
className: PropTypes.string,
|
|
379
|
+
fade: PropTypes.bool,
|
|
380
|
+
flash: PropTypes.bool,
|
|
381
|
+
mask: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
|
|
382
|
+
maskId: PropTypes.string,
|
|
383
|
+
fixedWidth: PropTypes.bool,
|
|
384
|
+
inverse: PropTypes.bool,
|
|
385
|
+
flip: PropTypes.oneOf([true, false, 'horizontal', 'vertical', 'both']),
|
|
386
|
+
icon: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
|
|
387
|
+
listItem: PropTypes.bool,
|
|
388
|
+
pull: PropTypes.oneOf(['right', 'left']),
|
|
389
|
+
pulse: PropTypes.bool,
|
|
390
|
+
rotation: PropTypes.oneOf([0, 90, 180, 270]),
|
|
391
|
+
shake: PropTypes.bool,
|
|
392
|
+
size: PropTypes.oneOf(['2xs', 'xs', 'sm', 'lg', 'xl', '2xl', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x']),
|
|
393
|
+
spin: PropTypes.bool,
|
|
394
|
+
spinPulse: PropTypes.bool,
|
|
395
|
+
spinReverse: PropTypes.bool,
|
|
396
|
+
symbol: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
397
|
+
title: PropTypes.string,
|
|
398
|
+
titleId: PropTypes.string,
|
|
399
|
+
transform: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
400
|
+
swapOpacity: PropTypes.bool
|
|
401
|
+
};
|
|
402
|
+
FontAwesomeIcon.defaultProps = {
|
|
403
|
+
border: false,
|
|
404
|
+
className: '',
|
|
405
|
+
mask: null,
|
|
406
|
+
maskId: null,
|
|
407
|
+
fixedWidth: false,
|
|
408
|
+
inverse: false,
|
|
409
|
+
flip: false,
|
|
410
|
+
icon: null,
|
|
411
|
+
listItem: false,
|
|
412
|
+
pull: null,
|
|
413
|
+
pulse: false,
|
|
414
|
+
rotation: null,
|
|
415
|
+
size: null,
|
|
416
|
+
spin: false,
|
|
417
|
+
spinPulse: false,
|
|
418
|
+
spinReverse: false,
|
|
419
|
+
beat: false,
|
|
420
|
+
fade: false,
|
|
421
|
+
beatFade: false,
|
|
422
|
+
bounce: false,
|
|
423
|
+
shake: false,
|
|
424
|
+
symbol: false,
|
|
425
|
+
title: '',
|
|
426
|
+
titleId: null,
|
|
427
|
+
transform: null,
|
|
428
|
+
swapOpacity: false
|
|
429
|
+
};
|
|
430
|
+
var convertCurry = convert.bind(null, React.createElement);
|
|
431
|
+
|
|
432
|
+
export { FontAwesomeIcon };
|
package/index.js
ADDED
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined'
|
|
3
|
+
? factory(
|
|
4
|
+
exports,
|
|
5
|
+
require('../fontawesome-svg-core'),
|
|
6
|
+
require('prop-types'),
|
|
7
|
+
require('react'),
|
|
8
|
+
)
|
|
9
|
+
: typeof define === 'function' && define.amd
|
|
10
|
+
? define(['exports', '../fontawesome-svg-core', 'prop-types', 'react'], factory)
|
|
11
|
+
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
|
|
12
|
+
factory(
|
|
13
|
+
(global['react-fontawesome'] = {}),
|
|
14
|
+
global.FontAwesome,
|
|
15
|
+
global.PropTypes,
|
|
16
|
+
global.React,
|
|
17
|
+
));
|
|
18
|
+
})(this, function (exports, fontawesomeSvgCore, PropTypes, React) {
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
function _interopDefaultLegacy(e) {
|
|
22
|
+
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var PropTypes__default = /*#__PURE__*/ _interopDefaultLegacy(PropTypes);
|
|
26
|
+
var React__default = /*#__PURE__*/ _interopDefaultLegacy(React);
|
|
27
|
+
|
|
28
|
+
function ownKeys(object, enumerableOnly) {
|
|
29
|
+
var keys = Object.keys(object);
|
|
30
|
+
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
enumerableOnly &&
|
|
34
|
+
(symbols = symbols.filter(function (sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
})),
|
|
37
|
+
keys.push.apply(keys, symbols);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _objectSpread2(target) {
|
|
44
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
45
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
46
|
+
i % 2
|
|
47
|
+
? ownKeys(Object(source), !0).forEach(function (key) {
|
|
48
|
+
_defineProperty(target, key, source[key]);
|
|
49
|
+
})
|
|
50
|
+
: Object.getOwnPropertyDescriptors
|
|
51
|
+
? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source))
|
|
52
|
+
: ownKeys(Object(source)).forEach(function (key) {
|
|
53
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return target;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _typeof(obj) {
|
|
61
|
+
'@babel/helpers - typeof';
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
(_typeof =
|
|
65
|
+
'function' === typeof Symbol && 'symbol' === typeof Symbol.iterator
|
|
66
|
+
? function (obj) {
|
|
67
|
+
return typeof obj;
|
|
68
|
+
}
|
|
69
|
+
: function (obj) {
|
|
70
|
+
return obj &&
|
|
71
|
+
'function' === typeof Symbol &&
|
|
72
|
+
obj.constructor === Symbol &&
|
|
73
|
+
obj !== Symbol.prototype
|
|
74
|
+
? 'symbol'
|
|
75
|
+
: typeof obj;
|
|
76
|
+
}),
|
|
77
|
+
_typeof(obj)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function _defineProperty(obj, key, value) {
|
|
82
|
+
if (key in obj) {
|
|
83
|
+
Object.defineProperty(obj, key, {
|
|
84
|
+
value: value,
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
obj[key] = value;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return obj;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
97
|
+
if (source == null) {
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
var target = {};
|
|
101
|
+
var sourceKeys = Object.keys(source);
|
|
102
|
+
var key, i;
|
|
103
|
+
|
|
104
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
105
|
+
key = sourceKeys[i];
|
|
106
|
+
if (excluded.indexOf(key) >= 0) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
target[key] = source[key];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return target;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function _objectWithoutProperties(source, excluded) {
|
|
116
|
+
if (source == null) {
|
|
117
|
+
return {};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
121
|
+
|
|
122
|
+
var key, i;
|
|
123
|
+
|
|
124
|
+
if (Object.getOwnPropertySymbols) {
|
|
125
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
126
|
+
|
|
127
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
128
|
+
key = sourceSymbolKeys[i];
|
|
129
|
+
if (excluded.indexOf(key) >= 0) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
target[key] = source[key];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return target;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function _toConsumableArray(arr) {
|
|
143
|
+
return (
|
|
144
|
+
_arrayWithoutHoles(arr) ||
|
|
145
|
+
_iterableToArray(arr) ||
|
|
146
|
+
_unsupportedIterableToArray(arr) ||
|
|
147
|
+
_nonIterableSpread()
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function _arrayWithoutHoles(arr) {
|
|
152
|
+
if (Array.isArray(arr)) {
|
|
153
|
+
return _arrayLikeToArray(arr);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function _iterableToArray(iter) {
|
|
158
|
+
if (
|
|
159
|
+
(typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
|
|
160
|
+
iter['@@iterator'] != null
|
|
161
|
+
) {
|
|
162
|
+
return Array.from(iter);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
167
|
+
if (!o) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (typeof o === 'string') {
|
|
171
|
+
return _arrayLikeToArray(o, minLen);
|
|
172
|
+
}
|
|
173
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
174
|
+
if (n === 'Object' && o.constructor) {
|
|
175
|
+
n = o.constructor.name;
|
|
176
|
+
}
|
|
177
|
+
if (n === 'Map' || n === 'Set') {
|
|
178
|
+
return Array.from(o);
|
|
179
|
+
}
|
|
180
|
+
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) {
|
|
181
|
+
return _arrayLikeToArray(o, minLen);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function _arrayLikeToArray(arr, len) {
|
|
186
|
+
if (len == null || len > arr.length) {
|
|
187
|
+
len = arr.length;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
191
|
+
arr2[i] = arr[i];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return arr2;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function _nonIterableSpread() {
|
|
198
|
+
throw new TypeError(
|
|
199
|
+
'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Get CSS class list from a props object
|
|
204
|
+
function classList(props) {
|
|
205
|
+
var _classes;
|
|
206
|
+
|
|
207
|
+
var beat = props.beat,
|
|
208
|
+
fade = props.fade,
|
|
209
|
+
beatFade = props.beatFade,
|
|
210
|
+
bounce = props.bounce,
|
|
211
|
+
shake = props.shake,
|
|
212
|
+
flash = props.flash,
|
|
213
|
+
spin = props.spin,
|
|
214
|
+
spinPulse = props.spinPulse,
|
|
215
|
+
spinReverse = props.spinReverse,
|
|
216
|
+
pulse = props.pulse,
|
|
217
|
+
fixedWidth = props.fixedWidth,
|
|
218
|
+
inverse = props.inverse,
|
|
219
|
+
border = props.border,
|
|
220
|
+
listItem = props.listItem,
|
|
221
|
+
flip = props.flip,
|
|
222
|
+
size = props.size,
|
|
223
|
+
rotation = props.rotation,
|
|
224
|
+
pull = props.pull; // map of CSS class names to properties
|
|
225
|
+
|
|
226
|
+
var classes =
|
|
227
|
+
((_classes = {
|
|
228
|
+
'fa-beat': beat,
|
|
229
|
+
'fa-fade': fade,
|
|
230
|
+
'fa-beat-fade': beatFade,
|
|
231
|
+
'fa-bounce': bounce,
|
|
232
|
+
'fa-shake': shake,
|
|
233
|
+
'fa-flash': flash,
|
|
234
|
+
'fa-spin': spin,
|
|
235
|
+
'fa-spin-reverse': spinReverse,
|
|
236
|
+
'fa-spin-pulse': spinPulse,
|
|
237
|
+
'fa-pulse': pulse,
|
|
238
|
+
'fa-fw': fixedWidth,
|
|
239
|
+
'fa-inverse': inverse,
|
|
240
|
+
'fa-border': border,
|
|
241
|
+
'fa-li': listItem,
|
|
242
|
+
'fa-flip': flip === true,
|
|
243
|
+
'fa-flip-horizontal': flip === 'horizontal' || flip === 'both',
|
|
244
|
+
'fa-flip-vertical': flip === 'vertical' || flip === 'both',
|
|
245
|
+
}),
|
|
246
|
+
_defineProperty(_classes, 'fa-'.concat(size), typeof size !== 'undefined' && size !== null),
|
|
247
|
+
_defineProperty(
|
|
248
|
+
_classes,
|
|
249
|
+
'fa-rotate-'.concat(rotation),
|
|
250
|
+
typeof rotation !== 'undefined' && rotation !== null && rotation !== 0,
|
|
251
|
+
),
|
|
252
|
+
_defineProperty(
|
|
253
|
+
_classes,
|
|
254
|
+
'fa-pull-'.concat(pull),
|
|
255
|
+
typeof pull !== 'undefined' && pull !== null,
|
|
256
|
+
),
|
|
257
|
+
_defineProperty(_classes, 'fa-swap-opacity', props.swapOpacity),
|
|
258
|
+
_classes); // map over all the keys in the classes object
|
|
259
|
+
// return an array of the keys where the value for the key is not null
|
|
260
|
+
|
|
261
|
+
return Object.keys(classes)
|
|
262
|
+
.map(function (key) {
|
|
263
|
+
return classes[key] ? key : null;
|
|
264
|
+
})
|
|
265
|
+
.filter(function (key) {
|
|
266
|
+
return key;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Camelize taken from humps
|
|
271
|
+
// humps is copyright © 2012+ Dom Christie
|
|
272
|
+
// Released under the MIT license.
|
|
273
|
+
// Performant way to determine if object coerces to a number
|
|
274
|
+
function _isNumerical(obj) {
|
|
275
|
+
obj = obj - 0; // eslint-disable-next-line no-self-compare
|
|
276
|
+
|
|
277
|
+
return obj === obj;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function camelize(string) {
|
|
281
|
+
if (_isNumerical(string)) {
|
|
282
|
+
return string;
|
|
283
|
+
} // eslint-disable-next-line no-useless-escape
|
|
284
|
+
|
|
285
|
+
string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
|
|
286
|
+
return chr ? chr.toUpperCase() : '';
|
|
287
|
+
}); // Ensure 1st char is always lowercase
|
|
288
|
+
|
|
289
|
+
return string.substr(0, 1).toLowerCase() + string.substr(1);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
var _excluded$1 = ['style'];
|
|
293
|
+
|
|
294
|
+
function capitalize(val) {
|
|
295
|
+
return val.charAt(0).toUpperCase() + val.slice(1);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function styleToObject(style) {
|
|
299
|
+
return style
|
|
300
|
+
.split(';')
|
|
301
|
+
.map(function (s) {
|
|
302
|
+
return s.trim();
|
|
303
|
+
})
|
|
304
|
+
.filter(function (s) {
|
|
305
|
+
return s;
|
|
306
|
+
})
|
|
307
|
+
.reduce(function (acc, pair) {
|
|
308
|
+
var i = pair.indexOf(':');
|
|
309
|
+
var prop = camelize(pair.slice(0, i));
|
|
310
|
+
var value = pair.slice(i + 1).trim();
|
|
311
|
+
prop.startsWith('webkit') ? (acc[capitalize(prop)] = value) : (acc[prop] = value);
|
|
312
|
+
return acc;
|
|
313
|
+
}, {});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function convert(createElement, element) {
|
|
317
|
+
var extraProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
318
|
+
|
|
319
|
+
if (typeof element === 'string') {
|
|
320
|
+
return element;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
var children = (element.children || []).map(function (child) {
|
|
324
|
+
return convert(createElement, child);
|
|
325
|
+
});
|
|
326
|
+
/* eslint-disable dot-notation */
|
|
327
|
+
|
|
328
|
+
var mixins = Object.keys(element.attributes || {}).reduce(
|
|
329
|
+
function (acc, key) {
|
|
330
|
+
var val = element.attributes[key];
|
|
331
|
+
|
|
332
|
+
switch (key) {
|
|
333
|
+
case 'class':
|
|
334
|
+
acc.attrs['className'] = val;
|
|
335
|
+
delete element.attributes['class'];
|
|
336
|
+
break;
|
|
337
|
+
|
|
338
|
+
case 'style':
|
|
339
|
+
acc.attrs['style'] = styleToObject(val);
|
|
340
|
+
break;
|
|
341
|
+
|
|
342
|
+
default:
|
|
343
|
+
if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0) {
|
|
344
|
+
acc.attrs[key.toLowerCase()] = val;
|
|
345
|
+
} else {
|
|
346
|
+
acc.attrs[camelize(key)] = val;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return acc;
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
attrs: {},
|
|
354
|
+
},
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
var _extraProps$style = extraProps.style,
|
|
358
|
+
existingStyle = _extraProps$style === void 0 ? {} : _extraProps$style,
|
|
359
|
+
remaining = _objectWithoutProperties(extraProps, _excluded$1);
|
|
360
|
+
|
|
361
|
+
mixins.attrs['style'] = _objectSpread2(
|
|
362
|
+
_objectSpread2({}, mixins.attrs['style']),
|
|
363
|
+
existingStyle,
|
|
364
|
+
);
|
|
365
|
+
/* eslint-enable */
|
|
366
|
+
|
|
367
|
+
return createElement.apply(
|
|
368
|
+
void 0,
|
|
369
|
+
[element.tag, _objectSpread2(_objectSpread2({}, mixins.attrs), remaining)].concat(
|
|
370
|
+
_toConsumableArray(children),
|
|
371
|
+
),
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
var PRODUCTION = false;
|
|
376
|
+
|
|
377
|
+
try {
|
|
378
|
+
PRODUCTION = process.env.NODE_ENV === 'production';
|
|
379
|
+
} catch (e) {}
|
|
380
|
+
|
|
381
|
+
function log() {
|
|
382
|
+
if (!PRODUCTION && console && typeof console.error === 'function') {
|
|
383
|
+
var _console;
|
|
384
|
+
|
|
385
|
+
(_console = console).error.apply(_console, arguments);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function normalizeIconArgs(icon) {
|
|
390
|
+
// this has everything that it needs to be rendered which means it was probably imported
|
|
391
|
+
// directly from an icon svg package
|
|
392
|
+
if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName && icon.icon) {
|
|
393
|
+
return icon;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (fontawesomeSvgCore.parse.icon) {
|
|
397
|
+
return fontawesomeSvgCore.parse.icon(icon);
|
|
398
|
+
} // if the icon is null, there's nothing to do
|
|
399
|
+
|
|
400
|
+
if (icon === null) {
|
|
401
|
+
return null;
|
|
402
|
+
} // if the icon is an object and has a prefix and an icon name, return it
|
|
403
|
+
|
|
404
|
+
if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName) {
|
|
405
|
+
return icon;
|
|
406
|
+
} // if it's an array with length of two
|
|
407
|
+
|
|
408
|
+
if (Array.isArray(icon) && icon.length === 2) {
|
|
409
|
+
// use the first item as prefix, second as icon name
|
|
410
|
+
return {
|
|
411
|
+
prefix: icon[0],
|
|
412
|
+
iconName: icon[1],
|
|
413
|
+
};
|
|
414
|
+
} // if it's a string, use it as the icon name
|
|
415
|
+
|
|
416
|
+
if (typeof icon === 'string') {
|
|
417
|
+
return {
|
|
418
|
+
prefix: 'fas',
|
|
419
|
+
iconName: icon,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// creates an object with a key of key
|
|
425
|
+
// and a value of value
|
|
426
|
+
// if certain conditions are met
|
|
427
|
+
function objectWithKey(key, value) {
|
|
428
|
+
// if the value is a non-empty array
|
|
429
|
+
// or it's not an array but it is truthy
|
|
430
|
+
// then create the object with the key and the value
|
|
431
|
+
// if not, return an empty array
|
|
432
|
+
return (Array.isArray(value) && value.length > 0) || (!Array.isArray(value) && value)
|
|
433
|
+
? _defineProperty({}, key, value)
|
|
434
|
+
: {};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
var _excluded = ['forwardedRef'];
|
|
438
|
+
function FontAwesomeIcon(_ref) {
|
|
439
|
+
var forwardedRef = _ref.forwardedRef,
|
|
440
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
441
|
+
|
|
442
|
+
var iconArgs = props.icon,
|
|
443
|
+
maskArgs = props.mask,
|
|
444
|
+
symbol = props.symbol,
|
|
445
|
+
className = props.className,
|
|
446
|
+
title = props.title,
|
|
447
|
+
titleId = props.titleId,
|
|
448
|
+
maskId = props.maskId;
|
|
449
|
+
var iconLookup = normalizeIconArgs(iconArgs);
|
|
450
|
+
var classes = objectWithKey(
|
|
451
|
+
'classes',
|
|
452
|
+
[].concat(_toConsumableArray(classList(props)), _toConsumableArray(className.split(' '))),
|
|
453
|
+
);
|
|
454
|
+
var transform = objectWithKey(
|
|
455
|
+
'transform',
|
|
456
|
+
typeof props.transform === 'string'
|
|
457
|
+
? fontawesomeSvgCore.parse.transform(props.transform)
|
|
458
|
+
: props.transform,
|
|
459
|
+
);
|
|
460
|
+
var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
|
|
461
|
+
var renderedIcon = fontawesomeSvgCore.icon(
|
|
462
|
+
iconLookup,
|
|
463
|
+
_objectSpread2(
|
|
464
|
+
_objectSpread2(_objectSpread2(_objectSpread2({}, classes), transform), mask),
|
|
465
|
+
{},
|
|
466
|
+
{
|
|
467
|
+
symbol: symbol,
|
|
468
|
+
title: title,
|
|
469
|
+
titleId: titleId,
|
|
470
|
+
maskId: maskId,
|
|
471
|
+
},
|
|
472
|
+
),
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
if (!renderedIcon) {
|
|
476
|
+
log('Could not find icon', iconLookup);
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
var abstract = renderedIcon.abstract;
|
|
481
|
+
var extraProps = {
|
|
482
|
+
ref: forwardedRef,
|
|
483
|
+
};
|
|
484
|
+
Object.keys(props).forEach(function (key) {
|
|
485
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
486
|
+
if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) {
|
|
487
|
+
extraProps[key] = props[key];
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
return convertCurry(abstract[0], extraProps);
|
|
491
|
+
}
|
|
492
|
+
FontAwesomeIcon.displayName = 'FontAwesomeIcon';
|
|
493
|
+
FontAwesomeIcon.propTypes = {
|
|
494
|
+
beat: PropTypes__default['default'].bool,
|
|
495
|
+
border: PropTypes__default['default'].bool,
|
|
496
|
+
beatFade: PropTypes__default['default'].bool,
|
|
497
|
+
bounce: PropTypes__default['default'].bool,
|
|
498
|
+
className: PropTypes__default['default'].string,
|
|
499
|
+
fade: PropTypes__default['default'].bool,
|
|
500
|
+
flash: PropTypes__default['default'].bool,
|
|
501
|
+
mask: PropTypes__default['default'].oneOfType([
|
|
502
|
+
PropTypes__default['default'].object,
|
|
503
|
+
PropTypes__default['default'].array,
|
|
504
|
+
PropTypes__default['default'].string,
|
|
505
|
+
]),
|
|
506
|
+
maskId: PropTypes__default['default'].string,
|
|
507
|
+
fixedWidth: PropTypes__default['default'].bool,
|
|
508
|
+
inverse: PropTypes__default['default'].bool,
|
|
509
|
+
flip: PropTypes__default['default'].oneOf([true, false, 'horizontal', 'vertical', 'both']),
|
|
510
|
+
icon: PropTypes__default['default'].oneOfType([
|
|
511
|
+
PropTypes__default['default'].object,
|
|
512
|
+
PropTypes__default['default'].array,
|
|
513
|
+
PropTypes__default['default'].string,
|
|
514
|
+
]),
|
|
515
|
+
listItem: PropTypes__default['default'].bool,
|
|
516
|
+
pull: PropTypes__default['default'].oneOf(['right', 'left']),
|
|
517
|
+
pulse: PropTypes__default['default'].bool,
|
|
518
|
+
rotation: PropTypes__default['default'].oneOf([0, 90, 180, 270]),
|
|
519
|
+
shake: PropTypes__default['default'].bool,
|
|
520
|
+
size: PropTypes__default['default'].oneOf([
|
|
521
|
+
'2xs',
|
|
522
|
+
'xs',
|
|
523
|
+
'sm',
|
|
524
|
+
'lg',
|
|
525
|
+
'xl',
|
|
526
|
+
'2xl',
|
|
527
|
+
'1x',
|
|
528
|
+
'2x',
|
|
529
|
+
'3x',
|
|
530
|
+
'4x',
|
|
531
|
+
'5x',
|
|
532
|
+
'6x',
|
|
533
|
+
'7x',
|
|
534
|
+
'8x',
|
|
535
|
+
'9x',
|
|
536
|
+
'10x',
|
|
537
|
+
]),
|
|
538
|
+
spin: PropTypes__default['default'].bool,
|
|
539
|
+
spinPulse: PropTypes__default['default'].bool,
|
|
540
|
+
spinReverse: PropTypes__default['default'].bool,
|
|
541
|
+
symbol: PropTypes__default['default'].oneOfType([
|
|
542
|
+
PropTypes__default['default'].bool,
|
|
543
|
+
PropTypes__default['default'].string,
|
|
544
|
+
]),
|
|
545
|
+
title: PropTypes__default['default'].string,
|
|
546
|
+
titleId: PropTypes__default['default'].string,
|
|
547
|
+
transform: PropTypes__default['default'].oneOfType([
|
|
548
|
+
PropTypes__default['default'].string,
|
|
549
|
+
PropTypes__default['default'].object,
|
|
550
|
+
]),
|
|
551
|
+
swapOpacity: PropTypes__default['default'].bool,
|
|
552
|
+
};
|
|
553
|
+
FontAwesomeIcon.defaultProps = {
|
|
554
|
+
border: false,
|
|
555
|
+
className: '',
|
|
556
|
+
mask: null,
|
|
557
|
+
maskId: null,
|
|
558
|
+
fixedWidth: false,
|
|
559
|
+
inverse: false,
|
|
560
|
+
flip: false,
|
|
561
|
+
icon: null,
|
|
562
|
+
listItem: false,
|
|
563
|
+
pull: null,
|
|
564
|
+
pulse: false,
|
|
565
|
+
rotation: null,
|
|
566
|
+
size: null,
|
|
567
|
+
spin: false,
|
|
568
|
+
spinPulse: false,
|
|
569
|
+
spinReverse: false,
|
|
570
|
+
beat: false,
|
|
571
|
+
fade: false,
|
|
572
|
+
beatFade: false,
|
|
573
|
+
bounce: false,
|
|
574
|
+
shake: false,
|
|
575
|
+
symbol: false,
|
|
576
|
+
title: '',
|
|
577
|
+
titleId: null,
|
|
578
|
+
transform: null,
|
|
579
|
+
swapOpacity: false,
|
|
580
|
+
};
|
|
581
|
+
var convertCurry = convert.bind(null, React__default['default'].createElement);
|
|
582
|
+
|
|
583
|
+
exports.FontAwesomeIcon = FontAwesomeIcon;
|
|
584
|
+
|
|
585
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
586
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@medely/react-fontawesome",
|
|
3
|
+
"description": "Official React component for Font Awesome 5",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "index.es.js",
|
|
7
|
+
"jsnext:main": "index.es.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"homepage": "https://github.com/FortAwesome/react-fontawesome",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/FortAwesome/react-fontawesome.git"
|
|
13
|
+
},
|
|
14
|
+
"contributors": [
|
|
15
|
+
"Travis Chase <travis@fontawesome.com>",
|
|
16
|
+
"Rob Madole <rob@fontawesome.com>",
|
|
17
|
+
"Mike Wilkerson <mwilkerson@gmail.com>",
|
|
18
|
+
"Nate Radebaugh <github.com/NateRadebaugh>",
|
|
19
|
+
"Kirk Ross <github.com/kirkbross>",
|
|
20
|
+
"Prateek Goel <github.com/prateekgoel>",
|
|
21
|
+
"Naor Torgeman <github.com/naortor>",
|
|
22
|
+
"Matthew Hand <github.com/mmhand123>",
|
|
23
|
+
"Calvin Freitas <github.com/calvinf>",
|
|
24
|
+
"Bill Parrott <github.com/chimericdream>",
|
|
25
|
+
"Mike Lynch <github.com/baelec>",
|
|
26
|
+
"Lukáš Rod <github.com/rodlukas>",
|
|
27
|
+
"Proudust <github.com/proudust>",
|
|
28
|
+
"Tiago Sousa <github.com/TiagoPortfolio>",
|
|
29
|
+
"Alexey Victorov <github.com/AliMamed>"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "rollup -c rollup.config.js",
|
|
34
|
+
"dist": "cross-env NODE_ENV=production npm run build",
|
|
35
|
+
"lint": "eslint src",
|
|
36
|
+
"prettier": "pretty-quick --pattern src/** --staged",
|
|
37
|
+
"test": "jest --silent",
|
|
38
|
+
"install.5": "npm --no-save install ../fontawesome-svg-core@1.2.x @fortawesome/free-solid-svg-icons@5.x",
|
|
39
|
+
"install.6": "npm --no-save install ../fontawesome-svg-core@6.x @fortawesome/free-solid-svg-icons@6.x",
|
|
40
|
+
"clean": "rm -f index.js && rm -f index.es.js"
|
|
41
|
+
},
|
|
42
|
+
"lint-staged": {
|
|
43
|
+
"README.md": [
|
|
44
|
+
"markdown-toc -i",
|
|
45
|
+
"git add README.md"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@medely/fontawesome-svg-core": "~1 || ~6",
|
|
50
|
+
"react": ">=16.x"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@babel/core": "^7.16.7",
|
|
54
|
+
"@babel/plugin-external-helpers": "^7.16.7",
|
|
55
|
+
"@babel/preset-env": "^7.16.8",
|
|
56
|
+
"@babel/preset-react": "^7.16.7",
|
|
57
|
+
"@babel/preset-stage-3": "^7.8.3",
|
|
58
|
+
"@medely/fontawesome-svg-core": "^0.0.1",
|
|
59
|
+
"@fortawesome/free-solid-svg-icons": "^5.15.4",
|
|
60
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
61
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
62
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
63
|
+
"@types/react": "^17.0.38",
|
|
64
|
+
"babel-eslint": "^10.0.3",
|
|
65
|
+
"babel-jest": "^27.4.6",
|
|
66
|
+
"browserslist": "^4.19.1",
|
|
67
|
+
"caniuse-lite": "^1.0.30001299",
|
|
68
|
+
"cross-env": "^7.0.3",
|
|
69
|
+
"eslint": "^6.7.2",
|
|
70
|
+
"eslint-config-standard": "^14.1.0",
|
|
71
|
+
"eslint-plugin-compat": "^3.3.0",
|
|
72
|
+
"eslint-plugin-import": "^2.18.2",
|
|
73
|
+
"eslint-plugin-jest": "^23.1.1",
|
|
74
|
+
"eslint-plugin-node": "^10.0.0",
|
|
75
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
76
|
+
"eslint-plugin-react": "^7.17.0",
|
|
77
|
+
"eslint-plugin-standard": "^4.0.1",
|
|
78
|
+
"husky": "^7.0.4",
|
|
79
|
+
"jest": "^27.4.7",
|
|
80
|
+
"lint-staged": "^12.1.7",
|
|
81
|
+
"markdown-toc": "^1.2.0",
|
|
82
|
+
"prettier": "^2.5.1",
|
|
83
|
+
"pretty-quick": "^3.1.3",
|
|
84
|
+
"react": ">=17.x",
|
|
85
|
+
"react-dom": "^17.0.2",
|
|
86
|
+
"react-test-renderer": "^17.0.2",
|
|
87
|
+
"rollup": "^2.64.0"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"prop-types": "^15.8.1"
|
|
91
|
+
},
|
|
92
|
+
"files": [
|
|
93
|
+
"index.js",
|
|
94
|
+
"index.es.js",
|
|
95
|
+
"index.d.ts"
|
|
96
|
+
],
|
|
97
|
+
"browserslist": [
|
|
98
|
+
"> 1%",
|
|
99
|
+
"last 2 versions",
|
|
100
|
+
"ie > 10"
|
|
101
|
+
],
|
|
102
|
+
"jest": {
|
|
103
|
+
"roots": [
|
|
104
|
+
"src"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"husky": {
|
|
108
|
+
"hooks": {
|
|
109
|
+
"pre-commit": "npm run lint && npm run prettier && lint-staged"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|