source: trip-planner-front/node_modules/@fortawesome/angular-fontawesome/fesm2015/angular-fontawesome.js

Last change on this file was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 19.8 KB
Line 
1import { ɵɵdefineInjectable, Injectable, Directive, Input, Component, Renderer2, ElementRef, Optional, HostBinding, NgModule } from '@angular/core';
2import { DomSanitizer } from '@angular/platform-browser';
3import { findIconDefinition, parse, icon, counter, text } from '@fortawesome/fontawesome-svg-core';
4
5class FaConfig {
6 constructor() {
7 /**
8 * Default prefix to use, when one is not provided with the icon name.
9 *
10 * @default 'fas'
11 */
12 this.defaultPrefix = 'fas';
13 /**
14 * Provides a fallback icon to use whilst main icon is being loaded asynchronously.
15 * When value is null, then fa-icon component will throw an error if icon input is missing.
16 * When value is not null, then the provided icon will be used as a fallback icon if icon input is missing.
17 *
18 * @default null
19 */
20 this.fallbackIcon = null;
21 /**
22 * Whether components should lookup icon definitions in the global icon
23 * library (the one available from
24 * `import { library } from '@fortawesome/fontawesome-svg-core')`.
25 *
26 * See https://github.com/FortAwesome/angular-fontawesome/blob/master/docs/usage/icon-library.md
27 * for detailed description of library modes.
28 *
29 * - 'unset' - Components should lookup icon definitions in the global library
30 * and emit warning if they find a definition there. This option is a default
31 * to assist existing applications with a migration. Applications are expected
32 * to switch to using {@link FaIconLibrary}.
33 * - true - Components should lookup icon definitions in the global library.
34 * Note that global icon library is deprecated and support for it will be
35 * removed. This option can be used to temporarily suppress warnings.
36 * - false - Components should not lookup icon definitions in the global
37 * library. Library will throw an error if missing icon is found in the global
38 * library.
39 *
40 * @deprecated This option is deprecated since 0.5.0. In 0.6.0 default will
41 * be changed to false. In 0.8.0 the option will be removed together with the
42 * support for the global icon library.
43 *
44 * @default false
45 */
46 this.globalLibrary = false;
47 }
48}
49FaConfig.ɵprov = ɵɵdefineInjectable({ factory: function FaConfig_Factory() { return new FaConfig(); }, token: FaConfig, providedIn: "root" });
50FaConfig.decorators = [
51 { type: Injectable, args: [{ providedIn: 'root' },] }
52];
53
54class FaIconLibrary {
55 constructor() {
56 this.definitions = {};
57 }
58 addIcons(...icons) {
59 for (const icon of icons) {
60 if (!(icon.prefix in this.definitions)) {
61 this.definitions[icon.prefix] = {};
62 }
63 this.definitions[icon.prefix][icon.iconName] = icon;
64 }
65 }
66 addIconPacks(...packs) {
67 for (const pack of packs) {
68 const icons = Object.keys(pack).map((key) => pack[key]);
69 this.addIcons(...icons);
70 }
71 }
72 getIconDefinition(prefix, name) {
73 if (prefix in this.definitions && name in this.definitions[prefix]) {
74 return this.definitions[prefix][name];
75 }
76 return null;
77 }
78}
79FaIconLibrary.ɵprov = ɵɵdefineInjectable({ factory: function FaIconLibrary_Factory() { return new FaIconLibrary(); }, token: FaIconLibrary, providedIn: "root" });
80FaIconLibrary.decorators = [
81 { type: Injectable, args: [{ providedIn: 'root' },] }
82];
83
84const faWarnIfIconDefinitionMissing = (iconSpec) => {
85 throw new Error(`Could not find icon with iconName=${iconSpec.iconName} and prefix=${iconSpec.prefix} in the icon library.`);
86};
87
88const faWarnIfIconSpecMissing = () => {
89 throw new Error('Property `icon` is required for `fa-icon`/`fa-duotone-icon` components.');
90};
91
92/**
93 * Fontawesome class list.
94 * Returns classes array by props.
95 */
96const faClassList = (props) => {
97 const classes = {
98 'fa-spin': props.spin,
99 'fa-pulse': props.pulse,
100 'fa-fw': props.fixedWidth,
101 'fa-border': props.border,
102 'fa-inverse': props.inverse,
103 'fa-layers-counter': props.counter,
104 'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both',
105 'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both',
106 [`fa-${props.size}`]: props.size !== null,
107 [`fa-rotate-${props.rotate}`]: props.rotate !== null,
108 [`fa-pull-${props.pull}`]: props.pull !== null,
109 [`fa-stack-${props.stackItemSize}`]: props.stackItemSize != null,
110 };
111 return Object.keys(classes)
112 .map((key) => (classes[key] ? key : null))
113 .filter((key) => key);
114};
115
116/**
117 * Returns if is IconLookup or not.
118 */
119const isIconLookup = (i) => {
120 return i.prefix !== undefined && i.iconName !== undefined;
121};
122
123/**
124 * Normalizing icon spec.
125 */
126const faNormalizeIconSpec = (iconSpec, defaultPrefix) => {
127 if (isIconLookup(iconSpec)) {
128 return iconSpec;
129 }
130 if (Array.isArray(iconSpec) && iconSpec.length === 2) {
131 return { prefix: iconSpec[0], iconName: iconSpec[1] };
132 }
133 if (typeof iconSpec === 'string') {
134 return { prefix: defaultPrefix, iconName: iconSpec };
135 }
136};
137
138class FaStackItemSizeDirective {
139 constructor() {
140 /**
141 * Specify whether icon inside {@link FaStackComponent} should be rendered in
142 * regular size (1x) or as a larger icon (2x).
143 */
144 this.stackItemSize = '1x';
145 }
146 ngOnChanges(changes) {
147 if ('size' in changes) {
148 throw new Error('fa-icon is not allowed to customize size when used inside fa-stack. ' +
149 'Set size on the enclosing fa-stack instead: <fa-stack size="4x">...</fa-stack>.');
150 }
151 }
152}
153FaStackItemSizeDirective.decorators = [
154 { type: Directive, args: [{
155 // tslint:disable-next-line:directive-selector
156 selector: 'fa-icon[stackItemSize],fa-duotone-icon[stackItemSize]',
157 },] }
158];
159FaStackItemSizeDirective.propDecorators = {
160 stackItemSize: [{ type: Input }],
161 size: [{ type: Input }]
162};
163
164class FaStackComponent {
165 constructor(renderer, elementRef) {
166 this.renderer = renderer;
167 this.elementRef = elementRef;
168 }
169 ngOnInit() {
170 this.renderer.addClass(this.elementRef.nativeElement, 'fa-stack');
171 }
172 ngOnChanges(changes) {
173 if ('size' in changes) {
174 if (changes.size.currentValue != null) {
175 this.renderer.addClass(this.elementRef.nativeElement, `fa-${changes.size.currentValue}`);
176 }
177 if (changes.size.previousValue != null) {
178 this.renderer.removeClass(this.elementRef.nativeElement, `fa-${changes.size.previousValue}`);
179 }
180 }
181 }
182}
183FaStackComponent.decorators = [
184 { type: Component, args: [{
185 selector: 'fa-stack',
186 template: `<ng-content></ng-content>`
187 },] }
188];
189FaStackComponent.ctorParameters = () => [
190 { type: Renderer2 },
191 { type: ElementRef }
192];
193FaStackComponent.propDecorators = {
194 size: [{ type: Input }]
195};
196
197class FaIconComponent {
198 constructor(sanitizer, config, iconLibrary, stackItem, stack) {
199 this.sanitizer = sanitizer;
200 this.config = config;
201 this.iconLibrary = iconLibrary;
202 this.stackItem = stackItem;
203 this.classes = [];
204 if (stack != null && stackItem == null) {
205 console.error('FontAwesome: fa-icon and fa-duotone-icon elements must specify stackItemSize attribute when wrapped into ' +
206 'fa-stack. Example: <fa-icon stackItemSize="2x"></fa-icon>.');
207 }
208 }
209 ngOnChanges(changes) {
210 if (this.icon == null && this.config.fallbackIcon == null) {
211 return faWarnIfIconSpecMissing();
212 }
213 let iconToBeRendered = null;
214 if (this.icon == null) {
215 iconToBeRendered = this.config.fallbackIcon;
216 }
217 else {
218 iconToBeRendered = this.icon;
219 }
220 if (changes) {
221 const iconDefinition = this.findIconDefinition(iconToBeRendered);
222 if (iconDefinition != null) {
223 const params = this.buildParams();
224 this.renderIcon(iconDefinition, params);
225 }
226 }
227 }
228 /**
229 * Programmatically trigger rendering of the icon.
230 *
231 * This method is useful, when creating {@link FaIconComponent} dynamically or
232 * changing its inputs programmatically as in these cases icon won't be
233 * re-rendered automatically.
234 */
235 render() {
236 this.ngOnChanges({});
237 }
238 findIconDefinition(i) {
239 const lookup = faNormalizeIconSpec(i, this.config.defaultPrefix);
240 if ('icon' in lookup) {
241 return lookup;
242 }
243 const definition = this.iconLibrary.getIconDefinition(lookup.prefix, lookup.iconName);
244 if (definition != null) {
245 return definition;
246 }
247 const globalDefinition = findIconDefinition(lookup);
248 if (globalDefinition != null) {
249 const message = 'Global icon library is deprecated. ' +
250 'Consult https://github.com/FortAwesome/angular-fontawesome/blob/master/UPGRADING.md ' +
251 'for the migration instructions.';
252 if (this.config.globalLibrary === 'unset') {
253 console.error('FontAwesome: ' + message);
254 }
255 else if (!this.config.globalLibrary) {
256 throw new Error(message);
257 }
258 return globalDefinition;
259 }
260 faWarnIfIconDefinitionMissing(lookup);
261 return null;
262 }
263 buildParams() {
264 const classOpts = {
265 flip: this.flip,
266 spin: this.spin,
267 pulse: this.pulse,
268 border: this.border,
269 inverse: this.inverse,
270 size: this.size || null,
271 pull: this.pull || null,
272 rotate: this.rotate || null,
273 fixedWidth: typeof this.fixedWidth === 'boolean' ? this.fixedWidth : this.config.fixedWidth,
274 stackItemSize: this.stackItem != null ? this.stackItem.stackItemSize : null,
275 };
276 const parsedTransform = typeof this.transform === 'string' ? parse.transform(this.transform) : this.transform;
277 return {
278 title: this.title,
279 transform: parsedTransform,
280 classes: [...faClassList(classOpts), ...this.classes],
281 mask: this.mask != null ? this.findIconDefinition(this.mask) : null,
282 styles: this.styles != null ? this.styles : {},
283 symbol: this.symbol,
284 attributes: {
285 role: this.a11yRole,
286 },
287 };
288 }
289 renderIcon(definition, params) {
290 const renderedIcon = icon(definition, params);
291 this.renderedIconHTML = this.sanitizer.bypassSecurityTrustHtml(renderedIcon.html.join('\n'));
292 }
293}
294FaIconComponent.decorators = [
295 { type: Component, args: [{
296 selector: 'fa-icon',
297 template: ``,
298 host: {
299 class: 'ng-fa-icon',
300 '[attr.title]': 'title',
301 }
302 },] }
303];
304FaIconComponent.ctorParameters = () => [
305 { type: DomSanitizer },
306 { type: FaConfig },
307 { type: FaIconLibrary },
308 { type: FaStackItemSizeDirective, decorators: [{ type: Optional }] },
309 { type: FaStackComponent, decorators: [{ type: Optional }] }
310];
311FaIconComponent.propDecorators = {
312 icon: [{ type: Input }],
313 title: [{ type: Input }],
314 spin: [{ type: Input }],
315 pulse: [{ type: Input }],
316 mask: [{ type: Input }],
317 styles: [{ type: Input }],
318 flip: [{ type: Input }],
319 size: [{ type: Input }],
320 pull: [{ type: Input }],
321 border: [{ type: Input }],
322 inverse: [{ type: Input }],
323 symbol: [{ type: Input }],
324 rotate: [{ type: Input }],
325 fixedWidth: [{ type: Input }],
326 classes: [{ type: Input }],
327 transform: [{ type: Input }],
328 a11yRole: [{ type: Input }],
329 renderedIconHTML: [{ type: HostBinding, args: ['innerHTML',] }]
330};
331
332class FaDuotoneIconComponent extends FaIconComponent {
333 findIconDefinition(i) {
334 const definition = super.findIconDefinition(i);
335 if (definition != null && !Array.isArray(definition.icon[4])) {
336 throw new Error('The specified icon does not appear to be a Duotone icon. ' +
337 'Check that you specified the correct style: ' +
338 `<fa-duotone-icon [icon]="['fad', '${definition.iconName}']"></fa-duotone-icon> ` +
339 `or use: <fa-icon icon="${definition.iconName}"></fa-icon> instead.`);
340 }
341 return definition;
342 }
343 buildParams() {
344 const params = super.buildParams();
345 if (this.swapOpacity === true || this.swapOpacity === 'true') {
346 params.classes.push('fa-swap-opacity');
347 }
348 if (this.primaryOpacity != null) {
349 params.styles['--fa-primary-opacity'] = this.primaryOpacity.toString();
350 }
351 if (this.secondaryOpacity != null) {
352 params.styles['--fa-secondary-opacity'] = this.secondaryOpacity.toString();
353 }
354 if (this.primaryColor != null) {
355 params.styles['--fa-primary-color'] = this.primaryColor;
356 }
357 if (this.secondaryColor != null) {
358 params.styles['--fa-secondary-color'] = this.secondaryColor;
359 }
360 return params;
361 }
362}
363FaDuotoneIconComponent.decorators = [
364 { type: Component, args: [{
365 selector: 'fa-duotone-icon',
366 template: ``
367 },] }
368];
369FaDuotoneIconComponent.propDecorators = {
370 swapOpacity: [{ type: Input }],
371 primaryOpacity: [{ type: Input }],
372 secondaryOpacity: [{ type: Input }],
373 primaryColor: [{ type: Input }],
374 secondaryColor: [{ type: Input }]
375};
376
377/**
378 * Warns if parent component not existing.
379 */
380const faWarnIfParentNotExist = (parent, parentName, childName) => {
381 if (!parent) {
382 throw new Error(`${childName} should be used as child of ${parentName} only.`);
383 }
384};
385
386/**
387 * Fontawesome layers.
388 */
389class FaLayersComponent {
390 constructor(renderer, elementRef, config) {
391 this.renderer = renderer;
392 this.elementRef = elementRef;
393 this.config = config;
394 }
395 ngOnInit() {
396 this.renderer.addClass(this.elementRef.nativeElement, 'fa-layers');
397 this.fixedWidth = typeof this.fixedWidth === 'boolean' ? this.fixedWidth : this.config.fixedWidth;
398 }
399 ngOnChanges(changes) {
400 if ('size' in changes) {
401 if (changes.size.currentValue != null) {
402 this.renderer.addClass(this.elementRef.nativeElement, `fa-${changes.size.currentValue}`);
403 }
404 if (changes.size.previousValue != null) {
405 this.renderer.removeClass(this.elementRef.nativeElement, `fa-${changes.size.previousValue}`);
406 }
407 }
408 }
409}
410FaLayersComponent.decorators = [
411 { type: Component, args: [{
412 selector: 'fa-layers',
413 template: `<ng-content></ng-content>`
414 },] }
415];
416FaLayersComponent.ctorParameters = () => [
417 { type: Renderer2 },
418 { type: ElementRef },
419 { type: FaConfig }
420];
421FaLayersComponent.propDecorators = {
422 size: [{ type: Input }],
423 fixedWidth: [{ type: Input }, { type: HostBinding, args: ['class.fa-fw',] }]
424};
425
426class FaLayersCounterComponent {
427 constructor(parent, sanitizer) {
428 this.parent = parent;
429 this.sanitizer = sanitizer;
430 this.classes = [];
431 faWarnIfParentNotExist(this.parent, 'FaLayersComponent', this.constructor.name);
432 }
433 ngOnChanges(changes) {
434 if (changes) {
435 const params = this.buildParams();
436 this.updateContent(params);
437 }
438 }
439 buildParams() {
440 return {
441 title: this.title,
442 classes: this.classes,
443 styles: this.styles,
444 };
445 }
446 updateContent(params) {
447 this.renderedHTML = this.sanitizer.bypassSecurityTrustHtml(counter(this.content || '', params).html.join(''));
448 }
449}
450FaLayersCounterComponent.decorators = [
451 { type: Component, args: [{
452 selector: 'fa-layers-counter',
453 template: '',
454 host: {
455 class: 'ng-fa-layers-counter',
456 }
457 },] }
458];
459FaLayersCounterComponent.ctorParameters = () => [
460 { type: FaLayersComponent, decorators: [{ type: Optional }] },
461 { type: DomSanitizer }
462];
463FaLayersCounterComponent.propDecorators = {
464 content: [{ type: Input }],
465 title: [{ type: Input }],
466 styles: [{ type: Input }],
467 classes: [{ type: Input }],
468 renderedHTML: [{ type: HostBinding, args: ['innerHTML',] }]
469};
470
471class FaLayersTextComponent {
472 constructor(parent, sanitizer) {
473 this.parent = parent;
474 this.sanitizer = sanitizer;
475 this.classes = [];
476 faWarnIfParentNotExist(this.parent, 'FaLayersComponent', this.constructor.name);
477 }
478 ngOnChanges(changes) {
479 if (changes) {
480 const params = this.buildParams();
481 this.updateContent(params);
482 }
483 }
484 /**
485 * Updating params by component props.
486 */
487 buildParams() {
488 const classOpts = {
489 flip: this.flip,
490 spin: this.spin,
491 pulse: this.pulse,
492 border: this.border,
493 inverse: this.inverse,
494 size: this.size || null,
495 pull: this.pull || null,
496 rotate: this.rotate || null,
497 fixedWidth: this.fixedWidth,
498 };
499 const parsedTransform = typeof this.transform === 'string' ? parse.transform(this.transform) : this.transform;
500 return {
501 transform: parsedTransform,
502 classes: [...faClassList(classOpts), ...this.classes],
503 title: this.title,
504 styles: this.styles,
505 };
506 }
507 updateContent(params) {
508 this.renderedHTML = this.sanitizer.bypassSecurityTrustHtml(text(this.content || '', params).html.join('\n'));
509 }
510}
511FaLayersTextComponent.decorators = [
512 { type: Component, args: [{
513 selector: 'fa-layers-text',
514 template: '',
515 host: {
516 class: 'ng-fa-layers-text',
517 }
518 },] }
519];
520FaLayersTextComponent.ctorParameters = () => [
521 { type: FaLayersComponent, decorators: [{ type: Optional }] },
522 { type: DomSanitizer }
523];
524FaLayersTextComponent.propDecorators = {
525 content: [{ type: Input }],
526 title: [{ type: Input }],
527 styles: [{ type: Input }],
528 classes: [{ type: Input }],
529 spin: [{ type: Input }],
530 pulse: [{ type: Input }],
531 flip: [{ type: Input }],
532 size: [{ type: Input }],
533 pull: [{ type: Input }],
534 border: [{ type: Input }],
535 inverse: [{ type: Input }],
536 rotate: [{ type: Input }],
537 fixedWidth: [{ type: Input }],
538 transform: [{ type: Input }],
539 renderedHTML: [{ type: HostBinding, args: ['innerHTML',] }]
540};
541
542class FontAwesomeModule {
543}
544FontAwesomeModule.decorators = [
545 { type: NgModule, args: [{
546 declarations: [
547 FaIconComponent,
548 FaDuotoneIconComponent,
549 FaLayersComponent,
550 FaLayersTextComponent,
551 FaLayersCounterComponent,
552 FaStackComponent,
553 FaStackItemSizeDirective,
554 ],
555 exports: [
556 FaIconComponent,
557 FaDuotoneIconComponent,
558 FaLayersComponent,
559 FaLayersTextComponent,
560 FaLayersCounterComponent,
561 FaStackComponent,
562 FaStackItemSizeDirective,
563 ],
564 },] }
565];
566
567/**
568 * Generated bundle index. Do not edit.
569 */
570
571export { FaConfig, FaDuotoneIconComponent, FaIconComponent, FaIconLibrary, FaLayersComponent, FaLayersCounterComponent, FaLayersTextComponent, FaStackComponent, FaStackItemSizeDirective, FontAwesomeModule };
572//# sourceMappingURL=angular-fontawesome.js.map
Note: See TracBrowser for help on using the repository browser.