Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 1x 1x 32x 6x 26x 26x 26x 26x 25x 26x 26x 26x 26x 90x | /**
* Copyright (c) Siemens 2016 - 2025
* SPDX-License-Identifier: MIT
*/
import { ElementRef } from '@angular/core';
import { SiFormItemControl } from '../si-form-item.control';
/**
* This will be used by the `si-form-item` to create a form item control if none is provided.
* This is typically the case for native form controls like `input`, `textarea` and `select`.
* It allows accessing the control's id and type.
*/
export class SiFormFieldNativeControl implements SiFormItemControl {
private static idCounter = 0;
private static readonly supportedTypes = ['INPUT', 'TEXTAREA', 'SELECT', 'METER', 'PROGRESS'];
static createForElementRef(
element: ElementRef<HTMLElement> | undefined
): SiFormFieldNativeControl | undefined {
if (!element) {
return undefined;
}
Iif (!SiFormFieldNativeControl.supportedTypes.includes(element.nativeElement.tagName)) {
return undefined;
}
return new SiFormFieldNativeControl(element.nativeElement);
}
private constructor(private readonly element: HTMLElement) {
if (!element.id) {
element.id = `__si-form-field-native-control-${SiFormFieldNativeControl.idCounter++}`;
}
this.errormessageId = `${this.id}-errormessage`;
if (element instanceof HTMLInputElement) {
this.isFormCheck = element.type === 'checkbox' || element.type === 'radio';
} else E{
this.isFormCheck = false;
}
element.setAttribute('aria-describedby', this.errormessageId);
}
isFormCheck: boolean;
get id(): string {
return this.element?.id;
}
set id(value: string) {
this.element.id = value;
}
readonly errormessageId: string;
}
|