Fixed #1711 - Better types for selects

pull/1280/head^2
Cagatay Civici 2021-11-17 13:06:47 +03:00
parent 45d4a5ac46
commit ad8e2796f7
8 changed files with 43 additions and 28 deletions

View File

@ -1,12 +1,16 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
type CascadeSelectOptionLabelType = string | ((data: any) => string) | undefined;
type CascadeSelectOptionValueType = string | ((data: any) => any) | undefined;
type CascadeSelectOptionChildrenType = string[] | string | ((data: any) => any[]) | undefined;
interface CascadeSelectProps { interface CascadeSelectProps {
modelValue?: any; modelValue?: any;
options?: any[]; options?: any[];
optionLabel?: string; optionLabel?: CascadeSelectOptionLabelType;
optionValue?: any; optionValue?: CascadeSelectOptionValueType;
optionGroupLabel?: string; optionGroupLabel?: CascadeSelectOptionLabelType;
optionGroupChildren?: string[]; optionGroupChildren?: CascadeSelectOptionChildrenType;
placeholder?: string; placeholder?: string;
disabled?: boolean; disabled?: boolean;
dataKey?: string; dataKey?: string;

View File

@ -1,16 +1,19 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
import VirtualScrollerProps from '../virtualscroller'; import VirtualScrollerProps from '../virtualscroller';
type DropdownOptionLabelType = string | ((data: any) => string) | undefined;
type DropdownOptionValueType = string | ((data: any) => any) | undefined;
type DropdownOptionDisabledType = string | ((data: any) => boolean) | undefined; type DropdownOptionDisabledType = string | ((data: any) => boolean) | undefined;
type DropdownOptionChildrenType = string | ((data: any) => any[]) | undefined;
interface DropdownProps { interface DropdownProps {
modelValue?: any; modelValue?: any;
options?: any[]; options?: any[];
optionLabel?: string; optionLabel?: DropdownOptionLabelType;
optionValue?: any; optionValue?: DropdownOptionValueType;
optionDisabled?: DropdownOptionDisabledType; optionDisabled?: DropdownOptionDisabledType;
optionGroupLabel?: string; optionGroupLabel?: DropdownOptionLabelType;
optionGroupChildren?: string; optionGroupChildren?: DropdownOptionChildrenType;
scrollHeight?: string; scrollHeight?: string;
filter?: boolean; filter?: boolean;
filterPlaceholder?: string; filterPlaceholder?: string;

View File

@ -1,16 +1,19 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
import VirtualScrollerProps from '../virtualscroller'; import VirtualScrollerProps from '../virtualscroller';
type ListboxOptionLabelType = string | ((data: any) => string) | undefined;
type ListboxOptionValueType = string | ((data: any) => any) | undefined;
type ListboxOptionDisabledType = string | ((data: any) => boolean) | undefined; type ListboxOptionDisabledType = string | ((data: any) => boolean) | undefined;
type ListboxOptionChildrenType = string | ((data: any) => any[]) | undefined;
interface ListboxProps { interface ListboxProps {
modelValue?: any; modelValue?: any;
options?: any[]; options?: any[];
optionLabel?: string; optionLabel?: ListboxOptionLabelType;
optionValue?: any; optionValue?: ListboxOptionValueType;
optionDisabled?: ListboxOptionDisabledType; optionDisabled?: ListboxOptionDisabledType;
optionGroupLabel?: string; optionGroupLabel?: ListboxOptionLabelType;
optionGroupChildren?: string; optionGroupChildren?: ListboxOptionChildrenType;
listStyle?: string; listStyle?: string;
disabled?: boolean; disabled?: boolean;
dataKey?: string; dataKey?: string;

View File

@ -1,16 +1,19 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
import VirtualScrollerProps from '../virtualscroller'; import VirtualScrollerProps from '../virtualscroller';
type MultiSelectOptionLabelType = string | ((data: any) => string) | undefined;
type MultiSelectOptionValueType = string | ((data: any) => any) | undefined;
type MultiSelectOptionDisabledType = string | ((data: any) => boolean) | undefined; type MultiSelectOptionDisabledType = string | ((data: any) => boolean) | undefined;
type MultiSelectOptionChildrenType = string | ((data: any) => any[]) | undefined;
interface MultiSelectProps { interface MultiSelectProps {
modelValue?: any; modelValue?: any;
options?: any[]; options?: any[];
optionLabel?: string; optionLabel?: MultiSelectOptionLabelType;
optionValue?: any; optionValue?: MultiSelectOptionValueType;
optionDisabled?: MultiSelectOptionDisabledType; optionDisabled?: MultiSelectOptionDisabledType;
optionGroupLabel?: string; optionGroupLabel?: MultiSelectOptionLabelType;
optionGroupChildren?: string; optionGroupChildren?: MultiSelectOptionChildrenType;
scrollHeight?: string; scrollHeight?: string;
placeholder?: string; placeholder?: string;
disabled?: boolean; disabled?: boolean;

View File

@ -1,10 +1,12 @@
type SelectButtonOptionLabelType = string | ((data: any) => string) | undefined;
type SelectButtonOptionValueType = string | ((data: any) => any) | undefined;
type SelectButtonOptionDisabledType = string | ((data: any) => boolean) | undefined; type SelectButtonOptionDisabledType = string | ((data: any) => boolean) | undefined;
interface SelectButtonProps { interface SelectButtonProps {
modelValue?: any; modelValue?: any;
options?: any[]; options?: any[];
optionLabel?: string; optionLabel?: SelectButtonOptionLabelType;
optionValue?: any; optionValue?: SelectButtonOptionValueType;
optionDisabled?: SelectButtonOptionDisabledType; optionDisabled?: SelectButtonOptionDisabledType;
multiple?: boolean; multiple?: boolean;
disabled?: boolean; disabled?: boolean;

View File

@ -145,13 +145,13 @@ export default {
</tr> </tr>
<tr> <tr>
<td>optionLabel</td> <td>optionLabel</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the label of an option.</td> <td>Property name or getter function to use as the label of an option.</td>
</tr> </tr>
<tr> <tr>
<td>optionValue</td> <td>optionValue</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the value of an option, defaults to the option itself when not defined.</td> <td>Property name or getter function to use as the value of an option, defaults to the option itself when not defined.</td>
</tr> </tr>
@ -163,13 +163,13 @@ export default {
</tr> </tr>
<tr> <tr>
<td>optionGroupLabel</td> <td>optionGroupLabel</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the label of an option group.</td> <td>Property name or getter function to use as the label of an option group.</td>
</tr> </tr>
<tr> <tr>
<td>optionGroupChildren</td> <td>optionGroupChildren</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function that refers to the children options of option group.</td> <td>Property name or getter function that refers to the children options of option group.</td>
</tr> </tr>

View File

@ -154,13 +154,13 @@ export default {
</tr> </tr>
<tr> <tr>
<td>optionLabel</td> <td>optionLabel</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the label of an option.</td> <td>Property name or getter function to use as the label of an option.</td>
</tr> </tr>
<tr> <tr>
<td>optionValue</td> <td>optionValue</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the value of an option, defaults to the option itself when not defined.</td> <td>Property name or getter function to use as the value of an option, defaults to the option itself when not defined.</td>
</tr> </tr>
@ -172,13 +172,13 @@ export default {
</tr> </tr>
<tr> <tr>
<td>optionGroupLabel</td> <td>optionGroupLabel</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the label of an option group.</td> <td>Property name or getter function to use as the label of an option group.</td>
</tr> </tr>
<tr> <tr>
<td>optionGroupChildren</td> <td>optionGroupChildren</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function that refers to the children options of option group.</td> <td>Property name or getter function that refers to the children options of option group.</td>
</tr> </tr>

View File

@ -84,13 +84,13 @@ export default {
</tr> </tr>
<tr> <tr>
<td>optionLabel</td> <td>optionLabel</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the label of an option.</td> <td>Property name or getter function to use as the label of an option.</td>
</tr> </tr>
<tr> <tr>
<td>optionValue</td> <td>optionValue</td>
<td>string</td> <td>string | function</td>
<td>null</td> <td>null</td>
<td>Property name or getter function to use as the value of an option, defaults to the option itself when not defined.</td> <td>Property name or getter function to use as the value of an option, defaults to the option itself when not defined.</td>
</tr> </tr>