<!--

    Copyright © 2016-2026 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.

-->
<ng-container [formGroup]="alarmsTableKeySettingsForm">
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.table.column-settings</div>
    <div class="tb-form-row">
      <div class="fixed-title-width">{{ 'widgets.table.custom-title' | translate }}</div>
      <mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
        <input matInput formControlName="customTitle" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.table.column-width' | translate }}</div>
      <mat-form-field appearance="outline" subscriptSizing="dynamic">
        <input matInput formControlName="columnWidth" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.table.default-column-visibility' | translate }}</div>
      <mat-form-field class="medium-width" appearance="outline" subscriptSizing="dynamic">
        <mat-select formControlName="defaultColumnVisibility">
          <mat-option [value]="'visible'">
            {{ 'widgets.table.column-visibility-visible' | translate }}
          </mat-option>
          <mat-option [value]="'hidden'">
            {{ 'widgets.table.column-visibility-hidden' | translate }}
          </mat-option>
          <mat-option [value]="'hidden-mobile'">
            {{ 'widgets.table.column-visibility-hidden-mobile' | translate }}
          </mat-option>
        </mat-select>
      </mat-form-field>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.table.column-selection-to-display' | translate }}</div>
      <mat-form-field class="medium-width" appearance="outline" subscriptSizing="dynamic">
        <mat-select formControlName="columnSelectionToDisplay">
          <mat-option [value]="'enabled'">
            {{ 'widgets.table.column-selection-to-display-enabled' | translate }}
          </mat-option>
          <mat-option [value]="'disabled'">
            {{ 'widgets.table.column-selection-to-display-disabled' | translate }}
          </mat-option>
        </mat-select>
      </mat-form-field>
    </div>
    <div class="tb-form-row">
      <mat-slide-toggle class="mat-slide"  formControlName="disableSorting">
        {{ 'widgets.table.disable-sorting' | translate }}
      </mat-slide-toggle>
    </div>
  </div>
  <div class="tb-form-panel tb-slide-toggle">
    <mat-expansion-panel class="tb-settings" [expanded]="alarmsTableKeySettingsForm.get('useCellStyleFunction').value">
      <mat-expansion-panel-header class="flex flex-row flex-wrap">
        <mat-panel-title>
          <mat-slide-toggle class="mat-slide flex items-stretch justify-center" formControlName="useCellStyleFunction" (click)="$event.stopPropagation()">
            {{ 'widgets.table.use-cell-style-function' | translate }}
          </mat-slide-toggle>
        </mat-panel-title>
        <mat-panel-description class="flex max-w-40% flex-full items-center justify-end xs:!hidden" translate>
          widget-config.advanced-settings
        </mat-panel-description>
      </mat-expansion-panel-header>
      <ng-template matExpansionPanelContent>
        <tb-js-func required
                    formControlName="cellStyleFunction"
                    withModules
                    [globalVariables]="functionScopeVariables"
                    [functionArgs]="['value', 'alarm', 'ctx']"
                    functionTitle="{{ 'widgets.table.cell-style-function' | translate }}"
                    helpId="widget/lib/alarm/cell_style_fn">
        </tb-js-func>
      </ng-template>
    </mat-expansion-panel>
  </div>
  <div class="tb-form-panel tb-slide-toggle">
    <mat-expansion-panel class="tb-settings" [expanded]="alarmsTableKeySettingsForm.get('useCellContentFunction').value">
      <mat-expansion-panel-header class="flex flex-row flex-wrap">
        <mat-panel-title>
          <mat-slide-toggle class="mat-slide flex items-stretch justify-center" formControlName="useCellContentFunction" (click)="$event.stopPropagation()">
            {{ 'widgets.table.use-cell-content-function' | translate }}
          </mat-slide-toggle>
        </mat-panel-title>
        <mat-panel-description class="flex max-w-40% flex-full items-center justify-end xs:!hidden" translate>
          widget-config.advanced-settings
        </mat-panel-description>
      </mat-expansion-panel-header>
      <ng-template matExpansionPanelContent>
        <tb-js-func required
                    formControlName="cellContentFunction"
                    withModules
                    [globalVariables]="functionScopeVariables"
                    [functionArgs]="['value', 'alarm', 'ctx']"
                    functionTitle="{{ 'widgets.table.cell-content-function' | translate }}"
                    helpId="widget/lib/alarm/cell_content_fn">
        </tb-js-func>
      </ng-template>
    </mat-expansion-panel>
  </div>
</ng-container>
