Skip to content

Commit d25af31

Browse files
authored
Merge branch 'main' into main
2 parents 867e060 + 2465d37 commit d25af31

File tree

10 files changed

+1233
-2195
lines changed

10 files changed

+1233
-2195
lines changed

package-lock.json

Lines changed: 1111 additions & 2113 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coreui-angular-dev",
3-
"version": "4.2.3",
3+
"version": "4.2.4",
44
"description": "CoreUI Components Library for Angular",
55
"license": "MIT",
66
"author": "The CoreUI Team (https://github.com/orgs/coreui/people)",
@@ -35,48 +35,48 @@
3535
},
3636
"private": true,
3737
"dependencies": {
38-
"@angular/animations": "^14.2.0",
39-
"@angular/cdk": "^14.2.0",
40-
"@angular/common": "^14.2.0",
41-
"@angular/compiler": "^14.2.0",
42-
"@angular/core": "^14.2.0",
43-
"@angular/forms": "^14.2.0",
44-
"@angular/localize": "^14.2.0",
45-
"@angular/platform-browser": "^14.2.0",
46-
"@angular/platform-browser-dynamic": "^14.2.0",
47-
"@angular/router": "^14.2.0",
38+
"@angular/animations": "^14.2.4",
39+
"@angular/cdk": "^14.2.3",
40+
"@angular/common": "^14.2.4",
41+
"@angular/compiler": "^14.2.4",
42+
"@angular/core": "^14.2.4",
43+
"@angular/forms": "^14.2.4",
44+
"@angular/localize": "^14.2.4",
45+
"@angular/platform-browser": "^14.2.4",
46+
"@angular/platform-browser-dynamic": "^14.2.4",
47+
"@angular/router": "^14.2.4",
4848
"@coreui/chartjs": "^3.0.0",
4949
"@popperjs/core": "~2.11.5",
5050
"chart.js": "^3.9.1",
51+
"lodash-es": "^4.17.21",
5152
"rxjs": "~7.5.0",
5253
"tslib": "^2.3.0",
5354
"zone.js": "~0.11.4"
5455
},
5556
"devDependencies": {
56-
"@angular-devkit/build-angular": "^14.2.1",
57-
"@angular-eslint/builder": "^14.0.3",
58-
"@angular-eslint/eslint-plugin": "^14.0.3",
59-
"@angular-eslint/eslint-plugin-template": "^14.0.3",
60-
"@angular-eslint/schematics": "^14.0.3",
61-
"@angular-eslint/template-parser": "^14.0.3",
62-
"@angular/cli": "^14.2.1",
63-
"@angular/compiler-cli": "^14.2.0",
64-
"@angular/language-service": "^14.2.0",
57+
"@angular-devkit/build-angular": "^14.2.4",
58+
"@angular-eslint/builder": "^14.1.2",
59+
"@angular-eslint/eslint-plugin": "^14.1.2",
60+
"@angular-eslint/eslint-plugin-template": "^14.1.2",
61+
"@angular-eslint/schematics": "^14.1.2",
62+
"@angular-eslint/template-parser": "^14.1.2",
63+
"@angular/cli": "^14.2.4",
64+
"@angular/compiler-cli": "^14.2.4",
65+
"@angular/language-service": "^14.2.4",
6566
"@coreui/icons": "^2.1.0",
6667
"@types/jasmine": "~4.3.0",
6768
"@types/lodash-es": "^4.17.6",
68-
"@types/node": "^16.11.56",
69-
"@typescript-eslint/eslint-plugin": "^5.36.1",
70-
"@typescript-eslint/parser": "^5.36.1",
71-
"eslint": "~8.22.0",
72-
"jasmine-core": "^4.3.0",
73-
"karma": "^6.4.0",
69+
"@types/node": "^16.11.62",
70+
"@typescript-eslint/eslint-plugin": "^5.38.1",
71+
"@typescript-eslint/parser": "^5.38.1",
72+
"eslint": "~8.24.0",
73+
"jasmine-core": "^4.4.0",
74+
"karma": "^6.4.1",
7475
"karma-chrome-launcher": "^3.1.1",
7576
"karma-coverage": "~2.2.0",
7677
"karma-jasmine": "~5.1.0",
7778
"karma-jasmine-html-reporter": "^2.0.0",
78-
"lodash-es": "^4.17.21",
79-
"ng-packagr": "^14.2.0",
79+
"ng-packagr": "^14.2.1",
8080
"prettier": "^2.7.1",
8181
"typescript": "~4.7.2"
8282
},
@@ -107,4 +107,4 @@
107107
"node": "^14.15.0 || >=16.10.0",
108108
"npm": ">=6"
109109
}
110-
}
110+
}

