@medely/react-fontawesome 0.0.1 → 0.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.
Files changed (5) hide show
  1. package/README.md +36 -20
  2. package/index.d.ts +34 -33
  3. package/index.es.js +273 -207
  4. package/index.js +342 -419
  5. package/package.json +21 -11
package/index.js CHANGED
@@ -1,209 +1,161 @@
1
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);
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fortawesome/fontawesome-svg-core'), require('prop-types'), require('react')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@fortawesome/fontawesome-svg-core', 'prop-types', 'react'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["react-fontawesome"] = {}, global.FontAwesome, global.PropTypes, global.React));
5
+ })(this, (function (exports, fontawesomeSvgCore, PropTypes, React) { 'use strict';
27
6
 
28
- function ownKeys(object, enumerableOnly) {
29
- var keys = Object.keys(object);
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
30
8
 
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
- }
9
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
39
11
 
40
- return keys;
12
+ function _arrayLikeToArray(r, a) {
13
+ (null == a || a > r.length) && (a = r.length);
14
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
15
+ return n;
41
16
  }
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;
17
+ function _arrayWithHoles(r) {
18
+ if (Array.isArray(r)) return r;
58
19
  }
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
- );
20
+ function _arrayWithoutHoles(r) {
21
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
79
22
  }
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;
23
+ function _defineProperty(e, r, t) {
24
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
25
+ value: t,
26
+ enumerable: !0,
27
+ configurable: !0,
28
+ writable: !0
29
+ }) : e[r] = t, e;
94
30
  }
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;
31
+ function _iterableToArray(r) {
32
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
113
33
  }
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;
34
+ function _iterableToArrayLimit(r, l) {
35
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
36
+ if (null != t) {
37
+ var e,
38
+ n,
39
+ i,
40
+ u,
41
+ a = [],
42
+ f = !0,
43
+ o = !1;
44
+ try {
45
+ if (i = (t = t.call(r)).next, 0 === l) {
46
+ if (Object(t) !== t) return;
47
+ f = !1;
48
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
49
+ } catch (r) {
50
+ o = !0, n = r;
51
+ } finally {
52
+ try {
53
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
54
+ } finally {
55
+ if (o) throw n;
131
56
  }
132
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) {
133
- continue;
134
- }
135
- target[key] = source[key];
136
57
  }
58
+ return a;
137
59
  }
138
-
139
- return target;
140
60
  }
141
-
142
- function _toConsumableArray(arr) {
143
- return (
144
- _arrayWithoutHoles(arr) ||
145
- _iterableToArray(arr) ||
146
- _unsupportedIterableToArray(arr) ||
147
- _nonIterableSpread()
148
- );
61
+ function _nonIterableRest() {
62
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
149
63
  }
150
-
151
- function _arrayWithoutHoles(arr) {
152
- if (Array.isArray(arr)) {
153
- return _arrayLikeToArray(arr);
154
- }
64
+ function _nonIterableSpread() {
65
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
155
66
  }
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);
67
+ function ownKeys(e, r) {
68
+ var t = Object.keys(e);
69
+ if (Object.getOwnPropertySymbols) {
70
+ var o = Object.getOwnPropertySymbols(e);
71
+ r && (o = o.filter(function (r) {
72
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
73
+ })), t.push.apply(t, o);
163
74
  }
75
+ return t;
164
76
  }
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;
77
+ function _objectSpread2(e) {
78
+ for (var r = 1; r < arguments.length; r++) {
79
+ var t = null != arguments[r] ? arguments[r] : {};
80
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
81
+ _defineProperty(e, r, t[r]);
82
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
83
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
84
+ });
176
85
  }
177
- if (n === 'Map' || n === 'Set') {
178
- return Array.from(o);
86
+ return e;
87
+ }
88
+ function _objectWithoutProperties(e, t) {
89
+ if (null == e) return {};
90
+ var o,
91
+ r,
92
+ i = _objectWithoutPropertiesLoose(e, t);
93
+ if (Object.getOwnPropertySymbols) {
94
+ var n = Object.getOwnPropertySymbols(e);
95
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
179
96
  }
180
- if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) {
181
- return _arrayLikeToArray(o, minLen);
97
+ return i;
98
+ }
99
+ function _objectWithoutPropertiesLoose(r, e) {
100
+ if (null == r) return {};
101
+ var t = {};
102
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
103
+ if (-1 !== e.indexOf(n)) continue;
104
+ t[n] = r[n];
182
105
  }
