1 | /*!
|
---|
2 | * Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
|
---|
3 | * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
---|
4 | */
|
---|
5 | function _typeof(obj) {
|
---|
6 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
---|
7 | _typeof = function (obj) {
|
---|
8 | return typeof obj;
|
---|
9 | };
|
---|
10 | } else {
|
---|
11 | _typeof = function (obj) {
|
---|
12 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
---|
13 | };
|
---|
14 | }
|
---|
15 |
|
---|
16 | return _typeof(obj);
|
---|
17 | }
|
---|
18 |
|
---|
19 | function _classCallCheck(instance, Constructor) {
|
---|
20 | if (!(instance instanceof Constructor)) {
|
---|
21 | throw new TypeError("Cannot call a class as a function");
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 | function _defineProperties(target, props) {
|
---|
26 | for (var i = 0; i < props.length; i++) {
|
---|
27 | var descriptor = props[i];
|
---|
28 | descriptor.enumerable = descriptor.enumerable || false;
|
---|
29 | descriptor.configurable = true;
|
---|
30 | if ("value" in descriptor) descriptor.writable = true;
|
---|
31 | Object.defineProperty(target, descriptor.key, descriptor);
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | function _createClass(Constructor, protoProps, staticProps) {
|
---|
36 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
---|
37 | if (staticProps) _defineProperties(Constructor, staticProps);
|
---|
38 | return Constructor;
|
---|
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 _objectSpread(target) {
|
---|
57 | for (var i = 1; i < arguments.length; i++) {
|
---|
58 | var source = arguments[i] != null ? arguments[i] : {};
|
---|
59 | var ownKeys = Object.keys(source);
|
---|
60 |
|
---|
61 | if (typeof Object.getOwnPropertySymbols === 'function') {
|
---|
62 | ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
---|
63 | return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
---|
64 | }));
|
---|
65 | }
|
---|
66 |
|
---|
67 | ownKeys.forEach(function (key) {
|
---|
68 | _defineProperty(target, key, source[key]);
|
---|
69 | });
|
---|
70 | }
|
---|
71 |
|
---|
72 | return target;
|
---|
73 | }
|
---|
74 |
|
---|
75 | function _slicedToArray(arr, i) {
|
---|
76 | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
---|
77 | }
|
---|
78 |
|
---|
79 | function _toConsumableArray(arr) {
|
---|
80 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
---|
81 | }
|
---|
82 |
|
---|
83 | function _arrayWithoutHoles(arr) {
|
---|
84 | if (Array.isArray(arr)) {
|
---|
85 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
---|
86 |
|
---|
87 | return arr2;
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | function _arrayWithHoles(arr) {
|
---|
92 | if (Array.isArray(arr)) return arr;
|
---|
93 | }
|
---|
94 |
|
---|
95 | function _iterableToArray(iter) {
|
---|
96 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
---|
97 | }
|
---|
98 |
|
---|
99 | function _iterableToArrayLimit(arr, i) {
|
---|
100 | var _arr = [];
|
---|
101 | var _n = true;
|
---|
102 | var _d = false;
|
---|
103 | var _e = undefined;
|
---|
104 |
|
---|
105 | try {
|
---|
106 | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
---|
107 | _arr.push(_s.value);
|
---|
108 |
|
---|
109 | if (i && _arr.length === i) break;
|
---|
110 | }
|
---|
111 | } catch (err) {
|
---|
112 | _d = true;
|
---|
113 | _e = err;
|
---|
114 | } finally {
|
---|
115 | try {
|
---|
116 | if (!_n && _i["return"] != null) _i["return"]();
|
---|
117 | } finally {
|
---|
118 | if (_d) throw _e;
|
---|
119 | }
|
---|
120 | }
|
---|
121 |
|
---|
122 | return _arr;
|
---|
123 | }
|
---|
124 |
|
---|
125 | function _nonIterableSpread() {
|
---|
126 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
---|
127 | }
|
---|
128 |
|
---|
129 | function _nonIterableRest() {
|
---|
130 | throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
---|
131 | }
|
---|
132 |
|
---|
133 | var noop = function noop() {};
|
---|
134 |
|
---|
135 | var _WINDOW = {};
|
---|
136 | var _DOCUMENT = {};
|
---|
137 | var _MUTATION_OBSERVER = null;
|
---|
138 | var _PERFORMANCE = {
|
---|
139 | mark: noop,
|
---|
140 | measure: noop
|
---|
141 | };
|
---|
142 |
|
---|
143 | try {
|
---|
144 | if (typeof window !== 'undefined') _WINDOW = window;
|
---|
145 | if (typeof document !== 'undefined') _DOCUMENT = document;
|
---|
146 | if (typeof MutationObserver !== 'undefined') _MUTATION_OBSERVER = MutationObserver;
|
---|
147 | if (typeof performance !== 'undefined') _PERFORMANCE = performance;
|
---|
148 | } catch (e) {}
|
---|
149 |
|
---|
150 | var _ref = _WINDOW.navigator || {},
|
---|
151 | _ref$userAgent = _ref.userAgent,
|
---|
152 | userAgent = _ref$userAgent === void 0 ? '' : _ref$userAgent;
|
---|
153 |
|
---|
154 | var WINDOW = _WINDOW;
|
---|
155 | var DOCUMENT = _DOCUMENT;
|
---|
156 | var MUTATION_OBSERVER = _MUTATION_OBSERVER;
|
---|
157 | var PERFORMANCE = _PERFORMANCE;
|
---|
158 | var IS_BROWSER = !!WINDOW.document;
|
---|
159 | var IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
|
---|
160 | var IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
|
---|
161 |
|
---|
162 | var NAMESPACE_IDENTIFIER = '___FONT_AWESOME___';
|
---|
163 | var UNITS_IN_GRID = 16;
|
---|
164 | var DEFAULT_FAMILY_PREFIX = 'fa';
|
---|
165 | var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
|
---|
166 | var DATA_FA_I2SVG = 'data-fa-i2svg';
|
---|
167 | var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
|
---|
168 | var DATA_FA_PSEUDO_ELEMENT_PENDING = 'data-fa-pseudo-element-pending';
|
---|
169 | var DATA_PREFIX = 'data-prefix';
|
---|
170 | var DATA_ICON = 'data-icon';
|
---|
171 | var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
|
---|
172 | var MUTATION_APPROACH_ASYNC = 'async';
|
---|
173 | var TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS = ['HTML', 'HEAD', 'STYLE', 'SCRIPT'];
|
---|
174 | var PRODUCTION = function () {
|
---|
175 | try {
|
---|
176 | return process.env.NODE_ENV === 'production';
|
---|
177 | } catch (e) {
|
---|
178 | return false;
|
---|
179 | }
|
---|
180 | }();
|
---|
181 | var PREFIX_TO_STYLE = {
|
---|
182 | 'fas': 'solid',
|
---|
183 | 'far': 'regular',
|
---|
184 | 'fal': 'light',
|
---|
185 | 'fad': 'duotone',
|
---|
186 | 'fab': 'brands',
|
---|
187 | 'fak': 'kit',
|
---|
188 | 'fa': 'solid'
|
---|
189 | };
|
---|
190 | var STYLE_TO_PREFIX = {
|
---|
191 | 'solid': 'fas',
|
---|
192 | 'regular': 'far',
|
---|
193 | 'light': 'fal',
|
---|
194 | 'duotone': 'fad',
|
---|
195 | 'brands': 'fab',
|
---|
196 | 'kit': 'fak'
|
---|
197 | };
|
---|
198 | var LAYERS_TEXT_CLASSNAME = 'fa-layers-text';
|
---|
199 | var FONT_FAMILY_PATTERN = /Font Awesome ([5 ]*)(Solid|Regular|Light|Duotone|Brands|Free|Pro|Kit).*/i; // TODO: do we need to handle font-weight for kit SVG pseudo-elements?
|
---|
200 |
|
---|
201 | var FONT_WEIGHT_TO_PREFIX = {
|
---|
202 | '900': 'fas',
|
---|
203 | '400': 'far',
|
---|
204 | 'normal': 'far',
|
---|
205 | '300': 'fal'
|
---|
206 | };
|
---|
207 | var oneToTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
---|
208 | var oneToTwenty = oneToTen.concat([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
|
---|
209 | var ATTRIBUTES_WATCHED_FOR_MUTATION = ['class', 'data-prefix', 'data-icon', 'data-fa-transform', 'data-fa-mask'];
|
---|
210 | var DUOTONE_CLASSES = {
|
---|
211 | GROUP: 'group',
|
---|
212 | SWAP_OPACITY: 'swap-opacity',
|
---|
213 | PRIMARY: 'primary',
|
---|
214 | SECONDARY: 'secondary'
|
---|
215 | };
|
---|
216 | var RESERVED_CLASSES = ['xs', 'sm', 'lg', 'fw', 'ul', 'li', 'border', 'pull-left', 'pull-right', 'spin', 'pulse', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical', 'flip-both', 'stack', 'stack-1x', 'stack-2x', 'inverse', 'layers', 'layers-text', 'layers-counter', DUOTONE_CLASSES.GROUP, DUOTONE_CLASSES.SWAP_OPACITY, DUOTONE_CLASSES.PRIMARY, DUOTONE_CLASSES.SECONDARY].concat(oneToTen.map(function (n) {
|
---|
217 | return "".concat(n, "x");
|
---|
218 | })).concat(oneToTwenty.map(function (n) {
|
---|
219 | return "w-".concat(n);
|
---|
220 | }));
|
---|
221 |
|
---|
222 | var initial = WINDOW.FontAwesomeConfig || {};
|
---|
223 |
|
---|
224 | function getAttrConfig(attr) {
|
---|
225 | var element = DOCUMENT.querySelector('script[' + attr + ']');
|
---|
226 |
|
---|
227 | if (element) {
|
---|
228 | return element.getAttribute(attr);
|
---|
229 | }
|
---|
230 | }
|
---|
231 |
|
---|
232 | function coerce(val) {
|
---|
233 | // Getting an empty string will occur if the attribute is set on the HTML tag but without a value
|
---|
234 | // We'll assume that this is an indication that it should be toggled to true
|
---|
235 | // For example <script data-search-pseudo-elements src="..."></script>
|
---|
236 | if (val === '') return true;
|
---|
237 | if (val === 'false') return false;
|
---|
238 | if (val === 'true') return true;
|
---|
239 | return val;
|
---|
240 | }
|
---|
241 |
|
---|
242 | if (DOCUMENT && typeof DOCUMENT.querySelector === 'function') {
|
---|
243 | var attrs = [['data-family-prefix', 'familyPrefix'], ['data-replacement-class', 'replacementClass'], ['data-auto-replace-svg', 'autoReplaceSvg'], ['data-auto-add-css', 'autoAddCss'], ['data-auto-a11y', 'autoA11y'], ['data-search-pseudo-elements', 'searchPseudoElements'], ['data-observe-mutations', 'observeMutations'], ['data-mutate-approach', 'mutateApproach'], ['data-keep-original-source', 'keepOriginalSource'], ['data-measure-performance', 'measurePerformance'], ['data-show-missing-icons', 'showMissingIcons']];
|
---|
244 | attrs.forEach(function (_ref) {
|
---|
245 | var _ref2 = _slicedToArray(_ref, 2),
|
---|
246 | attr = _ref2[0],
|
---|
247 | key = _ref2[1];
|
---|
248 |
|
---|
249 | var val = coerce(getAttrConfig(attr));
|
---|
250 |
|
---|
251 | if (val !== undefined && val !== null) {
|
---|
252 | initial[key] = val;
|
---|
253 | }
|
---|
254 | });
|
---|
255 | }
|
---|
256 |
|
---|
257 | var _default = {
|
---|
258 | familyPrefix: DEFAULT_FAMILY_PREFIX,
|
---|
259 | replacementClass: DEFAULT_REPLACEMENT_CLASS,
|
---|
260 | autoReplaceSvg: true,
|
---|
261 | autoAddCss: true,
|
---|
262 | autoA11y: true,
|
---|
263 | searchPseudoElements: false,
|
---|
264 | observeMutations: true,
|
---|
265 | mutateApproach: 'async',
|
---|
266 | keepOriginalSource: true,
|
---|
267 | measurePerformance: false,
|
---|
268 | showMissingIcons: true
|
---|
269 | };
|
---|
270 |
|
---|
271 | var _config = _objectSpread({}, _default, initial);
|
---|
272 |
|
---|
273 | if (!_config.autoReplaceSvg) _config.observeMutations = false;
|
---|
274 |
|
---|
275 | var config = _objectSpread({}, _config);
|
---|
276 |
|
---|
277 | WINDOW.FontAwesomeConfig = config;
|
---|
278 |
|
---|
279 | var w = WINDOW || {};
|
---|
280 | if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
|
---|
281 | if (!w[NAMESPACE_IDENTIFIER].styles) w[NAMESPACE_IDENTIFIER].styles = {};
|
---|
282 | if (!w[NAMESPACE_IDENTIFIER].hooks) w[NAMESPACE_IDENTIFIER].hooks = {};
|
---|
283 | if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
|
---|
284 | var namespace = w[NAMESPACE_IDENTIFIER];
|
---|
285 |
|
---|
286 | var functions = [];
|
---|
287 |
|
---|
288 | var listener = function listener() {
|
---|
289 | DOCUMENT.removeEventListener('DOMContentLoaded', listener);
|
---|
290 | loaded = 1;
|
---|
291 | functions.map(function (fn) {
|
---|
292 | return fn();
|
---|
293 | });
|
---|
294 | };
|
---|
295 |
|
---|
296 | var loaded = false;
|
---|
297 |
|
---|
298 | if (IS_DOM) {
|
---|
299 | loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
|
---|
300 | if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
|
---|
301 | }
|
---|
302 |
|
---|
303 | function domready (fn) {
|
---|
304 | if (!IS_DOM) return;
|
---|
305 | loaded ? setTimeout(fn, 0) : functions.push(fn);
|
---|
306 | }
|
---|
307 |
|
---|
308 | var PENDING = 'pending';
|
---|
309 | var SETTLED = 'settled';
|
---|
310 | var FULFILLED = 'fulfilled';
|
---|
311 | var REJECTED = 'rejected';
|
---|
312 |
|
---|
313 | var NOOP = function NOOP() {};
|
---|
314 |
|
---|
315 | var isNode = typeof global !== 'undefined' && typeof global.process !== 'undefined' && typeof global.process.emit === 'function';
|
---|
316 | var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
|
---|
317 | var asyncQueue = [];
|
---|
318 | var asyncTimer;
|
---|
319 |
|
---|
320 | function asyncFlush() {
|
---|
321 | // run promise callbacks
|
---|
322 | for (var i = 0; i < asyncQueue.length; i++) {
|
---|
323 | asyncQueue[i][0](asyncQueue[i][1]);
|
---|
324 | } // reset async asyncQueue
|
---|
325 |
|
---|
326 |
|
---|
327 | asyncQueue = [];
|
---|
328 | asyncTimer = false;
|
---|
329 | }
|
---|
330 |
|
---|
331 | function asyncCall(callback, arg) {
|
---|
332 | asyncQueue.push([callback, arg]);
|
---|
333 |
|
---|
334 | if (!asyncTimer) {
|
---|
335 | asyncTimer = true;
|
---|
336 | asyncSetTimer(asyncFlush, 0);
|
---|
337 | }
|
---|
338 | }
|
---|
339 |
|
---|
340 | function invokeResolver(resolver, promise) {
|
---|
341 | function resolvePromise(value) {
|
---|
342 | resolve(promise, value);
|
---|
343 | }
|
---|
344 |
|
---|
345 | function rejectPromise(reason) {
|
---|
346 | reject(promise, reason);
|
---|
347 | }
|
---|
348 |
|
---|
349 | try {
|
---|
350 | resolver(resolvePromise, rejectPromise);
|
---|
351 | } catch (e) {
|
---|
352 | rejectPromise(e);
|
---|
353 | }
|
---|
354 | }
|
---|
355 |
|
---|
356 | function invokeCallback(subscriber) {
|
---|
357 | var owner = subscriber.owner;
|
---|
358 | var settled = owner._state;
|
---|
359 | var value = owner._data;
|
---|
360 | var callback = subscriber[settled];
|
---|
361 | var promise = subscriber.then;
|
---|
362 |
|
---|
363 | if (typeof callback === 'function') {
|
---|
364 | settled = FULFILLED;
|
---|
365 |
|
---|
366 | try {
|
---|
367 | value = callback(value);
|
---|
368 | } catch (e) {
|
---|
369 | reject(promise, e);
|
---|
370 | }
|
---|
371 | }
|
---|
372 |
|
---|
373 | if (!handleThenable(promise, value)) {
|
---|
374 | if (settled === FULFILLED) {
|
---|
375 | resolve(promise, value);
|
---|
376 | }
|
---|
377 |
|
---|
378 | if (settled === REJECTED) {
|
---|
379 | reject(promise, value);
|
---|
380 | }
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | function handleThenable(promise, value) {
|
---|
385 | var resolved;
|
---|
386 |
|
---|
387 | try {
|
---|
388 | if (promise === value) {
|
---|
389 | throw new TypeError('A promises callback cannot return that same promise.');
|
---|
390 | }
|
---|
391 |
|
---|
392 | if (value && (typeof value === 'function' || _typeof(value) === 'object')) {
|
---|
393 | // then should be retrieved only once
|
---|
394 | var then = value.then;
|
---|
395 |
|
---|
396 | if (typeof then === 'function') {
|
---|
397 | then.call(value, function (val) {
|
---|
398 | if (!resolved) {
|
---|
399 | resolved = true;
|
---|
400 |
|
---|
401 | if (value === val) {
|
---|
402 | fulfill(promise, val);
|
---|
403 | } else {
|
---|
404 | resolve(promise, val);
|
---|
405 | }
|
---|
406 | }
|
---|
407 | }, function (reason) {
|
---|
408 | if (!resolved) {
|
---|
409 | resolved = true;
|
---|
410 | reject(promise, reason);
|
---|
411 | }
|
---|
412 | });
|
---|
413 | return true;
|
---|
414 | }
|
---|
415 | }
|
---|
416 | } catch (e) {
|
---|
417 | if (!resolved) {
|
---|
418 | reject(promise, e);
|
---|
419 | }
|
---|
420 |
|
---|
421 | return true;
|
---|
422 | }
|
---|
423 |
|
---|
424 | return false;
|
---|
425 | }
|
---|
426 |
|
---|
427 | function resolve(promise, value) {
|
---|
428 | if (promise === value || !handleThenable(promise, value)) {
|
---|
429 | fulfill(promise, value);
|
---|
430 | }
|
---|
431 | }
|
---|
432 |
|
---|
433 | function fulfill(promise, value) {
|
---|
434 | if (promise._state === PENDING) {
|
---|
435 | promise._state = SETTLED;
|
---|
436 | promise._data = value;
|
---|
437 | asyncCall(publishFulfillment, promise);
|
---|
438 | }
|
---|
439 | }
|
---|
440 |
|
---|
441 | function reject(promise, reason) {
|
---|
442 | if (promise._state === PENDING) {
|
---|
443 | promise._state = SETTLED;
|
---|
444 | promise._data = reason;
|
---|
445 | asyncCall(publishRejection, promise);
|
---|
446 | }
|
---|
447 | }
|
---|
448 |
|
---|
449 | function publish(promise) {
|
---|
450 | promise._then = promise._then.forEach(invokeCallback);
|
---|
451 | }
|
---|
452 |
|
---|
453 | function publishFulfillment(promise) {
|
---|
454 | promise._state = FULFILLED;
|
---|
455 | publish(promise);
|
---|
456 | }
|
---|
457 |
|
---|
458 | function publishRejection(promise) {
|
---|
459 | promise._state = REJECTED;
|
---|
460 | publish(promise);
|
---|
461 |
|
---|
462 | if (!promise._handled && isNode) {
|
---|
463 | global.process.emit('unhandledRejection', promise._data, promise);
|
---|
464 | }
|
---|
465 | }
|
---|
466 |
|
---|
467 | function notifyRejectionHandled(promise) {
|
---|
468 | global.process.emit('rejectionHandled', promise);
|
---|
469 | }
|
---|
470 | /**
|
---|
471 | * @class
|
---|
472 | */
|
---|
473 |
|
---|
474 |
|
---|
475 | function P(resolver) {
|
---|
476 | if (typeof resolver !== 'function') {
|
---|
477 | throw new TypeError('Promise resolver ' + resolver + ' is not a function');
|
---|
478 | }
|
---|
479 |
|
---|
480 | if (this instanceof P === false) {
|
---|
481 | throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
|
---|
482 | }
|
---|
483 |
|
---|
484 | this._then = [];
|
---|
485 | invokeResolver(resolver, this);
|
---|
486 | }
|
---|
487 |
|
---|
488 | P.prototype = {
|
---|
489 | constructor: P,
|
---|
490 | _state: PENDING,
|
---|
491 | _then: null,
|
---|
492 | _data: undefined,
|
---|
493 | _handled: false,
|
---|
494 | then: function then(onFulfillment, onRejection) {
|
---|
495 | var subscriber = {
|
---|
496 | owner: this,
|
---|
497 | then: new this.constructor(NOOP),
|
---|
498 | fulfilled: onFulfillment,
|
---|
499 | rejected: onRejection
|
---|
500 | };
|
---|
501 |
|
---|
502 | if ((onRejection || onFulfillment) && !this._handled) {
|
---|
503 | this._handled = true;
|
---|
504 |
|
---|
505 | if (this._state === REJECTED && isNode) {
|
---|
506 | asyncCall(notifyRejectionHandled, this);
|
---|
507 | }
|
---|
508 | }
|
---|
509 |
|
---|
510 | if (this._state === FULFILLED || this._state === REJECTED) {
|
---|
511 | // already resolved, call callback async
|
---|
512 | asyncCall(invokeCallback, subscriber);
|
---|
513 | } else {
|
---|
514 | // subscribe
|
---|
515 | this._then.push(subscriber);
|
---|
516 | }
|
---|
517 |
|
---|
518 | return subscriber.then;
|
---|
519 | },
|
---|
520 | catch: function _catch(onRejection) {
|
---|
521 | return this.then(null, onRejection);
|
---|
522 | }
|
---|
523 | };
|
---|
524 |
|
---|
525 | P.all = function (promises) {
|
---|
526 | if (!Array.isArray(promises)) {
|
---|
527 | throw new TypeError('You must pass an array to Promise.all().');
|
---|
528 | }
|
---|
529 |
|
---|
530 | return new P(function (resolve, reject) {
|
---|
531 | var results = [];
|
---|
532 | var remaining = 0;
|
---|
533 |
|
---|
534 | function resolver(index) {
|
---|
535 | remaining++;
|
---|
536 | return function (value) {
|
---|
537 | results[index] = value;
|
---|
538 |
|
---|
539 | if (! --remaining) {
|
---|
540 | resolve(results);
|
---|
541 | }
|
---|
542 | };
|
---|
543 | }
|
---|
544 |
|
---|
545 | for (var i = 0, promise; i < promises.length; i++) {
|
---|
546 | promise = promises[i];
|
---|
547 |
|
---|
548 | if (promise && typeof promise.then === 'function') {
|
---|
549 | promise.then(resolver(i), reject);
|
---|
550 | } else {
|
---|
551 | results[i] = promise;
|
---|
552 | }
|
---|
553 | }
|
---|
554 |
|
---|
555 | if (!remaining) {
|
---|
556 | resolve(results);
|
---|
557 | }
|
---|
558 | });
|
---|
559 | };
|
---|
560 |
|
---|
561 | P.race = function (promises) {
|
---|
562 | if (!Array.isArray(promises)) {
|
---|
563 | throw new TypeError('You must pass an array to Promise.race().');
|
---|
564 | }
|
---|
565 |
|
---|
566 | return new P(function (resolve, reject) {
|
---|
567 | for (var i = 0, promise; i < promises.length; i++) {
|
---|
568 | promise = promises[i];
|
---|
569 |
|
---|
570 | if (promise && typeof promise.then === 'function') {
|
---|
571 | promise.then(resolve, reject);
|
---|
572 | } else {
|
---|
573 | resolve(promise);
|
---|
574 | }
|
---|
575 | }
|
---|
576 | });
|
---|
577 | };
|
---|
578 |
|
---|
579 | P.resolve = function (value) {
|
---|
580 | if (value && _typeof(value) === 'object' && value.constructor === P) {
|
---|
581 | return value;
|
---|
582 | }
|
---|
583 |
|
---|
584 | return new P(function (resolve) {
|
---|
585 | resolve(value);
|
---|
586 | });
|
---|
587 | };
|
---|
588 |
|
---|
589 | P.reject = function (reason) {
|
---|
590 | return new P(function (resolve, reject) {
|
---|
591 | reject(reason);
|
---|
592 | });
|
---|
593 | };
|
---|
594 |
|
---|
595 | var picked = typeof Promise === 'function' ? Promise : P;
|
---|
596 |
|
---|
597 | var d = UNITS_IN_GRID;
|
---|
598 | var meaninglessTransform = {
|
---|
599 | size: 16,
|
---|
600 | x: 0,
|
---|
601 | y: 0,
|
---|
602 | rotate: 0,
|
---|
603 | flipX: false,
|
---|
604 | flipY: false
|
---|
605 | };
|
---|
606 |
|
---|
607 | function isReserved(name) {
|
---|
608 | return ~RESERVED_CLASSES.indexOf(name);
|
---|
609 | }
|
---|
610 | function insertCss(css) {
|
---|
611 | if (!css || !IS_DOM) {
|
---|
612 | return;
|
---|
613 | }
|
---|
614 |
|
---|
615 | var style = DOCUMENT.createElement('style');
|
---|
616 | style.setAttribute('type', 'text/css');
|
---|
617 | style.innerHTML = css;
|
---|
618 | var headChildren = DOCUMENT.head.childNodes;
|
---|
619 | var beforeChild = null;
|
---|
620 |
|
---|
621 | for (var i = headChildren.length - 1; i > -1; i--) {
|
---|
622 | var child = headChildren[i];
|
---|
623 | var tagName = (child.tagName || '').toUpperCase();
|
---|
624 |
|
---|
625 | if (['STYLE', 'LINK'].indexOf(tagName) > -1) {
|
---|
626 | beforeChild = child;
|
---|
627 | }
|
---|
628 | }
|
---|
629 |
|
---|
630 | DOCUMENT.head.insertBefore(style, beforeChild);
|
---|
631 | return css;
|
---|
632 | }
|
---|
633 | var idPool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
---|
634 | function nextUniqueId() {
|
---|
635 | var size = 12;
|
---|
636 | var id = '';
|
---|
637 |
|
---|
638 | while (size-- > 0) {
|
---|
639 | id += idPool[Math.random() * 62 | 0];
|
---|
640 | }
|
---|
641 |
|
---|
642 | return id;
|
---|
643 | }
|
---|
644 | function toArray(obj) {
|
---|
645 | var array = [];
|
---|
646 |
|
---|
647 | for (var i = (obj || []).length >>> 0; i--;) {
|
---|
648 | array[i] = obj[i];
|
---|
649 | }
|
---|
650 |
|
---|
651 | return array;
|
---|
652 | }
|
---|
653 | function classArray(node) {
|
---|
654 | if (node.classList) {
|
---|
655 | return toArray(node.classList);
|
---|
656 | } else {
|
---|
657 | return (node.getAttribute('class') || '').split(' ').filter(function (i) {
|
---|
658 | return i;
|
---|
659 | });
|
---|
660 | }
|
---|
661 | }
|
---|
662 | function getIconName(familyPrefix, cls) {
|
---|
663 | var parts = cls.split('-');
|
---|
664 | var prefix = parts[0];
|
---|
665 | var iconName = parts.slice(1).join('-');
|
---|
666 |
|
---|
667 | if (prefix === familyPrefix && iconName !== '' && !isReserved(iconName)) {
|
---|
668 | return iconName;
|
---|
669 | } else {
|
---|
670 | return null;
|
---|
671 | }
|
---|
672 | }
|
---|
673 | function htmlEscape(str) {
|
---|
674 | return "".concat(str).replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>');
|
---|
675 | }
|
---|
676 | function joinAttributes(attributes) {
|
---|
677 | return Object.keys(attributes || {}).reduce(function (acc, attributeName) {
|
---|
678 | return acc + "".concat(attributeName, "=\"").concat(htmlEscape(attributes[attributeName]), "\" ");
|
---|
679 | }, '').trim();
|
---|
680 | }
|
---|
681 | function joinStyles(styles) {
|
---|
682 | return Object.keys(styles || {}).reduce(function (acc, styleName) {
|
---|
683 | return acc + "".concat(styleName, ": ").concat(styles[styleName], ";");
|
---|
684 | }, '');
|
---|
685 | }
|
---|
686 | function transformIsMeaningful(transform) {
|
---|
687 | return transform.size !== meaninglessTransform.size || transform.x !== meaninglessTransform.x || transform.y !== meaninglessTransform.y || transform.rotate !== meaninglessTransform.rotate || transform.flipX || transform.flipY;
|
---|
688 | }
|
---|
689 | function transformForSvg(_ref) {
|
---|
690 | var transform = _ref.transform,
|
---|
691 | containerWidth = _ref.containerWidth,
|
---|
692 | iconWidth = _ref.iconWidth;
|
---|
693 | var outer = {
|
---|
694 | transform: "translate(".concat(containerWidth / 2, " 256)")
|
---|
695 | };
|
---|
696 | var innerTranslate = "translate(".concat(transform.x * 32, ", ").concat(transform.y * 32, ") ");
|
---|
697 | var innerScale = "scale(".concat(transform.size / 16 * (transform.flipX ? -1 : 1), ", ").concat(transform.size / 16 * (transform.flipY ? -1 : 1), ") ");
|
---|
698 | var innerRotate = "rotate(".concat(transform.rotate, " 0 0)");
|
---|
699 | var inner = {
|
---|
700 | transform: "".concat(innerTranslate, " ").concat(innerScale, " ").concat(innerRotate)
|
---|
701 | };
|
---|
702 | var path = {
|
---|
703 | transform: "translate(".concat(iconWidth / 2 * -1, " -256)")
|
---|
704 | };
|
---|
705 | return {
|
---|
706 | outer: outer,
|
---|
707 | inner: inner,
|
---|
708 | path: path
|
---|
709 | };
|
---|
710 | }
|
---|
711 | function transformForCss(_ref2) {
|
---|
712 | var transform = _ref2.transform,
|
---|
713 | _ref2$width = _ref2.width,
|
---|
714 | width = _ref2$width === void 0 ? UNITS_IN_GRID : _ref2$width,
|
---|
715 | _ref2$height = _ref2.height,
|
---|
716 | height = _ref2$height === void 0 ? UNITS_IN_GRID : _ref2$height,
|
---|
717 | _ref2$startCentered = _ref2.startCentered,
|
---|
718 | startCentered = _ref2$startCentered === void 0 ? false : _ref2$startCentered;
|
---|
719 | var val = '';
|
---|
720 |
|
---|
721 | if (startCentered && IS_IE) {
|
---|
722 | val += "translate(".concat(transform.x / d - width / 2, "em, ").concat(transform.y / d - height / 2, "em) ");
|
---|
723 | } else if (startCentered) {
|
---|
724 | val += "translate(calc(-50% + ".concat(transform.x / d, "em), calc(-50% + ").concat(transform.y / d, "em)) ");
|
---|
725 | } else {
|
---|
726 | val += "translate(".concat(transform.x / d, "em, ").concat(transform.y / d, "em) ");
|
---|
727 | }
|
---|
728 |
|
---|
729 | val += "scale(".concat(transform.size / d * (transform.flipX ? -1 : 1), ", ").concat(transform.size / d * (transform.flipY ? -1 : 1), ") ");
|
---|
730 | val += "rotate(".concat(transform.rotate, "deg) ");
|
---|
731 | return val;
|
---|
732 | }
|
---|
733 |
|
---|
734 | var ALL_SPACE = {
|
---|
735 | x: 0,
|
---|
736 | y: 0,
|
---|
737 | width: '100%',
|
---|
738 | height: '100%'
|
---|
739 | };
|
---|
740 |
|
---|
741 | function fillBlack(abstract) {
|
---|
742 | var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
---|
743 |
|
---|
744 | if (abstract.attributes && (abstract.attributes.fill || force)) {
|
---|
745 | abstract.attributes.fill = 'black';
|
---|
746 | }
|
---|
747 |
|
---|
748 | return abstract;
|
---|
749 | }
|
---|
750 |
|
---|
751 | function deGroup(abstract) {
|
---|
752 | if (abstract.tag === 'g') {
|
---|
753 | return abstract.children;
|
---|
754 | } else {
|
---|
755 | return [abstract];
|
---|
756 | }
|
---|
757 | }
|
---|
758 |
|
---|
759 | function makeIconMasking (_ref) {
|
---|
760 | var children = _ref.children,
|
---|
761 | attributes = _ref.attributes,
|
---|
762 | main = _ref.main,
|
---|
763 | mask = _ref.mask,
|
---|
764 | explicitMaskId = _ref.maskId,
|
---|
765 | transform = _ref.transform;
|
---|
766 | var mainWidth = main.width,
|
---|
767 | mainPath = main.icon;
|
---|
768 | var maskWidth = mask.width,
|
---|
769 | maskPath = mask.icon;
|
---|
770 | var trans = transformForSvg({
|
---|
771 | transform: transform,
|
---|
772 | containerWidth: maskWidth,
|
---|
773 | iconWidth: mainWidth
|
---|
774 | });
|
---|
775 | var maskRect = {
|
---|
776 | tag: 'rect',
|
---|
777 | attributes: _objectSpread({}, ALL_SPACE, {
|
---|
778 | fill: 'white'
|
---|
779 | })
|
---|
780 | };
|
---|
781 | var maskInnerGroupChildrenMixin = mainPath.children ? {
|
---|
782 | children: mainPath.children.map(fillBlack)
|
---|
783 | } : {};
|
---|
784 | var maskInnerGroup = {
|
---|
785 | tag: 'g',
|
---|
786 | attributes: _objectSpread({}, trans.inner),
|
---|
787 | children: [fillBlack(_objectSpread({
|
---|
788 | tag: mainPath.tag,
|
---|
789 | attributes: _objectSpread({}, mainPath.attributes, trans.path)
|
---|
790 | }, maskInnerGroupChildrenMixin))]
|
---|
791 | };
|
---|
792 | var maskOuterGroup = {
|
---|
793 | tag: 'g',
|
---|
794 | attributes: _objectSpread({}, trans.outer),
|
---|
795 | children: [maskInnerGroup]
|
---|
796 | };
|
---|
797 | var maskId = "mask-".concat(explicitMaskId || nextUniqueId());
|
---|
798 | var clipId = "clip-".concat(explicitMaskId || nextUniqueId());
|
---|
799 | var maskTag = {
|
---|
800 | tag: 'mask',
|
---|
801 | attributes: _objectSpread({}, ALL_SPACE, {
|
---|
802 | id: maskId,
|
---|
803 | maskUnits: 'userSpaceOnUse',
|
---|
804 | maskContentUnits: 'userSpaceOnUse'
|
---|
805 | }),
|
---|
806 | children: [maskRect, maskOuterGroup]
|
---|
807 | };
|
---|
808 | var defs = {
|
---|
809 | tag: 'defs',
|
---|
810 | children: [{
|
---|
811 | tag: 'clipPath',
|
---|
812 | attributes: {
|
---|
813 | id: clipId
|
---|
814 | },
|
---|
815 | children: deGroup(maskPath)
|
---|
816 | }, maskTag]
|
---|
817 | };
|
---|
818 | children.push(defs, {
|
---|
819 | tag: 'rect',
|
---|
820 | attributes: _objectSpread({
|
---|
821 | fill: 'currentColor',
|
---|
822 | 'clip-path': "url(#".concat(clipId, ")"),
|
---|
823 | mask: "url(#".concat(maskId, ")")
|
---|
824 | }, ALL_SPACE)
|
---|
825 | });
|
---|
826 | return {
|
---|
827 | children: children,
|
---|
828 | attributes: attributes
|
---|
829 | };
|
---|
830 | }
|
---|
831 |
|
---|
832 | function makeIconStandard (_ref) {
|
---|
833 | var children = _ref.children,
|
---|
834 | attributes = _ref.attributes,
|
---|
835 | main = _ref.main,
|
---|
836 | transform = _ref.transform,
|
---|
837 | styles = _ref.styles;
|
---|
838 | var styleString = joinStyles(styles);
|
---|
839 |
|
---|
840 | if (styleString.length > 0) {
|
---|
841 | attributes['style'] = styleString;
|
---|
842 | }
|
---|
843 |
|
---|
844 | if (transformIsMeaningful(transform)) {
|
---|
845 | var trans = transformForSvg({
|
---|
846 | transform: transform,
|
---|
847 | containerWidth: main.width,
|
---|
848 | iconWidth: main.width
|
---|
849 | });
|
---|
850 | children.push({
|
---|
851 | tag: 'g',
|
---|
852 | attributes: _objectSpread({}, trans.outer),
|
---|
853 | children: [{
|
---|
854 | tag: 'g',
|
---|
855 | attributes: _objectSpread({}, trans.inner),
|
---|
856 | children: [{
|
---|
857 | tag: main.icon.tag,
|
---|
858 | children: main.icon.children,
|
---|
859 | attributes: _objectSpread({}, main.icon.attributes, trans.path)
|
---|
860 | }]
|
---|
861 | }]
|
---|
862 | });
|
---|
863 | } else {
|
---|
864 | children.push(main.icon);
|
---|
865 | }
|
---|
866 |
|
---|
867 | return {
|
---|
868 | children: children,
|
---|
869 | attributes: attributes
|
---|
870 | };
|
---|
871 | }
|
---|
872 |
|
---|
873 | function asIcon (_ref) {
|
---|
874 | var children = _ref.children,
|
---|
875 | main = _ref.main,
|
---|
876 | mask = _ref.mask,
|
---|
877 | attributes = _ref.attributes,
|
---|
878 | styles = _ref.styles,
|
---|
879 | transform = _ref.transform;
|
---|
880 |
|
---|
881 | if (transformIsMeaningful(transform) && main.found && !mask.found) {
|
---|
882 | var width = main.width,
|
---|
883 | height = main.height;
|
---|
884 | var offset = {
|
---|
885 | x: width / height / 2,
|
---|
886 | y: 0.5
|
---|
887 | };
|
---|
888 | attributes['style'] = joinStyles(_objectSpread({}, styles, {
|
---|
889 | 'transform-origin': "".concat(offset.x + transform.x / 16, "em ").concat(offset.y + transform.y / 16, "em")
|
---|
890 | }));
|
---|
891 | }
|
---|
892 |
|
---|
893 | return [{
|
---|
894 | tag: 'svg',
|
---|
895 | attributes: attributes,
|
---|
896 | children: children
|
---|
897 | }];
|
---|
898 | }
|
---|
899 |
|
---|
900 | function asSymbol (_ref) {
|
---|
901 | var prefix = _ref.prefix,
|
---|
902 | iconName = _ref.iconName,
|
---|
903 | children = _ref.children,
|
---|
904 | attributes = _ref.attributes,
|
---|
905 | symbol = _ref.symbol;
|
---|
906 | var id = symbol === true ? "".concat(prefix, "-").concat(config.familyPrefix, "-").concat(iconName) : symbol;
|
---|
907 | return [{
|
---|
908 | tag: 'svg',
|
---|
909 | attributes: {
|
---|
910 | style: 'display: none;'
|
---|
911 | },
|
---|
912 | children: [{
|
---|
913 | tag: 'symbol',
|
---|
914 | attributes: _objectSpread({}, attributes, {
|
---|
915 | id: id
|
---|
916 | }),
|
---|
917 | children: children
|
---|
918 | }]
|
---|
919 | }];
|
---|
920 | }
|
---|
921 |
|
---|
922 | function makeInlineSvgAbstract(params) {
|
---|
923 | var _params$icons = params.icons,
|
---|
924 | main = _params$icons.main,
|
---|
925 | mask = _params$icons.mask,
|
---|
926 | prefix = params.prefix,
|
---|
927 | iconName = params.iconName,
|
---|
928 | transform = params.transform,
|
---|
929 | symbol = params.symbol,
|
---|
930 | title = params.title,
|
---|
931 | maskId = params.maskId,
|
---|
932 | titleId = params.titleId,
|
---|
933 | extra = params.extra,
|
---|
934 | _params$watchable = params.watchable,
|
---|
935 | watchable = _params$watchable === void 0 ? false : _params$watchable;
|
---|
936 |
|
---|
937 | var _ref = mask.found ? mask : main,
|
---|
938 | width = _ref.width,
|
---|
939 | height = _ref.height;
|
---|
940 |
|
---|
941 | var isUploadedIcon = prefix === 'fak';
|
---|
942 | var widthClass = isUploadedIcon ? '' : "fa-w-".concat(Math.ceil(width / height * 16));
|
---|
943 | var attrClass = [config.replacementClass, iconName ? "".concat(config.familyPrefix, "-").concat(iconName) : '', widthClass].filter(function (c) {
|
---|
944 | return extra.classes.indexOf(c) === -1;
|
---|
945 | }).filter(function (c) {
|
---|
946 | return c !== '' || !!c;
|
---|
947 | }).concat(extra.classes).join(' ');
|
---|
948 | var content = {
|
---|
949 | children: [],
|
---|
950 | attributes: _objectSpread({}, extra.attributes, {
|
---|
951 | 'data-prefix': prefix,
|
---|
952 | 'data-icon': iconName,
|
---|
953 | 'class': attrClass,
|
---|
954 | 'role': extra.attributes.role || 'img',
|
---|
955 | 'xmlns': 'http://www.w3.org/2000/svg',
|
---|
956 | 'viewBox': "0 0 ".concat(width, " ").concat(height)
|
---|
957 | })
|
---|
958 | };
|
---|
959 | var uploadedIconWidthStyle = isUploadedIcon && !~extra.classes.indexOf('fa-fw') ? {
|
---|
960 | width: "".concat(width / height * 16 * 0.0625, "em")
|
---|
961 | } : {};
|
---|
962 |
|
---|
963 | if (watchable) {
|
---|
964 | content.attributes[DATA_FA_I2SVG] = '';
|
---|
965 | }
|
---|
966 |
|
---|
967 | if (title) content.children.push({
|
---|
968 | tag: 'title',
|
---|
969 | attributes: {
|
---|
970 | id: content.attributes['aria-labelledby'] || "title-".concat(titleId || nextUniqueId())
|
---|
971 | },
|
---|
972 | children: [title]
|
---|
973 | });
|
---|
974 |
|
---|
975 | var args = _objectSpread({}, content, {
|
---|
976 | prefix: prefix,
|
---|
977 | iconName: iconName,
|
---|
978 | main: main,
|
---|
979 | mask: mask,
|
---|
980 | maskId: maskId,
|
---|
981 | transform: transform,
|
---|
982 | symbol: symbol,
|
---|
983 | styles: _objectSpread({}, uploadedIconWidthStyle, extra.styles)
|
---|
984 | });
|
---|
985 |
|
---|
986 | var _ref2 = mask.found && main.found ? makeIconMasking(args) : makeIconStandard(args),
|
---|
987 | children = _ref2.children,
|
---|
988 | attributes = _ref2.attributes;
|
---|
989 |
|
---|
990 | args.children = children;
|
---|
991 | args.attributes = attributes;
|
---|
992 |
|
---|
993 | if (symbol) {
|
---|
994 | return asSymbol(args);
|
---|
995 | } else {
|
---|
996 | return asIcon(args);
|
---|
997 | }
|
---|
998 | }
|
---|
999 | function makeLayersTextAbstract(params) {
|
---|
1000 | var content = params.content,
|
---|
1001 | width = params.width,
|
---|
1002 | height = params.height,
|
---|
1003 | transform = params.transform,
|
---|
1004 | title = params.title,
|
---|
1005 | extra = params.extra,
|
---|
1006 | _params$watchable2 = params.watchable,
|
---|
1007 | watchable = _params$watchable2 === void 0 ? false : _params$watchable2;
|
---|
1008 |
|
---|
1009 | var attributes = _objectSpread({}, extra.attributes, title ? {
|
---|
1010 | 'title': title
|
---|
1011 | } : {}, {
|
---|
1012 | 'class': extra.classes.join(' ')
|
---|
1013 | });
|
---|
1014 |
|
---|
1015 | if (watchable) {
|
---|
1016 | attributes[DATA_FA_I2SVG] = '';
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | var styles = _objectSpread({}, extra.styles);
|
---|
1020 |
|
---|
1021 | if (transformIsMeaningful(transform)) {
|
---|
1022 | styles['transform'] = transformForCss({
|
---|
1023 | transform: transform,
|
---|
1024 | startCentered: true,
|
---|
1025 | width: width,
|
---|
1026 | height: height
|
---|
1027 | });
|
---|
1028 | styles['-webkit-transform'] = styles['transform'];
|
---|
1029 | }
|
---|
1030 |
|
---|
1031 | var styleString = joinStyles(styles);
|
---|
1032 |
|
---|
1033 | if (styleString.length > 0) {
|
---|
1034 | attributes['style'] = styleString;
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | var val = [];
|
---|
1038 | val.push({
|
---|
1039 | tag: 'span',
|
---|
1040 | attributes: attributes,
|
---|
1041 | children: [content]
|
---|
1042 | });
|
---|
1043 |
|
---|
1044 | if (title) {
|
---|
1045 | val.push({
|
---|
1046 | tag: 'span',
|
---|
1047 | attributes: {
|
---|
1048 | class: 'sr-only'
|
---|
1049 | },
|
---|
1050 | children: [title]
|
---|
1051 | });
|
---|
1052 | }
|
---|
1053 |
|
---|
1054 | return val;
|
---|
1055 | }
|
---|
1056 | function makeLayersCounterAbstract(params) {
|
---|
1057 | var content = params.content,
|
---|
1058 | title = params.title,
|
---|
1059 | extra = params.extra;
|
---|
1060 |
|
---|
1061 | var attributes = _objectSpread({}, extra.attributes, title ? {
|
---|
1062 | 'title': title
|
---|
1063 | } : {}, {
|
---|
1064 | 'class': extra.classes.join(' ')
|
---|
1065 | });
|
---|
1066 |
|
---|
1067 | var styleString = joinStyles(extra.styles);
|
---|
1068 |
|
---|
1069 | if (styleString.length > 0) {
|
---|
1070 | attributes['style'] = styleString;
|
---|
1071 | }
|
---|
1072 |
|
---|
1073 | var val = [];
|
---|
1074 | val.push({
|
---|
1075 | tag: 'span',
|
---|
1076 | attributes: attributes,
|
---|
1077 | children: [content]
|
---|
1078 | });
|
---|
1079 |
|
---|
1080 | if (title) {
|
---|
1081 | val.push({
|
---|
1082 | tag: 'span',
|
---|
1083 | attributes: {
|
---|
1084 | class: 'sr-only'
|
---|
1085 | },
|
---|
1086 | children: [title]
|
---|
1087 | });
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | return val;
|
---|
1091 | }
|
---|
1092 |
|
---|
1093 | var noop$1 = function noop() {};
|
---|
1094 |
|
---|
1095 | var p = config.measurePerformance && PERFORMANCE && PERFORMANCE.mark && PERFORMANCE.measure ? PERFORMANCE : {
|
---|
1096 | mark: noop$1,
|
---|
1097 | measure: noop$1
|
---|
1098 | };
|
---|
1099 | var preamble = "FA \"5.15.4\"";
|
---|
1100 |
|
---|
1101 | var begin = function begin(name) {
|
---|
1102 | p.mark("".concat(preamble, " ").concat(name, " begins"));
|
---|
1103 | return function () {
|
---|
1104 | return end(name);
|
---|
1105 | };
|
---|
1106 | };
|
---|
1107 |
|
---|
1108 | var end = function end(name) {
|
---|
1109 | p.mark("".concat(preamble, " ").concat(name, " ends"));
|
---|
1110 | p.measure("".concat(preamble, " ").concat(name), "".concat(preamble, " ").concat(name, " begins"), "".concat(preamble, " ").concat(name, " ends"));
|
---|
1111 | };
|
---|
1112 |
|
---|
1113 | var perf = {
|
---|
1114 | begin: begin,
|
---|
1115 | end: end
|
---|
1116 | };
|
---|
1117 |
|
---|
1118 | /**
|
---|
1119 | * Internal helper to bind a function known to have 4 arguments
|
---|
1120 | * to a given context.
|
---|
1121 | */
|
---|
1122 |
|
---|
1123 | var bindInternal4 = function bindInternal4(func, thisContext) {
|
---|
1124 | return function (a, b, c, d) {
|
---|
1125 | return func.call(thisContext, a, b, c, d);
|
---|
1126 | };
|
---|
1127 | };
|
---|
1128 |
|
---|
1129 | /**
|
---|
1130 | * # Reduce
|
---|
1131 | *
|
---|
1132 | * A fast object `.reduce()` implementation.
|
---|
1133 | *
|
---|
1134 | * @param {Object} subject The object to reduce over.
|
---|
1135 | * @param {Function} fn The reducer function.
|
---|
1136 | * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
|
---|
1137 | * @param {Object} thisContext The context for the reducer.
|
---|
1138 | * @return {mixed} The final result.
|
---|
1139 | */
|
---|
1140 |
|
---|
1141 |
|
---|
1142 | var reduce = function fastReduceObject(subject, fn, initialValue, thisContext) {
|
---|
1143 | var keys = Object.keys(subject),
|
---|
1144 | length = keys.length,
|
---|
1145 | iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
|
---|
1146 | i,
|
---|
1147 | key,
|
---|
1148 | result;
|
---|
1149 |
|
---|
1150 | if (initialValue === undefined) {
|
---|
1151 | i = 1;
|
---|
1152 | result = subject[keys[0]];
|
---|
1153 | } else {
|
---|
1154 | i = 0;
|
---|
1155 | result = initialValue;
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | for (; i < length; i++) {
|
---|
1159 | key = keys[i];
|
---|
1160 | result = iterator(result, subject[key], key, subject);
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | return result;
|
---|
1164 | };
|
---|
1165 |
|
---|
1166 | function toHex(unicode) {
|
---|
1167 | var result = '';
|
---|
1168 |
|
---|
1169 | for (var i = 0; i < unicode.length; i++) {
|
---|
1170 | var hex = unicode.charCodeAt(i).toString(16);
|
---|
1171 | result += ('000' + hex).slice(-4);
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | return result;
|
---|
1175 | }
|
---|
1176 |
|
---|
1177 | function defineIcons(prefix, icons) {
|
---|
1178 | var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
---|
1179 | var _params$skipHooks = params.skipHooks,
|
---|
1180 | skipHooks = _params$skipHooks === void 0 ? false : _params$skipHooks;
|
---|
1181 | var normalized = Object.keys(icons).reduce(function (acc, iconName) {
|
---|
1182 | var icon = icons[iconName];
|
---|
1183 | var expanded = !!icon.icon;
|
---|
1184 |
|
---|
1185 | if (expanded) {
|
---|
1186 | acc[icon.iconName] = icon.icon;
|
---|
1187 | } else {
|
---|
1188 | acc[iconName] = icon;
|
---|
1189 | }
|
---|
1190 |
|
---|
1191 | return acc;
|
---|
1192 | }, {});
|
---|
1193 |
|
---|
1194 | if (typeof namespace.hooks.addPack === 'function' && !skipHooks) {
|
---|
1195 | namespace.hooks.addPack(prefix, normalized);
|
---|
1196 | } else {
|
---|
1197 | namespace.styles[prefix] = _objectSpread({}, namespace.styles[prefix] || {}, normalized);
|
---|
1198 | }
|
---|
1199 | /**
|
---|
1200 | * Font Awesome 4 used the prefix of `fa` for all icons. With the introduction
|
---|
1201 | * of new styles we needed to differentiate between them. Prefix `fa` is now an alias
|
---|
1202 | * for `fas` so we'll easy the upgrade process for our users by automatically defining
|
---|
1203 | * this as well.
|
---|
1204 | */
|
---|
1205 |
|
---|
1206 |
|
---|
1207 | if (prefix === 'fas') {
|
---|
1208 | defineIcons('fa', icons);
|
---|
1209 | }
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | var styles = namespace.styles,
|
---|
1213 | shims = namespace.shims;
|
---|
1214 | var _byUnicode = {};
|
---|
1215 | var _byLigature = {};
|
---|
1216 | var _byOldName = {};
|
---|
1217 | var build = function build() {
|
---|
1218 | var lookup = function lookup(reducer) {
|
---|
1219 | return reduce(styles, function (o, style, prefix) {
|
---|
1220 | o[prefix] = reduce(style, reducer, {});
|
---|
1221 | return o;
|
---|
1222 | }, {});
|
---|
1223 | };
|
---|
1224 |
|
---|
1225 | _byUnicode = lookup(function (acc, icon, iconName) {
|
---|
1226 | if (icon[3]) {
|
---|
1227 | acc[icon[3]] = iconName;
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | return acc;
|
---|
1231 | });
|
---|
1232 | _byLigature = lookup(function (acc, icon, iconName) {
|
---|
1233 | var ligatures = icon[2];
|
---|
1234 | acc[iconName] = iconName;
|
---|
1235 | ligatures.forEach(function (ligature) {
|
---|
1236 | acc[ligature] = iconName;
|
---|
1237 | });
|
---|
1238 | return acc;
|
---|
1239 | });
|
---|
1240 | var hasRegular = 'far' in styles;
|
---|
1241 | _byOldName = reduce(shims, function (acc, shim) {
|
---|
1242 | var oldName = shim[0];
|
---|
1243 | var prefix = shim[1];
|
---|
1244 | var iconName = shim[2];
|
---|
1245 |
|
---|
1246 | if (prefix === 'far' && !hasRegular) {
|
---|
1247 | prefix = 'fas';
|
---|
1248 | }
|
---|
1249 |
|
---|
1250 | acc[oldName] = {
|
---|
1251 | prefix: prefix,
|
---|
1252 | iconName: iconName
|
---|
1253 | };
|
---|
1254 | return acc;
|
---|
1255 | }, {});
|
---|
1256 | };
|
---|
1257 | build();
|
---|
1258 | function byUnicode(prefix, unicode) {
|
---|
1259 | return (_byUnicode[prefix] || {})[unicode];
|
---|
1260 | }
|
---|
1261 | function byLigature(prefix, ligature) {
|
---|
1262 | return (_byLigature[prefix] || {})[ligature];
|
---|
1263 | }
|
---|
1264 | function byOldName(name) {
|
---|
1265 | return _byOldName[name] || {
|
---|
1266 | prefix: null,
|
---|
1267 | iconName: null
|
---|
1268 | };
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | var styles$1 = namespace.styles;
|
---|
1272 | var emptyCanonicalIcon = function emptyCanonicalIcon() {
|
---|
1273 | return {
|
---|
1274 | prefix: null,
|
---|
1275 | iconName: null,
|
---|
1276 | rest: []
|
---|
1277 | };
|
---|
1278 | };
|
---|
1279 | function getCanonicalIcon(values) {
|
---|
1280 | return values.reduce(function (acc, cls) {
|
---|
1281 | var iconName = getIconName(config.familyPrefix, cls);
|
---|
1282 |
|
---|
1283 | if (styles$1[cls]) {
|
---|
1284 | acc.prefix = cls;
|
---|
1285 | } else if (config.autoFetchSvg && Object.keys(PREFIX_TO_STYLE).indexOf(cls) > -1) {
|
---|
1286 | acc.prefix = cls;
|
---|
1287 | } else if (iconName) {
|
---|
1288 | var shim = acc.prefix === 'fa' ? byOldName(iconName) : {};
|
---|
1289 | acc.iconName = shim.iconName || iconName;
|
---|
1290 | acc.prefix = shim.prefix || acc.prefix;
|
---|
1291 | } else if (cls !== config.replacementClass && cls.indexOf('fa-w-') !== 0) {
|
---|
1292 | acc.rest.push(cls);
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | return acc;
|
---|
1296 | }, emptyCanonicalIcon());
|
---|
1297 | }
|
---|
1298 | function iconFromMapping(mapping, prefix, iconName) {
|
---|
1299 | if (mapping && mapping[prefix] && mapping[prefix][iconName]) {
|
---|
1300 | return {
|
---|
1301 | prefix: prefix,
|
---|
1302 | iconName: iconName,
|
---|
1303 | icon: mapping[prefix][iconName]
|
---|
1304 | };
|
---|
1305 | }
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 | function toHtml(abstractNodes) {
|
---|
1309 | var tag = abstractNodes.tag,
|
---|
1310 | _abstractNodes$attrib = abstractNodes.attributes,
|
---|
1311 | attributes = _abstractNodes$attrib === void 0 ? {} : _abstractNodes$attrib,
|
---|
1312 | _abstractNodes$childr = abstractNodes.children,
|
---|
1313 | children = _abstractNodes$childr === void 0 ? [] : _abstractNodes$childr;
|
---|
1314 |
|
---|
1315 | if (typeof abstractNodes === 'string') {
|
---|
1316 | return htmlEscape(abstractNodes);
|
---|
1317 | } else {
|
---|
1318 | return "<".concat(tag, " ").concat(joinAttributes(attributes), ">").concat(children.map(toHtml).join(''), "</").concat(tag, ">");
|
---|
1319 | }
|
---|
1320 | }
|
---|
1321 |
|
---|
1322 | var noop$2 = function noop() {};
|
---|
1323 |
|
---|
1324 | function isWatched(node) {
|
---|
1325 | var i2svg = node.getAttribute ? node.getAttribute(DATA_FA_I2SVG) : null;
|
---|
1326 | return typeof i2svg === 'string';
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | function getMutator() {
|
---|
1330 | if (config.autoReplaceSvg === true) {
|
---|
1331 | return mutators.replace;
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | var mutator = mutators[config.autoReplaceSvg];
|
---|
1335 | return mutator || mutators.replace;
|
---|
1336 | }
|
---|
1337 |
|
---|
1338 | var mutators = {
|
---|
1339 | replace: function replace(mutation) {
|
---|
1340 | var node = mutation[0];
|
---|
1341 | var abstract = mutation[1];
|
---|
1342 | var newOuterHTML = abstract.map(function (a) {
|
---|
1343 | return toHtml(a);
|
---|
1344 | }).join('\n');
|
---|
1345 |
|
---|
1346 | if (node.parentNode && node.outerHTML) {
|
---|
1347 | node.outerHTML = newOuterHTML + (config.keepOriginalSource && node.tagName.toLowerCase() !== 'svg' ? "<!-- ".concat(node.outerHTML, " Font Awesome fontawesome.com -->") : '');
|
---|
1348 | } else if (node.parentNode) {
|
---|
1349 | var newNode = document.createElement('span');
|
---|
1350 | node.parentNode.replaceChild(newNode, node);
|
---|
1351 | newNode.outerHTML = newOuterHTML;
|
---|
1352 | }
|
---|
1353 | },
|
---|
1354 | nest: function nest(mutation) {
|
---|
1355 | var node = mutation[0];
|
---|
1356 | var abstract = mutation[1]; // If we already have a replaced node we do not want to continue nesting within it.
|
---|
1357 | // Short-circuit to the standard replacement
|
---|
1358 |
|
---|
1359 | if (~classArray(node).indexOf(config.replacementClass)) {
|
---|
1360 | return mutators.replace(mutation);
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 | var forSvg = new RegExp("".concat(config.familyPrefix, "-.*"));
|
---|
1364 | delete abstract[0].attributes.style;
|
---|
1365 | delete abstract[0].attributes.id;
|
---|
1366 | var splitClasses = abstract[0].attributes.class.split(' ').reduce(function (acc, cls) {
|
---|
1367 | if (cls === config.replacementClass || cls.match(forSvg)) {
|
---|
1368 | acc.toSvg.push(cls);
|
---|
1369 | } else {
|
---|
1370 | acc.toNode.push(cls);
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | return acc;
|
---|
1374 | }, {
|
---|
1375 | toNode: [],
|
---|
1376 | toSvg: []
|
---|
1377 | });
|
---|
1378 | abstract[0].attributes.class = splitClasses.toSvg.join(' ');
|
---|
1379 | var newInnerHTML = abstract.map(function (a) {
|
---|
1380 | return toHtml(a);
|
---|
1381 | }).join('\n');
|
---|
1382 | node.setAttribute('class', splitClasses.toNode.join(' '));
|
---|
1383 | node.setAttribute(DATA_FA_I2SVG, '');
|
---|
1384 | node.innerHTML = newInnerHTML;
|
---|
1385 | }
|
---|
1386 | };
|
---|
1387 |
|
---|
1388 | function performOperationSync(op) {
|
---|
1389 | op();
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | function perform(mutations, callback) {
|
---|
1393 | var callbackFunction = typeof callback === 'function' ? callback : noop$2;
|
---|
1394 |
|
---|
1395 | if (mutations.length === 0) {
|
---|
1396 | callbackFunction();
|
---|
1397 | } else {
|
---|
1398 | var frame = performOperationSync;
|
---|
1399 |
|
---|
1400 | if (config.mutateApproach === MUTATION_APPROACH_ASYNC) {
|
---|
1401 | frame = WINDOW.requestAnimationFrame || performOperationSync;
|
---|
1402 | }
|
---|
1403 |
|
---|
1404 | frame(function () {
|
---|
1405 | var mutator = getMutator();
|
---|
1406 | var mark = perf.begin('mutate');
|
---|
1407 | mutations.map(mutator);
|
---|
1408 | mark();
|
---|
1409 | callbackFunction();
|
---|
1410 | });
|
---|
1411 | }
|
---|
1412 | }
|
---|
1413 | var disabled = false;
|
---|
1414 | function disableObservation() {
|
---|
1415 | disabled = true;
|
---|
1416 | }
|
---|
1417 | function enableObservation() {
|
---|
1418 | disabled = false;
|
---|
1419 | }
|
---|
1420 | var mo = null;
|
---|
1421 | function observe(options) {
|
---|
1422 | if (!MUTATION_OBSERVER) {
|
---|
1423 | return;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | if (!config.observeMutations) {
|
---|
1427 | return;
|
---|
1428 | }
|
---|
1429 |
|
---|
1430 | var treeCallback = options.treeCallback,
|
---|
1431 | nodeCallback = options.nodeCallback,
|
---|
1432 | pseudoElementsCallback = options.pseudoElementsCallback,
|
---|
1433 | _options$observeMutat = options.observeMutationsRoot,
|
---|
1434 | observeMutationsRoot = _options$observeMutat === void 0 ? DOCUMENT : _options$observeMutat;
|
---|
1435 | mo = new MUTATION_OBSERVER(function (objects) {
|
---|
1436 | if (disabled) return;
|
---|
1437 | toArray(objects).forEach(function (mutationRecord) {
|
---|
1438 | if (mutationRecord.type === 'childList' && mutationRecord.addedNodes.length > 0 && !isWatched(mutationRecord.addedNodes[0])) {
|
---|
1439 | if (config.searchPseudoElements) {
|
---|
1440 | pseudoElementsCallback(mutationRecord.target);
|
---|
1441 | }
|
---|
1442 |
|
---|
1443 | treeCallback(mutationRecord.target);
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | if (mutationRecord.type === 'attributes' && mutationRecord.target.parentNode && config.searchPseudoElements) {
|
---|
1447 | pseudoElementsCallback(mutationRecord.target.parentNode);
|
---|
1448 | }
|
---|
1449 |
|
---|
1450 | if (mutationRecord.type === 'attributes' && isWatched(mutationRecord.target) && ~ATTRIBUTES_WATCHED_FOR_MUTATION.indexOf(mutationRecord.attributeName)) {
|
---|
1451 | if (mutationRecord.attributeName === 'class') {
|
---|
1452 | var _getCanonicalIcon = getCanonicalIcon(classArray(mutationRecord.target)),
|
---|
1453 | prefix = _getCanonicalIcon.prefix,
|
---|
1454 | iconName = _getCanonicalIcon.iconName;
|
---|
1455 |
|
---|
1456 | if (prefix) mutationRecord.target.setAttribute('data-prefix', prefix);
|
---|
1457 | if (iconName) mutationRecord.target.setAttribute('data-icon', iconName);
|
---|
1458 | } else {
|
---|
1459 | nodeCallback(mutationRecord.target);
|
---|
1460 | }
|
---|
1461 | }
|
---|
1462 | });
|
---|
1463 | });
|
---|
1464 | if (!IS_DOM) return;
|
---|
1465 | mo.observe(observeMutationsRoot, {
|
---|
1466 | childList: true,
|
---|
1467 | attributes: true,
|
---|
1468 | characterData: true,
|
---|
1469 | subtree: true
|
---|
1470 | });
|
---|
1471 | }
|
---|
1472 | function disconnect() {
|
---|
1473 | if (!mo) return;
|
---|
1474 | mo.disconnect();
|
---|
1475 | }
|
---|
1476 |
|
---|
1477 | function styleParser (node) {
|
---|
1478 | var style = node.getAttribute('style');
|
---|
1479 | var val = [];
|
---|
1480 |
|
---|
1481 | if (style) {
|
---|
1482 | val = style.split(';').reduce(function (acc, style) {
|
---|
1483 | var styles = style.split(':');
|
---|
1484 | var prop = styles[0];
|
---|
1485 | var value = styles.slice(1);
|
---|
1486 |
|
---|
1487 | if (prop && value.length > 0) {
|
---|
1488 | acc[prop] = value.join(':').trim();
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | return acc;
|
---|
1492 | }, {});
|
---|
1493 | }
|
---|
1494 |
|
---|
1495 | return val;
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 | function classParser (node) {
|
---|
1499 | var existingPrefix = node.getAttribute('data-prefix');
|
---|
1500 | var existingIconName = node.getAttribute('data-icon');
|
---|
1501 | var innerText = node.innerText !== undefined ? node.innerText.trim() : '';
|
---|
1502 | var val = getCanonicalIcon(classArray(node));
|
---|
1503 |
|
---|
1504 | if (existingPrefix && existingIconName) {
|
---|
1505 | val.prefix = existingPrefix;
|
---|
1506 | val.iconName = existingIconName;
|
---|
1507 | }
|
---|
1508 |
|
---|
1509 | if (val.prefix && innerText.length > 1) {
|
---|
1510 | val.iconName = byLigature(val.prefix, node.innerText);
|
---|
1511 | } else if (val.prefix && innerText.length === 1) {
|
---|
1512 | val.iconName = byUnicode(val.prefix, toHex(node.innerText));
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 | return val;
|
---|
1516 | }
|
---|
1517 |
|
---|
1518 | var parseTransformString = function parseTransformString(transformString) {
|
---|
1519 | var transform = {
|
---|
1520 | size: 16,
|
---|
1521 | x: 0,
|
---|
1522 | y: 0,
|
---|
1523 | flipX: false,
|
---|
1524 | flipY: false,
|
---|
1525 | rotate: 0
|
---|
1526 | };
|
---|
1527 |
|
---|
1528 | if (!transformString) {
|
---|
1529 | return transform;
|
---|
1530 | } else {
|
---|
1531 | return transformString.toLowerCase().split(' ').reduce(function (acc, n) {
|
---|
1532 | var parts = n.toLowerCase().split('-');
|
---|
1533 | var first = parts[0];
|
---|
1534 | var rest = parts.slice(1).join('-');
|
---|
1535 |
|
---|
1536 | if (first && rest === 'h') {
|
---|
1537 | acc.flipX = true;
|
---|
1538 | return acc;
|
---|
1539 | }
|
---|
1540 |
|
---|
1541 | if (first && rest === 'v') {
|
---|
1542 | acc.flipY = true;
|
---|
1543 | return acc;
|
---|
1544 | }
|
---|
1545 |
|
---|
1546 | rest = parseFloat(rest);
|
---|
1547 |
|
---|
1548 | if (isNaN(rest)) {
|
---|
1549 | return acc;
|
---|
1550 | }
|
---|
1551 |
|
---|
1552 | switch (first) {
|
---|
1553 | case 'grow':
|
---|
1554 | acc.size = acc.size + rest;
|
---|
1555 | break;
|
---|
1556 |
|
---|
1557 | case 'shrink':
|
---|
1558 | acc.size = acc.size - rest;
|
---|
1559 | break;
|
---|
1560 |
|
---|
1561 | case 'left':
|
---|
1562 | acc.x = acc.x - rest;
|
---|
1563 | break;
|
---|
1564 |
|
---|
1565 | case 'right':
|
---|
1566 | acc.x = acc.x + rest;
|
---|
1567 | break;
|
---|
1568 |
|
---|
1569 | case 'up':
|
---|
1570 | acc.y = acc.y - rest;
|
---|
1571 | break;
|
---|
1572 |
|
---|
1573 | case 'down':
|
---|
1574 | acc.y = acc.y + rest;
|
---|
1575 | break;
|
---|
1576 |
|
---|
1577 | case 'rotate':
|
---|
1578 | acc.rotate = acc.rotate + rest;
|
---|
1579 | break;
|
---|
1580 | }
|
---|
1581 |
|
---|
1582 | return acc;
|
---|
1583 | }, transform);
|
---|
1584 | }
|
---|
1585 | };
|
---|
1586 | function transformParser (node) {
|
---|
1587 | return parseTransformString(node.getAttribute('data-fa-transform'));
|
---|
1588 | }
|
---|
1589 |
|
---|
1590 | function symbolParser (node) {
|
---|
1591 | var symbol = node.getAttribute('data-fa-symbol');
|
---|
1592 | return symbol === null ? false : symbol === '' ? true : symbol;
|
---|
1593 | }
|
---|
1594 |
|
---|
1595 | function attributesParser (node) {
|
---|
1596 | var extraAttributes = toArray(node.attributes).reduce(function (acc, attr) {
|
---|
1597 | if (acc.name !== 'class' && acc.name !== 'style') {
|
---|
1598 | acc[attr.name] = attr.value;
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 | return acc;
|
---|
1602 | }, {});
|
---|
1603 | var title = node.getAttribute('title');
|
---|
1604 | var titleId = node.getAttribute('data-fa-title-id');
|
---|
1605 |
|
---|
1606 | if (config.autoA11y) {
|
---|
1607 | if (title) {
|
---|
1608 | extraAttributes['aria-labelledby'] = "".concat(config.replacementClass, "-title-").concat(titleId || nextUniqueId());
|
---|
1609 | } else {
|
---|
1610 | extraAttributes['aria-hidden'] = 'true';
|
---|
1611 | extraAttributes['focusable'] = 'false';
|
---|
1612 | }
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | return extraAttributes;
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 | function maskParser (node) {
|
---|
1619 | var mask = node.getAttribute('data-fa-mask');
|
---|
1620 |
|
---|
1621 | if (!mask) {
|
---|
1622 | return emptyCanonicalIcon();
|
---|
1623 | } else {
|
---|
1624 | return getCanonicalIcon(mask.split(' ').map(function (i) {
|
---|
1625 | return i.trim();
|
---|
1626 | }));
|
---|
1627 | }
|
---|
1628 | }
|
---|
1629 |
|
---|
1630 | function blankMeta() {
|
---|
1631 | return {
|
---|
1632 | iconName: null,
|
---|
1633 | title: null,
|
---|
1634 | titleId: null,
|
---|
1635 | prefix: null,
|
---|
1636 | transform: meaninglessTransform,
|
---|
1637 | symbol: false,
|
---|
1638 | mask: null,
|
---|
1639 | maskId: null,
|
---|
1640 | extra: {
|
---|
1641 | classes: [],
|
---|
1642 | styles: {},
|
---|
1643 | attributes: {}
|
---|
1644 | }
|
---|
1645 | };
|
---|
1646 | }
|
---|
1647 | function parseMeta(node) {
|
---|
1648 | var _classParser = classParser(node),
|
---|
1649 | iconName = _classParser.iconName,
|
---|
1650 | prefix = _classParser.prefix,
|
---|
1651 | extraClasses = _classParser.rest;
|
---|
1652 |
|
---|
1653 | var extraStyles = styleParser(node);
|
---|
1654 | var transform = transformParser(node);
|
---|
1655 | var symbol = symbolParser(node);
|
---|
1656 | var extraAttributes = attributesParser(node);
|
---|
1657 | var mask = maskParser(node);
|
---|
1658 | return {
|
---|
1659 | iconName: iconName,
|
---|
1660 | title: node.getAttribute('title'),
|
---|
1661 | titleId: node.getAttribute('data-fa-title-id'),
|
---|
1662 | prefix: prefix,
|
---|
1663 | transform: transform,
|
---|
1664 | symbol: symbol,
|
---|
1665 | mask: mask,
|
---|
1666 | maskId: node.getAttribute('data-fa-mask-id'),
|
---|
1667 | extra: {
|
---|
1668 | classes: extraClasses,
|
---|
1669 | styles: extraStyles,
|
---|
1670 | attributes: extraAttributes
|
---|
1671 | }
|
---|
1672 | };
|
---|
1673 | }
|
---|
1674 |
|
---|
1675 | function MissingIcon(error) {
|
---|
1676 | this.name = 'MissingIcon';
|
---|
1677 | this.message = error || 'Icon unavailable';
|
---|
1678 | this.stack = new Error().stack;
|
---|
1679 | }
|
---|
1680 | MissingIcon.prototype = Object.create(Error.prototype);
|
---|
1681 | MissingIcon.prototype.constructor = MissingIcon;
|
---|
1682 |
|
---|
1683 | var FILL = {
|
---|
1684 | fill: 'currentColor'
|
---|
1685 | };
|
---|
1686 | var ANIMATION_BASE = {
|
---|
1687 | attributeType: 'XML',
|
---|
1688 | repeatCount: 'indefinite',
|
---|
1689 | dur: '2s'
|
---|
1690 | };
|
---|
1691 | var RING = {
|
---|
1692 | tag: 'path',
|
---|
1693 | attributes: _objectSpread({}, FILL, {
|
---|
1694 | d: 'M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z'
|
---|
1695 | })
|
---|
1696 | };
|
---|
1697 |
|
---|
1698 | var OPACITY_ANIMATE = _objectSpread({}, ANIMATION_BASE, {
|
---|
1699 | attributeName: 'opacity'
|
---|
1700 | });
|
---|
1701 |
|
---|
1702 | var DOT = {
|
---|
1703 | tag: 'circle',
|
---|
1704 | attributes: _objectSpread({}, FILL, {
|
---|
1705 | cx: '256',
|
---|
1706 | cy: '364',
|
---|
1707 | r: '28'
|
---|
1708 | }),
|
---|
1709 | children: [{
|
---|
1710 | tag: 'animate',
|
---|
1711 | attributes: _objectSpread({}, ANIMATION_BASE, {
|
---|
1712 | attributeName: 'r',
|
---|
1713 | values: '28;14;28;28;14;28;'
|
---|
1714 | })
|
---|
1715 | }, {
|
---|
1716 | tag: 'animate',
|
---|
1717 | attributes: _objectSpread({}, OPACITY_ANIMATE, {
|
---|
1718 | values: '1;0;1;1;0;1;'
|
---|
1719 | })
|
---|
1720 | }]
|
---|
1721 | };
|
---|
1722 | var QUESTION = {
|
---|
1723 | tag: 'path',
|
---|
1724 | attributes: _objectSpread({}, FILL, {
|
---|
1725 | opacity: '1',
|
---|
1726 | d: 'M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z'
|
---|
1727 | }),
|
---|
1728 | children: [{
|
---|
1729 | tag: 'animate',
|
---|
1730 | attributes: _objectSpread({}, OPACITY_ANIMATE, {
|
---|
1731 | values: '1;0;0;0;0;1;'
|
---|
1732 | })
|
---|
1733 | }]
|
---|
1734 | };
|
---|
1735 | var EXCLAMATION = {
|
---|
1736 | tag: 'path',
|
---|
1737 | attributes: _objectSpread({}, FILL, {
|
---|
1738 | opacity: '0',
|
---|
1739 | d: 'M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z'
|
---|
1740 | }),
|
---|
1741 | children: [{
|
---|
1742 | tag: 'animate',
|
---|
1743 | attributes: _objectSpread({}, OPACITY_ANIMATE, {
|
---|
1744 | values: '0;0;1;1;0;0;'
|
---|
1745 | })
|
---|
1746 | }]
|
---|
1747 | };
|
---|
1748 | var missing = {
|
---|
1749 | tag: 'g',
|
---|
1750 | children: [RING, DOT, QUESTION, EXCLAMATION]
|
---|
1751 | };
|
---|
1752 |
|
---|
1753 | var styles$2 = namespace.styles;
|
---|
1754 | function asFoundIcon(icon) {
|
---|
1755 | var width = icon[0];
|
---|
1756 | var height = icon[1];
|
---|
1757 |
|
---|
1758 | var _icon$slice = icon.slice(4),
|
---|
1759 | _icon$slice2 = _slicedToArray(_icon$slice, 1),
|
---|
1760 | vectorData = _icon$slice2[0];
|
---|
1761 |
|
---|
1762 | var element = null;
|
---|
1763 |
|
---|
1764 | if (Array.isArray(vectorData)) {
|
---|
1765 | element = {
|
---|
1766 | tag: 'g',
|
---|
1767 | attributes: {
|
---|
1768 | class: "".concat(config.familyPrefix, "-").concat(DUOTONE_CLASSES.GROUP)
|
---|
1769 | },
|
---|
1770 | children: [{
|
---|
1771 | tag: 'path',
|
---|
1772 | attributes: {
|
---|
1773 | class: "".concat(config.familyPrefix, "-").concat(DUOTONE_CLASSES.SECONDARY),
|
---|
1774 | fill: 'currentColor',
|
---|
1775 | d: vectorData[0]
|
---|
1776 | }
|
---|
1777 | }, {
|
---|
1778 | tag: 'path',
|
---|
1779 | attributes: {
|
---|
1780 | class: "".concat(config.familyPrefix, "-").concat(DUOTONE_CLASSES.PRIMARY),
|
---|
1781 | fill: 'currentColor',
|
---|
1782 | d: vectorData[1]
|
---|
1783 | }
|
---|
1784 | }]
|
---|
1785 | };
|
---|
1786 | } else {
|
---|
1787 | element = {
|
---|
1788 | tag: 'path',
|
---|
1789 | attributes: {
|
---|
1790 | fill: 'currentColor',
|
---|
1791 | d: vectorData
|
---|
1792 | }
|
---|
1793 | };
|
---|
1794 | }
|
---|
1795 |
|
---|
1796 | return {
|
---|
1797 | found: true,
|
---|
1798 | width: width,
|
---|
1799 | height: height,
|
---|
1800 | icon: element
|
---|
1801 | };
|
---|
1802 | }
|
---|
1803 | function findIcon(iconName, prefix) {
|
---|
1804 | return new picked(function (resolve, reject) {
|
---|
1805 | var val = {
|
---|
1806 | found: false,
|
---|
1807 | width: 512,
|
---|
1808 | height: 512,
|
---|
1809 | icon: missing
|
---|
1810 | };
|
---|
1811 |
|
---|
1812 | if (iconName && prefix && styles$2[prefix] && styles$2[prefix][iconName]) {
|
---|
1813 | var icon = styles$2[prefix][iconName];
|
---|
1814 | return resolve(asFoundIcon(icon));
|
---|
1815 | }
|
---|
1816 |
|
---|
1817 | if (iconName && prefix && !config.showMissingIcons) {
|
---|
1818 | reject(new MissingIcon("Icon is missing for prefix ".concat(prefix, " with icon name ").concat(iconName)));
|
---|
1819 | } else {
|
---|
1820 | resolve(val);
|
---|
1821 | }
|
---|
1822 | });
|
---|
1823 | }
|
---|
1824 |
|
---|
1825 | var styles$3 = namespace.styles;
|
---|
1826 |
|
---|
1827 | function generateSvgReplacementMutation(node, nodeMeta) {
|
---|
1828 | var iconName = nodeMeta.iconName,
|
---|
1829 | title = nodeMeta.title,
|
---|
1830 | titleId = nodeMeta.titleId,
|
---|
1831 | prefix = nodeMeta.prefix,
|
---|
1832 | transform = nodeMeta.transform,
|
---|
1833 | symbol = nodeMeta.symbol,
|
---|
1834 | mask = nodeMeta.mask,
|
---|
1835 | maskId = nodeMeta.maskId,
|
---|
1836 | extra = nodeMeta.extra;
|
---|
1837 | return new picked(function (resolve, reject) {
|
---|
1838 | picked.all([findIcon(iconName, prefix), findIcon(mask.iconName, mask.prefix)]).then(function (_ref) {
|
---|
1839 | var _ref2 = _slicedToArray(_ref, 2),
|
---|
1840 | main = _ref2[0],
|
---|
1841 | mask = _ref2[1];
|
---|
1842 |
|
---|
1843 | resolve([node, makeInlineSvgAbstract({
|
---|
1844 | icons: {
|
---|
1845 | main: main,
|
---|
1846 | mask: mask
|
---|
1847 | },
|
---|
1848 | prefix: prefix,
|
---|
1849 | iconName: iconName,
|
---|
1850 | transform: transform,
|
---|
1851 | symbol: symbol,
|
---|
1852 | mask: mask,
|
---|
1853 | maskId: maskId,
|
---|
1854 | title: title,
|
---|
1855 | titleId: titleId,
|
---|
1856 | extra: extra,
|
---|
1857 | watchable: true
|
---|
1858 | })]);
|
---|
1859 | });
|
---|
1860 | });
|
---|
1861 | }
|
---|
1862 |
|
---|
1863 | function generateLayersText(node, nodeMeta) {
|
---|
1864 | var title = nodeMeta.title,
|
---|
1865 | transform = nodeMeta.transform,
|
---|
1866 | extra = nodeMeta.extra;
|
---|
1867 | var width = null;
|
---|
1868 | var height = null;
|
---|
1869 |
|
---|
1870 | if (IS_IE) {
|
---|
1871 | var computedFontSize = parseInt(getComputedStyle(node).fontSize, 10);
|
---|
1872 | var boundingClientRect = node.getBoundingClientRect();
|
---|
1873 | width = boundingClientRect.width / computedFontSize;
|
---|
1874 | height = boundingClientRect.height / computedFontSize;
|
---|
1875 | }
|
---|
1876 |
|
---|
1877 | if (config.autoA11y && !title) {
|
---|
1878 | extra.attributes['aria-hidden'] = 'true';
|
---|
1879 | }
|
---|
1880 |
|
---|
1881 | return picked.resolve([node, makeLayersTextAbstract({
|
---|
1882 | content: node.innerHTML,
|
---|
1883 | width: width,
|
---|
1884 | height: height,
|
---|
1885 | transform: transform,
|
---|
1886 | title: title,
|
---|
1887 | extra: extra,
|
---|
1888 | watchable: true
|
---|
1889 | })]);
|
---|
1890 | }
|
---|
1891 |
|
---|
1892 | function generateMutation(node) {
|
---|
1893 | var nodeMeta = parseMeta(node);
|
---|
1894 |
|
---|
1895 | if (~nodeMeta.extra.classes.indexOf(LAYERS_TEXT_CLASSNAME)) {
|
---|
1896 | return generateLayersText(node, nodeMeta);
|
---|
1897 | } else {
|
---|
1898 | return generateSvgReplacementMutation(node, nodeMeta);
|
---|
1899 | }
|
---|
1900 | }
|
---|
1901 |
|
---|
1902 | function onTree(root) {
|
---|
1903 | var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
---|
1904 | if (!IS_DOM) return;
|
---|
1905 | var htmlClassList = DOCUMENT.documentElement.classList;
|
---|
1906 |
|
---|
1907 | var hclAdd = function hclAdd(suffix) {
|
---|
1908 | return htmlClassList.add("".concat(HTML_CLASS_I2SVG_BASE_CLASS, "-").concat(suffix));
|
---|
1909 | };
|
---|
1910 |
|
---|
1911 | var hclRemove = function hclRemove(suffix) {
|
---|
1912 | return htmlClassList.remove("".concat(HTML_CLASS_I2SVG_BASE_CLASS, "-").concat(suffix));
|
---|
1913 | };
|
---|
1914 |
|
---|
1915 | var prefixes = config.autoFetchSvg ? Object.keys(PREFIX_TO_STYLE) : Object.keys(styles$3);
|
---|
1916 | var prefixesDomQuery = [".".concat(LAYERS_TEXT_CLASSNAME, ":not([").concat(DATA_FA_I2SVG, "])")].concat(prefixes.map(function (p) {
|
---|
1917 | return ".".concat(p, ":not([").concat(DATA_FA_I2SVG, "])");
|
---|
1918 | })).join(', ');
|
---|
1919 |
|
---|
1920 | if (prefixesDomQuery.length === 0) {
|
---|
1921 | return;
|
---|
1922 | }
|
---|
1923 |
|
---|
1924 | var candidates = [];
|
---|
1925 |
|
---|
1926 | try {
|
---|
1927 | candidates = toArray(root.querySelectorAll(prefixesDomQuery));
|
---|
1928 | } catch (e) {// noop
|
---|
1929 | }
|
---|
1930 |
|
---|
1931 | if (candidates.length > 0) {
|
---|
1932 | hclAdd('pending');
|
---|
1933 | hclRemove('complete');
|
---|
1934 | } else {
|
---|
1935 | return;
|
---|
1936 | }
|
---|
1937 |
|
---|
1938 | var mark = perf.begin('onTree');
|
---|
1939 | var mutations = candidates.reduce(function (acc, node) {
|
---|
1940 | try {
|
---|
1941 | var mutation = generateMutation(node);
|
---|
1942 |
|
---|
1943 | if (mutation) {
|
---|
1944 | acc.push(mutation);
|
---|
1945 | }
|
---|
1946 | } catch (e) {
|
---|
1947 | if (!PRODUCTION) {
|
---|
1948 | if (e instanceof MissingIcon) {
|
---|
1949 | console.error(e);
|
---|
1950 | }
|
---|
1951 | }
|
---|
1952 | }
|
---|
1953 |
|
---|
1954 | return acc;
|
---|
1955 | }, []);
|
---|
1956 | return new picked(function (resolve, reject) {
|
---|
1957 | picked.all(mutations).then(function (resolvedMutations) {
|
---|
1958 | perform(resolvedMutations, function () {
|
---|
1959 | hclAdd('active');
|
---|
1960 | hclAdd('complete');
|
---|
1961 | hclRemove('pending');
|
---|
1962 | if (typeof callback === 'function') callback();
|
---|
1963 | mark();
|
---|
1964 | resolve();
|
---|
1965 | });
|
---|
1966 | }).catch(function () {
|
---|
1967 | mark();
|
---|
1968 | reject();
|
---|
1969 | });
|
---|
1970 | });
|
---|
1971 | }
|
---|
1972 | function onNode(node) {
|
---|
1973 | var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
---|
1974 | generateMutation(node).then(function (mutation) {
|
---|
1975 | if (mutation) {
|
---|
1976 | perform([mutation], callback);
|
---|
1977 | }
|
---|
1978 | });
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | function replaceForPosition(node, position) {
|
---|
1982 | var pendingAttribute = "".concat(DATA_FA_PSEUDO_ELEMENT_PENDING).concat(position.replace(':', '-'));
|
---|
1983 | return new picked(function (resolve, reject) {
|
---|
1984 | if (node.getAttribute(pendingAttribute) !== null) {
|
---|
1985 | // This node is already being processed
|
---|
1986 | return resolve();
|
---|
1987 | }
|
---|
1988 |
|
---|
1989 | var children = toArray(node.children);
|
---|
1990 | var alreadyProcessedPseudoElement = children.filter(function (c) {
|
---|
1991 | return c.getAttribute(DATA_FA_PSEUDO_ELEMENT) === position;
|
---|
1992 | })[0];
|
---|
1993 | var styles = WINDOW.getComputedStyle(node, position);
|
---|
1994 | var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
|
---|
1995 | var fontWeight = styles.getPropertyValue('font-weight');
|
---|
1996 | var content = styles.getPropertyValue('content');
|
---|
1997 |
|
---|
1998 | if (alreadyProcessedPseudoElement && !fontFamily) {
|
---|
1999 | // If we've already processed it but the current computed style does not result in a font-family,
|
---|
2000 | // that probably means that a class name that was previously present to make the icon has been
|
---|
2001 | // removed. So we now should delete the icon.
|
---|
2002 | node.removeChild(alreadyProcessedPseudoElement);
|
---|
2003 | return resolve();
|
---|
2004 | } else if (fontFamily && content !== 'none' && content !== '') {
|
---|
2005 | var _content = styles.getPropertyValue('content');
|
---|
2006 |
|
---|
2007 | var prefix = ~['Solid', 'Regular', 'Light', 'Duotone', 'Brands', 'Kit'].indexOf(fontFamily[2]) ? STYLE_TO_PREFIX[fontFamily[2].toLowerCase()] : FONT_WEIGHT_TO_PREFIX[fontWeight];
|
---|
2008 | var hexValue = toHex(_content.length === 3 ? _content.substr(1, 1) : _content);
|
---|
2009 | var iconName = byUnicode(prefix, hexValue);
|
---|
2010 | var iconIdentifier = iconName; // Only convert the pseudo element in this :before/:after position into an icon if we haven't
|
---|
2011 | // already done so with the same prefix and iconName
|
---|
2012 |
|
---|
2013 | if (iconName && (!alreadyProcessedPseudoElement || alreadyProcessedPseudoElement.getAttribute(DATA_PREFIX) !== prefix || alreadyProcessedPseudoElement.getAttribute(DATA_ICON) !== iconIdentifier)) {
|
---|
2014 | node.setAttribute(pendingAttribute, iconIdentifier);
|
---|
2015 |
|
---|
2016 | if (alreadyProcessedPseudoElement) {
|
---|
2017 | // Delete the old one, since we're replacing it with a new one
|
---|
2018 | node.removeChild(alreadyProcessedPseudoElement);
|
---|
2019 | }
|
---|
2020 |
|
---|
2021 | var meta = blankMeta();
|
---|
2022 | var extra = meta.extra;
|
---|
2023 | extra.attributes[DATA_FA_PSEUDO_ELEMENT] = position;
|
---|
2024 | findIcon(iconName, prefix).then(function (main) {
|
---|
2025 | var abstract = makeInlineSvgAbstract(_objectSpread({}, meta, {
|
---|
2026 | icons: {
|
---|
2027 | main: main,
|
---|
2028 | mask: emptyCanonicalIcon()
|
---|
2029 | },
|
---|
2030 | prefix: prefix,
|
---|
2031 | iconName: iconIdentifier,
|
---|
2032 | extra: extra,
|
---|
2033 | watchable: true
|
---|
2034 | }));
|
---|
2035 | var element = DOCUMENT.createElement('svg');
|
---|
2036 |
|
---|
2037 | if (position === ':before') {
|
---|
2038 | node.insertBefore(element, node.firstChild);
|
---|
2039 | } else {
|
---|
2040 | node.appendChild(element);
|
---|
2041 | }
|
---|
2042 |
|
---|
2043 | element.outerHTML = abstract.map(function (a) {
|
---|
2044 | return toHtml(a);
|
---|
2045 | }).join('\n');
|
---|
2046 | node.removeAttribute(pendingAttribute);
|
---|
2047 | resolve();
|
---|
2048 | }).catch(reject);
|
---|
2049 | } else {
|
---|
2050 | resolve();
|
---|
2051 | }
|
---|
2052 | } else {
|
---|
2053 | resolve();
|
---|
2054 | }
|
---|
2055 | });
|
---|
2056 | }
|
---|
2057 |
|
---|
2058 | function replace(node) {
|
---|
2059 | return picked.all([replaceForPosition(node, ':before'), replaceForPosition(node, ':after')]);
|
---|
2060 | }
|
---|
2061 |
|
---|
2062 | function processable(node) {
|
---|
2063 | return node.parentNode !== document.head && !~TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS.indexOf(node.tagName.toUpperCase()) && !node.getAttribute(DATA_FA_PSEUDO_ELEMENT) && (!node.parentNode || node.parentNode.tagName !== 'svg');
|
---|
2064 | }
|
---|
2065 |
|
---|
2066 | function searchPseudoElements (root) {
|
---|
2067 | if (!IS_DOM) return;
|
---|
2068 | return new picked(function (resolve, reject) {
|
---|
2069 | var operations = toArray(root.querySelectorAll('*')).filter(processable).map(replace);
|
---|
2070 | var end = perf.begin('searchPseudoElements');
|
---|
2071 | disableObservation();
|
---|
2072 | picked.all(operations).then(function () {
|
---|
2073 | end();
|
---|
2074 | enableObservation();
|
---|
2075 | resolve();
|
---|
2076 | }).catch(function () {
|
---|
2077 | end();
|
---|
2078 | enableObservation();
|
---|
2079 | reject();
|
---|
2080 | });
|
---|
2081 | });
|
---|
2082 | }
|
---|
2083 |
|
---|
2084 | var baseStyles = "svg:not(:root).svg-inline--fa {\n overflow: visible;\n}\n\n.svg-inline--fa {\n display: inline-block;\n font-size: inherit;\n height: 1em;\n overflow: visible;\n vertical-align: -0.125em;\n}\n.svg-inline--fa.fa-lg {\n vertical-align: -0.225em;\n}\n.svg-inline--fa.fa-w-1 {\n width: 0.0625em;\n}\n.svg-inline--fa.fa-w-2 {\n width: 0.125em;\n}\n.svg-inline--fa.fa-w-3 {\n width: 0.1875em;\n}\n.svg-inline--fa.fa-w-4 {\n width: 0.25em;\n}\n.svg-inline--fa.fa-w-5 {\n width: 0.3125em;\n}\n.svg-inline--fa.fa-w-6 {\n width: 0.375em;\n}\n.svg-inline--fa.fa-w-7 {\n width: 0.4375em;\n}\n.svg-inline--fa.fa-w-8 {\n width: 0.5em;\n}\n.svg-inline--fa.fa-w-9 {\n width: 0.5625em;\n}\n.svg-inline--fa.fa-w-10 {\n width: 0.625em;\n}\n.svg-inline--fa.fa-w-11 {\n width: 0.6875em;\n}\n.svg-inline--fa.fa-w-12 {\n width: 0.75em;\n}\n.svg-inline--fa.fa-w-13 {\n width: 0.8125em;\n}\n.svg-inline--fa.fa-w-14 {\n width: 0.875em;\n}\n.svg-inline--fa.fa-w-15 {\n width: 0.9375em;\n}\n.svg-inline--fa.fa-w-16 {\n width: 1em;\n}\n.svg-inline--fa.fa-w-17 {\n width: 1.0625em;\n}\n.svg-inline--fa.fa-w-18 {\n width: 1.125em;\n}\n.svg-inline--fa.fa-w-19 {\n width: 1.1875em;\n}\n.svg-inline--fa.fa-w-20 {\n width: 1.25em;\n}\n.svg-inline--fa.fa-pull-left {\n margin-right: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-pull-right {\n margin-left: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-border {\n height: 1.5em;\n}\n.svg-inline--fa.fa-li {\n width: 2em;\n}\n.svg-inline--fa.fa-fw {\n width: 1.25em;\n}\n\n.fa-layers svg.svg-inline--fa {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.fa-layers {\n display: inline-block;\n height: 1em;\n position: relative;\n text-align: center;\n vertical-align: -0.125em;\n width: 1em;\n}\n.fa-layers svg.svg-inline--fa {\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter, .fa-layers-text {\n display: inline-block;\n position: absolute;\n text-align: center;\n}\n\n.fa-layers-text {\n left: 50%;\n top: 50%;\n -webkit-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter {\n background-color: #ff253a;\n border-radius: 1em;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n color: #fff;\n height: 1.5em;\n line-height: 1;\n max-width: 5em;\n min-width: 1.5em;\n overflow: hidden;\n padding: 0.25em;\n right: 0;\n text-overflow: ellipsis;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-bottom-right {\n bottom: 0;\n right: 0;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom right;\n transform-origin: bottom right;\n}\n\n.fa-layers-bottom-left {\n bottom: 0;\n left: 0;\n right: auto;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom left;\n transform-origin: bottom left;\n}\n\n.fa-layers-top-right {\n right: 0;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-top-left {\n left: 0;\n right: auto;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top left;\n transform-origin: top left;\n}\n\n.fa-lg {\n font-size: 1.3333333333em;\n line-height: 0.75em;\n vertical-align: -0.0667em;\n}\n\n.fa-xs {\n font-size: 0.75em;\n}\n\n.fa-sm {\n font-size: 0.875em;\n}\n\n.fa-1x {\n font-size: 1em;\n}\n\n.fa-2x {\n font-size: 2em;\n}\n\n.fa-3x {\n font-size: 3em;\n}\n\n.fa-4x {\n font-size: 4em;\n}\n\n.fa-5x {\n font-size: 5em;\n}\n\n.fa-6x {\n font-size: 6em;\n}\n\n.fa-7x {\n font-size: 7em;\n}\n\n.fa-8x {\n font-size: 8em;\n}\n\n.fa-9x {\n font-size: 9em;\n}\n\n.fa-10x {\n font-size: 10em;\n}\n\n.fa-fw {\n text-align: center;\n width: 1.25em;\n}\n\n.fa-ul {\n list-style-type: none;\n margin-left: 2.5em;\n padding-left: 0;\n}\n.fa-ul > li {\n position: relative;\n}\n\n.fa-li {\n left: -2em;\n position: absolute;\n text-align: center;\n width: 2em;\n line-height: inherit;\n}\n\n.fa-border {\n border: solid 0.08em #eee;\n border-radius: 0.1em;\n padding: 0.2em 0.25em 0.15em;\n}\n\n.fa-pull-left {\n float: left;\n}\n\n.fa-pull-right {\n float: right;\n}\n\n.fa.fa-pull-left,\n.fas.fa-pull-left,\n.far.fa-pull-left,\n.fal.fa-pull-left,\n.fab.fa-pull-left {\n margin-right: 0.3em;\n}\n.fa.fa-pull-right,\n.fas.fa-pull-right,\n.far.fa-pull-right,\n.fal.fa-pull-right,\n.fab.fa-pull-right {\n margin-left: 0.3em;\n}\n\n.fa-spin {\n -webkit-animation: fa-spin 2s infinite linear;\n animation: fa-spin 2s infinite linear;\n}\n\n.fa-pulse {\n -webkit-animation: fa-spin 1s infinite steps(8);\n animation: fa-spin 1s infinite steps(8);\n}\n\n@-webkit-keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.fa-rotate-90 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)\";\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n}\n\n.fa-rotate-180 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)\";\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n}\n\n.fa-rotate-270 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)\";\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n}\n\n.fa-flip-horizontal {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)\";\n -webkit-transform: scale(-1, 1);\n transform: scale(-1, 1);\n}\n\n.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(1, -1);\n transform: scale(1, -1);\n}\n\n.fa-flip-both, .fa-flip-horizontal.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(-1, -1);\n transform: scale(-1, -1);\n}\n\n:root .fa-rotate-90,\n:root .fa-rotate-180,\n:root .fa-rotate-270,\n:root .fa-flip-horizontal,\n:root .fa-flip-vertical,\n:root .fa-flip-both {\n -webkit-filter: none;\n filter: none;\n}\n\n.fa-stack {\n display: inline-block;\n height: 2em;\n position: relative;\n width: 2.5em;\n}\n\n.fa-stack-1x,\n.fa-stack-2x {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.svg-inline--fa.fa-stack-1x {\n height: 1em;\n width: 1.25em;\n}\n.svg-inline--fa.fa-stack-2x {\n height: 2em;\n width: 2.5em;\n}\n\n.fa-inverse {\n color: #fff;\n}\n\n.sr-only {\n border: 0;\n clip: rect(0, 0, 0, 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n}\n\n.sr-only-focusable:active, .sr-only-focusable:focus {\n clip: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n position: static;\n width: auto;\n}\n\n.svg-inline--fa .fa-primary {\n fill: var(--fa-primary-color, currentColor);\n opacity: 1;\n opacity: var(--fa-primary-opacity, 1);\n}\n\n.svg-inline--fa .fa-secondary {\n fill: var(--fa-secondary-color, currentColor);\n opacity: 0.4;\n opacity: var(--fa-secondary-opacity, 0.4);\n}\n\n.svg-inline--fa.fa-swap-opacity .fa-primary {\n opacity: 0.4;\n opacity: var(--fa-secondary-opacity, 0.4);\n}\n\n.svg-inline--fa.fa-swap-opacity .fa-secondary {\n opacity: 1;\n opacity: var(--fa-primary-opacity, 1);\n}\n\n.svg-inline--fa mask .fa-primary,\n.svg-inline--fa mask .fa-secondary {\n fill: black;\n}\n\n.fad.fa-inverse {\n color: #fff;\n}";
|
---|
2085 |
|
---|
2086 | function css () {
|
---|
2087 | var dfp = DEFAULT_FAMILY_PREFIX;
|
---|
2088 | var drc = DEFAULT_REPLACEMENT_CLASS;
|
---|
2089 | var fp = config.familyPrefix;
|
---|
2090 | var rc = config.replacementClass;
|
---|
2091 | var s = baseStyles;
|
---|
2092 |
|
---|
2093 | if (fp !== dfp || rc !== drc) {
|
---|
2094 | var dPatt = new RegExp("\\.".concat(dfp, "\\-"), 'g');
|
---|
2095 | var customPropPatt = new RegExp("\\--".concat(dfp, "\\-"), 'g');
|
---|
2096 | var rPatt = new RegExp("\\.".concat(drc), 'g');
|
---|
2097 | s = s.replace(dPatt, ".".concat(fp, "-")).replace(customPropPatt, "--".concat(fp, "-")).replace(rPatt, ".".concat(rc));
|
---|
2098 | }
|
---|
2099 |
|
---|
2100 | return s;
|
---|
2101 | }
|
---|
2102 |
|
---|
2103 | var Library =
|
---|
2104 | /*#__PURE__*/
|
---|
2105 | function () {
|
---|
2106 | function Library() {
|
---|
2107 | _classCallCheck(this, Library);
|
---|
2108 |
|
---|
2109 | this.definitions = {};
|
---|
2110 | }
|
---|
2111 |
|
---|
2112 | _createClass(Library, [{
|
---|
2113 | key: "add",
|
---|
2114 | value: function add() {
|
---|
2115 | var _this = this;
|
---|
2116 |
|
---|
2117 | for (var _len = arguments.length, definitions = new Array(_len), _key = 0; _key < _len; _key++) {
|
---|
2118 | definitions[_key] = arguments[_key];
|
---|
2119 | }
|
---|
2120 |
|
---|
2121 | var additions = definitions.reduce(this._pullDefinitions, {});
|
---|
2122 | Object.keys(additions).forEach(function (key) {
|
---|
2123 | _this.definitions[key] = _objectSpread({}, _this.definitions[key] || {}, additions[key]);
|
---|
2124 | defineIcons(key, additions[key]);
|
---|
2125 | build();
|
---|
2126 | });
|
---|
2127 | }
|
---|
2128 | }, {
|
---|
2129 | key: "reset",
|
---|
2130 | value: function reset() {
|
---|
2131 | this.definitions = {};
|
---|
2132 | }
|
---|
2133 | }, {
|
---|
2134 | key: "_pullDefinitions",
|
---|
2135 | value: function _pullDefinitions(additions, definition) {
|
---|
2136 | var normalized = definition.prefix && definition.iconName && definition.icon ? {
|
---|
2137 | 0: definition
|
---|
2138 | } : definition;
|
---|
2139 | Object.keys(normalized).map(function (key) {
|
---|
2140 | var _normalized$key = normalized[key],
|
---|
2141 | prefix = _normalized$key.prefix,
|
---|
2142 | iconName = _normalized$key.iconName,
|
---|
2143 | icon = _normalized$key.icon;
|
---|
2144 | if (!additions[prefix]) additions[prefix] = {};
|
---|
2145 | additions[prefix][iconName] = icon;
|
---|
2146 | });
|
---|
2147 | return additions;
|
---|
2148 | }
|
---|
2149 | }]);
|
---|
2150 |
|
---|
2151 | return Library;
|
---|
2152 | }();
|
---|
2153 |
|
---|
2154 | function ensureCss() {
|
---|
2155 | if (config.autoAddCss && !_cssInserted) {
|
---|
2156 | insertCss(css());
|
---|
2157 |
|
---|
2158 | _cssInserted = true;
|
---|
2159 | }
|
---|
2160 | }
|
---|
2161 |
|
---|
2162 | function apiObject(val, abstractCreator) {
|
---|
2163 | Object.defineProperty(val, 'abstract', {
|
---|
2164 | get: abstractCreator
|
---|
2165 | });
|
---|
2166 | Object.defineProperty(val, 'html', {
|
---|
2167 | get: function get() {
|
---|
2168 | return val.abstract.map(function (a) {
|
---|
2169 | return toHtml(a);
|
---|
2170 | });
|
---|
2171 | }
|
---|
2172 | });
|
---|
2173 | Object.defineProperty(val, 'node', {
|
---|
2174 | get: function get() {
|
---|
2175 | if (!IS_DOM) return;
|
---|
2176 | var container = DOCUMENT.createElement('div');
|
---|
2177 | container.innerHTML = val.html;
|
---|
2178 | return container.children;
|
---|
2179 | }
|
---|
2180 | });
|
---|
2181 | return val;
|
---|
2182 | }
|
---|
2183 |
|
---|
2184 | function findIconDefinition(iconLookup) {
|
---|
2185 | var _iconLookup$prefix = iconLookup.prefix,
|
---|
2186 | prefix = _iconLookup$prefix === void 0 ? 'fa' : _iconLookup$prefix,
|
---|
2187 | iconName = iconLookup.iconName;
|
---|
2188 | if (!iconName) return;
|
---|
2189 | return iconFromMapping(library.definitions, prefix, iconName) || iconFromMapping(namespace.styles, prefix, iconName);
|
---|
2190 | }
|
---|
2191 |
|
---|
2192 | function resolveIcons(next) {
|
---|
2193 | return function (maybeIconDefinition) {
|
---|
2194 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
---|
2195 | var iconDefinition = (maybeIconDefinition || {}).icon ? maybeIconDefinition : findIconDefinition(maybeIconDefinition || {});
|
---|
2196 | var mask = params.mask;
|
---|
2197 |
|
---|
2198 | if (mask) {
|
---|
2199 | mask = (mask || {}).icon ? mask : findIconDefinition(mask || {});
|
---|
2200 | }
|
---|
2201 |
|
---|
2202 | return next(iconDefinition, _objectSpread({}, params, {
|
---|
2203 | mask: mask
|
---|
2204 | }));
|
---|
2205 | };
|
---|
2206 | }
|
---|
2207 |
|
---|
2208 | var library = new Library();
|
---|
2209 | var noAuto = function noAuto() {
|
---|
2210 | config.autoReplaceSvg = false;
|
---|
2211 | config.observeMutations = false;
|
---|
2212 | disconnect();
|
---|
2213 | };
|
---|
2214 | var _cssInserted = false;
|
---|
2215 | var dom = {
|
---|
2216 | i2svg: function i2svg() {
|
---|
2217 | var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
---|
2218 |
|
---|
2219 | if (IS_DOM) {
|
---|
2220 | ensureCss();
|
---|
2221 | var _params$node = params.node,
|
---|
2222 | node = _params$node === void 0 ? DOCUMENT : _params$node,
|
---|
2223 | _params$callback = params.callback,
|
---|
2224 | callback = _params$callback === void 0 ? function () {} : _params$callback;
|
---|
2225 |
|
---|
2226 | if (config.searchPseudoElements) {
|
---|
2227 | searchPseudoElements(node);
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 | return onTree(node, callback);
|
---|
2231 | } else {
|
---|
2232 | return picked.reject('Operation requires a DOM of some kind.');
|
---|
2233 | }
|
---|
2234 | },
|
---|
2235 | css: css,
|
---|
2236 | insertCss: function insertCss$$1() {
|
---|
2237 | if (!_cssInserted) {
|
---|
2238 | insertCss(css());
|
---|
2239 |
|
---|
2240 | _cssInserted = true;
|
---|
2241 | }
|
---|
2242 | },
|
---|
2243 | watch: function watch() {
|
---|
2244 | var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
---|
2245 | var autoReplaceSvgRoot = params.autoReplaceSvgRoot,
|
---|
2246 | observeMutationsRoot = params.observeMutationsRoot;
|
---|
2247 |
|
---|
2248 | if (config.autoReplaceSvg === false) {
|
---|
2249 | config.autoReplaceSvg = true;
|
---|
2250 | }
|
---|
2251 |
|
---|
2252 | config.observeMutations = true;
|
---|
2253 | domready(function () {
|
---|
2254 | autoReplace({
|
---|
2255 | autoReplaceSvgRoot: autoReplaceSvgRoot
|
---|
2256 | });
|
---|
2257 | observe({
|
---|
2258 | treeCallback: onTree,
|
---|
2259 | nodeCallback: onNode,
|
---|
2260 | pseudoElementsCallback: searchPseudoElements,
|
---|
2261 | observeMutationsRoot: observeMutationsRoot
|
---|
2262 | });
|
---|
2263 | });
|
---|
2264 | }
|
---|
2265 | };
|
---|
2266 | var parse = {
|
---|
2267 | transform: function transform(transformString) {
|
---|
2268 | return parseTransformString(transformString);
|
---|
2269 | }
|
---|
2270 | };
|
---|
2271 | var icon = resolveIcons(function (iconDefinition) {
|
---|
2272 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
---|
2273 | var _params$transform = params.transform,
|
---|
2274 | transform = _params$transform === void 0 ? meaninglessTransform : _params$transform,
|
---|
2275 | _params$symbol = params.symbol,
|
---|
2276 | symbol = _params$symbol === void 0 ? false : _params$symbol,
|
---|
2277 | _params$mask = params.mask,
|
---|
2278 | mask = _params$mask === void 0 ? null : _params$mask,
|
---|
2279 | _params$maskId = params.maskId,
|
---|
2280 | maskId = _params$maskId === void 0 ? null : _params$maskId,
|
---|
2281 | _params$title = params.title,
|
---|
2282 | title = _params$title === void 0 ? null : _params$title,
|
---|
2283 | _params$titleId = params.titleId,
|
---|
2284 | titleId = _params$titleId === void 0 ? null : _params$titleId,
|
---|
2285 | _params$classes = params.classes,
|
---|
2286 | classes = _params$classes === void 0 ? [] : _params$classes,
|
---|
2287 | _params$attributes = params.attributes,
|
---|
2288 | attributes = _params$attributes === void 0 ? {} : _params$attributes,
|
---|
2289 | _params$styles = params.styles,
|
---|
2290 | styles = _params$styles === void 0 ? {} : _params$styles;
|
---|
2291 | if (!iconDefinition) return;
|
---|
2292 | var prefix = iconDefinition.prefix,
|
---|
2293 | iconName = iconDefinition.iconName,
|
---|
2294 | icon = iconDefinition.icon;
|
---|
2295 | return apiObject(_objectSpread({
|
---|
2296 | type: 'icon'
|
---|
2297 | }, iconDefinition), function () {
|
---|
2298 | ensureCss();
|
---|
2299 |
|
---|
2300 | if (config.autoA11y) {
|
---|
2301 | if (title) {
|
---|
2302 | attributes['aria-labelledby'] = "".concat(config.replacementClass, "-title-").concat(titleId || nextUniqueId());
|
---|
2303 | } else {
|
---|
2304 | attributes['aria-hidden'] = 'true';
|
---|
2305 | attributes['focusable'] = 'false';
|
---|
2306 | }
|
---|
2307 | }
|
---|
2308 |
|
---|
2309 | return makeInlineSvgAbstract({
|
---|
2310 | icons: {
|
---|
2311 | main: asFoundIcon(icon),
|
---|
2312 | mask: mask ? asFoundIcon(mask.icon) : {
|
---|
2313 | found: false,
|
---|
2314 | width: null,
|
---|
2315 | height: null,
|
---|
2316 | icon: {}
|
---|
2317 | }
|
---|
2318 | },
|
---|
2319 | prefix: prefix,
|
---|
2320 | iconName: iconName,
|
---|
2321 | transform: _objectSpread({}, meaninglessTransform, transform),
|
---|
2322 | symbol: symbol,
|
---|
2323 | title: title,
|
---|
2324 | maskId: maskId,
|
---|
2325 | titleId: titleId,
|
---|
2326 | extra: {
|
---|
2327 | attributes: attributes,
|
---|
2328 | styles: styles,
|
---|
2329 | classes: classes
|
---|
2330 | }
|
---|
2331 | });
|
---|
2332 | });
|
---|
2333 | });
|
---|
2334 | var text = function text(content) {
|
---|
2335 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
---|
2336 | var _params$transform2 = params.transform,
|
---|
2337 | transform = _params$transform2 === void 0 ? meaninglessTransform : _params$transform2,
|
---|
2338 | _params$title2 = params.title,
|
---|
2339 | title = _params$title2 === void 0 ? null : _params$title2,
|
---|
2340 | _params$classes2 = params.classes,
|
---|
2341 | classes = _params$classes2 === void 0 ? [] : _params$classes2,
|
---|
2342 | _params$attributes2 = params.attributes,
|
---|
2343 | attributes = _params$attributes2 === void 0 ? {} : _params$attributes2,
|
---|
2344 | _params$styles2 = params.styles,
|
---|
2345 | styles = _params$styles2 === void 0 ? {} : _params$styles2;
|
---|
2346 | return apiObject({
|
---|
2347 | type: 'text',
|
---|
2348 | content: content
|
---|
2349 | }, function () {
|
---|
2350 | ensureCss();
|
---|
2351 | return makeLayersTextAbstract({
|
---|
2352 | content: content,
|
---|
2353 | transform: _objectSpread({}, meaninglessTransform, transform),
|
---|
2354 | title: title,
|
---|
2355 | extra: {
|
---|
2356 | attributes: attributes,
|
---|
2357 | styles: styles,
|
---|
2358 | classes: ["".concat(config.familyPrefix, "-layers-text")].concat(_toConsumableArray(classes))
|
---|
2359 | }
|
---|
2360 | });
|
---|
2361 | });
|
---|
2362 | };
|
---|
2363 | var counter = function counter(content) {
|
---|
2364 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
---|
2365 | var _params$title3 = params.title,
|
---|
2366 | title = _params$title3 === void 0 ? null : _params$title3,
|
---|
2367 | _params$classes3 = params.classes,
|
---|
2368 | classes = _params$classes3 === void 0 ? [] : _params$classes3,
|
---|
2369 | _params$attributes3 = params.attributes,
|
---|
2370 | attributes = _params$attributes3 === void 0 ? {} : _params$attributes3,
|
---|
2371 | _params$styles3 = params.styles,
|
---|
2372 | styles = _params$styles3 === void 0 ? {} : _params$styles3;
|
---|
2373 | return apiObject({
|
---|
2374 | type: 'counter',
|
---|
2375 | content: content
|
---|
2376 | }, function () {
|
---|
2377 | ensureCss();
|
---|
2378 | return makeLayersCounterAbstract({
|
---|
2379 | content: content.toString(),
|
---|
2380 | title: title,
|
---|
2381 | extra: {
|
---|
2382 | attributes: attributes,
|
---|
2383 | styles: styles,
|
---|
2384 | classes: ["".concat(config.familyPrefix, "-layers-counter")].concat(_toConsumableArray(classes))
|
---|
2385 | }
|
---|
2386 | });
|
---|
2387 | });
|
---|
2388 | };
|
---|
2389 | var layer = function layer(assembler) {
|
---|
2390 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
---|
2391 | var _params$classes4 = params.classes,
|
---|
2392 | classes = _params$classes4 === void 0 ? [] : _params$classes4;
|
---|
2393 | return apiObject({
|
---|
2394 | type: 'layer'
|
---|
2395 | }, function () {
|
---|
2396 | ensureCss();
|
---|
2397 | var children = [];
|
---|
2398 | assembler(function (args) {
|
---|
2399 | Array.isArray(args) ? args.map(function (a) {
|
---|
2400 | children = children.concat(a.abstract);
|
---|
2401 | }) : children = children.concat(args.abstract);
|
---|
2402 | });
|
---|
2403 | return [{
|
---|
2404 | tag: 'span',
|
---|
2405 | attributes: {
|
---|
2406 | class: ["".concat(config.familyPrefix, "-layers")].concat(_toConsumableArray(classes)).join(' ')
|
---|
2407 | },
|
---|
2408 | children: children
|
---|
2409 | }];
|
---|
2410 | });
|
---|
2411 | };
|
---|
2412 | var api = {
|
---|
2413 | noAuto: noAuto,
|
---|
2414 | config: config,
|
---|
2415 | dom: dom,
|
---|
2416 | library: library,
|
---|
2417 | parse: parse,
|
---|
2418 | findIconDefinition: findIconDefinition,
|
---|
2419 | icon: icon,
|
---|
2420 | text: text,
|
---|
2421 | counter: counter,
|
---|
2422 | layer: layer,
|
---|
2423 | toHtml: toHtml
|
---|
2424 | };
|
---|
2425 |
|
---|
2426 | var autoReplace = function autoReplace() {
|
---|
2427 | var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
---|
2428 | var _params$autoReplaceSv = params.autoReplaceSvgRoot,
|
---|
2429 | autoReplaceSvgRoot = _params$autoReplaceSv === void 0 ? DOCUMENT : _params$autoReplaceSv;
|
---|
2430 | if ((Object.keys(namespace.styles).length > 0 || config.autoFetchSvg) && IS_DOM && config.autoReplaceSvg) api.dom.i2svg({
|
---|
2431 | node: autoReplaceSvgRoot
|
---|
2432 | });
|
---|
2433 | };
|
---|
2434 |
|
---|
2435 | export { icon, noAuto, config, toHtml, layer, text, counter, library, dom, parse, findIconDefinition };
|
---|