|
1 | 1 | // Type definitions originally for Vue-Multislect 2.1.0, rebuilt and tested with Vue 3 version
|
2 | 2 | // Originally written by: Akshay Jat https://github.com/akki-jat
|
3 |
| -import Vue from 'vue'; |
| 3 | +import { DefineComponent } from 'vue'; |
4 | 4 |
|
5 |
| -declare class Multiselect extends Vue { |
6 |
| - activate: () => void |
7 |
| - deactivate: () => void |
| 5 | +export interface MultiselectMixinOptions { |
| 6 | + /** |
| 7 | + * Decide whether to filter the results based on search query. |
| 8 | + * Useful for async filtering, where we search through more complex data. |
| 9 | + * @type {Boolean} |
| 10 | + */ |
| 11 | + internalSearch?: boolean; |
| 12 | + /** |
| 13 | + * Array of available options: Objects, Strings or Integers. |
| 14 | + * If array of objects, visible label will default to option.label. |
| 15 | + * If `labal` prop is passed, label will equal option['label'] |
| 16 | + * @type {Array} |
| 17 | + */ |
| 18 | + options: Array<string | number> | Array<any>; |
| 19 | + /** |
| 20 | + * Equivalent to the `multiple` attribute on a `<select>` input. |
| 21 | + * @default false |
| 22 | + * @type {Boolean} |
| 23 | + */ |
| 24 | + multiple?: boolean; |
| 25 | + /** |
| 26 | + * Key to compare objects |
| 27 | + * @default 'id' |
| 28 | + * @type {String} |
| 29 | + */ |
| 30 | + trackBy?: string; |
| 31 | + /** |
| 32 | + * Label to look for in option Object |
| 33 | + * @default 'label' |
| 34 | + * @type {String} |
| 35 | + */ |
| 36 | + label?: string; |
| 37 | + /** |
| 38 | + * Enable/disable search in options |
| 39 | + * @default true |
| 40 | + * @type {Boolean} |
| 41 | + */ |
| 42 | + searchable?: boolean; |
| 43 | + /** |
| 44 | + * Clear the search input after `) |
| 45 | + * @default true |
| 46 | + * @type {Boolean} |
| 47 | + */ |
| 48 | + clearOnSelect?: boolean; |
| 49 | + /** |
| 50 | + * Hide already selected options |
| 51 | + * @default false |
| 52 | + * @type {Boolean} |
| 53 | + */ |
| 54 | + hideSelected?: boolean; |
| 55 | + /** |
| 56 | + * Equivalent to the `placeholder` attribute on a `<select>` input. |
| 57 | + * @default 'Select option' |
| 58 | + * @type {String} |
| 59 | + */ |
| 60 | + placeholder?: string; |
| 61 | + /** |
| 62 | + * Allow to remove all selected values |
| 63 | + * @default true |
| 64 | + * @type {Boolean} |
| 65 | + */ |
| 66 | + allowEmpty?: boolean; |
| 67 | + /** |
| 68 | + * Reset this.internalValue, this.search after this.internalValue changes. |
| 69 | + * Useful if want to create a stateless dropdown. |
| 70 | + * @default false |
| 71 | + * @type {Boolean} |
| 72 | + */ |
| 73 | + resetAfter?: boolean; |
| 74 | + /** |
| 75 | + * Enable/disable closing after selecting an option |
| 76 | + * @default true |
| 77 | + * @type {Boolean} |
| 78 | + */ |
| 79 | + closeOnSelect?: boolean; |
| 80 | + /** |
| 81 | + * Function to interpolate the custom label |
| 82 | + * @default false |
| 83 | + * @type {Function} |
| 84 | + */ |
| 85 | + customLabel?: (option: any, label: any) => string; |
| 86 | + /** |
| 87 | + * Disable / Enable tagging |
| 88 | + * @default false |
| 89 | + * @type {Boolean} |
| 90 | + */ |
| 91 | + taggable?: boolean; |
| 92 | + /** |
| 93 | + * String to show when highlighting a potential tag |
| 94 | + * @default 'Press enter to create a tag' |
| 95 | + * @type {String} |
| 96 | + */ |
| 97 | + tagPlaceholder?: string; |
| 98 | + /** |
| 99 | + * By default new tags will appear above the search results. |
| 100 | + * Changing to 'bottom' will revert this behaviour |
| 101 | + * and will proritize the search results |
| 102 | + * @default 'top' |
| 103 | + * @type {String} |
| 104 | + */ |
| 105 | + tagPosition?: string; |
| 106 | + /** |
| 107 | + * Number of allowed selected options. No limit if 0. |
| 108 | + * @default 0 |
| 109 | + * @type {Number} |
| 110 | + */ |
| 111 | + max?: number | boolean; |
| 112 | + /** |
| 113 | + * Will be passed with all events as second param. |
| 114 | + * Useful for identifying events origin. |
| 115 | + * @default null |
| 116 | + * @type {String|Integer} |
| 117 | + */ |
| 118 | + id?: string | number | null; |
| 119 | + /** |
| 120 | + * Limits the options displayed in the dropdown |
| 121 | + * to the first X options. |
| 122 | + * @default 1000 |
| 123 | + * @type {Integer} |
| 124 | + */ |
| 125 | + optionsLimit?: number; |
| 126 | + /** |
| 127 | + * Name of the property containing |
| 128 | + * the group values |
| 129 | + * @default 1000 |
| 130 | + * @type {String} |
| 131 | + */ |
| 132 | + groupValues?: string; |
| 133 | + /** |
| 134 | + * Name of the property containing |
| 135 | + * the group label |
| 136 | + * @default 1000 |
| 137 | + * @type {String} |
| 138 | + */ |
| 139 | + groupLabel?: string; |
| 140 | + /** |
| 141 | + * Allow to select all group values |
| 142 | + * by selecting the group label |
| 143 | + * @default false |
| 144 | + * @type {Boolean} |
| 145 | + */ |
| 146 | + groupSelect?: boolean; |
| 147 | + /** |
| 148 | + * Array of keyboard keys to block |
| 149 | + * when selecting |
| 150 | + * @default 1000 |
| 151 | + * @type {String} |
| 152 | + */ |
| 153 | + blockKeys?: string[]; |
| 154 | + /** |
| 155 | + * Prevent from wiping up the search value |
| 156 | + * @default false |
| 157 | + * @type {Boolean} |
| 158 | + */ |
| 159 | + preserveSearch?: boolean; |
| 160 | + /** |
| 161 | + * Select 1st options if value is empty |
| 162 | + * @default false |
| 163 | + * @type {Boolean} |
| 164 | + */ |
| 165 | + preselectFirst?: boolean; |
| 166 | + /** |
| 167 | + * Prevent autofocus |
| 168 | + * @default false |
| 169 | + * @type {Boolean} |
| 170 | + */ |
| 171 | + preventAutofocus?: boolean; |
| 172 | + /** |
| 173 | + * Allows a custom function for sorting search/filtered results. |
| 174 | + * @default null |
| 175 | + * @type {Function} |
| 176 | + */ |
| 177 | + filteringSortFunc?: (a: any, b: any) => number; |
8 | 178 | }
|
9 |
| -declare class multiselectMixin extends Vue { } |
10 |
| -declare class pointerMixin extends Vue { } |
| 179 | + |
| 180 | +export interface PointerMixinOptions { |
| 181 | + /** |
| 182 | + * Enable/disable highlighting of the pointed value. |
| 183 | + * @type {Boolean} |
| 184 | + * @default true |
| 185 | + */ |
| 186 | + showPointer?: boolean; |
| 187 | + optionHeight?: number; |
| 188 | +} |
| 189 | + |
| 190 | +export const multiselectMixin: DefineComponent<MultiselectMixinOptions>; |
| 191 | +export const pointerMixin: DefineComponent<PointerMixinOptions>; |
| 192 | +export const Multiselect: DefineComponent< |
| 193 | + { |
| 194 | + /** |
| 195 | + * name attribute to match optional label element |
| 196 | + * @default '' |
| 197 | + * @type {String} |
| 198 | + */ |
| 199 | + name?: string; |
| 200 | + /** |
| 201 | + * Presets the selected options value. |
| 202 | + * @type {Object||Array||String||Integer} |
| 203 | + */ |
| 204 | + modelValue?: object | any[] | string | number; |
| 205 | + /** |
| 206 | + * String to show when pointing to an option |
| 207 | + * @default 'Press enter to select' |
| 208 | + * @type {String} |
| 209 | + */ |
| 210 | + selectLabel?: string; |
| 211 | + /** |
| 212 | + * String to show when pointing to an option |
| 213 | + * @default 'Press enter to select' |
| 214 | + * @type {String} |
| 215 | + */ |
| 216 | + selectGroupLabel?: string; |
| 217 | + /** |
| 218 | + * String to show next to selected option |
| 219 | + * @default 'Selected' |
| 220 | + * @type {String} |
| 221 | + */ |
| 222 | + selectedLabel?: string; |
| 223 | + /** |
| 224 | + * String to show when pointing to an already selected option |
| 225 | + * @default 'Press enter to remove' |
| 226 | + * @type {String} |
| 227 | + */ |
| 228 | + deselectLabel?: string; |
| 229 | + /** |
| 230 | + * String to show when pointing to an already selected option |
| 231 | + * @default 'Press enter to remove' |
| 232 | + * @type {String} |
| 233 | + */ |
| 234 | + deselectGroupLabel?: string; |
| 235 | + /** |
| 236 | + * Decide whether to show pointer labels |
| 237 | + * @default true |
| 238 | + * @type {Boolean} |
| 239 | + */ |
| 240 | + showLabels?: boolean; |
| 241 | + /** |
| 242 | + * Limit the display of selected options. The rest will be hidden within the limitText string. |
| 243 | + * @default 99999 |
| 244 | + * @type {Integer} |
| 245 | + */ |
| 246 | + limit?: number; |
| 247 | + /** |
| 248 | + * Sets maxHeight style value of the dropdown |
| 249 | + * @default 300 |
| 250 | + * @type {Integer} |
| 251 | + */ |
| 252 | + maxHeight?: number; |
| 253 | + /** |
| 254 | + * Function that process the message shown when selected |
| 255 | + * elements pass the defined limit. |
| 256 | + * @default 'and * more' |
| 257 | + * @param {Int} count Number of elements more than limit |
| 258 | + * @type {Function} |
| 259 | + */ |
| 260 | + limitText?: (count: number) => string; |
| 261 | + /** |
| 262 | + * Set true to trigger the loading spinner. |
| 263 | + * @default False |
| 264 | + * @type {Boolean} |
| 265 | + */ |
| 266 | + loading?: boolean; |
| 267 | + /** |
| 268 | + * Disables the multiselect if true. |
| 269 | + * @default false |
| 270 | + * @type {Boolean} |
| 271 | + */ |
| 272 | + disabled?: boolean; |
| 273 | + /** |
| 274 | + * Enables search input's spellcheck if true. |
| 275 | + * @default false |
| 276 | + * @type {Boolean} |
| 277 | + */ |
| 278 | + spellcheck?: boolean; |
| 279 | + /** |
| 280 | + * Fixed opening direction |
| 281 | + * @default '' |
| 282 | + * @type {String} |
| 283 | + */ |
| 284 | + openDirection?: string; |
| 285 | + /** |
| 286 | + * Shows slot with message about empty options |
| 287 | + * @default true |
| 288 | + * @type {Boolean} |
| 289 | + */ |
| 290 | + showNoOptions?: boolean; |
| 291 | + showNoResults?: boolean; |
| 292 | + tabindex?: number; |
| 293 | + required?: boolean; |
| 294 | + }, |
| 295 | + {}, |
| 296 | + {}, |
| 297 | + {}, |
| 298 | + { activate(): void; deactivate(): void }, |
| 299 | + typeof multiselectMixin | typeof pointerMixin |
| 300 | +>; |
11 | 301 |
|
12 | 302 | export default Multiselect;
|
13 |
| -export { Multiselect, multiselectMixin, pointerMixin }; |
|
0 commit comments