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 60 61 62 63 64 65 66 67 68 69 | 93x 93x 93x 93x 5x 5x 5x 5x 1x 1x 1x 1x 93x | import { DatasourceFactory, IDatasource } from '@zeedhi/core';
import { Input } from '../zd-input/input';
import { InputFactory } from '../zd-input/input-factory';
import { IRadio } from './interfaces';
/**
* Base class for Radio component.
*/
export class Radio extends Input implements IRadio {
/**
* Field on datasource.data that will be used to set radio's color
*/
public dataColor = '';
/**
* Field on datasource.data that will be used to set radio's label
*/
public dataLabel = '';
/**
* Source of radio items
*/
public datasource?: IDatasource;
/**
* Field on datasource.data that will be used to set radio's value
*/
public dataValue = '';
/**
* Defines the radio list direction
*/
public vertical = true;
/* istanbul ignore next */
/**
* Create a new Radio.
* @param props Radio properties
*/
constructor(props: IRadio) {
super(props);
this.dataColor = this.getInitValue('dataColor', props.dataColor, this.dataColor);
this.dataLabel = this.getInitValue('dataLabel', props.dataLabel, this.dataLabel);
this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
this.vertical = this.getInitValue('vertical', props.vertical, this.vertical);
if (props.datasource && props.datasource.type === 'simple') {
this.dataValue = 'value';
this.dataLabel = this.dataValue;
}
this.datasource = this.getInitValue('datasource', props.datasource, this.datasource);
this.datasource = DatasourceFactory.factory(this.datasource);
this.createAccessors();
}
public onBeforeDestroy() {
super.onBeforeDestroy();
this.datasource!.destroy();
}
public onCreated(): void {
super.onCreated();
this.datasource!.initialize();
}
}
InputFactory.register('ZdRadio', Radio);
|