@progress/kendo-vue-treeview 3.5.0 → 3.5.1-dev.202208150613

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/README.md +2 -2
  2. package/dist/cdn/js/kendo-vue-treeview.js +1 -1
  3. package/dist/es/ItemRenderProps.js +1 -0
  4. package/dist/es/TreeView.js +1 -1
  5. package/dist/es/TreeViewDragAnalyzer.js +2 -2
  6. package/dist/es/TreeViewItem.js +2 -2
  7. package/dist/es/TreeViewOperationDescriptors.js +1 -0
  8. package/dist/es/TreeViewProps.js +1 -0
  9. package/dist/es/events.js +1 -0
  10. package/dist/es/moveTreeViewItem.js +1 -1
  11. package/dist/es/package-metadata.js +1 -1
  12. package/dist/esm/ItemRenderProps.d.ts +13 -0
  13. package/dist/esm/ItemRenderProps.js +2 -0
  14. package/dist/esm/TreeView.d.ts +116 -0
  15. package/dist/esm/TreeView.js +435 -0
  16. package/dist/esm/TreeViewDragAnalyzer.d.ts +63 -0
  17. package/dist/esm/TreeViewDragAnalyzer.js +111 -0
  18. package/dist/esm/TreeViewDragClue.d.ts +78 -0
  19. package/dist/esm/TreeViewDragClue.js +112 -0
  20. package/dist/esm/TreeViewItem.d.ts +75 -0
  21. package/dist/esm/TreeViewItem.js +404 -0
  22. package/dist/esm/TreeViewOperationDescriptors.d.ts +76 -0
  23. package/dist/esm/TreeViewOperationDescriptors.js +2 -0
  24. package/dist/esm/TreeViewProps.d.ts +126 -0
  25. package/dist/esm/TreeViewProps.js +1 -0
  26. package/dist/esm/additionalTypes.ts +21 -0
  27. package/dist/esm/events.d.ts +135 -0
  28. package/dist/esm/events.js +1 -0
  29. package/dist/esm/handleTreeViewCheckChange.d.ts +49 -0
  30. package/dist/esm/handleTreeViewCheckChange.js +177 -0
  31. package/dist/esm/main.d.ts +12 -0
  32. package/dist/esm/main.js +8 -0
  33. package/dist/esm/moveTreeViewItem.d.ts +46 -0
  34. package/dist/esm/moveTreeViewItem.js +93 -0
  35. package/dist/esm/package-metadata.d.ts +5 -0
  36. package/dist/esm/package-metadata.js +11 -0
  37. package/dist/esm/package.json +3 -0
  38. package/dist/esm/processTreeViewItems.d.ts +24 -0
  39. package/dist/esm/processTreeViewItems.js +139 -0
  40. package/dist/esm/utils/FieldsService.d.ts +26 -0
  41. package/dist/esm/utils/FieldsService.js +50 -0
  42. package/dist/esm/utils/SortedPublicItemIds.d.ts +8 -0
  43. package/dist/esm/utils/SortedPublicItemIds.js +24 -0
  44. package/dist/esm/utils/consts.d.ts +40 -0
  45. package/dist/esm/utils/consts.js +40 -0
  46. package/dist/esm/utils/getItemIdUponKeyboardNavigation.d.ts +5 -0
  47. package/dist/esm/utils/getItemIdUponKeyboardNavigation.js +77 -0
  48. package/dist/esm/utils/itemIdUtils.d.ts +60 -0
  49. package/dist/esm/utils/itemIdUtils.js +117 -0
  50. package/dist/esm/utils/itemUtils.d.ts +45 -0
  51. package/dist/esm/utils/itemUtils.js +191 -0
  52. package/dist/esm/utils/misc.d.ts +9 -0
  53. package/dist/esm/utils/misc.js +17 -0
  54. package/dist/npm/TreeView.js +8 -8
  55. package/dist/npm/TreeViewDragAnalyzer.js +2 -2
  56. package/dist/npm/TreeViewDragClue.js +1 -1
  57. package/dist/npm/TreeViewItem.js +15 -15
  58. package/dist/npm/handleTreeViewCheckChange.js +10 -10
  59. package/dist/npm/moveTreeViewItem.js +7 -7
  60. package/dist/npm/package-metadata.js +1 -1
  61. package/dist/npm/processTreeViewItems.js +7 -7
  62. package/dist/npm/utils/FieldsService.js +9 -9
  63. package/dist/npm/utils/getItemIdUponKeyboardNavigation.js +5 -5
  64. package/dist/npm/utils/itemUtils.js +18 -18
  65. package/package.json +12 -6
