From 99b1edd5cedddbd12d72b24fcd240abe18b308b5 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 12 Jan 2024 07:07:55 +0000 Subject: [PATCH] Refactor #5071 - Improve the structure of some components to comply with standards --- .../basecomponent/style/BaseComponentStyle.js | 55 --------- components/lib/checkbox/BaseCheckbox.vue | 4 - components/lib/checkbox/Checkbox.d.ts | 33 ++---- components/lib/checkbox/Checkbox.vue | 59 ++++------ .../lib/checkbox/style/CheckboxStyle.js | 35 ++++-- .../lib/inputswitch/BaseInputSwitch.vue | 12 +- components/lib/inputswitch/InputSwitch.vue | 64 +++++----- .../lib/inputswitch/style/InputSwitchStyle.js | 10 +- .../lib/radiobutton/BaseRadioButton.vue | 12 +- components/lib/radiobutton/RadioButton.vue | 55 +++++---- .../lib/radiobutton/style/RadioButtonStyle.js | 48 ++++++-- components/lib/slider/Slider.vue | 1 - components/lib/togglebutton/ToggleButton.vue | 102 ++++++---------- .../togglebutton/style/ToggleButtonStyle.js | 45 ++++++- .../tristatecheckbox/BaseTriStateCheckbox.vue | 26 +++-- .../lib/tristatecheckbox/TriStateCheckbox.vue | 110 ++++++++---------- .../style/TriStateCheckboxStyle.js | 39 +++++-- 17 files changed, 355 insertions(+), 355 deletions(-) diff --git a/components/lib/basecomponent/style/BaseComponentStyle.js b/components/lib/basecomponent/style/BaseComponentStyle.js index 632553a1b..665db5fe3 100644 --- a/components/lib/basecomponent/style/BaseComponentStyle.js +++ b/components/lib/basecomponent/style/BaseComponentStyle.js @@ -71,26 +71,6 @@ const buttonCSS = ` } `; -const checkboxCSS = ` -.p-checkbox { - display: inline-flex; - cursor: pointer; - user-select: none; - vertical-align: bottom; - position: relative; -} - -.p-checkbox.p-checkbox-disabled { - cursor: default; -} - -.p-checkbox-box { - display: flex; - justify-content: center; - align-items: center; -} -`; - const inputTextCSS = ` .p-fluid .p-inputtext { width: 100%; @@ -193,39 +173,6 @@ const inputTextCSS = ` } `; -const radioButtonCSS = ` -.p-radiobutton { - position: relative; - display: inline-flex; - cursor: pointer; - user-select: none; - vertical-align: bottom; -} - -.p-radiobutton.p-radiobutton-disabled { - cursor: default; -} - -.p-radiobutton-box { - display: flex; - justify-content: center; - align-items: center; -} - -.p-radiobutton-icon { - -webkit-backface-visibility: hidden; - backface-visibility: hidden; - transform: translateZ(0) scale(.1); - border-radius: 50%; - visibility: hidden; -} - -.p-radiobutton-box.p-highlight .p-radiobutton-icon { - transform: translateZ(0) scale(1.0, 1.0); - visibility: visible; -} -`; - const css = ` @layer primevue { .p-component, .p-component * { @@ -348,9 +295,7 @@ const css = ` transition: max-height 1s ease-in-out; } ${buttonCSS} -${checkboxCSS} ${inputTextCSS} -${radioButtonCSS} } `; diff --git a/components/lib/checkbox/BaseCheckbox.vue b/components/lib/checkbox/BaseCheckbox.vue index afd924115..939f7a9af 100644 --- a/components/lib/checkbox/BaseCheckbox.vue +++ b/components/lib/checkbox/BaseCheckbox.vue @@ -49,10 +49,6 @@ export default { type: Object, default: null }, - inputProps: { - type: null, - default: null - }, ariaLabelledby: { type: String, default: null diff --git a/components/lib/checkbox/Checkbox.d.ts b/components/lib/checkbox/Checkbox.d.ts index cf3c1bce1..31356a51b 100755 --- a/components/lib/checkbox/Checkbox.d.ts +++ b/components/lib/checkbox/Checkbox.d.ts @@ -7,7 +7,7 @@ * @module checkbox * */ -import { InputHTMLAttributes, VNode } from 'vue'; +import { VNode } from 'vue'; import { ComponentHooks } from '../basecomponent'; import { PassThroughOptions } from '../passthrough'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; @@ -91,11 +91,7 @@ export interface CheckboxPassThroughAttributes { * Defines current inline state in Checkbox component. */ export interface CheckboxState { - /** - * Current focus state as a boolean. - * @defaultValue false - */ - focused: boolean; + [key: string]: any; } /** @@ -160,10 +156,6 @@ export interface CheckboxProps { * Inline style of the input field. */ inputStyle?: string | object | undefined; - /** - * Used to pass all properties of the HTMLInputElement to the focusable input element inside the component. - */ - inputProps?: InputHTMLAttributes | undefined; /** * Establishes relationships between the component and label(s) where its value should be one or more element IDs. */ @@ -198,11 +190,6 @@ export interface CheckboxContext { * @defaultValue false */ checked: boolean; - /** - * Current focus state of the item as a boolean. - * @defaultValue false - */ - focused: boolean; /** * Current disabled state of the item as a boolean. * @defaultValue false @@ -239,21 +226,21 @@ export interface CheckboxEmits { * @param {*} value - New page value. */ 'update:page'(value: any): void; - /** - * Callback to invoke on value click. - * @param {MouseEvent} event - Browser event. - */ - click(event: MouseEvent): void; /** * Callback to invoke on value change. * @param {Event} event - Browser event. */ change(event: Event): void; /** - * Callback to invoke on value change. - * @param {boolean} value - New value. + * Callback to invoke when the component receives focus. + * @param {Event} event - Browser event. */ - input(value: boolean): void; + focus(event: Event): void; + /** + * Callback to invoke when the component loses focus. + * @param {Event} event - Browser event. + */ + blur(event: Event): void; } /** diff --git a/components/lib/checkbox/Checkbox.vue b/components/lib/checkbox/Checkbox.vue index e58c059cc..6ca78f82e 100755 --- a/components/lib/checkbox/Checkbox.vue +++ b/components/lib/checkbox/Checkbox.vue @@ -1,25 +1,25 @@