Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/ngds-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitalspace/ngds-forms",
"version": "0.0.129",
"version": "0.0.130",
"peerDependencies": {
"@angular/common": "^16.0.0",
"@angular/core": "^16.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<div class="row d-flex">
<div class="d-flex justify-content-between">
<div>
<div class="col-auto" *ngIf="displayDepth < 1">
<button (click)="changeDepth.emit(1)" class="btn btn-outline-secondary border-0" [disabled]="disabled">
<div class="col-auto" *ngIf="depth < 1">
<button (click)="toggleDepth(1)" class="btn btn-outline-secondary border-0" [disabled]="disabled">
{{ calendarConfig?.value?.date?.monthLong}}
</button>
</div>
</div>
<div class="col-auto">
<button (click)="changeDepth.emit(2)" class="btn btn-outline-secondary border-0" [disabled]="disabled">
<div *ngIf="displayDepth === 2">{{ calendarConfig?.value?.years?.flat()[0] }} - {{
<button (click)="toggleDepth(2)" class="btn btn-outline-secondary border-0" [disabled]="disabled">
<div *ngIf="depth === 2">{{ calendarConfig?.value?.years?.flat()[0] }} - {{
calendarConfig?.value?.years?.flat()[calendarConfig?.value?.years?.flat().length-1]}}</div>
<div *ngIf="displayDepth !== 2">{{ calendarConfig?.value?.date?.year}}</div>
<div *ngIf="depth !== 2">{{ calendarConfig?.value?.date?.year}}</div>
</button>
</div>
<div class="d-flex row">
Expand All @@ -32,7 +32,7 @@
</div>
<!-- Body -->
<hr>
<div *ngIf="displayDepth === 0">
<div *ngIf="depth === 0">
<table class="text-center">
<thead class="fw-bold mb-1">
<tr>
Expand All @@ -56,21 +56,21 @@
</table>
</div>

<div *ngIf="displayDepth === 1">
<div *ngIf="depth === 1">
<div *ngFor="let row of months" class="d-flex">
<div *ngFor="let month of row" class="d-flex col-4 justify-content-center">
<button [disabled]="checkDisabledMonth(month)" [ngClass]="getMonthClasses(month)"
(click)="changeMonth.emit(month?.number)">
(click)="onMonthSelected(month?.number)">
{{month?.name}}
</button>
</div>
</div>
</div>

<div *ngIf="displayDepth === 2">
<div *ngIf="depth === 2">
<div *ngFor="let row of calendarConfig?.value?.years" class="d-flex">
<div *ngFor="let year of row" class="d-flex col-4 justify-content-center">
<button [disabled]="checkDisabledYear(year)" [ngClass]="getYearClasses(year)" (click)="changeYear.emit(year)">
<button [disabled]="checkDisabledYear(year)" [ngClass]="getYearClasses(year)" (click)="onYearSelected(year)">
{{year}}
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,33 @@ export class NgdsCalendar implements OnInit {
],
];

// Local view depth (0 = date, 1 = month, 2 = year). The calendar owns its own
// display state so the view updates from its own click handlers, rather than
// round-tripping the value out to the parent's @Input and back.
protected depth: number = 0;

ngOnInit(): void {
// set display to the minimum display depth.
this.displayDepth = this.minDisplayDepth;
this.depth = this.minDisplayDepth;
}

// Switch the header between date/month/year views.
toggleDepth(index: number): void {
this.depth = (this.depth === index || index < this.minDisplayDepth)
? this.minDisplayDepth
: index;
this.changeDepth.emit(index);
}

// Collapse back to the base view after picking a month, then notify the parent.
onMonthSelected(monthNumber: number): void {
this.depth = this.minDisplayDepth;
this.changeMonth.emit(monthNumber);
}

// Collapse back to the base view after picking a year, then notify the parent.
onYearSelected(year: number): void {
this.depth = this.minDisplayDepth;
this.changeYear.emit(year);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class NgdsDropdown extends NgdsInput implements AfterViewInit {
@Input() selectFirstItemOnEnter: boolean = true;

// Custom classes to apply to the dropdown element
@Input() dropdownClasses: string
@Input() dropdownClasses: string | string[]

// Whether to use dynamic positioning for the dropdown menu. If false, the dropdown will always be positioned statically below the input, which can prevent issues with certain parent elements that have overflow hidden or other positioning styles that interfere with Popper's ability to position the dropdown correctly.
@Input() dynamicPositioning: boolean = true;
Expand Down