@factor_ec/ui 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.browserslistrc +16 -0
  2. package/karma.conf.js +44 -0
  3. package/ng-package.json +7 -0
  4. package/package.json +3 -23
  5. package/src/lib/display/avatar/avatar.component.html +1 -0
  6. package/src/lib/display/avatar/avatar.component.scss +20 -0
  7. package/src/lib/display/avatar/avatar.component.spec.ts +23 -0
  8. package/src/lib/display/avatar/avatar.component.ts +69 -0
  9. package/src/lib/display/content/content.component.html +4 -0
  10. package/src/lib/display/content/content.component.scss +0 -0
  11. package/src/lib/display/content/content.component.spec.ts +23 -0
  12. package/src/lib/display/content/content.component.ts +15 -0
  13. package/src/lib/display/display.module.ts +41 -0
  14. package/src/lib/display/icon/icon.component.html +4 -0
  15. package/src/lib/display/icon/icon.component.scss +47 -0
  16. package/src/lib/display/icon/icon.component.spec.ts +23 -0
  17. package/src/lib/display/icon/icon.component.ts +88 -0
  18. package/src/lib/display/image/image.component.html +2 -0
  19. package/src/lib/display/image/image.component.scss +53 -0
  20. package/src/lib/display/image/image.component.spec.ts +23 -0
  21. package/src/lib/display/image/image.component.ts +71 -0
  22. package/src/lib/display/message/message.component.html +33 -0
  23. package/src/lib/display/message/message.component.scss +25 -0
  24. package/src/lib/display/message/message.component.spec.ts +23 -0
  25. package/src/lib/display/message/message.component.ts +24 -0
  26. package/src/lib/display/message.service.spec.ts +16 -0
  27. package/src/lib/display/message.service.ts +58 -0
  28. package/src/lib/display/observe-intersecting.directive.spec.ts +8 -0
  29. package/src/lib/display/observe-intersecting.directive.ts +34 -0
  30. package/src/lib/display/progress/progress.component.html +6 -0
  31. package/src/lib/display/progress/progress.component.scss +121 -0
  32. package/src/lib/display/progress/progress.component.spec.ts +23 -0
  33. package/src/lib/display/progress/progress.component.ts +36 -0
  34. package/src/lib/display/progress.service.spec.ts +16 -0
  35. package/src/lib/display/progress.service.ts +51 -0
  36. package/src/lib/inputs/inputs.module.ts +17 -0
  37. package/src/lib/inputs/rating/rating.component.html +13 -0
  38. package/src/lib/inputs/rating/rating.component.scss +61 -0
  39. package/src/lib/inputs/rating/rating.component.spec.ts +25 -0
  40. package/src/lib/inputs/rating/rating.component.ts +66 -0
  41. package/src/lib/models/action-group.ts +9 -0
  42. package/{lib/models/action.d.ts → src/lib/models/action.ts} +1 -1
  43. package/{lib/models/content.d.ts → src/lib/models/content.ts} +1 -1
  44. package/{lib/models/icon.d.ts → src/lib/models/icon.ts} +1 -1
  45. package/{lib/models/message-options.d.ts → src/lib/models/message-options.ts} +2 -1
  46. package/src/lib/models/module-configuration.ts +6 -0
  47. package/src/lib/models/ui-configuration.ts +7 -0
  48. package/src/lib/navigation/list/list.component.html +52 -0
  49. package/src/lib/navigation/list/list.component.scss +93 -0
  50. package/src/lib/navigation/list/list.component.spec.ts +23 -0
  51. package/src/lib/navigation/list/list.component.ts +56 -0
  52. package/src/lib/navigation/navbar/navbar.component.html +23 -0
  53. package/src/lib/navigation/navbar/navbar.component.scss +202 -0
  54. package/src/lib/navigation/navbar/navbar.component.spec.ts +23 -0
  55. package/src/lib/navigation/navbar/navbar.component.ts +57 -0
  56. package/src/lib/navigation/navigation.module.ts +34 -0
  57. package/src/lib/navigation/searchbox/searchbox.component.html +34 -0
  58. package/src/lib/navigation/searchbox/searchbox.component.scss +37 -0
  59. package/src/lib/navigation/searchbox/searchbox.component.spec.ts +23 -0
  60. package/src/lib/navigation/searchbox/searchbox.component.ts +94 -0
  61. package/src/lib/navigation/toolbar/toolbar.component.html +43 -0
  62. package/src/lib/navigation/toolbar/toolbar.component.scss +29 -0
  63. package/src/lib/navigation/toolbar/toolbar.component.spec.ts +23 -0
  64. package/src/lib/navigation/toolbar/toolbar.component.ts +43 -0
  65. package/src/lib/scss/breakpoints.scss +123 -0
  66. package/src/lib/scss/variables.scss +8 -0
  67. package/src/lib/ui.module.ts +34 -0
  68. package/{public-api.d.ts → src/public-api.ts} +4 -0
  69. package/src/test.ts +27 -0
  70. package/tsconfig.lib.json +15 -0
  71. package/tsconfig.lib.prod.json +10 -0
  72. package/tsconfig.spec.json +17 -0
  73. package/esm2020/factor_ec-ui.mjs +0 -5
  74. package/esm2020/lib/display/avatar/avatar.component.mjs +0 -74
  75. package/esm2020/lib/display/content/content.component.mjs +0 -19
  76. package/esm2020/lib/display/display.module.mjs +0 -66
  77. package/esm2020/lib/display/icon/icon.component.mjs +0 -97
  78. package/esm2020/lib/display/image/image.component.mjs +0 -80
  79. package/esm2020/lib/display/message/message.component.mjs +0 -30
  80. package/esm2020/lib/display/message.service.mjs +0 -58
  81. package/esm2020/lib/display/observe-intersecting.directive.mjs +0 -43
  82. package/esm2020/lib/display/progress/progress.component.mjs +0 -42
  83. package/esm2020/lib/display/progress.service.mjs +0 -50
  84. package/esm2020/lib/inputs/inputs.module.mjs +0 -24
  85. package/esm2020/lib/inputs/rating/rating.component.mjs +0 -73
  86. package/esm2020/lib/models/action.mjs +0 -2
  87. package/esm2020/lib/models/content.mjs +0 -2
  88. package/esm2020/lib/models/icon.mjs +0 -2
  89. package/esm2020/lib/models/message-options.mjs +0 -2
  90. package/esm2020/lib/models/module-configuration.mjs +0 -2
  91. package/esm2020/lib/models/ui-configuration.mjs +0 -2
  92. package/esm2020/lib/navigation/list/list.component.mjs +0 -70
  93. package/esm2020/lib/navigation/navbar/navbar.component.mjs +0 -74
  94. package/esm2020/lib/navigation/navigation.module.mjs +0 -55
  95. package/esm2020/lib/navigation/searchbox/searchbox.component.mjs +0 -109
  96. package/esm2020/lib/navigation/toolbar/toolbar.component.mjs +0 -53
  97. package/esm2020/lib/ui.module.mjs +0 -47
  98. package/esm2020/public-api.mjs +0 -22
  99. package/fesm2015/factor_ec-ui.mjs +0 -1002
  100. package/fesm2015/factor_ec-ui.mjs.map +0 -1
  101. package/fesm2020/factor_ec-ui.mjs +0 -993
  102. package/fesm2020/factor_ec-ui.mjs.map +0 -1
  103. package/index.d.ts +0 -5
  104. package/lib/display/avatar/avatar.component.d.ts +0 -22
  105. package/lib/display/content/content.component.d.ts +0 -7
  106. package/lib/display/display.module.d.ts +0 -17
  107. package/lib/display/icon/icon.component.d.ts +0 -24
  108. package/lib/display/image/image.component.d.ts +0 -15
  109. package/lib/display/message/message.component.d.ts +0 -11
  110. package/lib/display/message.service.d.ts +0 -15
  111. package/lib/display/observe-intersecting.directive.d.ts +0 -16
  112. package/lib/display/progress/progress.component.d.ts +0 -15
  113. package/lib/display/progress.service.d.ts +0 -15
  114. package/lib/inputs/inputs.module.d.ts +0 -8
  115. package/lib/inputs/rating/rating.component.d.ts +0 -23
  116. package/lib/models/module-configuration.d.ts +0 -6
  117. package/lib/models/ui-configuration.d.ts +0 -7
  118. package/lib/navigation/list/list.component.d.ts +0 -21
  119. package/lib/navigation/navbar/navbar.component.d.ts +0 -23
  120. package/lib/navigation/navigation.module.d.ts +0 -15
  121. package/lib/navigation/searchbox/searchbox.component.d.ts +0 -34
  122. package/lib/navigation/toolbar/toolbar.component.d.ts +0 -18
  123. package/lib/ui.module.d.ts +0 -13
