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