@progress/kendo-vue-dropdowns 3.5.0-dev.202208020811 → 3.5.1-dev.202208110751

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/cdn/js/kendo-vue-dropdowns.js +1 -1
  2. package/dist/es/AutoComplete/AutoComplete.js +3 -3
  3. package/dist/es/AutoComplete/AutoCompleteProps.js +1 -0
  4. package/dist/es/ComboBox/ComboBox.js +4 -4
  5. package/dist/es/ComboBox/ComboBoxProps.d.ts +1 -1
  6. package/dist/es/ComboBox/ComboBoxProps.js +1 -0
  7. package/dist/es/DropDownList/DropDownList.js +5 -13
  8. package/dist/es/DropDownList/DropDownListProps.js +1 -0
  9. package/dist/es/MultiSelect/MultiSelect.js +16 -20
  10. package/dist/es/MultiSelect/MultiSelectProps.d.ts +1 -1
  11. package/dist/es/MultiSelect/MultiSelectProps.js +1 -0
  12. package/dist/es/MultiSelect/TagList.js +3 -3
  13. package/dist/es/common/List.js +2 -2
  14. package/dist/es/common/ListFilter.js +1 -1
  15. package/dist/es/common/events.js +1 -0
  16. package/dist/es/common/filterDescriptor.js +1 -0
  17. package/dist/es/package-metadata.js +1 -1
  18. package/dist/esm/AutoComplete/AutoComplete.d.ts +107 -0
  19. package/dist/esm/AutoComplete/AutoComplete.js +761 -0
  20. package/dist/esm/AutoComplete/AutoCompleteProps.d.ts +202 -0
  21. package/dist/esm/AutoComplete/AutoCompleteProps.js +2 -0
  22. package/dist/esm/ComboBox/ComboBox.d.ts +99 -0
  23. package/dist/esm/ComboBox/ComboBox.js +1063 -0
  24. package/dist/esm/ComboBox/ComboBoxProps.d.ts +244 -0
  25. package/dist/esm/ComboBox/ComboBoxProps.js +2 -0
  26. package/dist/esm/DropDownList/DropDownList.d.ts +100 -0
  27. package/dist/esm/DropDownList/DropDownList.js +1088 -0
  28. package/dist/esm/DropDownList/DropDownListProps.d.ts +274 -0
  29. package/dist/esm/DropDownList/DropDownListProps.js +2 -0
  30. package/dist/esm/MultiSelect/MultiSelect.d.ts +115 -0
  31. package/dist/esm/MultiSelect/MultiSelect.js +1249 -0
  32. package/dist/esm/MultiSelect/MultiSelectProps.d.ts +262 -0
  33. package/dist/esm/MultiSelect/MultiSelectProps.js +2 -0
  34. package/dist/esm/MultiSelect/TagList.d.ts +51 -0
  35. package/dist/esm/MultiSelect/TagList.js +180 -0
  36. package/dist/esm/additionalTypes.ts +21 -0
  37. package/dist/esm/common/ClearButton.d.ts +21 -0
  38. package/dist/esm/common/ClearButton.js +68 -0
  39. package/dist/esm/common/DropDownBase.d.ts +84 -0
  40. package/dist/esm/common/DropDownBase.js +303 -0
  41. package/dist/esm/common/List.d.ts +58 -0
  42. package/dist/esm/common/List.js +176 -0
  43. package/dist/esm/common/ListContainer.d.ts +40 -0
  44. package/dist/esm/common/ListContainer.js +131 -0
  45. package/dist/esm/common/ListDefaultItem.d.ts +29 -0
  46. package/dist/esm/common/ListDefaultItem.js +62 -0
  47. package/dist/esm/common/ListFilter.d.ts +46 -0
  48. package/dist/esm/common/ListFilter.js +112 -0
  49. package/dist/esm/common/ListItem.d.ts +71 -0
  50. package/dist/esm/common/ListItem.js +105 -0
  51. package/dist/esm/common/Navigation.d.ts +12 -0
  52. package/dist/esm/common/Navigation.js +34 -0
  53. package/dist/esm/common/SearchBar.d.ts +65 -0
  54. package/dist/esm/common/SearchBar.js +177 -0
  55. package/dist/esm/common/VirtualScroll.d.ts +42 -0
  56. package/dist/esm/common/VirtualScroll.js +196 -0
  57. package/dist/esm/common/events.d.ts +63 -0
  58. package/dist/esm/common/events.js +1 -0
  59. package/dist/esm/common/filterDescriptor.d.ts +41 -0
  60. package/dist/esm/common/filterDescriptor.js +2 -0
  61. package/dist/esm/common/settings.d.ts +102 -0
  62. package/dist/esm/common/settings.js +8 -0
  63. package/dist/esm/common/utils.d.ts +57 -0
  64. package/dist/esm/common/utils.js +184 -0
  65. package/dist/esm/main.d.ts +13 -0
  66. package/dist/esm/main.js +5 -0
  67. package/dist/esm/messages/index.d.ts +20 -0
  68. package/dist/esm/messages/index.js +21 -0
  69. package/dist/esm/package-metadata.d.ts +5 -0
  70. package/dist/esm/package-metadata.js +11 -0
  71. package/dist/esm/package.json +3 -0
  72. package/dist/npm/AutoComplete/AutoComplete.js +18 -18
  73. package/dist/npm/ComboBox/ComboBox.js +36 -36
  74. package/dist/npm/ComboBox/ComboBoxProps.d.ts +1 -1
  75. package/dist/npm/DropDownList/DropDownList.js +36 -44
  76. package/dist/npm/MultiSelect/MultiSelect.js +34 -38
  77. package/dist/npm/MultiSelect/MultiSelectProps.d.ts +1 -1
  78. package/dist/npm/MultiSelect/TagList.js +3 -3
  79. package/dist/npm/common/ClearButton.js +1 -1
  80. package/dist/npm/common/DropDownBase.js +6 -6
  81. package/dist/npm/common/List.js +8 -8
  82. package/dist/npm/common/ListContainer.js +1 -1
  83. package/dist/npm/common/ListDefaultItem.js +2 -2
  84. package/dist/npm/common/ListFilter.js +3 -3
  85. package/dist/npm/common/ListItem.js +2 -2
  86. package/dist/npm/common/Navigation.js +1 -1
  87. package/dist/npm/common/SearchBar.js +2 -2
  88. package/dist/npm/package-metadata.js +1 -1
  89. package/package.json +11 -5
