Radiobutton doc added
parent
a21e497376
commit
e658d5ac77
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="p-radiobutton p-component" @click="onClick($event)">
|
<div class="p-radiobutton p-component" @click="onClick($event)">
|
||||||
<div class="p-hidden-accessible">
|
<div class="p-hidden-accessible">
|
||||||
<input ref="input" :id="inputId" type="radio" :name="name" :checked="checked" :disabled="disabled" @focus="onFocus()" @blur="onBlur()"
|
<input ref="input" :id="inputId" type="radio" :name="name" :checked="checked" :disabled="disabled" @focus="onFocus($event)" @blur="onBlur($event)"
|
||||||
:autocomplete="autocomplete" :autofocus="autofocus">
|
:autocomplete="autocomplete" :autofocus="autofocus">
|
||||||
</div>
|
</div>
|
||||||
<div ref="box" :class="['p-radiobutton-box p-component', {'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused}]">
|
<div ref="box" :class="['p-radiobutton-box p-component', {'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused}]">
|
||||||
|
@ -11,17 +11,17 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ObjectUtils from '../utils/ObjectUtils';
|
import ObjectUtils from '../utils/ObjectUtils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
inputId: String,
|
||||||
modelValue: null,
|
name: String,
|
||||||
name: String,
|
value: null,
|
||||||
inputId: String,
|
disabled: Boolean,
|
||||||
autofocus: Boolean,
|
modelValue: null,
|
||||||
autocomplete: String,
|
autofocus: Boolean,
|
||||||
disabled: Boolean
|
autocomplete: String
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
prop: 'modelValue',
|
prop: 'modelValue',
|
||||||
|
@ -48,7 +48,7 @@ export default {
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
this.$emit('focus', event);
|
this.$emit('focus', event);
|
||||||
},
|
},
|
||||||
onBlur() {
|
onBlur(event) {
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
this.$emit('blur', event);
|
this.$emit('blur', event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,14 @@
|
||||||
</div>
|
</div>
|
||||||
<p>Selected Theme: <span style="font-weight: bold">{{this.selectedTheme}}</span></p>
|
<p>Selected Theme: <span style="font-weight: bold">{{this.selectedTheme}}</span></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<RadioButtonDoc/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import RadioButtonDoc from './RadioButtonDoc';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -52,6 +56,9 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.selectedTheme = this.themes[1];
|
this.selectedTheme = this.themes[1];
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'RadioButtonDoc': RadioButtonDoc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,237 @@
|
||||||
|
<template>
|
||||||
|
<div class="content-section documentation">
|
||||||
|
<TabView>
|
||||||
|
<TabPanel header="Documentation">
|
||||||
|
<h3>Import</h3>
|
||||||
|
<CodeHighlight lang="javascript">
|
||||||
|
import RadioButton from 'primevue/radiobutton';
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<h3>Getting Started</h3>
|
||||||
|
<p>Two-way value binding is defined using the standard v-model directive.</p>
|
||||||
|
<CodeHighlight>
|
||||||
|
<RadioButton inputId="city1" name="city" value="Chicago" v-model="city" />
|
||||||
|
<RadioButton inputId="city2" name="city" value="Los Angeles" v-model="city" />
|
||||||
|
</CodeHighlight>
|
||||||
|
<CodeHighlight lang="js">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
city: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
<p>As model is two-way binding enabled, giving a default value to the model is enough to display a radio button as checked by default.</p>
|
||||||
|
<CodeHighlight lang="js">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
city: 'Chicago'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</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 radiobutton.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>name</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Name of the checkbox element .</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>value</td>
|
||||||
|
<td>any</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Value of the radiobutton.</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>autofocus</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>When present, it specifies that the element should automatically get focus when the page loads.</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>
|
||||||
|
</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-radiobutton</td>
|
||||||
|
<td>Container element</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-radiobutton-box</td>
|
||||||
|
<td>Container of icon.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-radiobutton-icon</td>
|
||||||
|
<td>Icon element.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-radiobutton-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/radiobutton" 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>RadioButton</h1>
|
||||||
|
<p>RadioButton is an extension to standard radio button element with theming.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-section implementation">
|
||||||
|
<h3 class="first">Basic</h3>
|
||||||
|
<div class="p-grid">
|
||||||
|
<div class="p-col-12">
|
||||||
|
<RadioButton inputId="city1" name="city" value="Chicago" v-model="city" />
|
||||||
|
<label for="city1" class="p-radiobutton-label">Chicago</label>
|
||||||
|
</div>
|
||||||
|
<div class="p-col-12">
|
||||||
|
<RadioButton inputId="city2" name="city" value="Los Angeles" v-model="city" />
|
||||||
|
<label for="city2" class="p-radiobutton-label">Los Angeles</label>
|
||||||
|
</div>
|
||||||
|
<div class="p-col-12">
|
||||||
|
<RadioButton inputId="city3" name="city" value="New York" v-model="city" />
|
||||||
|
<label for="city3" class="p-radiobutton-label">New York</label>
|
||||||
|
</div>
|
||||||
|
<div class="p-col-12">
|
||||||
|
<RadioButton inputId="city4" name="city" value="San Francisco" v-model="city" />
|
||||||
|
<label for="city4" class="p-radiobutton-label">San Francisco</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p>Selected City: <span style="font-weight: bold">{{this.city}}</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">
|
||||||
|
<RadioButton :inputId="theme.key" name="theme" :value="theme" v-model="selectedTheme" :disabled="theme.key === 'U'" />
|
||||||
|
<label :for="theme.key" class="p-radiobutton-label">{{theme.name}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p>Selected Theme: <span style="font-weight: bold">{{this.selectedTheme}}</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="javascript">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
city: null,
|
||||||
|
themes: [{name: 'Apollo', key: 'A'}, {name: 'Babylon', key: 'B'}, {name: 'Serenity', key: 'S'}, {name: 'Ultima', key: 'U'}],
|
||||||
|
selectedTheme: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.selectedTheme = this.themes[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
</TabPanel>
|
||||||
|
</TabView>
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Reference in New Issue