<!--
  Questo file fa parte di MyTown.
  MyTown è software libero: puoi ridistribuirlo e/o modificarlo secondo
  i termini della GNU Affero General Public License come pubblicata dalla
  Free Software Foundation, versione 3.
  Distribuito senza ALCUNA GARANZIA; vedi la GNU AGPL v3 per i dettagli.
  Copyright (C) Kondor Consulting & Services S.r.l.
  SPDX-License-Identifier: AGPL-3.0-or-later
-->
@if (ionicForm) {
  <form [formGroup]="ionicForm" novalidate class="ion-no-margin ion-no-padding" class="form-calendar">
    <!-- If the type is 'date' -->
    @if (type == 'date') {
      <ion-input
        class="calendar-date-input"
        placeholder="dd/mm/yyyy"
        aria-label="date"
        [(ngModel)]="data_in"
        (ionBlur)="setDataControll($event)"
        type="text"
        formControlName="data"
        [tabindex]="tabindex"
        [disabled]="ionicForm.get('data')?.disabled || false"
        (ionInput)="onInput($event)"
        (keydown)="onKeyDown($event)"
        #in_digit
      ></ion-input>
      <ion-popover #ord_date_popover trigger="'ord_trig_date_popover'{{ lst_uniqueId }}" size="auto">
        <ng-template>
          <ion-datetime max="2100-05-31T23:59:59" #ord_date_popover [value]="parseDateString(data_in) ? datePipe.transform(parseDateString(data_in), 'yyyy-MM-dd') : null" [presentation]="type" locale="it-IT" (ionBlur)="setData($event)"> </ion-datetime>
        </ng-template>
      </ion-popover>
      @if (!disabled) {
        <ion-icon class="calendar-date-icon" id="'ord_trig_date_popover'{{ lst_uniqueId }}" name="calendar-outline" slot="end"></ion-icon>
      }
    } @else if (type == 'time') {
      <ion-select [(ngModel)]="ore" (ionChange)="setOre($event)" interface="popover" alignment="center" placeholder="HH:mm" required formControlName="data">
        @for (h of list_hh_mm; track h) {
          <ion-select-option [value]="h">{{ h }}</ion-select-option>
        }
      </ion-select>
    }
  </form>
}
@if (filteredSuggestions.length > 0 && showSuggestions) {
  <ion-list class="suggestion-list">
    @for (suggestion of filteredSuggestions; track suggestion; let i = $index) {
      <ion-item
        (click)="selectSuggestion(suggestion)"
        [ngClass]="{ focused: i === focusedSuggestionIndex }"
        suggestion-item
        tabindex="0"
        (keydown)="onSuggestionKeyDown($event, suggestion)"
        (focus)="focusedSuggestionIndex = i"
        >
        {{ suggestion }}
      </ion-item>
    }
  </ion-list>
}
