<!--

    Copyright © 2016-2023 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div *ngIf="panelTitle" class="tb-form-panel-title">{{ panelTitle }}</div>
<div class="tb-color-ranges"  [formGroup]="colorRangeListFormGroup">
  <div class="tb-form-row no-padding no-border" [formGroup]="rangeFormGroup" *ngFor="let rangeFormGroup of rangeListFormGroups; trackBy: trackByRange; let $index = index;">
    <div fxFlex fxLayout="row" fxLayoutGap="24px">
      <div fxFlex fxLayout="row" fxLayoutGap="12px" fxLayoutAlign="start center">
        <div class="tb-value-range-text" translate>widgets.color.from</div>
        <mat-form-field fxFlex appearance="outline" class="center number" subscriptSizing="dynamic">
          <input matInput type="number" formControlName="from" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <div class="tb-value-range-text tb-value-range-text-to" translate>widgets.color.to</div>
        <mat-form-field fxFlex appearance="outline" class="center number" subscriptSizing="dynamic">
          <input matInput type="number" formControlName="to" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-color-input asBoxInput
                        formControlName="color">
        </tb-color-input>
      </div>
      <button type="button"
              mat-icon-button
              class="tb-box-button"
              (click)="removeRange($index)"
              matTooltip="{{ 'action.remove' | translate }}"
              matTooltipPosition="above">
        <mat-icon>delete</mat-icon>
      </button>
    </div>
  </div>
</div>
<button class="tb-add-color-range"
        mat-stroked-button
        (click)="addRange()">
  <mat-icon>add</mat-icon>
</button>