projects/coreui-angular-chartjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coreui/angular-chartjs",
3-
"version": "4.2.0",
3+
"version": "4.2.4",
44
"description": "Angular wrapper component for Chart.js",
55
"copyright": "Copyright 2022 creativeLabs Łukasz Holeczek",
66
"license": "MIT",

projects/coreui-angular-chartjs/src/lib/chartjs.component.spec.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentFixture, TestBed } from '@angular/core/testing';
1+
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
22

33
import { ChartjsComponent } from './chartjs.component';
44
import { Chart, registerables } from 'chart.js';
@@ -42,30 +42,33 @@ describe('ChartjsComponent', () => {
4242
component.type = 'line';
4343
});
4444

45-
it('chart should create', () => {
45+
it('chart should create', fakeAsync(() => {
4646
fixture.detectChanges();
47+
tick();
4748
expect(component).toBeTruthy();
4849
expect(component.chart).toBeDefined();
49-
});
50+
}));
5051

51-
it('chart should receive data', () => {
52+
it('chart should receive data', fakeAsync(() => {
5253
component.data = { ...data };
5354
fixture.detectChanges();
55+
tick();
5456
expect(component.chart?.config.data.labels?.length).toBe(7);
5557
expect(component.chart?.config.data.labels).toEqual(labels);
5658
expect(component.chart?.config.data.datasets[0]?.data.length).toBe(7);
57-
});
59+
}));
5860

59-
it('chart to Base64Image', () => {
61+
it('chart to Base64Image', fakeAsync(() => {
6062
component.data = { ...data };
6163
fixture.detectChanges();
64+
tick();
6265
const image = component.chartToBase64Image();
6366
expect(image).toBeDefined();
6467
expect(typeof image).toBe('string');
6568
expect(image).toContain('data:image/png;base64,');
66-
});
69+
}));
6770

68-
it('chart should update on data change', () => {
71+
it('chart should update on data change', fakeAsync(() => {
6972
component.data = {
7073
...data,
7174
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
@@ -75,7 +78,8 @@ describe('ChartjsComponent', () => {
7578
]
7679
};
7780
fixture.detectChanges();
78-
expect(component.chart.config?.data.labels?.length).toBe(5);
79-
expect(component.chart.config?.data.datasets[1]?.data.length).toBe(5);
80-
});
81+
tick();
82+
expect(component.chart?.config?.data.labels?.length).toBe(5);
83+
expect(component.chart?.config?.data.datasets[1]?.data.length).toBe(5);
84+
}));
8185
});

