@js-smart/ng-kit 20.6.2-beta.1 → 20.6.2
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.
- package/fesm2022/js-smart-ng-kit.mjs +2443 -0
- package/fesm2022/js-smart-ng-kit.mjs.map +1 -0
- package/index.d.ts +1100 -0
- package/package.json +13 -2
- package/eslint.config.js +0 -18
- package/karma.conf.js +0 -35
- package/ng-package.json +0 -11
- package/src/assets/app-buttons.css +0 -33
- package/src/assets/app-mat-snack-bar.css +0 -89
- package/src/assets/app-variables.css +0 -10
- package/src/assets/general.scss +0 -77
- package/src/assets/styles.scss +0 -5
- package/src/lib/components/alert/alert.component.html +0 -12
- package/src/lib/components/alert/alert.component.scss +0 -5
- package/src/lib/components/alert/alert.component.ts +0 -105
- package/src/lib/components/autocomplete/autocomplete.component.html +0 -42
- package/src/lib/components/autocomplete/autocomplete.component.ts +0 -207
- package/src/lib/components/buttons/base-button/base-button.component.html +0 -0
- package/src/lib/components/buttons/base-button/base-button.component.ts +0 -86
- package/src/lib/components/buttons/base-button/base-button.directive.ts +0 -87
- package/src/lib/components/buttons/bs-link-button/bs-link-button.component.ts +0 -37
- package/src/lib/components/buttons/bs-link-button/bs-link-button.directive.ts +0 -28
- package/src/lib/components/buttons/close-button/close-button.directive.ts +0 -12
- package/src/lib/components/buttons/delete-button/delete-button.component.ts +0 -42
- package/src/lib/components/buttons/delete-button/delete-button.directive.ts +0 -15
- package/src/lib/components/buttons/edit-bs-button/edit-bs-button.component.ts +0 -39
- package/src/lib/components/buttons/edit-bs-button/edit-bs-button.directive.ts +0 -37
- package/src/lib/components/buttons/edit-button/edit-button.component.ts +0 -37
- package/src/lib/components/buttons/edit-button/edit-button.directive.ts +0 -15
- package/src/lib/components/buttons/edit-svg-icon-button/edit-svg-icon-button.component.ts +0 -37
- package/src/lib/components/buttons/edit-svg-icon-button/edit-svg-icon-button.directive.ts +0 -39
- package/src/lib/components/buttons/excel-export-button/excel-export-button.component.ts +0 -23
- package/src/lib/components/buttons/excel-export-button/excel-export-button.directive.ts +0 -23
- package/src/lib/components/buttons/manage-button/manage-button.component.ts +0 -35
- package/src/lib/components/buttons/manage-button/manage-button.directive.ts +0 -15
- package/src/lib/components/buttons/pdf-export-button/pdf-export-button.component.ts +0 -20
- package/src/lib/components/buttons/pdf-export-button/pdf-export-button.directive.ts +0 -22
- package/src/lib/components/buttons/primary-button/primary-button.component.ts +0 -43
- package/src/lib/components/buttons/primary-button/primary-button.directive.ts +0 -16
- package/src/lib/components/buttons/save-primary-button/save-primary-button.component.ts +0 -43
- package/src/lib/components/buttons/save-primary-button/save-primary-button.directive.ts +0 -16
- package/src/lib/components/buttons/search-button/search-button.component.ts +0 -41
- package/src/lib/components/buttons/success-button/success-button.component.ts +0 -41
- package/src/lib/components/buttons/success-button/success-button.directive.ts +0 -15
- package/src/lib/components/buttons/view-button/view-button.component.ts +0 -32
- package/src/lib/components/buttons/view-button/view-button.directive.ts +0 -14
- package/src/lib/components/buttons/view-primary-button/view-primary-button.component.ts +0 -37
- package/src/lib/components/buttons/view-primary-button/view-primary-button.directive.ts +0 -15
- package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +0 -56
- package/src/lib/components/ngx-spinner/ngx-spinner.component.css +0 -169
- package/src/lib/components/ngx-spinner/ngx-spinner.component.html +0 -24
- package/src/lib/components/ngx-spinner/ngx-spinner.component.spec.ts +0 -186
- package/src/lib/components/ngx-spinner/ngx-spinner.component.ts +0 -199
- package/src/lib/components/ngx-spinner/ngx-spinner.enum.ts +0 -45
- package/src/lib/components/ngx-spinner/ngx-spinner.service.ts +0 -66
- package/src/lib/components/ngx-spinner/safe-html.pipe.ts +0 -17
- package/src/lib/components/snack-bar/error-snack-bar/error-snack-bar.component.ts +0 -36
- package/src/lib/components/snack-bar/success-snack-bar/success-snack-bar.component.ts +0 -35
- package/src/lib/components/spinner/spinner.component.html +0 -11
- package/src/lib/components/spinner/spinner.component.scss +0 -18
- package/src/lib/components/spinner/spinner.component.ts +0 -31
- package/src/lib/directives/ngx-print/ngx-print.directive.ts +0 -281
- package/src/lib/directives/ngx-print/print-options.ts +0 -16
- package/src/lib/directives/prevent-multiple-clicks/prevent-multiple-clicks.directive.spec.ts +0 -99
- package/src/lib/directives/prevent-multiple-clicks/prevent-multiple-clicks.directive.ts +0 -36
- package/src/lib/services/mat-snack-bar.service.ts +0 -102
- package/src/lib/store/entity-store.spec.ts +0 -128
- package/src/lib/store/entity-store.ts +0 -88
- package/src/lib/store/store.spec.ts +0 -47
- package/src/lib/store/store.ts +0 -44
- package/src/lib/svg-icons/edit-solid-svg/edit-solid-svg.component.ts +0 -20
- package/src/lib/types/id-type.ts +0 -3
- package/src/lib/types/progress-state.ts +0 -7
- package/src/lib/util/progress-util.ts +0 -84
- package/src/public-api.ts +0 -64
- package/test.ts +0 -11
- package/tsconfig.lib.json +0 -12
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -10
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectorRef } from '@angular/core';
|
|
2
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
-
import { provideAnimations } from '@angular/platform-browser/animations';
|
|
4
|
-
import { BehaviorSubject } from 'rxjs';
|
|
5
|
-
import { NgxSpinnerComponent } from './ngx-spinner.component';
|
|
6
|
-
import { DEFAULTS, NgxSpinner, PRIMARY_SPINNER } from './ngx-spinner.enum';
|
|
7
|
-
import { NgxSpinnerService } from './ngx-spinner.service';
|
|
8
|
-
|
|
9
|
-
describe('NgxSpinnerComponent', () => {
|
|
10
|
-
let component: NgxSpinnerComponent;
|
|
11
|
-
let fixture: ComponentFixture<NgxSpinnerComponent>;
|
|
12
|
-
let spinnerService: jasmine.SpyObj<NgxSpinnerService>;
|
|
13
|
-
let changeDetectorRef: jasmine.SpyObj<ChangeDetectorRef>;
|
|
14
|
-
|
|
15
|
-
const mockSpinnerSubject = new BehaviorSubject<NgxSpinner>(new NgxSpinner());
|
|
16
|
-
|
|
17
|
-
// Helper function to create a keyboard event with spies
|
|
18
|
-
const createKeyboardEvent = (type = 'keydown'): KeyboardEvent => {
|
|
19
|
-
const event = new KeyboardEvent(type);
|
|
20
|
-
spyOn(event, 'preventDefault');
|
|
21
|
-
Object.defineProperty(event, 'returnValue', {
|
|
22
|
-
set: jasmine.createSpy('set returnValue'),
|
|
23
|
-
get: jasmine.createSpy('get returnValue').and.returnValue(false),
|
|
24
|
-
});
|
|
25
|
-
return event;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
beforeEach(async () => {
|
|
29
|
-
const spySpinnerService = jasmine.createSpyObj('NgxSpinnerService', ['getSpinner', 'show', 'hide']);
|
|
30
|
-
const spyChangeDetectorRef = jasmine.createSpyObj('ChangeDetectorRef', ['detectChanges']);
|
|
31
|
-
|
|
32
|
-
spySpinnerService.getSpinner.and.returnValue(mockSpinnerSubject.asObservable());
|
|
33
|
-
|
|
34
|
-
await TestBed.configureTestingModule({
|
|
35
|
-
imports: [NgxSpinnerComponent],
|
|
36
|
-
providers: [
|
|
37
|
-
{ provide: NgxSpinnerService, useValue: spySpinnerService },
|
|
38
|
-
{ provide: ChangeDetectorRef, useValue: spyChangeDetectorRef },
|
|
39
|
-
provideAnimations(),
|
|
40
|
-
],
|
|
41
|
-
}).compileComponents();
|
|
42
|
-
|
|
43
|
-
spinnerService = TestBed.inject(NgxSpinnerService) as jasmine.SpyObj<NgxSpinnerService>;
|
|
44
|
-
changeDetectorRef = TestBed.inject(ChangeDetectorRef) as jasmine.SpyObj<ChangeDetectorRef>;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
fixture = TestBed.createComponent(NgxSpinnerComponent);
|
|
49
|
-
component = fixture.componentInstance;
|
|
50
|
-
fixture.detectChanges();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should create', () => {
|
|
54
|
-
expect(component).toBeTruthy();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should initialize with default values', () => {
|
|
58
|
-
expect(component.bdColor()).toBe(DEFAULTS.BD_COLOR);
|
|
59
|
-
expect(component.size()).toBe('large');
|
|
60
|
-
expect(component.color()).toBe(DEFAULTS.SPINNER_COLOR);
|
|
61
|
-
expect(component.type()).toBe(DEFAULTS.SPINNER_TYPE);
|
|
62
|
-
expect(component.fullScreen()).toBe(true);
|
|
63
|
-
expect(component.name()).toBe(PRIMARY_SPINNER);
|
|
64
|
-
expect(component.zIndex()).toBe(DEFAULTS.Z_INDEX);
|
|
65
|
-
expect(component.template()).toBeUndefined();
|
|
66
|
-
expect(component.showSpinner()).toBe(false);
|
|
67
|
-
expect(component.disableAnimation()).toBe(false);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should update spinner when service emits new value', () => {
|
|
71
|
-
const newSpinner = new NgxSpinner({
|
|
72
|
-
name: 'test-spinner',
|
|
73
|
-
bdColor: 'rgba(0,0,0,0.8)',
|
|
74
|
-
size: 'medium',
|
|
75
|
-
color: '#ffffff',
|
|
76
|
-
type: 'ball-spin',
|
|
77
|
-
fullScreen: false,
|
|
78
|
-
show: true,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
mockSpinnerSubject.next(newSpinner);
|
|
82
|
-
|
|
83
|
-
expect(component.spinner.name).toBe('test-spinner');
|
|
84
|
-
expect(component.spinner.bdColor).toBe('rgba(0,0,0,0.8)');
|
|
85
|
-
expect(component.spinner.size).toBe('medium');
|
|
86
|
-
expect(component.spinner.color).toBe('#ffffff');
|
|
87
|
-
expect(component.spinner.type).toBe('ball-spin');
|
|
88
|
-
expect(component.spinner.fullScreen).toBe(false);
|
|
89
|
-
expect(component.spinner.show).toBe(true);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('Keyboard Event Handling', () => {
|
|
93
|
-
it('should handle keydown event when spinner is visible', () => {
|
|
94
|
-
const event = createKeyboardEvent();
|
|
95
|
-
component.spinnerDOM = { nativeElement: document.createElement('div') };
|
|
96
|
-
|
|
97
|
-
component.handleKeyboardEvent(event);
|
|
98
|
-
|
|
99
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
100
|
-
expect(event.returnValue).toBe(false);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('should handle keyup event when spinner is visible', () => {
|
|
104
|
-
const event = createKeyboardEvent('keyup');
|
|
105
|
-
component.spinnerDOM = { nativeElement: document.createElement('div') };
|
|
106
|
-
|
|
107
|
-
component.handleKeyboardEvent(event);
|
|
108
|
-
|
|
109
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
110
|
-
expect(event.returnValue).toBe(false);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should not handle keyboard events when spinner is not visible', () => {
|
|
114
|
-
const event = createKeyboardEvent();
|
|
115
|
-
component.spinnerDOM = null;
|
|
116
|
-
|
|
117
|
-
component.handleKeyboardEvent(event);
|
|
118
|
-
|
|
119
|
-
expect(event.preventDefault).not.toHaveBeenCalled();
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should not handle keyboard events when spinner DOM is not initialized', () => {
|
|
123
|
-
const event = createKeyboardEvent();
|
|
124
|
-
component.spinnerDOM = undefined;
|
|
125
|
-
|
|
126
|
-
component.handleKeyboardEvent(event);
|
|
127
|
-
|
|
128
|
-
expect(event.preventDefault).not.toHaveBeenCalled();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe('Spinner Class Generation', () => {
|
|
133
|
-
it('should generate correct class name for large spinner', () => {
|
|
134
|
-
const type = 'ball-spin';
|
|
135
|
-
const size = 'large';
|
|
136
|
-
const className = component.getClass(type, size);
|
|
137
|
-
expect(className).toBe('la-ball-spin la-3x');
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('should generate correct class name for medium spinner', () => {
|
|
141
|
-
const type = 'ball-spin';
|
|
142
|
-
const size = 'medium';
|
|
143
|
-
const className = component.getClass(type, size);
|
|
144
|
-
expect(className).toBe('la-ball-spin la-2x');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should generate correct class name for small spinner', () => {
|
|
148
|
-
const type = 'ball-spin';
|
|
149
|
-
const size = 'small';
|
|
150
|
-
const className = component.getClass(type, size);
|
|
151
|
-
expect(className).toBe('la-ball-spin la-sm');
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('should update spinner class on input change', () => {
|
|
155
|
-
component.spinner.type = 'ball-spin';
|
|
156
|
-
component.spinner.size = 'large';
|
|
157
|
-
component.onInputChange();
|
|
158
|
-
expect(component.spinner.class).toBe('la-ball-spin la-3x');
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('should use default values when type or size is undefined', () => {
|
|
162
|
-
component.spinner.type = undefined;
|
|
163
|
-
component.spinner.size = undefined;
|
|
164
|
-
component.onInputChange();
|
|
165
|
-
expect(component.spinner.class).toBe(`la-${DEFAULTS.SPINNER_TYPE} `);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
describe('Component Lifecycle', () => {
|
|
170
|
-
it('should clean up subscription on destroy', () => {
|
|
171
|
-
spyOn(component.ngUnsubscribe, 'next');
|
|
172
|
-
spyOn(component.ngUnsubscribe, 'complete');
|
|
173
|
-
|
|
174
|
-
component.ngOnDestroy();
|
|
175
|
-
|
|
176
|
-
expect(component.ngUnsubscribe.next).toHaveBeenCalled();
|
|
177
|
-
expect(component.ngUnsubscribe.complete).toHaveBeenCalled();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('should set default options on init', () => {
|
|
181
|
-
spyOn(component, 'setDefaultOptions');
|
|
182
|
-
component.ngOnInit();
|
|
183
|
-
expect(component.setDefaultOptions).toHaveBeenCalled();
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { animate, state, style, transition, trigger } from '@angular/animations';
|
|
2
|
-
import { ChangeDetectorRef, Component, HostListener, input, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
|
3
|
-
import { Subject } from 'rxjs';
|
|
4
|
-
import { takeUntil } from 'rxjs/operators';
|
|
5
|
-
import { DEFAULTS, LOADERS, NgxSpinner, PRIMARY_SPINNER, Size } from './ngx-spinner.enum';
|
|
6
|
-
import { NgxSpinnerService } from './ngx-spinner.service';
|
|
7
|
-
import { SafeHtmlPipe } from './safe-html.pipe';
|
|
8
|
-
|
|
9
|
-
@Component({
|
|
10
|
-
selector: 'ngx-spinner',
|
|
11
|
-
imports: [SafeHtmlPipe],
|
|
12
|
-
templateUrl: 'ngx-spinner.component.html',
|
|
13
|
-
styleUrls: ['ngx-spinner.component.css'],
|
|
14
|
-
animations: [
|
|
15
|
-
trigger('fadeIn', [
|
|
16
|
-
state('in', style({ opacity: 1 })),
|
|
17
|
-
transition(':enter', [style({ opacity: 0 }), animate(300)]),
|
|
18
|
-
transition(':leave', animate(200, style({ opacity: 0 }))),
|
|
19
|
-
]),
|
|
20
|
-
],
|
|
21
|
-
})
|
|
22
|
-
export class NgxSpinnerComponent implements OnDestroy, OnInit {
|
|
23
|
-
/**
|
|
24
|
-
* To set backdrop color
|
|
25
|
-
* Only supports RGBA color format
|
|
26
|
-
*/
|
|
27
|
-
bdColor = input<string>(DEFAULTS.BD_COLOR);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* To set spinner size
|
|
31
|
-
*/
|
|
32
|
-
size = input<Size>('large');
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* To set spinner color(DEFAULTS.SPINNER_COLOR)
|
|
36
|
-
*/
|
|
37
|
-
color = input<string>(DEFAULTS.SPINNER_COLOR);
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* To set type of spinner
|
|
41
|
-
*/
|
|
42
|
-
type = input<string>(DEFAULTS.SPINNER_TYPE);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* To toggle fullscreen mode
|
|
46
|
-
*/
|
|
47
|
-
fullScreen = input<boolean>(true);
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Spinner name
|
|
51
|
-
*/
|
|
52
|
-
name = input<string>(PRIMARY_SPINNER);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* z-index value
|
|
56
|
-
*/
|
|
57
|
-
zIndex = input<number>(DEFAULTS.Z_INDEX);
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Custom template for spinner/loader
|
|
61
|
-
*/
|
|
62
|
-
template = input<string>('');
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Show/Hide the spinner
|
|
66
|
-
*/
|
|
67
|
-
showSpinner = input<boolean>(false);
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* To enable/disable animation
|
|
71
|
-
*/
|
|
72
|
-
disableAnimation = input<boolean>(false);
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Spinner Object
|
|
76
|
-
*/
|
|
77
|
-
spinner: NgxSpinner = new NgxSpinner();
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Array for spinner's div
|
|
81
|
-
*/
|
|
82
|
-
divArray: number[] = [];
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Counter for div
|
|
86
|
-
*/
|
|
87
|
-
divCount = 0;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Show spinner
|
|
91
|
-
**/
|
|
92
|
-
show = false;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Unsubscribe from spinner's observable
|
|
96
|
-
**/
|
|
97
|
-
ngUnsubscribe = new Subject<void>();
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Element Reference
|
|
101
|
-
*/
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
@ViewChild('overlay') spinnerDOM;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Creates an instance of NgxSpinnerComponent.
|
|
107
|
-
*/
|
|
108
|
-
constructor(
|
|
109
|
-
private readonly spinnerService: NgxSpinnerService,
|
|
110
|
-
private readonly changeDetector: ChangeDetectorRef,
|
|
111
|
-
) {}
|
|
112
|
-
|
|
113
|
-
@HostListener('document:keydown', ['$event'])
|
|
114
|
-
handleKeyboardEvent(event: KeyboardEvent): void {
|
|
115
|
-
if (this.spinnerDOM?.nativeElement) {
|
|
116
|
-
event.returnValue = false;
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Initialization method
|
|
123
|
-
*/
|
|
124
|
-
ngOnInit(): void {
|
|
125
|
-
this.setDefaultOptions();
|
|
126
|
-
this.spinnerService
|
|
127
|
-
.getSpinner(this.name())
|
|
128
|
-
.pipe(takeUntil(this.ngUnsubscribe))
|
|
129
|
-
.subscribe((spinner: NgxSpinner) => {
|
|
130
|
-
this.setDefaultOptions();
|
|
131
|
-
Object.assign(this.spinner, spinner);
|
|
132
|
-
if (spinner.show) {
|
|
133
|
-
this.onInputChange();
|
|
134
|
-
}
|
|
135
|
-
this.changeDetector.detectChanges();
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* To set default ngx-spinner options
|
|
141
|
-
*/
|
|
142
|
-
setDefaultOptions = (): void => {
|
|
143
|
-
this.spinner = new NgxSpinner({
|
|
144
|
-
name: this.name(),
|
|
145
|
-
bdColor: this.bdColor(),
|
|
146
|
-
size: this.size(),
|
|
147
|
-
color: this.color(),
|
|
148
|
-
type: this.type(),
|
|
149
|
-
fullScreen: this.fullScreen(),
|
|
150
|
-
divArray: this.divArray,
|
|
151
|
-
divCount: this.divCount,
|
|
152
|
-
show: this.show,
|
|
153
|
-
zIndex: this.zIndex(),
|
|
154
|
-
template: this.template(),
|
|
155
|
-
showSpinner: this.showSpinner(),
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* To get class for spinner
|
|
161
|
-
*/
|
|
162
|
-
getClass(type: string, size: Size): string {
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
this.spinner.divCount = LOADERS[type];
|
|
165
|
-
this.spinner.divArray = Array(this.spinner.divCount)
|
|
166
|
-
.fill(0)
|
|
167
|
-
.map((_x, i) => i);
|
|
168
|
-
let sizeClass = '';
|
|
169
|
-
switch (size.toLowerCase()) {
|
|
170
|
-
case 'small':
|
|
171
|
-
sizeClass = 'la-sm';
|
|
172
|
-
break;
|
|
173
|
-
case 'medium':
|
|
174
|
-
sizeClass = 'la-2x';
|
|
175
|
-
break;
|
|
176
|
-
case 'large':
|
|
177
|
-
sizeClass = 'la-3x';
|
|
178
|
-
break;
|
|
179
|
-
default:
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
return 'la-' + type + ' ' + sizeClass;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Check if input variables have changed
|
|
187
|
-
*/
|
|
188
|
-
onInputChange(): void {
|
|
189
|
-
this.spinner.class = this.getClass(this.spinner.type ?? DEFAULTS.SPINNER_TYPE, this.spinner.size ?? 'default');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Component destroy event
|
|
194
|
-
*/
|
|
195
|
-
ngOnDestroy(): void {
|
|
196
|
-
this.ngUnsubscribe.next();
|
|
197
|
-
this.ngUnsubscribe.complete();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const LOADERS = {
|
|
2
|
-
'ball-clip-rotate': 1,
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export const DEFAULTS = {
|
|
6
|
-
BD_COLOR: 'rgba(51,51,51,0.8)',
|
|
7
|
-
SPINNER_COLOR: '#fff',
|
|
8
|
-
SPINNER_TYPE: 'ball-clip-rotate',
|
|
9
|
-
Z_INDEX: 99999,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const PRIMARY_SPINNER = 'primary';
|
|
13
|
-
|
|
14
|
-
export type Size = 'default' | 'small' | 'medium' | 'large';
|
|
15
|
-
|
|
16
|
-
export interface Spinner {
|
|
17
|
-
bdColor?: string;
|
|
18
|
-
size?: Size;
|
|
19
|
-
color?: string;
|
|
20
|
-
type?: string;
|
|
21
|
-
fullScreen?: boolean;
|
|
22
|
-
zIndex?: number;
|
|
23
|
-
template?: string;
|
|
24
|
-
showSpinner?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class NgxSpinner {
|
|
28
|
-
name?: string;
|
|
29
|
-
bdColor?: string;
|
|
30
|
-
size?: Size;
|
|
31
|
-
color?: string;
|
|
32
|
-
type?: string;
|
|
33
|
-
class?: string;
|
|
34
|
-
divCount?: number;
|
|
35
|
-
divArray?: number[];
|
|
36
|
-
fullScreen?: boolean;
|
|
37
|
-
show?: boolean;
|
|
38
|
-
zIndex?: number;
|
|
39
|
-
template?: string;
|
|
40
|
-
showSpinner?: boolean;
|
|
41
|
-
|
|
42
|
-
constructor(init?: Partial<NgxSpinner>) {
|
|
43
|
-
Object.assign(this, init);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
-
import { filter } from 'rxjs/operators';
|
|
4
|
-
import { NgxSpinner, PRIMARY_SPINNER, Spinner } from './ngx-spinner.enum';
|
|
5
|
-
|
|
6
|
-
@Injectable({
|
|
7
|
-
providedIn: 'root',
|
|
8
|
-
})
|
|
9
|
-
export class NgxSpinnerService {
|
|
10
|
-
/**
|
|
11
|
-
* Spinner observable
|
|
12
|
-
*
|
|
13
|
-
* @memberof NgxSpinnerService
|
|
14
|
-
*/
|
|
15
|
-
// private spinnerObservable = new ReplaySubject<NgxSpinner>(1);
|
|
16
|
-
public spinnerObservable = new BehaviorSubject<NgxSpinner | undefined>(undefined);
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Creates an instance of NgxSpinnerService.
|
|
20
|
-
* @memberof NgxSpinnerService
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get subscription of desired spinner
|
|
25
|
-
* @memberof NgxSpinnerService
|
|
26
|
-
**/
|
|
27
|
-
getSpinner(name: string): Observable<NgxSpinner> {
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
return this.spinnerObservable.asObservable().pipe(filter((x) => x?.name === name));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* To show spinner
|
|
34
|
-
*
|
|
35
|
-
* @memberof NgxSpinnerService
|
|
36
|
-
*/
|
|
37
|
-
show(name: string = PRIMARY_SPINNER, spinner?: Spinner) {
|
|
38
|
-
return new Promise((resolve, _reject) => {
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
if (spinner && Object.keys(spinner).length) {
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
spinner['name'] = name;
|
|
43
|
-
this.spinnerObservable.next(new NgxSpinner({ ...spinner, show: true }));
|
|
44
|
-
resolve(true);
|
|
45
|
-
} else {
|
|
46
|
-
this.spinnerObservable.next(new NgxSpinner({ name, show: true }));
|
|
47
|
-
resolve(true);
|
|
48
|
-
}
|
|
49
|
-
}, 10);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* To hide spinner
|
|
55
|
-
*
|
|
56
|
-
* @memberof NgxSpinnerService
|
|
57
|
-
*/
|
|
58
|
-
hide(name: string = PRIMARY_SPINNER, debounce = 10) {
|
|
59
|
-
return new Promise((resolve, _reject) => {
|
|
60
|
-
setTimeout(() => {
|
|
61
|
-
this.spinnerObservable.next(new NgxSpinner({ name, show: false }));
|
|
62
|
-
resolve(true);
|
|
63
|
-
}, debounce);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
|
2
|
-
import { Pipe, PipeTransform } from '@angular/core';
|
|
3
|
-
|
|
4
|
-
@Pipe({
|
|
5
|
-
name: 'safeHtml',
|
|
6
|
-
standalone: true,
|
|
7
|
-
})
|
|
8
|
-
export class SafeHtmlPipe implements PipeTransform {
|
|
9
|
-
constructor(private _sanitizer: DomSanitizer) {}
|
|
10
|
-
|
|
11
|
-
transform(v: string): SafeHtml | undefined {
|
|
12
|
-
if (v) {
|
|
13
|
-
return this._sanitizer.bypassSecurityTrustHtml(v);
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Component, Inject } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
4
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
5
|
-
import { MAT_SNACK_BAR_DATA, MatSnackBarRef } from '@angular/material/snack-bar';
|
|
6
|
-
|
|
7
|
-
@Component({
|
|
8
|
-
selector: 'app-error-snack-bar',
|
|
9
|
-
imports: [MatIconModule, MatButtonModule],
|
|
10
|
-
template: `
|
|
11
|
-
<div class="app-flex-center error-snackbar">
|
|
12
|
-
<mat-icon style="font-size:1.3rem">error</mat-icon>
|
|
13
|
-
<label>{{ data.message }}</label>
|
|
14
|
-
<button style="margin-left: auto" (click)="close()" mat-icon-button>
|
|
15
|
-
<mat-icon>close</mat-icon>
|
|
16
|
-
</button>
|
|
17
|
-
</div>
|
|
18
|
-
`,
|
|
19
|
-
styleUrls: ['../../../../assets/app-mat-snack-bar.css'],
|
|
20
|
-
})
|
|
21
|
-
export class ErrorSnackBarComponent {
|
|
22
|
-
constructor(
|
|
23
|
-
public msb: MatSnackBarRef<ErrorSnackBarComponent>,
|
|
24
|
-
@Inject(MAT_SNACK_BAR_DATA) public data: { message: string; action?: string },
|
|
25
|
-
) {}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Close the Snack Bar
|
|
29
|
-
*
|
|
30
|
-
* @author Pavan Kumar Jadda
|
|
31
|
-
* @since 2.7.18
|
|
32
|
-
*/
|
|
33
|
-
close(): void {
|
|
34
|
-
this.msb.dismissWithAction();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Component, Inject } from '@angular/core';
|
|
2
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
3
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
4
|
-
import { MAT_SNACK_BAR_DATA, MatSnackBarRef } from '@angular/material/snack-bar';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'app-success-snack-bar',
|
|
8
|
-
imports: [MatButtonModule, MatIconModule],
|
|
9
|
-
template: `
|
|
10
|
-
<div class="app-flex-center success-snackbar">
|
|
11
|
-
<mat-icon style="font-size:1.3rem">check_circle</mat-icon>
|
|
12
|
-
<label>{{ data.message }}</label>
|
|
13
|
-
<button style="margin-left: auto" (click)="close()" mat-icon-button>
|
|
14
|
-
<mat-icon>close</mat-icon>
|
|
15
|
-
</button>
|
|
16
|
-
</div>
|
|
17
|
-
`,
|
|
18
|
-
styleUrls: ['../../../../assets/app-mat-snack-bar.css'],
|
|
19
|
-
})
|
|
20
|
-
export class SuccessSnackBarComponent {
|
|
21
|
-
constructor(
|
|
22
|
-
public msb: MatSnackBarRef<SuccessSnackBarComponent>,
|
|
23
|
-
@Inject(MAT_SNACK_BAR_DATA) public data: { message: string; action?: string },
|
|
24
|
-
) {}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Close the Snack Bar
|
|
28
|
-
*
|
|
29
|
-
* @author Pavan Kumar Jadda
|
|
30
|
-
* @since 2.7.18
|
|
31
|
-
*/
|
|
32
|
-
close(): void {
|
|
33
|
-
this.msb.dismissWithAction();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<!-- Angular Material Spinner -->
|
|
2
|
-
@if (!bootstrapSpinner()) {
|
|
3
|
-
<mat-spinner [color]="color()" [diameter]="diameter()" [strokeWidth]="strokeWidth()" class="mx-auto"> </mat-spinner>
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
<!-- Bootstrap Spinner -->
|
|
7
|
-
@if (bootstrapSpinner()) {
|
|
8
|
-
<div class="d-flex justify-content-center">
|
|
9
|
-
<div class="spinner-border bs-spinner" role="status"></div>
|
|
10
|
-
</div>
|
|
11
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.bs-spinner-sm {
|
|
2
|
-
color: #3f51b5;
|
|
3
|
-
margin-bottom: 20px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.bs-spinner {
|
|
7
|
-
color: #3f51b5;
|
|
8
|
-
width: 3rem;
|
|
9
|
-
height: 3rem;
|
|
10
|
-
margin-bottom: 20px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.bs-spinner-lg {
|
|
14
|
-
color: #3f51b5;
|
|
15
|
-
width: 5rem;
|
|
16
|
-
height: 5rem;
|
|
17
|
-
margin-bottom: 20px;
|
|
18
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Component, input } from '@angular/core';
|
|
2
|
-
import { ThemePalette } from '@angular/material/core';
|
|
3
|
-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'spinner,lib-spinner',
|
|
7
|
-
imports: [MatProgressSpinnerModule],
|
|
8
|
-
templateUrl: './spinner.component.html',
|
|
9
|
-
styleUrls: ['./spinner.component.scss'],
|
|
10
|
-
})
|
|
11
|
-
export class SpinnerComponent {
|
|
12
|
-
/**
|
|
13
|
-
* Use Boostrap Spinner. Default `true`
|
|
14
|
-
*/
|
|
15
|
-
bootstrapSpinner = input(true);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Diameter of the Angular Material spinner
|
|
19
|
-
*/
|
|
20
|
-
diameter = input(50);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Color of the Angular Material spinner
|
|
24
|
-
*/
|
|
25
|
-
color = input<ThemePalette>('primary');
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Stroke Width of the Angular Material spinner
|
|
29
|
-
*/
|
|
30
|
-
strokeWidth = input(5);
|
|
31
|
-
}
|