@progress/kendo-vue-dropdowns 3.9.3 → 3.9.4-dev.202304210655

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 (65) hide show
  1. package/dist/cdn/js/kendo-vue-dropdowns.js +1 -1
  2. package/dist/es/ComboBox/ComboBox.js +3 -1
  3. package/dist/es/DropDownTree/DropDownTree.d.ts +1 -0
  4. package/dist/es/DropDownTree/DropDownTree.js +639 -0
  5. package/dist/es/DropDownTree/DropDownTreeProps.d.ts +278 -0
  6. package/dist/es/DropDownTree/DropDownTreeProps.js +2 -0
  7. package/dist/es/DropDownTree/ListNoData.d.ts +42 -0
  8. package/dist/es/DropDownTree/ListNoData.js +32 -0
  9. package/dist/es/DropDownTree/useDropdownWidth.d.ts +4 -0
  10. package/dist/es/DropDownTree/useDropdownWidth.js +10 -0
  11. package/dist/es/MultiSelectTree/MultiSelectTree.d.ts +48 -0
  12. package/dist/es/MultiSelectTree/MultiSelectTree.js +896 -0
  13. package/dist/es/MultiSelectTree/MultiSelectTreeProps.d.ts +306 -0
  14. package/dist/es/MultiSelectTree/MultiSelectTreeProps.js +2 -0
  15. package/dist/es/MultiSelectTree/utils.d.ts +17 -0
  16. package/dist/es/MultiSelectTree/utils.js +109 -0
  17. package/dist/es/common/ListFilter.js +15 -3
  18. package/dist/es/common/utils.d.ts +6 -1
  19. package/dist/es/common/utils.js +10 -1
  20. package/dist/es/main.d.ts +5 -1
  21. package/dist/es/main.js +5 -1
  22. package/dist/es/package-metadata.js +1 -1
  23. package/dist/esm/ComboBox/ComboBox.js +3 -1
  24. package/dist/esm/DropDownTree/DropDownTree.d.ts +1 -0
  25. package/dist/esm/DropDownTree/DropDownTree.js +639 -0
  26. package/dist/esm/DropDownTree/DropDownTreeProps.d.ts +278 -0
  27. package/dist/esm/DropDownTree/DropDownTreeProps.js +2 -0
  28. package/dist/esm/DropDownTree/ListNoData.d.ts +42 -0
  29. package/dist/esm/DropDownTree/ListNoData.js +32 -0
  30. package/dist/esm/DropDownTree/useDropdownWidth.d.ts +4 -0
  31. package/dist/esm/DropDownTree/useDropdownWidth.js +10 -0
  32. package/dist/esm/MultiSelectTree/MultiSelectTree.d.ts +48 -0
  33. package/dist/esm/MultiSelectTree/MultiSelectTree.js +896 -0
  34. package/dist/esm/MultiSelectTree/MultiSelectTreeProps.d.ts +306 -0
  35. package/dist/esm/MultiSelectTree/MultiSelectTreeProps.js +2 -0
  36. package/dist/esm/MultiSelectTree/utils.d.ts +17 -0
  37. package/dist/esm/MultiSelectTree/utils.js +109 -0
  38. package/dist/esm/common/ListFilter.js +15 -3
  39. package/dist/esm/common/utils.d.ts +6 -1
  40. package/dist/esm/common/utils.js +10 -1
  41. package/dist/esm/main.d.ts +5 -1
  42. package/dist/esm/main.js +5 -1
  43. package/dist/esm/package-metadata.js +1 -1
  44. package/dist/npm/ComboBox/ComboBox.js +3 -1
  45. package/dist/npm/DropDownTree/DropDownTree.d.ts +1 -0
  46. package/dist/npm/DropDownTree/DropDownTree.js +640 -0
  47. package/dist/npm/DropDownTree/DropDownTreeProps.d.ts +278 -0
  48. package/dist/npm/DropDownTree/DropDownTreeProps.js +3 -0
  49. package/dist/npm/DropDownTree/ListNoData.d.ts +42 -0
  50. package/dist/npm/DropDownTree/ListNoData.js +39 -0
  51. package/dist/npm/DropDownTree/useDropdownWidth.d.ts +4 -0
  52. package/dist/npm/DropDownTree/useDropdownWidth.js +17 -0
  53. package/dist/npm/MultiSelectTree/MultiSelectTree.d.ts +48 -0
  54. package/dist/npm/MultiSelectTree/MultiSelectTree.js +903 -0
  55. package/dist/npm/MultiSelectTree/MultiSelectTreeProps.d.ts +306 -0
  56. package/dist/npm/MultiSelectTree/MultiSelectTreeProps.js +3 -0
  57. package/dist/npm/MultiSelectTree/utils.d.ts +17 -0
  58. package/dist/npm/MultiSelectTree/utils.js +114 -0
  59. package/dist/npm/common/ListFilter.js +15 -3
  60. package/dist/npm/common/utils.d.ts +6 -1
  61. package/dist/npm/common/utils.js +11 -1
  62. package/dist/npm/main.d.ts +5 -1
  63. package/dist/npm/main.js +20 -1
  64. package/dist/npm/package-metadata.js +1 -1
  65. package/package.json +12 -8