projects/coreui-angular-chartjs/src/lib/chartjs.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export class ChartjsComponent<TType extends ChartType = ChartType, TData = Defau
143143
this.ngZone.runOutsideAngular(() => {
144144
const config = this.chartConfig();
145145
if (config) {
146-
this.chart = new Chart(ctx, config);
147146
setTimeout(() => {
147+
this.chart = new Chart(ctx, config);
148148
this.renderer.setStyle(this.canvasElement.nativeElement, 'display', 'block');
149149
});
150150
}

projects/coreui-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coreui/angular",
3-
"version": "4.2.3",
3+
"version": "4.2.4",
44
"description": "CoreUI for Angular UI components library",
55
"license": "MIT",
66
"homepage": "https://coreui.io/angular",

projects/coreui-angular/src/lib/dropdown/dropdown/dropdown.component.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class DropdownComponent implements AfterContentInit, OnDestroy, OnInit {
141141
* Sets a specified direction and ___location of the dropdown menu.
142142
* @type 'dropup' | 'dropend' | 'dropstart'
143143
*/
144-
@Input() direction?: 'dropup' | 'dropend' | 'dropstart';
144+
@Input() direction?: 'center' | 'dropup' | 'dropup-center' | 'dropend' | 'dropstart';
145145

146146
/**
147147
* Describes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.
@@ -186,6 +186,14 @@ export class DropdownComponent implements AfterContentInit, OnDestroy, OnInit {
186186
placement = 'left-start';
187187
break;
188188
}
189+
case 'center': {
190+
placement = 'bottom';
191+
break;
192+
}
193+
case 'dropup-center': {
194+
placement = 'top';
195+
break;
196+
}
189197
}
190198
if (this.alignment === 'end') {
191199
placement = 'bottom-end';
@@ -250,9 +258,7 @@ export class DropdownComponent implements AfterContentInit, OnDestroy, OnInit {
250258
(this.variant === 'dropdown' || this.variant === 'nav-item') &&
251259
!this.direction,
252260
[`${this.direction}`]: !!this.direction,
253-
'btn-group': this.variant === 'btn-group',
254-
'nav-item': this.variant === 'nav-item',
255-
'input-group': this.variant === 'input-group',
261+
[`${this.variant}`]: !!this.variant,
256262
show: this.visible
257263
};
258264
}

projects/coreui-angular/src/lib/modal/modal/modal.component.ts

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { ModalContentComponent } from '../modal-content/modal-content.component'
3737
display: 'none'
3838
})
3939
),
40-
transition('visible <=> *', [animate('300ms')],)
40+
transition('visible <=> *', [animate('300ms')])
4141
])
4242
],
4343
templateUrl: './modal.component.html',
@@ -50,7 +50,7 @@ export class ModalComponent implements OnInit, OnDestroy {
5050
static ngAcceptInputType_visible: BooleanInput;
5151

5252
constructor(
53-
@Inject(DOCUMENT) private document: any,
53+
@Inject(DOCUMENT) private document: Document,
5454
private renderer: Renderer2,
5555
private hostElement: ElementRef,
5656
private modalService: ModalService,
@@ -111,9 +111,11 @@ export class ModalComponent implements OnInit, OnDestroy {
111111
set scrollable(value: boolean) {
112112
this._scrollable = coerceBooleanProperty(value);
113113
}
114+
114115
get scrollable(): boolean {
115116
return this._scrollable;
116117
}
118+
117119
private _scrollable = false;
118120

119121
/**
@@ -123,35 +125,36 @@ export class ModalComponent implements OnInit, OnDestroy {
123125
@Input()
124126
set visible(value: boolean) {
125127
const newValue = coerceBooleanProperty(value);
126-
if(this._visible !== newValue) {
128+
if (this._visible !== newValue) {
127129
this._visible = newValue;
128130
this.setBackdrop(this.backdrop !== false && newValue);
129131
this.setBodyStyles(newValue);
130132
this.visibleChange.emit(newValue);
131133
}
132134
}
135+
133136
get visible(): boolean {
134137
return this._visible;
135138
}
139+
136140
private _visible!: boolean;
137141

138142
/**
139143
* Event triggered on modal dismiss.
140144
*/
141145
@Output() visibleChange = new EventEmitter<boolean>();
142146

143-
@ViewChild(ModalContentComponent, {read: ElementRef}) modalContent!: ElementRef;
147+
@ViewChild(ModalContentComponent, { read: ElementRef }) modalContent!: ElementRef;
144148
private activeBackdrop!: any;
145149
private stateToggleSubscription!: Subscription;
146150
private inBoundingClientRect!: boolean;
147151

148-
149152
@HostBinding('class')
150153
get hostClasses(): any {
151154
return {
152155
modal: true,
153156
fade: this.transition,
154-
show: this.show,
157+
show: this.show
155158
};
156159
}
157160

@@ -170,14 +173,16 @@ export class ModalComponent implements OnInit, OnDestroy {
170173
return this.visible ? 'visible' : 'hidden';
171174
}
172175

173-
private _show = true;
174176
get show(): boolean {
175177
return this.visible && this._show;
176178
}
179+
177180
set show(value: boolean) {
178181
this._show = value;
179182
}
180183

184+
private _show = true;
185+
181186
private get scrollbarWidth() {
182187
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
183188
const documentWidth = this.document.documentElement.clientWidth;
@@ -187,28 +192,21 @@ export class ModalComponent implements OnInit, OnDestroy {
187192

188193
@HostListener('@showHide.start', ['$event'])
189194
animateStart(event: AnimationEvent) {
190-
this.renderer.setStyle(this.hostElement.nativeElement, 'overflow-y', 'hidden');
191-
this.show = this.visible;
195+
const scrollbarWidth = this.scrollbarWidth;
196+
if (event.toState === 'visible') {
197+
this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
198+
this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
199+
}
192200
}
193201

194202
@HostListener('@showHide.done', ['$event'])
195203
animateDone(event: AnimationEvent) {
196-
const scrollbarWidth = this.scrollbarWidth;
197204
setTimeout(() => {
198-
if (event.toState === 'visible') {
199-
this.inBoundingClientRect = this.modalContent?.nativeElement?.getBoundingClientRect().height <= this.document?.documentElement.clientHeight;
200-
if (!this.inBoundingClientRect) {
201-
this.renderer.setStyle(this.document.body, 'overflow-y', 'hidden');
202-
this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
203-
} else {
204-
this.renderer.removeStyle(this.document.body, 'overflow-y');
205-
this.renderer.removeStyle(this.document.body, 'padding-right');
206-
}
207-
if (this.fullscreen === true) {
208-
this.renderer.setStyle(this.document.body, 'overflow-y', 'hidden');
209-
}
210-
this.renderer.removeStyle(this.hostElement.nativeElement, 'overflow-y');
205+
if (event.toState === 'hidden') {
206+
this.renderer.removeStyle(this.document.body, 'overflow');
207+
this.renderer.removeStyle(this.document.body, 'padding-right');
211208
}
209+
this.show = this.visible;
212210
});
213211
}
214212

@@ -218,7 +216,7 @@ export class ModalComponent implements OnInit, OnDestroy {
218216
if (this.backdrop === 'static') {
219217
this.setStaticBackdrop();
220218
} else {
221-
this.modalService.toggle({show: false, modal: this});
219+
this.modalService.toggle({ show: false, modal: this });
222220
}
223221
}
224222
}
@@ -241,15 +239,15 @@ export class ModalComponent implements OnInit, OnDestroy {
241239
this.setStaticBackdrop();
242240
return;
243241
}
244-
this.modalService.toggle({show: false, modal: this});
242+
this.modalService.toggle({ show: false, modal: this });
245243
}
246244

247245
ngOnInit(): void {
248246
this.stateToggleSubscribe();
249247
}
250248

251249
ngOnDestroy(): void {
252-
this.modalService.toggle({show: false, modal: this});
250+
this.modalService.toggle({ show: false, modal: this });
253251
this.stateToggleSubscribe(false);
254252
}
255253

@@ -283,16 +281,11 @@ export class ModalComponent implements OnInit, OnDestroy {
283281

284282
private setBodyStyles(open: boolean): void {
285283
if (open) {
286-
if (this.fullscreen === true) {
287-
this.renderer.setStyle(this.document.body, 'overflow-y', 'hidden');
288-
}
289284
if (this.backdrop === true) {
290285
this.renderer.addClass(this.document.body, 'modal-open');
291286
}
292287
} else {
293288
this.renderer.removeClass(this.document.body, 'modal-open');
294-
this.renderer.removeStyle(this.document.body, 'overflow-y');
295-
this.renderer.removeStyle(this.document.body, 'padding-right');
296289
}
297290
}
298291

@@ -303,7 +296,7 @@ export class ModalComponent implements OnInit, OnDestroy {
303296
setTimeout(() => {
304297
this.renderer.removeClass(this.hostElement.nativeElement, 'modal-static');
305298
this.renderer.removeStyle(this.hostElement.nativeElement, 'overflow-y');
306-
}, 400);
299+
}, 300);
307300
}
308301
}
309302
}

0 commit comments

Comments
 (0)