Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/primefaces/primeng
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcetin01140 committed Jan 4, 2024
2 parents efd161c + 0d04b3e commit d7f077c
Show file tree
Hide file tree
Showing 130 changed files with 2,554 additions and 1,598 deletions.
14 changes: 7 additions & 7 deletions src/app/components/megamenu/megamenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ export class MegaMenu implements AfterContentInit, OnDestroy, OnInit {
this.focusedItemInfo.set({ index, key, parentKey, item });

this.dirty = !root;
DomHandler.focus(this.rootmenu.menubarViewChild.nativeElement);
DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement);
} else {
if (grouped) {
this.onItemChange(event);
Expand All @@ -623,7 +623,7 @@ export class MegaMenu implements AfterContentInit, OnDestroy, OnInit {
this.hide(originalEvent);
this.changeFocusedItemInfo(originalEvent, rootProcessedItem ? rootProcessedItem.index : -1);

DomHandler.focus(this.rootmenu.menubarViewChild.nativeElement);
DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement);
}
}
}
Expand All @@ -636,7 +636,7 @@ export class MegaMenu implements AfterContentInit, OnDestroy, OnInit {

scrollInView(index: number = -1) {
const id = index !== -1 ? `${this.id}_${index}` : this.focusedItemId;
const element = DomHandler.findSingle(this.rootmenu.el.nativeElement, `li[id="${id}"]`);
const element = DomHandler.findSingle(this.rootmenu?.el.nativeElement, `li[id="${id}"]`);

if (element) {
element.scrollIntoView && element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
Expand All @@ -657,14 +657,14 @@ export class MegaMenu implements AfterContentInit, OnDestroy, OnInit {
this.focusedItemInfo.set({ index, key, parentKey, item });

grouped && (this.dirty = true);
isFocus && DomHandler.focus(this.rootmenu.menubarViewChild.nativeElement);
isFocus && DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement);
}

hide(event?, isFocus?: boolean) {
this.activeItem.set(null);
this.focusedItemInfo.set({ index: -1, key: '', parentKey: '', item: null });

isFocus && DomHandler.focus(this.rootmenu.menubarViewChild.nativeElement);
isFocus && DomHandler.focus(this.rootmenu?.menubarViewChild?.nativeElement);
this.dirty = false;
}

Expand Down Expand Up @@ -991,7 +991,7 @@ export class MegaMenu implements AfterContentInit, OnDestroy, OnInit {

onEnterKey(event: KeyboardEvent) {
if (this.focusedItemInfo().index !== -1) {
const element = DomHandler.findSingle(this.rootmenu.el.nativeElement, `li[id="${`${this.focusedItemId}`}"]`);
const element = DomHandler.findSingle(this.rootmenu?.el?.nativeElement, `li[id="${`${this.focusedItemId}`}"]`);
const anchorElement = element && DomHandler.findSingle(element, 'a[data-pc-section="action"]');

anchorElement ? anchorElement.click() : element && element.click();
Expand Down Expand Up @@ -1044,7 +1044,7 @@ export class MegaMenu implements AfterContentInit, OnDestroy, OnInit {
if (isPlatformBrowser(this.platformId)) {
if (!this.outsideClickListener) {
this.outsideClickListener = this.renderer.listen(this.document, 'click', (event) => {
const isOutsideContainer = this.rootmenu.el.nativeElement !== event.target && !this.rootmenu.el.nativeElement.contains(event.target);
const isOutsideContainer = this.rootmenu?.el.nativeElement !== event.target && !this.rootmenu?.el.nativeElement.contains(event.target);

if (isOutsideContainer) {
this.hide();
Expand Down
1 change: 1 addition & 0 deletions src/app/components/tieredmenu/tieredmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primeng/utils';
[menuId]="menuId"
[activeItemPath]="activeItemPath"
[focusedItemId]="focusedItemId"
[ariaLabelledBy]="getItemId(processedItem)"
[level]="level + 1"
(itemClick)="itemClick.emit($event)"
(itemMouseEnter)="onItemMouseEnter($event)"
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ import {
</span>
</span>
</div>
<ul class="p-treenode-children" style="display: none;" *ngIf="!tree.virtualScroll && node.children && node.expanded" [style.display]="node.expanded ? 'block' : 'none'" role="group">
<ul class="p-treenode-children" style="display: none;" *ngIf="!tree.virtualScroll && node.children && node.expanded" [style.display]="node.expanded ? 'block' : 'none'" role="tree">
<p-treeNode
*ngFor="let childNode of node.children; let firstChild = first; let lastChild = last; let index = index; trackBy: tree.trackBy"
[node]="childNode"
Expand Down
10 changes: 10 additions & 0 deletions src/app/showcase/demo/deferreddemo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.demo-section-loading {
display: grid;
place-items: center;
padding: 2rem;
border-radius: 10px;
margin-bottom: 1rem;
font-size: 2rem;
height: 350px;
background: var(--maskbg);
}
54 changes: 54 additions & 0 deletions src/app/showcase/demo/deferreddemo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { CommonModule, isPlatformBrowser } from '@angular/common';
import { Component, ElementRef, EventEmitter, Inject, Input, OnInit, Output, PLATFORM_ID } from '@angular/core';

@Component({
selector: 'p-deferred-demo',
standalone: true,
imports: [CommonModule],
template: `
@if(!visible){
<div class="demo-section-loading">Loading...</div>
} @else {
<ng-content></ng-content>
}
`,
styleUrl: './deferreddemo.scss'
})
export class DeferredDemo implements OnInit {
visible: boolean = false;

observer = null;

timeout = null;

@Input() options: any;

@Output() load: EventEmitter<boolean> = new EventEmitter<boolean>();

constructor(public el: ElementRef, @Inject(PLATFORM_ID) private platformId: any) {}

ngOnInit() {
if (isPlatformBrowser(this.platformId)) {
this.observer = new IntersectionObserver(([entry]) => {
clearTimeout(this.timeout);

if (entry.isIntersecting) {
this.timeout = setTimeout(() => {
this.visible = true;
this.observer.unobserve(this.el.nativeElement);
this.load.emit();
}, 350);
}
}, this.options);

this.observer.observe(this.el.nativeElement);
}
}

ngOnDestroy() {
if (!this.visible && this.el.nativeElement) {
this.observer?.unobserve(this.el.nativeElement);
}
clearTimeout(this.timeout);
}
}
31 changes: 23 additions & 8 deletions src/app/showcase/doc/chart/basicdoc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { ChangeDetectorRef, Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Code } from '../../domain/code';
import { AppConfigService } from '../../service/appconfigservice';
import { Subscription, debounceTime } from 'rxjs';

@Component({
selector: 'chart-basic-demo',
Expand All @@ -22,9 +24,20 @@ export class BasicDoc implements OnInit {

basicOptions: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand All @@ -48,22 +61,24 @@ export class BasicDoc implements OnInit {
plugins: {
legend: {
labels: {
color: textColor
fontColor: textColor
}
}
},
scales: {
y: {
beginAtZero: true,
x: {
ticks: {
color: textColorSecondary
color: textColorSecondary,
font: {
weight: 500
}
},
grid: {
color: surfaceBorder,
display: false,
drawBorder: false
}
},
x: {
y: {
ticks: {
color: textColorSecondary
},
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/combodoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-combo-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class ComboDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
19 changes: 15 additions & 4 deletions src/app/showcase/doc/chart/doughnutdoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-doughnut-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class DoughnutDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down Expand Up @@ -49,7 +61,6 @@ export class DoughnutDoc implements OnInit {
};
}
}

code: Code = {
basic: `<p-chart type="doughnut" [data]="data" [options]="options"></p-chart>`,
html: `
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/horizontalbardoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-horizontal-bar-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class HorizontalBarDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart()
}

initChart(){
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/linedoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-line-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class LineDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/linestyledoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-line-style-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class LineStyleDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
Loading

0 comments on commit d7f077c

Please sign in to comment.