106
+ return t;
183
107
  }
184
-
185
- function _arrayLikeToArray(arr, len) {
186
- if (len == null || len > arr.length) {
187
- len = arr.length;
108
+ function _slicedToArray(r, e) {
109
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
110
+ }
111
+ function _toConsumableArray(r) {
112
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
113
+ }
114
+ function _toPrimitive(t, r) {
115
+ if ("object" != typeof t || !t) return t;
116
+ var e = t[Symbol.toPrimitive];
117
+ if (void 0 !== e) {
118
+ var i = e.call(t, r || "default");
119
+ if ("object" != typeof i) return i;
120
+ throw new TypeError("@@toPrimitive must return a primitive value.");
188
121
  }
189
-
190
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
191
- arr2[i] = arr[i];
122
+ return ("string" === r ? String : Number)(t);
123
+ }
124
+ function _toPropertyKey(t) {
125
+ var i = _toPrimitive(t, "string");
126
+ return "symbol" == typeof i ? i : i + "";
127
+ }
128
+ function _typeof(o) {
129
+ "@babel/helpers - typeof";
130
+
131
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
132
+ return typeof o;
133
+ } : function (o) {
134
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
135
+ }, _typeof(o);
136
+ }
137
+ function _unsupportedIterableToArray(r, a) {
138
+ if (r) {
139
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
140
+ var t = {}.toString.call(r).slice(8, -1);
141
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
192
142
  }
193
-
194
- return arr2;
195
143
  }
196
144
 
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
- );
145
+ var ICON_PACKS_STARTING_VERSION = '7.0.0';
146
+
147
+ // Try to get version from installed package first, fallback to env var, then default
148
+ var SVG_CORE_VERSION;
149
+ try {
150
+ var svgCorePackageJson = require('@fortawesome/fontawesome-svg-core/package.json');
151
+ SVG_CORE_VERSION = svgCorePackageJson.version;
152
+ } catch (e) {
153
+ // If package.json can't be loaded, try environment variable
154
+ SVG_CORE_VERSION = typeof process !== 'undefined' && process.env.FA_VERSION || '7.0.0';
201
155
  }
202
156
 
203
157
  // Get CSS class list from a props object
204
158
  function classList(props) {
205
- var _classes;
206
-
207
159
  var beat = props.beat,
208
160
  fade = props.fade,
209
161
  beatFade = props.beatFade,
@@ -221,202 +173,219 @@
221
173
  flip = props.flip,
222
174
  size = props.size,
223
175
  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
176
+ pull = props.pull,
177
+ swapOpacity = props.swapOpacity,
178
+ rotateBy = props.rotateBy,
179
+ widthAuto = props.widthAuto;
180
+
181
+ // Check if we're using version 7 or later
182
+ var isVersion7OrLater = versionCheckGte(SVG_CORE_VERSION, ICON_PACKS_STARTING_VERSION);
183
+
184
+ // map of CSS class names to properties
185
+ var classes = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
186
+ 'fa-beat': beat,
187
+ 'fa-fade': fade,
188
+ 'fa-beat-fade': beatFade,
189
+ 'fa-bounce': bounce,
190
+ 'fa-shake': shake,
191
+ 'fa-flash': flash,
192
+ 'fa-spin': spin,
193
+ 'fa-spin-reverse': spinReverse,
194
+ 'fa-spin-pulse': spinPulse,
195
+ 'fa-pulse': pulse,
196
+ 'fa-fw': fixedWidth,
197
+ 'fa-inverse': inverse,
198
+ 'fa-border': border,
199
+ 'fa-li': listItem,
200
+ 'fa-flip': flip === true,
201
+ 'fa-flip-horizontal': flip === 'horizontal' || flip === 'both',
202
+ 'fa-flip-vertical': flip === 'vertical' || flip === 'both'
203
+ }, "fa-".concat(size), typeof size !== 'undefined' && size !== null), "fa-rotate-".concat(rotation), typeof rotation !== 'undefined' && rotation !== null && rotation !== 0), "fa-pull-".concat(pull), typeof pull !== 'undefined' && pull !== null), 'fa-swap-opacity', swapOpacity), 'fa-rotate-by', isVersion7OrLater && rotateBy), 'fa-width-auto', isVersion7OrLater && widthAuto);
204
+
205
+ // map over all the keys in the classes object
259
206
  // return an array of the keys where the value for the key is not null
