@progress/kendo-vue-treeview 3.3.4 → 3.3.6-dev.202206170937

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 (42) hide show
  1. package/dist/cdn/js/kendo-vue-treeview.js +1 -1
  2. package/dist/es/TreeView.d.ts +70 -0
  3. package/dist/es/TreeView.js +72 -1
  4. package/dist/es/TreeViewDragAnalyzer.d.ts +15 -2
  5. package/dist/es/TreeViewDragAnalyzer.js +14 -2
  6. package/dist/es/TreeViewDragClue.d.ts +33 -90
  7. package/dist/es/TreeViewDragClue.js +34 -1
  8. package/dist/es/TreeViewItem.d.ts +6 -0
  9. package/dist/es/TreeViewItem.js +8 -1
  10. package/dist/es/TreeViewProps.d.ts +1 -1
  11. package/dist/es/additionalTypes.ts +11 -0
  12. package/dist/es/handleTreeViewCheckChange.d.ts +22 -40
  13. package/dist/es/handleTreeViewCheckChange.js +22 -40
  14. package/dist/es/main.d.ts +3 -3
  15. package/dist/es/main.js +3 -3
  16. package/dist/es/moveTreeViewItem.d.ts +31 -94
  17. package/dist/es/moveTreeViewItem.js +32 -95
  18. package/dist/es/package-metadata.js +1 -1
  19. package/dist/es/processTreeViewItems.d.ts +16 -43
  20. package/dist/es/processTreeViewItems.js +17 -44
  21. package/dist/es/utils/SortedPublicItemIds.js +0 -2
  22. package/dist/npm/TreeView.d.ts +70 -0
  23. package/dist/npm/TreeView.js +72 -1
  24. package/dist/npm/TreeViewDragAnalyzer.d.ts +15 -2
  25. package/dist/npm/TreeViewDragAnalyzer.js +15 -2
  26. package/dist/npm/TreeViewDragClue.d.ts +33 -90
  27. package/dist/npm/TreeViewDragClue.js +34 -1
  28. package/dist/npm/TreeViewItem.d.ts +6 -0
  29. package/dist/npm/TreeViewItem.js +8 -1
  30. package/dist/npm/TreeViewProps.d.ts +1 -1
  31. package/dist/npm/additionalTypes.ts +11 -0
  32. package/dist/npm/handleTreeViewCheckChange.d.ts +22 -40
  33. package/dist/npm/handleTreeViewCheckChange.js +22 -40
  34. package/dist/npm/main.d.ts +3 -3
  35. package/dist/npm/main.js +3 -3
  36. package/dist/npm/moveTreeViewItem.d.ts +31 -94
  37. package/dist/npm/moveTreeViewItem.js +30 -96
  38. package/dist/npm/package-metadata.js +1 -1
  39. package/dist/npm/processTreeViewItems.d.ts +16 -43
  40. package/dist/npm/processTreeViewItems.js +18 -45
  41. package/dist/npm/utils/SortedPublicItemIds.js +0 -2
  42. package/package.json +6 -6
@@ -5,99 +5,10 @@ declare type DefaultMethods<V> = {
5
5
  [key: string]: (this: V, ...args: any[]) => any;
6
6
  };
7
7
  /**
8
- * Represents the props of the KendoReact TreeViewDragClue component.
8
+ * Represents the props of the Kendo UI for Vue TreeViewDragClue component.
9
9
  */
10
10
  export interface TreeViewDragClueProps {
11
11
  }