@@ -0,0 +1,16 @@
1
+ # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
+ # For additional information regarding the format and rule options, please see:
3
+ # https://github.com/browserslist/browserslist#queries
4
+
5
+ # For the full list of supported browsers by the Angular framework, please see:
6
+ # https://angular.io/guide/browser-support
7
+
8
+ # You can see what browsers were selected by your queries by running:
9
+ # npx browserslist
10
+
11
+ last 1 Chrome version
12
+ last 1 Firefox version
13
+ last 2 Edge major versions
14
+ last 2 Safari major versions
15
+ last 2 iOS major versions
16
+ Firefox ESR
package/karma.conf.js ADDED
@@ -0,0 +1,44 @@
1
+ // Karma configuration file, see link for more information
2
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+ module.exports = function (config) {
5
+ config.set({
6
+ basePath: '',
7
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+ plugins: [
9
+ require('karma-jasmine'),
10
+ require('karma-chrome-launcher'),
11
+ require('karma-jasmine-html-reporter'),
12
+ require('karma-coverage'),
13
+ require('@angular-devkit/build-angular/plugins/karma')
14
+ ],
15
+ client: {
16
+ jasmine: {
17
+ // you can add configuration options for Jasmine here
18
+ // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+ // for example, you can disable the random execution with `random: false`
20
+ // or set a specific seed with `seed: 4321`
21
+ },
22
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+ },
24
+ jasmineHtmlReporter: {
25
+ suppressAll: true // removes the duplicated traces
26
+ },
27
+ coverageReporter: {
28
+ dir: require('path').join(__dirname, '../../coverage/ui'),
29
+ subdir: '.',
30
+ reporters: [
31
+ { type: 'html' },
32
+ { type: 'text-summary' }
33
+ ]
34
+ },
35
+ reporters: ['progress', 'kjhtml'],
36
+ port: 9876,
37
+ colors: true,
38
+ logLevel: config.LOG_INFO,
39
+ autoWatch: true,
40
+ browsers: ['Chrome'],
41
+ singleRun: false,
42
+ restartOnFileChange: true
43
+ });
44
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ui",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factor_ec/ui",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "license": "CC-BY-NC-ND-4.0",
5
5
  "author": "Factor",
6
6
  "private": false,
@@ -12,25 +12,5 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "tslib": "^2.3.0"
15
- },
16
- "module": "fesm2015/factor_ec-ui.mjs",
17
- "es2020": "fesm2020/factor_ec-ui.mjs",
18
- "esm2020": "esm2020/factor_ec-ui.mjs",
19
- "fesm2020": "fesm2020/factor_ec-ui.mjs",
20
- "fesm2015": "fesm2015/factor_ec-ui.mjs",
21
- "typings": "index.d.ts",
22
- "exports": {
23
- "./package.json": {
24
- "default": "./package.json"
25
- },
26
- ".": {
27
- "types": "./index.d.ts",
28
- "esm2020": "./esm2020/factor_ec-ui.mjs",
29
- "es2020": "./fesm2020/factor_ec-ui.mjs",
30
- "es2015": "./fesm2015/factor_ec-ui.mjs",
31
- "node": "./fesm2015/factor_ec-ui.mjs",
32
- "default": "./fesm2020/factor_ec-ui.mjs"
33
- }
34
- },
35
- "sideEffects": false
36
- }
15
+ }
16
+ }
@@ -0,0 +1 @@
1
+ <div *ngIf="!loaded">{{ initials }}</div>
@@ -0,0 +1,20 @@
1
+ :host {
2
+ --default-size: var(--size, 3rem);
3
+ display: inline-flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ color: #fff;
7
+ background-size: cover;
8
+ background-repeat: no-repeat;
9
+ border-radius: calc(var(--default-size) / 2);
10
+ font-size: calc(var(--default-size) - (var(--default-size) * 0.6));
11
+ min-width: var(--default-size);
12
+ min-height: var(--default-size);
13
+ cursor: default;
14
+ user-select: none;
15
+ }
16
+
17
+ div {
18
+ font-size: 1em;
19
+ line-height: 1em;
20
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { AvatarComponent } from './avatar.component';
4
+
5
+ describe('AvatarComponent', () => {
6
+ let component: AvatarComponent;
7
+ let fixture: ComponentFixture<AvatarComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ AvatarComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(AvatarComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,69 @@
1
+ import { Component, HostBinding, Input, OnInit } from '@angular/core';
2
+ import { ColorService } from '@factor_ec/utils';
3
+
4
+ @Component({
5
+ selector: 'ft-avatar',
6
+ templateUrl: './avatar.component.html',
7
+ styleUrls: ['./avatar.component.scss']
8
+ })
9
+ export class AvatarComponent implements OnInit {
10
+ _label!: string;
11
+ _src!: string;
12
+ @Input()
13
+ color!: string;
14
+ initials!: string;
15
+ loaded!: boolean;
16
+ @Input()
17
+ class: string = '';
18
+ @Input()
19
+ set src(value: string | undefined) {
20
+ if (value && value.trim()!='') {
21
+ this._src = value;
22
+ let image = new Image();
23
+ image.src = value;
24
+ image.onload = () => {
25
+ if ("decode" in image) {
26
+ image.decode().then(() => {
27
+ this.loaded = true;
28
+ });
29
+ } else {
30
+ console.error('Image.decode not available.');
31
+ }
32
+ };
33
+ }
34
+ }
35
+ @Input()
36
+ set label(value: string) {
37
+ this._label = value;
38
+ this.initials = this.getInitials(value);
39
+ }
40
+ @HostBinding('style.background-color')
41
+ get backgroundColor(): string {
42
+ return this.color || this.colorService.hex(this._label);
43
+ }
44
+ @HostBinding('style.background-image')
45
+ get backgroundImage(): string {
46
+ return this._src ? `url(${this._src})` : '';
47
+ }
48
+ @HostBinding('class')
49
+ get hostClasses(): string {
50
+ return [
51
+ 'ft-avatar',
52
+ this.class
53
+ ].join(' ');
54
+ }
55
+
56
+ constructor(
57
+ private colorService: ColorService
58
+ ) { }
59
+
60
+ ngOnInit() {
61
+
62
+ }
63
+ getInitials(value: string): string {
64
+ let allInitials: string[] = value.match(/\b\w/g) || [];
65
+ let initials: string = ((allInitials.shift() || '') + (allInitials.pop() || '')).toUpperCase();
66
+ return initials;
67
+ }
68
+
69
+ }
@@ -0,0 +1,4 @@
1
+ <ng-container [ngSwitch]="data.message?.type">
2
+ <div *ngSwitchCase="'html'" [innerHTML]="data.message?.content"></div>
3
+ <ng-container *ngSwitchDefault>{{ data.message?.content }}</ng-container>
4
+ </ng-container>
File without changes
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { ContentComponent } from './content.component';
4
+
5
+ describe('ContentComponent', () => {
6
+ let component: ContentComponent;
7
+ let fixture: ComponentFixture<ContentComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ ContentComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(ContentComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,15 @@
1
+ import { Component, Inject } from '@angular/core';
2
+ import { MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
3
+
4
+ @Component({
5
+ selector: 'lib-content',
6
+ templateUrl: './content.component.html',
7
+ styleUrls: ['./content.component.scss']
8
+ })
9
+ export class ContentComponent {
10
+
11
+ constructor(
12
+ @Inject(MAT_SNACK_BAR_DATA) public data: any
13
+ ) { }
14
+
15
+ }
@@ -0,0 +1,41 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { MatButtonModule } from '@angular/material/button';
4
+ import { MatDialogModule } from '@angular/material/dialog';
5
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
6
+
7
+ import { AvatarComponent } from './avatar/avatar.component';
8
+ import { IconComponent } from './icon/icon.component';
9
+ import { ImageComponent } from './image/image.component';
10
+ import { ProgressComponent } from './progress/progress.component';
11
+ import { ObserveIntersectingDirective } from './observe-intersecting.directive';
12
+ import { MessageComponent } from './message/message.component';
13
+ import { ContentComponent } from './content/content.component';
14
+
15
+ @NgModule({
16
+ declarations: [
17
+ AvatarComponent,
18
+ IconComponent,
19
+ ImageComponent,
20
+ ProgressComponent,
21
+ ObserveIntersectingDirective,
22
+ MessageComponent,
23
+ ContentComponent
24
+ ],
25
+ exports: [
26
+ AvatarComponent,
27
+ IconComponent,
28
+ ImageComponent,
29
+ ProgressComponent,
30
+ ObserveIntersectingDirective,
31
+ MessageComponent,
32
+ ContentComponent
33
+ ],
34
+ imports: [
35
+ CommonModule,
36
+ MatButtonModule,
37
+ MatDialogModule,
38
+ MatSnackBarModule
39
+ ]
40
+ })
41
+ export class DisplayModule { }
@@ -0,0 +1,4 @@
1
+ <svg *ngIf="!src; else imageTemplate"><use attr.xlink:href="{{ url }}" attr.href="{{ url }}" /></svg>
2
+ <ng-template #imageTemplate>
3
+ <img [src]="src" />
4
+ </ng-template>
@@ -0,0 +1,47 @@
1
+ :host {
2
+ line-height: 0;
3
+ display: inline-block;
4
+ &[size="1"],
5
+ &.ft-icon--1 {
6
+ font-size: 1rem;
7
+ }
8
+ &[size="2"],
9
+ &.ft-icon--2 {
10
+ font-size: 1.5rem;
11
+ }
12
+ &[size="3"],
13
+ &.ft-icon--3 {
14
+ font-size: 2rem;
15
+ }
16
+ &[size="4"],
17
+ &.ft-icon--4 {
18
+ font-size: 3rem;
19
+ }
20
+ &[size="5"],
21
+ &.ft-icon--5 {
22
+ font-size: 4.5rem;
23
+ }
24
+ &[size="6"],
25
+ &.ft-icon--6 {
26
+ font-size: 8rem;
27
+ }
28
+ &[size="7"],
29
+ &.ft-icon--7 {
30
+ font-size: 16rem;
31
+ }
32
+ &[size="8"],
33
+ &.ft-icon--8 {
34
+ font-size: 32rem;
35
+ }
36
+ }
37
+ svg {
38
+ width: 1em;
39
+ height: 1em;
40
+ vertical-align: middle;
41
+ fill: currentColor;
42
+ }
43
+ img {
44
+ height: 1em;
45
+ vertical-align: middle;
46
+ }
47
+
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { IconComponent } from './icon.component';
4
+
5
+ describe('IconComponent', () => {
6
+ let component: IconComponent;
7
+ let fixture: ComponentFixture<IconComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ IconComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(IconComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,88 @@
1
+ import { Component, OnInit, Input, Inject, HostBinding } from '@angular/core';
2
+ import { UiConfiguration } from '../../models/ui-configuration';
3
+
4
+ @Component({
5
+ selector: 'ft-icon',
6
+ templateUrl: './icon.component.html',
7
+ styleUrls: ['./icon.component.scss']
8
+ })
9
+ export class IconComponent implements OnInit {
10
+ _collection!: string;
11
+ _name!: string;
12
+ _mode!: 'inline' | 'external';
13
+ _path!: string;
14
+ @Input()
15
+ class: string = '';
16
+ @Input()
17
+ set collection(collection: string) {
18
+ this._collection = collection;
19
+ this.update();
20
+ }
21
+ @Input()
22
+ set mode(mode: 'inline' | 'external') {
23
+ this._mode = mode;
24
+ this.update();
25
+ }
26
+ @Input()
27
+ set name(name: string) {
28
+ this._name = name;
29
+ this.update();
30
+ }
31
+ @Input()
32
+ set path(path: string) {
33
+ this._path = path;
34
+ this.update();
35
+ }
36
+ @Input()
37
+ size!: string;
38
+ @Input()
39
+ src!: string;
40
+ url!: string;
41
+ @HostBinding('class')
42
+ get hostClasses(): string {
43
+ return [
44
+ 'ft-icon',
45
+ this.class
46
+ ].join(' ');
47
+ }
48
+
49
+ constructor(
50
+ @Inject('FactorUiConfiguration') private configuration: UiConfiguration
51
+ ) { }
52
+
53
+ ngOnInit() {
54
+ this.update();
55
+ }
56
+ private update() {
57
+ // Set the default collection if the mode is external
58
+ if (!this._collection) {
59
+ if (this.configuration.icon && this.configuration.icon.collection) {
60
+ this._collection = this.configuration.icon.collection;
61
+ } else if (this._mode === 'external') {
62
+ this._collection = 'icons';
63
+ }
64
+ }
65
+ if (!this._mode) {
66
+ if (this.configuration.icon && this.configuration.icon.mode) {
67
+ this._mode = this.configuration.icon.mode;
68
+ } else {
69
+ this._mode = 'external';
70
+ }
71
+ }
72
+ if (this._mode === 'external') {
73
+ // If the icon mode is external
74
+ if (!this._path) {
75
+ if (this.configuration.icon && this.configuration.icon.path) {
76
+ this._path = this.configuration.icon.path;
77
+ } else {
78
+ this._path = 'assets';
79
+ }
80
+ }
81
+ this.url = `${ this._path }/${ this._collection }.svg#${this._name}`;
82
+ } else {
83
+ // If the icon mode is inline
84
+ const name = this._collection && this._collection !== 'unset' ? `${this._collection}--${this._name}` : this._name;
85
+ this.url = `#${name}`;
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,2 @@
1
+ <img *ngIf="shown" [src]="src" />
2
+ <ft-icon name="warning" size="2" *ngIf="error"></ft-icon>
@@ -0,0 +1,53 @@
1
+ :host {
2
+ display: inline-block;
3
+ overflow: hidden;
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ &.ft-image--loading {
8
+ background-color: rgba(0, 0, 0, 0.03);
9
+ position: relative;
10
+ overflow: hidden;
11
+ &::after {
12
+ content: "";
13
+ display: block;
14
+ background-color: rgba(0, 0, 0, 0.02);
15
+ position: absolute;
16
+ top: 0;
17
+ bottom: 0;
18
+ width: 100%;
19
+ height: 100%;
20
+ transform: translateX(0);
21
+ animation: 1.5s placeholder-loading ease-in-out infinite;
22
+ }
23
+ }
24
+ &.ft-image--error {
25
+ background-color: rgba(255, 0, 0, 0.03);
26
+ ft-icon {
27
+ color: var(--danger);
28
+ }
29
+ }
30
+ }
31
+ img {
32
+ position: relative;
33
+ z-index: 1;
34
+ max-width: 100%;
35
+ max-height: 100%;
36
+ animation: fade-in 0.3s;
37
+ }
38
+ @keyframes fade-in {
39
+ from {
40
+ opacity: 0;
41
+ }
42
+ to {
43
+ opacity: 1;
44
+ }
45
+ }
46
+ @keyframes placeholder-loading {
47
+ 0% {
48
+ transform: translateX(-100%);
49
+ }
50
+ 100% {
51
+ transform: translateX(100%);
52
+ }
53
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { ImageComponent } from './image.component';
4
+
5
+ describe('ImageComponent', () => {
6
+ let component: ImageComponent;
7
+ let fixture: ComponentFixture<ImageComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ ImageComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(ImageComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,71 @@
1
+ import { Component, OnInit, Input, HostBinding, ElementRef } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'ft-image',
5
+ templateUrl: './image.component.html',
6
+ styleUrls: ['./image.component.scss']
7
+ })
8
+ export class ImageComponent implements OnInit {
9
+ @Input()
10
+ class: string = '';
11
+ @HostBinding('class.ft-image--error')
12
+ error!: boolean;
13
+ @HostBinding('class.ft-image--loading')
14
+ loading: boolean = false;
15
+ @Input()
16
+ src!: string;
17
+ shown: boolean = false;
18
+
19
+ constructor(
20
+ private element: ElementRef
21
+ ) { }
22
+
23
+ ngOnInit() {
24
+ if ("IntersectionObserver" in window) {
25
+ let elementObserver = new IntersectionObserver((entries, observer) => {
26
+ entries.forEach((entry) => {
27
+ if (entry.isIntersecting) {
28
+ let image = new Image();
29
+ image.src = this.src;
30
+ setTimeout(() => {
31
+ if (!this.shown && !this.error) {
32
+ this.loading = true;
33
+ }
34
+ }, 100);
35
+ image.onerror = () => {
36
+ this.error = true;
37
+ this.loading = false;
38
+ };
39
+ image.onload = () => {
40
+ if ("decode" in image) {
41
+ image.decode().then(() => {
42
+ this.loading = false;
43
+ this.shown = true;
44
+ });
45
+ } else {
46
+ this.loading = false;
47
+ this.shown = true;
48
+ }
49
+ };
50
+ elementObserver.unobserve(this.element.nativeElement);
51
+ }
52
+ });
53
+ }, {
54
+ rootMargin: "0px 0px 200px 0px"
55
+ });
56
+ elementObserver.observe(this.element.nativeElement);
57
+ } else {
58
+ console.error('IntersectionObserver not available.');
59
+ this.loading = false;
60
+ this.shown = true;
61
+ }
62
+ }
63
+ @HostBinding('class')
64
+ get hostClasses(): string {
65
+ return [
66
+ 'ft-image',
67
+ this.class
68
+ ].join(' ');
69
+ }
70
+
71
+ }
@@ -0,0 +1,33 @@
1
+ <h1 mat-dialog-title class="ft-message__title" *ngIf="data.options?.title">
2
+ <ft-icon *ngIf="data.options?.titleIcon" [name]="data.options?.titleIcon?.name"
3
+ [collection]="data.options?.titleIcon?.collection" [ngClass]="data.options?.titleIcon?.class"
4
+ [size]="data.options?.titleIcon?.size || 2"></ft-icon>
5
+ <div>{{ data.options?.title }}</div>
6
+ </h1>
7
+ <div mat-dialog-content class="ft-message__content" [ngClass]="data.options?.class">
8
+ <ft-icon *ngIf="data.options?.icon" [name]="data.options?.icon?.name" [collection]="data.options?.icon?.collection"
9
+ [ngClass]="data.options?.icon?.class" [size]="data.options?.icon?.size || 2"></ft-icon>
10
+ <ng-container [ngSwitch]="data.message?.type">
11
+ <div *ngSwitchCase="'html'" [innerHTML]="data.message?.content"></div>
12
+ <ng-container *ngSwitchDefault>{{ data.message?.content }}</ng-container>
13
+ </ng-container>
14
+ </div>
15
+ <div mat-dialog-actions class="ft-message__actions" *ngIf="data.options.actionsVisible">
16
+ <ng-container *ngIf="data.options?.actions?.length > 0; else acceptTemplate">
17
+ <ng-container *ngFor="let action of data.options?.actions; let i = index">
18
+ <ng-container [ngSwitch]="action.type">
19
+ <button type="button" *ngSwitchCase="'raised'" mat-raised-button [color]="action.metadata?.color"
20
+ (click)="select(action.value)" autofocus>{{ action.label }}</button>
21
+ <button type="button" *ngSwitchCase="'flat'" mat-flat-button [color]="action.metadata?.color"
22
+ (click)="select(action.value)" autofocus>{{ action.label }}</button>
23
+ <button type="button" *ngSwitchCase="'stroked'" mat-stroked-button [color]="action.metadata?.color"
24
+ (click)="select(action.value)" autofocus>{{ action.label }}</button>
25
+ <button type="button" *ngSwitchDefault mat-button [color]="action.metadata?.color"
26
+ (click)="select(action.value)">{{ action.label }}</button>
27
+ </ng-container>
28
+ </ng-container>
29
+ </ng-container>
30
+ </div>
31
+ <ng-template #acceptTemplate>
32
+ <button type="button" mat-stroked-button color="primary" autofocus (click)="select('-1')" i18n>Accept</button>
33
+ </ng-template>