207
+ return Object.keys(classes).map(function (key) {
208
+ return classes[key] ? key : null;
209
+ }).filter(function (key) {
210
+ return key;
211
+ });
212
+ }
260
213
 
261
- return Object.keys(classes)
262
- .map(function (key) {
263
- return classes[key] ? key : null;
264
- })
265
- .filter(function (key) {
266
- return key;
267
- });
214
+ // check if verion1 is greater than or equal to version2
215
+ function versionCheckGte(version1, version2) {
216
+ var _version1$split = version1.split('-'),
217
+ _version1$split2 = _slicedToArray(_version1$split, 2),
218
+ v1Base = _version1$split2[0],
219
+ v1PreRelease = _version1$split2[1];
220
+ var _version2$split = version2.split('-'),
221
+ _version2$split2 = _slicedToArray(_version2$split, 2),
222
+ v2Base = _version2$split2[0],
223
+ v2PreRelease = _version2$split2[1];
224
+ var v1Parts = v1Base.split('.');
225
+ var v2Parts = v2Base.split('.');
226
+
227
+ // Compare version numbers first
228
+ for (var i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
229
+ var v1Part = v1Parts[i] || '0';
230
+ var v2Part = v2Parts[i] || '0';
231
+
232
+ // Compare numeric values
233
+ var v1Num = parseInt(v1Part, 10);
234
+ var v2Num = parseInt(v2Part, 10);
235
+ if (v1Num !== v2Num) {
236
+ return v1Num > v2Num;
237
+ }
238
+ }
239
+
240
+ // If numeric values are equal, look for any remaining parts
241
+ // that would make one version greater than the other
242
+ for (var _i = 0; _i < Math.max(v1Parts.length, v2Parts.length); _i++) {
243
+ var _v1Part = v1Parts[_i] || '0';
244
+ var _v2Part = v2Parts[_i] || '0';
245
+ if (_v1Part !== _v2Part) {
246
+ // When numeric values are equal but strings differ,
247
+ // the one without leading zeros is greater
248
+ if (_v1Part.length !== _v2Part.length) {
249
+ return _v1Part.length < _v2Part.length;
250
+ }
251
+ }
252
+ }
253
+
254
+ // If version numbers are equal, compare pre-release identifiers
255
+ // A version with a pre-release identifier is less than one without
256
+ if (v1PreRelease && !v2PreRelease) return false;
257
+ if (!v1PreRelease && v2PreRelease) return true;
258
+ return true;
268
259
  }
269
260
 
270
261
  // Camelize taken from humps
271
262
  // humps is copyright © 2012+ Dom Christie
272
263
  // Released under the MIT license.
264
+
273
265
  // Performant way to determine if object coerces to a number
274
266
  function _isNumerical(obj) {
275
- obj = obj - 0; // eslint-disable-next-line no-self-compare
267
+ obj = obj - 0;
276
268
 
269
+ // eslint-disable-next-line no-self-compare
277
270
  return obj === obj;
278
271
  }
279
-
280
272
  function camelize(string) {
281
273
  if (_isNumerical(string)) {
282
274
  return string;
283
- } // eslint-disable-next-line no-useless-escape
275
+ }
284
276
 
277
+ // eslint-disable-next-line no-useless-escape
285
278
  string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
286
279
  return chr ? chr.toUpperCase() : '';
287
- }); // Ensure 1st char is always lowercase
280
+ });
288
281
 
282
+ // Ensure 1st char is always lowercase
289
283
  return string.substr(0, 1).toLowerCase() + string.substr(1);
290
284
  }
291
285
 
292
- var _excluded$1 = ['style'];
293
-
286
+ var _excluded = ["style"];
294
287
  function capitalize(val) {
295
288
  return val.charAt(0).toUpperCase() + val.slice(1);
296
289
  }
297
-
298
290
  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
- }, {});
291
+ return style.split(';').map(function (s) {
292
+ return s.trim();
293
+ }).filter(function (s) {
294
+ return s;
295
+ }).reduce(function (acc, pair) {
296
+ var i = pair.indexOf(':');
297
+ var prop = camelize(pair.slice(0, i));
298
+ var value = pair.slice(i + 1).trim();
299
+ prop.startsWith('webkit') ? acc[capitalize(prop)] = value : acc[prop] = value;
300
+ return acc;
301
+ }, {});
314
302
  }