@@ -0,0 +1,896 @@
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
+ for (var p in s) {
6
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7
+ }
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ // @ts-ignore
23
+ import * as Vue from 'vue';
24
+ var allVue = Vue;
25
+ var gh = allVue.h;
26
+ var isV3 = allVue.version && allVue.version[0] === '3';
27
+ import { classNames, noop, getTabIndex, Keys, guid, kendoThemeMaps, Icon, getRef, setRef, validatePackage, templateRendering, getListeners, getTemplate } from '@progress/kendo-vue-common';
28
+ import { Popup } from '@progress/kendo-vue-popup';
29
+ import { provideLocalizationService } from '@progress/kendo-vue-intl';
30
+ import { TreeView } from '@progress/kendo-vue-treeview';
31
+ import { packageMetadata } from './../package-metadata.js';
32
+ import { getItemValue, areSame, matchTags } from '../common/utils.js';
33
+ import { ListNoData } from './../DropDownTree/ListNoData.js';
34
+ import { messages, nodata } from './../messages/main.js';
35
+ import { FloatingLabel } from '@progress/kendo-vue-labels';
36
+ import { TagList } from '../MultiSelect/TagList.js';
37
+ import { ClearButton } from '../common/ClearButton.js';
38
+ import { ListFilter } from '../common/ListFilter.js';
39
+ var VALIDATION_MESSAGE = 'Please select a value from the list!';
40
+ var sizeMap = kendoThemeMaps.sizeMap,
41
+ roundedMap = kendoThemeMaps.roundedMap;
42
+ var toLevel = function toLevel(hierarchicalIndex) {
43
+ return hierarchicalIndex.split('_').map(function (i) {
44
+ return parseInt(i, 10);
45
+ });
46
+ };
47
+ var getValidity = function getValidity(parameters, hasValue) {
48
+ var validationMessage = parameters.validationMessage,
49
+ valid = parameters.valid,
50
+ required = parameters.required;
51
+ return {
52
+ customError: validationMessage !== undefined,
53
+ valid: Boolean(valid !== undefined ? valid : !required || hasValue),
54
+ valueMissing: !hasValue
55
+ };
56
+ };
57
+ /**
58
+ * @hidden
59
+ */
60
+ var MultiSelectTreeVue2 = {
61
+ name: 'KendoMultiSelectTree',
62
+ // @ts-ignore
63
+ emits: {
64
+ open: null,
65
+ close: null,
66
+ focus: null,
67
+ blur: null,
68
+ change: null,
69
+ filterChange: null,
70
+ expandChange: null
71
+ },
72
+ props: {
73
+ opened: {
74
+ type: Boolean,
75
+ default: undefined
76
+ },
77
+ disabled: Boolean,
78
+ dir: String,
79
+ tabIndex: Number,
80
+ accessKey: String,
81
+ dataItems: {
82
+ type: Array,
83
+ default: function _default() {
84
+ return [];
85
+ }
86
+ },
87
+ value: Array,
88
+ valueMap: Function,
89
+ placeholder: String,
90
+ dataItemKey: {
91
+ type: String,
92
+ required: true
93
+ },
94
+ textField: {
95
+ type: String,
96
+ required: true
97
+ },
98
+ checkField: {
99
+ type: String,
100
+ default: 'checkField'
101
+ },
102
+ checkIndeterminateField: {
103
+ type: String,
104
+ default: 'checkIndeterminateField'
105
+ },
106
+ expandField: String,
107
+ subItemsField: {
108
+ type: String,
109
+ default: 'items'
110
+ },
111
+ className: String,
112
+ label: String,
113
+ validationMessage: String,
114
+ validityStyles: {
115
+ type: Boolean,
116
+ default: true
117
+ },
118
+ valid: {
119
+ type: Boolean,
120
+ default: true
121
+ },
122
+ required: Boolean,
123
+ name: String,
124
+ id: String,
125
+ ariaLabelledBy: String,
126
+ ariaDescribedBy: String,
127
+ filterable: Boolean,
128
+ filter: String,
129
+ loading: Boolean,
130
+ tags: Array,
131
+ popupSettings: {
132
+ type: Object,
133
+ default: function _default() {
134
+ return {
135
+ animate: true,
136
+ height: '200px'
137
+ };
138
+ }
139
+ },
140
+ size: {
141
+ type: String,
142
+ default: 'medium',
143
+ validator: function validator(value) {
144
+ return [null, 'small', 'medium', 'large'].includes(value);
145
+ }
146
+ },
147
+ rounded: {
148
+ type: String,
149
+ default: 'medium',
150
+ validator: function validator(value) {
151
+ return [null, 'small', 'medium', 'large', 'full'].includes(value);
152
+ }
153
+ },
154
+ fillMode: {
155
+ type: String,
156
+ default: 'solid',
157
+ validator: function validator(value) {
158
+ return [null, 'flat', 'outline', 'solid'].includes(value);
159
+ }
160
+ },
161
+ item: [String, Function, Object],
162
+ tag: [String, Function, Object],
163
+ header: [String, Function, Object],
164
+ footer: [String, Function, Object],
165
+ listNoData: [String, Function, Object]
166
+ },
167
+ inject: {
168
+ kendoLocalizationService: {
169
+ default: null
170
+ }
171
+ },
172
+ created: function created() {
173
+ validatePackage(packageMetadata);
174
+ this.componentGuid = guid();
175
+ this.anchor = guid();
176
+ },
177
+ data: function data() {
178
+ return {
179
+ focusedTagState: undefined,
180
+ openState: false,
181
+ focusedState: false,
182
+ filterState: '',
183
+ currentValue: [],
184
+ popupWidth: '200px'
185
+ };
186
+ },
187
+ computed: {
188
+ isOpen: function isOpen() {
189
+ return this.opened !== undefined ? this.opened : this.openState;
190
+ },
191
+ computedValue: function computedValue() {
192
+ return this.value !== undefined ? this.value : this.currentValue;
193
+ },
194
+ hasValue: function hasValue() {
195
+ return !!this.computedValue.length;
196
+ },
197
+ tagsToRenderRef: function tagsToRenderRef() {
198
+ var _this = this;
199
+ return this.tags === undefined ? this.computedValue.map(function (item) {
200
+ return {
201
+ text: getItemValue(item, _this.$props.textField),
202
+ data: [item]
203
+ };
204
+ }) : __spreadArray([], this.tags, true);
205
+ }
206
+ },
207
+ mounted: function mounted() {
208
+ this.elementRef = getRef(this, 'kendoAnchor', this.anchor);
209
+ this.inputRef = getRef(this, 'input');
210
+ this.selectRef = getRef(this, 'select');
211
+ this.treeViewRef = getRef(this, 'treeView');
212
+ this.skipFocusRef = false;
213
+ this.popupRef = getRef(this, 'popup');
214
+ this.calculatePopupWidth();
215
+ },
216
+ updated: function updated() {
217
+ this.inputRef = getRef(this, 'input');
218
+ this.treeViewRef = getRef(this, 'treeView');
219
+ if (this.popupRef && this.isOpen && this.hasValue) {
220
+ this.popupRef.reposition();
221
+ }
222
+ this.setValidity();
223
+ this.calculatePopupWidth();
224
+ },
225
+ // @ts-ignore
226
+ setup: !isV3 ? undefined : function () {
227
+ var v3 = !!isV3;
228
+ return {
229
+ v3: v3
230
+ };
231
+ },
232
+ // @ts-ignore
233
+ render: function render(createElement) {
234
+ var _this2 = this;
235
+ var _a, _b;
236
+ var _this = this;
237
+ var h = gh || createElement;
238
+ var id = this.$props.id || this.componentGuid;
239
+ var _c = this.$props,
240
+ dataItems = _c.dataItems,
241
+ dataItemKey = _c.dataItemKey,
242
+ _d = _c.popupSettings,
243
+ popupSettings = _d === void 0 ? {} : _d,
244
+ disabled = _c.disabled,
245
+ placeholder = _c.placeholder,
246
+ label = _c.label,
247
+ name = _c.name,
248
+ checkField = _c.checkField,
249
+ checkIndeterminateField = _c.checkIndeterminateField,
250
+ subItemsField = _c.subItemsField,
251
+ validationMessage = _c.validationMessage,
252
+ valid = _c.valid,
253
+ value = _c.value,
254
+ required = _c.required,
255
+ validityStyles = _c.validityStyles;
256
+ var tabIndex = getTabIndex(this.$props.tabIndex, disabled);
257
+ var localization = provideLocalizationService(this);
258
+ var validity = getValidity({
259
+ validationMessage: validationMessage,
260
+ valid: valid,
261
+ required: required
262
+ }, this.hasValue);
263
+ var dir = this.$props.dir; // useRtl(elementRef,this.$props.dir);
264
+ var itemTemplate = templateRendering.call(this, this.item, getListeners.call(this));
265
+ var tagTemplate = templateRendering.call(this, this.tag, getListeners.call(this));
266
+ var headerTemplate = templateRendering.call(this, this.$props.header, getListeners.call(this));
267
+ var footerTemplate = templateRendering.call(this, this.$props.footer, getListeners.call(this));
268
+ var header = getTemplate.call(this, {
269
+ h: h,
270
+ template: headerTemplate
271
+ });
272
+ var footer = getTemplate.call(this, {
273
+ h: h,
274
+ template: footerTemplate
275
+ });
276
+ var listNoDataRender = templateRendering.call(this, this.$props.listNoData, getListeners.call(this));
277
+ var noDataDefault =
278
+ // @ts-ignore function children
279
+ h(ListNoData, this.v3 ? function () {
280
+ return [localization.toLanguageString(nodata, messages[nodata])];
281
+ } : [localization.toLanguageString(nodata, messages[nodata])]);
282
+ var noDataTemplate = getTemplate.call(this, {
283
+ h: h,
284
+ defaultRendering: noDataDefault,
285
+ template: listNoDataRender
286
+ });
287
+ var isValid = !validityStyles || validity.valid;
288
+ var _e = this.$props,
289
+ size = _e.size,
290
+ rounded = _e.rounded,
291
+ fillMode = _e.fillMode;
292
+ var multiselecttree = h("span", {
293
+ ref: setRef(this, 'kendoAnchor', this.anchor),
294
+ "class": classNames('k-multiselect k-input', this.$props.className, (_a = {}, _a["k-input-".concat(sizeMap[size] || size)] = size, _a["k-rounded-".concat(roundedMap[rounded] || rounded)] = rounded, _a["k-input-".concat(fillMode)] = fillMode, _a['k-focus'] = this.focusedState && !disabled, _a['k-invalid'] = !isValid, _a['k-disabled'] = disabled, _a['k-loading'] = this.$props.loading, _a['k-required'] = required, _a)),
295
+ tabIndex: tabIndex,
296
+ attrs: this.v3 ? undefined : {
297
+ tabIndex: tabIndex,
298
+ accessKey: this.$props.accessKey,
299
+ id: id,
300
+ dir: dir,
301
+ role: "combobox",
302
+ "aria-haspopup": "true",
303
+ "aria-expanded": this.isOpen,
304
+ "aria-disabled": disabled,
305
+ "aria-label": label,
306
+ "aria-labelledby": this.$props.ariaLabelledBy,
307
+ "aria-describedby": this.$props.ariaDescribedBy,
308
+ "aria-required": this.$props.required
309
+ },
310
+ accessKey: this.$props.accessKey,
311
+ id: id,
312
+ dir: dir,
313
+ onKeydown: this.onWrapperKeyDown,
314
+ on: this.v3 ? undefined : {
315
+ "keydown": this.onWrapperKeyDown,
316
+ "mousedown": this.onWrapperMouseDown,
317
+ "focus": this.onFocus,
318
+ "blur": this.onBlur,
319
+ "click": this.onWrapperClick
320
+ },
321
+ onMousedown: this.onWrapperMouseDown,
322
+ onFocus: this.onFocus,
323
+ onBlur: this.onBlur,
324
+ role: "combobox",
325
+ "aria-haspopup": "true",
326
+ "aria-expanded": this.isOpen,
327
+ "aria-disabled": disabled,
328
+ "aria-label": label,
329
+ "aria-labelledby": this.$props.ariaLabelledBy,
330
+ "aria-describedby": this.$props.ariaDescribedBy,
331
+ "aria-required": this.$props.required,
332
+ onClick: this.onWrapperClick
333
+ }, [h("div", {
334
+ id: 'tagslist-' + id,
335
+ attrs: this.v3 ? undefined : {
336
+ id: 'tagslist-' + id
337
+ },
338
+ "class": classNames('k-input-values k-chip-list k-selection-multiple', (_b = {}, _b["k-chip-list-".concat(sizeMap[size] || size)] = size, _b['k-readonly'] = this.hasValue, _b))
339
+ }, [this.tagsToRenderRef.length > 0 ? h(TagList, {
340
+ tagRender: tagTemplate,
341
+ attrs: this.v3 ? undefined : {
342
+ tagRender: tagTemplate,
343
+ dataItems: this.tagsToRenderRef,
344
+ guid: id,
345
+ focused: this.focusedTagState ? this.tagsToRenderRef.find(function (t) {
346
+ return matchTags(t, _this.focusedTagState, dataItemKey);
347
+ }) : undefined,
348
+ size: size
349
+ },
350
+ onTagdelete: this.onTagDelete,
351
+ on: this.v3 ? undefined : {
352
+ "tagdelete": this.onTagDelete
353
+ },
354
+ dataItems: this.tagsToRenderRef,
355
+ guid: id,
356
+ focused: this.focusedTagState ? this.tagsToRenderRef.find(function (t) {
357
+ return matchTags(t, _this.focusedTagState, dataItemKey);
358
+ }) : undefined,
359
+ size: size
360
+ }) : !this.hasValue && h("span", {
361
+ "class": "k-input-inner",
362
+ role: 'combobox',
363
+ attrs: this.v3 ? undefined : {
364
+ role: 'combobox',
365
+ tabIndex: tabIndex,
366
+ "aria-expanded": this.isOpen,
367
+ "aria-describedby": 'tagslist-' + id,
368
+ "aria-label": this.$props.ariaLabelledBy
369
+ },
370
+ tabIndex: tabIndex,
371
+ "aria-expanded": this.isOpen,
372
+ "aria-describedby": 'tagslist-' + id,
373
+ "aria-label": this.$props.ariaLabelledBy
374
+ }, [h("span", {
375
+ "class": "k-input-value-text"
376
+ }, [placeholder])])]), this.$props.loading && h(Icon, {
377
+ "class": "k-input-loading-icon",
378
+ name: "loading",
379
+ attrs: this.v3 ? undefined : {
380
+ name: "loading"
381
+ }
382
+ }), this.hasValue && !disabled && h(ClearButton, {
383
+ onClearclick: this.onClear,
384
+ on: this.v3 ? undefined : {
385
+ "clearclick": this.onClear
386
+ }
387
+ }), /* Dummy component to support forms */h("select", {
388
+ name: name,
389
+ attrs: this.v3 ? undefined : {
390
+ name: name,
391
+ tabIndex: -1,
392
+ "aria-hidden": true,
393
+ title: label
394
+ },
395
+ ref: setRef(this, 'select'),
396
+ tabIndex: -1,
397
+ "aria-hidden": true,
398
+ title: label,
399
+ style: {
400
+ opacity: 0,
401
+ width: 1,
402
+ border: 0,
403
+ zIndex: -1,
404
+ position: 'absolute',
405
+ left: '50%'
406
+ }
407
+ }, [h("option", {
408
+ value: this.v3 ? this.$props.valueMap ? this.$props.valueMap.call(undefined, value) : value : null,
409
+ domProps: this.v3 ? undefined : {
410
+ "value": this.$props.valueMap ? this.$props.valueMap.call(undefined, value) : value
411
+ }
412
+ })]),
413
+ // @ts-ignore function children
414
+ h(Popup, {
415
+ style: {
416
+ width: this.popupWidth,
417
+ direction: dir
418
+ },
419
+ popupClass: classNames(popupSettings.popupClass, 'k-list-container', 'k-multiselecttree-popup', 'popup-' + this.componentGuid),
420
+ attrs: this.v3 ? undefined : {
421
+ popupClass: classNames(popupSettings.popupClass, 'k-list-container', 'k-multiselecttree-popup', 'popup-' + this.componentGuid),
422
+ animate: popupSettings.animate,
423
+ anchor: this.anchor,
424
+ show: this.isOpen,
425
+ appendTo: popupSettings.appendTo
426
+ },
427
+ "class": classNames(popupSettings.className, {
428
+ 'k-rtl': dir === 'rtl'
429
+ }),
430
+ animate: popupSettings.animate,
431
+ anchor: this.anchor,
432
+ show: this.isOpen,
433
+ onOpen: this.onPopupOpened,
434
+ on: this.v3 ? undefined : {
435
+ "open": this.onPopupOpened,
436
+ "close": this.onPopupClosed
437
+ },
438
+ onClose: this.onPopupClosed,
439
+ appendTo: popupSettings.appendTo,
440
+ ref: setRef(this, 'popup')
441
+ }, this.v3 ? function () {
442
+ return [_this2.$props.filterable &&
443
+ // @ts-ignore
444
+ h(ListFilter, {
445
+ value: _this2.$props.filter === undefined ? _this2.filterState : _this2.$props.filter,
446
+ attrs: _this2.v3 ? undefined : {
447
+ value: _this2.$props.filter === undefined ? _this2.filterState : _this2.$props.filter,
448
+ size: size,
449
+ rounded: rounded,
450
+ fillMode: fillMode
451
+ },
452
+ ref: setRef(_this2, 'input'),
453
+ onChange: _this2.onFilterChange,
454
+ on: _this2.v3 ? undefined : {
455
+ "change": _this2.onFilterChange,
456
+ "keydown": _this2.onInputKeyDown,
457
+ "focus": _this2.onFocus,
458
+ "blur": _this2.onBlur
459
+ },
460
+ onKeydown: _this2.onInputKeyDown,
461
+ size: size,
462
+ rounded: rounded,
463
+ fillMode: fillMode,
464
+ onFocus: _this2.onFocus,
465
+ onBlur: _this2.onBlur
466
+ }), header && h("div", {
467
+ "class": "k-list-header"
468
+ }, [header]), dataItems.length > 0 ?
469
+ // @ts-ignore
470
+ h(TreeView, {
471
+ ref: setRef(_this2, 'treeView'),
472
+ tabIndex: tabIndex,
473
+ attrs: _this2.v3 ? undefined : {
474
+ tabIndex: tabIndex,
475
+ dataItems: dataItems,
476
+ focusIdField: dataItemKey,
477
+ textField: _this2.$props.textField,
478
+ checkField: checkField,
479
+ checkIndeterminateField: checkIndeterminateField,
480
+ expandField: _this2.$props.expandField,
481
+ childrenField: subItemsField,
482
+ expandIcons: true,
483
+ checkboxes: true,
484
+ size: size,
485
+ item: itemTemplate
486
+ },
487
+ dataItems: dataItems,
488
+ focusIdField: dataItemKey,
489
+ textField: _this2.$props.textField,
490
+ checkField: checkField,
491
+ checkIndeterminateField: checkIndeterminateField,
492
+ expandField: _this2.$props.expandField,
493
+ childrenField: subItemsField,
494
+ expandIcons: true,
495
+ onItemclick: _this2.onChange,
496
+ on: _this2.v3 ? undefined : {
497
+ "itemclick": _this2.onChange,
498
+ "checkchange": _this2.onChange,
499
+ "expandchange": _this2.onExpand,
500
+ "focus": _this2.onFocus,
501
+ "blur": _this2.onBlur,
502
+ "keydown": _this2.onWrapperKeyDown
503
+ },
504
+ onCheckchange: _this2.onChange,
505
+ onExpandchange: _this2.onExpand,
506
+ onFocus: _this2.onFocus,
507
+ onBlur: _this2.onBlur,
508
+ onKeydown: _this2.onWrapperKeyDown,
509
+ checkboxes: true,
510
+ size: size,
511
+ item: itemTemplate
512
+ }) : noDataTemplate, footer && h("div", {
513
+ "class": "k-list-footer"
514
+ }, [footer])];
515
+ } : [_this2.$props.filterable && h(ListFilter, {
516
+ value: _this2.$props.filter === undefined ? _this2.filterState : _this2.$props.filter,
517
+ attrs: _this2.v3 ? undefined : {
518
+ value: _this2.$props.filter === undefined ? _this2.filterState : _this2.$props.filter,
519
+ size: size,
520
+ rounded: rounded,
521
+ fillMode: fillMode
522
+ },
523
+ ref: setRef(_this2, 'input'),
524
+ onChange: _this2.onFilterChange,
525
+ on: _this2.v3 ? undefined : {
526
+ "change": _this2.onFilterChange,
527
+ "keydown": _this2.onInputKeyDown,
528
+ "focus": _this2.onFocus,
529
+ "blur": _this2.onBlur
530
+ },
531
+ onKeydown: _this2.onInputKeyDown,
532
+ size: size,
533
+ rounded: rounded,
534
+ fillMode: fillMode,
535
+ onFocus: _this2.onFocus,
536
+ onBlur: _this2.onBlur
537
+ }), header && h("div", {
538
+ "class": "k-list-header"
539
+ }, [header]), dataItems.length > 0 ? h(TreeView, {
540
+ ref: setRef(_this2, 'treeView'),
541
+ tabIndex: tabIndex,
542
+ attrs: _this2.v3 ? undefined : {
543
+ tabIndex: tabIndex,
544
+ dataItems: dataItems,
545
+ focusIdField: dataItemKey,
546
+ textField: _this2.$props.textField,
547
+ checkField: checkField,
548
+ checkIndeterminateField: checkIndeterminateField,
549
+ expandField: _this2.$props.expandField,
550
+ childrenField: subItemsField,
551
+ expandIcons: true,
552
+ checkboxes: true,
553
+ size: size,
554
+ item: itemTemplate
555
+ },
556
+ dataItems: dataItems,
557
+ focusIdField: dataItemKey,
558
+ textField: _this2.$props.textField,
559
+ checkField: checkField,
560
+ checkIndeterminateField: checkIndeterminateField,
561
+ expandField: _this2.$props.expandField,
562
+ childrenField: subItemsField,
563
+ expandIcons: true,
564
+ onItemclick: _this2.onChange,
565
+ on: _this2.v3 ? undefined : {
566
+ "itemclick": _this2.onChange,
567
+ "checkchange": _this2.onChange,
568
+ "expandchange": _this2.onExpand,
569
+ "focus": _this2.onFocus,
570
+ "blur": _this2.onBlur,
571
+ "keydown": _this2.onWrapperKeyDown
572
+ },
573
+ onCheckchange: _this2.onChange,
574
+ onExpandchange: _this2.onExpand,
575
+ onFocus: _this2.onFocus,
576
+ onBlur: _this2.onBlur,
577
+ onKeydown: _this2.onWrapperKeyDown,
578
+ checkboxes: true,
579
+ size: size,
580
+ item: itemTemplate
581
+ }) : noDataTemplate, footer && h("div", {
582
+ "class": "k-list-footer"
583
+ }, [footer])])]);
584
+ return label ?
585
+ // @ts-ignore function children
586
+ h(FloatingLabel, {
587
+ label: label,
588
+ attrs: this.v3 ? undefined : {
589
+ label: label,
590
+ editorValue: this.hasValue,
591
+ editorPlaceholder: placeholder,
592
+ editorValid: isValid,
593
+ editorDisabled: disabled,
594
+ editorId: id,
595
+ dir: dir
596
+ },
597
+ editorValue: this.hasValue,
598
+ editorPlaceholder: placeholder,
599
+ editorValid: isValid,
600
+ editorDisabled: disabled,
601
+ editorId: id,
602
+ dir: dir
603
+ }, this.v3 ? function () {
604
+ return [multiselecttree];
605
+ } : [multiselecttree]) : multiselecttree;
606
+ },
607
+ methods: {
608
+ calculatePopupWidth: function calculatePopupWidth() {
609
+ if (this.elementRef) {
610
+ this.popupWidth = this.popupSettings.width !== undefined ? this.popupSettings.width : this.elementRef.offsetWidth + 'px';
611
+ }
612
+ },
613
+ focus: function focus() {
614
+ if (this.$el) {
615
+ this.$el.focus();
616
+ }
617
+ },
618
+ setValidity: function setValidity() {
619
+ if (this.selectRef && this.selectRef.setCustomValidity) {
620
+ var _a = this.$props,
621
+ validationMessage = _a.validationMessage,
622
+ valid = _a.valid,
623
+ required = _a.required;
624
+ var validity = getValidity({
625
+ validationMessage: validationMessage,
626
+ valid: valid,
627
+ required: required
628
+ }, this.hasValue);
629
+ this.selectRef.setCustomValidity(validity.valid ? '' : this.validationMessage === undefined ? VALIDATION_MESSAGE : this.validationMessage);
630
+ }
631
+ },
632
+ changeValue: function changeValue(event, relatedItems, operation) {
633
+ var changeEvent = __assign({
634
+ items: relatedItems,
635
+ operation: operation
636
+ }, event);
637
+ this.$emit('change', changeEvent);
638
+ },
639
+ onChange: function onChange(e) {
640
+ if (areSame(e.item, this.computedValue, this.dataItemKey)) {
641
+ return;
642
+ }
643
+ var item = e.item,
644
+ event = e.event;
645
+ var ev = {
646
+ event: event,
647
+ target: this
648
+ };
649
+ this.changeValue(ev, [item], 'toggle');
650
+ },
651
+ openPopup: function openPopup(event) {
652
+ if (!this.isOpen) {
653
+ var openEvent = __assign({}, event);
654
+ this.$emit('open', openEvent);
655
+ if (this.opened === undefined) {
656
+ this.openState = true;
657
+ }
658
+ }
659
+ },
660
+ closePopup: function closePopup(event) {
661
+ if (this.isOpen) {
662
+ var closeEvent = __assign({}, event);
663
+ this.$emit('close', closeEvent);
664
+ if (this.opened === undefined) {
665
+ this.openState = false;
666
+ }
667
+ }
668
+ },
669
+ switchFocus: function switchFocus(focusFn) {
670
+ var _this = this;
671
+ this.skipFocusRef = true;
672
+ focusFn();
673
+ window.setTimeout(function () {
674
+ return _this.skipFocusRef = false;
675
+ }, 0);
676
+ },
677
+ focusElement: function focusElement(element) {
678
+ if (element) {
679
+ this.switchFocus(function () {
680
+ return element.focus();
681
+ });
682
+ }
683
+ },
684
+ onPopupOpened: function onPopupOpened() {
685
+ if (!this.focusedState && this.isOpen) {
686
+ this.closePopup({
687
+ target: this
688
+ });
689
+ } else {
690
+ if (this.$props.filterable) {
691
+ var inputElement = this.inputRef && this.inputRef.input;
692
+ this.focusElement(inputElement);
693
+ } else {
694
+ this.focusElement(this.treeViewRef && this.treeViewRef.input);
695
+ }
696
+ }
697
+ },
698
+ onPopupClosed: function onPopupClosed() {
699
+ if (this.focusedState) {
700
+ // Move the focus from treeview to dropdown without triggering Focus or Blur events.
701
+ this.focusElement(this.$el);
702
+ }
703
+ },
704
+ onFocus: function onFocus(event) {
705
+ if (!this.focusedState && !this.skipFocusRef) {
706
+ this.focusedState = true;
707
+ var focusEvent = {
708
+ event: event,
709
+ target: this
710
+ };
711
+ this.$emit('focus', focusEvent);
712
+ }
713
+ },
714
+ onBlur: function onBlur(event) {
715
+ if (this.focusedState && !this.skipFocusRef) {
716
+ this.focusedTagState = undefined;
717
+ this.focusedState = false;
718
+ var ev = {
719
+ event: event,
720
+ target: this
721
+ };
722
+ var focusEvent = __assign({}, ev);
723
+ if (!event.relatedTarget || !event.relatedTarget.closest('.popup-' + this.componentGuid)) {
724
+ this.$emit('blur', focusEvent);
725
+ this.closePopup(ev);
726
+ }
727
+ }
728
+ },
729
+ onWrapperMouseDown: function onWrapperMouseDown() {
730
+ if (this.focusedState) {
731
+ // moving focus from treeview to dropdown triggers Focus and Blur events.
732
+ this.switchFocus(noop);
733
+ }
734
+ },
735
+ onWrapperClick: function onWrapperClick(event) {
736
+ if (!this.$props.disabled && !event.defaultPrevented) {
737
+ this.focusedState = true;
738
+ var ev = {
739
+ event: event,
740
+ target: this
741
+ };
742
+ if (!this.isOpen) {
743
+ this.openPopup(ev);
744
+ }
745
+ }
746
+ },
747
+ onWrapperKeyDown: function onWrapperKeyDown(event) {
748
+ var _this = this;
749
+ var keyCode = event.keyCode,
750
+ altKey = event.altKey;
751
+ var treeviewElement = this.treeViewRef && this.treeViewRef.$el;
752
+ var inputElement = this.inputRef && this.inputRef.input;
753
+ if (this.$props.disabled || event.defaultPrevented && inputElement === event.target) {
754
+ return;
755
+ }
756
+ var ev = {
757
+ event: event,
758
+ target: this
759
+ };
760
+ if (this.value && this.value.length > 0 && (keyCode === Keys.left || keyCode === Keys.right || keyCode === Keys.home || keyCode === Keys.end || keyCode === Keys.delete || keyCode === Keys.backspace)) {
761
+ var tagsToRender = this.tagsToRenderRef;
762
+ var focusedIndex = this.focusedTagState ? tagsToRender.findIndex(function (t) {
763
+ return matchTags(t, _this.focusedTagState, _this.dataItemKey);
764
+ }) : -1;
765
+ var newFocusedTag = undefined;
766
+ var hasFocused = focusedIndex !== -1;
767
+ if (keyCode === Keys.left) {
768
+ if (hasFocused) {
769
+ focusedIndex = Math.max(0, focusedIndex - 1);
770
+ } else {
771
+ focusedIndex = tagsToRender.length - 1;
772
+ }
773
+ newFocusedTag = tagsToRender[focusedIndex];
774
+ } else if (keyCode === Keys.right) {
775
+ if (focusedIndex === tagsToRender.length - 1) {
776
+ newFocusedTag = undefined;
777
+ } else if (hasFocused) {
778
+ focusedIndex = Math.min(tagsToRender.length - 1, focusedIndex + 1);
779
+ newFocusedTag = tagsToRender[focusedIndex];
780
+ }
781
+ } else if (keyCode === Keys.home) {
782
+ newFocusedTag = tagsToRender[0];
783
+ } else if (keyCode === Keys.end) {
784
+ newFocusedTag = tagsToRender[tagsToRender.length - 1];
785
+ } else if (keyCode === Keys.delete || keyCode === Keys.backspace) {
786
+ if (hasFocused) {
787
+ this.changeValue(ev, tagsToRender[focusedIndex].data, 'delete');
788
+ }
789
+ }
790
+ if (newFocusedTag !== this.focusedTagState) {
791
+ this.focusedTagState = newFocusedTag;
792
+ }
793
+ }
794
+ if (this.isOpen) {
795
+ if (keyCode === Keys.esc || altKey && keyCode === Keys.up) {
796
+ event.preventDefault();
797
+ this.switchFocus(function () {
798
+ _this.focusElement(_this.elementRef);
799
+ });
800
+ this.closePopup(ev);
801
+ } else if (treeviewElement && treeviewElement.querySelector('.k-focus') && (keyCode === Keys.up || keyCode === Keys.down || keyCode === Keys.left || keyCode === Keys.right || keyCode === Keys.home || keyCode === Keys.end)) {
802
+ if (keyCode === Keys.up) {
803
+ var items = Array.from(treeviewElement.querySelectorAll('.k-treeview-item'));
804
+ var focusedItem = __spreadArray([], items, true).reverse().find(function (i) {
805
+ return Boolean(i && i.querySelector('.k-focus'));
806
+ });
807
+ if (focusedItem && items.indexOf(focusedItem) === 0) {
808
+ return this.switchFocus(function () {
809
+ _this.focusElement(inputElement || _this.elementRef);
810
+ });
811
+ }
812
+ }
813
+ this.switchFocus(noop);
814
+ } else if (keyCode === Keys.down) {
815
+ this.switchFocus(function () {
816
+ _this.focusElement(inputElement || treeviewElement);
817
+ });
818
+ }
819
+ } else {
820
+ if (altKey && keyCode === Keys.down) {
821
+ event.preventDefault();
822
+ this.openPopup(ev);
823
+ }
824
+ }
825
+ },
826
+ onInputKeyDown: function onInputKeyDown(event) {
827
+ var _this = this;
828
+ var keyCode = event.keyCode,
829
+ altKey = event.altKey;
830
+ if (altKey || keyCode !== Keys.up && keyCode !== Keys.down) {
831
+ return;
832
+ }
833
+ event.preventDefault();
834
+ this.switchFocus(keyCode === Keys.up ? function () {
835
+ _this.focusElement(_this.elementRef);
836
+ } : function () {
837
+ _this.focusElement(_this.treeViewRef && _this.treeViewRef.$el);
838
+ });
839
+ },
840
+ onClear: function onClear(event) {
841
+ var ev = {
842
+ event: event,
843
+ target: this
844
+ };
845
+ this.changeValue(ev, [], 'clear');
846
+ this.closePopup(ev);
847
+ event.preventDefault();
848
+ },
849
+ onTagDelete: function onTagDelete(itemsToRemove, event) {
850
+ this.closePopup({
851
+ target: this
852
+ });
853
+ if (!this.focusedState) {
854
+ var inputElement = this.inputRef && this.inputRef.input;
855
+ this.focusElement(inputElement);
856
+ }
857
+ this.changeValue({
858
+ event: event,
859
+ target: this
860
+ }, itemsToRemove, 'delete');
861
+ },
862
+ onExpand: function onExpand(e) {
863
+ var item = e.item,
864
+ itemHierarchicalIndex = e.itemHierarchicalIndex,
865
+ event = e.event;
866
+ var expandEvent = {
867
+ level: toLevel(itemHierarchicalIndex),
868
+ item: item,
869
+ event: event,
870
+ target: this
871
+ };
872
+ this.$emit('expandchange', expandEvent);
873
+ },
874
+ onFilterChange: function onFilterChange(event) {
875
+ var filterDesc = {
876
+ field: this.$props.textField,
877
+ operator: 'contains',
878
+ value: event.target.value
879
+ };
880
+ var ev = {
881
+ filter: filterDesc,
882
+ event: event,
883
+ target: this
884
+ };
885
+ this.$emit('filterchange', ev);
886
+ if (this.$props.filter === undefined) {
887
+ this.filterState = event.target.value;
888
+ }
889
+ }
890
+ }
891
+ };
892
+ /**
893
+ * @hidden
894
+ */
895
+ var MultiSelectTree = MultiSelectTreeVue2;
896
+ export { MultiSelectTree, MultiSelectTreeVue2 };