@@ -0,0 +1,435 @@
1
+ // @ts-ignore
2
+ import * as Vue from 'vue';
3
+ var allVue = Vue;
4
+ var gh = allVue.h;
5
+ var isV3 = allVue.version && allVue.version[0] === '3';
6
+ import { Keys, validatePackage, guid, kendoThemeMaps, classNames, templateRendering, getListeners } from '@progress/kendo-vue-common';
7
+ import nav from './utils/getItemIdUponKeyboardNavigation.js';
8
+ import { resolveItemId, isEnabledAndAllParentsEnabled, hasChildren } from './utils/itemUtils.js';
9
+ import { TreeViewItem } from './TreeViewItem.js';
10
+ import { ZERO_LEVEL_ZERO_NODE_ID, getItemById as _getItemById } from './utils/itemIdUtils.js';
11
+ import FieldsService from './utils/FieldsService.js';
12
+ import { packageMetadata } from './package-metadata.js';
13
+ import { CHECK_FIELD, CHECK_INDETERMINATE_FIELD, CHILDREN_FIELD, DISABLED_FIELD, EXPAND_FIELD, HAS_CHILDREN_FIELD, SELECT_FIELD, TEXT_FIELD } from './utils/consts.js';
14
+ var sizeMap = kendoThemeMaps.sizeMap;
15
+ /**
16
+ * @hidden
17
+ */
18
+
19
+ var TreeViewVue2 = {
20
+ name: 'KendoTreeView',
21
+ props: {
22
+ dataItems: Array,
23
+ animate: {
24
+ type: Boolean,
25
+ default: true
26
+ },
27
+ id: String,
28
+ draggable: Boolean,
29
+ tabIndex: Number,
30
+ focusIdField: String,
31
+ getFocusHierarchicalIndex: Function,
32
+ expandField: {
33
+ type: String,
34
+ default: EXPAND_FIELD
35
+ },
36
+ selectField: {
37
+ type: String,
38
+ default: SELECT_FIELD
39
+ },
40
+ childrenField: {
41
+ type: String,
42
+ default: CHILDREN_FIELD
43
+ },
44
+ hasChildrenField: {
45
+ type: String,
46
+ default: HAS_CHILDREN_FIELD
47
+ },
48
+ expandIcons: Boolean,
49
+ checkboxes: Boolean,
50
+ textField: {
51
+ type: String,
52
+ default: TEXT_FIELD
53
+ },
54
+ disableField: {
55
+ type: String,
56
+ default: DISABLED_FIELD
57
+ },
58
+ checkField: {
59
+ type: String,
60
+ default: CHECK_FIELD
61
+ },
62
+ checkIndeterminateField: {
63
+ type: String,
64
+ default: CHECK_INDETERMINATE_FIELD
65
+ },
66
+ item: [Object, String, Function],
67
+ ariaMultiSelectable: [String, Boolean],
68
+ ariaLabel: String,
69
+ ariaLabelledby: String,
70
+ size: {
71
+ type: String,
72
+ default: 'medium',
73
+ validator: function validator(value) {
74
+ return [null, 'small', 'medium', 'large'].includes(value);
75
+ }
76
+ }
77
+ },
78
+ data: function data() {
79
+ return {
80
+ focusedItemId: undefined,
81
+ focusedItemPublicId: undefined,
82
+ tabbableItemId: ZERO_LEVEL_ZERO_NODE_ID
83
+ };
84
+ },
85
+ computed: {
86
+ treeGuid: function treeGuid() {
87
+ return this.id || this.innerId;
88
+ }
89
+ },
90
+ created: function created() {
91
+ validatePackage(packageMetadata);
92
+ this.allowExplicitFocus = false;
93
+ this.innerId = guid();
94
+ },
95
+ updated: function updated() {
96
+ this.allowExplicitFocus = false;
97
+ this.refocusDueToFocusIdField();
98
+ },
99
+ // @ts-ignore
100
+ setup: !isV3 ? undefined : function () {
101
+ var v3 = !!isV3;
102
+ return {
103
+ v3: v3
104
+ };
105
+ },
106
+ // @ts-ignore
107
+ render: function render(createElement) {
108
+ var _a;
109
+
110
+ var h = gh || createElement;
111
+ this.fieldsSvc = new FieldsService(this.$props);
112
+ var size = this.$props.size;
113
+ return h("div", {
114
+ "class": classNames('k-treeview', (_a = {}, _a["k-treeview-".concat(sizeMap[size] || size)] = size, _a)),
115
+ onKeydown: this.onKeyDown,
116
+ on: this.v3 ? undefined : {
117
+ "keydown": this.onKeyDown,
118
+ "focusin": this.onFocus,
119
+ "focusout": this.onBlur
120
+ },
121
+ onFocusin: this.onFocus,
122
+ onFocusout: this.onBlur,
123
+ role: "tree",
124
+ attrs: this.v3 ? undefined : {
125
+ role: "tree",
126
+ "aria-multiselectable": this.ariaMultiSelectable ? true : undefined,
127
+ "aria-label": this.$props['aria-label'],
128
+ "aria-labelledby": this.$props['aria-labelledby'],
129
+ tabindex: this.$props.tabIndex
130
+ },
131
+ "aria-multiselectable": this.ariaMultiSelectable ? true : undefined,
132
+ "aria-label": this.$props['aria-label'],
133
+ "aria-labelledby": this.$props['aria-labelledby'],
134
+ tabindex: this.$props.tabIndex,
135
+ style: {
136
+ userSelect: this.draggable ? 'none' : undefined
137
+ }
138
+ }, [h("ul", {
139
+ "class": "k-treeview-lines k-treeview-group",
140
+ role: "group",
141
+ attrs: this.v3 ? undefined : {
142
+ role: "group"
143
+ }
144
+ }, [this.dataItems.map(function (item, index) {
145
+ var itemTemplate = templateRendering.call(this, this.item, getListeners.call(this));
146
+ return h(TreeViewItem, {
147
+ item: item,
148
+ attrs: this.v3 ? undefined : {
149
+ item: item,
150
+ itemId: index.toString(),
151
+ treeGuid: this.treeGuid,
152
+ animate: this.$props.animate,
153
+ focusedItemId: this.focusedItemId,
154
+ tabbableItemId: this.tabbableItemId,
155
+ fieldsService: this.fieldsSvc,
156
+ itemUI: itemTemplate,
157
+ checkboxes: this.$props.checkboxes,
158
+ ariaMultiSelectable: this.ariaMultiSelectable,
159
+ draggable: this.$props.draggable,
160
+ expandIcons: this.$props.expandIcons,
161
+ size: size
162
+ },
163
+ itemId: index.toString(),
164
+ treeGuid: this.treeGuid,
165
+ animate: this.$props.animate,
166
+ focusedItemId: this.focusedItemId,
167
+ tabbableItemId: this.tabbableItemId,
168
+ fieldsService: this.fieldsSvc,
169
+ itemUI: itemTemplate,
170
+ checkboxes: this.$props.checkboxes,
171
+ ariaMultiSelectable: this.ariaMultiSelectable,
172
+ onItemclick: this.onItemClick,
173
+ on: this.v3 ? undefined : {
174
+ "itemclick": this.onItemClick,
175
+ "focusdomelneeded": this.onFocusDomElNeeded,
176
+ "press": this.onPress,
177
+ "drag": this.onDrag,
178
+ "release": this.onRelease,
179
+ "expandchange": this.onExpandChange,
180
+ "checkchange": this.onCheckChange
181
+ },
182
+ onFocusdomelneeded: this.onFocusDomElNeeded,
183
+ draggable: this.$props.draggable,
184
+ onPress: this.onPress,
185
+ onDrag: this.onDrag,
186
+ onRelease: this.onRelease,
187
+ expandIcons: this.$props.expandIcons,
188
+ onExpandchange: this.onExpandChange,
189
+ onCheckchange: this.onCheckChange,
190
+ key: index,
191
+ size: size
192
+ });
193
+ }, this)])]);
194
+ },
195
+ methods: {
196
+ onFocusDomElNeeded: function onFocusDomElNeeded(domItem) {
197
+ if (this.allowExplicitFocus) {
198
+ this.focusDomItem(domItem);
199
+ }
200
+ },
201
+ onCheckChange: function onCheckChange(event, item, itemId) {
202
+ this.setFocus(itemId);
203
+ this.dispatchCheckChange(event, item, itemId);
204
+ },
205
+ onExpandChange: function onExpandChange(event, item, itemId) {
206
+ this.setFocus(itemId);
207
+ this.dispatchExpandChange(event, item, itemId);
208
+ },
209
+ onPress: function onPress(_event, item, itemId) {
210
+ this.$emit('itemdragstart', {
211
+ target: this,
212
+ item: item,
213
+ itemHierarchicalIndex: itemId
214
+ });
215
+ },
216
+ onDrag: function onDrag(event, item, itemId) {
217
+ var pageX = event.pageX,
218
+ pageY = event.pageY,
219
+ clientX = event.clientX,
220
+ clientY = event.clientY;
221
+ this.$emit('itemdragover', {
222
+ target: this,
223
+ item: item,
224
+ itemHierarchicalIndex: itemId,
225
+ pageX: pageX,
226
+ pageY: pageY,
227
+ clientX: clientX,
228
+ clientY: clientY
229
+ });
230
+ },
231
+ onRelease: function onRelease(event, item, itemId) {
232
+ var pageX = event.pageX,
233
+ pageY = event.pageY,
234
+ clientX = event.clientX,
235
+ clientY = event.clientY;
236
+ this.$emit('itemdragend', {
237
+ target: this,
238
+ item: item,
239
+ itemHierarchicalIndex: itemId,
240
+ pageX: pageX,
241
+ pageY: pageY,
242
+ clientX: clientX,
243
+ clientY: clientY
244
+ });
245
+ },
246
+ onItemClick: function onItemClick(event, item, itemId) {
247
+ this.setFocus(itemId);
248
+ this.dispatchItemClick(event, item, itemId);
249
+ },
250
+ onFocus: function onFocus() {
251
+ clearTimeout(this.blurRequest);
252
+
253
+ if (this.focusedItemId === undefined && this.dataItems.length) {
254
+ this.setFocus(this.tabbableItemId);
255
+ }
256
+ },
257
+ onBlur: function onBlur() {
258
+ var _this = this;
259
+
260
+ clearTimeout(this.blurRequest);
261
+ this.blurRequest = window.setTimeout(function () {
262
+ return _this.setFocus(undefined);
263
+ }, 0);
264
+ },
265
+ onKeyDown: function onKeyDown(event) {
266
+ var focusedItem = this.getFocusedItem();
267
+
268
+ if (focusedItem) {
269
+ var newItemId = nav(focusedItem, this.focusedItemId, this.dataItems, event.keyCode, this.fieldsSvc);
270
+
271
+ if (newItemId !== this.focusedItemId) {
272
+ // This disables the auto-scroll. The scroll is achieved via item focusing.
273
+ event.preventDefault();
274
+ this.allowExplicitFocus = true;
275
+ this.setFocus(newItemId);
276
+ }
277
+
278
+ this.dispatchEventsOnKeyDown(event, focusedItem);
279
+ }
280
+ },
281
+ dispatchEventsOnKeyDown: function dispatchEventsOnKeyDown(event, focusedItem) {
282
+ var _this = this; // isEnabled is the most expensive op and that is why is left last.
283
+
284
+
285
+ var isEnabled = function isEnabled() {
286
+ return isEnabledAndAllParentsEnabled(_this.focusedItemId, _this.dataItems, _this.fieldsSvc);
287
+ };
288
+
289
+ if (event.keyCode === Keys.left && this.fieldsSvc.expanded(focusedItem) && isEnabled()) {
290
+ this.dispatchExpandChange(event, focusedItem, this.focusedItemId);
291
+ } else if (event.keyCode === Keys.right && !this.fieldsSvc.expanded(focusedItem) && (this.fieldsSvc.hasChildren(focusedItem) || hasChildren(focusedItem, this.$props.childrenField)) && isEnabled()) {
292
+ this.dispatchExpandChange(event, focusedItem, this.focusedItemId);
293
+ } else if (event.keyCode === Keys.enter && isEnabled()) {
294
+ this.dispatchItemClick(event, focusedItem, this.focusedItemId);
295
+ } else if (event.keyCode === Keys.space && isEnabled()) {
296
+ // W/o preventDefault() long TreeViews gets incorrectly scrolled.
297
+ event.preventDefault();
298
+ this.dispatchCheckChange(event, focusedItem, this.focusedItemId);
299
+ }
300
+ },
301
+ setFocus: function setFocus(focusedItemId) {
302
+ if (focusedItemId) {
303
+ if (this.fieldsSvc.focusIdField) {
304
+ var item = this.getItemById(focusedItemId);
305
+ this.focusedItemId = focusedItemId;
306
+ this.focusedItemPublicId = this.fieldsSvc.focusId(item);
307
+ } else {
308
+ this.focusedItemId = focusedItemId;
309
+ }
310
+ } else {
311
+ var tempId = this.focusedItemId;
312
+ this.focusedItemId = undefined;
313
+ this.focusedItemPublicId = undefined;
314
+ this.tabbableItemId = tempId;
315
+ }
316
+ },
317
+ getFocusedItem: function getFocusedItem() {
318
+ return this.focusedItemId ? this.getItemById(this.focusedItemId) : undefined;
319
+ },
320
+ getItemById: function getItemById(itemId) {
321
+ return _getItemById(itemId, this.dataItems, this.$props.childrenField || CHILDREN_FIELD);
322
+ },
323
+ dispatchCheckChange: function dispatchCheckChange(_dispatchedEvent, item, itemId) {
324
+ this.$emit('checkchange', {
325
+ item: item,
326
+ itemHierarchicalIndex: itemId
327
+ });
328
+ },
329
+ dispatchExpandChange: function dispatchExpandChange(_dispatchedEvent, item, itemId) {
330
+ this.$emit('expandchange', {
331
+ item: item,
332
+ itemHierarchicalIndex: itemId
333
+ });
334
+ },
335
+ dispatchItemClick: function dispatchItemClick(_dispatchedEvent, item, itemId) {
336
+ this.$emit('itemclick', {
337
+ item: item,
338
+ itemHierarchicalIndex: itemId
339
+ });
340
+ },
341
+ refocusDueToFocusIdField: function refocusDueToFocusIdField() {
342
+ if (this.fieldsSvc.focusIdField) {
343
+ var focusedItemPublicId = this.focusedItemPublicId;
344
+
345
+ if (focusedItemPublicId) {
346
+ var focusedItemId = this.$props.getFocusHierarchicalIndex ? this.$props.getFocusHierarchicalIndex(focusedItemPublicId) : resolveItemId(focusedItemPublicId, this.fieldsSvc.focusIdField, this.dataItems, this.$props.childrenField);
347
+
348
+ if (focusedItemId !== this.focusedItemId) {
349
+ this.allowExplicitFocus = true;
350
+ this.focusedItemId = focusedItemId;
351
+ }
352
+ }
353
+ }
354
+ },
355
+ // private get ariaMultiSelectable() {
356
+ // return this.$props['aria-multiselectable'] === true || this.$props['aria-multiselectable'] === 'true';
357
+ // }
358
+ focusDomItem: function focusDomItem(domItem) {
359
+ domItem.focus();
360
+ },
361
+ guid: function guid() {
362
+ return this.treeGuid;
363
+ }
364
+ }
365
+ };
366
+ /**
367
+ *
368
+ *
369
+ * Represents the [Kendo UI for Vue Native TreeView component]({% slug overview_treeview %}).
370
+ *
371
+ * ```jsx
372
+ * <template>
373
+ * <div>
374
+ * <TreeView :dataItems="tree" />
375
+ * </div>
376
+ * </template>
377
+ *
378
+ * <script>
379
+ * import { TreeView } from '@progress/kendo-vue-treeview';
380
+ *
381
+ * export default {
382
+ * components: {
383
+ * TreeView,
384
+ * },
385
+ * data() {
386
+ * return {
387
+ * tree: [
388
+ * {
389
+ * text: 'Furniture',
390
+ * expanded: true,
391
+ * items: [
392
+ * {
393
+ * text: 'Tables & Chairs',
394
+ * },
395
+ * {
396
+ * text: 'Sofas',
397
+ * },
398
+ * {
399
+ * text: 'Occasional Furniture',
400
+ * },
401
+ * ],
402
+ * },
403
+ * {
404
+ * text: 'Decor',
405
+ * expanded: true,
406
+ * items: [
407
+ * {
408
+ * text: 'Bed Linen',
409
+ * },
410
+ * {
411
+ * text: 'Curtains & Blinds',
412
+ * },
413
+ * {
414
+ * text: 'Carpets',
415
+ * },
416
+ * ],
417
+ * },
418
+ * ],
419
+ * };
420
+ * },
421
+ * };
422
+ * </script>
423
+ * ```
424
+ *
425
+ *
426
+ *
427
+ * ### props <span class='code'>Readonly&lt;[TreeViewProps]({% slug api_treeview_treeviewprops %})&gt;</span>
428
+ * The props of the TreeView component.
429
+ *
430
+ * ### guid <span class='code'>string</span>
431
+ * Returns the `guid` which is associated with the TreeView.
432
+ */
433
+
434
+ var TreeView = TreeViewVue2;
435
+ export { TreeView, TreeViewVue2 };
@@ -0,0 +1,63 @@
1
+ import { TreeViewItemDragOverEvent, TreeViewItemDragEndEvent } from './events';
2
+ /**
3
+ * A class which provides an API for analyzing the `drag` events
4
+ * of the TreeView.
5
+ *
6
+ * {% meta height:400 %}
7
+ * {% embed_file drag/single/main.vue preview %}
8
+ * {% embed_file drag/single/main.js %}
9
+ * {% endmeta %}
10
+ *
11
+ * ### destinationMeta <span class='code'>{ itemHierarchicalIndex: string; treeViewGuid: string; }</span>
12
+ * Returns an object which contains:
13
+ * * The `itemHierarchicalIndex` of the destination item (the item below the dragged item) and
14
+ * * The `guid` of the destination TreeView (the TreeView which renders the destination item).
15
+ *
16
+ * ### isDropAllowed <span class='code'>boolean</span>
17
+ * Returns `true` if dropping is allowed. Otherwise, returns `false`.
18
+ */
19
+ declare class TreeViewDragAnalyzer {
20
+ private event;
21
+ private itemId;
22
+ private treeViewGuid;
23
+ private initialized;
24
+ private destDomNodeWithMeta;
25
+ private destItemId;
26
+ private destTreeViewGuid;
27
+ /**
28
+ * @param event - The event that will be analyzed.
29
+ */
30
+ constructor(event: TreeViewItemDragOverEvent | TreeViewItemDragEndEvent);
31
+ /**
32
+ * The method which initializes the analyzer.
33
+ * Invoke the method before you call any other methods.
34
+ *
35
+ * @returns - The analyzer object of the `drag` event.
36
+ */
37
+ init(): this;
38
+ /**
39
+ * Returns `true` if dropping is allowed. Otherwise, returns `false`.
40
+ */
41
+ get isDropAllowed(): boolean;
42
+ /**
43
+ * Returns an object which contains:
44
+ * * The `itemHierarchicalIndex` of the destination item (the item below the dragged item) and
45
+ * * The `guid` of the destination TreeView (the TreeView which renders the destination item).
46
+ */
47
+ get destinationMeta(): {
48
+ itemHierarchicalIndex: string;
49
+ treeViewGuid: string;
50
+ };
51
+ /**
52
+ * Returns the specific drop operation.
53
+ *
54
+ * @returns - The following values are returned:
55
+ * * `before`&mdash;Indicates that the dragged item is positioned at the beginning of the destination item.
56
+ * * `after`&mdash;Indicates that the dragged item is positioned at the end of the destination item.
57
+ * * `child`&mdash;Indicates that the dragged item is positioned in the middle of the destination item.
58
+ * * `undefined`&mdash;Indicates that dropping is not allowed.
59
+ */
60
+ getDropOperation(): "before" | "after" | "child";
61
+ private setDestimationMeta;
62
+ }
63
+ export { TreeViewDragAnalyzer };
@@ -0,0 +1,111 @@
1
+ import { DOM_KENDO_ITEM_ID_FIELD, DOM_KENDO_TREEVIEW_GUID_FIELD } from './utils/consts.js';
2
+ var DROPZONE_BOUNDARY_DELTA = 6;
3
+ /**
4
+ * A class which provides an API for analyzing the `drag` events
5
+ * of the TreeView.
6
+ *
7
+ * {% meta height:400 %}
8
+ * {% embed_file drag/single/main.vue preview %}
9
+ * {% embed_file drag/single/main.js %}
10
+ * {% endmeta %}
11
+ *
12
+ * ### destinationMeta <span class='code'>{ itemHierarchicalIndex: string; treeViewGuid: string; }</span>
13
+ * Returns an object which contains:
14
+ * * The `itemHierarchicalIndex` of the destination item (the item below the dragged item) and
15
+ * * The `guid` of the destination TreeView (the TreeView which renders the destination item).
16
+ *
17
+ * ### isDropAllowed <span class='code'>boolean</span>
18
+ * Returns `true` if dropping is allowed. Otherwise, returns `false`.
19
+ */
20
+ var TreeViewDragAnalyzer = /** @class */ (function () {
21
+ /**
22
+ * @param event - The event that will be analyzed.
23
+ */
24
+ function TreeViewDragAnalyzer(event) {
25
+ this.event = event;
26
+ this.initialized = false;
27
+ this.itemId = event.itemHierarchicalIndex;
28
+ this.treeViewGuid = event.target.guid();
29
+ }
30
+ /**
31
+ * The method which initializes the analyzer.
32
+ * Invoke the method before you call any other methods.
33
+ *
34
+ * @returns - The analyzer object of the `drag` event.
35
+ */
36
+ TreeViewDragAnalyzer.prototype.init = function () {
37
+ if (!this.initialized) {
38
+ this.setDestimationMeta(document.elementFromPoint(this.event.clientX, this.event.clientY));
39
+ this.initialized = true;
40
+ }
41
+ return this;
42
+ };
43
+ Object.defineProperty(TreeViewDragAnalyzer.prototype, "isDropAllowed", {
44
+ /**
45
+ * Returns `true` if dropping is allowed. Otherwise, returns `false`.
46
+ */
47
+ get: function () {
48
+ if (this.initialized && this.destItemId && this.destTreeViewGuid) {
49
+ // Disallow circular references.
50
+ return !(("".concat(this.destTreeViewGuid, "_").concat(this.destItemId, "_")).
51
+ startsWith("".concat(this.treeViewGuid, "_").concat(this.itemId, "_")));
52
+ }
53
+ else {
54
+ return false;
55
+ }
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
60
+ Object.defineProperty(TreeViewDragAnalyzer.prototype, "destinationMeta", {
61
+ /**
62
+ * Returns an object which contains:
63
+ * * The `itemHierarchicalIndex` of the destination item (the item below the dragged item) and
64
+ * * The `guid` of the destination TreeView (the TreeView which renders the destination item).
65
+ */
66
+ get: function () {
67
+ return { itemHierarchicalIndex: this.destItemId, treeViewGuid: this.destTreeViewGuid };
68
+ },
69
+ enumerable: false,
70
+ configurable: true
71
+ });
72
+ /**
73
+ * Returns the specific drop operation.
74
+ *
75
+ * @returns - The following values are returned:
76
+ * * `before`&mdash;Indicates that the dragged item is positioned at the beginning of the destination item.
77
+ * * `after`&mdash;Indicates that the dragged item is positioned at the end of the destination item.
78
+ * * `child`&mdash;Indicates that the dragged item is positioned in the middle of the destination item.
79
+ * * `undefined`&mdash;Indicates that dropping is not allowed.
80
+ */
81
+ TreeViewDragAnalyzer.prototype.getDropOperation = function () {
82
+ if (this.initialized && this.isDropAllowed) {
83
+ var _a = this.destDomNodeWithMeta.getBoundingClientRect(), top_1 = _a.top, height = _a.height;
84
+ if (top_1 + height - this.event.clientY < DROPZONE_BOUNDARY_DELTA) {
85
+ return 'after';
86
+ }
87
+ else if (this.event.clientY - top_1 < DROPZONE_BOUNDARY_DELTA) {
88
+ return 'before';
89
+ }
90
+ else {
91
+ return 'child';
92
+ }
93
+ }
94
+ else {
95
+ return undefined;
96
+ }
97
+ };
98
+ TreeViewDragAnalyzer.prototype.setDestimationMeta = function (element) {
99
+ var node = element;
100
+ while (node && !node[DOM_KENDO_ITEM_ID_FIELD]) {
101
+ node = node.parentNode;
102
+ }
103
+ if (node && node[DOM_KENDO_ITEM_ID_FIELD]) {
104
+ this.destDomNodeWithMeta = node;
105
+ this.destItemId = node[DOM_KENDO_ITEM_ID_FIELD];
106
+ this.destTreeViewGuid = node[DOM_KENDO_TREEVIEW_GUID_FIELD];
107
+ }
108
+ };
109
+ return TreeViewDragAnalyzer;
110
+ }());
111
+ export { TreeViewDragAnalyzer };
@@ -0,0 +1,78 @@
1
+ import { DefineComponent } from './additionalTypes';
2
+ import { RecordPropsDefinition, ComponentOptions } from 'vue/types/options';
3
+ declare type DefaultData<V> = object | ((this: V) => {});
4
+ declare type DefaultMethods<V> = {
5
+ [key: string]: (this: V, ...args: any[]) => any;
6
+ };
7
+ /**
8
+ * Represents the props of the Kendo UI for Vue TreeViewDragClue component.
9
+ */
10
+ export interface TreeViewDragClueProps {
11
+ }
12
+ /**
13
+ * @hidden
14
+ */
15
+ export interface TreeViewDragClueState {
16
+ }
17
+ /**
18
+ * @hidden
19
+ */
20
+ export interface TreeViewDragClueComputed {
21
+ [key: string]: any;
22
+ }
23
+ /**
24
+ * @hidden
25
+ */
26
+ export interface TreeViewDragClueMethods {
27
+ [key: string]: any;
28
+ }
29
+ /**
30
+ * @hidden
31
+ */
32
+ export interface TreeViewDragClueData {
33
+ visible?: boolean;
34
+ top?: number;
35
+ left?: number;
36
+ text?: string;
37
+ operationClassName?: string;
38
+ }
39
+ /**
40
+ * @hidden
41
+ */
42
+ export interface TreeViewDragClueAll extends Vue, TreeViewDragClueMethods, TreeViewDragClueData, TreeViewDragClueComputed, TreeViewDragClueState {
43
+ }
44
+ /**
45
+ * @hidden
46
+ */
47
+ declare let TreeViewDragClueVue2: ComponentOptions<TreeViewDragClueAll, DefaultData<TreeViewDragClueData>, DefaultMethods<TreeViewDragClueAll>, TreeViewDragClueComputed, RecordPropsDefinition<TreeViewDragClueProps>>;
48
+ /**
49
+ * Represents the Kendo UI for Vue Native TreeViewDragClue component which renders a clue when an item is dragged.
50
+ *
51
+ * {% meta height:400 %}
52
+ * {% embed_file drag/single/main.vue preview %}
53
+ * {% embed_file drag/single/main.js %}
54
+ * {% endmeta %}
55
+ *
56
+ * ## Methods
57
+ *
58
+ * ### hide
59
+ * Hides the TreeViewDragClue component.
60
+ *
61
+ * ### show
62
+ * Displays the TreeViewDragClue component.
63
+ *
64
+ * #### Parameters
65
+ * ##### top <span class='code'>number</span>
66
+ * The `top` CSS position of the component.
67
+ *
68
+ * ##### left <span class='code'>number</span>
69
+ * The `left` CSS position of the component.
70
+ *
71
+ * ##### text <span class='code'>string</span>
72
+ * The text of the component.
73
+ *
74
+ * ##### operationClassName <span class='code'>string</span>
75
+ * The CSS class name which is related to the specific drop operation.
76
+ */
77
+ declare const TreeViewDragClue: DefineComponent<TreeViewDragClueProps, any, TreeViewDragClueData, TreeViewDragClueComputed, TreeViewDragClueMethods, {}, {}, {}, string, TreeViewDragClueProps, TreeViewDragClueProps, {}>;
78
+ export { TreeViewDragClue, TreeViewDragClueVue2 };