Skip to content

Commit

Permalink
Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Nov 1, 2023
1 parent 6305342 commit 143c9b0
Show file tree
Hide file tree
Showing 32 changed files with 1,705 additions and 1,720 deletions.
35 changes: 19 additions & 16 deletions src/app/components/animateonscroll/animateonscroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {
* Specifies the root option of the IntersectionObserver API.
* @group Props
*/
@Input() root: HTMLElement | undefined | null;
@Input() root: HTMLElement | undefined | null;
/**
* Specifies the rootMargin option of the IntersectionObserver API.
* @group Props
Expand Down Expand Up @@ -63,13 +63,13 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {
constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, private host: ElementRef, public el: ElementRef, public renderer: Renderer2) {}

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

ngAfterViewInit() {
if(isPlatformBrowser(this.platformId)){
if (isPlatformBrowser(this.platformId)) {
this.bindIntersectionObserver();
}
}
Expand All @@ -79,16 +79,16 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {
root: this.root,
rootMargin: this.rootMargin,
threshold: this.threshold
}
};
}

bindIntersectionObserver() {
this.observer = new IntersectionObserver(([entry]) => {
if(this.isObserverActive) {
if(entry.boundingClientRect.top > 0) {
if (this.isObserverActive) {
if (entry.boundingClientRect.top > 0) {
entry.isIntersecting ? this.enter() : this.leave();
}
} else if(entry.isIntersecting) {
} else if (entry.isIntersecting) {
this.enter();
}

Expand All @@ -99,16 +99,19 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {

// 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.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.resetObserver.unobserve(this.host.nativeElement);
}
this.resetObserver.unobserve(this.host.nativeElement);
}

this.animationState = undefined;
}, {...this.options, threshold: 0})
this.animationState = undefined;
},
{ ...this.options, threshold: 0 }
);
}

enter() {
Expand Down Expand Up @@ -141,7 +144,7 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {
DomHandler.removeMultipleClasses(this.host.nativeElement, [this.enterClass, this.leaveClass]);
!this.once && this.resetObserver.observe(this.host.nativeElement);
this.unbindAnimationEvents();
})
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
}

getOptionLabel(option: any) {
return this.field || this.optionLabel ? ObjectUtils.resolveFieldData(option, this.field || this.optionLabel) : option && option.label != undefined ? option.label : option;
return this.field || this.optionLabel ? ObjectUtils.resolveFieldData(option, this.field || this.optionLabel) : option && option.label != undefined ? option.label : option;
}

getOptionValue(option) {
Expand Down
46 changes: 19 additions & 27 deletions src/app/components/cascadeselect/cascadeselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,18 @@ export const CASCADESELECT_VALUE_ACCESSOR: any = {
template: `
<ul class="p-cascadeselect-panel p-cascadeselect-items" [ngClass]="{ 'p-cascadeselect-panel-root': root }" [attr.role]="role" aria-orientation="horizontal" [attr.data-pc-section]="level === 0 ? 'list' : 'sublist'">
<ng-template ngFor let-processedOption [ngForOf]="options" let-i="index">
<li
[ngClass]="getItemClass(processedOption)"
role="treeitem"
[attr.aria-level]="level + 1"
[attr.aria-setsize]="options.length"
<li
[ngClass]="getItemClass(processedOption)"
role="treeitem"
[attr.aria-level]="level + 1"
[attr.aria-setsize]="options.length"
[attr.data-pc-section]="'item'"
[id]="getOptionId(processedOption)"
[attr.aria-label]="getOptionLabelToRender(processedOption)"
[attr.aria-selected]="isOptionGroup(processedOption) ? undefined : isOptionSelected(processedOption)"
[attr.aria-posinset]="i + 1"
>
<div
class="p-cascadeselect-item-content"
(click)="onOptionClick($event, processedOption)"
[attr.tabindex]="0"
pRipple
[attr.data-pc-section]="'content'"
>
<div class="p-cascadeselect-item-content" (click)="onOptionClick($event, processedOption)" [attr.tabindex]="0" pRipple [attr.data-pc-section]="'content'">
<ng-container *ngIf="optionTemplate; else defaultOptionTemplate">
<ng-container *ngTemplateOutlet="optionTemplate; context: { $implicit: processedOption.option }"></ng-container>
</ng-container>
Expand Down Expand Up @@ -100,13 +94,12 @@ export const CASCADESELECT_VALUE_ACCESSOR: any = {
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CascadeSelectSub implements OnInit {

@Input() role: string | undefined;

@Input() selectId: string | undefined;

@Input() activeOptionPath: any[];

@Input() optionDisabled: any[];

@Input() focusedOptionId: string | undefined;
Expand Down Expand Up @@ -146,7 +139,7 @@ export class CascadeSelectSub implements OnInit {
originalEvent: event,
value: option,
isFocus: true
})
});
}

onOptionChange(event) {
Expand All @@ -156,11 +149,11 @@ export class CascadeSelectSub implements OnInit {
getOptionId(processedOption) {
return `${this.selectId}_${processedOption.key}`;
}

getOptionLabel(processedOption) {
return this.optionLabel ? ObjectUtils.resolveFieldData(processedOption.option, this.optionLabel) : processedOption.option;
}

getOptionValue(processedOption) {
return this.optionValue ? ObjectUtils.resolveFieldData(processedOption.option, this.optionValue) : processedOption.option;
}
Expand All @@ -172,31 +165,31 @@ export class CascadeSelectSub implements OnInit {
isOptionDisabled(processedOption) {
return this.optionDisabled ? ObjectUtils.resolveFieldData(processedOption.option, this.optionDisabled) : false;
}

getOptionGroupLabel(processedOption) {
return this.optionGroupLabel ? ObjectUtils.resolveFieldData(processedOption.option, this.optionGroupLabel) : null;
}

getOptionGroupChildren(processedOption) {
return processedOption.children;
}

isOptionGroup(processedOption) {
return ObjectUtils.isNotEmpty(processedOption.children);
}

isOptionSelected(processedOption) {
return !this.isOptionGroup(processedOption) && this.isOptionActive(processedOption);
}

isOptionActive(processedOption) {
return this.activeOptionPath.some((path) => path.key === processedOption.key);
}

isOptionFocused(processedOption) {
return this.focusedOptionId === this.getOptionId(processedOption);
}

getItemClass(option: string | string[]) {
return {
'p-cascadeselect-item': true,
Expand Down Expand Up @@ -1327,4 +1320,3 @@ export class CascadeSelect implements OnInit, AfterContentInit {
declarations: [CascadeSelect, CascadeSelectSub]
})
export class CascadeSelectModule {}

4 changes: 2 additions & 2 deletions src/app/components/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ export class ContextMenu implements OnInit, AfterContentInit, OnDestroy {
}
}

removeAppendedElements(){
if (this.appendTo) {
removeAppendedElements() {
if (this.appendTo) {
if (this.appendTo === 'body') this.renderer.removeChild(this.document.body, this.containerViewChild.nativeElement);
else DomHandler.removeChild(this.containerViewChild.nativeElement, this.appendTo);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/password/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,13 @@ export class Password implements AfterContentInit, OnInit {
let value = (event.target as HTMLInputElement).value;
this.updateUI(value);

if(event.code === 'Escape') {
if (event.code === 'Escape') {
this.overlayVisible && (this.overlayVisible = false);

return;
}

if(!this.overlayVisible) {
if (!this.overlayVisible) {
this.overlayVisible = true;
}
}
Expand Down
36 changes: 29 additions & 7 deletions src/app/components/rating/rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,39 @@ export const RATING_VALUE_ACCESSOR: any = {
template: `
<div class="p-rating" [ngClass]="{ 'p-readonly': readonly, 'p-disabled': disabled }" [attr.data-pc-name]="'rating'" [attr.data-pc-section]="'root'">
<ng-container *ngIf="!isCustomIcon; else customTemplate">
<div *ngIf="cancel" [attr.data-pc-section]="'cancelItem'" (click)="onOptionClick($event, 0)" [ngClass]="{'p-focus': focusedOptionIndex() === 0 && isFocusVisible}" class="p-rating-item p-rating-cancel-item">
<div *ngIf="cancel" [attr.data-pc-section]="'cancelItem'" (click)="onOptionClick($event, 0)" [ngClass]="{ 'p-focus': focusedOptionIndex() === 0 && isFocusVisible }" class="p-rating-item p-rating-cancel-item">
<span class="p-hidden-accessible" [attr.data-p-hidden-accessible]="true">
<input type="radio" value="0" [name]="name" [checked]="value === 0" [disabled]="disabled" [readonly]="readonly" [attr.aria-label]="cancelAriaLabel()" (focus)="onInputFocus($event, 0)" (blur)="onInputBlur($event)" (change)="onChange($event, 0)"/>
<input
type="radio"
value="0"
[name]="name"
[checked]="value === 0"
[disabled]="disabled"
[readonly]="readonly"
[attr.aria-label]="cancelAriaLabel()"
(focus)="onInputFocus($event, 0)"
(blur)="onInputBlur($event)"
(change)="onChange($event, 0)"
/>
</span>
<span *ngIf="iconCancelClass" class="p-rating-icon p-rating-cancel" [ngClass]="iconCancelClass" [ngStyle]="iconCancelStyle"></span>
<BanIcon *ngIf="!iconCancelClass" [styleClass]="'p-rating-icon p-rating-cancel'" [ngStyle]="iconCancelStyle" [attr.data-pc-section]="'cancelIcon'" />
</div>
<ng-template ngFor [ngForOf]="starsArray" let-star let-i="index">
<div class="p-rating-item" [ngClass]="{ 'p-rating-item-active': star + 1 <= value, 'p-focus': star + 1 === focusedOptionIndex() && isFocusVisible }" (click)="onOptionClick($event, star + 1)">
<span class="p-hidden-accessible" [attr.data-p-hidden-accessible]="true">
<input type="radio" value="0" [name]="name" [checked]="value === 0" [disabled]="disabled" [readonly]="readonly" [attr.aria-label]="starAriaLabel(star + 1)" (focus)="onInputFocus($event, star + 1)" (blur)="onInputBlur($event)" (change)="onChange($event, star + 1)"/>
<input
type="radio"
value="0"
[name]="name"
[checked]="value === 0"
[disabled]="disabled"
[readonly]="readonly"
[attr.aria-label]="starAriaLabel(star + 1)"
(focus)="onInputFocus($event, star + 1)"
(blur)="onInputBlur($event)"
(change)="onChange($event, star + 1)"
/>
</span>
<ng-container *ngIf="!value || i >= value">
<span class="p-rating-icon" *ngIf="iconOffClass" [ngStyle]="iconOffStyle" [ngClass]="iconOffClass" [attr.data-pc-section]="'offIcon'"></span>
Expand Down Expand Up @@ -192,12 +214,12 @@ export class Rating implements OnInit, ControlValueAccessor {
}

onOptionClick(event, value) {
if(!this.readonly && !this.disabled) {
if (!this.readonly && !this.disabled) {
this.onOptionSelect(event, value);
this.isFocusVisibleItem = false;
const firstFocusableEl = DomHandler.getFirstFocusableElement(event.currentTarget, '');

firstFocusableEl && DomHandler.focus(firstFocusableEl)
firstFocusableEl && DomHandler.focus(firstFocusableEl);
}
}

Expand All @@ -207,7 +229,7 @@ export class Rating implements OnInit, ControlValueAccessor {
}

onChange(event, value) {
this.onOptionSelect(event,value);
this.onOptionSelect(event, value);
this.isFocusVisibleItem = true;
}

Expand All @@ -226,7 +248,7 @@ export class Rating implements OnInit, ControlValueAccessor {
this.onModelChange(this.value);
this.onModelTouched();

if(!value) {
if (!value) {
this.onCancel.emit();
} else {
this.onRate.emit({
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/selectbutton/selectbutton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class SelectButton implements ControlValueAccessor {
originalEvent: event,
value: this.value
});

this.onOptionClick.emit({
originalEvent: event,
option: option,
Expand Down
22 changes: 8 additions & 14 deletions src/app/showcase/doc/animateonscroll/accessibilitydoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@ import { Component, Input } from '@angular/core';

@Component({
selector: 'accessibility-doc',
template: `
<div>
<app-docsectiontext [title]="title" [id]="id">
<h3>Screen Reader</h3>
<p>
AnimateOnScroll does not require any roles and attributes.
</p>
<h3>Keyboard Support</h3>
<p>
Component does not include any interactive elements.
</p>
</app-docsectiontext>
</div>`
template: ` <div>
<app-docsectiontext [title]="title" [id]="id">
<h3>Screen Reader</h3>
<p>AnimateOnScroll does not require any roles and attributes.</p>
<h3>Keyboard Support</h3>
<p>Component does not include any interactive elements.</p>
</app-docsectiontext>
</div>`
})
export class AccessibilityDoc {
@Input() id: string;

@Input() title: string;

}
Loading

1 comment on commit 143c9b0

@vercel
Copy link

@vercel vercel bot commented on 143c9b0 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.