315
-
316
303
  function convert(createElement, element) {
317
304
  var extraProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
318
-
319
305
  if (typeof element === 'string') {
320
306
  return element;
321
307
  }
322
-
323
308
  var children = (element.children || []).map(function (child) {
324
309
  return convert(createElement, child);
325
310
  });
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
311
 
312
+ /* eslint-disable dot-notation */
313
+ var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) {
314
+ var val = element.attributes[key];
315
+ switch (key) {
316
+ case 'class':
317
+ acc.attrs['className'] = val;
318
+ delete element.attributes['class'];
319
+ break;
320
+ case 'style':
321
+ acc.attrs['style'] = styleToObject(val);
322
+ break;
323
+ default:
324
+ if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0) {
325
+ acc.attrs[key.toLowerCase()] = val;
326
+ } else {
327
+ acc.attrs[camelize(key)] = val;
328
+ }
329
+ }
330
+ return acc;
331
+ }, {
332
+ attrs: {}
333
+ });
357
334
  var _extraProps$style = extraProps.style,
358
335
  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
- );
336
+ remaining = _objectWithoutProperties(extraProps, _excluded);
337
+ mixins.attrs['style'] = _objectSpread2(_objectSpread2({}, mixins.attrs['style']), existingStyle);
365
338
  /* eslint-enable */
366
339
 
367
- return createElement.apply(
368
- void 0,
369
- [element.tag, _objectSpread2(_objectSpread2({}, mixins.attrs), remaining)].concat(
370
- _toConsumableArray(children),
371
- ),
372
- );
340
+ return createElement.apply(void 0, [element.tag, _objectSpread2(_objectSpread2({}, mixins.attrs), remaining)].concat(_toConsumableArray(children)));
373
341
  }
374
342
 
375
343
  var PRODUCTION = false;
376
-
377
344
  try {
378
345
  PRODUCTION = process.env.NODE_ENV === 'production';
379
346
  } catch (e) {}
380
-
381
- function log() {
347
+ function log () {
382
348
  if (!PRODUCTION && console && typeof console.error === 'function') {
383
349
  var _console;
384
-
385
350
  (_console = console).error.apply(_console, arguments);
386
351
  }
387
352
  }
388
353
 
354
+ // Normalize icon arguments
389
355
  function normalizeIconArgs(icon) {
390
356
  // this has everything that it needs to be rendered which means it was probably imported
391
357
  // directly from an icon svg package
392
358
  if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName && icon.icon) {
393
359
  return icon;
394
360
  }
395
-
396
361
  if (fontawesomeSvgCore.parse.icon) {
397
362
  return fontawesomeSvgCore.parse.icon(icon);
398
- } // if the icon is null, there's nothing to do
363
+ }
399
364
 
365
+ // if the icon is null, there's nothing to do
400
366
  if (icon === null) {
401
367
  return null;
402
- } // if the icon is an object and has a prefix and an icon name, return it
368
+ }
403
369
 
370
+ // if the icon is an object and has a prefix and an icon name, return it
404
371
  if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName) {
405
372
  return icon;
406
- } // if it's an array with length of two
373
+ }
407
374
 
375
+ // if it's an array with length of two
408
376
  if (Array.isArray(icon) && icon.length === 2) {
409
377
  // use the first item as prefix, second as icon name
410
378
  return {
411
379
  prefix: icon[0],
412
- iconName: icon[1],
380
+ iconName: icon[1]
413
381
  };
414
- } // if it's a string, use it as the icon name
382
+ }
415
383
 
384
+ // if it's a string, use it as the icon name
416
385
  if (typeof icon === 'string') {
417
386
  return {
418
387
  prefix: 'fas',
419
- iconName: icon,
388
+ iconName: icon
420
389
  };
421
390
  }
422
391
  }
@@ -429,132 +398,15 @@
429
398
  // or it's not an array but it is truthy
430
399
  // then create the object with the key and the value
431
400
  // if not, return an empty array
432
- return (Array.isArray(value) && value.length > 0) || (!Array.isArray(value) && value)
433
- ? _defineProperty({}, key, value)
434
- : {};
401
+ return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? _defineProperty({}, key, value) : {};
435
402
  }
