Skip to content

Commit

Permalink
Merge branch 'v18' into modern-togglebutton
Browse files Browse the repository at this point in the history
  • Loading branch information
medbenmakhlouf authored Oct 20, 2024
2 parents fe57ee8 + 384122c commit 012459a
Show file tree
Hide file tree
Showing 679 changed files with 18,492 additions and 16,622 deletions.
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
"sourceMap": false
}
},
"defaultConfiguration": "production"
Expand Down
7,600 changes: 3,800 additions & 3,800 deletions api-generator/themedoc.json

Large diffs are not rendered by default.

61 changes: 35 additions & 26 deletions src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ export class AccordionHeader extends BaseComponent {
disabled = computed(() => this.pcAccordionPanel.disabled());

ariaControls = computed(() => `${this.pcAccordion.id()}_accordioncontent_${this.pcAccordionPanel.value()}`);
/**
* A template reference variable that represents the toggle icon in a UI component.
* @param {AccordionToggleIconTemplateContext} context - Context of the template
* @example
* ```html
* <ng-template #toggleicon let-active="active"> </ng-template>
* ```
* @see {@link AccordionToggleIconTemplateContext}
* @group Templates
*/
@ContentChild('toggleicon') toggleicon: TemplateRef<AccordionToggleIconTemplateContext> | undefined;
@ContentChildren(PrimeTemplate) templates!: QueryList<PrimeTemplate>;

@HostListener('click', ['$event']) onClick() {
this.changeActiveValue();
Expand Down Expand Up @@ -210,19 +222,6 @@ export class AccordionHeader extends BaseComponent {
break;
}
}
/**
* A template reference variable that represents the toggle icon in a UI component.
* @param {AccordionToggleIconTemplateContext} context - Context of the template
* @example
* ```html
* <ng-template #toggleicon let-active="active"> </ng-template>
* ```
* @see {@link AccordionToggleIconTemplateContext}
* @group Templates
*/
@ContentChild('toggleicon') toggleicon: TemplateRef<AccordionToggleIconTemplateContext> | undefined;

@ContentChildren(PrimeTemplate) templates!: QueryList<PrimeTemplate>;

ngAfterContentInit() {
this.templates.forEach((item) => {
Expand Down Expand Up @@ -391,13 +390,13 @@ export class AccordionContent extends BaseComponent {
[attr.id]="getTabHeaderActionId(id)"
[attr.aria-controls]="getTabContentId(id)"
>
@if (!hasHeaderFacet && !headerTemplate) {
@if (!headerTemplate) {
{{ header }}
} @else {
@if (headerTemplate) {
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
}
@if (hasHeaderFacet) {
@if (headerFacet) {
<ng-content select="p-header" />
}
}
Expand Down Expand Up @@ -584,12 +583,26 @@ export class AccordionTab extends BaseComponent implements AfterContentInit, OnD
return 'p-accordionheader-toggle-icon icon-start';
}
}

contentTemplate: TemplateRef<any> | undefined;

headerTemplate: TemplateRef<any> | undefined;

iconTemplate: TemplateRef<any> | undefined;
/**
* Content template for the content of the drawer.
* @group Templates
*/
@ContentChild('header') headerTemplate: TemplateRef<any> | undefined;
/**
* Header template for the header of the drawer.
* @group Templates
*/
@ContentChild('footer') footerTemplate: TemplateRef<any> | undefined;
/**
* Template for the header icon.
* @group Templates
*/
@ContentChild('icon') iconTemplate: TemplateRef<any> | undefined;
/**
* Content template for the footer of the drawer.
* @group Templates
*/
@ContentChild('content') contentTemplate: TemplateRef<any> | undefined;

loaded: boolean = false;

Expand Down Expand Up @@ -668,10 +681,6 @@ export class AccordionTab extends BaseComponent implements AfterContentInit, OnD
return index;
}

get hasHeaderFacet(): boolean {
return (this.headerFacet as QueryList<Header>) && (this.headerFacet as QueryList<Header>).length > 0;
}

onKeydown(event: KeyboardEvent) {
switch (event.code) {
case 'Enter':
Expand Down Expand Up @@ -1052,7 +1061,7 @@ export class Accordion extends BaseComponent implements BlockableUI, AfterConten
}

@NgModule({
imports: [Accordion, AccordionTab, AccordionPanel, AccordionHeader, AccordionContent],
imports: [Accordion, AccordionTab, SharedModule, AccordionPanel, AccordionHeader, AccordionContent],
exports: [Accordion, AccordionTab, SharedModule, AccordionPanel, AccordionHeader, AccordionContent],
})
export class AccordionModule {}
67 changes: 26 additions & 41 deletions src/app/components/animateonscroll/animateonscroll.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';
import {
AfterViewInit,
Directive,
ElementRef,
Input,
NgModule,
Renderer2,
OnInit,
Inject,
PLATFORM_ID,
booleanAttribute,
numberAttribute,
} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { AfterViewInit, booleanAttribute, Directive, Input, NgModule, numberAttribute, OnInit } from '@angular/core';
import { BaseComponent } from 'primeng/basecomponent';
import { DomHandler } from 'primeng/dom';

interface AnimateOnScrollOptions {
Expand All @@ -26,11 +15,12 @@ interface AnimateOnScrollOptions {
*/
@Directive({
selector: '[pAnimateOnScroll]',
standalone: true,
host: {
'[class.p-animateonscroll]': 'true',
},
})
export class AnimateOnScroll implements OnInit, AfterViewInit {
export class AnimateOnScroll extends BaseComponent implements OnInit, AfterViewInit {
/**
* Selector to define the CSS class for enter animation.
* @group Props
Expand Down Expand Up @@ -72,21 +62,15 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {

animationEndListener: VoidFunction | undefined;

constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
private host: ElementRef,
public el: ElementRef,
public renderer: Renderer2,
) {}

ngOnInit() {
super.ngOnInit();
if (isPlatformBrowser(this.platformId)) {
this.renderer.setStyle(this.host.nativeElement, 'opacity', this.enterClass ? '0' : '');
this.renderer.setStyle(this.el.nativeElement, 'opacity', this.enterClass ? '0' : '');
}
}

ngAfterViewInit() {
super.ngAfterViewInit();
if (isPlatformBrowser(this.platformId)) {
this.bindIntersectionObserver();
}
Expand All @@ -113,17 +97,17 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {
this.isObserverActive = true;
}, this.options);

setTimeout(() => this.observer.observe(this.host.nativeElement), 0);
setTimeout(() => this.observer.observe(this.el.nativeElement), 0);

// Reset

this.resetObserver = new IntersectionObserver(
([entry]) => {
if (entry.boundingClientRect.top > 0 && !entry.isIntersecting) {
this.host.nativeElement.style.opacity = this.enterClass ? '0' : '';
DomHandler.removeMultipleClasses(this.host.nativeElement, [this.enterClass, this.leaveClass]);
this.el.nativeElement.style.opacity = this.enterClass ? '0' : '';
DomHandler.removeMultipleClasses(this.el.nativeElement, [this.enterClass, this.leaveClass]);

this.resetObserver.unobserve(this.host.nativeElement);
this.resetObserver.unobserve(this.el.nativeElement);
}

this.animationState = undefined;
Expand All @@ -134,9 +118,9 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {

enter() {
if (this.animationState !== 'enter' && this.enterClass) {
this.host.nativeElement.style.opacity = '';
DomHandler.removeMultipleClasses(this.host.nativeElement, this.leaveClass);
DomHandler.addMultipleClasses(this.host.nativeElement, this.enterClass);
this.el.nativeElement.style.opacity = '';
DomHandler.removeMultipleClasses(this.el.nativeElement, this.leaveClass);
DomHandler.addMultipleClasses(this.el.nativeElement, this.enterClass);

this.once && this.unbindIntersectionObserver();

Expand All @@ -147,9 +131,9 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {

leave() {
if (this.animationState !== 'leave' && this.leaveClass) {
this.host.nativeElement.style.opacity = this.enterClass ? '0' : '';
DomHandler.removeMultipleClasses(this.host.nativeElement, this.enterClass);
DomHandler.addMultipleClasses(this.host.nativeElement, this.leaveClass);
this.el.nativeElement.style.opacity = this.enterClass ? '0' : '';
DomHandler.removeMultipleClasses(this.el.nativeElement, this.enterClass);
DomHandler.addMultipleClasses(this.el.nativeElement, this.leaveClass);

this.bindAnimationEvents();
this.animationState = 'leave';
Expand All @@ -158,9 +142,9 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {

bindAnimationEvents() {
if (!this.animationEndListener) {
this.animationEndListener = this.renderer.listen(this.host.nativeElement, 'animationend', () => {
DomHandler.removeMultipleClasses(this.host.nativeElement, [this.enterClass, this.leaveClass]);
!this.once && this.resetObserver.observe(this.host.nativeElement);
this.animationEndListener = this.renderer.listen(this.el.nativeElement, 'animationend', () => {
DomHandler.removeMultipleClasses(this.el.nativeElement, [this.enterClass, this.leaveClass]);
!this.once && this.resetObserver.observe(this.el.nativeElement);
this.unbindAnimationEvents();
});
}
Expand All @@ -174,20 +158,21 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {
}

unbindIntersectionObserver() {
this.observer?.unobserve(this.host.nativeElement);
this.resetObserver?.unobserve(this.host.nativeElement);
this.observer?.unobserve(this.el.nativeElement);
this.resetObserver?.unobserve(this.el.nativeElement);
this.isObserverActive = false;
}

ngOnDestroy() {
this.unbindAnimationEvents();
this.unbindIntersectionObserver();

super.ngOnDestroy();
}
}

@NgModule({
imports: [CommonModule],
imports: [AnimateOnScroll],
exports: [AnimateOnScroll],
declarations: [AnimateOnScroll],
})
export class AnimateOnScrollModule {}
Loading

0 comments on commit 012459a

Please sign in to comment.