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 Nov 21, 2023
2 parents 3e37533 + b6b2a4d commit 3003af5
Show file tree
Hide file tree
Showing 32 changed files with 1,374 additions and 1,202 deletions.
193 changes: 110 additions & 83 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1570,13 +1570,13 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
onOverlayAnimationStart(event: AnimationEvent) {
if (event.toState === 'visible') {
this.itemsWrapper = DomHandler.findSingle(this.overlayViewChild.overlayViewChild?.nativeElement, this.virtualScroll ? '.p-scroller' : '.p-autocomplete-panel');
if(this.virtualScroll) {

if (this.virtualScroll) {
this.scroller?.setContentEl(this.itemsViewChild?.nativeElement);
this.scroller.viewInit();
}
if(this.visibleOptions() && this.visibleOptions().length) {
if(this.virtualScroll) {
if (this.visibleOptions() && this.visibleOptions().length) {
if (this.virtualScroll) {
const selectedIndex = this.modelValue() ? this.focusedOptionIndex() : -1;

if (selectedIndex !== -1) {
Expand Down
14 changes: 7 additions & 7 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
this.updateModel(value, event);
this.focusedOptionIndex.set(this.findSelectedOptionIndex());
isHide && this.hide(true);
(preventChange === false) && this.onChange.emit({originalEvent: event, value: value});
preventChange === false && this.onChange.emit({ originalEvent: event, value: value });
}

onOptionMouseEnter(event, index) {
Expand All @@ -1072,14 +1072,14 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
this.resetFilter();
}
this.value = value;

this.allowModelChange() && this.onModelChange(value);
this.modelValue.set(this.value)
this.modelValue.set(this.value);
this.updateEditableLabel();
this.cd.markForCheck();
}

allowModelChange(){
allowModelChange() {
return this.autoDisplayFirst && !this.placeholder && !this.modelValue() && !this.editable && this.options && this.options.length;
}

Expand Down Expand Up @@ -1191,7 +1191,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV

this.onModelChange(value);
this.updateModel(value, event);
this.onChange.emit({originalEvent: event, value: value})
this.onChange.emit({ originalEvent: event, value: value });
}
/**
* Displays the panel.
Expand Down Expand Up @@ -1276,7 +1276,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV

onInputBlur(event: Event) {
this.focused = false;
(this.overlayVisible === false) && this.onBlur.emit(event);
this.overlayVisible === false && this.onBlur.emit(event);

if (!this.preventModelTouched) {
this.onModelTouched();
Expand Down Expand Up @@ -1719,7 +1719,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
clear(event: Event) {
this.updateModel(null, event);
this.updateEditableLabel();
this.onChange.emit({originalEvent: event, value: this.value})
this.onChange.emit({ originalEvent: event, value: this.value });
this.onClear.emit(event);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,18 +862,18 @@ export class Listbox implements AfterContentInit, OnInit, ControlValueAccessor,
}
DomHandler.focus(this.headerCheckboxViewChild.nativeElement);

if(this.selectAll !== null) {
if (this.selectAll !== null) {
this.onSelectAllChange.emit({
originalEvent: event,
checked: !this.allSelected()
})
});
} else {
const value = this.allSelected()
? []
: this.visibleOptions()
.filter((option) => this.isValidOption(option))
.map((option) => this.getOptionValue(option));

this.updateModel(value, event);
this.onChange.emit({ originalEvent: event, value: this.value });
}
Expand Down
22 changes: 11 additions & 11 deletions src/app/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
return ObjectUtils.isNotEmpty(this.maxSelectedLabels) && this.modelValue() && this.modelValue().length > this.maxSelectedLabels ? this.modelValue().slice(0, this.maxSelectedLabels) : this.modelValue();
});

constructor( public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public zone: NgZone, public filterService: FilterService, public config: PrimeNGConfig, public overlayService: OverlayService) {}
constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public zone: NgZone, public filterService: FilterService, public config: PrimeNGConfig, public overlayService: OverlayService) {}

ngOnInit() {
this.id = this.id || UniqueComponentId();
Expand Down Expand Up @@ -1242,7 +1242,7 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
index !== -1 && this.focusedOptionIndex.set(index);

isFocus && DomHandler.focus(this.focusInputViewChild?.nativeElement);

this.onChange.emit({
originalEvent: event,
value: value,
Expand Down Expand Up @@ -1677,7 +1677,7 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
}
this.focusInputViewChild?.nativeElement.focus({ preventScroll: true });
this.onClick.emit(event);
this.cd.detectChanges()
this.cd.detectChanges();
}

onFirstHiddenFocus(event) {
Expand Down Expand Up @@ -1767,19 +1767,19 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
return;
}

if(this.selectAll !== null) {
if (this.selectAll !== null) {
this.onSelectAllChange.emit({
originalEvent: event,
checked: !this.allSelected()
})
});
} else {
const value = this.allSelected()
? []
: this.visibleOptions()
.filter((option) => this.isValidOption(option))
.map((option) => this.getOptionValue(option));
this.updateModel(value, event)
? []
: this.visibleOptions()
.filter((option) => this.isValidOption(option))
.map((option) => this.getOptionValue(option));

this.updateModel(value, event);
}

DomHandler.focus(this.headerCheckboxViewChild.nativeElement);
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/orderlist/orderlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ export class OrderList implements AfterViewChecked, AfterContentInit {
}

onListFocus(event) {
const focusableEl = DomHandler.findSingle(this.listViewChild.nativeElement, '[data-p-highlight="true"]') || DomHandler.findSingle(this.listViewChild.nativeElement, '[data-pc-section="item"]')
const focusableEl = DomHandler.findSingle(this.listViewChild.nativeElement, '[data-p-highlight="true"]') || DomHandler.findSingle(this.listViewChild.nativeElement, '[data-pc-section="item"]');
if (focusableEl) {
const findIndex = ObjectUtils.findIndexInList(focusableEl, this.listViewChild.nativeElement.children);
this.focused = true;
Expand Down
73 changes: 41 additions & 32 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ export class TableService {
[pTableBodyTemplate]="bodyTemplate"
[scrollerOptions]="scrollerOptions"
></tbody>
<tbody role="rowgroup" *ngIf="scrollerOptions.spacerStyle" [style]="'height: calc(' + scrollerOptions.spacerStyle.height + ' - ' + scrollerOptions.rows.length * scrollerOptions.itemSize + 'px);'" class="p-datatable-scroller-spacer"></tbody>
<tbody
role="rowgroup"
*ngIf="scrollerOptions.spacerStyle"
[style]="'height: calc(' + scrollerOptions.spacerStyle.height + ' - ' + scrollerOptions.rows.length * scrollerOptions.itemSize + 'px);'"
class="p-datatable-scroller-spacer"
></tbody>
<tfoot role="rowgroup" *ngIf="footerGroupedTemplate || footerTemplate" #tfoot class="p-datatable-tfoot">
<ng-container *ngTemplateOutlet="footerGroupedTemplate || footerTemplate; context: { $implicit: scrollerOptions.columns }"></ng-container>
</tfoot>
Expand Down Expand Up @@ -1408,8 +1413,7 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable

dataToRender(data: any) {
const _data = data || this.processedData;



if (_data && this.paginator) {
const first = this.lazy ? 0 : this.first;
return _data.slice(first, <number>first + <number>this.rows);
Expand Down Expand Up @@ -1667,7 +1671,6 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable

this.preventSelectionSetterPropagation = true;
if (this.isMultipleSelectionMode() && event.originalEvent.shiftKey && this.anchorRowIndex != null) {

DomHandler.clearSelection();
if (this.rangeRowIndex != null) {
this.clearSelectionRange(event.originalEvent);
Expand Down Expand Up @@ -1869,7 +1872,7 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable
let rangeStart, rangeEnd;
let rangeRowIndex = <number>this.rangeRowIndex;
let anchorRowIndex = <number>this.anchorRowIndex;

if (rangeRowIndex > anchorRowIndex) {
rangeStart = this.anchorRowIndex;
rangeEnd = this.rangeRowIndex;
Expand Down Expand Up @@ -3485,7 +3488,7 @@ export class SortIcon implements OnInit, OnDestroy {
'[class.p-highlight]': 'selected',
'[attr.tabindex]': 'setRowTabIndex()',
'[attr.data-p-highlight]': 'selected',
'[attr.data-p-selectable-row]' : 'true'
'[attr.data-p-selectable-row]': 'true'
}
})
export class SelectableRow implements OnInit, OnDestroy {
Expand All @@ -3508,7 +3511,7 @@ export class SelectableRow implements OnInit, OnDestroy {
}

setRowTabIndex() {
if(this.dt.selectionMode === 'single' || this.dt.selectionMode === 'multiple') {
if (this.dt.selectionMode === 'single' || this.dt.selectionMode === 'multiple') {
return !this.dt.selection ? 0 : this.dt.anchorRowIndex === this.index ? 0 : -1;
}
}
Expand Down Expand Up @@ -3538,8 +3541,8 @@ export class SelectableRow implements OnInit, OnDestroy {
}

@HostListener('keydown', ['$event'])
onKeyDown(event:KeyboardEvent){
switch(event.code) {
onKeyDown(event: KeyboardEvent) {
switch (event.code) {
case 'ArrowDown':
this.onArrowDownKey(event);
break;
Expand All @@ -3559,21 +3562,20 @@ export class SelectableRow implements OnInit, OnDestroy {
case 'Space':
this.onSpaceKey(event);
break;

case 'Enter':
this.onEnterKey(event);
break;

default:
if(event.code === 'KeyA' && (event.metaKey || event.ctrlKey)){
if (event.code === 'KeyA' && (event.metaKey || event.ctrlKey)) {
const data = this.dt.dataToRender(this.dt.rows);
this.dt.selection = [...data];
this.dt.selectRange(event, data.length -1);
this.dt.selectRange(event, data.length - 1);

event.preventDefault();
}
break;

}
}

Expand Down Expand Up @@ -3618,12 +3620,12 @@ export class SelectableRow implements OnInit, OnDestroy {
rowIndex: this.index
});
}

onEndKey(event: KeyboardEvent) {
const lastRow = this.findLastSelectableRow();
lastRow && this.focusRowChange(this.el.nativeElement, lastRow)
lastRow && this.focusRowChange(this.el.nativeElement, lastRow);

if(event.ctrlKey && event.shiftKey) {
if (event.ctrlKey && event.shiftKey) {
const data = this.dt.dataToRender(this.dt.rows);
const lastSelectableRowIndex = DomHandler.getAttribute(lastRow, 'index');

Expand All @@ -3639,27 +3641,25 @@ export class SelectableRow implements OnInit, OnDestroy {

firstRow && this.focusRowChange(this.el.nativeElement, firstRow);

if(event.ctrlKey && event.shiftKey) {
if (event.ctrlKey && event.shiftKey) {
const data = this.dt.dataToRender(this.dt.rows);
const firstSelectableRowIndex = DomHandler.getAttribute(firstRow, 'index');

this.dt.anchorRowIndex = this.dt.anchorRowIndex || firstSelectableRowIndex;
this.dt.selection = data.slice(0, this.index + 1);
this.dt.selectRange(event, this.index)


this.dt.selectRange(event, this.index);
}
event.preventDefault();
}

onSpaceKey(event) {
this.onEnterKey(event);

if(event.shiftKey && this.dt.selection !== null) {
if (event.shiftKey && this.dt.selection !== null) {
const data = this.dt.dataToRender(this.dt.rows);
let index;
if(ObjectUtils.isNotEmpty(this.dt.selection) && this.dt.selection.length > 0) {

if (ObjectUtils.isNotEmpty(this.dt.selection) && this.dt.selection.length > 0) {
let firstSelectedRowIndex, lastSelectedRowIndex;
firstSelectedRowIndex = ObjectUtils.findIndexInList(this.dt.selection[0], data);
lastSelectedRowIndex = ObjectUtils.findIndexInList(this.dt.selection[this.dt.selection.length - 1], data);
Expand All @@ -3668,11 +3668,10 @@ export class SelectableRow implements OnInit, OnDestroy {
} else {
index = ObjectUtils.findIndexInList(this.dt.selection, data);
}

this.dt.anchorRowIndex = index;
this.dt.selection = index !== this.index ? data.slice(Math.min(index, this.index), Math.max(index, this.index) + 1) : [this.data];
this.dt.selectRange(event, this.index)

this.dt.selectRange(event, this.index);
}

event.preventDefault();
Expand All @@ -3687,7 +3686,7 @@ export class SelectableRow implements OnInit, OnDestroy {
findLastSelectableRow() {
const rows = DomHandler.find(this.dt.el.nativeElement, '.p-selectable-row');

return rows ? rows[rows.length -1] : null;
return rows ? rows[rows.length - 1] : null;
}

findFirstSelectableRow() {
Expand Down Expand Up @@ -4495,7 +4494,7 @@ export class CellEditor implements AfterContentInit {
template: `
<div class="p-radiobutton p-component" [ngClass]="{ 'p-radiobutton-focused': focused, 'p-radiobutton-checked': checked, 'p-radiobutton-disabled': disabled }" (click)="onClick($event)">
<div class="p-hidden-accessible">
<input #rb type="radio" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="disabled" [attr.aria-label]="ariaLabel" [tabindex]="disabled ? null : '0'"/>
<input #rb type="radio" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="disabled" [attr.aria-label]="ariaLabel" [tabindex]="disabled ? null : '0'" />
</div>
<div #box [ngClass]="{ 'p-radiobutton-box p-component': true, 'p-highlight': checked, 'p-focus': focused, 'p-disabled': disabled }">
<div class="p-radiobutton-icon"></div>
Expand Down Expand Up @@ -4576,7 +4575,18 @@ export class TableRadioButton {
template: `
<div class="p-checkbox p-component" [ngClass]="{ 'p-checkbox-focused': focused, 'p-checkbox-disabled': disabled }" (click)="onClick($event)">
<div class="p-hidden-accessible">
<input type="checkbox" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="disabled" [attr.required]="required" [attr.aria-label]="ariaLabel" [tabindex]="disabled ? null : '0'"/>
<input
type="checkbox"
[attr.id]="inputId"
[attr.name]="name"
[checked]="checked"
(focus)="onFocus()"
(blur)="onBlur()"
[disabled]="disabled"
[attr.required]="required"
[attr.aria-label]="ariaLabel"
[tabindex]="disabled ? null : '0'"
/>
</div>
<div #box [ngClass]="{ 'p-checkbox-box p-component': true, 'p-highlight': checked, 'p-focus': focused, 'p-disabled': disabled }">
<ng-container *ngIf="!dt.checkboxIconTemplate">
Expand Down Expand Up @@ -5260,7 +5270,6 @@ export class ColumnFilter implements AfterContentInit {

toggleMenu() {
this.overlayVisible = !this.overlayVisible;

}

onToggleButtonKeyDown(event: KeyboardEvent) {
Expand Down Expand Up @@ -5350,8 +5359,8 @@ export class ColumnFilter implements AfterContentInit {
}

focusOnFirstElement() {
if(this.overlay) {
DomHandler.focus(DomHandler.getFirstFocusableElement(this.overlay, ''))
if (this.overlay) {
DomHandler.focus(DomHandler.getFirstFocusableElement(this.overlay, ''));
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/app/components/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@ export class Tooltip implements AfterViewInit, OnDestroy {

onMouseLeave(e: MouseEvent) {
if (!this.isAutoHide()) {
const valid =
DomHandler.hasClass(e.relatedTarget, 'p-tooltip') ||
DomHandler.hasClass(e.relatedTarget, 'p-tooltip-text') ||
DomHandler.hasClass(e.relatedTarget, 'p-tooltip-arrow');
const valid = DomHandler.hasClass(e.relatedTarget, 'p-tooltip') || DomHandler.hasClass(e.relatedTarget, 'p-tooltip-text') || DomHandler.hasClass(e.relatedTarget, 'p-tooltip-arrow');
!valid && this.deactivate();
} else {
this.deactivate();
Expand Down
Loading

1 comment on commit 3003af5

@vercel
Copy link

@vercel vercel bot commented on 3003af5 Nov 21, 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.