436
403
 
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 = {
404
+ var defaultProps = {
554
405
  border: false,
555
406
  className: '',
556
407
  mask: null,
557
408
  maskId: null,
409
+ // the fixedWidth property has been deprecated as of version 7
558
410
  fixedWidth: false,
559
411
  inverse: false,
560
412
  flip: false,
@@ -563,6 +415,7 @@
563
415
  pull: null,
564
416
  pulse: false,
565
417
  rotation: null,
418
+ rotateBy: false,
566
419
  size: null,
567
420
  spin: false,
568
421
  spinPulse: false,
@@ -577,10 +430,80 @@
577
430
  titleId: null,
578
431
  transform: null,
579
432
  swapOpacity: false,
433
+ widthAuto: false
434
+ };
435
+ var FontAwesomeIcon = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) {
436
+ var allProps = _objectSpread2(_objectSpread2({}, defaultProps), props);
437
+ var iconArgs = allProps.icon,
438
+ maskArgs = allProps.mask,
439
+ symbol = allProps.symbol,
440
+ className = allProps.className,
441
+ title = allProps.title,
442
+ titleId = allProps.titleId,
443
+ maskId = allProps.maskId;
444
+ var iconLookup = normalizeIconArgs(iconArgs);
445
+ var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(allProps)), _toConsumableArray((className || '').split(' '))));
446
+ var transform = objectWithKey('transform', typeof allProps.transform === 'string' ? fontawesomeSvgCore.parse.transform(allProps.transform) : allProps.transform);
447
+ var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
448
+ var renderedIcon = fontawesomeSvgCore.icon(iconLookup, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, classes), transform), mask), {}, {
449
+ symbol: symbol,
450
+ title: title,
451
+ titleId: titleId,
452
+ maskId: maskId
453
+ }));
454
+ if (!renderedIcon) {
455
+ log('Could not find icon', iconLookup);
456
+ return null;
457
+ }
458
+ var abstract = renderedIcon.abstract;
459
+ var extraProps = {
460
+ ref: ref
461
+ };
462
+ Object.keys(allProps).forEach(function (key) {
463
+ // eslint-disable-next-line no-prototype-builtins
464
+ if (!defaultProps.hasOwnProperty(key)) {
465
+ extraProps[key] = allProps[key];
466
+ }
467
+ });
468
+ return convertCurry(abstract[0], extraProps);
469
+ });
470
+ FontAwesomeIcon.displayName = 'FontAwesomeIcon';
471
+ FontAwesomeIcon.propTypes = {
472
+ beat: PropTypes__default["default"].bool,
473
+ border: PropTypes__default["default"].bool,
474
+ beatFade: PropTypes__default["default"].bool,
475
+ bounce: PropTypes__default["default"].bool,
476
+ className: PropTypes__default["default"].string,
477
+ fade: PropTypes__default["default"].bool,
478
+ flash: PropTypes__default["default"].bool,
479
+ mask: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].array, PropTypes__default["default"].string]),
480
+ maskId: PropTypes__default["default"].string,
481
+ // the fixedWidth property has been deprecated as of version 7
482
+ fixedWidth: PropTypes__default["default"].bool,
483
+ inverse: PropTypes__default["default"].bool,
484
+ flip: PropTypes__default["default"].oneOf([true, false, 'horizontal', 'vertical', 'both']),
485
+ icon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].array, PropTypes__default["default"].string]),
486
+ listItem: PropTypes__default["default"].bool,
487
+ pull: PropTypes__default["default"].oneOf(['right', 'left']),
488
+ pulse: PropTypes__default["default"].bool,
489
+ rotation: PropTypes__default["default"].oneOf([0, 90, 180, 270]),
490
+ rotateBy: PropTypes__default["default"].bool,
491
+ shake: PropTypes__default["default"].bool,
492
+ size: PropTypes__default["default"].oneOf(['2xs', 'xs', 'sm', 'lg', 'xl', '2xl', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x']),
493
+ spin: PropTypes__default["default"].bool,
494
+ spinPulse: PropTypes__default["default"].bool,
495
+ spinReverse: PropTypes__default["default"].bool,
496
+ symbol: PropTypes__default["default"].oneOfType([PropTypes__default["default"].bool, PropTypes__default["default"].string]),
497
+ title: PropTypes__default["default"].string,
498
+ titleId: PropTypes__default["default"].string,
499
+ transform: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].object]),
500
+ swapOpacity: PropTypes__default["default"].bool,
501
+ widthAuto: PropTypes__default["default"].bool
580
502
  };
581
- var convertCurry = convert.bind(null, React__default['default'].createElement);
503
+ var convertCurry = convert.bind(null, React__default["default"].createElement);
582
504
 
583
505
  exports.FontAwesomeIcon = FontAwesomeIcon;
584
506
 
585
507
  Object.defineProperty(exports, '__esModule', { value: true });
586
- });
508
+
509
+ }));