@v4fire/client
Version:
V4Fire client core library
119 lines (76 loc) • 2.4 kB
Markdown
This module provides a component to create a radio button.
* The component extends [[bCheckbox]].
* The component is used as functional if there is no provided the `dataProvider` prop.
* The component can be used as flyweight.
* By default, the root tag of the component is `<span>`.
* The component contains an `<input>` tag within.
* The component has `skeletonMarker`.
See the parent component and the component traits.
See the parent component and the component traits.
```
< b-radio-button :name = 'adult' | :value = 0
< b-radio-button :name = 'adult' | :value = 1 | :checked = true
< b-radio-button @change = doSomething
```
You free to use any ways to define a label.
```
< b-radio-button :name = 'adult' | :label = 'Are you over 18?'
< label
Are you over 18?
< b-radio-button :name = 'adult2'
< label for = adult3
Are you over 18?
< b-radio-button :id = 'adult3' | :name = 'adult3'
```
To group radio buttons, use the same name.
```
< b-radio-button :name = 'registration' | :value = 'agree'
< b-radio-button :name = 'registration' | :value = 'subscribe'
```
```
< b-radio-button :dataProvider = 'AdultProvider'
```
If a provider returns a dictionary, it will be mapped on the component
(you can pass the complex property path using dots as separators).
If a key from the response is matched with a component method, this method will be invoked with a value from this key
(if the value is an array, it will be spread to the method as arguments).
```
{
value: true,
label: 'Are you over 18?',
'mods.focused': true
}
```
In other cases, the response value is interpreted as a component value.
The component supports a few of slots to provide:
1. `check` to provide radio button UI.
```
< b-radio-button
< template
< .check-ui :data-status = ctx.mods.checked
```
2. `label` to provide label UI.
```
< b-radio-button
< template
< .label
{{ label }}
```
Also, you can see the parent component and the component traits.
If true, the checkbox can be unchecked directly after the first check.
```
< b-radio-button :name = 'bar' | :changeable = true | :checked = true
```