Doc refactor for AutoComplete, InputText and Calendar
parent
a35f6fd139
commit
09d2b816cc
|
@ -7,11 +7,11 @@
|
||||||
<span class="p-autocomplete-token-label">{{getItemContent(item)}}</span>
|
<span class="p-autocomplete-token-label">{{getItemContent(item)}}</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="p-autocomplete-input-token">
|
<li class="p-autocomplete-input-token">
|
||||||
<input ref="input" type="text" autoComplete="off" :disabled="disabled" v-bind="$attrs" v-on="listeners">
|
<input ref="input" type="text" autoComplete="off" v-bind="$attrs" v-on="listeners">
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<i class="p-autocomplete-loader pi pi-spinner pi-spin" v-show="searching"></i>
|
<i class="p-autocomplete-loader pi pi-spinner pi-spin" v-show="searching"></i>
|
||||||
<Button ref="dropdownButton" type="button" icon="pi pi-fw pi-chevron-down" class="p-autocomplete-dropdown" :disabled="disabled" @click="onDropdownClick" v-if="dropdown"/>
|
<Button ref="dropdownButton" type="button" icon="pi pi-fw pi-chevron-down" class="p-autocomplete-dropdown" :disabled="$attrs.disabled" @click="onDropdownClick" v-if="dropdown"/>
|
||||||
<transition name="p-input-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave">
|
<transition name="p-input-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave">
|
||||||
<div ref="overlay" class="p-autocomplete-panel" :style="{'max-height': scrollHeight}" v-if="overlayVisible">
|
<div ref="overlay" class="p-autocomplete-panel" :style="{'max-height': scrollHeight}" v-if="overlayVisible">
|
||||||
<ul class="p-autocomplete-items p-autocomplete-list p-component">
|
<ul class="p-autocomplete-items p-autocomplete-list p-component">
|
||||||
|
@ -35,18 +35,29 @@ export default {
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
value: null,
|
||||||
suggestions: Array,
|
suggestions: {
|
||||||
dropdown: Boolean,
|
type: Array,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
field: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
scrollHeight: {
|
||||||
|
type: String,
|
||||||
|
default: '200px'
|
||||||
|
},
|
||||||
|
dropdown: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
dropdownMode: {
|
dropdownMode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'blank'
|
default: 'blank'
|
||||||
},
|
},
|
||||||
multiple: Boolean,
|
multiple: {
|
||||||
disabled: Boolean,
|
type: Boolean,
|
||||||
field: String,
|
default: false
|
||||||
scrollHeight: {
|
|
||||||
type: String,
|
|
||||||
default: '200px'
|
|
||||||
},
|
},
|
||||||
minLength: {
|
minLength: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
@ -55,7 +66,7 @@ export default {
|
||||||
delay: {
|
delay: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 300
|
default: 300
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
timeout: null,
|
timeout: null,
|
||||||
outsideClickListener: null,
|
outsideClickListener: null,
|
||||||
|
@ -353,12 +364,12 @@ export default {
|
||||||
inputClass() {
|
inputClass() {
|
||||||
return ['p-autocomplete-input p-inputtext p-component', {
|
return ['p-autocomplete-input p-inputtext p-component', {
|
||||||
'p-autocomplete-dd-input': this.dropdown,
|
'p-autocomplete-dd-input': this.dropdown,
|
||||||
'p-disabled': this.disabled
|
'p-disabled': this.$attrs.disabled
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
multiContainerClass() {
|
multiContainerClass() {
|
||||||
return ['p-autocomplete-multiple-container p-component p-inputtext', {
|
return ['p-autocomplete-multiple-container p-component p-inputtext', {
|
||||||
'p-disabled': this.disabled,
|
'p-disabled': this.$attrs.disabled,
|
||||||
'p-focus': this.focused
|
'p-focus': this.focused
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,35 +9,25 @@ import AutoComplete from 'primevue/autocomplete';
|
||||||
|
|
||||||
<h3>Getting Started</h3>
|
<h3>Getting Started</h3>
|
||||||
<p>AutoComplete uses v-model for two-way binding, requires a list of suggestions and a complete method to query for the results. The complete method
|
<p>AutoComplete uses v-model for two-way binding, requires a list of suggestions and a complete method to query for the results. The complete method
|
||||||
gets the query text as event.query property and should update the suggestions with the search results.</p>
|
gets the query text as event.query property and should update the suggestions with the search results. Example below connects to a remote datasource to fetch the results;</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<AutoComplete v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountryBasic($event)" field="name" />
|
<AutoComplete v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountry($event)" field="name" />
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
<CodeHighlight lang="js">
|
<CodeHighlight lang="js">
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedCountry: null,
|
selectedCountry: null,
|
||||||
filteredCountriesBasic: null
|
filteredCountries: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
countryService: null,
|
countryService: null,
|
||||||
created() {
|
created() {
|
||||||
this.countryService = new CountryService();
|
this.countryService = new CountryService();
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.countryService.getCountries().then(data => this.countries = data);
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
searchCountry(query) {
|
searchCountry(event) {
|
||||||
return this.countries.filter((country) => {
|
this.filteredCountriesBasic = this.countryService.search(event.query);
|
||||||
return country.name.toLowerCase().startsWith(query.toLowerCase());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
searchCountryBasic(event) {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.filteredCountriesBasic = this.searchCountry(event.query);
|
|
||||||
}, 250);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +43,7 @@ export default {
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<h3>Multiple Mode</h3>
|
<h3>Multiple Mode</h3>
|
||||||
<p>Multiple mode is enabled using <i>multiple</i> property used to select more than one value from the autocomplete. In this case, value reference should be an array.</p>
|
<p>Multiple mode is enabled using <i>multiple</i> property to select more than one value from the autocomplete. In this case, value reference should be an array.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<AutoComplete :multiple="true" v-model="selectedCountries" :suggestions="filteredCountriesMultiple" @complete="searchCountryMultiple($event)" field="name" />
|
<AutoComplete :multiple="true" v-model="selectedCountries" :suggestions="filteredCountriesMultiple" @complete="searchCountryMultiple($event)" field="name" />
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
@ -67,21 +57,20 @@ export default {
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<h3>Templating</h3>
|
<h3>Templating</h3>
|
||||||
<p>Item template allows displaying custom content inside the suggestions panel. The local template variable passed to the template is an object in the suggestions array.</p>
|
<p>Item template allows displaying custom content inside the suggestions panel. The slotProps variable passed to the template provides an item property to represent an item in the suggestions collection.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<AutoComplete v-model="brand" :suggestions="filteredBrands" @complete="searchBrand($event)" placeholder="Hint: type 'v' or 'f'" :dropdown="true">
|
<AutoComplete v-model="brand" :suggestions="filteredBrands" @complete="searchBrand($event)" placeholder="Hint: type 'v' or 'f'" :dropdown="true">
|
||||||
<template #item="slotProps">
|
<template #item="slotProps">
|
||||||
<div class="p-clearfix p-autocomplete-brand-item">
|
|
||||||
<img :alt="slotProps.item" :src="'/demo/images/car/' + slotProps.item + '.png'" />
|
<img :alt="slotProps.item" :src="'/demo/images/car/' + slotProps.item + '.png'" />
|
||||||
<div>{{slotProps.item}}</div>
|
<div>{{slotProps.item}}</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</AutoComplete>
|
</AutoComplete>
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<h3>Properties</h3>
|
<h3>Properties</h3>
|
||||||
|
<p>Any valid attribute such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.</p>
|
||||||
<div class="doc-tablewrapper">
|
<div class="doc-tablewrapper">
|
||||||
<table class="doc-table">
|
<table class="doc-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -147,17 +136,12 @@ export default {
|
||||||
<td>300</td>
|
<td>300</td>
|
||||||
<td>Delay between keystrokes to wait before sending a query.</td>
|
<td>Delay between keystrokes to wait before sending a query.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>disabled</td>
|
|
||||||
<td>boolean</td>
|
|
||||||
<td>false</td>
|
|
||||||
<td>When present, it specifies that the component should be disabled.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Events</h3>
|
<h3>Events</h3>
|
||||||
|
<p>Any valid event such as focus, blur and input are passed to the underlying input element. Following are the additional events to configure the component.</p>
|
||||||
<div class="doc-tablewrapper">
|
<div class="doc-tablewrapper">
|
||||||
<table class="doc-table">
|
<table class="doc-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -167,7 +167,7 @@ export default {
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<h3>Properties</h3>
|
<h3>Properties</h3>
|
||||||
<p>Calendar passes any valid attribute such as name and placeholder to the underlying input text element. Following are the additional properties to configure the calendar.</p>
|
<p>Any valid attribute such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.</p>
|
||||||
<div class="doc-tablewrapper">
|
<div class="doc-tablewrapper">
|
||||||
<table class="doc-table">
|
<table class="doc-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -406,7 +406,7 @@ export default {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Events</h3>
|
<h3>Events</h3>
|
||||||
<p>Calendar passes any valid event such as focus, blur and input to the underlying input text element. Following are the additional event to configure the calendar.</p>
|
<p>Any valid event such as focus, blur and input are passed to the underlying input element. Following are the additional events to configure the component.</p>
|
||||||
<div class="doc-tablewrapper">
|
<div class="doc-tablewrapper">
|
||||||
<table class="doc-table">
|
<table class="doc-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
<h3>Floating Label</h3>
|
<h3>Floating Label</h3>
|
||||||
<span class="p-float-label">
|
<span class="p-float-label">
|
||||||
<InputText type="text" v-model="value2" />
|
<InputText id="username" type="text" v-model="value2" />
|
||||||
<label htmlFor="float-input">Username</label>
|
<label for="username">Username</label>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<h3>Disabled</h3>
|
<h3>Disabled</h3>
|
||||||
|
|
|
@ -17,8 +17,8 @@ import InputText from 'primevue/inputtext';
|
||||||
<p>A floating label is implemented by wrapping the input and the label inside a container having <i>.p-float-label</i> style class.</p>
|
<p>A floating label is implemented by wrapping the input and the label inside a container having <i>.p-float-label</i> style class.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<span class="p-float-label">
|
<span class="p-float-label">
|
||||||
<InputText type="text" v-model="value" />
|
<InputText id="username" type="text" v-model="value" />
|
||||||
<label htmlFor="float-input">Username</label>
|
<label for="username">Username</label>
|
||||||
</span>
|
</span>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ import InputText from 'primevue/inputtext';
|
||||||
|
|
||||||
<h3>Floating Label</h3>
|
<h3>Floating Label</h3>
|
||||||
<span class="p-float-label">
|
<span class="p-float-label">
|
||||||
<InputText type="text" v-model="value2" />
|
<InputText id="username" type="text" v-model="value2" />
|
||||||
<label htmlFor="float-input">Username</label>
|
<label for="username">Username</label>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<h3>Disabled</h3>
|
<h3>Disabled</h3>
|
||||||
|
|
Loading…
Reference in New Issue