@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
80 lines (79 loc) • 3.43 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* 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]({% slug overview_checkbox %}) input component.
* The directive is placed on input type="radio" elements.
*
* @example
* ```ts-no-run
* <input type="radio" kendoRadioButton />
* ```
*/
export class RadioButtonDirective {
renderer;
hostElement;
kendoClass = true;
/**
* The size property specifies the width and height of the RadioButton
* ([see example]({% slug appearance_radiobuttondirective %}#toc-size)).
* The possible values are:
* * `small`
* * `medium` (default)
* * `large`
* * `none`
*/
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: "16.2.12", ngImport: i0, type: RadioButtonDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: RadioButtonDirective, isStandalone: true, selector: "input[kendoRadioButton]", inputs: { size: "size" }, host: { properties: { "class.k-radio": "this.kendoClass" } }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RadioButtonDirective, decorators: [{
type: Directive,
args: [{
selector: 'input[kendoRadioButton]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { kendoClass: [{
type: HostBinding,
args: ['class.k-radio']
}], size: [{
type: Input
}] } });