Dropdown doc added
parent
efdd70a391
commit
2253ddf566
|
@ -43,21 +43,21 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
value: null,
|
||||||
options: Array,
|
options: Array,
|
||||||
dataKey: null,
|
|
||||||
filter: Boolean,
|
|
||||||
optionLabel: null,
|
optionLabel: null,
|
||||||
optionValue: null,
|
|
||||||
optionDisabled: null,
|
|
||||||
disabled: Boolean,
|
|
||||||
tabindex: String,
|
|
||||||
editable: Boolean,
|
|
||||||
placeholder: String,
|
|
||||||
showClear: Boolean,
|
|
||||||
scrollHeight: {
|
scrollHeight: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '200px'
|
default: '200px'
|
||||||
},
|
},
|
||||||
filterPlaceholder: String
|
filter: Boolean,
|
||||||
|
filterPlaceholder: String,
|
||||||
|
editable: Boolean,
|
||||||
|
placeholder: String,
|
||||||
|
disabled: Boolean,
|
||||||
|
dataKey: null,
|
||||||
|
showClear: Boolean,
|
||||||
|
tabindex: String,
|
||||||
|
optionValue: null,
|
||||||
|
optionDisabled: null
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -16,12 +16,6 @@
|
||||||
|
|
||||||
<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" placeholder="Select a Car" :filter="true" :showClear="true">
|
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" placeholder="Select a Car" :filter="true" :showClear="true">
|
||||||
<template v-slot:option={props}>
|
|
||||||
<div class="p-clearfix p-dropdown-car-option">
|
|
||||||
<img :alt="props.option.brand" :src="'/demo/images/car/' + props.option.brand + '.png'" />
|
|
||||||
<span>{{props.option.brand}}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template #option="slotProps">
|
<template #option="slotProps">
|
||||||
<div class="p-clearfix p-dropdown-car-option">
|
<div class="p-clearfix p-dropdown-car-option">
|
||||||
<img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" />
|
<img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" />
|
||||||
|
@ -30,10 +24,14 @@
|
||||||
</template>
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<DropdownDoc/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import DropdownDoc from './DropdownDoc';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -59,6 +57,9 @@ export default {
|
||||||
{brand: 'Volvo', value: 'Volvo'}
|
{brand: 'Volvo', value: 'Volvo'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'DropdownDoc': DropdownDoc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,329 @@
|
||||||
|
<template>
|
||||||
|
<div class="content-section documentation">
|
||||||
|
<TabView>
|
||||||
|
<TabPanel header="Documentation">
|
||||||
|
<h3>Import</h3>
|
||||||
|
<CodeHighlight lang="javascript">
|
||||||
|
import Dropdown from 'primevue/dropdown';
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>Getting Started</h3>
|
||||||
|
<p>Dropdown requires a value to bind, optionLabel and a collection of options. How to define the options property; Providing an array of arbitrary objects along with the <i>optionLabel</i> property to specify the field name of the option.</p>
|
||||||
|
<CodeHighlight>
|
||||||
|
<Dropdown v-model="selectedCity" :options="cities" optionLabel="name" placeholder="Select a City" />
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="js">
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
selectedCity: null,
|
||||||
|
cities: [
|
||||||
|
{name: 'New York', code: 'NY'},
|
||||||
|
{name: 'Rome', code: 'RM'},
|
||||||
|
{name: 'London', code: 'LDN'},
|
||||||
|
{name: 'Istanbul', code: 'IST'},
|
||||||
|
{name: 'Paris', code: 'PRS'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>Placeholder</h3>
|
||||||
|
<p>Common pattern is providing an empty option as the placeholder when using native selects, however Dropdown has built-in support using the placeholder option so it is suggested to use it instead of creating an empty option.</p>
|
||||||
|
|
||||||
|
<h3>Filtering</h3>
|
||||||
|
<p>Options can be filtered using an input field in the overlay by enabling the <i>filter</i> property.</p>
|
||||||
|
|
||||||
|
<CodeHighlight>
|
||||||
|
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" placeholder="Select a Car" :filter="true" filterPlaceholder="Find Car"/>
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>Custom Content</h3>
|
||||||
|
<p>Label of an option is used as the display text of an item by default, for custom content support define an <i>item</i> template that gets the option instance as a parameter and returns the content.</p>
|
||||||
|
<CodeHighlight>
|
||||||
|
<template v-pre>
|
||||||
|
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" placeholder="Select a Car" :filter="true" :showClear="true">
|
||||||
|
<template #option="slotProps">
|
||||||
|
<div class="p-clearfix p-dropdown-car-option">
|
||||||
|
<img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" />
|
||||||
|
<span>{{slotProps.option.brand}}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Dropdown>
|
||||||
|
</template>
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>Properties</h3>
|
||||||
|
<div class="doc-tablewrapper">
|
||||||
|
<table class="doc-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>value</td>
|
||||||
|
<td>any</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Value of the component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>options</td>
|
||||||
|
<td>array</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>An array of selectitems to display as the available options.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>optionLabel</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Name of the label field of an option when an arbitrary objects instead of SelectItems are used as options.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>scrollHeight</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>200px</td>
|
||||||
|
<td>Height of the viewport in pixels, a scrollbar is defined if height of list exceeds this value.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>filter</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>When specified, displays an input field to filter the items on keyup.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>filterPlaceholder</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Placeholder text to show when filter input is empty.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>editable</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>When present, custom value instead of predefined options can be entered using the editable input field.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>placeholder</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Default text to display when no option is selected.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>disabled</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>When present, it specifies that the component should be disabled.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>dataKey</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>A property to uniquely match the value in options for better performance.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>showClear</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>When enabled, a clear icon is displayed to clear the value.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>tabindex</td>
|
||||||
|
<td>number</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Index of the element in tabbing order.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>optionValue</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>???</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>optionDisabled</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>???</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Events</h3>
|
||||||
|
<div class="doc-tablewrapper">
|
||||||
|
<table class="doc-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Parameters</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>change</td>
|
||||||
|
<td>event.originalEvent: Original event <br />
|
||||||
|
event.value: Selected option value </td>
|
||||||
|
<td>Callback to invoke on value change</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>input</td>
|
||||||
|
<td>event: Input field value</td>
|
||||||
|
<td>Callback to invoke on input event of input field (editable mode).</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Styling</h3>
|
||||||
|
<p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p>
|
||||||
|
<div class="doc-tablewrapper">
|
||||||
|
<table class="doc-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Element</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown</td>
|
||||||
|
<td>Container element.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-label</td>
|
||||||
|
<td>Element to display label of selected option.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-trigger</td>
|
||||||
|
<td>Icon element.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-panel</td>
|
||||||
|
<td>Icon element.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-items-wrapper</td>
|
||||||
|
<td>Wrapper element of items list.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-items</td>
|
||||||
|
<td>List element of items.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-item</td>
|
||||||
|
<td>An item in the list.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-filter-container</td>
|
||||||
|
<td>Container of filter input.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-filter</td>
|
||||||
|
<td>Filter element.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-dropdown-open</td>
|
||||||
|
<td>Container element when overlay is visible.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Dependencies</h3>
|
||||||
|
<p>None.</p>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Source">
|
||||||
|
<a href="https://github.com/primefaces/primevue/tree/master/src/views/dropdown" class="btn-viewsource" target="_blank" rel="noopener noreferrer">
|
||||||
|
<span>View on GitHub</span>
|
||||||
|
</a>
|
||||||
|
<CodeHighlight>
|
||||||
|
<template v-pre>
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="content-section introduction">
|
||||||
|
<div class="feature-intro">
|
||||||
|
<h1>Dropdown</h1>
|
||||||
|
<p>Dropdown is used to select an item from a list of options.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-section implementation">
|
||||||
|
<h3 class="first">Basic</h3>
|
||||||
|
<Dropdown v-model="selectedCity1" :options="cities" optionLabel="name" placeholder="Select a City" />
|
||||||
|
|
||||||
|
<h3>Editable</h3>
|
||||||
|
<Dropdown v-model="selectedCity2" :options="cities" optionLabel="name" :editable="true"/>
|
||||||
|
|
||||||
|
<h3>Advanced with Templating, Filtering and Clear Icon</h3>
|
||||||
|
<Dropdown v-model="selectedCar" :options="cars" optionLabel="brand" placeholder="Select a Car" :filter="true" :showClear="true">
|
||||||
|
<template #option="slotProps">
|
||||||
|
<div class="p-clearfix p-dropdown-car-option">
|
||||||
|
<img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" />
|
||||||
|
<span>{{slotProps.option.brand}}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="javascript">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
selectedCity1: null,
|
||||||
|
selectedCity2: null,
|
||||||
|
selectedCar: null,
|
||||||
|
cities: [
|
||||||
|
{name: 'New York', code: 'NY'},
|
||||||
|
{name: 'Rome', code: 'RM'},
|
||||||
|
{name: 'London', code: 'LDN'},
|
||||||
|
{name: 'Istanbul', code: 'IST'},
|
||||||
|
{name: 'Paris', code: 'PRS'}
|
||||||
|
],
|
||||||
|
cars: [
|
||||||
|
{brand: 'Audi', value: 'Audi'},
|
||||||
|
{brand: 'Bmw', value: 'Bmw'},
|
||||||
|
{brand: 'Fiat', value: 'Fiat'},
|
||||||
|
{brand: 'Honda', value: 'Honda'},
|
||||||
|
{brand: 'Jaguar', value: 'Jaguar'},
|
||||||
|
{brand: 'Mercedes', value: 'Mercedes'},
|
||||||
|
{brand: 'Renault', value: 'Renault'},
|
||||||
|
{brand: 'Volkswagen', value: 'Volkswagen'},
|
||||||
|
{brand: 'Volvo', value: 'Volvo'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="css">
|
||||||
|
.p-dropdown {
|
||||||
|
width: 12em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-dropdown-car-option {
|
||||||
|
img {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: .5em;
|
||||||
|
width: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
float: right;
|
||||||
|
margin-top: .125em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
</TabPanel>
|
||||||
|
</TabView>
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Reference in New Issue