@@ -0,0 +1,1088 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+
6
+ for (var p in s) {
7
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ }; // @ts-ignore
16
+
17
+
18
+ import * as Vue from 'vue';
19
+ var allVue = Vue;
20
+ var gh = allVue.h;
21
+ var isV3 = allVue.version && allVue.version[0] === '3';
22
+ var ref = allVue.ref;
23
+ import { templateRendering, getListeners, classNames, Keys, guid, noop, getTemplate, kendoThemeMaps, getTabIndex, setRef, getRef } from '@progress/kendo-vue-common';
24
+ import { Button as KButton } from '@progress/kendo-vue-buttons';
25
+ var sizeMap = kendoThemeMaps.sizeMap,
26
+ roundedMap = kendoThemeMaps.roundedMap;
27
+ import { ListContainer } from '../common/ListContainer.js';
28
+ import { ListFilter } from '../common/ListFilter.js';
29
+ import { ListDefaultItem } from '../common/ListDefaultItem.js';
30
+ import { List } from '../common/List.js';
31
+ import DropDownBase from '../common/DropDownBase.js';
32
+ import { isPresent, getItemValue, sameCharsOnly, shuffleData, matchText, areSame, preventDefaultNonInputs, getFocusedItem } from '../common/utils.js';
33
+ var VALIDATION_MESSAGE = 'Please select a value from the list!';
34
+ /**
35
+ * @hidden
36
+ */
37
+
38
+ var DropDownListVue2 = {
39
+ name: 'KendoDropDownList',
40
+ model: {
41
+ event: 'changemodel'
42
+ },
43
+ props: {
44
+ id: String,
45
+ title: String,
46
+ dataItemKey: {
47
+ type: [Object, String]
48
+ },
49
+ defaultValue: {
50
+ type: [String, Object, Number, Boolean],
51
+ default: undefined
52
+ },
53
+ name: String,
54
+ modelValue: {
55
+ type: [String, Object, Number, Boolean],
56
+ default: undefined
57
+ },
58
+ value: {
59
+ type: [String, Object, Number, Boolean],
60
+ default: undefined
61
+ },
62
+ label: {
63
+ type: String
64
+ },
65
+ required: {
66
+ type: Boolean,
67
+ default: false
68
+ },
69
+ leftRightKeysNavigation: {
70
+ type: Boolean,
71
+ default: true
72
+ },
73
+ valid: {
74
+ type: Boolean,
75
+ default: undefined
76
+ },
77
+ validate: {
78
+ type: Boolean
79
+ },
80
+ validationMessage: {
81
+ type: String,
82
+ default: undefined
83
+ },
84
+ validityStyles: {
85
+ type: Boolean,
86
+ default: true
87
+ },
88
+ delay: {
89
+ type: Number,
90
+ default: 500
91
+ },
92
+ ignoreCase: {
93
+ type: Boolean,
94
+ default: true
95
+ },
96
+ iconClassName: String,
97
+ defaultItem: [Object, String],
98
+ valueRender: [String, Function, Object],
99
+ valueMap: Function,
100
+ opened: {
101
+ type: Boolean,
102
+ default: undefined
103
+ },
104
+ disabled: Boolean,
105
+ dir: {
106
+ type: String,
107
+ default: undefined
108
+ },
109
+ tabIndex: {
110
+ type: Number,
111
+ default: 0
112
+ },
113
+ accessKey: String,
114
+ dataItems: Array,
115
+ textField: String,
116
+ valueField: String,
117
+ valuePrimitive: Boolean,
118
+ className: String,
119
+ loading: Boolean,
120
+ popupSettings: {
121
+ type: Object,
122
+ default: function _default() {
123
+ return {
124
+ animate: true,
125
+ height: '200px'
126
+ };
127
+ }
128
+ },
129
+ itemRender: [String, Function, Object],
130
+ listNoDataRender: [String, Function, Object],
131
+ focusedItemIndex: Function,
132
+ header: [String, Function, Object],
133
+ footer: [String, Function, Object],
134
+ filterable: Boolean,
135
+ filter: {
136
+ type: String,
137
+ default: undefined
138
+ },
139
+ virtual: {
140
+ type: Object,
141
+ default: undefined
142
+ },
143
+ ariaLabelledBy: String,
144
+ ariaDescribedBy: String,
145
+ rounded: {
146
+ type: String,
147
+ default: 'medium',
148
+ validator: function validator(value) {
149
+ return ['small', 'medium', 'large', 'full'].includes(value);
150
+ }
151
+ },
152
+ fillMode: {
153
+ type: String,
154
+ default: 'solid',
155
+ validator: function validator(value) {
156
+ return ['solid', 'flat', 'outline'].includes(value);
157
+ }
158
+ },
159
+ size: {
160
+ type: String,
161
+ default: 'medium',
162
+ validator: function validator(value) {
163
+ return ['small', 'medium', 'large'].includes(value);
164
+ }
165
+ }
166
+ },
167
+ data: function data() {
168
+ return {
169
+ hasMounted: false,
170
+ currentText: '',
171
+ currentValue: '',
172
+ currentFocused: false,
173
+ currentOpened: false,
174
+ searchState: {
175
+ word: '',
176
+ last: ''
177
+ },
178
+ _skipFocusEvent: false,
179
+ valueDuringOnChange: {},
180
+ _navigated: false
181
+ };
182
+ },
183
+ watch: {
184
+ currentOpened: function currentOpened(_, oldValue) {
185
+ // @ts-ignore
186
+ this.prevCurrentOpened = oldValue;
187
+ },
188
+ opened: function opened(_, oldValue) {
189
+ // @ts-ignore
190
+ this.prevOpened = oldValue;
191
+ },
192
+ virtual: function virtual(newValue, oldValue) {
193
+ if (newValue && oldValue && newValue.total !== oldValue.total) {
194
+ this.virtualTotalHasChanged = true;
195
+ }
196
+
197
+ this.virtualHasChanged = true;
198
+ }
199
+ },
200
+ created: function created() {
201
+ this.valueDuringOnChange = undefined;
202
+ this.currentText = undefined;
203
+ this.currentValue = undefined;
204
+ this.prevCurrentValue = this.computedValue();
205
+ this.currentFocused = undefined;
206
+ this.currentOpened = undefined;
207
+ this.base = new DropDownBase(this);
208
+ this.anchor = guid();
209
+ this.inputId = guid();
210
+ },
211
+ // @ts-ignore
212
+ setup: !isV3 ? undefined : function () {
213
+ var v3 = !!isV3;
214
+ var selectRef = ref(null);
215
+ var baseWrapperRef = ref(null);
216
+ var kendoAnchorRef = ref(null);
217
+ return {
218
+ v3: v3,
219
+ selectRef: selectRef,
220
+ baseWrapperRef: baseWrapperRef,
221
+ kendoAnchorRef: kendoAnchorRef
222
+ };
223
+ },
224
+ mounted: function mounted() {
225
+ this.hasMounted = true;
226
+ this.select = getRef(this, 'select');
227
+ this.base.wrapper = getRef(this, 'kendoAnchor', this.anchor);
228
+ this.base.didMount();
229
+ this.setValidity();
230
+ },
231
+ updated: function updated() {
232
+ var _a = this.$props,
233
+ _b = _a.dataItems,
234
+ dataItems = _b === void 0 ? [] : _b,
235
+ dataItemKey = _a.dataItemKey,
236
+ virtual = _a.virtual;
237
+ var opened = this.$props.opened !== undefined ? this.$props.opened : this.currentOpened;
238
+ var prevOpened = this.prevOpened !== undefined ? this.prevOpened : this.prevCurrentOpened;
239
+ var opening = !prevOpened && opened;
240
+ var closing = prevOpened && !opened;
241
+ var list = this.$refs.list;
242
+ var filterInput = this.$refs.filterInput;
243
+ var scrollElement = this.$refs.scrollElement;
244
+ var scroller = this.$refs.scroller;
245
+
246
+ if (list) {
247
+ // @ts-ignore
248
+ this.base.vs.list = list.list; // @ts-ignore
249
+
250
+ this.base.list = list.list;
251
+ }
252
+
253
+ if (scrollElement) {
254
+ this.base.vs.scrollElement = scrollElement;
255
+ }
256
+
257
+ if (filterInput) {
258
+ this.filterInput = filterInput;
259
+ }
260
+
261
+ if (list && dataItems.length) {
262
+ // @ts-ignore
263
+ this.base.vs.scrollerRef(list.$el);
264
+ }
265
+
266
+ if (!this.$props.popupSettings.animate) {
267
+ if (opening) {
268
+ this.onPopupOpened();
269
+ } else if (closing) {// this.onPopupClosed();
270
+ }
271
+ } // @ts-ignore
272
+
273
+
274
+ if (virtual && this.virtualTotalHasChanged) {
275
+ this.base.vs.calcScrollElementHeight();
276
+ this.base.vs.reset(); // @ts-ignore
277
+
278
+ this.virtualTotalHasChanged = false;
279
+ } else {
280
+ var selectedItem_1 = this.computedValue();
281
+ var prevSelectedItem = this.prevCurrentValue;
282
+ var selectedItemIndex = dataItems.findIndex(function (i) {
283
+ return areSame(i, selectedItem_1, dataItemKey);
284
+ });
285
+ var selectedItemChanged = !areSame(prevSelectedItem, selectedItem_1, dataItemKey);
286
+
287
+ if (opening && virtual) {
288
+ this.base.scrollToVirtualItem(virtual, selectedItemIndex);
289
+ this.prevCurrentOpened = true;
290
+ } else if (opening && !virtual) {
291
+ this.base.scrollToItem(selectedItemIndex);
292
+ this.prevCurrentOpened = true;
293
+ } else if (opened && prevOpened && selectedItem_1 && selectedItemChanged && !this._navigated) {
294
+ this.base.scrollToItem(selectedItemIndex);
295
+ } else if (opened && prevOpened && this._navigated) {
296
+ if (this._navigated && virtual && virtual.skip === 0) {
297
+ this.base.vs.reset();
298
+ } else if (this._navigated && virtual && virtual.skip === virtual.total - virtual.pageSize) {
299
+ this.base.vs.scrollToEnd();
300
+ }
301
+ }
302
+ }
303
+
304
+ this._navigated = false;
305
+ this.prevCurrentValue = this.computedValue();
306
+ this.setValidity();
307
+ },
308
+ computed: {
309
+ index: {
310
+ get: function get() {
311
+ var _a = this.$props,
312
+ _b = _a.dataItems,
313
+ dataItems = _b === void 0 ? [] : _b,
314
+ dataItemKey = _a.dataItemKey;
315
+ var value = this.computedValue(); // TO DO: deprecate it!
316
+
317
+ return dataItems.findIndex(function (i) {
318
+ return areSame(i, value, dataItemKey);
319
+ });
320
+ }
321
+ },
322
+ spanClassNames: {
323
+ get: function get() {
324
+ var isValid = !this.hasMounted || !this.$props.validityStyles || this.validity().valid;
325
+ return {
326
+ 'k-floating-label-container': true,
327
+ 'k-focus': this.currentFocused,
328
+ 'k-empty': !this.computedValue(),
329
+ 'k-invalid': !isValid && isValid !== undefined,
330
+ 'k-rtl': this.$props.dir === 'rtl'
331
+ };
332
+ }
333
+ }
334
+ },
335
+ methods: {
336
+ focus: function focus() {
337
+ if (this.base.wrapper) {
338
+ this.base.wrapper.focus();
339
+ }
340
+ },
341
+ computedValue: function computedValue() {
342
+ var value;
343
+
344
+ if (this.valueDuringOnChange !== undefined) {
345
+ value = this.valueDuringOnChange;
346
+ } else if (this.$props.value !== undefined) {
347
+ value = this.$props.value;
348
+ } else if (this.$props.modelValue !== undefined) {
349
+ value = this.$props.modelValue;
350
+ } else if (this.currentValue !== undefined) {
351
+ value = this.currentValue;
352
+ } else if (this.$props.defaultValue !== undefined) {
353
+ value = this.$props.defaultValue;
354
+ }
355
+
356
+ if (!isPresent(value) && this.$props.defaultItem !== undefined) {
357
+ value = this.$props.defaultItem;
358
+ }
359
+
360
+ return this.valuePrimitive ? this.findByFieldValue(this.valueField, value) || value : value;
361
+ },
362
+ findByFieldValue: function findByFieldValue(field, value) {
363
+ var index = this.dataItems.findIndex(function (i) {
364
+ return getItemValue(i, field) === value;
365
+ });
366
+ return this.dataItems[index];
367
+ },
368
+ primitiveValue: function primitiveValue() {
369
+ var value = this.computedValue();
370
+ return this.valuePrimitive ? getItemValue(value, this.valueField) : value;
371
+ },
372
+ validity: function validity() {
373
+ var customError = this.$props.validationMessage !== undefined;
374
+ var isValid = !this.$props.required || this.computedValue() !== null && this.computedValue() !== '' && this.computedValue() !== undefined;
375
+ var valid = this.$props.valid !== undefined ? this.$props.valid : isValid;
376
+ return {
377
+ customError: customError,
378
+ valid: valid,
379
+ valueMissing: this.computedValue() === null
380
+ };
381
+ },
382
+ handleItemSelect: function handleItemSelect(index, state) {
383
+ var _a = this.$props,
384
+ _b = _a.dataItems,
385
+ dataItems = _b === void 0 ? [] : _b,
386
+ virtual = _a.virtual,
387
+ dataItemKey = _a.dataItemKey,
388
+ defaultItem = _a.defaultItem;
389
+ var skip = virtual ? virtual.skip : 0;
390
+ var item = index === -1 && defaultItem !== undefined ? defaultItem : dataItems[index - skip];
391
+ var newSelected = !areSame(item, this.computedValue(), dataItemKey);
392
+ this.triggerOnChange(item, state);
393
+
394
+ if (newSelected) {
395
+ this.base.triggerPageChangeCornerItems(item, state);
396
+ }
397
+ },
398
+ onNavigate: function onNavigate(state, keyCode) {
399
+ var _a = this.$props,
400
+ _b = _a.dataItems,
401
+ dataItems = _b === void 0 ? [] : _b,
402
+ defaultItem = _a.defaultItem,
403
+ dataItemKey = _a.dataItemKey,
404
+ _c = _a.virtual,
405
+ virtual = _c === void 0 ? {
406
+ skip: 0,
407
+ total: 0,
408
+ pageSize: 0
409
+ } : _c;
410
+ var vs = this.base.vs;
411
+ var value = this.computedValue();
412
+ var index = dataItems.findIndex(function (i) {
413
+ return areSame(i, value, dataItemKey);
414
+ });
415
+ var newIndex = this.base.navigation.navigate({
416
+ current: virtual.skip + index,
417
+ max: (vs.enabled ? virtual.total : dataItems.length) - 1,
418
+ min: defaultItem !== undefined ? -1 : 0,
419
+ keyCode: keyCode
420
+ });
421
+
422
+ if (newIndex !== undefined) {
423
+ this.handleItemSelect(newIndex, state);
424
+ }
425
+
426
+ this.applyState(state);
427
+ },
428
+ search: function search(event) {
429
+ var _this = this;
430
+
431
+ clearTimeout(this.typingTimeout);
432
+
433
+ if (!this.$props.filterable) {
434
+ this.typingTimeout = setTimeout(function () {
435
+ return _this.searchState.word = '';
436
+ }, this.$props.delay);
437
+ this.selectNext(event);
438
+ }
439
+ },
440
+ selectNext: function selectNext(event) {
441
+ var _this = this;
442
+
443
+ var _a = this.$props,
444
+ _b = _a.dataItems,
445
+ dataItems = _b === void 0 ? [] : _b,
446
+ dataItemKey = _a.dataItemKey;
447
+ var mappedData = dataItems.map(function (item, idx) {
448
+ return {
449
+ item: item,
450
+ itemIndex: idx
451
+ };
452
+ });
453
+ var word = this.searchState.word;
454
+ var last = this.searchState.last;
455
+ var isInLoop = sameCharsOnly(word, last);
456
+ var dataLength = mappedData.length;
457
+ var startIndex = Math.max(0, dataItems.findIndex(function (i) {
458
+ return areSame(i, _this.computedValue(), dataItemKey);
459
+ }));
460
+ var defaultItem;
461
+
462
+ if (this.$props.defaultItem) {
463
+ defaultItem = {
464
+ item: this.$props.defaultItem,
465
+ itemIndex: -1
466
+ };
467
+ dataLength += 1;
468
+ startIndex += 1;
469
+ }
470
+
471
+ startIndex += isInLoop ? 1 : 0;
472
+ mappedData = shuffleData(mappedData, startIndex, defaultItem);
473
+ var text,
474
+ loopMatch,
475
+ nextMatch,
476
+ index = 0;
477
+ var _c = this.$props,
478
+ textField = _c.textField,
479
+ ignoreCase = _c.ignoreCase;
480
+
481
+ for (; index < dataLength; index++) {
482
+ text = getItemValue(mappedData[index].item, textField);
483
+ loopMatch = isInLoop && matchText(text, last, ignoreCase);
484
+ nextMatch = matchText(text, word, ignoreCase);
485
+
486
+ if (loopMatch || nextMatch) {
487
+ index = mappedData[index].itemIndex;
488
+ break;
489
+ }
490
+ }
491
+
492
+ if (index !== dataLength) {
493
+ var state = this.base.initState();
494
+ state.event = event;
495
+ this.handleItemSelect(index, state);
496
+ this.applyState(state);
497
+ this.valueDuringOnChange = undefined;
498
+ }
499
+ },
500
+ handleKeyDown: function handleKeyDown(event) {
501
+ var _a = this.$props,
502
+ _b = _a.dataItems,
503
+ dataItems = _b === void 0 ? [] : _b,
504
+ leftRightKeysNavigation = _a.leftRightKeysNavigation,
505
+ filterable = _a.filterable,
506
+ disabled = _a.disabled,
507
+ _c = _a.virtual,
508
+ virtual = _c === void 0 ? {
509
+ skip: 0,
510
+ total: 0,
511
+ pageSize: 0
512
+ } : _c;
513
+ var opened = this.$props.opened !== undefined ? this.$props.opened : this.currentOpened;
514
+ var keyCode = event.keyCode;
515
+ var homeOrEndKeys = keyCode === Keys.home || keyCode === Keys.end;
516
+ var upOrDownKeys = keyCode === Keys.up || keyCode === Keys.down;
517
+ var shouldOpen = !opened && (event.altKey && keyCode === Keys.down || keyCode === Keys.enter || keyCode === Keys.space);
518
+ var shouldClose = opened && (event.altKey && keyCode === Keys.up || keyCode === Keys.esc);
519
+ var leftOrRightKeys = leftRightKeysNavigation && (keyCode === Keys.left || keyCode === Keys.right);
520
+ var shouldNavigate = upOrDownKeys || !filterable && (leftOrRightKeys || homeOrEndKeys);
521
+ var state = this.base.initState();
522
+ state.event = event;
523
+
524
+ if (disabled) {
525
+ return;
526
+ } else if (homeOrEndKeys && this.base.vs.enabled) {
527
+ if (keyCode === Keys.home) {
528
+ if (virtual.skip !== 0) {
529
+ this.base.triggerOnPageChange(state, 0, virtual.pageSize);
530
+ this._navigated = true;
531
+ } else {
532
+ this.triggerOnChange(dataItems[0], state);
533
+ }
534
+ } else {
535
+ if (virtual.skip < virtual.total - virtual.pageSize) {
536
+ this.base.triggerOnPageChange(state, virtual.total - virtual.pageSize, virtual.pageSize);
537
+ this._navigated = true;
538
+ } else {
539
+ this.triggerOnChange(dataItems[dataItems.length - 1], state);
540
+ }
541
+ }
542
+ } else if (opened && keyCode === Keys.enter) {
543
+ var focusedIndex = this.focusedIndex();
544
+
545
+ if (focusedIndex !== undefined) {
546
+ this.handleItemSelect(focusedIndex, state);
547
+ }
548
+
549
+ this.base.togglePopup(state);
550
+ event.preventDefault();
551
+ } else if (shouldOpen || shouldClose) {
552
+ this.base.togglePopup(state);
553
+ event.preventDefault();
554
+ } else if (shouldNavigate) {
555
+ this.onNavigate(state, keyCode);
556
+ event.preventDefault();
557
+ }
558
+
559
+ this.applyState(state);
560
+ },
561
+ handleItemClick: function handleItemClick(index, event) {
562
+ this.base.handleItemClick(index, event);
563
+ this.valueDuringOnChange = undefined;
564
+ },
565
+ handleFocus: function handleFocus(event) {
566
+ if (this._skipFocusEvent) {
567
+ return;
568
+ }
569
+
570
+ this.base.handleFocus(event);
571
+ },
572
+ handleBlur: function handleBlur(event) {
573
+ if (this._skipFocusEvent || !this.currentFocused) {
574
+ return;
575
+ }
576
+
577
+ var opened = this.$props.opened !== undefined ? this.$props.opened : this.currentOpened;
578
+ var state = this.base.initState();
579
+ state.event = event;
580
+ state.data.currentFocused = false;
581
+ state.events.push({
582
+ type: 'blur'
583
+ });
584
+
585
+ if (opened) {
586
+ this.base.togglePopup(state);
587
+ }
588
+
589
+ this.applyState(state);
590
+ },
591
+ handleDefaultItemClick: function handleDefaultItemClick(event) {
592
+ var state = this.base.initState();
593
+ state.event = event;
594
+ this.base.togglePopup(state);
595
+ this.triggerOnChange(this.$props.defaultItem, state);
596
+ this.applyState(state);
597
+ },
598
+ handleWrapperClick: function handleWrapperClick(event) {
599
+ var state = this.base.initState();
600
+ state.event = event;
601
+
602
+ if (!this.currentFocused) {
603
+ // @ts-ignore
604
+ state.data.currentFocused = true;
605
+ }
606
+
607
+ this.base.togglePopup(state);
608
+ this.applyState(state);
609
+ },
610
+ handleKeyPress: function handleKeyPress(event) {
611
+ if (this.$props.filterable || event.keyCode === Keys.enter) {
612
+ return;
613
+ }
614
+
615
+ var character = String.fromCharCode(event.charCode || event.keyCode);
616
+
617
+ if (this.$props.ignoreCase) {
618
+ character = character.toLowerCase();
619
+ }
620
+
621
+ if (character === ' ') {
622
+ event.preventDefault();
623
+ }
624
+
625
+ this.searchState = {
626
+ word: this.searchState.word + character,
627
+ last: this.searchState.last + character
628
+ };
629
+ this.search(event);
630
+ },
631
+ handleListFilterChange: function handleListFilterChange(event) {
632
+ var state = this.base.initState();
633
+ state.event = event;
634
+
635
+ if (this.$props.filter === undefined) {
636
+ // @ts-ignore
637
+ state.data.currentText = event.target.value;
638
+ }
639
+
640
+ this.base.filterChanged(event.target.value, state);
641
+ this.applyState(state);
642
+ },
643
+ onPopupOpened: function onPopupOpened() {
644
+ if (this.filterInput) {
645
+ this.focusElement(this.filterInput.input);
646
+ }
647
+ },
648
+ onPopupClosed: function onPopupClosed() {
649
+ var _this = this;
650
+
651
+ if (this.currentFocused) {
652
+ setTimeout(function () {
653
+ if (_this.currentFocused && _this.base.wrapper) {
654
+ _this.focusElement(_this.base.wrapper);
655
+ }
656
+ });
657
+ }
658
+ },
659
+ focusedIndex: function focusedIndex() {
660
+ var filterText = isPresent(this.$props.filter) ? this.$props.filter : this.currentText;
661
+ var _a = this.$props,
662
+ _b = _a.dataItems,
663
+ dataItems = _b === void 0 ? [] : _b,
664
+ _c = _a.virtual,
665
+ virtual = _c === void 0 ? {
666
+ skip: 0
667
+ } : _c,
668
+ dataItemKey = _a.dataItemKey,
669
+ textField = _a.textField,
670
+ focusedItemIndex = _a.focusedItemIndex;
671
+ var value = this.computedValue();
672
+ var selectedIndex = dataItems.findIndex(function (i) {
673
+ return areSame(i, value, dataItemKey);
674
+ });
675
+ var hasSelected = !(selectedIndex < 0 && !this.$props.defaultItem);
676
+
677
+ if (!hasSelected && filterText && virtual.skip === 0) {
678
+ return focusedItemIndex ? focusedItemIndex(dataItems, filterText, textField) : dataItems.indexOf(getFocusedItem(dataItems, filterText, textField));
679
+ } else {
680
+ return !hasSelected && virtual.skip === 0 ? 0 : undefined;
681
+ }
682
+ },
683
+ focusElement: function focusElement(element) {
684
+ var _this = this;
685
+
686
+ this._skipFocusEvent = true;
687
+ element.focus();
688
+ setTimeout(function () {
689
+ return _this._skipFocusEvent = false;
690
+ }, 30);
691
+ },
692
+ setValidity: function setValidity() {
693
+ if (this.select && this.select.setCustomValidity) {
694
+ this.select.setCustomValidity(this.validity().valid ? '' : this.$props.validationMessage || VALIDATION_MESSAGE);
695
+ }
696
+ },
697
+ triggerOnChange: function triggerOnChange(item, state) {
698
+ if (areSame(this.computedValue(), item, this.$props.dataItemKey)) {
699
+ return;
700
+ }
701
+
702
+ if (this.$props.value === undefined) {
703
+ this.currentValue = item;
704
+ }
705
+
706
+ this.valueDuringOnChange = item;
707
+ state.events.push({
708
+ type: 'change'
709
+ });
710
+ },
711
+ applyState: function applyState(state) {
712
+ this.base.applyState(state);
713
+ this.valueDuringOnChange = undefined;
714
+ }
715
+ },
716
+ render: function render(createElement) {
717
+ var _a;
718
+
719
+ var h = gh || createElement;
720
+ var _b = this.$props,
721
+ style = _b.style,
722
+ className = _b.className,
723
+ label = _b.label,
724
+ dir = _b.dir,
725
+ _c = _b.virtual,
726
+ virtual = _c === void 0 ? {
727
+ skip: 0
728
+ } : _c,
729
+ size = _b.size,
730
+ rounded = _b.rounded,
731
+ fillMode = _b.fillMode;
732
+ var opened = this.$props.opened !== undefined ? this.$props.opened : this.currentOpened;
733
+ var text = getItemValue(this.computedValue(), this.$props.textField);
734
+ var isValid = !this.$props.validityStyles || this.validity().valid;
735
+ var base = this.base;
736
+ var vs = base.vs;
737
+ var id = this.$props.id || this.inputId;
738
+ vs.enabled = this.$props.virtual !== undefined;
739
+ var popupSettings = Object.assign({}, {
740
+ animate: true,
741
+ height: '200px'
742
+ }, this.$props.popupSettings);
743
+ var _d = this.$props,
744
+ dataItemKey = _d.dataItemKey,
745
+ _e = _d.dataItems,
746
+ dataItems = _e === void 0 ? [] : _e,
747
+ disabled = _d.disabled,
748
+ tabIndex = _d.tabIndex,
749
+ loading = _d.loading,
750
+ iconClassName = _d.iconClassName;
751
+ var valueRender = templateRendering.call(this, this.$props.valueRender, getListeners.call(this));
752
+ var focused = this.currentFocused;
753
+ var value = this.primitiveValue();
754
+ var selectedIndex = dataItems.findIndex(function (i) {
755
+ return areSame(i, value, dataItemKey);
756
+ });
757
+ var valueDefaultRendering = h("span", {
758
+ "class": "k-input-inner"
759
+ }, [h("span", {
760
+ "class": "k-input-value-text"
761
+ }, [text])]);
762
+ var valueElement = getTemplate.call(this, {
763
+ h: h,
764
+ template: valueRender,
765
+ defaultRendering: valueDefaultRendering,
766
+ additionalProps: __assign({
767
+ value: this.computedValue()
768
+ }, this.$data)
769
+ });
770
+
771
+ var dummySelect = function dummySelect(cvalue) {
772
+ /* Dummy component to support forms */
773
+ return h("select", {
774
+ name: this.$props.name,
775
+ attrs: this.v3 ? undefined : {
776
+ name: this.$props.name,
777
+ id: id,
778
+ tabindex: -1,
779
+ "aria-hidden": true,
780
+ title: this.$props.label
781
+ },
782
+ id: id,
783
+ ref: setRef(this, 'select'),
784
+ tabindex: -1,
785
+ "aria-hidden": true,
786
+ title: this.$props.label,
787
+ style: {
788
+ opacity: 0,
789
+ width: 1,
790
+ border: 0,
791
+ zIndex: -1,
792
+ position: 'absolute',
793
+ left: '50%'
794
+ }
795
+ }, [h("option", {
796
+ value: this.v3 ? this.$props.valueMap ? this.$props.valueMap.call(undefined, cvalue) : cvalue : null,
797
+ domProps: this.v3 ? undefined : {
798
+ "value": this.$props.valueMap ? this.$props.valueMap.call(undefined, cvalue) : cvalue
799
+ }
800
+ })]);
801
+ };
802
+
803
+ var renderDefaultItem = function renderDefaultItem() {
804
+ var _a = this.$props,
805
+ textField = _a.textField,
806
+ defaultItem = _a.defaultItem;
807
+ return defaultItem !== undefined && // @ts-ignore
808
+ h(ListDefaultItem, {
809
+ defaultItem: defaultItem,
810
+ attrs: this.v3 ? undefined : {
811
+ defaultItem: defaultItem,
812
+ textField: textField,
813
+ selected: areSame(this.computedValue(), defaultItem, dataItemKey)
814
+ },
815
+ textField: textField,
816
+ selected: areSame(this.computedValue(), defaultItem, dataItemKey),
817
+ key: "defaultitemkey",
818
+ onDefaultitemclick: this.handleDefaultItemClick,
819
+ on: this.v3 ? undefined : {
820
+ "defaultitemclick": this.handleDefaultItemClick
821
+ }
822
+ });
823
+ };
824
+
825
+ var renderList = function renderList() {
826
+ var _this2 = this;
827
+
828
+ var textField = this.$props.textField;
829
+ var itemRender = templateRendering.call(this, this.$props.itemRender, getListeners.call(this));
830
+ var listNoDataRender = templateRendering.call(this, this.$props.listNoDataRender, getListeners.call(this));
831
+ var skip = virtual.skip;
832
+ var translate = "translateY(".concat(vs.translate, "px)");
833
+ return (// @ts-ignore function children
834
+ h(List, {
835
+ id: this.base.listBoxId,
836
+ attrs: this.v3 ? undefined : {
837
+ id: this.base.listBoxId,
838
+ show: opened,
839
+ dataItems: dataItems.slice(),
840
+ focusedIndex: this.focusedIndex(),
841
+ value: this.computedValue(),
842
+ textField: textField,
843
+ valueField: dataItemKey,
844
+ optionsGuid: this.base.guid,
845
+ wrapperStyle: {
846
+ maxHeight: popupSettings.height
847
+ },
848
+ wrapperCssClass: 'k-list-content',
849
+ listStyle: vs.enabled ? {
850
+ transform: translate
851
+ } : undefined,
852
+ skip: skip,
853
+ itemRender: itemRender,
854
+ noDataRender: listNoDataRender
855
+ },
856
+ show: opened,
857
+ dataItems: dataItems.slice(),
858
+ focusedIndex: this.focusedIndex(),
859
+ value: this.computedValue(),
860
+ textField: textField,
861
+ valueField: dataItemKey,
862
+ optionsGuid: this.base.guid,
863
+ ref: 'list',
864
+ wrapperStyle: {
865
+ maxHeight: popupSettings.height
866
+ },
867
+ wrapperCssClass: 'k-list-content',
868
+ listStyle: vs.enabled ? {
869
+ transform: translate
870
+ } : undefined,
871
+ key: "listkey",
872
+ skip: skip,
873
+ onListclick: this.handleItemClick,
874
+ on: this.v3 ? undefined : {
875
+ "listclick": this.handleItemClick,
876
+ "scroll": vs.scrollHandler
877
+ },
878
+ itemRender: itemRender,
879
+ noDataRender: listNoDataRender,
880
+ onScroll: vs.scrollHandler
881
+ }, this.v3 ? function () {
882
+ return [renderScrollElement.call(_this2)];
883
+ } : [renderScrollElement.call(_this2)])
884
+ );
885
+ };
886
+
887
+ var renderListFilter = function renderListFilter() {
888
+ var filterText = this.$props.filter !== undefined ? this.$props.filter : this.currentText;
889
+ return this.$props.filterable && // @ts-ignore
890
+ h(ListFilter, {
891
+ value: filterText,
892
+ attrs: this.v3 ? undefined : {
893
+ value: filterText,
894
+ size: this.$props.size,
895
+ rounded: this.$props.rounded,
896
+ fillMode: this.$props.fillMode
897
+ },
898
+ ref: 'filterInput',
899
+ onChange: this.handleListFilterChange,
900
+ on: this.v3 ? undefined : {
901
+ "change": this.handleListFilterChange,
902
+ "keydown": this.handleKeyDown
903
+ },
904
+ onKeydown: this.handleKeyDown,
905
+ size: this.$props.size,
906
+ rounded: this.$props.rounded,
907
+ fillMode: this.$props.fillMode
908
+ });
909
+ };
910
+
911
+ var renderScrollElement = function renderScrollElement() {
912
+ return vs.enabled && h("div", {
913
+ ref: 'scrollElement',
914
+ key: 'scrollElementKey'
915
+ });
916
+ };
917
+
918
+ var renderListContainer = function renderListContainer() {
919
+ var _this3 = this;
920
+
921
+ var _a;
922
+
923
+ var headerTemplate = templateRendering.call(this, this.$props.header, getListeners.call(this));
924
+ var footerTemplate = templateRendering.call(this, this.$props.footer, getListeners.call(this));
925
+ var header = getTemplate.call(this, {
926
+ h: h,
927
+ template: headerTemplate
928
+ });
929
+ var footer = getTemplate.call(this, {
930
+ h: h,
931
+ template: footerTemplate
932
+ });
933
+ var popupWidth = popupSettings.width !== undefined ? popupSettings.width : base.popupWidth;
934
+ return (// @ts-ignore function children
935
+ h(ListContainer, {
936
+ onMousedown: preventDefaultNonInputs,
937
+ on: this.v3 ? undefined : {
938
+ "mousedown": preventDefaultNonInputs,
939
+ "open": this.onPopupOpened,
940
+ "close": this.onPopupClosed,
941
+ "blur": this.handleBlur
942
+ },
943
+ dir: dir !== undefined ? dir : base.dirCalculated,
944
+ attrs: this.v3 ? undefined : {
945
+ dir: dir !== undefined ? dir : base.dirCalculated,
946
+ width: popupWidth // @ts-ignore
947
+ ,
948
+ popupSettings: {
949
+ popupClass: classNames(popupSettings.popupClass, 'k-list', (_a = {}, _a["k-list-".concat(sizeMap[size] || size)] = size, _a['k-virtual-list'] = this.base.vs.enabled, _a)),
950
+ className: popupSettings.className,
951
+ animate: popupSettings.animate,
952
+ anchor: this.anchor,
953
+ show: opened
954
+ }
955
+ },
956
+ width: popupWidth,
957
+ popupSettings: {
958
+ popupClass: classNames(popupSettings.popupClass, 'k-list', (_a = {}, _a["k-list-".concat(sizeMap[size] || size)] = size, _a['k-virtual-list'] = this.base.vs.enabled, _a)),
959
+ className: popupSettings.className,
960
+ animate: popupSettings.animate,
961
+ anchor: this.anchor,
962
+ show: opened
963
+ },
964
+ onOpen: this.onPopupOpened,
965
+ onClose: this.onPopupClosed,
966
+ onBlur: this.handleBlur
967
+ }, this.v3 ? function () {
968
+ return [renderListFilter.call(_this3), renderDefaultItem.call(_this3), header && h("div", {
969
+ "class": "k-list-header"
970
+ }, [header]), renderList.call(_this3), footer && h("div", {
971
+ "class": "k-list-footer"
972
+ }, [footer])];
973
+ } : [renderListFilter.call(_this3), renderDefaultItem.call(_this3), header && h("div", {
974
+ "class": "k-list-header"
975
+ }, [header]), renderList.call(_this3), footer && h("div", {
976
+ "class": "k-list-footer"
977
+ }, [footer])])
978
+ );
979
+ };
980
+
981
+ if (this.$props.virtual !== undefined) {
982
+ base.vs.skip = virtual.skip; // @ts-ignore
983
+
984
+ base.vs.total = virtual.total; // @ts-ignore
985
+
986
+ base.vs.pageSize = virtual.pageSize;
987
+ }
988
+
989
+ var dropdownlist = h("span", {
990
+ ref: setRef(this, 'kendoAnchor', this.anchor),
991
+ "class": classNames('k-dropdownlist k-picker', className, (_a = {}, _a["k-picker-".concat(sizeMap[size] || size)] = size, _a["k-rounded-".concat(roundedMap[rounded] || rounded)] = rounded, _a["k-picker-".concat(fillMode)] = fillMode, _a['k-focus'] = focused, _a['k-disabled'] = disabled, _a['k-invalid'] = !isValid, _a['k-loading'] = loading, _a['k-required'] = this.required, _a)),
992
+ style: !label ? style : __assign(__assign({}, style), {
993
+ width: undefined
994
+ }),
995
+ dir: dir,
996
+ attrs: this.v3 ? undefined : {
997
+ dir: dir,
998
+ tabindex: getTabIndex(tabIndex, disabled),
999
+ accesskey: this.$props.accessKey,
1000
+ role: 'listbox',
1001
+ "aria-disabled": disabled || undefined,
1002
+ "aria-haspopup": true,
1003
+ "aria-expanded": opened || false,
1004
+ "aria-owns": this.base.listBoxId,
1005
+ "aria-activedescendant": opened ? 'option-' + this.base.guid + '-' + (selectedIndex + (virtual ? virtual.skip : 0)) : undefined,
1006
+ "aria-label": this.$props.label,
1007
+ "aria-labelledby": this.$props.ariaLabelledBy,
1008
+ "aria-describedby": this.$props.ariaDescribedBy,
1009
+ id: this.$props.id,
1010
+ title: this.$props.title
1011
+ },
1012
+ onMousedown: opened ? preventDefaultNonInputs : noop,
1013
+ on: this.v3 ? undefined : {
1014
+ "mousedown": opened ? preventDefaultNonInputs : noop,
1015
+ "focusin": this.handleFocus,
1016
+ "focusout": this.handleBlur,
1017
+ "keydown": this.handleKeyDown,
1018
+ "keypress": this.handleKeyPress,
1019
+ "click": disabled ? noop : this.handleWrapperClick
1020
+ },
1021
+ onFocusin: this.handleFocus,
1022
+ onFocusout: this.handleBlur,
1023
+ tabindex: getTabIndex(tabIndex, disabled),
1024
+ accesskey: this.$props.accessKey,
1025
+ onKeydown: this.handleKeyDown,
1026
+ onKeypress: this.handleKeyPress,
1027
+ role: 'listbox',
1028
+ onClick: disabled ? noop : this.handleWrapperClick,
1029
+ "aria-disabled": disabled || undefined,
1030
+ "aria-haspopup": true,
1031
+ "aria-expanded": opened || false,
1032
+ "aria-owns": this.base.listBoxId,
1033
+ "aria-activedescendant": opened ? 'option-' + this.base.guid + '-' + (selectedIndex + (virtual ? virtual.skip : 0)) : undefined,
1034
+ "aria-label": this.$props.label,
1035
+ "aria-labelledby": this.$props.ariaLabelledBy,
1036
+ "aria-describedby": this.$props.ariaDescribedBy,
1037
+ id: this.$props.id,
1038
+ title: this.$props.title
1039
+ }, [valueElement, loading && h("span", {
1040
+ "class": "k-icon k-input-loading-icon k-i-loading",
1041
+ key: "loading"
1042
+ }), // @ts-ignore
1043
+ h(KButton, {
1044
+ type: "button",
1045
+ attrs: this.v3 ? undefined : {
1046
+ type: "button",
1047
+ tabIndex: -1,
1048
+ size: size,
1049
+ fillMode: fillMode,
1050
+ rounded: null,
1051
+ iconClass: classNames('k-icon k-i-arrow-s', iconClassName)
1052
+ },
1053
+ tabIndex: -1,
1054
+ size: size,
1055
+ fillMode: fillMode,
1056
+ rounded: null,
1057
+ "class": 'k-input-button',
1058
+ iconClass: classNames('k-icon k-i-arrow-s', iconClassName)
1059
+ }), dummySelect.call(this, value), renderListContainer.call(this)]);
1060
+ return label ? h("span", {
1061
+ "class": this.spanClassNames,
1062
+ onFocusin: this.handleFocus,
1063
+ on: this.v3 ? undefined : {
1064
+ "focusin": this.handleFocus,
1065
+ "focusout": this.handleBlur
1066
+ },
1067
+ onFocusout: this.handleBlur,
1068
+ dir: this.$props.dir,
1069
+ attrs: this.v3 ? undefined : {
1070
+ dir: this.$props.dir
1071
+ }
1072
+ }, [dropdownlist, this.$props.label ? id ? h("label", {
1073
+ "for": id,
1074
+ attrs: this.v3 ? undefined : {
1075
+ "for": id
1076
+ },
1077
+ "class": "k-label"
1078
+ }, [this.$props.label]) : h("span", {
1079
+ "class": "k-label"
1080
+ }, [this.$props.label]) : null]) : dropdownlist;
1081
+ }
1082
+ };
1083
+ /**
1084
+ * @hidden
1085
+ */
1086
+
1087
+ var DropDownList = DropDownListVue2;
1088
+ export { DropDownList, DropDownListVue2 };