|
|
@@ -52,6 +52,32 @@ app.use(Checkbox).use(CheckboxGroup).use(Icon);
|
|
|
|
|
|
:::
|
|
|
|
|
|
+## Semi selective
|
|
|
+
|
|
|
+:::demo
|
|
|
+
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <nut-cell>
|
|
|
+ <nut-checkbox v-model="checkbox9" :indeterminate="true" label="check box">check box</nut-checkbox>
|
|
|
+ </nut-cell>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { reactive, toRefs } from 'vue';
|
|
|
+ export default {
|
|
|
+ props: {},
|
|
|
+ setup() {
|
|
|
+ const state = reactive({
|
|
|
+ checkbox9: true
|
|
|
+ });
|
|
|
+ return { ...toRefs(state) };
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+```
|
|
|
+
|
|
|
+:::
|
|
|
+
|
|
|
## Disabled state
|
|
|
|
|
|
:::demo
|
|
|
@@ -203,8 +229,9 @@ When the value changes, the `change` event will be triggered
|
|
|
<nut-checkbox v-for="item in checkboxsource" :key="item.label" :label="item.label">{{item.value}}</nut-checkbox>
|
|
|
</nut-checkboxgroup>
|
|
|
<span class="btn">
|
|
|
- <nut-button type="primary" @click="toggleAll(true)">Select all</nut-button>
|
|
|
- <nut-button type="primary" @click="toggleAll(false)">cancel</nut-button>
|
|
|
+ <nut-button type="primary" @click="toggleAll(true)" style="margin: 0 20px 0 0">Select all</nut-button>
|
|
|
+ <nut-button type="primary" @click="toggleAll(false)" style="margin: 0 20px 0 0">cancel</nut-button>
|
|
|
+ <nut-button type="warning" @click="toggleReverse()">reverse selection</nut-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
@@ -217,7 +244,11 @@ When the value changes, the `change` event will be triggered
|
|
|
checkboxgroup3: ['2'],
|
|
|
checkboxsource: [
|
|
|
{label: '1', value: 'Combined check box'},
|
|
|
- {label: '2', value: 'Combined check box'}
|
|
|
+ {label: '2', value: 'Combined check box'},
|
|
|
+ {label: '3', value: 'Combined check box'},
|
|
|
+ {label: '4', value: 'Combined check box'},
|
|
|
+ {label: '5', value: 'Combined check box'},
|
|
|
+ {label: '6', value: 'Combined check box'}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
@@ -230,6 +261,11 @@ When the value changes, the `change` event will be triggered
|
|
|
(group.value as any).toggleAll(f);
|
|
|
};
|
|
|
|
|
|
+ const toggleReverse = () => {
|
|
|
+ Toast.text(`reverse selection`);
|
|
|
+ group.value.toggleReverse();
|
|
|
+ };
|
|
|
+
|
|
|
return { ...toRefs(state), group, changeBox4, toggleAll };
|
|
|
}
|
|
|
};
|
|
|
@@ -238,6 +274,100 @@ When the value changes, the `change` event will be triggered
|
|
|
|
|
|
:::
|
|
|
|
|
|
+## use checkboxGroup, Limit the maximum number of options (2)
|
|
|
+
|
|
|
+:::demo
|
|
|
+
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <nut-cell-group title="use checkboxGroup, Limit the maximum number of options (2)">
|
|
|
+ <nut-cell>
|
|
|
+ <nut-checkboxgroup v-model="checkboxgroup4" :max="2">
|
|
|
+ <nut-checkbox label="1" style="margin: 2px 20px 0 0">Combined check box</nut-checkbox>
|
|
|
+ <nut-checkbox label="2">Combined check box</nut-checkbox>
|
|
|
+ <nut-checkbox label="3" style="margin: 2px 20px 0 0">Combined check box</nut-checkbox>
|
|
|
+ <nut-checkbox label="4">Combined check box</nut-checkbox>
|
|
|
+ </nut-checkboxgroup>
|
|
|
+ </nut-cell>
|
|
|
+ <nut-cell>
|
|
|
+ <div class="demo-check">selected</div>
|
|
|
+ <div>{{ checkboxgroup4 }}</div>
|
|
|
+ </nut-cell>
|
|
|
+ </nut-cell-group>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { reactive, toRefs } from 'vue';
|
|
|
+ import { Toast } from '@nutui/nutui';
|
|
|
+ export default {
|
|
|
+ props: {},
|
|
|
+ setup() {
|
|
|
+ const state = reactive({
|
|
|
+ checkboxgroup4: ['2']
|
|
|
+ });
|
|
|
+
|
|
|
+ return { ...toRefs(state) };
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+```
|
|
|
+
|
|
|
+:::
|
|
|
+
|
|
|
+## Select all / half / cancel
|
|
|
+
|
|
|
+:::demo
|
|
|
+
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <nut-cell-group title="Select all / half / cancel">
|
|
|
+ <nut-cell>
|
|
|
+ <nut-checkbox :indeterminate="indeterminate" v-model="checkbox10" @change="changeBox5">selectAll</nut-checkbox>
|
|
|
+ </nut-cell>
|
|
|
+ <nut-checkboxgroup v-model="checkboxgroup5" ref="group2" @change="changeBox6">
|
|
|
+ <nut-cell><nut-checkbox label="1" style="margin: 2px 20px 0 0">Combined check box</nut-checkbox></nut-cell>
|
|
|
+ <nut-cell><nut-checkbox label="2">Combined check box</nut-checkbox></nut-cell>
|
|
|
+ <nut-cell><nut-checkbox label="3">Combined check box</nut-checkbox></nut-cell>
|
|
|
+ <nut-cell><nut-checkbox label="4">Combined check box</nut-checkbox></nut-cell>
|
|
|
+ </nut-checkboxgroup>
|
|
|
+ </nut-cell-group>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { reactive, toRefs,ref, Ref } from 'vue';
|
|
|
+ import { Toast } from '@nutui/nutui';
|
|
|
+ export default {
|
|
|
+ props: {},
|
|
|
+ setup() {
|
|
|
+ const group2 = ref(null) as Ref;
|
|
|
+ const state = reactive({
|
|
|
+ indeterminate: true,
|
|
|
+ checkbox10: false,
|
|
|
+ checkboxgroup5: [],
|
|
|
+ });
|
|
|
+
|
|
|
+ const changeBox5 = (value: boolean) => {
|
|
|
+ group2.value.toggleAll(value);
|
|
|
+ };
|
|
|
+
|
|
|
+ const changeBox6 = (label: string[]) => {
|
|
|
+ if(label.length === 4) {
|
|
|
+ state.indeterminate = false;
|
|
|
+ state.checkbox10 = true;
|
|
|
+ } else if(label.length && label.length < 4){
|
|
|
+ state.indeterminate = true;
|
|
|
+ state.checkbox10 = true;
|
|
|
+ } else {
|
|
|
+ state.checkbox10 = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ return { ...toRefs(state), group2, changeBox5, changeBox6 };
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+```
|
|
|
+
|
|
|
+:::
|
|
|
+
|
|
|
## Checkbox
|
|
|
|
|
|
| Attribute | Description | Type | Default
|
|
|
@@ -247,10 +377,12 @@ When the value changes, the `change` event will be triggered
|
|
|
| text-position | The position of the text, optional value:`left`,`right` | String | `right`
|
|
|
| icon-size | [Icon Size](#/en-US/icon) | String、Number | `18`
|
|
|
| icon-name | [Icon Name](#/en-US/icon),Before selection (it is suggested to modify it together with `icon-active-name`) | String | `'check-normal'`
|
|
|
-| icon-active-name | [Icon Name](#/en-US/icon),After selection (it is suggested to modify it together with `icon-name`) | String | `'checked'`
|
|
|
+| icon-active-name | [Icon Name](#/en-US/icon),After selection (it is suggested to modify it together with `icon-name`) | String | `'checked'`
|
|
|
+| icon-indeterminate-name | [Icon Name](#/en-US/icon),Semi selected state | String | `'check-disabled'`
|
|
|
| icon-class-prefix | Custom icon class name prefix, used to use custom icons | String | `nut-icon`
|
|
|
| icon-font-class-name | Basic class name of custom icon font | String | `nutui-iconfont`
|
|
|
| label | Text content of the check box | String | -
|
|
|
+| indeterminate | Whether half selection status is currently supported. It is generally used in select all operation | Boolean | `false` |
|
|
|
|
|
|
|
|
|
## CheckboxGroup
|
|
|
@@ -259,6 +391,7 @@ When the value changes, the `change` event will be triggered
|
|
|
|----- | ----- | ----- | -----
|
|
|
| v-model | Identifier of the currently selected item, corresponding to `label` | Array | -
|
|
|
| disabled | Whether to disable the selection, which will be used for all check boxes under it | Boolean | `false`
|
|
|
+| max | Limit the number of choices. It cannot be used with select all / cancel / invert selection. `0 'means there is no limit | Number | `0`
|
|
|
|
|
|
|
|
|
|
|
|
@@ -273,3 +406,10 @@ When the value changes, the `change` event will be triggered
|
|
|
| Event | Description | Arguments
|
|
|
|----- | ----- | -----
|
|
|
| change | Triggered when the value changes | label,`label` returns an array representing the collection of currently selected items
|
|
|
+
|
|
|
+## CheckboxGroup API
|
|
|
+
|
|
|
+| methodName | Description | Arguments
|
|
|
+|----- | ----- | -----
|
|
|
+| toggleAll | Select all / cancel | `f`,`true`,to select all,`false`,cancel the selection
|
|
|
+| toggleReverse | Reverse selection | -
|