12
- /**
13
- * Represents the KendoReact TreeViewDragClue component which renders a clue when an item is dragged.
14
- *
15
- * @example
16
- * ```jsx
17
- * class App extends React.Component {
18
- * dragClue;
19
- * state = { tree };
20
- *
21
- * render() {
22
- * return (
23
- * <div>
24
- * <TreeView data={this.state.tree} draggable={true}
25
- * onItemDragOver={this.onItemDragOver} onItemDragEnd={this.onItemDragEnd} />
26
- * <TreeViewDragClue ref={dragClue => this.dragClue = dragClue} />
27
- * </div>
28
- * );
29
- * }
30
- *
31
- * onItemDragOver = (event) => {
32
- * this.dragClue.show(event.pageY + 10, event.pageX, event.item.text, this.getClueClassName(event));
33
- * }
34
- * onItemDragEnd = (event) => {
35
- * this.dragClue.hide();
36
- * const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
37
- *
38
- * if (eventAnalyzer.isDropAllowed) {
39
- * const updatedTree = moveTreeViewItem(
40
- * event.itemHierarchicalIndex,
41
- * this.state.tree,
42
- * eventAnalyzer.getDropOperation(),
43
- * eventAnalyzer.destinationMeta.itemHierarchicalIndex,
44
- * );
45
- *
46
- * this.setState({ tree: updatedTree });
47
- * }
48
- * }
49
- * getClueClassName(event) {
50
- * const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
51
- * const itemIndex = eventAnalyzer.destinationMeta.itemHierarchicalIndex;
52
- *
53
- * if (eventAnalyzer.isDropAllowed) {
54
- * switch (eventAnalyzer.getDropOperation()) {
55
- * case 'child':
56
- * return 'k-i-plus';
57
- * case 'before':
58
- * return itemIndex === '0' || itemIndex.endsWith(`${SEPARATOR}0`) ?
59
- * 'k-i-insert-up' : 'k-i-insert-middle';
60
- * case 'after':
61
- * const siblings = getSiblings(itemIndex, this.state.tree);
62
- * const lastIndex = Number(itemIndex.split(SEPARATOR).pop());
63
- *
64
- * return lastIndex < siblings.length - 1 ? 'k-i-insert-middle' : 'k-i-insert-down';
65
- * default:
66
- * break;
67
- * }
68
- * }
69
- *
70
- * return 'k-i-cancel';
71
- * }
72
- * }
73
- *
74
- * function getSiblings(itemIndex, data) {
75
- * let result = data;
76
- *
77
- * const indices = itemIndex.split(SEPARATOR).map(index => Number(index));
78
- * for (let i = 0; i < indices.length - 1; i++) {
79
- * result = result[indices[i]].items;
80
- * }
81
- *
82
- * return result;
83
- * }
84
- *
85
- * const SEPARATOR = '_';
86
- * const tree = [{
87
- * text: 'Furniture', expanded: true, items: [
88
- * { text: 'Tables & Chairs', expanded: true },
89
- * { text: 'Sofas', expanded: true },
90
- * { text: 'Occasional Furniture', expanded: true }]
91
- * }, {
92
- * text: 'Decor', expanded: true, items: [
93
- * { text: 'Bed Linen', expanded: true },
94
- * { text: 'Curtains & Blinds', expanded: true },
95
- * { text: 'Carpets', expanded: true }]
96
- * }];
97
- *
98
- * ReactDOM.render(<App />, document.querySelector('my-app'));
99
- * ```
100
- */
101
12
  /**
102
13
  * @hidden
103
14
  */
