@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,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.TreeViewDragClue = void 0;
|
|
30
|
-
var React = require("react");
|
|
31
|
-
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
32
|
-
var kendo_svg_icons_1 = require("@progress/kendo-svg-icons");
|
|
33
|
-
/**
|
|
34
|
-
* Represents the KendoReact TreeViewDragClue component which renders a clue when an item is dragged.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```jsx
|
|
38
|
-
* class App extends React.Component {
|
|
39
|
-
* dragClue;
|
|
40
|
-
* state = { tree };
|
|
41
|
-
*
|
|
42
|
-
* render() {
|
|
43
|
-
* return (
|
|
44
|
-
* <div>
|
|
45
|
-
* <TreeView data={this.state.tree} draggable={true}
|
|
46
|
-
* onItemDragOver={this.onItemDragOver} onItemDragEnd={this.onItemDragEnd} />
|
|
47
|
-
* <TreeViewDragClue ref={dragClue => this.dragClue = dragClue} />
|
|
48
|
-
* </div>
|
|
49
|
-
* );
|
|
50
|
-
* }
|
|
51
|
-
*
|
|
52
|
-
* onItemDragOver = (event) => {
|
|
53
|
-
* this.dragClue.show(event.pageY + 10, event.pageX, event.item.text, this.getClueClassName(event));
|
|
54
|
-
* }
|
|
55
|
-
* onItemDragEnd = (event) => {
|
|
56
|
-
* this.dragClue.hide();
|
|
57
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
58
|
-
*
|
|
59
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
60
|
-
* const updatedTree = moveTreeViewItem(
|
|
61
|
-
* event.itemHierarchicalIndex,
|
|
62
|
-
* this.state.tree,
|
|
63
|
-
* eventAnalyzer.getDropOperation(),
|
|
64
|
-
* eventAnalyzer.destinationMeta.itemHierarchicalIndex,
|
|
65
|
-
* );
|
|
66
|
-
*
|
|
67
|
-
* this.setState({ tree: updatedTree });
|
|
68
|
-
* }
|
|
69
|
-
* }
|
|
70
|
-
* getClueClassName(event) {
|
|
71
|
-
* const eventAnalyzer = new TreeViewDragAnalyzer(event).init();
|
|
72
|
-
* const itemIndex = eventAnalyzer.destinationMeta.itemHierarchicalIndex;
|
|
73
|
-
*
|
|
74
|
-
* if (eventAnalyzer.isDropAllowed) {
|
|
75
|
-
* switch (eventAnalyzer.getDropOperation()) {
|
|
76
|
-
* case 'child':
|
|
77
|
-
* return 'k-i-plus';
|
|
78
|
-
* case 'before':
|
|
79
|
-
* return itemIndex === '0' || itemIndex.endsWith(`${SEPARATOR}0`) ?
|
|
80
|
-
* 'k-i-insert-up' : 'k-i-insert-middle';
|
|
81
|
-
* case 'after':
|
|
82
|
-
* const siblings = getSiblings(itemIndex, this.state.tree);
|
|
83
|
-
* const lastIndex = Number(itemIndex.split(SEPARATOR).pop());
|
|
84
|
-
*
|
|
85
|
-
* return lastIndex < siblings.length - 1 ? 'k-i-insert-middle' : 'k-i-insert-down';
|
|
86
|
-
* default:
|
|
87
|
-
* break;
|
|
88
|
-
* }
|
|
89
|
-
* }
|
|
90
|
-
*
|
|
91
|
-
* return 'k-i-cancel';
|
|
92
|
-
* }
|
|
93
|
-
* }
|
|
94
|
-
*
|
|
95
|
-
* function getSiblings(itemIndex, data) {
|
|
96
|
-
* let result = data;
|
|
97
|
-
*
|
|
98
|
-
* const indices = itemIndex.split(SEPARATOR).map(index => Number(index));
|
|
99
|
-
* for (let i = 0; i < indices.length - 1; i++) {
|
|
100
|
-
* result = result[indices[i]].items;
|
|
101
|
-
* }
|
|
102
|
-
*
|
|
103
|
-
* return result;
|
|
104
|
-
* }
|
|
105
|
-
*
|
|
106
|
-
* const SEPARATOR = '_';
|
|
107
|
-
* const tree = [{
|
|
108
|
-
* text: 'Furniture', expanded: true, items: [
|
|
109
|
-
* { text: 'Tables & Chairs', expanded: true },
|
|
110
|
-
* { text: 'Sofas', expanded: true },
|
|
111
|
-
* { text: 'Occasional Furniture', expanded: true }]
|
|
112
|
-
* }, {
|
|
113
|
-
* text: 'Decor', expanded: true, items: [
|
|
114
|
-
* { text: 'Bed Linen', expanded: true },
|
|
115
|
-
* { text: 'Curtains & Blinds', expanded: true },
|
|
116
|
-
* { text: 'Carpets', expanded: true }]
|
|
117
|
-
* }];
|
|
118
|
-
*
|
|
119
|
-
* ReactDOM.render(<App />, document.querySelector('my-app'));
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
var TreeViewDragClue = /** @class */ (function (_super) {
|
|
123
|
-
__extends(TreeViewDragClue, _super);
|
|
124
|
-
function TreeViewDragClue() {
|
|
125
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
126
|
-
/**
|
|
127
|
-
* @hidden
|
|
128
|
-
*/
|
|
129
|
-
_this.state = {
|
|
130
|
-
visible: false,
|
|
131
|
-
top: 0,
|
|
132
|
-
left: 0,
|
|
133
|
-
text: '',
|
|
134
|
-
operationClassName: 'cancel'
|
|
135
|
-
};
|
|
136
|
-
return _this;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* @hidden
|
|
140
|
-
*/
|
|
141
|
-
TreeViewDragClue.prototype.render = function () {
|
|
142
|
-
var dynamicStyle = { top: this.state.top + 'px', left: this.state.left + 'px' };
|
|
143
|
-
return this.state.visible && (React.createElement("div", { className: "k-header k-drag-clue", style: __assign(__assign({}, this.props.style), dynamicStyle) },
|
|
144
|
-
React.createElement(kendo_react_common_1.IconWrap, { className: (0, kendo_react_common_1.classNames)('k-drag-status'), name: this.state.operationClassName && (0, kendo_react_common_1.toIconName)(this.state.operationClassName), icon: this.state.operationClassName === 'k-i-plus' ? kendo_svg_icons_1.plusIcon
|
|
145
|
-
: this.state.operationClassName === 'k-i-insert-up' ? kendo_svg_icons_1.insertTopIcon
|
|
146
|
-
: this.state.operationClassName === 'k-i-insert-up' ? kendo_svg_icons_1.insertBottomIcon
|
|
147
|
-
: this.state.operationClassName === 'k-i-insert-middle' ? kendo_svg_icons_1.insertMiddleIcon
|
|
148
|
-
: kendo_svg_icons_1.cancelIcon }),
|
|
149
|
-
this.state.text));
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Displays the TreeViewDragClue component.
|
|
153
|
-
*
|
|
154
|
-
* @param top - The `top` CSS position of the component.
|
|
155
|
-
* @param left - The `left` CSS position of the component.
|
|
156
|
-
* @param text - The text of the component.
|
|
157
|
-
* @param operationClassName - The CSS class name which is related to the specific drop operation.
|
|
158
|
-
*/
|
|
159
|
-
TreeViewDragClue.prototype.show = function (top, left, text, operationClassName) {
|
|
160
|
-
this.setState({ visible: true, top: top, left: left, text: text, operationClassName: operationClassName });
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Hides the TreeViewDragClue component.
|
|
164
|
-
*/
|
|
165
|
-
TreeViewDragClue.prototype.hide = function () {
|
|
166
|
-
this.setState({ visible: false });
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* @hidden
|
|
170
|
-
*/
|
|
171
|
-
TreeViewDragClue.defaultProps = { style: { display: 'block', position: 'absolute', zIndex: 20000, padding: '4px 6px' } };
|
|
172
|
-
return TreeViewDragClue;
|
|
173
|
-
}(React.PureComponent));
|
|
174
|
-
exports.TreeViewDragClue = TreeViewDragClue;
|
package/dist/npm/TreeViewItem.js
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.TreeViewItem = exports.TreeViewItemPropsContext = void 0;
|
|
30
|
-
var React = require("react");
|
|
31
|
-
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
32
|
-
var kendo_svg_icons_1 = require("@progress/kendo-svg-icons");
|
|
33
|
-
var kendo_react_common_2 = require("@progress/kendo-react-common");
|
|
34
|
-
var kendo_react_animation_1 = require("@progress/kendo-react-animation");
|
|
35
|
-
var consts_1 = require("./utils/consts");
|
|
36
|
-
var sizeMap = kendo_react_common_1.kendoThemeMaps.sizeMap;
|
|
37
|
-
/**
|
|
38
|
-
* @hidden
|
|
39
|
-
*/
|
|
40
|
-
exports.TreeViewItemPropsContext = React.createContext(function (props) { return props; });
|
|
41
|
-
/**
|
|
42
|
-
* @hidden
|
|
43
|
-
*/
|
|
44
|
-
var TreeViewItemWithoutContext = /** @class */ (function (_super) {
|
|
45
|
-
__extends(TreeViewItemWithoutContext, _super);
|
|
46
|
-
function TreeViewItemWithoutContext() {
|
|
47
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
48
|
-
_this.itemGuid = (0, kendo_react_common_1.guid)();
|
|
49
|
-
_this.onCheckChange = function (e) {
|
|
50
|
-
_this.props.onCheckChange(e, _this.item, _this.itemId);
|
|
51
|
-
};
|
|
52
|
-
_this.onExpandChange = function (e) {
|
|
53
|
-
_this.props.onExpandChange(e, _this.item, _this.itemId);
|
|
54
|
-
};
|
|
55
|
-
_this.onItemClick = function (e) {
|
|
56
|
-
_this.props.onItemClick(e, _this.item, _this.itemId);
|
|
57
|
-
};
|
|
58
|
-
_this.onPress = function (e) {
|
|
59
|
-
_this.props.onPress(e.event, _this.item, _this.itemId);
|
|
60
|
-
};
|
|
61
|
-
_this.onDrag = function (e) {
|
|
62
|
-
_this.props.onDrag(e.event, _this.item, _this.itemId);
|
|
63
|
-
};
|
|
64
|
-
_this.onRelease = function (e) {
|
|
65
|
-
_this.props.onRelease(e.event, _this.item, _this.itemId);
|
|
66
|
-
};
|
|
67
|
-
_this.onContextMenu = function (e) {
|
|
68
|
-
_this.props.onContextMenu(e, _this.item, _this.itemId);
|
|
69
|
-
};
|
|
70
|
-
_this.assignDraggableMeta = function (element) {
|
|
71
|
-
if (element) {
|
|
72
|
-
element[consts_1.DOM_KENDO_ITEM_ID_FIELD] = _this.props.itemId;
|
|
73
|
-
element[consts_1.DOM_KENDO_TREEVIEW_GUID_FIELD] = _this.props.treeGuid;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return _this;
|
|
77
|
-
}
|
|
78
|
-
TreeViewItemWithoutContext.prototype.render = function () {
|
|
79
|
-
var _this = this;
|
|
80
|
-
var subitems = this.renderSubitemsIfApplicable();
|
|
81
|
-
var itemInPart = this.renderItemInPart();
|
|
82
|
-
return (React.createElement("li", { className: (0, kendo_react_common_1.classNames)('k-treeview-item'), tabIndex: this.tabIndex, role: "treeitem", "aria-expanded": this.ariaExpanded, "aria-selected": this.ariaSelected, "aria-checked": this.ariaChecked, "aria-disabled": this.disabled ? true : undefined, ref: function (el) { return _this.itemElement = el; } },
|
|
83
|
-
React.createElement("div", { className: "k-treeview-".concat(this.props.position), ref: this.assignDraggableMeta },
|
|
84
|
-
this.renderExpandIcon(),
|
|
85
|
-
this.renderCheckbox(),
|
|
86
|
-
this.props.draggable ?
|
|
87
|
-
React.createElement(kendo_react_common_1.Draggable, { onPress: this.onPress, onDrag: this.onDrag, onRelease: this.onRelease }, itemInPart) : itemInPart),
|
|
88
|
-
this.props.animate ?
|
|
89
|
-
React.createElement(kendo_react_animation_1.Reveal, { transitionEnterDuration: 200, transitionExitDuration: 200, style: { display: 'block' }, children: subitems }) : subitems));
|
|
90
|
-
};
|
|
91
|
-
TreeViewItemWithoutContext.prototype.componentDidMount = function () {
|
|
92
|
-
var focusedItemId = this.props.focusedItemId;
|
|
93
|
-
var currentItemId = this.itemId;
|
|
94
|
-
if (focusedItemId && focusedItemId === currentItemId) {
|
|
95
|
-
this.props.onFocusDomElNeeded(this.itemElement);
|
|
96
|
-
}
|
|
97
|
-
if (this.checkboxElement) {
|
|
98
|
-
this.checkboxElement.indeterminate = this.fieldsSvc.checkIndeterminate(this.item);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
TreeViewItemWithoutContext.prototype.componentDidUpdate = function (prevProps) {
|
|
102
|
-
var focusedItemId = this.props.focusedItemId;
|
|
103
|
-
if (focusedItemId &&
|
|
104
|
-
focusedItemId !== prevProps.focusedItemId &&
|
|
105
|
-
focusedItemId === this.itemId) {
|
|
106
|
-
this.props.onFocusDomElNeeded(this.itemElement);
|
|
107
|
-
}
|
|
108
|
-
if (this.checkboxElement) {
|
|
109
|
-
var indeterminate = this.fieldsSvc.checkIndeterminate(this.item);
|
|
110
|
-
if (indeterminate !== prevProps.fieldsService.checkIndeterminate(prevProps.item)) {
|
|
111
|
-
this.checkboxElement.indeterminate = indeterminate;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
TreeViewItemWithoutContext.prototype.renderCheckbox = function () {
|
|
116
|
-
var _a;
|
|
117
|
-
var _this = this;
|
|
118
|
-
if (this.props.checkboxes) {
|
|
119
|
-
var size = this.props.size;
|
|
120
|
-
return (React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-checkbox-wrap') },
|
|
121
|
-
React.createElement("input", { type: "checkbox", className: (0, kendo_react_common_1.classNames)('k-checkbox k-rounded-md', (_a = {},
|
|
122
|
-
_a["k-checkbox-".concat(sizeMap[size] || size)] = size,
|
|
123
|
-
_a['k-disabled'] = this.disabled,
|
|
124
|
-
_a)), "aria-label": this.item.text, checked: Boolean(this.fieldsSvc.checked(this.item)), id: this.itemGuid, tabIndex: -1, onChange: this.onCheckChange, ref: function (el) { return _this.checkboxElement = el; } }),
|
|
125
|
-
React.createElement("label", { className: "k-checkbox-label", htmlFor: this.itemGuid })));
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
TreeViewItemWithoutContext.prototype.renderExpandIcon = function () {
|
|
132
|
-
var renderExpand = this.props.expandIcons &&
|
|
133
|
-
// If it is explicitly said that the item has children (even not loaded yet)
|
|
134
|
-
// or if the item actually has children, then render the icon.
|
|
135
|
-
(this.fieldsSvc.hasChildren(this.item) || (0, kendo_react_common_2.hasChildren)(this.item, this.fieldsSvc.getChildrenField()));
|
|
136
|
-
return renderExpand && (
|
|
137
|
-
// Allowing the toggle-button even with `disabled=true` might be a valid case!
|
|
138
|
-
// Re-evaluate the classes bellow if such scenario occurs
|
|
139
|
-
React.createElement("span", { className: (0, kendo_react_common_1.classNames)('k-treeview-toggle', { 'k-disabled': this.disabled }), onClick: this.onExpandChange },
|
|
140
|
-
React.createElement(kendo_react_common_1.IconWrap, __assign({}, this.getIconProps()))));
|
|
141
|
-
};
|
|
142
|
-
TreeViewItemWithoutContext.prototype.renderSubitemsIfApplicable = function () {
|
|
143
|
-
var _this = this;
|
|
144
|
-
var data = this.fieldsSvc.children(this.item);
|
|
145
|
-
return (0, kendo_react_common_2.isItemExpandedAndWithChildren)(this.item, this.fieldsSvc) ?
|
|
146
|
-
(React.createElement("ul", { className: "k-treeview-group", role: "group" }, data.map(function (item, index) {
|
|
147
|
-
return (React.createElement(exports.TreeViewItem, { item: item, position: index === 0 ? 'top' : index === data.length - 1 ? 'bot' : 'mid', itemId: kendo_react_common_2.treeIdUtils.createId(index, _this.itemId), treeGuid: _this.props.treeGuid, animate: _this.props.animate, focusedItemId: _this.props.focusedItemId, tabbableItemId: _this.props.tabbableItemId, fieldsService: _this.props.fieldsService, itemUI: _this.props.itemUI, checkboxes: _this.props.checkboxes, ariaMultiSelectable: _this.props.ariaMultiSelectable, onItemClick: _this.props.onItemClick, onFocusDomElNeeded: _this.props.onFocusDomElNeeded, draggable: _this.props.draggable, onPress: _this.props.onPress, onDrag: _this.props.onDrag, onRelease: _this.props.onRelease, expandIcons: _this.props.expandIcons, onExpandChange: _this.props.onExpandChange, onCheckChange: _this.props.onCheckChange, onContextMenu: _this.props.onContextMenu, key: index, size: _this.props.size, disabled: _this.disabled, isRtl: _this.props.isRtl }));
|
|
148
|
-
}))) : undefined;
|
|
149
|
-
};
|
|
150
|
-
TreeViewItemWithoutContext.prototype.renderItemInPart = function () {
|
|
151
|
-
return (React.createElement("span", { className: (0, kendo_react_common_1.classNames)('k-treeview-leaf', {
|
|
152
|
-
'k-focus': this.props.focusedItemId === this.itemId,
|
|
153
|
-
'k-selected': this.fieldsSvc.selected(this.item),
|
|
154
|
-
'k-disabled': this.disabled
|
|
155
|
-
}), style: { touchAction: 'none' }, onClick: this.onItemClick, onContextMenu: this.onContextMenu },
|
|
156
|
-
React.createElement("span", { className: "k-treeview-leaf-text" }, this.props.itemUI ?
|
|
157
|
-
React.createElement(this.props.itemUI, { item: this.item, itemHierarchicalIndex: this.itemId }) :
|
|
158
|
-
this.fieldsSvc.text(this.item))));
|
|
159
|
-
};
|
|
160
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "fieldsSvc", {
|
|
161
|
-
get: function () {
|
|
162
|
-
return this.props.fieldsService;
|
|
163
|
-
},
|
|
164
|
-
enumerable: false,
|
|
165
|
-
configurable: true
|
|
166
|
-
});
|
|
167
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "itemId", {
|
|
168
|
-
get: function () {
|
|
169
|
-
return this.props.itemId;
|
|
170
|
-
},
|
|
171
|
-
enumerable: false,
|
|
172
|
-
configurable: true
|
|
173
|
-
});
|
|
174
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "item", {
|
|
175
|
-
get: function () {
|
|
176
|
-
return this.props.item;
|
|
177
|
-
},
|
|
178
|
-
enumerable: false,
|
|
179
|
-
configurable: true
|
|
180
|
-
});
|
|
181
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "tabIndex", {
|
|
182
|
-
get: function () {
|
|
183
|
-
return (this.props.focusedItemId || this.props.tabbableItemId) === this.itemId ? 0 : -1;
|
|
184
|
-
},
|
|
185
|
-
enumerable: false,
|
|
186
|
-
configurable: true
|
|
187
|
-
});
|
|
188
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "ariaExpanded", {
|
|
189
|
-
get: function () {
|
|
190
|
-
return this.fieldsSvc.hasChildren(this.item) || (0, kendo_react_common_2.hasChildren)(this.item, this.fieldsSvc.getChildrenField()) ?
|
|
191
|
-
Boolean(this.fieldsSvc.expanded(this.item)) : undefined;
|
|
192
|
-
},
|
|
193
|
-
enumerable: false,
|
|
194
|
-
configurable: true
|
|
195
|
-
});
|
|
196
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "disabled", {
|
|
197
|
-
get: function () {
|
|
198
|
-
return this.props.disabled || this.fieldsSvc.disabled(this.item);
|
|
199
|
-
},
|
|
200
|
-
enumerable: false,
|
|
201
|
-
configurable: true
|
|
202
|
-
});
|
|
203
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "ariaChecked", {
|
|
204
|
-
get: function () {
|
|
205
|
-
if (this.props.checkboxes) {
|
|
206
|
-
if (this.fieldsSvc.checked(this.item)) {
|
|
207
|
-
return 'true';
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
return this.fieldsSvc.checkIndeterminate(this.item) ? 'mixed' : 'false';
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
return undefined;
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
enumerable: false,
|
|
218
|
-
configurable: true
|
|
219
|
-
});
|
|
220
|
-
Object.defineProperty(TreeViewItemWithoutContext.prototype, "ariaSelected", {
|
|
221
|
-
get: function () {
|
|
222
|
-
if (this.fieldsSvc.selected(this.item)) {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
else if (this.props.ariaMultiSelectable) {
|
|
226
|
-
return this.disabled ? undefined : false;
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
return undefined;
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
enumerable: false,
|
|
233
|
-
configurable: true
|
|
234
|
-
});
|
|
235
|
-
TreeViewItemWithoutContext.prototype.getIconProps = function () {
|
|
236
|
-
var expanded = this.fieldsSvc.expanded(this.item);
|
|
237
|
-
var loading = expanded && !(0, kendo_react_common_2.hasChildren)(this.item, this.fieldsSvc.getChildrenField());
|
|
238
|
-
if (loading) {
|
|
239
|
-
return { name: 'loading' };
|
|
240
|
-
}
|
|
241
|
-
return expanded
|
|
242
|
-
? { name: 'caret-alt-down', icon: kendo_svg_icons_1.caretAltDownIcon }
|
|
243
|
-
: { name: this.props.isRtl ? 'caret-alt-left' : 'caret-alt-right', icon: this.props.isRtl ? kendo_svg_icons_1.caretAltLeftIcon : kendo_svg_icons_1.caretAltRightIcon };
|
|
244
|
-
};
|
|
245
|
-
TreeViewItemWithoutContext.defaultProps = {
|
|
246
|
-
position: 'top'
|
|
247
|
-
};
|
|
248
|
-
return TreeViewItemWithoutContext;
|
|
249
|
-
}(React.Component));
|
|
250
|
-
/**
|
|
251
|
-
* @hidden
|
|
252
|
-
*/
|
|
253
|
-
exports.TreeViewItem = React.forwardRef(function (props, ref) {
|
|
254
|
-
var contextPropsCallback = React.useContext(exports.TreeViewItemPropsContext);
|
|
255
|
-
var treeViewItemProps = contextPropsCallback.call(undefined, props);
|
|
256
|
-
return (React.createElement(TreeViewItemWithoutContext, __assign({ ref: ref }, treeViewItemProps)));
|
|
257
|
-
});
|
|
258
|
-
exports.TreeViewItem.displayName = 'TreeViewItem';
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The descriptors of the data operations which are applied to the TreeView component.
|
|
3
|
-
*/
|
|
4
|
-
export interface TreeViewOperationDescriptors {
|
|
5
|
-
/**
|
|
6
|
-
* The hierarchical indices of the items to which the expand operation will be applied, or the descriptor of the operation.
|
|
7
|
-
*/
|
|
8
|
-
expand?: string[] | TreeViewOperationDescriptor;
|
|
9
|
-
/**
|
|
10
|
-
* The hierarchical indices of the items to which the select operation will be applied, or the descriptor of the operation.
|
|
11
|
-
*/
|
|
12
|
-
select?: string[] | TreeViewOperationDescriptor;
|
|
13
|
-
/**
|
|
14
|
-
* The hierarchical indices of the items to which the check operation will be applied, or the descriptor of the operation.
|
|
15
|
-
*/
|
|
16
|
-
check?: string[] | TreeViewCheckDescriptor;
|
|
17
|
-
/**
|
|
18
|
-
* When the operations are applied, the corresponding items and their parents are cloned.
|
|
19
|
-
* For performance reasons, TreeView items are cloned only once.
|
|
20
|
-
* The name of the field which provides a Boolean representation of whether an item is already cloned.
|
|
21
|
-
* Defaults to `cloned`.
|
|
22
|
-
*/
|
|
23
|
-
cloneField?: string;
|
|
24
|
-
/**
|
|
25
|
-
* The expand field of the item.
|
|
26
|
-
*/
|
|
27
|
-
expandField?: string;
|
|
28
|
-
/**
|
|
29
|
-
* The select field of the item.
|
|
30
|
-
*/
|
|
31
|
-
selectField?: string;
|
|
32
|
-
/**
|
|
33
|
-
* The check field of the item.
|
|
34
|
-
*/
|
|
35
|
-
checkField?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The children field of the item.
|
|
38
|
-
*/
|
|
39
|
-
childrenField?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* The descriptor which is used for expanding, selecting, and checking.
|
|
43
|
-
*/
|
|
44
|
-
export interface TreeViewOperationDescriptor {
|
|
45
|
-
/**
|
|
46
|
-
* The IDs of the items to which the operation will be applied. By default, the TreeView applies the hierarchical indices of the items. These indices are zero-based. The first root item has a `0` (zero) index. If the first root item has children, the first child acquires a `0_0` index and the second acquires a `0_1` index.
|
|
47
|
-
*/
|
|
48
|
-
ids?: any[];
|
|
49
|
-
/**
|
|
50
|
-
* The name of the field which will provide a Boolean representation for the operation state of the item.
|
|
51
|
-
*
|
|
52
|
-
* The default fields are:
|
|
53
|
-
* * `expanded`—Indicates that an item is expanded.
|
|
54
|
-
* * `selected`—Indicates that an item is selected.
|
|
55
|
-
* * `checked`—Indicates that an item is checked.
|
|
56
|
-
*/
|
|
57
|
-
operationField?: string;
|
|
58
|
-
/**
|
|
59
|
-
* The name of the field which will uniquely describe an item as an alternative to its hierarchical index.
|
|
60
|
-
*/
|
|
61
|
-
idField?: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The descriptor which is used for checking.
|
|
65
|
-
*/
|
|
66
|
-
export interface TreeViewCheckDescriptor extends TreeViewOperationDescriptor {
|
|
67
|
-
/**
|
|
68
|
-
* Determines if a parent item will have an indeterminate state when not all its children are checked.
|
|
69
|
-
*/
|
|
70
|
-
applyCheckIndeterminate?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* The name of the field which will provide a Boolean representation for the indeterminate state of a parent item.
|
|
73
|
-
* Defaults to `checkIndeterminate`.
|
|
74
|
-
*/
|
|
75
|
-
checkIndeterminateField?: string;
|
|
76
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import * as events from './events';
|
|
3
|
-
import { ItemRenderProps } from './ItemRenderProps';
|
|
4
|
-
import { TreeViewContextMenuEvent } from './events';
|
|
5
|
-
/**
|
|
6
|
-
* Represents the props of the [KendoReact TreeView component]({% slug overview_treeview %}).
|
|
7
|
-
*/
|
|
8
|
-
export interface TreeViewProps {
|
|
9
|
-
/**
|
|
10
|
-
* Sets a class of the TreeView DOM element.
|
|
11
|
-
*/
|
|
12
|
-
className?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Sets the data of the TreeView ([more information and examples]({% slug databinding_treeview %})).
|
|
15
|
-
*/
|
|
16
|
-
data?: any[] | null;
|
|
17
|
-
/**
|
|
18
|
-
* Controls the animation. By default, the expand and collapse animations are enabled.
|
|
19
|
-
*/
|
|
20
|
-
animate?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Sets a tabIndex of the TreeView DOM element.
|
|
23
|
-
*/
|
|
24
|
-
tabIndex?: number;
|
|
25
|
-
/**
|
|
26
|
-
* The TreeView has a built-in implementation of focusing and keyboard navigation. By default, the component uses hierarchical indices to uniquely match the focused item. You can use the `focusIdField` prop for specifying the name of the field which will uniquely describe an item as an alternative to its hierarchical index ([see example]({% slug datareload_treeview %}#toc-using-item-ids)).
|
|
27
|
-
*/
|
|
28
|
-
focusIdField?: string;
|
|
29
|
-
/**
|
|
30
|
-
* When `focusIdField` is set, the TreeView executes a depth-first search on the data to find the currently focused item. The `getFocusHierarchicalIndex` prop specifies the function that will be used as an alternative to the default search algorithm.
|
|
31
|
-
*/
|
|
32
|
-
getFocusHierarchicalIndex?: (itemId: any) => string | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Controls the rendering of the expand (collapse) icons. By default, the icons are not rendered ([see example]({% slug expansion_ways_treeview %})).
|
|
35
|
-
*/
|
|
36
|
-
expandIcons?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Fires when the expanding or collapsing of an item is requested ([see example]({% slug expansion_ways_treeview %})).
|
|
39
|
-
*/
|
|
40
|
-
onExpandChange?: (event: events.TreeViewExpandChangeEvent) => void;
|
|
41
|
-
/**
|
|
42
|
-
* Fires when an item is clicked or when `Enter` is pressed on a focused item ([see example]({% slug selection_ways_treeview %})).
|
|
43
|
-
*/
|
|
44
|
-
onItemClick?: (event: events.TreeViewItemClickEvent) => void;
|
|
45
|
-
/**
|
|
46
|
-
* Specifies the name of the field which will provide a Boolean representation for the expanded state of the item. Defaults to `expanded`.
|
|
47
|
-
*/
|
|
48
|
-
expandField?: string;
|
|
49
|
-
/**
|
|
50
|
-
* Specifies the name of the field which will provide a Boolean representation for the selected state of the item. Defaults to `selected`.
|
|
51
|
-
*/
|
|
52
|
-
selectField?: string;
|
|
53
|
-
/**
|
|
54
|
-
* Specifies the name of the field which indicates to the TreeView that an item has children even if the children are not initially passed. Used for implementing the load-on-demand feature ([see example]({% slug databinding_treeview %}#toc-loading-data-on-demand)). Defaults to `hasChildren`.
|
|
55
|
-
*/
|
|
56
|
-
hasChildrenField?: string;
|
|
57
|
-
/**
|
|
58
|
-
* Specifies the name of the field which will provide an array representation of the item children.
|
|
59
|
-
*/
|
|
60
|
-
childrenField?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Specifies the name of the field which will provide a text representation for the item. Defaults to `text`.
|
|
63
|
-
*/
|
|
64
|
-
textField?: string;
|
|
65
|
-
/**
|
|
66
|
-
* Specifies the name of the field which will provide a Boolean representation for the disabled state of the item. Defaults to `disabled`.
|
|
67
|
-
*/
|
|
68
|
-
disableField?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Defines the component that will be used for rendering each of the TreeView items ([see example]({% slug rendering_treeview %})).
|
|
71
|
-
*/
|
|
72
|
-
item?: ComponentType<ItemRenderProps>;
|
|
73
|
-
/**
|
|
74
|
-
* Indicates that the user can select more than one TreeView items. If the TreeView is in a multiple selection mode, set the `aria-multiselectable` prop to `true` ([more on accessibility by the TreeView]({% slug accessibility_treeview %})).
|
|
75
|
-
*/
|
|
76
|
-
'aria-multiselectable'?: boolean | 'false' | 'true';
|
|
77
|
-
/**
|
|
78
|
-
* Defines a string value that labels the TreeView ([more on accessibility by the TreeView]({% slug accessibility_treeview %})).
|
|
79
|
-
*/
|
|
80
|
-
'aria-label'?: string;
|
|
81
|
-
/**
|
|
82
|
-
* Identifies the element or elements which will label the TreeView ([more on accessibility by the TreeView]({% slug accessibility_treeview %})).
|
|
83
|
-
*/
|
|
84
|
-
'aria-labelledby'?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Controls the rendering of checkboxes. By default, the checkboxes are not rendered ([see example]({% slug check_items_directly_treeview %})).
|
|
87
|
-
*/
|
|
88
|
-
checkboxes?: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Specifies the name of the field which will provide a Boolean representation for the checked state of the item. Defaults to `checked`.
|
|
91
|
-
*/
|
|
92
|
-
checkField?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Specifies the name of the field which will provide a Boolean representation for the check indeterminate state of the item. Defaults to `checkIndeterminate`.
|
|
95
|
-
*/
|
|
96
|
-
checkIndeterminateField?: string;
|
|
97
|
-
/**
|
|
98
|
-
* Fires when a checkbox is clicked or when `Space` is pressed on a focused item ([see example]({% slug check_items_directly_treeview %})).
|
|
99
|
-
*/
|
|
100
|
-
onCheckChange?: (event: events.TreeViewCheckChangeEvent) => void;
|
|
101
|
-
/**
|
|
102
|
-
* Controls the dispatching of the `drag` events. By default, the `drag` events are not dispatched ([see example]({% slug dragdrop_treeview %})).
|
|
103
|
-
*/
|
|
104
|
-
draggable?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Fires when the dragging of an item has started.
|
|
107
|
-
*/
|
|
108
|
-
onItemDragStart?: (event: events.TreeViewItemDragStartEvent) => void;
|
|
109
|
-
/**
|
|
110
|
-
* Fires when a dragged item changes its position ([see example]({% slug dragdrop_treeview %})).
|
|
111
|
-
*/
|
|
112
|
-
onItemDragOver?: (event: events.TreeViewItemDragOverEvent) => void;
|
|
113
|
-
/**
|
|
114
|
-
* Fires when a dragged item is dropped ([see example]({% slug dragdrop_treeview %})).
|
|
115
|
-
*/
|
|
116
|
-
onItemDragEnd?: (event: events.TreeViewItemDragEndEvent) => void;
|
|
117
|
-
/**
|
|
118
|
-
* Configures the `size` of the TreeView.
|
|
119
|
-
*
|
|
120
|
-
* The available options are:
|
|
121
|
-
* - small
|
|
122
|
-
* - medium
|
|
123
|
-
* - large
|
|
124
|
-
* - null—Does not set a size `className`.
|
|
125
|
-
*
|
|
126
|
-
* @default `medium`
|
|
127
|
-
*/
|
|
128
|
-
size?: null | 'small' | 'medium' | 'large';
|
|
129
|
-
/**
|
|
130
|
-
* Sets the direction of the component.
|
|
131
|
-
*/
|
|
132
|
-
dir?: string;
|
|
133
|
-
/**
|
|
134
|
-
* The event that is fired when the ContextMenu is activated.
|
|
135
|
-
*/
|
|
136
|
-
onContextMenu?: (event: TreeViewContextMenuEvent) => void;
|
|
137
|
-
}
|