import Vue, { CreateElement, VNode } from 'vue'; import { Component, Emit, Inject, Model, Prop, Provide, Watch, } from 'vue-property-decorator'; import { ClassName, Theme, ThemeComponent, FlexDirection } from '../../base'; import { mixinFormComponent, FormComponent } from '../_base'; import { VdForm } from '../form/form'; export interface RadioData { label: string; value: boolean | string | number; } /** * Component: Radio */ @Component({ mixins: [mixinFormComponent], }) export class VdRadio extends Vue implements ThemeComponent, FormComponent { public readonly form?: VdForm; @Prop({ type: String }) public readonly theme?: Theme; public get themeValue(): Theme { return this.theme || (this.form && this.form.themeValue) || this.$vd_theme.theme; } @Prop({ type: String }) public readonly id?: string; @Prop({ type: String }) public readonly name?: string; @Model('change', { type: [Boolean, String, Number], required: true }) public readonly modelSource!: boolean | string | number; @Prop({ type: [Boolean, String, Number], required: true }) public readonly value!: boolean | string | number; @Prop({ type: String }) public readonly label?: string; @Prop({ type: Boolean, default: false }) public readonly disabled!: boolean; public get checked(): boolean { return this.value === this.modelSource; } private onChange(event: Event): void { this.$emit('change', this.value); } public get classes(): ClassName { return [ `vdp-theme_${this.themeValue}`, { 'is-checked': this.checked, }, ]; } private render(h: CreateElement): VNode { // tslint:disable:react-a11y-role-has-required-aria-props return ( ); } } /** * Component: RadioGroup */ @Component export class VdRadioGroup extends Vue implements FormComponent { @Model('change', { type: [String, Number], required: true }) public readonly modelSource!: string | number; @Prop({ type: Array, required: true }) public readonly itemsSource!: RadioData[]; @Prop({ type: String }) public readonly direction?: FlexDirection; public get classes(): ClassName { return [ { [`vdp-direction_${this.direction}`]: this.direction, }, ]; } private onChange(value: string | number): void { this.$emit('change', value); } private render(h: CreateElement): VNode { return (