UNPKG

@progress/kendo-angular-inputs

Version:

Kendo UI for Angular Inputs Package - Everything you need to build professional form functionality (Checkbox, ColorGradient, ColorPalette, ColorPicker, FlatColorPicker, FormField, MaskedTextBox, NumericTextBox, RadioButton, RangeSlider, Slider, Switch, Te

82 lines (81 loc) 3.57 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, ElementRef, HostBinding, Input, Renderer2 } from '@angular/core'; import { validatePackage } from '@progress/kendo-licensing'; import { getStylingClasses } from '../common/utils'; import { packageMetadata } from '../package-metadata'; import * as i0 from "@angular/core"; const DEFAULT_SIZE = 'medium'; /** * Represents the directive that renders the Kendo UI RadioButton input component. * Place the directive on `input type="radio"` HTML elements. * * @example * ```html * <input type="radio" kendoRadioButton /> * ``` */ export class RadioButtonDirective { renderer; hostElement; kendoClass = true; get isDisabled() { return this.hostElement.nativeElement.disabled; } /** * Specifies the `size` of the RadioButton. The `size` property changes the width and height of the RadioButton ([see example]({% slug appearance_radiobuttondirective %}#toc-size)). * * @default "medium" */ set size(size) { const newSize = size ? size : DEFAULT_SIZE; this.handleClasses(newSize, 'size'); this._size = newSize; } get size() { return this._size; } _size = 'medium'; constructor(renderer, hostElement) { this.renderer = renderer; this.hostElement = hostElement; validatePackage(packageMetadata); } ngAfterViewInit() { // kept in sync with other inputs for easier refactoring // to a common base class const stylingInputs = ['size']; stylingInputs.forEach(input => { this.handleClasses(this[input], input); }); } handleClasses(value, input) { const elem = this.hostElement.nativeElement; const classes = getStylingClasses('radio', input, this[input], value); if (classes.toRemove) { this.renderer.removeClass(elem, classes.toRemove); } if (classes.toAdd) { this.renderer.addClass(elem, classes.toAdd); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RadioButtonDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: RadioButtonDirective, isStandalone: true, selector: "input[kendoRadioButton]", inputs: { size: "size" }, host: { properties: { "class.k-radio": "this.kendoClass", "class.k-disabled": "this.isDisabled" } }, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RadioButtonDirective, decorators: [{ type: Directive, args: [{ selector: 'input[kendoRadioButton]', standalone: true }] }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }], propDecorators: { kendoClass: [{ type: HostBinding, args: ['class.k-radio'] }], isDisabled: [{ type: HostBinding, args: ['class.k-disabled'] }], size: [{ type: Input }] } });