From 8018dbb0d6f53c11a4c8f39ad89ff67b7a75bc2a Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Thu, 21 Mar 2024 16:21:57 +0300 Subject: [PATCH] Refactor #5437 - For ToggleButton --- .../lib/togglebutton/BaseToggleButton.vue | 12 ------- components/lib/togglebutton/ToggleButton.d.ts | 31 ++--------------- components/lib/togglebutton/ToggleButton.vue | 34 ++----------------- .../togglebutton/style/ToggleButtonStyle.js | 16 +++------ 4 files changed, 10 insertions(+), 83 deletions(-) diff --git a/components/lib/togglebutton/BaseToggleButton.vue b/components/lib/togglebutton/BaseToggleButton.vue index 742ef22db4..1a7a5f72f0 100644 --- a/components/lib/togglebutton/BaseToggleButton.vue +++ b/components/lib/togglebutton/BaseToggleButton.vue @@ -37,18 +37,6 @@ export default { type: Number, default: null }, - inputId: { - type: String, - default: null - }, - inputClass: { - type: [String, Object], - default: null - }, - inputStyle: { - type: Object, - default: null - }, ariaLabelledby: { type: String, default: null diff --git a/components/lib/togglebutton/ToggleButton.d.ts b/components/lib/togglebutton/ToggleButton.d.ts index 3a0139f24b..c62525fe44 100755 --- a/components/lib/togglebutton/ToggleButton.d.ts +++ b/components/lib/togglebutton/ToggleButton.d.ts @@ -26,10 +26,6 @@ export interface ToggleButtonPassThroughMethodOptions { * Defines valid properties. */ props: ToggleButtonProps; - /** - * Defines current inline state. - */ - state: ToggleButtonState; /** * Defines current options. */ @@ -58,13 +54,9 @@ export interface ToggleButtonPassThroughOptions { */ root?: ToggleButtonPassThroughOptionType; /** - * Used to pass attributes to the input's DOM element. - */ - input?: ToggleButtonPassThroughOptionType; - /** - * Used to pass attributes to the box's DOM element. + * Used to pass attributes to the button's DOM element. */ - box?: ToggleButtonPassThroughOptionType; + button?: ToggleButtonPassThroughOptionType; /** * Used to pass attributes to the icon's DOM element. */ @@ -87,13 +79,6 @@ export interface ToggleButtonPassThroughAttributes { [key: string]: any; } -/** - * Defines current inline state in ToggleButton component. - */ -export interface ToggleButtonState { - [key: string]: any; -} - /** * Defines current options in ToggleButton component. */ @@ -163,18 +148,6 @@ export interface ToggleButtonProps { * Index of the element in tabbing order. */ tabindex?: string | undefined; - /** - * Identifier of the focus input to match a label defined for the chips. - */ - inputId?: string | undefined; - /** - * Style class of the input field. - */ - inputClass?: string | object | undefined; - /** - * Inline style of the input field. - */ - inputStyle?: object | undefined; /** * Establishes relationships between the component and label(s) where its value should be one or more element IDs. */ diff --git a/components/lib/togglebutton/ToggleButton.vue b/components/lib/togglebutton/ToggleButton.vue index 944f152600..cb492b9de9 100755 --- a/components/lib/togglebutton/ToggleButton.vue +++ b/components/lib/togglebutton/ToggleButton.vue @@ -1,30 +1,11 @@ @@ -37,7 +18,7 @@ export default { name: 'ToggleButton', extends: BaseToggleButton, inheritAttrs: false, - emits: ['update:modelValue', 'change', 'focus', 'blur'], + emits: ['update:modelValue', 'change'], methods: { getPTOptions(key) { const _ptm = key === 'root' ? this.ptmi : this.ptm; @@ -54,12 +35,6 @@ export default { this.$emit('update:modelValue', !this.modelValue); this.$emit('change', event); } - }, - onFocus(event) { - this.$emit('focus', event); - }, - onBlur(event) { - this.$emit('blur', event); } }, computed: { @@ -69,9 +44,6 @@ export default { hasLabel() { return ObjectUtils.isNotEmpty(this.onLabel) && ObjectUtils.isNotEmpty(this.offLabel); }, - hasIcon() { - return this.$slots.icon || (this.onIcon && this.offIcon); - }, label() { return this.hasLabel ? (this.modelValue ? this.onLabel : this.offLabel) : ' '; } diff --git a/components/lib/togglebutton/style/ToggleButtonStyle.js b/components/lib/togglebutton/style/ToggleButtonStyle.js index db2645488a..32236286e2 100644 --- a/components/lib/togglebutton/style/ToggleButtonStyle.js +++ b/components/lib/togglebutton/style/ToggleButtonStyle.js @@ -9,21 +9,15 @@ const classes = { 'p-invalid': props.invalid } ], - input: 'p-togglebutton-input', - box: ({ instance }) => [ - 'p-button p-component', - { - 'p-button-icon-only': instance.hasIcon && !instance.hasLabel - } - ], + button: 'p-togglebutton-button', icon: ({ instance, props }) => [ - 'p-button-icon', + 'p-togglebutton-icon', { - 'p-button-icon-left': props.iconPos === 'left' && instance.label, - 'p-button-icon-right': props.iconPos === 'right' && instance.label + 'p-togglebutton-icon-left': props.iconPos === 'left' && instance.label, + 'p-togglebutton-icon-right': props.iconPos === 'right' && instance.label } ], - label: 'p-button-label' + label: 'p-togglebutton-label' }; export default BaseStyle.extend({