mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #28018 from silh/master
Added support for vue-select library.
This commit is contained in:
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
// Type definitions for vue-select 2.4
|
||||
// Project: https://github.com/sagalbot/vue-select#readme
|
||||
// Definitions by: Ilia Beliaev <https://github.com/silh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { VueConstructor } from 'vue';
|
||||
|
||||
export default VueSelect;
|
||||
export const VueSelect: VueSelectConstructor;
|
||||
export type OptionConsumer = (option: any) => void;
|
||||
|
||||
export interface VueSelectProps {
|
||||
value: any;
|
||||
options: any[];
|
||||
disabled: boolean;
|
||||
maxHeight: string;
|
||||
searchable: boolean;
|
||||
multiple: boolean;
|
||||
placeholder: string;
|
||||
transition: string;
|
||||
clearSearchOnSelect: boolean;
|
||||
closeOnSelect: boolean;
|
||||
label: string;
|
||||
getOptionLabel: (option: any) => string;
|
||||
onChange: OptionConsumer;
|
||||
taggable: boolean;
|
||||
tabindex: number | null;
|
||||
pushTags: boolean;
|
||||
filterable: boolean;
|
||||
createOption: (option: any) => any;
|
||||
resetOnOptionsChange: boolean;
|
||||
noDrop: boolean;
|
||||
inputId: string | null;
|
||||
dir: string;
|
||||
}
|
||||
|
||||
export interface VueSelectData {
|
||||
search: string;
|
||||
open: boolean;
|
||||
mutableValue: any;
|
||||
mutableOptions: any[];
|
||||
}
|
||||
|
||||
export interface VueSelectWatch {
|
||||
value: (val: any) => void;
|
||||
mutableValue: (val: any, old: any) => void;
|
||||
options: (val: any) => void;
|
||||
mutableOptions: () => void;
|
||||
multiple: (reset: boolean) => void;
|
||||
created: () => void;
|
||||
}
|
||||
|
||||
export interface VueSelectMethods {
|
||||
select: OptionConsumer;
|
||||
deselect: OptionConsumer;
|
||||
clearSelection: () => void;
|
||||
onAfterSelect: OptionConsumer;
|
||||
toggleDropdown: (e: Event) => void;
|
||||
isOptionSelected: (option: any) => boolean;
|
||||
onEscape: () => void;
|
||||
onSearchBlur: () => void;
|
||||
onSearchFocus: () => void;
|
||||
maybeDeleteValue: () => void;
|
||||
optionExists: (option: any) => boolean;
|
||||
maybePushTag: OptionConsumer;
|
||||
}
|
||||
|
||||
export interface VueSelectComputed {
|
||||
dropdownClasses: () => DropdownClasses;
|
||||
clearSearchOnBlur: () => boolean;
|
||||
searching: () => boolean;
|
||||
dropdownOpen: () => boolean;
|
||||
searchPlaceholder: () => boolean;
|
||||
filteredOptions: () => any[];
|
||||
isValueEmpty: () => boolean;
|
||||
valueAsArray: () => any[];
|
||||
showClearButton: () => boolean;
|
||||
}
|
||||
|
||||
export interface DropdownClasses {
|
||||
open: boolean;
|
||||
single: boolean;
|
||||
searching: boolean;
|
||||
searchable: boolean;
|
||||
unsearchable: boolean;
|
||||
loading: boolean;
|
||||
rtl: boolean;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
export interface VueSelectConstructor extends VueConstructor {
|
||||
props: VueSelectProps;
|
||||
data: () => VueSelectData;
|
||||
watch: VueSelectWatch;
|
||||
methods: VueSelectMethods;
|
||||
computed: VueSelectComputed;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"vue": ">=2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"vue-select-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,65 @@
|
||||
import Vue from 'vue';
|
||||
import VueSelect from 'vue-select';
|
||||
|
||||
const options = [
|
||||
{
|
||||
name: 'SomeName'
|
||||
},
|
||||
{
|
||||
name: 'SomeName2'
|
||||
}
|
||||
];
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
options,
|
||||
value: null,
|
||||
},
|
||||
components: {
|
||||
'vue-select': VueSelect
|
||||
},
|
||||
methods: {
|
||||
getOptionLabel(option: any) {
|
||||
if (option && option.name) {
|
||||
return option.name;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
optionConsumer(option: any) {
|
||||
},
|
||||
optionToOption(option: any) {
|
||||
return option;
|
||||
},
|
||||
onSearch(search: string, loading: (b: boolean) => void) {
|
||||
loading(true);
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<vue-select :filterable="false"
|
||||
:value="value"
|
||||
:options="options"
|
||||
disable="false"
|
||||
maxHeight="200"
|
||||
searchable="true"
|
||||
multiple="false"
|
||||
placeholder="Placeholder"
|
||||
transition="SomeTransition"
|
||||
clearSearchOnSelect="false"
|
||||
:closeOnSelect="false"
|
||||
label="name"
|
||||
:getOptionLabel="getOptionLabel"
|
||||
:onChange="optionConsumer"
|
||||
:taggable="true"
|
||||
:tabindex="null"
|
||||
pushTags="false"
|
||||
:createOption="optionToOption"
|
||||
resetOnOptionsChange="false"
|
||||
noDrop="true"
|
||||
:inputId="null"
|
||||
dir="someDir"
|
||||
@search="onSearch"
|
||||
@input="optionConsumer">
|
||||
</vue-select>
|
||||
`
|
||||
});
|
||||
Reference in New Issue
Block a user