@progress/kendo-react-treeview 6.1.1 → 7.0.0-develop.2
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.
- package/{dist/es/ItemRenderProps.d.ts → ItemRenderProps.d.ts} +4 -0
- package/LICENSE.md +1 -1
- package/{dist/npm/TreeView.d.ts → TreeView.d.ts} +5 -1
- package/{dist/es/TreeViewDragAnalyzer.d.ts → TreeViewDragAnalyzer.d.ts} +5 -1
- package/{dist/npm/TreeViewDragClue.d.ts → TreeViewDragClue.d.ts} +5 -1
- package/{dist/npm/TreeViewItem.d.ts → TreeViewItem.d.ts} +5 -1
- package/{dist/es/TreeViewOperationDescriptors.d.ts → TreeViewOperationDescriptors.d.ts} +4 -0
- package/{dist/es/TreeViewProps.d.ts → TreeViewProps.d.ts} +4 -0
- package/dist/cdn/js/kendo-react-treeview.js +5 -1
- package/{dist/es/events.d.ts → events.d.ts} +4 -1
- package/{dist/npm/handleTreeViewCheckChange.d.ts → handleTreeViewCheckChange.d.ts} +4 -0
- package/{dist/es/main.d.ts → index.d.ts} +9 -5
- package/index.js +5 -0
- package/index.mjs +745 -0
- package/{dist/npm/moveTreeViewItem.d.ts → moveTreeViewItem.d.ts} +4 -0
- package/package-metadata.d.ts +9 -0
- package/package.json +28 -37
- package/{dist/es/processTreeViewItems.d.ts → processTreeViewItems.d.ts} +4 -0
- package/{dist/npm/utils → utils}/consts.d.ts +4 -0
- package/utils/getItemIdUponKeyboardNavigation.d.ts +9 -0
- package/about.md +0 -3
- package/dist/es/ItemRenderProps.js +0 -2
- package/dist/es/TreeView.d.ts +0 -124
- package/dist/es/TreeView.js +0 -334
- package/dist/es/TreeViewDragAnalyzer.js +0 -186
- package/dist/es/TreeViewDragClue.d.ts +0 -144
- package/dist/es/TreeViewDragClue.js +0 -171
- package/dist/es/TreeViewItem.d.ts +0 -96
- package/dist/es/TreeViewItem.js +0 -255
- package/dist/es/TreeViewOperationDescriptors.js +0 -2
- package/dist/es/TreeViewProps.js +0 -1
- package/dist/es/events.js +0 -1
- package/dist/es/handleTreeViewCheckChange.d.ts +0 -69
- package/dist/es/handleTreeViewCheckChange.js +0 -193
- package/dist/es/main.js +0 -10
- package/dist/es/moveTreeViewItem.d.ts +0 -109
- package/dist/es/moveTreeViewItem.js +0 -155
- package/dist/es/package-metadata.d.ts +0 -5
- package/dist/es/package-metadata.js +0 -11
- package/dist/es/processTreeViewItems.js +0 -163
- package/dist/es/utils/consts.d.ts +0 -40
- package/dist/es/utils/consts.js +0 -40
- package/dist/es/utils/getItemIdUponKeyboardNavigation.d.ts +0 -5
- package/dist/es/utils/getItemIdUponKeyboardNavigation.js +0 -76
- package/dist/npm/ItemRenderProps.d.ts +0 -13
- package/dist/npm/ItemRenderProps.js +0 -3
- package/dist/npm/TreeView.js +0 -337
- package/dist/npm/TreeViewDragAnalyzer.d.ts +0 -135
- package/dist/npm/TreeViewDragAnalyzer.js +0 -189
- package/dist/npm/TreeViewDragClue.js +0 -174
- package/dist/npm/TreeViewItem.js +0 -258
- package/dist/npm/TreeViewOperationDescriptors.d.ts +0 -76
- package/dist/npm/TreeViewOperationDescriptors.js +0 -3
- package/dist/npm/TreeViewProps.d.ts +0 -137
- package/dist/npm/TreeViewProps.js +0 -2
- package/dist/npm/events.d.ts +0 -159
- package/dist/npm/events.js +0 -2
- package/dist/npm/handleTreeViewCheckChange.js +0 -197
- package/dist/npm/main.d.ts +0 -14
- package/dist/npm/main.js +0 -21
- package/dist/npm/moveTreeViewItem.js +0 -159
- package/dist/npm/package-metadata.d.ts +0 -5
- package/dist/npm/package-metadata.js +0 -14
- package/dist/npm/processTreeViewItems.d.ts +0 -51
- package/dist/npm/processTreeViewItems.js +0 -167
- package/dist/npm/utils/consts.js +0 -43
- package/dist/npm/utils/getItemIdUponKeyboardNavigation.d.ts +0 -5
- package/dist/npm/utils/getItemIdUponKeyboardNavigation.js +0 -79
- package/dist/systemjs/kendo-react-treeview.js +0 -1
- package/e2e-next/basic.tests.ts +0 -24
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { DOM_KENDO_ITEM_ID_FIELD, DOM_KENDO_TREEVIEW_GUID_FIELD } from './utils/consts';
|
|
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
|
-
* @example
|
|
8
|
-
* ```jsx
|
|
9
|
-
* class App extends React.Component {
|
|
10
|
-
* dragClue;
|
|
11
|
-
* state = { tree };
|
|
12
|
-
*
|
|
13
|
-
* render() {
|
|
14
|
-
* return (
|
|
15
|
-
* <div>
|
|
16
|
-
* <TreeView data={this.state.tree} draggable={true}
|
|
17
|
-
* onItemDragOver={this.onItemDragOver} onItemDragEnd={this.onItemDragEnd} />
|
|
18
|
-
* <TreeViewDragClue ref={dragClue => this.dragClue = dragClue} />
|
|
19
|
-
* </div>
|
|
20
|
-
* );
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* onItemDragOver = (event) => {
|
|
24
|
-
* this.dragClue.show(event.pageY + 10, event.pageX, event.item.text, this.getClueClassName(event));
|
|
25
|
-
* }
|
|
26
|
-
* onItemDragEnd = (event) => {
|
|
27
|
-
* this.dragClue.hide();
|
|
28
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
29
|
-
*
|
|
30
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
31
|
-
* const updatedTree = moveTreeViewItem(
|
|
32
|
-
* event.itemHierarchicalIndex,
|
|
33
|
-
* this.state.tree,
|
|
34
|
-
* eventAnalyzer.getDropOperation(),
|
|
35
|
-
* eventAnalyzer.destinationMeta.itemHierarchicalIndex,
|
|
36
|
-
* );
|
|
37
|
-
*
|
|
38
|
-
* this.setState({ tree: updatedTree });
|
|
39
|
-
* }
|
|
40
|
-
* }
|
|
41
|
-
* getClueClassName(event) {
|
|
42
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
43
|
-
* const itemIndex = eventAnalyzer.destinationMeta.itemHierarchicalIndex;
|
|
44
|
-
*
|
|
45
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
46
|
-
* switch (eventAnalyzer.getDropOperation()) {
|
|
47
|
-
* case 'child':
|
|
48
|
-
* return 'k-i-plus';
|
|
49
|
-
* case 'before':
|
|
50
|
-
* return itemIndex === '0' || itemIndex.endsWith(`${SEPARATOR}0`) ?
|
|
51
|
-
* 'k-i-insert-up' : 'k-i-insert-middle';
|
|
52
|
-
* case 'after':
|
|
53
|
-
* const siblings = getSiblings(itemIndex, this.state.tree);
|
|
54
|
-
* const lastIndex = Number(itemIndex.split(SEPARATOR).pop());
|
|
55
|
-
*
|
|
56
|
-
* return lastIndex < siblings.length - 1 ? 'k-i-insert-middle' : 'k-i-insert-down';
|
|
57
|
-
* default:
|
|
58
|
-
* break;
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
*
|
|
62
|
-
* return 'k-i-cancel';
|
|
63
|
-
* }
|
|
64
|
-
* }
|
|
65
|
-
*
|
|
66
|
-
* function getSiblings(itemIndex, data) {
|
|
67
|
-
* let result = data;
|
|
68
|
-
*
|
|
69
|
-
* const indices = itemIndex.split(SEPARATOR).map(index => Number(index));
|
|
70
|
-
* for (let i = 0; i < indices.length - 1; i++) {
|
|
71
|
-
* result = result[indices[i]].items;
|
|
72
|
-
* }
|
|
73
|
-
*
|
|
74
|
-
* return result;
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* const SEPARATOR = '_';
|
|
78
|
-
* const tree = [{
|
|
79
|
-
* text: 'Furniture', expanded: true, items: [
|
|
80
|
-
* { text: 'Tables & Chairs', expanded: true },
|
|
81
|
-
* { text: 'Sofas', expanded: true },
|
|
82
|
-
* { text: 'Occasional Furniture', expanded: true }]
|
|
83
|
-
* }, {
|
|
84
|
-
* text: 'Decor', expanded: true, items: [
|
|
85
|
-
* { text: 'Bed Linen', expanded: true },
|
|
86
|
-
* { text: 'Curtains & Blinds', expanded: true },
|
|
87
|
-
* { text: 'Carpets', expanded: true }]
|
|
88
|
-
* }];
|
|
89
|
-
*
|
|
90
|
-
* ReactDOM.render(<App />, document.querySelector('my-app'));
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
var TreeViewDragAnalyzer = /** @class */ (function () {
|
|
94
|
-
/**
|
|
95
|
-
* @param event - The event that will be analyzed.
|
|
96
|
-
*/
|
|
97
|
-
function TreeViewDragAnalyzer(event) {
|
|
98
|
-
this.event = event;
|
|
99
|
-
this.initialized = false;
|
|
100
|
-
this.destItemId = '';
|
|
101
|
-
this.destTreeViewGuid = '';
|
|
102
|
-
this.itemId = event.itemHierarchicalIndex;
|
|
103
|
-
this.treeViewGuid = event.target.guid;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* The method which initializes the analyzer.
|
|
107
|
-
* Invoke the method before you call any other methods.
|
|
108
|
-
*
|
|
109
|
-
* @returns - The analyzer object of the `drag` event.
|
|
110
|
-
*/
|
|
111
|
-
TreeViewDragAnalyzer.prototype.init = function () {
|
|
112
|
-
if (!this.initialized) {
|
|
113
|
-
this.setDestimationMeta(document.elementFromPoint(this.event.clientX, this.event.clientY));
|
|
114
|
-
this.initialized = true;
|
|
115
|
-
}
|
|
116
|
-
return this;
|
|
117
|
-
};
|
|
118
|
-
Object.defineProperty(TreeViewDragAnalyzer.prototype, "isDropAllowed", {
|
|
119
|
-
/**
|
|
120
|
-
* Returns `true` if dropping is allowed. Otherwise, returns `false`.
|
|
121
|
-
*/
|
|
122
|
-
get: function () {
|
|
123
|
-
if (this.initialized && this.destItemId && this.destTreeViewGuid) {
|
|
124
|
-
// Disallow circular references.
|
|
125
|
-
return !(("".concat(this.destTreeViewGuid, "_").concat(this.destItemId, "_")).
|
|
126
|
-
startsWith("".concat(this.treeViewGuid, "_").concat(this.itemId, "_")));
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
enumerable: false,
|
|
133
|
-
configurable: true
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(TreeViewDragAnalyzer.prototype, "destinationMeta", {
|
|
136
|
-
/**
|
|
137
|
-
* Returns an object which contains:
|
|
138
|
-
* * The `itemHierarchicalIndex` of the destination item (the item below the dragged item) and
|
|
139
|
-
* * The `guid` of the destination TreeView (the TreeView which renders the destination item).
|
|
140
|
-
*/
|
|
141
|
-
get: function () {
|
|
142
|
-
return { itemHierarchicalIndex: this.destItemId, treeViewGuid: this.destTreeViewGuid };
|
|
143
|
-
},
|
|
144
|
-
enumerable: false,
|
|
145
|
-
configurable: true
|
|
146
|
-
});
|
|
147
|
-
/**
|
|
148
|
-
* Returns the specific drop operation.
|
|
149
|
-
*
|
|
150
|
-
* @returns - The following values are returned:
|
|
151
|
-
* * `before`—Indicates that the dragged item is positioned at the beginning of the destination item.
|
|
152
|
-
* * `after`—Indicates that the dragged item is positioned at the end of the destination item.
|
|
153
|
-
* * `child`—Indicates that the dragged item is positioned in the middle of the destination item.
|
|
154
|
-
* * `undefined`—Indicates that dropping is not allowed.
|
|
155
|
-
*/
|
|
156
|
-
TreeViewDragAnalyzer.prototype.getDropOperation = function () {
|
|
157
|
-
if (this.initialized && this.isDropAllowed) {
|
|
158
|
-
var _a = this.destDomNodeWithMeta.getBoundingClientRect(), top_1 = _a.top, height = _a.height;
|
|
159
|
-
if (top_1 + height - this.event.clientY < DROPZONE_BOUNDARY_DELTA) {
|
|
160
|
-
return 'after';
|
|
161
|
-
}
|
|
162
|
-
else if (this.event.clientY - top_1 < DROPZONE_BOUNDARY_DELTA) {
|
|
163
|
-
return 'before';
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
return 'child';
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
return undefined;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
TreeViewDragAnalyzer.prototype.setDestimationMeta = function (element) {
|
|
174
|
-
var node = element;
|
|
175
|
-
while (node && !node[DOM_KENDO_ITEM_ID_FIELD]) {
|
|
176
|
-
node = node.parentNode;
|
|
177
|
-
}
|
|
178
|
-
if (node && node[DOM_KENDO_ITEM_ID_FIELD]) {
|
|
179
|
-
this.destDomNodeWithMeta = node;
|
|
180
|
-
this.destItemId = node[DOM_KENDO_ITEM_ID_FIELD];
|
|
181
|
-
this.destTreeViewGuid = node[DOM_KENDO_TREEVIEW_GUID_FIELD];
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
return TreeViewDragAnalyzer;
|
|
185
|
-
}());
|
|
186
|
-
export { TreeViewDragAnalyzer };
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Represents the props of the KendoReact TreeViewDragClue component.
|
|
4
|
-
*/
|
|
5
|
-
export interface TreeViewDragClueProps {
|
|
6
|
-
/**
|
|
7
|
-
* Sets custom CSS styles to the component.
|
|
8
|
-
* When specified, the default CSS styles are removed.
|
|
9
|
-
*/
|
|
10
|
-
style?: React.CSSProperties;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @hidden
|
|
14
|
-
*/
|
|
15
|
-
export interface TreeViewDragClueState {
|
|
16
|
-
visible?: boolean;
|
|
17
|
-
top?: number;
|
|
18
|
-
left?: number;
|
|
19
|
-
text?: string;
|
|
20
|
-
operationClassName?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Represents the KendoReact TreeViewDragClue component which renders a clue when an item is dragged.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```jsx
|
|
27
|
-
* class App extends React.Component {
|
|
28
|
-
* dragClue;
|
|
29
|
-
* state = { tree };
|
|
30
|
-
*
|
|
31
|
-
* render() {
|
|
32
|
-
* return (
|
|
33
|
-
* <div>
|
|
34
|
-
* <TreeView data={this.state.tree} draggable={true}
|
|
35
|
-
* onItemDragOver={this.onItemDragOver} onItemDragEnd={this.onItemDragEnd} />
|
|
36
|
-
* <TreeViewDragClue ref={dragClue => this.dragClue = dragClue} />
|
|
37
|
-
* </div>
|
|
38
|
-
* );
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* onItemDragOver = (event) => {
|
|
42
|
-
* this.dragClue.show(event.pageY + 10, event.pageX, event.item.text, this.getClueClassName(event));
|
|
43
|
-
* }
|
|
44
|
-
* onItemDragEnd = (event) => {
|
|
45
|
-
* this.dragClue.hide();
|
|
46
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
47
|
-
*
|
|
48
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
49
|
-
* const updatedTree = moveTreeViewItem(
|
|
50
|
-
* event.itemHierarchicalIndex,
|
|
51
|
-
* this.state.tree,
|
|
52
|
-
* eventAnalyzer.getDropOperation(),
|
|
53
|
-
* eventAnalyzer.destinationMeta.itemHierarchicalIndex,
|
|
54
|
-
* );
|
|
55
|
-
*
|
|
56
|
-
* this.setState({ tree: updatedTree });
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
* getClueClassName(event) {
|
|
60
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
61
|
-
* const itemIndex = eventAnalyzer.destinationMeta.itemHierarchicalIndex;
|
|
62
|
-
*
|
|
63
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
64
|
-
* switch (eventAnalyzer.getDropOperation()) {
|
|
65
|
-
* case 'child':
|
|
66
|
-
* return 'k-i-plus';
|
|
67
|
-
* case 'before':
|
|
68
|
-
* return itemIndex === '0' || itemIndex.endsWith(`${SEPARATOR}0`) ?
|
|
69
|
-
* 'k-i-insert-up' : 'k-i-insert-middle';
|
|
70
|
-
* case 'after':
|
|
71
|
-
* const siblings = getSiblings(itemIndex, this.state.tree);
|
|
72
|
-
* const lastIndex = Number(itemIndex.split(SEPARATOR).pop());
|
|
73
|
-
*
|
|
74
|
-
* return lastIndex < siblings.length - 1 ? 'k-i-insert-middle' : 'k-i-insert-down';
|
|
75
|
-
* default:
|
|
76
|
-
* break;
|
|
77
|
-
* }
|
|
78
|
-
* }
|
|
79
|
-
*
|
|
80
|
-
* return 'k-i-cancel';
|
|
81
|
-
* }
|
|
82
|
-
* }
|
|
83
|
-
*
|
|
84
|
-
* function getSiblings(itemIndex, data) {
|
|
85
|
-
* let result = data;
|
|
86
|
-
*
|
|
87
|
-
* const indices = itemIndex.split(SEPARATOR).map(index => Number(index));
|
|
88
|
-
* for (let i = 0; i < indices.length - 1; i++) {
|
|
89
|
-
* result = result[indices[i]].items;
|
|
90
|
-
* }
|
|
91
|
-
*
|
|
92
|
-
* return result;
|
|
93
|
-
* }
|
|
94
|
-
*
|
|
95
|
-
* const SEPARATOR = '_';
|
|
96
|
-
* const tree = [{
|
|
97
|
-
* text: 'Furniture', expanded: true, items: [
|
|
98
|
-
* { text: 'Tables & Chairs', expanded: true },
|
|
99
|
-
* { text: 'Sofas', expanded: true },
|
|
100
|
-
* { text: 'Occasional Furniture', expanded: true }]
|
|
101
|
-
* }, {
|
|
102
|
-
* text: 'Decor', expanded: true, items: [
|
|
103
|
-
* { text: 'Bed Linen', expanded: true },
|
|
104
|
-
* { text: 'Curtains & Blinds', expanded: true },
|
|
105
|
-
* { text: 'Carpets', expanded: true }]
|
|
106
|
-
* }];
|
|
107
|
-
*
|
|
108
|
-
* ReactDOM.render(<App />, document.querySelector('my-app'));
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
export declare class TreeViewDragClue extends React.PureComponent<TreeViewDragClueProps, TreeViewDragClueState> {
|
|
112
|
-
/**
|
|
113
|
-
* @hidden
|
|
114
|
-
*/
|
|
115
|
-
static defaultProps: {
|
|
116
|
-
style: {
|
|
117
|
-
display: string;
|
|
118
|
-
position: string;
|
|
119
|
-
zIndex: number;
|
|
120
|
-
padding: string;
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* @hidden
|
|
125
|
-
*/
|
|
126
|
-
readonly state: TreeViewDragClueState;
|
|
127
|
-
/**
|
|
128
|
-
* @hidden
|
|
129
|
-
*/
|
|
130
|
-
render(): false | JSX.Element | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Displays the TreeViewDragClue component.
|
|
133
|
-
*
|
|
134
|
-
* @param top - The `top` CSS position of the component.
|
|
135
|
-
* @param left - The `left` CSS position of the component.
|
|
136
|
-
* @param text - The text of the component.
|
|
137
|
-
* @param operationClassName - The CSS class name which is related to the specific drop operation.
|
|
138
|
-
*/
|
|
139
|
-
show(top: number, left: number, text: string, operationClassName: string): void;
|
|
140
|
-
/**
|
|
141
|
-
* Hides the TreeViewDragClue component.
|
|
142
|
-
*/
|
|
143
|
-
hide(): void;
|
|
144
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
|
-
import * as React from 'react';
|
|
28
|
-
import { IconWrap, classNames, toIconName } from '@progress/kendo-react-common';
|
|
29
|
-
import { cancelIcon, insertBottomIcon, insertMiddleIcon, insertTopIcon, plusIcon } from '@progress/kendo-svg-icons';
|
|
30
|
-
/**
|
|
31
|
-
* Represents the KendoReact TreeViewDragClue component which renders a clue when an item is dragged.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```jsx
|
|
35
|
-
* class App extends React.Component {
|
|
36
|
-
* dragClue;
|
|
37
|
-
* state = { tree };
|
|
38
|
-
*
|
|
39
|
-
* render() {
|
|
40
|
-
* return (
|
|
41
|
-
* <div>
|
|
42
|
-
* <TreeView data={this.state.tree} draggable={true}
|
|
43
|
-
* onItemDragOver={this.onItemDragOver} onItemDragEnd={this.onItemDragEnd} />
|
|
44
|
-
* <TreeViewDragClue ref={dragClue => this.dragClue = dragClue} />
|
|
45
|
-
* </div>
|
|
46
|
-
* );
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
* onItemDragOver = (event) => {
|
|
50
|
-
* this.dragClue.show(event.pageY + 10, event.pageX, event.item.text, this.getClueClassName(event));
|
|
51
|
-
* }
|
|
52
|
-
* onItemDragEnd = (event) => {
|
|
53
|
-
* this.dragClue.hide();
|
|
54
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
55
|
-
*
|
|
56
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
57
|
-
* const updatedTree = moveTreeViewItem(
|
|
58
|
-
* event.itemHierarchicalIndex,
|
|
59
|
-
* this.state.tree,
|
|
60
|
-
* eventAnalyzer.getDropOperation(),
|
|
61
|
-
* eventAnalyzer.destinationMeta.itemHierarchicalIndex,
|
|
62
|
-
* );
|
|
63
|
-
*
|
|
64
|
-
* this.setState({ tree: updatedTree });
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
* getClueClassName(event) {
|
|
68
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
69
|
-
* const itemIndex = eventAnalyzer.destinationMeta.itemHierarchicalIndex;
|
|
70
|
-
*
|
|
71
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
72
|
-
* switch (eventAnalyzer.getDropOperation()) {
|
|
73
|
-
* case 'child':
|
|
74
|
-
* return 'k-i-plus';
|
|
75
|
-
* case 'before':
|
|
76
|
-
* return itemIndex === '0' || itemIndex.endsWith(`${SEPARATOR}0`) ?
|
|
77
|
-
* 'k-i-insert-up' : 'k-i-insert-middle';
|
|
78
|
-
* case 'after':
|
|
79
|
-
* const siblings = getSiblings(itemIndex, this.state.tree);
|
|
80
|
-
* const lastIndex = Number(itemIndex.split(SEPARATOR).pop());
|
|
81
|
-
*
|
|
82
|
-
* return lastIndex < siblings.length - 1 ? 'k-i-insert-middle' : 'k-i-insert-down';
|
|
83
|
-
* default:
|
|
84
|
-
* break;
|
|
85
|
-
* }
|
|
86
|
-
* }
|
|
87
|
-
*
|
|
88
|
-
* return 'k-i-cancel';
|
|
89
|
-
* }
|
|
90
|
-
* }
|
|
91
|
-
*
|
|
92
|
-
* function getSiblings(itemIndex, data) {
|
|
93
|
-
* let result = data;
|
|
94
|
-
*
|
|
95
|
-
* const indices = itemIndex.split(SEPARATOR).map(index => Number(index));
|
|
96
|
-
* for (let i = 0; i < indices.length - 1; i++) {
|
|
97
|
-
* result = result[indices[i]].items;
|
|
98
|
-
* }
|
|
99
|
-
*
|
|
100
|
-
* return result;
|
|
101
|
-
* }
|
|
102
|
-
*
|
|
103
|
-
* const SEPARATOR = '_';
|
|
104
|
-
* const tree = [{
|
|
105
|
-
* text: 'Furniture', expanded: true, items: [
|
|
106
|
-
* { text: 'Tables & Chairs', expanded: true },
|
|
107
|
-
* { text: 'Sofas', expanded: true },
|
|
108
|
-
* { text: 'Occasional Furniture', expanded: true }]
|
|
109
|
-
* }, {
|
|
110
|
-
* text: 'Decor', expanded: true, items: [
|
|
111
|
-
* { text: 'Bed Linen', expanded: true },
|
|
112
|
-
* { text: 'Curtains & Blinds', expanded: true },
|
|
113
|
-
* { text: 'Carpets', expanded: true }]
|
|
114
|
-
* }];
|
|
115
|
-
*
|
|
116
|
-
* ReactDOM.render(<App />, document.querySelector('my-app'));
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
var TreeViewDragClue = /** @class */ (function (_super) {
|
|
120
|
-
__extends(TreeViewDragClue, _super);
|
|
121
|
-
function TreeViewDragClue() {
|
|
122
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
123
|
-
/**
|
|
124
|
-
* @hidden
|
|
125
|
-
*/
|
|
126
|
-
_this.state = {
|
|
127
|
-
visible: false,
|
|
128
|
-
top: 0,
|
|
129
|
-
left: 0,
|
|
130
|
-
text: '',
|
|
131
|
-
operationClassName: 'cancel'
|
|
132
|
-
};
|
|
133
|
-
return _this;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* @hidden
|
|
137
|
-
*/
|
|
138
|
-
TreeViewDragClue.prototype.render = function () {
|
|
139
|
-
var dynamicStyle = { top: this.state.top + 'px', left: this.state.left + 'px' };
|
|
140
|
-
return this.state.visible && (React.createElement("div", { className: "k-header k-drag-clue", style: __assign(__assign({}, this.props.style), dynamicStyle) },
|
|
141
|
-
React.createElement(IconWrap, { className: classNames('k-drag-status'), name: this.state.operationClassName && toIconName(this.state.operationClassName), icon: this.state.operationClassName === 'k-i-plus' ? plusIcon
|
|
142
|
-
: this.state.operationClassName === 'k-i-insert-up' ? insertTopIcon
|
|
143
|
-
: this.state.operationClassName === 'k-i-insert-up' ? insertBottomIcon
|
|
144
|
-
: this.state.operationClassName === 'k-i-insert-middle' ? insertMiddleIcon
|
|
145
|
-
: cancelIcon }),
|
|
146
|
-
this.state.text));
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Displays the TreeViewDragClue component.
|
|
150
|
-
*
|
|
151
|
-
* @param top - The `top` CSS position of the component.
|
|
152
|
-
* @param left - The `left` CSS position of the component.
|
|
153
|
-
* @param text - The text of the component.
|
|
154
|
-
* @param operationClassName - The CSS class name which is related to the specific drop operation.
|
|
155
|
-
*/
|
|
156
|
-
TreeViewDragClue.prototype.show = function (top, left, text, operationClassName) {
|
|
157
|
-
this.setState({ visible: true, top: top, left: left, text: text, operationClassName: operationClassName });
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Hides the TreeViewDragClue component.
|
|
161
|
-
*/
|
|
162
|
-
TreeViewDragClue.prototype.hide = function () {
|
|
163
|
-
this.setState({ visible: false });
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* @hidden
|
|
167
|
-
*/
|
|
168
|
-
TreeViewDragClue.defaultProps = { style: { display: 'block', position: 'absolute', zIndex: 20000, padding: '4px 6px' } };
|
|
169
|
-
return TreeViewDragClue;
|
|
170
|
-
}(React.PureComponent));
|
|
171
|
-
export { TreeViewDragClue };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { TreeFieldsService } from '@progress/kendo-react-common';
|
|
3
|
-
/**
|
|
4
|
-
* @hidden
|
|
5
|
-
*/
|
|
6
|
-
export declare const TreeViewItemPropsContext: React.Context<(props: TreeViewItemProps) => TreeViewItemProps>;
|
|
7
|
-
/**
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
export interface TreeViewItemProps {
|
|
11
|
-
item: any;
|
|
12
|
-
itemId: string;
|
|
13
|
-
treeGuid: string;
|
|
14
|
-
animate: boolean;
|
|
15
|
-
focusedItemId?: string;
|
|
16
|
-
tabbableItemId: string;
|
|
17
|
-
fieldsService: TreeFieldsService;
|
|
18
|
-
itemUI?: React.ComponentType<{
|
|
19
|
-
item: any;
|
|
20
|
-
itemHierarchicalIndex: string;
|
|
21
|
-
}>;
|
|
22
|
-
ariaMultiSelectable: boolean;
|
|
23
|
-
onItemClick: any;
|
|
24
|
-
expandIcons?: boolean;
|
|
25
|
-
onExpandChange: any;
|
|
26
|
-
onCheckChange: any;
|
|
27
|
-
checkboxes?: boolean;
|
|
28
|
-
onFocusDomElNeeded: any;
|
|
29
|
-
draggable?: boolean;
|
|
30
|
-
onPress: any;
|
|
31
|
-
onDrag: any;
|
|
32
|
-
onRelease: any;
|
|
33
|
-
size?: null | 'small' | 'medium' | 'large';
|
|
34
|
-
/**
|
|
35
|
-
* @hidden
|
|
36
|
-
*
|
|
37
|
-
* Internal usage!!!
|
|
38
|
-
*/
|
|
39
|
-
position?: 'top' | 'mid' | 'bot';
|
|
40
|
-
/**
|
|
41
|
-
* Currently for internal usage only! Replicates the current behavior which disables all children
|
|
42
|
-
* if the parent is disabled, which was previously achieved only though the kendo-themes,
|
|
43
|
-
* but due to rendering changes had to be replicated programmatically!
|
|
44
|
-
*
|
|
45
|
-
* @hidden
|
|
46
|
-
*/
|
|
47
|
-
disabled?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* @hidden
|
|
50
|
-
*/
|
|
51
|
-
isRtl?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* @hidden
|
|
54
|
-
*/
|
|
55
|
-
onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any, itemId: string) => void;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* @hidden
|
|
59
|
-
*/
|
|
60
|
-
declare class TreeViewItemWithoutContext extends React.Component<TreeViewItemProps> {
|
|
61
|
-
private itemElement;
|
|
62
|
-
private checkboxElement;
|
|
63
|
-
private itemGuid;
|
|
64
|
-
static defaultProps: {
|
|
65
|
-
position: string;
|
|
66
|
-
};
|
|
67
|
-
render(): JSX.Element;
|
|
68
|
-
componentDidMount(): void;
|
|
69
|
-
componentDidUpdate(prevProps: TreeViewItemProps): void;
|
|
70
|
-
private renderCheckbox;
|
|
71
|
-
private renderExpandIcon;
|
|
72
|
-
private renderSubitemsIfApplicable;
|
|
73
|
-
private renderItemInPart;
|
|
74
|
-
private onCheckChange;
|
|
75
|
-
private onExpandChange;
|
|
76
|
-
private onItemClick;
|
|
77
|
-
private onPress;
|
|
78
|
-
private onDrag;
|
|
79
|
-
private onRelease;
|
|
80
|
-
private onContextMenu;
|
|
81
|
-
private get fieldsSvc();
|
|
82
|
-
private get itemId();
|
|
83
|
-
private get item();
|
|
84
|
-
private get tabIndex();
|
|
85
|
-
private get ariaExpanded();
|
|
86
|
-
private get disabled();
|
|
87
|
-
private get ariaChecked();
|
|
88
|
-
private get ariaSelected();
|
|
89
|
-
private getIconProps;
|
|
90
|
-
private assignDraggableMeta;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* @hidden
|
|
94
|
-
*/
|
|
95
|
-
export declare const TreeViewItem: React.ForwardRefExoticComponent<TreeViewItemProps & React.RefAttributes<TreeViewItemWithoutContext>>;
|
|
96
|
-
export {};
|