Checkbox doc added
parent
e20b347597
commit
a1265c7b9b
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="p-checkbox p-component" @click="onClick($event)">
|
||||
<div class="p-hidden-accessible">
|
||||
<input ref="input" :id="inputId" type="checkbox" :name="name" :checked="checked" :disabled="disabled" @focus="onFocus()" @blur="onBlur()"
|
||||
<input ref="input" :id="inputId" type="checkbox" :name="name" :checked="checked" :disabled="disabled" @focus="onFocus($event)" @blur="onBlur($event)"
|
||||
:autocomplete="autocomplete" :autofocus="autofocus">
|
||||
</div>
|
||||
<div ref="box" :class="['p-checkbox-box p-component', {'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused}]">
|
||||
|
@ -57,7 +57,7 @@ export default {
|
|||
this.focused = true;
|
||||
this.$emit('focus', event);
|
||||
},
|
||||
onBlur() {
|
||||
onBlur(event) {
|
||||
this.focused = false;
|
||||
this.$emit('blur', event);
|
||||
}
|
||||
|
|
|
@ -9,25 +9,25 @@
|
|||
|
||||
<div class="content-section implementation">
|
||||
<h3 class="first">Basic</h3>
|
||||
<Checkbox inputId="binary" v-model="checked" />
|
||||
<Checkbox id="binary" inputId="binary" v-model="checked"/>
|
||||
<label for="binary" class="p-checkbox-label" style="font-weight: bold">{{checked}}</label>
|
||||
|
||||
<h3>Multiple</h3>
|
||||
<div class="p-grid">
|
||||
<div class="p-col-12">
|
||||
<Checkbox inputId="city1" name="city" value="Chicago" v-model="cities" />
|
||||
<Checkbox id="city1" inputId="city1" name="city" value="Chicago" v-model="cities" />
|
||||
<label for="city1" class="p-checkbox-label">Chicago</label>
|
||||
</div>
|
||||
<div class="p-col-12">
|
||||
<Checkbox inputId="city2" name="city" value="Los Angeles" v-model="cities" />
|
||||
<Checkbox id="city2" inputId="city2" name="city" value="Los Angeles" v-model="cities" />
|
||||
<label for="city2" class="p-checkbox-label">Los Angeles</label>
|
||||
</div>
|
||||
<div class="p-col-12">
|
||||
<Checkbox inputId="city3" name="city" value="New York" v-model="cities" />
|
||||
<Checkbox id="city3" inputId="city3" name="city" value="New York" v-model="cities" />
|
||||
<label for="city3" class="p-checkbox-label">New York</label>
|
||||
</div>
|
||||
<div class="p-col-12">
|
||||
<Checkbox inputId="city4" name="city" value="San Francisco" v-model="cities" />
|
||||
<Checkbox id="city4" inputId="city4" name="city" value="San Francisco" v-model="cities" />
|
||||
<label for="city4" class="p-checkbox-label">San Francisco</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -42,10 +42,14 @@
|
|||
</div>
|
||||
<p>Selected Themes: <span style="font-weight: bold">{{this.selectedThemes}}</span></p>
|
||||
</div>
|
||||
|
||||
<CheckboxDoc/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CheckboxDoc from './CheckboxDoc';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -57,6 +61,9 @@ export default {
|
|||
},
|
||||
created() {
|
||||
this.selectedThemes = this.themes.slice(1,3);
|
||||
},
|
||||
components: {
|
||||
'CheckboxDoc': CheckboxDoc
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,258 @@
|
|||
<template>
|
||||
<div class="content-section documentation">
|
||||
<TabView>
|
||||
<TabPanel header="Documentation">
|
||||
<h3>Import</h3>
|
||||
<CodeHighlight lang="javascript">
|
||||
import Checkbox from 'primevue/checkbox';
|
||||
</CodeHighlight>
|
||||
|
||||
<h3>Getting Started</h3>
|
||||
<p>Checkbox can either be used in multiple selection with other checkboxes or as a single checkbox to provide a boolean value.</p>
|
||||
<CodeHighlight>
|
||||
<Checkbox id="binary" inputId="binary" v-model="checked" />
|
||||
</CodeHighlight>
|
||||
|
||||
<h3>Multiple Values</h3>
|
||||
<p>Multiple mode is enabled by default, v-model property refers to an array to bind the selected values.</p>
|
||||
<CodeHighlight>
|
||||
<Checkbox id="city1" inputId="city1" name="city" value="Chicago" v-model="cities" />
|
||||
<Checkbox id="city2" inputId="city2" name="city" value="Los Angeles" v-model="cities" />
|
||||
<Checkbox id="city3" inputId="city3" name="city" value="New York" v-model="cities" />
|
||||
<Checkbox id="city4" inputId="city4" name="city" value="San Francisco" v-model="cities" />
|
||||
</CodeHighlight>
|
||||
|
||||
<CodeHighlight lang="js">
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cities: []
|
||||
}
|
||||
}
|
||||
}
|
||||
</CodeHighlight>
|
||||
|
||||
|
||||
<p>As v-model is two-way binding enabled, prepopulating the model array with values is enough to display the related
|
||||
checkboxes as checked by default.</p>
|
||||
<CodeHighlight lang="js">
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
themes: [{name: 'Apollo', key: 'A'}, {name: 'Babylon', key: 'B'}, {name: 'Serenity', key: 'S'}, {name: 'Ultima', key: 'U'}],
|
||||
selectedThemes: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.selectedThemes = this.themes.slice(1,3);
|
||||
}
|
||||
}
|
||||
</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>inputId</td>
|
||||
<td>string</td>
|
||||
<td>null</td>
|
||||
<td>Unique identifier of the inner native checkbox.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>value</td>
|
||||
<td>any</td>
|
||||
<td>null</td>
|
||||
<td>Value of the checkbox.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>name</td>
|
||||
<td>string</td>
|
||||
<td>null</td>
|
||||
<td>Name of the checkbox element .</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>disabled</td>
|
||||
<td>boolean</td>
|
||||
<td>false</td>
|
||||
<td>When present, it specifies that the element value cannot be altered.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>modelValue</td>
|
||||
<td>any</td>
|
||||
<td>null</td>
|
||||
<td>Value of the checkbox.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>autocomplete</td>
|
||||
<td>string</td>
|
||||
<td>null</td>
|
||||
<td>When specifies, whether or not an the element should have autocomplete enabled.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>autofocus</td>
|
||||
<td>boolean</td>
|
||||
<td>false</td>
|
||||
<td>When present, it specifies that the element should automatically get focus when the page loads.</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: Browser event</td>
|
||||
<td>Callback to invoke on value change.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>input</td>
|
||||
<td>event: Value of checkbox</td>
|
||||
<td>Callback to invoke on click.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>click</td>
|
||||
<td>event: Browser event</td>
|
||||
<td>Callback to invoke click.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>focus</td>
|
||||
<td>event: Browser event</td>
|
||||
<td>Callback to invoke on focus.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>blur</td>
|
||||
<td>event: Browser event</td>
|
||||
<td>Callback to invoke on blur.</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-chkbox</td>
|
||||
<td>Container element</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>p-chkbox-box</td>
|
||||
<td>Container of icon.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>p-chkbox-icon</td>
|
||||
<td>Icon element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>p-chkbox-label</td>
|
||||
<td>Label 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/inputtext" 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>Checkbox</h1>
|
||||
<p>Checkbox is an extension to standard checkbox element with theming.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-section implementation">
|
||||
<h3 class="first">Basic</h3>
|
||||
<Checkbox id="binary" inputId="binary" v-model="checked"/>
|
||||
<label for="binary" class="p-checkbox-label" style="font-weight: bold">{{checked}}</label>
|
||||
|
||||
<h3>Multiple</h3>
|
||||
<div class="p-grid">
|
||||
<div class="p-col-12">
|
||||
<Checkbox id="city1" inputId="city1" name="city" value="Chicago" v-model="cities" />
|
||||
<label for="city1" class="p-checkbox-label">Chicago</label>
|
||||
</div>
|
||||
<div class="p-col-12">
|
||||
<Checkbox id="city2" inputId="city2" name="city" value="Los Angeles" v-model="cities" />
|
||||
<label for="city2" class="p-checkbox-label">Los Angeles</label>
|
||||
</div>
|
||||
<div class="p-col-12">
|
||||
<Checkbox id="city3" inputId="city3" name="city" value="New York" v-model="cities" />
|
||||
<label for="city3" class="p-checkbox-label">New York</label>
|
||||
</div>
|
||||
<div class="p-col-12">
|
||||
<Checkbox id="city4" inputId="city4" name="city" value="San Francisco" v-model="cities" />
|
||||
<label for="city4" class="p-checkbox-label">San Francisco</label>
|
||||
</div>
|
||||
</div>
|
||||
<p>Selected Cities : <span style="font-weight: bold">{{cities}}</span></p>
|
||||
|
||||
<h3>Dynamic Values, Preselection, Value Binding and Disabled Option</h3>
|
||||
<div class="p-grid">
|
||||
<div v-for="theme of themes" :key="theme.key" class="p-col-12">
|
||||
<Checkbox :inputId="theme.key" name="theme" :value="theme" v-model="selectedThemes" :disabled="theme.key === 'U'"/>
|
||||
<label :for="theme.key" class="p-checkbox-label">{{theme.name}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<p>Selected Themes: <span style="font-weight: bold">{{this.selectedThemes}}</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</CodeHighlight>
|
||||
|
||||
<CodeHighlight lang="javascript">
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
checked: false,
|
||||
cities: [],
|
||||
themes: [{name: 'Apollo', key: 'A'}, {name: 'Babylon', key: 'B'}, {name: 'Serenity', key: 'S'}, {name: 'Ultima', key: 'U'}],
|
||||
selectedThemes: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.selectedThemes = this.themes.slice(1,3);
|
||||
}
|
||||
}
|
||||
</CodeHighlight>
|
||||
</TabPanel>
|
||||
</TabView>
|
||||
</div>
|
||||
</template>
|
Loading…
Reference in New Issue