@progress/kendo-vue-dropdowns 3.10.2 → 3.11.0-dev.202305230623

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