@@ -130,6 +41,38 @@ export interface TreeViewDragClueData {
130
41
  */
131
42
  export interface TreeViewDragClueAll extends Vue, TreeViewDragClueMethods, TreeViewDragClueData, TreeViewDragClueComputed, TreeViewDragClueState {
132
43
  }
44
+ /**
45
+ * @hidden
46
+ */
133
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
+ */
134
77
  declare const TreeViewDragClue: DefineComponent<TreeViewDragClueProps, any, TreeViewDragClueData, TreeViewDragClueComputed, TreeViewDragClueMethods, {}, {}, {}, string, TreeViewDragClueProps, TreeViewDragClueProps, {}>;
135
78
  export { TreeViewDragClue, TreeViewDragClueVue2 };
@@ -26,7 +26,10 @@ var Vue = require("vue");
26
26
  var allVue = Vue;
27
27
  var gh = allVue.h;
28
28
 
29
- var kendo_vue_common_1 = require("@progress/kendo-vue-common"); // tslint:enable:max-line-length
29
+ var kendo_vue_common_1 = require("@progress/kendo-vue-common");
30
+ /**
31
+ * @hidden
32
+ */
30
33
 
31
34
 
32
35
  var TreeViewDragClueVue2 = {
@@ -84,5 +87,35 @@ var TreeViewDragClueVue2 = {
84
87
  }
85
88
  };
86
89
  exports.TreeViewDragClueVue2 = TreeViewDragClueVue2;
90
+ /**
91
+ * Represents the Kendo UI for Vue Native TreeViewDragClue component which renders a clue when an item is dragged.
92
+ *
93
+ * {% meta height:400 %}
94
+ * {% embed_file drag/single/main.vue preview %}
95
+ * {% embed_file drag/single/main.js %}
96
+ * {% endmeta %}
97
+ *
98
+ * ## Methods
99
+ *
100
+ * ### hide
101
+ * Hides the TreeViewDragClue component.
102
+ *
103
+ * ### show
104
+ * Displays the TreeViewDragClue component.
105
+ *
106
+ * #### Parameters
107
+ * ##### top <span class='code'>number</span>
108
+ * The `top` CSS position of the component.
109
+ *
110
+ * ##### left <span class='code'>number</span>
111
+ * The `left` CSS position of the component.
112
+ *
113
+ * ##### text <span class='code'>string</span>
114
+ * The text of the component.
115
+ *
116
+ * ##### operationClassName <span class='code'>string</span>
117
+ * The CSS class name which is related to the specific drop operation.
118
+ */
119
+
87
120
  var TreeViewDragClue = TreeViewDragClueVue2;
88
121
  exports.TreeViewDragClue = TreeViewDragClue;
@@ -64,6 +64,12 @@ export interface TreeViewItemData {
64
64
  */
65
65
  export interface TreeViewItemAll extends Vue, TreeViewItemMethods, TreeViewItemData, TreeViewItemComputed, TreeViewItemState {
66
66
  }
67
+ /**
68
+ * @hidden
69
+ */
67
70
  declare let TreeViewItemVue2: ComponentOptions<TreeViewItemAll, DefaultData<TreeViewItemData>, DefaultMethods<TreeViewItemAll>, TreeViewItemComputed, RecordPropsDefinition<TreeViewItemProps>>;
71
+ /**
72
+ * @hidden
73
+ */
68
74
  declare const TreeViewItem: DefineComponent<TreeViewItemProps, any, TreeViewItemData, TreeViewItemComputed, TreeViewItemMethods, {}, {}, {}, string, TreeViewItemProps, TreeViewItemProps, {}>;
69
75
  export { TreeViewItem, TreeViewItemVue2 };
@@ -36,7 +36,10 @@ var kendo_vue_animation_1 = require("@progress/kendo-vue-animation");
36
36
 
37
37
  var consts_1 = require("./utils/consts");
38
38
 
39
- var sizeMap = kendo_vue_common_1.kendoThemeMaps.sizeMap; // tslint:enable:max-line-length
39
+ var sizeMap = kendo_vue_common_1.kendoThemeMaps.sizeMap;
40
+ /**
41
+ * @hidden
42
+ */
40
43
 
41
44
  var TreeViewItemVue2 = {
42
45
  name: 'KendoTreeViewItem',
@@ -406,5 +409,9 @@ var TreeViewItemVue2 = {
406
409
  }
407
410
  };
408
411
  exports.TreeViewItemVue2 = TreeViewItemVue2;
412
+ /**
413
+ * @hidden
414
+ */
415
+
409
416
  var TreeViewItem = TreeViewItemVue2;
410
417
  exports.TreeViewItem = TreeViewItem;
@@ -1,6 +1,6 @@
1
1
  import * as events from './events';
2
2
  /**
3
- * Represents the props of the [KendoReact TreeView component]({% slug overview_treeview %}).
3
+ * Represents the props of the [Kendo UI for Vue TreeView component]({% slug overview_treeview %}).
4
4
  */
5
5
  export interface TreeViewProps {
6
6
  /**
@@ -2,9 +2,20 @@
2
2
  import { DefineComponent } from 'vue';
3
3
  // @ts-ignore
4
4
  import * as Vue from 'vue';
5
+
6
+ /**
7
+ * @hidden
8
+ */
5
9
  // @ts-ignore
6
10
  type Vue2type = Vue.default;
11
+
12
+ /**
13
+ * @hidden
14
+ */
7
15
  // @ts-ignore
8
16
  import { RecordPropsDefinition, ComponentOptions } from 'vue/types/options';
17
+ /**
18
+ * @hidden
19
+ */
9
20
  // @ts-ignore
10
21
  export { DefineComponent, RecordPropsDefinition, ComponentOptions, Vue2type };
@@ -18,50 +18,32 @@ export interface TreeViewCheckChangeSettings {
18
18
  checkParents?: boolean;
19
19
  }
20
20
  /**
21
+ *
21
22
  * A helper function which updates the check descriptor.
22
23
  *
23
- * @param event - The event that triggered the change.
24
- * @param check - The check descriptor that will be updated.
25
- * @param data - The TreeView items.
26
- * @param settings - The additional settings that configure the update of the check descriptor.
27
- * @param childrenField - The field that points to the dataItem sub items. Defaults to `items`.
28
- * The default behavior allows the selection of multiple items.
29
- * @returns - The updated copy of the input check descriptor.
24
+ * {% meta height:650 %}
25
+ * {% embed_file checkbox/checkbox-helper/main.vue preview %}
26
+ * {% embed_file checkbox/checkbox-helper/main.js %}
27
+ * {% endmeta %}
28
+ *
29
+ * #### Parameters
30
+ * ##### event <span class='code'>[TreeViewExpandChangeEvent]({% slug api_treeview_treeviewexpandchangeevent %})</span>
31
+ * The event that triggered the change.
32
+ *
33
+ * ##### check <span class='code'>string[] | [TreeViewCheckDescriptor]({% slug api_treeview_treeviewcheckdescriptor %})</span>
34
+ * The check descriptor that will be updated.
35
+ *
36
+ * ##### data? <span class='code'>any[] | null</span>
37
+ * The TreeView items.
30
38
  *
31
- * @example
32
- * ```jsx
33
- * class App extends React.Component {
34
- * state = { check: [], items: tree };
35
- * render() {
36
- * return (
37
- * <div>
38
- * <TreeView
39
- * checkboxes={true} onCheckChange={this.onCheckChange}
40
- * data={processTreeViewItems(this.state.items, { check: this.state.check })}
41
- * />
42
- * <div style={{ marginTop: 5 }}>
43
- * <i>Press SPACE to check/uncheck the active item</i>
44
- * <div className="example-config">
45
- * Checked Indices: {this.state.check.join(",")}
46
- * </div>
47
- * </div>
48
- * </div>
49
- * );
50
- * }
51
- * onCheckChange = (event) => {
52
- * this.setState({ check: handleTreeViewCheckChange(event, this.state.check, this.state.items) });
53
- * }
54
- * }
39
+ * ##### settings <span class='code'>[TreeViewCheckChangeSettings]({% slug api_treeview_treeviewcheckchangesettings %})</span>
40
+ * The additional settings that configure the update of the check descriptor.
55
41
  *
56
- * const tree = [ {
57
- * text: 'Furniture', expanded: true, items: [
58
- * { text: 'Tables & Chairs' }, { text: 'Sofas' }, { text: 'Occasional Furniture' } ]
59
- * }, {
60
- * text: 'Decor', expanded: true, items: [
61
- * { text: 'Bed Linen' }, { text: 'Curtains & Blinds' }, { text: 'Carpets' } ]
62
- * } ];
42
+ * ##### childrenField? <span class='code'>string</span>
43
+ * The field that points to the dataItem sub items. Defaults to `items`.
44
+ * The default behavior allows the selection of multiple items.
63
45
  *
64
- * ReactDOM.render(<App />, document.querySelector('my-app'));
65
- * ```
46
+ * #### Returns
47
+ * <span class='code'>any</span> - The updated copy of the input check descriptor.
66
48
  */
67
49
  export declare function handleTreeViewCheckChange(event: TreeViewExpandChangeEvent, check: string[] | TreeViewCheckDescriptor, data?: any[] | null, settings?: TreeViewCheckChangeSettings, childrenField?: string): any;
@@ -33,51 +33,33 @@ var itemIdUtils_1 = require("./utils/itemIdUtils");
33
33
  var misc_1 = require("./utils/misc");
34
34
  var consts_1 = require("./utils/consts");
35
35
  /**
36
+ *
36
37
  * A helper function which updates the check descriptor.
37
38
  *
38
- * @param event - The event that triggered the change.
39
- * @param check - The check descriptor that will be updated.
40
- * @param data - The TreeView items.
41
- * @param settings - The additional settings that configure the update of the check descriptor.
42
- * @param childrenField - The field that points to the dataItem sub items. Defaults to `items`.
43
- * The default behavior allows the selection of multiple items.
44
- * @returns - The updated copy of the input check descriptor.
39
+ * {% meta height:650 %}
40
+ * {% embed_file checkbox/checkbox-helper/main.vue preview %}
41
+ * {% embed_file checkbox/checkbox-helper/main.js %}
42
+ * {% endmeta %}
43
+ *
44
+ * #### Parameters
45
+ * ##### event <span class='code'>[TreeViewExpandChangeEvent]({% slug api_treeview_treeviewexpandchangeevent %})</span>
46
+ * The event that triggered the change.
47
+ *
48
+ * ##### check <span class='code'>string[] | [TreeViewCheckDescriptor]({% slug api_treeview_treeviewcheckdescriptor %})</span>
49
+ * The check descriptor that will be updated.
50
+ *
51
+ * ##### data? <span class='code'>any[] | null</span>
52
+ * The TreeView items.
45
53
  *
46
- * @example
47
- * ```jsx
48
- * class App extends React.Component {
49
- * state = { check: [], items: tree };
50
- * render() {
51
- * return (
52
- * <div>
53
- * <TreeView
54
- * checkboxes={true} onCheckChange={this.onCheckChange}
55
- * data={processTreeViewItems(this.state.items, { check: this.state.check })}
56
- * />
57
- * <div style={{ marginTop: 5 }}>
58
- * <i>Press SPACE to check/uncheck the active item</i>
59
- * <div className="example-config">
60
- * Checked Indices: {this.state.check.join(",")}
61
- * </div>
62
- * </div>
63
- * </div>
64
- * );
65
- * }
66
- * onCheckChange = (event) => {
67
- * this.setState({ check: handleTreeViewCheckChange(event, this.state.check, this.state.items) });
68
- * }
69
- * }
54
+ * ##### settings <span class='code'>[TreeViewCheckChangeSettings]({% slug api_treeview_treeviewcheckchangesettings %})</span>
55
+ * The additional settings that configure the update of the check descriptor.
70
56
  *
71
- * const tree = [ {
72
- * text: 'Furniture', expanded: true, items: [
73
- * { text: 'Tables & Chairs' }, { text: 'Sofas' }, { text: 'Occasional Furniture' } ]
74
- * }, {
75
- * text: 'Decor', expanded: true, items: [
76
- * { text: 'Bed Linen' }, { text: 'Curtains & Blinds' }, { text: 'Carpets' } ]
77
- * } ];
57
+ * ##### childrenField? <span class='code'>string</span>
58
+ * The field that points to the dataItem sub items. Defaults to `items`.
59
+ * The default behavior allows the selection of multiple items.
78
60
  *
79
- * ReactDOM.render(<App />, document.querySelector('my-app'));
80
- * ```
61
+ * #### Returns
62
+ * <span class='code'>any</span> - The updated copy of the input check descriptor.
81
63
  */
82
64
  function handleTreeViewCheckChange(event, check, data, settings, childrenField) {
83
65
  if (settings === void 0) { settings = {}; }
@@ -1,12 +1,12 @@
1
1
  import { TreeView } from './TreeView';
2
2
  import { TreeViewItemClickEvent, TreeViewExpandChangeEvent, TreeViewCheckChangeEvent, TreeViewItemDragOverEvent, TreeViewItemDragStartEvent, TreeViewItemDragEndEvent } from './events';
3
- import processTreeViewItems from './processTreeViewItems';
4
- import moveTreeViewItem from './moveTreeViewItem';
3
+ import { processTreeViewItems } from './processTreeViewItems';
4
+ import { moveTreeViewItem } from './moveTreeViewItem';
5
5
  import { handleTreeViewCheckChange, TreeViewCheckChangeSettings } from './handleTreeViewCheckChange';
6
6
  import { TreeViewOperationDescriptor, TreeViewOperationDescriptors, TreeViewCheckDescriptor } from './TreeViewOperationDescriptors';
7
7
  import { ItemRenderProps } from './ItemRenderProps';
8
8
  import { TreeViewProps } from './TreeViewProps';
9
9
  import { TreeViewDragClue } from './TreeViewDragClue';
10
- import TreeViewDragAnalyzer from './TreeViewDragAnalyzer';
10
+ import { TreeViewDragAnalyzer } from './TreeViewDragAnalyzer';
11
11
  import { TreeViewItem } from './TreeViewItem';
12
12
  export { TreeViewItem, TreeView, processTreeViewItems, handleTreeViewCheckChange, TreeViewCheckChangeSettings, TreeViewItemClickEvent, TreeViewExpandChangeEvent, TreeViewCheckChangeEvent, TreeViewItemDragOverEvent, TreeViewItemDragStartEvent, TreeViewItemDragEndEvent, TreeViewOperationDescriptor, TreeViewOperationDescriptors, TreeViewCheckDescriptor, TreeViewProps, ItemRenderProps, TreeViewDragClue, moveTreeViewItem, TreeViewDragAnalyzer };
package/dist/npm/main.js CHANGED
@@ -4,14 +4,14 @@ exports.TreeViewDragAnalyzer = exports.moveTreeViewItem = exports.TreeViewDragCl
4
4
  var TreeView_1 = require("./TreeView");
5
5
  Object.defineProperty(exports, "TreeView", { enumerable: true, get: function () { return TreeView_1.TreeView; } });
6
6
  var processTreeViewItems_1 = require("./processTreeViewItems");
7
- exports.processTreeViewItems = processTreeViewItems_1.default;
7
+ Object.defineProperty(exports, "processTreeViewItems", { enumerable: true, get: function () { return processTreeViewItems_1.processTreeViewItems; } });
8
8
  var moveTreeViewItem_1 = require("./moveTreeViewItem");
9
- exports.moveTreeViewItem = moveTreeViewItem_1.default;
9
+ Object.defineProperty(exports, "moveTreeViewItem", { enumerable: true, get: function () { return moveTreeViewItem_1.moveTreeViewItem; } });
10
10
  var handleTreeViewCheckChange_1 = require("./handleTreeViewCheckChange");
11
11
  Object.defineProperty(exports, "handleTreeViewCheckChange", { enumerable: true, get: function () { return handleTreeViewCheckChange_1.handleTreeViewCheckChange; } });
12
12
  var TreeViewDragClue_1 = require("./TreeViewDragClue");
13
13
  Object.defineProperty(exports, "TreeViewDragClue", { enumerable: true, get: function () { return TreeViewDragClue_1.TreeViewDragClue; } });
14
14
  var TreeViewDragAnalyzer_1 = require("./TreeViewDragAnalyzer");
15
- exports.TreeViewDragAnalyzer = TreeViewDragAnalyzer_1.default;
15
+ Object.defineProperty(exports, "TreeViewDragAnalyzer", { enumerable: true, get: function () { return TreeViewDragAnalyzer_1.TreeViewDragAnalyzer; } });
16
16
  var TreeViewItem_1 = require("./TreeViewItem");
17
17
  Object.defineProperty(exports, "TreeViewItem", { enumerable: true, get: function () { return TreeViewItem_1.TreeViewItem; } });
@@ -1,109 +1,46 @@
1
1
  /**
2
2
  * A helper function which moves a TreeView item in an immutable way.
3
3
  *
4
- * @param sourceItemHierarchicalIndex - The hierarchical index of the item that will be moved.
5
- * @param sourceData - The tree which contains the item that will be moved.
6
- * @param operation - The specific move operation.
4
+ * {% meta height:400 %}
5
+ * {% embed_file drag/single/main.vue preview %}
6
+ * {% embed_file drag/single/main.js %}
7
+ * {% endmeta %}
7
8
  *
8
- * The available options are:
9
- * * `before`&mdash;Indicates that the source item will become the previous sibling of the target item.
10
- * * `after`&mdash;Indicates that the source item will become the next sibling of the target item.
11
- * * `child`&mdash;Indicates that the source item will become a child of the target item.
12
- * @param targetItemHierarchicalIndex - The hierarchical index of the item next to which the source item will be moved.
13
- * @param targetData - The tree which contains the target item.
14
- * If the argument is skipped, then the move operation will be executed within the same tree.
15
- * Setting the `sourceData` and `targetData` arguments to the same tree is also supported.
16
- * @param childrenField - The field that points to the dataItem sub items. Defaults to `items`.
17
- * @returns - The updated copies of the `sourceData` and `targetData` input arguments.
18
- * If `targetData` is not passed, then only the updated copy of the `sourceData` will be returned.
9
+ * #### Parameters
10
+ * ##### sourceItemHierarchicalIndex <span class='code'>string</span>
11
+ * The hierarchical index of the item that will be moved.
19
12
  *
20
- * @example
21
- * ```jsx
22
- * class App extends React.Component {
23
- * dragClue;
24
- * state = { tree };
13
+ * ##### sourceData <span class='code'>any[] | null | undefined</span>
14
+ * The tree which contains the item that will be moved.
25
15
  *
26
- * render() {
27
- * return (
28
- * <div>
29
- * <TreeView data={this.state.tree} draggable={true}
30
- * onItemDragOver={this.onItemDragOver} onItemDragEnd={this.onItemDragEnd} />
31
- * <TreeViewDragClue ref={dragClue => this.dragClue = dragClue} />
32
- * </div>
33
- * );
34
- * }
16
+ * ##### operation <span class='code'>"before" | "after" | "child"</span>
17
+ * The specific move operation.
35
18
  *
36
- * onItemDragOver = (event) => {
37
- * this.dragClue.show(event.pageY + 10, event.pageX, event.item.text, this.getClueClassName(event));
38
- * }
39
- * onItemDragEnd = (event) => {
40
- * this.dragClue.hide();
41
- * const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
19
+ * The available options are:
20
+ * * `before`&mdash;Indicates that the source item will become the previous sibling of the target item.
21
+ * * `after`&mdash;Indicates that the source item will become the next sibling of the target item.
22
+ * * `child`&mdash;Indicates that the source item will become a child of the target item.
42
23
  *
43
- * if (eventAnalyzer.isDropAllowed) {
44
- * const updatedTree = moveTreeViewItem(
45
- * event.itemHierarchicalIndex,
46
- * this.state.tree,
47
- * eventAnalyzer.getDropOperation(),
48
- * eventAnalyzer.destinationMeta.itemHierarchicalIndex,
49
- * );
24
+ * ##### targetItemHierarchicalIndex <span class='code'>string</span>
25
+ * The hierarchical index of the item next to which the source item will be moved.
50
26
  *
51
- * this.setState({ tree: updatedTree });
52
- * }
53
- * }
54
- * getClueClassName(event) {
55
- * const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
56
- * const itemIndex = eventAnalyzer.destinationMeta.itemHierarchicalIndex;
27
+ * ##### targetData? <span class='code'>any[] | null</span>
28
+ * The tree which contains the target item.
29
+ * If the argument is skipped, then the move operation will be executed within the same tree.
30
+ * Setting the `sourceData` and `targetData` arguments to the same tree is also supported.
57
31
  *
58
- * if (eventAnalyzer.isDropAllowed) {
59
- * switch (eventAnalyzer.getDropOperation()) {
60
- * case 'child':
61
- * return 'k-i-plus';
62
- * case 'before':
63
- * return itemIndex === '0' || itemIndex.endsWith(`${SEPARATOR}0`) ?
64
- * 'k-i-insert-up' : 'k-i-insert-middle';
65
- * case 'after':
66
- * const siblings = getSiblings(itemIndex, this.state.tree);
67
- * const lastIndex = Number(itemIndex.split(SEPARATOR).pop());
32
+ * ##### childrenField? <span class='code'>string</span>
33
+ * The field that points to the dataItem sub items. Defaults to `items`.
68
34
  *
69
- * return lastIndex < siblings.length - 1 ? 'k-i-insert-middle' : 'k-i-insert-down';
70
- * default:
71
- * break;
72
- * }
73
- * }
74
- *
75
- * return 'k-i-cancel';
76
- * }
77
- * }
78
- *
79
- * function getSiblings(itemIndex, data) {
80
- * let result = data;
81
- *
82
- * const indices = itemIndex.split(SEPARATOR).map(index => Number(index));
83
- * for (let i = 0; i < indices.length - 1; i++) {
84
- * result = result[indices[i]].items;
85
- * }
86
- *
87
- * return result;
88
- * }
89
- *
90
- * const SEPARATOR = '_';
91
- * const tree = [{
92
- * text: 'Furniture', expanded: true, items: [
93
- * { text: 'Tables & Chairs', expanded: true },
94
- * { text: 'Sofas', expanded: true },
95
- * { text: 'Occasional Furniture', expanded: true }]
96
- * }, {
97
- * text: 'Decor', expanded: true, items: [
98
- * { text: 'Bed Linen', expanded: true },
99
- * { text: 'Curtains & Blinds', expanded: true },
100
- * { text: 'Carpets', expanded: true }]
101
- * }];
102
- *
103
- * ReactDOM.render(<App />, document.querySelector('my-app'));
104
- * ```
35
+ * #### Returns
36
+ * <span class='code'>any[] | { sourceData: any[]; targetData: any[]; }</span> - The updated copies of the `sourceData` and `targetData` input arguments.
37
+ * If `targetData` is not passed, then only the updated copy of the `sourceData` will be returned.
105
38
  */
106
- export default function moveTreeViewItem(sourceItemHierarchicalIndex: string, sourceData: any[] | null | undefined, operation: 'before' | 'after' | 'child', targetItemHierarchicalIndex: string, targetData?: any[] | null, childrenField?: string): any[] | {
39
+ declare const moveTreeViewItem: (sourceItemHierarchicalIndex: string, sourceData: any[] | null | undefined, operation: 'before' | 'after' | 'child', targetItemHierarchicalIndex: string, targetData?: any[] | null, childrenField?: string) => any[] | {
107
40
  sourceData: any[];
108
41
  targetData: any[];
109
42
  };
43
+ /**
44
+ * @hidden
45
+ */
46
+ export { moveTreeViewItem };