Fixed #5786 - Deprecate inputStyle and add inputVariant

pull/5806/head
tugcekucukoglu 2024-05-27 13:28:07 +03:00
parent e14ce7fdf9
commit be72908415
15 changed files with 32 additions and 18 deletions

View File

@ -257,7 +257,7 @@ const classes = {
inputMultiple: ({ props, instance }) => [ inputMultiple: ({ props, instance }) => [
'p-autocomplete-input-multiple', 'p-autocomplete-input-multiple',
{ {
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
} }
], ],
chipItem: ({ instance, i }) => [ chipItem: ({ instance, i }) => [

View File

@ -196,7 +196,7 @@ const classes = {
{ {
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled', 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled',
'p-focus': instance.focused, 'p-focus': instance.focused,
'p-inputwrapper-filled': props.modelValue, 'p-inputwrapper-filled': props.modelValue,
'p-inputwrapper-focus': instance.focused || instance.overlayVisible, 'p-inputwrapper-focus': instance.focused || instance.overlayVisible,

View File

@ -120,7 +120,7 @@ const classes = {
'p-checkbox-checked': instance.checked, 'p-checkbox-checked': instance.checked,
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
} }
], ],
box: 'p-checkbox-box', box: 'p-checkbox-box',

View File

@ -110,7 +110,11 @@ import { VirtualScrollerPassThroughOptions } from '../virtualscroller';
export interface PrimeVueConfiguration { export interface PrimeVueConfiguration {
ripple?: boolean; ripple?: boolean;
/**
* @deprecated since v4.0. Use 'inputVariant' instead.
*/
inputStyle?: 'filled' | 'outlined' | undefined; inputStyle?: 'filled' | 'outlined' | undefined;
inputVariant?: 'filled' | 'outlined' | undefined;
locale?: PrimeVueLocaleOptions; locale?: PrimeVueLocaleOptions;
filterMatchModeOptions?: any; filterMatchModeOptions?: any;
zIndex?: PrimeVueZIndexOptions; zIndex?: PrimeVueZIndexOptions;

View File

@ -6,6 +6,7 @@ import { inject, reactive, ref, watch } from 'vue';
export const defaultOptions = { export const defaultOptions = {
ripple: false, ripple: false,
inputStyle: null, inputStyle: null,
inputVariant: null,
locale: { locale: {
startsWith: 'Starts with', startsWith: 'Starts with',
contains: 'Contains', contains: 'Contains',

View File

@ -118,7 +118,7 @@ const classes = {
input: ({ props, instance }) => [ input: ({ props, instance }) => [
'p-inputchips-input', 'p-inputchips-input',
{ {
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
} }
], ],
chipItem: ({ state, index }) => ['p-inputchips-chip-item', { 'p-focus': state.focusedIndex === index }], chipItem: ({ state, index }) => ['p-inputchips-chip-item', { 'p-focus': state.focusedIndex === index }],

View File

@ -64,7 +64,7 @@ const classes = {
'p-inputtext-sm': props.size === 'small', 'p-inputtext-sm': props.size === 'small',
'p-inputtext-lg': props.size === 'large', 'p-inputtext-lg': props.size === 'large',
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
} }
] ]
}; };

View File

@ -207,7 +207,7 @@ const classes = {
'p-multiselect-display-chip': props.display === 'chip', 'p-multiselect-display-chip': props.display === 'chip',
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled', 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled',
'p-focus': instance.focused, 'p-focus': instance.focused,
'p-inputwrapper-filled': props.modelValue && props.modelValue.length, 'p-inputwrapper-filled': props.modelValue && props.modelValue.length,
'p-inputwrapper-focus': instance.focused || instance.overlayVisible, 'p-inputwrapper-focus': instance.focused || instance.overlayVisible,

View File

@ -125,7 +125,7 @@ const classes = {
'p-radiobutton-checked': instance.checked, 'p-radiobutton-checked': instance.checked,
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
} }
], ],
box: 'p-radiobutton-box', box: 'p-radiobutton-box',

View File

@ -203,7 +203,7 @@ const classes = {
{ {
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled', 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled',
'p-focus': state.focused, 'p-focus': state.focused,
'p-inputwrapper-filled': instance.hasSelectedOption, 'p-inputwrapper-filled': instance.hasSelectedOption,
'p-inputwrapper-focus': state.focused || state.overlayVisible, 'p-inputwrapper-focus': state.focused || state.overlayVisible,

View File

@ -68,7 +68,7 @@ const classes = {
'p-filled': instance.filled, 'p-filled': instance.filled,
'p-textarea-resizable ': props.autoResize, 'p-textarea-resizable ': props.autoResize,
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
} }
] ]
}; };

View File

@ -138,7 +138,7 @@ const classes = {
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-invalid': props.invalid, 'p-invalid': props.invalid,
'p-focus': instance.focused, 'p-focus': instance.focused,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled', 'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled',
'p-inputwrapper-filled': !instance.emptyValue, 'p-inputwrapper-filled': !instance.emptyValue,
'p-inputwrapper-focus': instance.focused || instance.overlayVisible, 'p-inputwrapper-focus': instance.focused || instance.overlayVisible,
'p-treeselect-open': instance.overlayVisible 'p-treeselect-open': instance.overlayVisible

View File

@ -18272,6 +18272,15 @@
"optional": true, "optional": true,
"readonly": false, "readonly": false,
"type": "\"filled\" | \"outlined\"", "type": "\"filled\" | \"outlined\"",
"default": "",
"description": "",
"deprecated": "since v4.0. Use 'inputVariant' instead."
},
{
"name": "inputVariant",
"optional": true,
"readonly": false,
"type": "\"filled\" | \"outlined\"",
"default": "" "default": ""
}, },
{ {

View File

@ -1,10 +1,10 @@
<template> <template>
<DocSectionText v-bind="$attrs"> <DocSectionText v-bind="$attrs">
<p> <p>
Input fields come in two styles, default is <i>outlined</i> with borders around the field whereas <i>filled</i> alternative adds a background color to the field. Applying <i>p-input-filled</i> to an ancestor of an input enables the filled Input fields come in two styles, default is <i>outlined</i> with borders around the field whereas <i>filled</i> alternative adds a background color to the field. Applying <i>p-variant-filled</i> to an ancestor of an input enables the
style. If you prefer to use filled inputs in the entire application, use a global container such as the document body or the application element to apply the style class. Note that in case you add it to the application element, components filled style. If you prefer to use filled inputs in the entire application, use a global container such as the document body or the application element to apply the style class. Note that in case you add it to the application element,
that are teleported to the document body such as Dialog will not be able to display filled inputs as they are not a descendant of the application root element in the DOM tree, to resolve this case set inputStyle to <i>filled</i> at components that are teleported to the document body such as Dialog will not be able to display filled inputs as they are not a descendant of the application root element in the DOM tree, to resolve this case set inputVariant to
PrimeVue configuration as well. <i>filled</i> at PrimeVue configuration as well.
</p> </p>
</DocSectionText> </DocSectionText>
<DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz /> <DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz />
@ -20,7 +20,7 @@ import {createApp} from "vue";
import PrimeVue from "primevue/config"; import PrimeVue from "primevue/config";
const app = createApp(App); const app = createApp(App);
app.use(PrimeVue, { inputStyle: "filled" }); app.use(PrimeVue, { inputVariant: "filled" });
` `
} }
}; };

View File

@ -15,7 +15,7 @@ primevue: {
options: { options: {
unstyled: true, unstyled: true,
ripple: true, ripple: true,
inputStyle: 'filled' inputVariant: 'filled'
} }
} }
` `