New Component: `RadioButtonGroup`

pull/6632/head
Mert Sincan 2024-10-21 00:35:26 +01:00
parent 59d01c2ade
commit ab652204eb
4 changed files with 62 additions and 37 deletions

View File

@ -83,7 +83,7 @@ export default {
return this.invalid ?? this.$pcForm?.states?.[this.$formName]?.invalid; return this.invalid ?? this.$pcForm?.states?.[this.$formName]?.invalid;
}, },
$formName() { $formName() {
return this.formControl?.name || this.name || this.$attrs.name; return this.formControl?.name || this.name;
}, },
// @deprecated use $filled instead // @deprecated use $filled instead
filled() { filled() {

View File

@ -68,7 +68,7 @@ export default {
}, },
computed: { computed: {
groupName() { groupName() {
return this.$pcRadioButtonGroup ? this.$pcRadioButtonGroup.groupName : this.name; return this.$pcRadioButtonGroup ? this.$pcRadioButtonGroup.groupName : this.$formName;
}, },
checked() { checked() {
const value = this.$pcRadioButtonGroup ? this.$pcRadioButtonGroup.d_value : this.d_value; const value = this.$pcRadioButtonGroup ? this.$pcRadioButtonGroup.d_value : this.d_value;

View File

@ -1,25 +1,23 @@
/** /**
* *
* FloatLabel visually integrates a label with its form element. * RadioButtonGroup is a component that groups multiple radio buttons, allowing users to select only one option from the group.
* *
* [Live Demo](https://www.primevue.org/floatlabel/) * [Live Demo](https://www.primevue.org/radiobutton/)
* *
* @module floatlabel * @module radiobuttongroup
* *
*/ */
import type { DefineComponent, DesignToken, EmitFn, PassThrough } from '@primevue/core'; import type { DefineComponent, DesignToken, EmitFn, PassThrough } from '@primevue/core';
import type { ComponentHooks } from '@primevue/core/basecomponent'; import type { ComponentHooks } from '@primevue/core/basecomponent';
import type { PassThroughOptions } from 'primevue/passthrough'; import type { PassThroughOptions } from 'primevue/passthrough';
import { TransitionProps, VNode } from 'vue'; import { VNode } from 'vue';
export declare type FloatLabelPassThroughOptionType = FloatLabelPassThroughAttributes | ((options: FloatLabelPassThroughMethodOptions) => FloatLabelPassThroughAttributes | string) | string | null | undefined; export declare type RadioButtonGroupPassThroughOptionType = RadioButtonGroupPassThroughAttributes | ((options: RadioButtonGroupPassThroughMethodOptions) => RadioButtonGroupPassThroughAttributes | string) | string | null | undefined;
export declare type FloatLabelPassThroughTransitionType = TransitionProps | ((options: FloatLabelPassThroughMethodOptions) => TransitionProps) | undefined;
/** /**
* Custom passthrough(pt) option method. * Custom passthrough(pt) option method.
*/ */
export interface FloatLabelPassThroughMethodOptions { export interface RadioButtonGroupPassThroughMethodOptions {
/** /**
* Defines instance. * Defines instance.
*/ */
@ -27,7 +25,7 @@ export interface FloatLabelPassThroughMethodOptions {
/** /**
* Defines valid properties. * Defines valid properties.
*/ */
props: FloatLabelProps; props: RadioButtonGroupProps;
/** /**
* Defines valid attributes. * Defines valid attributes.
*/ */
@ -44,13 +42,13 @@ export interface FloatLabelPassThroughMethodOptions {
/** /**
* Custom passthrough(pt) options. * Custom passthrough(pt) options.
* @see {@link FloatLabelProps.pt} * @see {@link RadioButtonGroupProps.pt}
*/ */
export interface FloatLabelPassThroughOptions { export interface RadioButtonGroupPassThroughOptions {
/** /**
* Used to pass attributes to the root's DOM element. * Used to pass attributes to the root's DOM element.
*/ */
root?: FloatLabelPassThroughOptionType; root?: RadioButtonGroupPassThroughOptionType;
/** /**
* Used to manage all lifecycle hooks. * Used to manage all lifecycle hooks.
* @see {@link BaseComponent.ComponentHooks} * @see {@link BaseComponent.ComponentHooks}
@ -61,23 +59,44 @@ export interface FloatLabelPassThroughOptions {
/** /**
* Custom passthrough attributes for each DOM elements * Custom passthrough attributes for each DOM elements
*/ */
export interface FloatLabelPassThroughAttributes { export interface RadioButtonGroupPassThroughAttributes {
[key: string]: any; [key: string]: any;
} }
/** /**
* Defines valid properties in FloatLabel component. * Defines valid properties in RadioButtonGroup component.
*/ */
export interface FloatLabelProps { export interface RadioButtonGroupProps {
/**
* Value binding of the radiobuttons.
*/
modelValue?: any;
/**
* Default values of the radiobuttons in uncontrolled mode.
*/
defaultValue?: any;
/**
* Name of the input elements.
*/
name?: string | undefined;
/**
* When present, it specifies that the component should have invalid state style.
* @defaultValue false
*/
invalid?: boolean | undefined;
/**
* Used to set form control options.
*/
formControl?: any;
/** /**
* It generates scoped CSS variables using design tokens for the component. * It generates scoped CSS variables using design tokens for the component.
*/ */
dt?: DesignToken<any>; dt?: DesignToken<any>;
/** /**
* Used to pass attributes to DOM elements inside the component. * Used to pass attributes to DOM elements inside the component.
* @type {FloatLabelPassThroughOptions} * @type {RadioButtonGroupPassThroughOptions}
*/ */
pt?: PassThrough<FloatLabelPassThroughOptions>; pt?: PassThrough<RadioButtonGroupPassThroughOptions>;
/** /**
* Used to configure passthrough(pt) options of the component. * Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions} * @type {PassThroughOptions}
@ -88,17 +107,12 @@ export interface FloatLabelProps {
* @defaultValue false * @defaultValue false
*/ */
unstyled?: boolean; unstyled?: boolean;
/**
* Defines the positioning of the label relative to the input.
* @defaultValue false
*/
variant?: 'over' | 'in' | 'on' | undefined;
} }
/** /**
* Defines valid slots in FloatLabel component. * Defines valid slots in RadioButtonGroup component.
*/ */
export interface FloatLabelSlots { export interface RadioButtonGroupSlots {
/** /**
* Default content slot. * Default content slot.
*/ */
@ -106,30 +120,41 @@ export interface FloatLabelSlots {
} }
/** /**
* Defines valid emits in FloatLabel component. * Defines valid emits in RadioButtonGroup component.
*/ */
export interface FloatLabelEmitsOptions {} export interface RadioButtonGroupEmitsOptions {
/**
* Emitted when the value changes.
* @param {*} value - New value.
*/
'update:modelValue'(value: any): void;
/**
* Emitted when the value changes in uncontrolled mode.
* @param {*} value - New value.
*/
'value-change'(value: any): void;
}
export declare type FloatLabelEmits = EmitFn<FloatLabelEmitsOptions>; export declare type RadioButtonGroupEmits = EmitFn<RadioButtonGroupEmitsOptions>;
/** /**
* **PrimeVue - FloatLabel** * **PrimeVue - RadioButtonGroup**
* *
* _FloatLabel visually integrates a label with its form element._ * _RadioButtonGroup is a component that groups multiple radio buttons, allowing users to select only one option from the group._
* *
* [Live Demo](https://www.primevue.org/inputtext/) * [Live Demo](https://www.primevue.org/radiobutton/)
* --- --- * --- ---
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png) * ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
* *
* @group Component * @group Component
* *
*/ */
declare const FloatLabel: DefineComponent<FloatLabelProps, FloatLabelSlots, FloatLabelEmits>; declare const RadioButtonGroup: DefineComponent<RadioButtonGroupProps, RadioButtonGroupSlots, RadioButtonGroupEmits>;
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
FloatLabel: DefineComponent<FloatLabelProps, FloatLabelSlots, FloatLabelEmits>; RadioButtonGroup: DefineComponent<RadioButtonGroupProps, RadioButtonGroupSlots, RadioButtonGroupEmits>;
} }
} }
export default FloatLabel; export default RadioButtonGroup;

View File

@ -1,8 +1,8 @@
/** /**
* *
* FloatLabel visually integrates a label with its form element. * RadioButtonGroup is a component that groups multiple radio buttons, allowing users to select only one option from the group.
* *
* [Live Demo](https://www.primevue.org/floatlabel/) * [Live Demo](https://www.primevue.org/radiobuttongroup/)
* *
* @module radiobuttongroupstyle * @module radiobuttongroupstyle
* *