Placeholder support for #271
parent
81dc76760b
commit
b2a9a0dfc1
|
@ -7,7 +7,7 @@
|
||||||
<input v-if="editable" type="text" class="p-dropdown-label p-inputtext" :disabled="disabled" @focus="onFocus" @blur="onBlur" :placeholder="placeholder" :value="editableInputValue" @input="onEditableInput"
|
<input v-if="editable" type="text" class="p-dropdown-label p-inputtext" :disabled="disabled" @focus="onFocus" @blur="onBlur" :placeholder="placeholder" :value="editableInputValue" @input="onEditableInput"
|
||||||
aria-haspopup="listbox" :aria-expanded="overlayVisible">
|
aria-haspopup="listbox" :aria-expanded="overlayVisible">
|
||||||
<label v-if="!editable" :class="labelClass">
|
<label v-if="!editable" :class="labelClass">
|
||||||
<slot name="value" :value="value">
|
<slot name="value" :value="value" :placeholder="placeholder">
|
||||||
{{label}}
|
{{label}}
|
||||||
</slot>
|
</slot>
|
||||||
</label>
|
</label>
|
||||||
|
@ -425,7 +425,7 @@ export default {
|
||||||
'p-dropdown-label p-inputtext',
|
'p-dropdown-label p-inputtext',
|
||||||
{
|
{
|
||||||
'p-placeholder': this.label === this.placeholder,
|
'p-placeholder': this.label === this.placeholder,
|
||||||
'p-dropdown-label-empty': (this.label === 'p-emptylabel' || this.label.length === 0)
|
'p-dropdown-label-empty': !this.$scopedSlots['value'] && (this.label === 'p-emptylabel' || this.label.length === 0)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
<Dropdown v-model="selectedCity2" :options="cities" optionLabel="name" :editable="true"/>
|
<Dropdown v-model="selectedCity2" :options="cities" optionLabel="name" :editable="true"/>
|
||||||
|
|
||||||
<h3>Advanced with Templating, Filtering and Clear Icon</h3>
|
<h3>Advanced with Templating, Filtering and Clear Icon</h3>
|
||||||
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" :filter="true" :showClear="true">
|
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" :filter="true" placeholder="Select a Car" :showClear="true">
|
||||||
<template #value="slotProps">
|
<template #value="slotProps">
|
||||||
<div class="p-dropdown-car-value" v-if="slotProps.value">
|
<div class="p-dropdown-car-value" v-if="slotProps.value">
|
||||||
<img :alt="slotProps.value.brand" :src="'demo/images/car/' + slotProps.value.brand + '.png'" />
|
<img :alt="slotProps.value.brand" :src="'demo/images/car/' + slotProps.value.brand + '.png'" />
|
||||||
<span>{{slotProps.value.brand}}</span>
|
<span>{{slotProps.value.brand}}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
Select a Car
|
{{slotProps.placeholder}}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template #option="slotProps">
|
<template #option="slotProps">
|
||||||
|
|
|
@ -43,14 +43,14 @@ data() {
|
||||||
<p>In addition the <i>value</i> template can be used to customize the selected value.</p>
|
<p>In addition the <i>value</i> template can be used to customize the selected value.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" :filter="true" :showClear="true">
|
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" :filter="true" placeholder="Select a Car" :showClear="true">
|
||||||
<template #value="slotProps">
|
<template #value="slotProps">
|
||||||
<div class="p-dropdown-car-value" v-if="slotProps.value">
|
<div class="p-dropdown-car-value" v-if="slotProps.value">
|
||||||
<img :alt="slotProps.value.brand" :src="'demo/images/car/' + slotProps.value.brand + '.png'" />
|
<img :alt="slotProps.value.brand" :src="'demo/images/car/' + slotProps.value.brand + '.png'" />
|
||||||
<span>{{slotProps.value.brand}}</span>
|
<span>{{slotProps.value.brand}}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
Select a Car
|
{{slotProps.placeholder}}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template #option="slotProps">
|
<template #option="slotProps">
|
||||||
|
@ -294,13 +294,13 @@ data() {
|
||||||
<Dropdown v-model="selectedCity2" :options="cities" optionLabel="name" :editable="true"/>
|
<Dropdown v-model="selectedCity2" :options="cities" optionLabel="name" :editable="true"/>
|
||||||
|
|
||||||
<h3>Advanced with Templating, Filtering and Clear Icon</h3>
|
<h3>Advanced with Templating, Filtering and Clear Icon</h3>
|
||||||
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" :filter="true" :showClear="true">
|
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" :filter="true" placeholder="Select a Car" :showClear="true">
|
||||||
<div class="p-dropdown-car-value" v-if="slotProps.value">
|
<div class="p-dropdown-car-value" v-if="slotProps.value">
|
||||||
<img :alt="slotProps.value.brand" :src="'demo/images/car/' + slotProps.value.brand + '.png'" />
|
<img :alt="slotProps.value.brand" :src="'demo/images/car/' + slotProps.value.brand + '.png'" />
|
||||||
<span>{{slotProps.value.brand}}</span>
|
<span>{{slotProps.value.brand}}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
Select a Car
|
{{slotProps.placeholder}}
|
||||||
</span>
|
</span>
|
||||||
<template #option="slotProps">
|
<template #option="slotProps">
|
||||||
<div class="p-dropdown-car-option">
|
<div class="p-dropdown-car-option">
|
||||||
|
|
Loading…
Reference in New Issue