Refactor #3922 - For RadioButton
parent
26cbc4dc4c
commit
7000136a6a
|
@ -58,6 +58,12 @@ const RadioButtonProps = [
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'null',
|
default: 'null',
|
||||||
description: 'Used to define a string that labels the element.'
|
description: 'Used to define a string that labels the element.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pt',
|
||||||
|
type: 'any',
|
||||||
|
default: 'null',
|
||||||
|
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ import { PanelMenuPassThroughOptions } from '../panelmenu';
|
||||||
import { PasswordPassThroughOptions } from '../password';
|
import { PasswordPassThroughOptions } from '../password';
|
||||||
import { ProgressBarPassThroughOptions } from '../progressbar';
|
import { ProgressBarPassThroughOptions } from '../progressbar';
|
||||||
import { ProgressSpinnerPassThroughOptions } from '../progressspinner';
|
import { ProgressSpinnerPassThroughOptions } from '../progressspinner';
|
||||||
|
import { RadioButtonPassThroughOptions } from '../radiobutton';
|
||||||
import { ScrollPanelPassThroughOptions } from '../scrollpanel';
|
import { ScrollPanelPassThroughOptions } from '../scrollpanel';
|
||||||
import { ScrollTopPassThroughOptions } from '../scrolltop';
|
import { ScrollTopPassThroughOptions } from '../scrolltop';
|
||||||
import { SidebarPassThroughOptions } from '../sidebar';
|
import { SidebarPassThroughOptions } from '../sidebar';
|
||||||
|
@ -126,6 +127,7 @@ interface PrimeVuePTOptions {
|
||||||
password?: PasswordPassThroughOptions;
|
password?: PasswordPassThroughOptions;
|
||||||
progressbar?: ProgressBarPassThroughOptions;
|
progressbar?: ProgressBarPassThroughOptions;
|
||||||
progressspinner?: ProgressSpinnerPassThroughOptions;
|
progressspinner?: ProgressSpinnerPassThroughOptions;
|
||||||
|
radiobutton?: RadioButtonPassThroughOptions;
|
||||||
scrollpanel?: ScrollPanelPassThroughOptions;
|
scrollpanel?: ScrollPanelPassThroughOptions;
|
||||||
scrolltop?: ScrollTopPassThroughOptions;
|
scrolltop?: ScrollTopPassThroughOptions;
|
||||||
sidebar?: SidebarPassThroughOptions;
|
sidebar?: SidebarPassThroughOptions;
|
||||||
|
|
|
@ -10,6 +10,61 @@
|
||||||
import { InputHTMLAttributes } from 'vue';
|
import { InputHTMLAttributes } from 'vue';
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
|
export declare type RadioButtonPassThroughOptionType = RadioButtonPassThroughAttributes | ((options: RadioButtonPassThroughMethodOptions) => RadioButtonPassThroughAttributes) | null | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface RadioButtonPassThroughMethodOptions {
|
||||||
|
props: RadioButtonProps;
|
||||||
|
state: RadioButtonState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) options.
|
||||||
|
* @see {@link RadioButtonProps.pt}
|
||||||
|
*/
|
||||||
|
export interface RadioButtonPassThroughOptions {
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the root's DOM element.
|
||||||
|
*/
|
||||||
|
root?: RadioButtonPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the input's DOM element.
|
||||||
|
*/
|
||||||
|
input?: RadioButtonPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the icon's DOM element.
|
||||||
|
*/
|
||||||
|
icon?: RadioButtonPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the hidden accessible DOM element wrapper.
|
||||||
|
*/
|
||||||
|
hiddenInputWrapper?: RadioButtonPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the hidden accessible DOM element.
|
||||||
|
*/
|
||||||
|
hiddenInput?: RadioButtonPassThroughOptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough attributes for each DOM elements
|
||||||
|
*/
|
||||||
|
export interface RadioButtonPassThroughAttributes {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines current inline state in RadioButton component.
|
||||||
|
*/
|
||||||
|
export interface RadioButtonState {
|
||||||
|
/**
|
||||||
|
* Current focused state as a boolean.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
focused: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines valid properties in RadioButton component.
|
* Defines valid properties in RadioButton component.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="containerClass" @click="onClick($event)">
|
<div :class="containerClass" @click="onClick($event)" v-bind="ptm('root')">
|
||||||
<div class="p-hidden-accessible">
|
<div class="p-hidden-accessible" v-bind="ptm('hiddenInputWrapper')">
|
||||||
<input
|
<input
|
||||||
ref="input"
|
ref="input"
|
||||||
:id="inputId"
|
:id="inputId"
|
||||||
|
@ -15,20 +15,22 @@
|
||||||
:aria-label="ariaLabel"
|
:aria-label="ariaLabel"
|
||||||
@focus="onFocus"
|
@focus="onFocus"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
v-bind="inputProps"
|
v-bind="ptm('hiddenInput')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div ref="box" :class="['p-radiobutton-box', { 'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused }]">
|
<div ref="box" :class="['p-radiobutton-box', { 'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused }]" v-bind="{ ...inputProps, ...ptm('input') }">
|
||||||
<div class="p-radiobutton-icon"></div>
|
<div class="p-radiobutton-icon" v-bind="ptm('icon')"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import { ObjectUtils } from 'primevue/utils';
|
import { ObjectUtils } from 'primevue/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RadioButton',
|
name: 'RadioButton',
|
||||||
|
extends: BaseComponent,
|
||||||
emits: ['click', 'update:modelValue', 'change', 'focus', 'blur'],
|
emits: ['click', 'update:modelValue', 'change', 'focus', 'blur'],
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
value: null,
|
||||||
|
|
Loading…
Reference in New Issue