Listbox doc added
parent
ef96be3878
commit
b63cb74d23
|
@ -27,13 +27,13 @@ export default {
|
|||
props: {
|
||||
value: null,
|
||||
options: Array,
|
||||
optionLabel: null,
|
||||
listStyle: null,
|
||||
disabled: Boolean,
|
||||
dataKey: null,
|
||||
listStyle: null,
|
||||
multiple: Boolean,
|
||||
metaKeySelection: Boolean,
|
||||
filter: Boolean,
|
||||
optionLabel: null,
|
||||
optionValue: null,
|
||||
optionDisabled: null
|
||||
},
|
||||
|
|
|
@ -21,10 +21,14 @@
|
|||
</template>
|
||||
</Listbox>
|
||||
</div>
|
||||
|
||||
<ListboxDoc/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListboxDoc from './ListboxDoc';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -49,6 +53,9 @@ export default {
|
|||
{brand: 'Volvo', value: 'Volvo'}
|
||||
]
|
||||
}
|
||||
},
|
||||
components: {
|
||||
'ListboxDoc': ListboxDoc
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,275 @@
|
|||
<template>
|
||||
<div class="content-section documentation">
|
||||
<TabView>
|
||||
<TabPanel header="Documentation">
|
||||
<h3>Import</h3>
|
||||
<CodeHighlight lang="javascript">
|
||||
import Listbox from 'primevue/listbox';
|
||||
</CodeHighlight>
|
||||
|
||||
<h3>Getting Started</h3>
|
||||
<p>Listbox 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>
|
||||
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" />
|
||||
</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>Selection</h3>
|
||||
<p>Listbox allows selection of either single or multiple items. In single case, model should be a single object reference whereas in multiple case should be an array. Multiple items can either be selected
|
||||
using metaKey or toggled individually depending on the value of <i>metaKeySelection</i> property value which is true by default. On touch enabled
|
||||
devices metaKeySelection is turned off automatically.</p>
|
||||
<CodeHighlight>
|
||||
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" :multiple="true"/>
|
||||
</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 a template where
|
||||
the local template variable refers to an option in the options collection. </p>
|
||||
<CodeHighlight>
|
||||
<template v-pre>
|
||||
<Listbox v-model="selectedCars" :options="cars" :multiple="true" :filter="true" optionLabel="brand" listStyle="max-height:250px" style="width:15em">
|
||||
<template #option="slotProps">
|
||||
<div class="p-clearfix">
|
||||
<img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" style="display:inline-block;margin:5px 0 0 5px;width:48px" />
|
||||
<span style="float:right;margin:1.25em .5em 0 0">{{slotProps.option.brand}}</span>
|
||||
</div>
|
||||
</template>
|
||||
</Listbox>
|
||||
</template>
|
||||
</CodeHighlight>
|
||||
|
||||
<h3>Filter</h3>
|
||||
<p>Filtering allows searching items in the list using an input field at the header. In order to use filtering, enable <i>filter</i> property.</p>
|
||||
<CodeHighlight>
|
||||
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" :filter="true"/>
|
||||
</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>object</td>
|
||||
<td>null</td>
|
||||
<td>Selected value to display.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>options</td>
|
||||
<td>array</td>
|
||||
<td>null</td>
|
||||
<td>An array of objects 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>listStyle</td>
|
||||
<td>string</td>
|
||||
<td>null</td>
|
||||
<td>Inline style of inner list element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>disabled</td>
|
||||
<td>boolean</td>
|
||||
<td>false</td>
|
||||
<td>When specified, disables the component.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>dataKey</td>
|
||||
<td>string</td>
|
||||
<td>false</td>
|
||||
<td>A property to uniquely match the value in options for better performance.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>multiple</td>
|
||||
<td>boolean</td>
|
||||
<td>false</td>
|
||||
<td>When specified, allows selecting multiple values.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>metaKeySelection</td>
|
||||
<td>boolean</td>
|
||||
<td>true</td>
|
||||
<td>Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item
|
||||
can be toggled individually. On touch enabled devices, metaKeySelection is turned off automatically.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>filter</td>
|
||||
<td>boolean</td>
|
||||
<td>false</td>
|
||||
<td>When specified, displays a filter input at header.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>optionValue</td>
|
||||
<td>???</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: Browser event <br/>
|
||||
event.value: Single value or an array of values depending on the selection mode <br/>
|
||||
</td>
|
||||
<td>Callback to invoke when value of listbox changes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>input</td>
|
||||
<td>event: Single value or an array of values depending on the selection mode <br/>
|
||||
</td>
|
||||
<td>Callback to invoke when value of listbox changes.</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-listbox</td>
|
||||
<td>Main container element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>p-listbox-header</td>
|
||||
<td>Header element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>p-listbox-list-wrapper</td>
|
||||
<td>Container of list element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>p-listbox-list</td>
|
||||
<td>List element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>p-listbox-item</td>
|
||||
<td>An item in the list element.</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/listbox" 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>Listbox</h1>
|
||||
<p>Listbox is used to select one or more values from a list of items.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-section implementation">
|
||||
<h3 class="first">Single</h3>
|
||||
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" />
|
||||
|
||||
<h3>Advanced with Templating, Filtering and Multiple Selection</h3>
|
||||
<Listbox v-model="selectedCars" :options="cars" :multiple="true" :filter="true" optionLabel="brand" listStyle="max-height:250px" style="width:15em">
|
||||
<template #option="slotProps">
|
||||
<div class="p-clearfix">
|
||||
<img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" style="display:inline-block;margin:5px 0 0 5px;width:48px" />
|
||||
<span style="float:right;margin:1.25em .5em 0 0">{{slotProps.option.brand}}</span>
|
||||
</div>
|
||||
</template>
|
||||
</Listbox>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</CodeHighlight>
|
||||
|
||||
<CodeHighlight lang="javascript">
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
selectedCity: null,
|
||||
selectedCars: 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>
|
||||
</TabPanel>
|
||||
</TabView>
|
||||
</div>
|
||||
</template>
|
Loading…
Reference in New Issue