@progress/kendo-react-treeview 5.20.0-dev.202310051816 → 5.20.0-dev.202310061256
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/cdn/js/kendo-react-treeview.js +1 -1
- package/dist/es/TreeView.js +3 -6
- package/dist/es/TreeViewItem.d.ts +2 -2
- package/dist/es/TreeViewItem.js +2 -3
- package/dist/es/handleTreeViewCheckChange.js +4 -6
- package/dist/es/main.d.ts +1 -1
- package/dist/es/main.js +1 -1
- package/dist/es/moveTreeViewItem.js +4 -5
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/processTreeViewItems.js +1 -2
- package/dist/es/utils/getItemIdUponKeyboardNavigation.d.ts +2 -2
- package/dist/es/utils/getItemIdUponKeyboardNavigation.js +17 -18
- package/dist/npm/TreeView.js +6 -9
- package/dist/npm/TreeViewItem.d.ts +2 -2
- package/dist/npm/TreeViewItem.js +6 -7
- package/dist/npm/handleTreeViewCheckChange.js +11 -13
- package/dist/npm/main.d.ts +1 -1
- package/dist/npm/main.js +2 -2
- package/dist/npm/moveTreeViewItem.js +7 -8
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/processTreeViewItems.js +7 -8
- package/dist/npm/utils/getItemIdUponKeyboardNavigation.d.ts +2 -2
- package/dist/npm/utils/getItemIdUponKeyboardNavigation.js +21 -22
- package/dist/systemjs/kendo-react-treeview.js +1 -1
- package/package.json +6 -6
- package/dist/es/utils/FieldsService.d.ts +0 -26
- package/dist/es/utils/FieldsService.js +0 -50
- package/dist/es/utils/SortedPublicItemIds.d.ts +0 -8
- package/dist/es/utils/SortedPublicItemIds.js +0 -26
- package/dist/es/utils/itemIdUtils.d.ts +0 -60
- package/dist/es/utils/itemIdUtils.js +0 -117
- package/dist/es/utils/itemUtils.d.ts +0 -45
- package/dist/es/utils/itemUtils.js +0 -191
- package/dist/es/utils/misc.d.ts +0 -9
- package/dist/es/utils/misc.js +0 -17
- package/dist/npm/utils/FieldsService.d.ts +0 -26
- package/dist/npm/utils/FieldsService.js +0 -52
- package/dist/npm/utils/SortedPublicItemIds.d.ts +0 -8
- package/dist/npm/utils/SortedPublicItemIds.js +0 -28
- package/dist/npm/utils/itemIdUtils.d.ts +0 -60
- package/dist/npm/utils/itemIdUtils.js +0 -132
- package/dist/npm/utils/itemUtils.d.ts +0 -45
- package/dist/npm/utils/itemUtils.js +0 -205
- package/dist/npm/utils/misc.d.ts +0 -9
- package/dist/npm/utils/misc.js +0 -22
package/dist/es/TreeView.js
CHANGED
|
@@ -15,12 +15,9 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
})();
|
|
16
16
|
import * as React from 'react';
|
|
17
17
|
import * as PropTypes from 'prop-types';
|
|
18
|
-
import { Keys, dispatchEvent, guid, kendoThemeMaps, classNames } from '@progress/kendo-react-common';
|
|
18
|
+
import { Keys, dispatchEvent, guid, kendoThemeMaps, classNames, resolveItemId, isEnabledAndAllParentsEnabled, hasChildren, TreeFieldsService as FieldsService, treeIdUtils } from '@progress/kendo-react-common';
|
|
19
19
|
import nav from './utils/getItemIdUponKeyboardNavigation';
|
|
20
|
-
import { resolveItemId, isEnabledAndAllParentsEnabled, hasChildren } from './utils/itemUtils';
|
|
21
20
|
import { TreeViewItem } from './TreeViewItem';
|
|
22
|
-
import { ZERO_LEVEL_ZERO_NODE_ID, getItemById } from './utils/itemIdUtils';
|
|
23
|
-
import FieldsService from './utils/FieldsService';
|
|
24
21
|
import { validatePackage } from '@progress/kendo-react-common';
|
|
25
22
|
import { packageMetadata } from './package-metadata';
|
|
26
23
|
import { CHECK_FIELD, CHECK_INDETERMINATE_FIELD, CHILDREN_FIELD, DISABLED_FIELD, EXPAND_FIELD, HAS_CHILDREN_FIELD, SELECT_FIELD, TEXT_FIELD } from './utils/consts';
|
|
@@ -52,7 +49,7 @@ var TreeView = /** @class */ (function (_super) {
|
|
|
52
49
|
/**
|
|
53
50
|
* @hidden
|
|
54
51
|
*/
|
|
55
|
-
_this.state = { focusedItemId: undefined, focusedItemPublicId: undefined, tabbableItemId: ZERO_LEVEL_ZERO_NODE_ID };
|
|
52
|
+
_this.state = { focusedItemId: undefined, focusedItemPublicId: undefined, tabbableItemId: treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID };
|
|
56
53
|
_this.fieldsSvc = null;
|
|
57
54
|
// When there is a change in state.focusedItemId, calling focus() on the dom element of the focused item
|
|
58
55
|
// is most often not needed, because the browser focuses the element on its own.
|
|
@@ -231,7 +228,7 @@ var TreeView = /** @class */ (function (_super) {
|
|
|
231
228
|
return this.state.focusedItemId ? this.getItemById(this.state.focusedItemId) : undefined;
|
|
232
229
|
};
|
|
233
230
|
TreeView.prototype.getItemById = function (itemId) {
|
|
234
|
-
return getItemById(itemId, this.data, this.props.childrenField || CHILDREN_FIELD);
|
|
231
|
+
return treeIdUtils.getItemById(itemId, this.data, this.props.childrenField || CHILDREN_FIELD);
|
|
235
232
|
};
|
|
236
233
|
TreeView.prototype.dispatchCheckChange = function (dispatchedEvent, item, itemId) {
|
|
237
234
|
dispatchEvent(this.props.onCheckChange, dispatchedEvent, this, { item: item, itemHierarchicalIndex: itemId });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { TreeFieldsService } from '@progress/kendo-react-common';
|
|
3
3
|
/**
|
|
4
4
|
* @hidden
|
|
5
5
|
*/
|
|
@@ -14,7 +14,7 @@ export interface TreeViewItemProps {
|
|
|
14
14
|
animate: boolean;
|
|
15
15
|
focusedItemId?: string;
|
|
16
16
|
tabbableItemId: string;
|
|
17
|
-
fieldsService:
|
|
17
|
+
fieldsService: TreeFieldsService;
|
|
18
18
|
itemUI?: React.ComponentType<{
|
|
19
19
|
item: any;
|
|
20
20
|
itemHierarchicalIndex: string;
|
package/dist/es/TreeViewItem.js
CHANGED
|
@@ -27,8 +27,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
27
27
|
import * as React from 'react';
|
|
28
28
|
import { classNames, guid, Draggable, kendoThemeMaps, IconWrap } from '@progress/kendo-react-common';
|
|
29
29
|
import { caretAltDownIcon, caretAltLeftIcon, caretAltRightIcon } from '@progress/kendo-svg-icons';
|
|
30
|
-
import {
|
|
31
|
-
import { isItemExpandedAndWithChildren, hasChildren } from './utils/itemUtils';
|
|
30
|
+
import { isItemExpandedAndWithChildren, hasChildren, treeIdUtils } from '@progress/kendo-react-common';
|
|
32
31
|
import { Reveal } from '@progress/kendo-react-animation';
|
|
33
32
|
import { DOM_KENDO_ITEM_ID_FIELD, DOM_KENDO_TREEVIEW_GUID_FIELD } from './utils/consts';
|
|
34
33
|
var sizeMap = kendoThemeMaps.sizeMap;
|
|
@@ -142,7 +141,7 @@ var TreeViewItemWithoutContext = /** @class */ (function (_super) {
|
|
|
142
141
|
var data = this.fieldsSvc.children(this.item);
|
|
143
142
|
return isItemExpandedAndWithChildren(this.item, this.fieldsSvc) ?
|
|
144
143
|
(React.createElement("ul", { className: "k-treeview-group", role: "group" }, data.map(function (item, index) {
|
|
145
|
-
return (React.createElement(TreeViewItem, { item: item, position: index === 0 ? 'top' : index === data.length - 1 ? 'bot' : 'mid', itemId: 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 }));
|
|
144
|
+
return (React.createElement(TreeViewItem, { item: item, position: index === 0 ? 'top' : index === data.length - 1 ? 'bot' : 'mid', itemId: 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 }));
|
|
146
145
|
}))) : undefined;
|
|
147
146
|
};
|
|
148
147
|
TreeViewItemWithoutContext.prototype.renderItemInPart = function () {
|
|
@@ -25,9 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
import { getAllDirectIndirectChildrenIds, areAllDirectChildrenChecked, getAllParents } from '
|
|
29
|
-
import { getDirectParentId, getItemById } from './utils/itemIdUtils';
|
|
30
|
-
import { isArray, getNestedValue } from './utils/misc';
|
|
28
|
+
import { getAllDirectIndirectChildrenIds, areAllDirectChildrenChecked, getAllParents, isArray, getNestedValue, treeIdUtils } from '@progress/kendo-react-common';
|
|
31
29
|
import { CHILDREN_FIELD } from './utils/consts';
|
|
32
30
|
/**
|
|
33
31
|
* A helper function which updates the check descriptor.
|
|
@@ -179,14 +177,14 @@ function checkParents(itemHierarchicalIndex, itemJustChecked, idField, childrenF
|
|
|
179
177
|
return [3 /*break*/, 1];
|
|
180
178
|
case 4: return [3 /*break*/, 8];
|
|
181
179
|
case 5:
|
|
182
|
-
parentId = getDirectParentId(itemHierarchicalIndex);
|
|
180
|
+
parentId = treeIdUtils.getDirectParentId(itemHierarchicalIndex);
|
|
183
181
|
_a.label = 6;
|
|
184
182
|
case 6:
|
|
185
183
|
if (!parentId) return [3 /*break*/, 8];
|
|
186
|
-
return [4 /*yield*/, { id: parentId, item: itemJustChecked ? getItemById(parentId, data, childrenField) : undefined }];
|
|
184
|
+
return [4 /*yield*/, { id: parentId, item: itemJustChecked ? treeIdUtils.getItemById(parentId, data, childrenField) : undefined }];
|
|
187
185
|
case 7:
|
|
188
186
|
_a.sent();
|
|
189
|
-
parentId = getDirectParentId(parentId);
|
|
187
|
+
parentId = treeIdUtils.getDirectParentId(parentId);
|
|
190
188
|
return [3 /*break*/, 6];
|
|
191
189
|
case 8: return [2 /*return*/];
|
|
192
190
|
}
|
package/dist/es/main.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ import { TreeViewDragClue } from './TreeViewDragClue';
|
|
|
10
10
|
import { TreeViewDragAnalyzer } from './TreeViewDragAnalyzer';
|
|
11
11
|
import { TreeViewItemPropsContext } from './TreeViewItem';
|
|
12
12
|
import getItemIdUponKeyboardNavigation from './utils/getItemIdUponKeyboardNavigation';
|
|
13
|
-
import FieldsService from '
|
|
13
|
+
import { TreeFieldsService as FieldsService } from '@progress/kendo-react-common';
|
|
14
14
|
export { TreeViewItemPropsContext, TreeView, processTreeViewItems, handleTreeViewCheckChange, TreeViewCheckChangeSettings, TreeViewItemClickEvent, TreeViewExpandChangeEvent, TreeViewCheckChangeEvent, TreeViewItemDragOverEvent, TreeViewItemDragStartEvent, TreeViewItemDragEndEvent, TreeViewOperationDescriptor, TreeViewOperationDescriptors, TreeViewCheckDescriptor, TreeViewProps, ItemRenderProps, TreeViewDragClue, moveTreeViewItem, TreeViewDragAnalyzer, getItemIdUponKeyboardNavigation, FieldsService };
|
package/dist/es/main.js
CHANGED
|
@@ -6,5 +6,5 @@ import { TreeViewDragClue } from './TreeViewDragClue';
|
|
|
6
6
|
import { TreeViewDragAnalyzer } from './TreeViewDragAnalyzer';
|
|
7
7
|
import { TreeViewItemPropsContext } from './TreeViewItem';
|
|
8
8
|
import getItemIdUponKeyboardNavigation from './utils/getItemIdUponKeyboardNavigation';
|
|
9
|
-
import FieldsService from '
|
|
9
|
+
import { TreeFieldsService as FieldsService } from '@progress/kendo-react-common';
|
|
10
10
|
export { TreeViewItemPropsContext, TreeView, processTreeViewItems, handleTreeViewCheckChange, TreeViewDragClue, moveTreeViewItem, TreeViewDragAnalyzer, getItemIdUponKeyboardNavigation, FieldsService };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { addItem, removeItem } from '
|
|
2
|
-
import { getDecrementedItemIdAfterRemoval, getItemById } from './utils/itemIdUtils';
|
|
1
|
+
import { addItem, removeItem, treeIdUtils } from '@progress/kendo-react-common';
|
|
3
2
|
import { CHILDREN_FIELD } from './utils/consts';
|
|
4
3
|
/**
|
|
5
4
|
* A helper function which moves a TreeView item in an immutable way.
|
|
@@ -111,7 +110,7 @@ export function moveTreeViewItem(sourceItemHierarchicalIndex, sourceData, operat
|
|
|
111
110
|
if (!validateInput()) {
|
|
112
111
|
return prepareInputDataForReturn();
|
|
113
112
|
}
|
|
114
|
-
var sourceItem = getItemById(sourceItemHierarchicalIndex, sourceData, subItemsField);
|
|
113
|
+
var sourceItem = treeIdUtils.getItemById(sourceItemHierarchicalIndex, sourceData, subItemsField);
|
|
115
114
|
if (!sourceItem) {
|
|
116
115
|
return prepareInputDataForReturn();
|
|
117
116
|
}
|
|
@@ -121,7 +120,7 @@ export function moveTreeViewItem(sourceItemHierarchicalIndex, sourceData, operat
|
|
|
121
120
|
return prepareInputDataForReturn();
|
|
122
121
|
}
|
|
123
122
|
var updatedSourceData = removeItem(sourceItemHierarchicalIndex, subItemsField, sourceData);
|
|
124
|
-
var resultData = addItem(sourceItem, operation, subItemsField, getDecrementedItemIdAfterRemoval(sourceItemHierarchicalIndex, targetItemHierarchicalIndex), updatedSourceData);
|
|
123
|
+
var resultData = addItem(sourceItem, operation, subItemsField, treeIdUtils.getDecrementedItemIdAfterRemoval(sourceItemHierarchicalIndex, targetItemHierarchicalIndex), updatedSourceData);
|
|
125
124
|
// A simpler output is explicitly returned when the source and the target tree are
|
|
126
125
|
// the same, that is, the targetData argument is skipped.
|
|
127
126
|
return targetData ? { sourceData: resultData, targetData: resultData } : resultData;
|
|
@@ -148,7 +147,7 @@ export function moveTreeViewItem(sourceItemHierarchicalIndex, sourceData, operat
|
|
|
148
147
|
}
|
|
149
148
|
// Validate that the target item exists.
|
|
150
149
|
var data = !targetData || targetData === sourceData ? sourceData : targetData;
|
|
151
|
-
if (!getItemById(targetItemHierarchicalIndex, data, subItemsField)) {
|
|
150
|
+
if (!treeIdUtils.getItemById(targetItemHierarchicalIndex, data, subItemsField)) {
|
|
152
151
|
return false;
|
|
153
152
|
}
|
|
154
153
|
return true;
|
|
@@ -5,7 +5,7 @@ export var packageMetadata = {
|
|
|
5
5
|
name: '@progress/kendo-react-treeview',
|
|
6
6
|
productName: 'KendoReact',
|
|
7
7
|
productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
|
|
8
|
-
publishDate:
|
|
8
|
+
publishDate: 1696595032,
|
|
9
9
|
version: '',
|
|
10
10
|
licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
|
|
11
11
|
};
|
|
@@ -10,9 +10,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
import { updateItem, resolveItemsIds } from '
|
|
13
|
+
import { updateItem, resolveItemsIds, getNestedValue, isArray } from '@progress/kendo-react-common';
|
|
14
14
|
import { EXPAND_FIELD, SELECT_FIELD, CHECK_FIELD, CHECK_INDETERMINATE_FIELD, CHILDREN_FIELD } from './utils/consts';
|
|
15
|
-
import { getNestedValue, isArray } from './utils/misc';
|
|
16
15
|
/**
|
|
17
16
|
* A helper function which applies the specified operation descriptors to the data.
|
|
18
17
|
* * [Expanding and collapsing items]({% slug expansion_ways_treeview %}#toc-using-a-helper-function)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TreeFieldsService } from '@progress/kendo-react-common';
|
|
2
2
|
/**
|
|
3
3
|
* @hidden
|
|
4
4
|
*/
|
|
5
|
-
export default function getItemIdUponKeyboardNavigation(item: any, itemId: string, items: any[], keyCode: number, fieldsSvc:
|
|
5
|
+
export default function getItemIdUponKeyboardNavigation(item: any, itemId: string, items: any[], keyCode: number, fieldsSvc: TreeFieldsService): any;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Keys } from '@progress/kendo-react-common';
|
|
2
|
-
import
|
|
3
|
-
import { isItemExpandedAndWithChildren, isEnabledAndAllParentsEnabled } from './itemUtils';
|
|
2
|
+
import { isItemExpandedAndWithChildren, isEnabledAndAllParentsEnabled, treeIdUtils } from '@progress/kendo-react-common';
|
|
4
3
|
/**
|
|
5
4
|
* @hidden
|
|
6
5
|
*/
|
|
@@ -15,31 +14,31 @@ export default function getItemIdUponKeyboardNavigation(item, itemId, items, key
|
|
|
15
14
|
case Keys.down:
|
|
16
15
|
return getIdUponDownKey();
|
|
17
16
|
case Keys.home:
|
|
18
|
-
return
|
|
17
|
+
return treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID;
|
|
19
18
|
case Keys.end:
|
|
20
19
|
return getIdUponEndKey();
|
|
21
20
|
default:
|
|
22
21
|
return itemId;
|
|
23
22
|
}
|
|
24
23
|
function getIdUponLeftKey() {
|
|
25
|
-
return
|
|
24
|
+
return treeIdUtils.isIdZeroLevel(itemId)
|
|
26
25
|
// For expanded disabled items, navigate directly to the parent.
|
|
27
26
|
// Collapse cannot happen because an event is not fired to the client.
|
|
28
27
|
|| (fieldsSvc.expanded(item) && isEnabledAndAllParentsEnabled(itemId, items, fieldsSvc)) ?
|
|
29
|
-
itemId :
|
|
28
|
+
itemId : treeIdUtils.getDirectParentId(itemId);
|
|
30
29
|
}
|
|
31
30
|
function getIdUponRightKey() {
|
|
32
|
-
return isItemExpandedAndWithChildren(item, fieldsSvc) ?
|
|
31
|
+
return isItemExpandedAndWithChildren(item, fieldsSvc) ? treeIdUtils.getFirstChildId(itemId) : itemId;
|
|
33
32
|
}
|
|
34
33
|
function getIdUponUpKey() {
|
|
35
|
-
var index = Number(
|
|
36
|
-
var parentId =
|
|
37
|
-
return index ? getLastNotOpenedChildId(
|
|
38
|
-
|
|
34
|
+
var index = Number(treeIdUtils.getShortId(itemId));
|
|
35
|
+
var parentId = treeIdUtils.getDirectParentId(itemId);
|
|
36
|
+
return index ? getLastNotOpenedChildId(treeIdUtils.createId(index - 1, parentId), items, fieldsSvc) :
|
|
37
|
+
treeIdUtils.isIdZeroLevel(itemId) ? itemId : parentId;
|
|
39
38
|
}
|
|
40
39
|
function getIdUponDownKey() {
|
|
41
40
|
if (isItemExpandedAndWithChildren(item, fieldsSvc)) {
|
|
42
|
-
return
|
|
41
|
+
return treeIdUtils.getFirstChildId(itemId);
|
|
43
42
|
}
|
|
44
43
|
else {
|
|
45
44
|
return getNextItemId(itemId, items, fieldsSvc) || itemId;
|
|
@@ -51,25 +50,25 @@ export default function getItemIdUponKeyboardNavigation(item, itemId, items, key
|
|
|
51
50
|
var children;
|
|
52
51
|
while (isItemExpandedAndWithChildren(currentItem, fieldsSvc)) {
|
|
53
52
|
children = currentItem[fieldsSvc.getChildrenField()];
|
|
54
|
-
result =
|
|
53
|
+
result = treeIdUtils.createId(children.length - 1, result);
|
|
55
54
|
currentItem = children[children.length - 1];
|
|
56
55
|
}
|
|
57
56
|
return result;
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
function getNextItemId(itemId, items, fieldsSvc) {
|
|
61
|
-
var parentId =
|
|
62
|
-
var parent = parentId ?
|
|
60
|
+
var parentId = treeIdUtils.getDirectParentId(itemId);
|
|
61
|
+
var parent = parentId ? treeIdUtils.getItemById(parentId, items, fieldsSvc.getChildrenField()) : undefined;
|
|
63
62
|
var siblings = parent ? parent[fieldsSvc.getChildrenField()] : items;
|
|
64
|
-
var index = Number(
|
|
63
|
+
var index = Number(treeIdUtils.getShortId(itemId));
|
|
65
64
|
return index < siblings.length - 1 ?
|
|
66
|
-
|
|
65
|
+
treeIdUtils.createId(index + 1, parentId) :
|
|
67
66
|
parent ? getNextItemId(parentId, items, fieldsSvc) : undefined;
|
|
68
67
|
}
|
|
69
68
|
function getLastNotOpenedChildId(itemId, items, fieldsSvc) {
|
|
70
|
-
var item =
|
|
69
|
+
var item = treeIdUtils.getItemById(itemId, items, fieldsSvc.getChildrenField());
|
|
71
70
|
if (isItemExpandedAndWithChildren(item, fieldsSvc)) {
|
|
72
|
-
return getLastNotOpenedChildId(
|
|
71
|
+
return getLastNotOpenedChildId(treeIdUtils.createId(item[fieldsSvc.getChildrenField()].length - 1, itemId), items, fieldsSvc);
|
|
73
72
|
}
|
|
74
73
|
else {
|
|
75
74
|
return itemId;
|
package/dist/npm/TreeView.js
CHANGED
|
@@ -20,10 +20,7 @@ var React = require("react");
|
|
|
20
20
|
var PropTypes = require("prop-types");
|
|
21
21
|
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
22
22
|
var getItemIdUponKeyboardNavigation_1 = require("./utils/getItemIdUponKeyboardNavigation");
|
|
23
|
-
var itemUtils_1 = require("./utils/itemUtils");
|
|
24
23
|
var TreeViewItem_1 = require("./TreeViewItem");
|
|
25
|
-
var itemIdUtils_1 = require("./utils/itemIdUtils");
|
|
26
|
-
var FieldsService_1 = require("./utils/FieldsService");
|
|
27
24
|
var kendo_react_common_2 = require("@progress/kendo-react-common");
|
|
28
25
|
var package_metadata_1 = require("./package-metadata");
|
|
29
26
|
var consts_1 = require("./utils/consts");
|
|
@@ -55,7 +52,7 @@ var TreeView = /** @class */ (function (_super) {
|
|
|
55
52
|
/**
|
|
56
53
|
* @hidden
|
|
57
54
|
*/
|
|
58
|
-
_this.state = { focusedItemId: undefined, focusedItemPublicId: undefined, tabbableItemId:
|
|
55
|
+
_this.state = { focusedItemId: undefined, focusedItemPublicId: undefined, tabbableItemId: kendo_react_common_1.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID };
|
|
59
56
|
_this.fieldsSvc = null;
|
|
60
57
|
// When there is a change in state.focusedItemId, calling focus() on the dom element of the focused item
|
|
61
58
|
// is most often not needed, because the browser focuses the element on its own.
|
|
@@ -167,7 +164,7 @@ var TreeView = /** @class */ (function (_super) {
|
|
|
167
164
|
TreeView.prototype.render = function () {
|
|
168
165
|
var _a;
|
|
169
166
|
var _this = this;
|
|
170
|
-
this.fieldsSvc = new
|
|
167
|
+
this.fieldsSvc = new kendo_react_common_1.TreeFieldsService(this.props);
|
|
171
168
|
var _b = this.props, size = _b.size, className = _b.className;
|
|
172
169
|
return (React.createElement("div", { className: (0, kendo_react_common_1.classNames)('k-treeview', (_a = {},
|
|
173
170
|
_a["k-treeview-".concat(sizeMap[size] || size)] = size,
|
|
@@ -192,13 +189,13 @@ var TreeView = /** @class */ (function (_super) {
|
|
|
192
189
|
}
|
|
193
190
|
// isEnabled is the most expensive op and that is why is left last.
|
|
194
191
|
var isEnabled = function () {
|
|
195
|
-
return _this.fieldsSvc && (0,
|
|
192
|
+
return _this.fieldsSvc && (0, kendo_react_common_1.isEnabledAndAllParentsEnabled)(_this.state.focusedItemId, _this.data, _this.fieldsSvc);
|
|
196
193
|
};
|
|
197
194
|
if (event.keyCode === kendo_react_common_1.Keys.left && this.fieldsSvc.expanded(focusedItem) && isEnabled()) {
|
|
198
195
|
this.dispatchExpandChange(event, focusedItem, this.state.focusedItemId);
|
|
199
196
|
}
|
|
200
197
|
else if (event.keyCode === kendo_react_common_1.Keys.right && !this.fieldsSvc.expanded(focusedItem) &&
|
|
201
|
-
(this.fieldsSvc.hasChildren(focusedItem) || (0,
|
|
198
|
+
(this.fieldsSvc.hasChildren(focusedItem) || (0, kendo_react_common_1.hasChildren)(focusedItem, this.props.childrenField)) && isEnabled()) {
|
|
202
199
|
this.dispatchExpandChange(event, focusedItem, this.state.focusedItemId);
|
|
203
200
|
}
|
|
204
201
|
else if (event.keyCode === kendo_react_common_1.Keys.enter && isEnabled()) {
|
|
@@ -234,7 +231,7 @@ var TreeView = /** @class */ (function (_super) {
|
|
|
234
231
|
return this.state.focusedItemId ? this.getItemById(this.state.focusedItemId) : undefined;
|
|
235
232
|
};
|
|
236
233
|
TreeView.prototype.getItemById = function (itemId) {
|
|
237
|
-
return
|
|
234
|
+
return kendo_react_common_1.treeIdUtils.getItemById(itemId, this.data, this.props.childrenField || consts_1.CHILDREN_FIELD);
|
|
238
235
|
};
|
|
239
236
|
TreeView.prototype.dispatchCheckChange = function (dispatchedEvent, item, itemId) {
|
|
240
237
|
(0, kendo_react_common_1.dispatchEvent)(this.props.onCheckChange, dispatchedEvent, this, { item: item, itemHierarchicalIndex: itemId });
|
|
@@ -251,7 +248,7 @@ var TreeView = /** @class */ (function (_super) {
|
|
|
251
248
|
if (focusedItemPublicId) {
|
|
252
249
|
var focusedItemId = this.props.getFocusHierarchicalIndex ?
|
|
253
250
|
this.props.getFocusHierarchicalIndex(focusedItemPublicId) :
|
|
254
|
-
(0,
|
|
251
|
+
(0, kendo_react_common_1.resolveItemId)(focusedItemPublicId, this.fieldsSvc.focusIdField, this.data, this.props.childrenField);
|
|
255
252
|
if (focusedItemId !== this.state.focusedItemId) {
|
|
256
253
|
this.allowExplicitFocus = true;
|
|
257
254
|
this.setState({ focusedItemId: focusedItemId });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { TreeFieldsService } from '@progress/kendo-react-common';
|
|
3
3
|
/**
|
|
4
4
|
* @hidden
|
|
5
5
|
*/
|
|
@@ -14,7 +14,7 @@ export interface TreeViewItemProps {
|
|
|
14
14
|
animate: boolean;
|
|
15
15
|
focusedItemId?: string;
|
|
16
16
|
tabbableItemId: string;
|
|
17
|
-
fieldsService:
|
|
17
|
+
fieldsService: TreeFieldsService;
|
|
18
18
|
itemUI?: React.ComponentType<{
|
|
19
19
|
item: any;
|
|
20
20
|
itemHierarchicalIndex: string;
|
package/dist/npm/TreeViewItem.js
CHANGED
|
@@ -30,8 +30,7 @@ exports.TreeViewItem = exports.TreeViewItemPropsContext = void 0;
|
|
|
30
30
|
var React = require("react");
|
|
31
31
|
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
32
32
|
var kendo_svg_icons_1 = require("@progress/kendo-svg-icons");
|
|
33
|
-
var
|
|
34
|
-
var itemUtils_1 = require("./utils/itemUtils");
|
|
33
|
+
var kendo_react_common_2 = require("@progress/kendo-react-common");
|
|
35
34
|
var kendo_react_animation_1 = require("@progress/kendo-react-animation");
|
|
36
35
|
var consts_1 = require("./utils/consts");
|
|
37
36
|
var sizeMap = kendo_react_common_1.kendoThemeMaps.sizeMap;
|
|
@@ -133,7 +132,7 @@ var TreeViewItemWithoutContext = /** @class */ (function (_super) {
|
|
|
133
132
|
var renderExpand = this.props.expandIcons &&
|
|
134
133
|
// If it is explicitly said that the item has children (even not loaded yet)
|
|
135
134
|
// or if the item actually has children, then render the icon.
|
|
136
|
-
(this.fieldsSvc.hasChildren(this.item) || (0,
|
|
135
|
+
(this.fieldsSvc.hasChildren(this.item) || (0, kendo_react_common_2.hasChildren)(this.item, this.fieldsSvc.getChildrenField()));
|
|
137
136
|
return renderExpand && (
|
|
138
137
|
// Allowing the toggle-button even with `disabled=true` might be a valid case!
|
|
139
138
|
// Re-evaluate the classes bellow if such scenario occurs
|
|
@@ -143,9 +142,9 @@ var TreeViewItemWithoutContext = /** @class */ (function (_super) {
|
|
|
143
142
|
TreeViewItemWithoutContext.prototype.renderSubitemsIfApplicable = function () {
|
|
144
143
|
var _this = this;
|
|
145
144
|
var data = this.fieldsSvc.children(this.item);
|
|
146
|
-
return (0,
|
|
145
|
+
return (0, kendo_react_common_2.isItemExpandedAndWithChildren)(this.item, this.fieldsSvc) ?
|
|
147
146
|
(React.createElement("ul", { className: "k-treeview-group", role: "group" }, data.map(function (item, index) {
|
|
148
|
-
return (React.createElement(exports.TreeViewItem, { item: item, position: index === 0 ? 'top' : index === data.length - 1 ? 'bot' : 'mid', itemId:
|
|
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 }));
|
|
149
148
|
}))) : undefined;
|
|
150
149
|
};
|
|
151
150
|
TreeViewItemWithoutContext.prototype.renderItemInPart = function () {
|
|
@@ -188,7 +187,7 @@ var TreeViewItemWithoutContext = /** @class */ (function (_super) {
|
|
|
188
187
|
});
|
|
189
188
|
Object.defineProperty(TreeViewItemWithoutContext.prototype, "ariaExpanded", {
|
|
190
189
|
get: function () {
|
|
191
|
-
return this.fieldsSvc.hasChildren(this.item) || (0,
|
|
190
|
+
return this.fieldsSvc.hasChildren(this.item) || (0, kendo_react_common_2.hasChildren)(this.item, this.fieldsSvc.getChildrenField()) ?
|
|
192
191
|
Boolean(this.fieldsSvc.expanded(this.item)) : undefined;
|
|
193
192
|
},
|
|
194
193
|
enumerable: false,
|
|
@@ -235,7 +234,7 @@ var TreeViewItemWithoutContext = /** @class */ (function (_super) {
|
|
|
235
234
|
});
|
|
236
235
|
TreeViewItemWithoutContext.prototype.getIconProps = function () {
|
|
237
236
|
var expanded = this.fieldsSvc.expanded(this.item);
|
|
238
|
-
var loading = expanded && !(0,
|
|
237
|
+
var loading = expanded && !(0, kendo_react_common_2.hasChildren)(this.item, this.fieldsSvc.getChildrenField());
|
|
239
238
|
if (loading) {
|
|
240
239
|
return { name: 'loading' };
|
|
241
240
|
}
|
|
@@ -28,9 +28,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.handleTreeViewCheckChange = void 0;
|
|
31
|
-
var
|
|
32
|
-
var itemIdUtils_1 = require("./utils/itemIdUtils");
|
|
33
|
-
var misc_1 = require("./utils/misc");
|
|
31
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
34
32
|
var consts_1 = require("./utils/consts");
|
|
35
33
|
/**
|
|
36
34
|
* A helper function which updates the check descriptor.
|
|
@@ -85,7 +83,7 @@ function handleTreeViewCheckChange(event, check, data, settings, childrenField)
|
|
|
85
83
|
return [];
|
|
86
84
|
}
|
|
87
85
|
var _a = parseOperation(check), ids = _a.ids, idField = _a.idField;
|
|
88
|
-
var itemId = idField ? (0,
|
|
86
|
+
var itemId = idField ? (0, kendo_react_common_1.getNestedValue)(idField, event.item) : event.itemHierarchicalIndex;
|
|
89
87
|
var idIndex = ids.indexOf(itemId);
|
|
90
88
|
var itemJustChecked = idIndex === -1;
|
|
91
89
|
var subItemsField = childrenField || consts_1.CHILDREN_FIELD;
|
|
@@ -103,13 +101,13 @@ function handleTreeViewCheckChange(event, check, data, settings, childrenField)
|
|
|
103
101
|
checkParents(event.itemHierarchicalIndex, itemJustChecked, idField, subItemsField, newIds, data);
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
|
-
return (0,
|
|
104
|
+
return (0, kendo_react_common_1.isArray)(check) ? newIds : Object.assign({}, check, { ids: newIds });
|
|
107
105
|
}
|
|
108
106
|
exports.handleTreeViewCheckChange = handleTreeViewCheckChange;
|
|
109
107
|
function parseOperation(operation) {
|
|
110
108
|
var ids;
|
|
111
109
|
var idField = undefined;
|
|
112
|
-
if ((0,
|
|
110
|
+
if ((0, kendo_react_common_1.isArray)(operation)) {
|
|
113
111
|
ids = operation;
|
|
114
112
|
}
|
|
115
113
|
else {
|
|
@@ -119,7 +117,7 @@ function parseOperation(operation) {
|
|
|
119
117
|
return { ids: ids, idField: idField };
|
|
120
118
|
}
|
|
121
119
|
function checkChildren(item, itemHierarchicalIndex, itemJustChecked, idField, childrenField, ids) {
|
|
122
|
-
(0,
|
|
120
|
+
(0, kendo_react_common_1.getAllDirectIndirectChildrenIds)(item, itemHierarchicalIndex, childrenField, idField).forEach(function (itemId) {
|
|
123
121
|
if (itemJustChecked && ids.indexOf(itemId) === -1) {
|
|
124
122
|
ids.push(itemId);
|
|
125
123
|
}
|
|
@@ -138,7 +136,7 @@ function checkParents(itemHierarchicalIndex, itemJustChecked, idField, childrenF
|
|
|
138
136
|
var _a = result.value, id = _a.id, item = _a.item;
|
|
139
137
|
// The first check is needed. However, it is not sure whether to stop the entire loop.
|
|
140
138
|
if (ids.indexOf(id) === -1 &&
|
|
141
|
-
(0,
|
|
139
|
+
(0, kendo_react_common_1.areAllDirectChildrenChecked)(item, id, idField, childrenField, ids)) {
|
|
142
140
|
ids.push(id);
|
|
143
141
|
result = it.next();
|
|
144
142
|
}
|
|
@@ -169,12 +167,12 @@ function checkParents(itemHierarchicalIndex, itemJustChecked, idField, childrenF
|
|
|
169
167
|
switch (_a.label) {
|
|
170
168
|
case 0:
|
|
171
169
|
if (!idField) return [3 /*break*/, 5];
|
|
172
|
-
parents = (0,
|
|
170
|
+
parents = (0, kendo_react_common_1.getAllParents)(itemHierarchicalIndex, childrenField, data);
|
|
173
171
|
i = parents.length - 1;
|
|
174
172
|
_a.label = 1;
|
|
175
173
|
case 1:
|
|
176
174
|
if (!(i > -1)) return [3 /*break*/, 4];
|
|
177
|
-
return [4 /*yield*/, { id: (0,
|
|
175
|
+
return [4 /*yield*/, { id: (0, kendo_react_common_1.getNestedValue)(idField, parents[i]), item: itemJustChecked ? parents[i] : undefined }];
|
|
178
176
|
case 2:
|
|
179
177
|
_a.sent();
|
|
180
178
|
_a.label = 3;
|
|
@@ -183,14 +181,14 @@ function checkParents(itemHierarchicalIndex, itemJustChecked, idField, childrenF
|
|
|
183
181
|
return [3 /*break*/, 1];
|
|
184
182
|
case 4: return [3 /*break*/, 8];
|
|
185
183
|
case 5:
|
|
186
|
-
parentId =
|
|
184
|
+
parentId = kendo_react_common_1.treeIdUtils.getDirectParentId(itemHierarchicalIndex);
|
|
187
185
|
_a.label = 6;
|
|
188
186
|
case 6:
|
|
189
187
|
if (!parentId) return [3 /*break*/, 8];
|
|
190
|
-
return [4 /*yield*/, { id: parentId, item: itemJustChecked ?
|
|
188
|
+
return [4 /*yield*/, { id: parentId, item: itemJustChecked ? kendo_react_common_1.treeIdUtils.getItemById(parentId, data, childrenField) : undefined }];
|
|
191
189
|
case 7:
|
|
192
190
|
_a.sent();
|
|
193
|
-
parentId =
|
|
191
|
+
parentId = kendo_react_common_1.treeIdUtils.getDirectParentId(parentId);
|
|
194
192
|
return [3 /*break*/, 6];
|
|
195
193
|
case 8: return [2 /*return*/];
|
|
196
194
|
}
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ import { TreeViewDragClue } from './TreeViewDragClue';
|
|
|
10
10
|
import { TreeViewDragAnalyzer } from './TreeViewDragAnalyzer';
|
|
11
11
|
import { TreeViewItemPropsContext } from './TreeViewItem';
|
|
12
12
|
import getItemIdUponKeyboardNavigation from './utils/getItemIdUponKeyboardNavigation';
|
|
13
|
-
import FieldsService from '
|
|
13
|
+
import { TreeFieldsService as FieldsService } from '@progress/kendo-react-common';
|
|
14
14
|
export { TreeViewItemPropsContext, TreeView, processTreeViewItems, handleTreeViewCheckChange, TreeViewCheckChangeSettings, TreeViewItemClickEvent, TreeViewExpandChangeEvent, TreeViewCheckChangeEvent, TreeViewItemDragOverEvent, TreeViewItemDragStartEvent, TreeViewItemDragEndEvent, TreeViewOperationDescriptor, TreeViewOperationDescriptors, TreeViewCheckDescriptor, TreeViewProps, ItemRenderProps, TreeViewDragClue, moveTreeViewItem, TreeViewDragAnalyzer, getItemIdUponKeyboardNavigation, FieldsService };
|
package/dist/npm/main.js
CHANGED
|
@@ -17,5 +17,5 @@ var TreeViewItem_1 = require("./TreeViewItem");
|
|
|
17
17
|
Object.defineProperty(exports, "TreeViewItemPropsContext", { enumerable: true, get: function () { return TreeViewItem_1.TreeViewItemPropsContext; } });
|
|
18
18
|
var getItemIdUponKeyboardNavigation_1 = require("./utils/getItemIdUponKeyboardNavigation");
|
|
19
19
|
exports.getItemIdUponKeyboardNavigation = getItemIdUponKeyboardNavigation_1.default;
|
|
20
|
-
var
|
|
21
|
-
exports
|
|
20
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
21
|
+
Object.defineProperty(exports, "FieldsService", { enumerable: true, get: function () { return kendo_react_common_1.TreeFieldsService; } });
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.moveTreeViewItem = void 0;
|
|
4
|
-
var
|
|
5
|
-
var itemIdUtils_1 = require("./utils/itemIdUtils");
|
|
4
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
6
5
|
var consts_1 = require("./utils/consts");
|
|
7
6
|
/**
|
|
8
7
|
* A helper function which moves a TreeView item in an immutable way.
|
|
@@ -114,7 +113,7 @@ function moveTreeViewItem(sourceItemHierarchicalIndex, sourceData, operation, ta
|
|
|
114
113
|
if (!validateInput()) {
|
|
115
114
|
return prepareInputDataForReturn();
|
|
116
115
|
}
|
|
117
|
-
var sourceItem =
|
|
116
|
+
var sourceItem = kendo_react_common_1.treeIdUtils.getItemById(sourceItemHierarchicalIndex, sourceData, subItemsField);
|
|
118
117
|
if (!sourceItem) {
|
|
119
118
|
return prepareInputDataForReturn();
|
|
120
119
|
}
|
|
@@ -123,15 +122,15 @@ function moveTreeViewItem(sourceItemHierarchicalIndex, sourceData, operation, ta
|
|
|
123
122
|
if (!validateNoCircularReference()) {
|
|
124
123
|
return prepareInputDataForReturn();
|
|
125
124
|
}
|
|
126
|
-
var updatedSourceData = (0,
|
|
127
|
-
var resultData = (0,
|
|
125
|
+
var updatedSourceData = (0, kendo_react_common_1.removeItem)(sourceItemHierarchicalIndex, subItemsField, sourceData);
|
|
126
|
+
var resultData = (0, kendo_react_common_1.addItem)(sourceItem, operation, subItemsField, kendo_react_common_1.treeIdUtils.getDecrementedItemIdAfterRemoval(sourceItemHierarchicalIndex, targetItemHierarchicalIndex), updatedSourceData);
|
|
128
127
|
// A simpler output is explicitly returned when the source and the target tree are
|
|
129
128
|
// the same, that is, the targetData argument is skipped.
|
|
130
129
|
return targetData ? { sourceData: resultData, targetData: resultData } : resultData;
|
|
131
130
|
}
|
|
132
131
|
else {
|
|
133
|
-
var updatedSource = (0,
|
|
134
|
-
var updatedTarget = (0,
|
|
132
|
+
var updatedSource = (0, kendo_react_common_1.removeItem)(sourceItemHierarchicalIndex, subItemsField, sourceData);
|
|
133
|
+
var updatedTarget = (0, kendo_react_common_1.addItem)(sourceItem, operation, subItemsField, targetItemHierarchicalIndex, targetData);
|
|
135
134
|
return { sourceData: updatedSource, targetData: updatedTarget };
|
|
136
135
|
}
|
|
137
136
|
function prepareInputDataForReturn() {
|
|
@@ -151,7 +150,7 @@ function moveTreeViewItem(sourceItemHierarchicalIndex, sourceData, operation, ta
|
|
|
151
150
|
}
|
|
152
151
|
// Validate that the target item exists.
|
|
153
152
|
var data = !targetData || targetData === sourceData ? sourceData : targetData;
|
|
154
|
-
if (!
|
|
153
|
+
if (!kendo_react_common_1.treeIdUtils.getItemById(targetItemHierarchicalIndex, data, subItemsField)) {
|
|
155
154
|
return false;
|
|
156
155
|
}
|
|
157
156
|
return true;
|
|
@@ -8,7 +8,7 @@ exports.packageMetadata = {
|
|
|
8
8
|
name: '@progress/kendo-react-treeview',
|
|
9
9
|
productName: 'KendoReact',
|
|
10
10
|
productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
|
|
11
|
-
publishDate:
|
|
11
|
+
publishDate: 1696595032,
|
|
12
12
|
version: '',
|
|
13
13
|
licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
|
|
14
14
|
};
|
|
@@ -13,9 +13,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.processTreeViewItems = void 0;
|
|
16
|
-
var
|
|
16
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
17
17
|
var consts_1 = require("./utils/consts");
|
|
18
|
-
var misc_1 = require("./utils/misc");
|
|
19
18
|
/**
|
|
20
19
|
* A helper function which applies the specified operation descriptors to the data.
|
|
21
20
|
* * [Expanding and collapsing items]({% slug expansion_ways_treeview %}#toc-using-a-helper-function)
|
|
@@ -85,7 +84,7 @@ exports.processTreeViewItems = processTreeViewItems;
|
|
|
85
84
|
function handleOperation(items, defaultField, operation, cloneField, childrenField) {
|
|
86
85
|
if (operation) {
|
|
87
86
|
var _a = parseOperation(operation, defaultField), ids = _a.ids, field = _a.field;
|
|
88
|
-
var indices = !(0,
|
|
87
|
+
var indices = !(0, kendo_react_common_1.isArray)(operation) && operation.idField ? (0, kendo_react_common_1.resolveItemsIds)(ids, operation.idField, items, childrenField) : ids;
|
|
89
88
|
return raiseFlags(items, indices, field, cloneField, childrenField);
|
|
90
89
|
}
|
|
91
90
|
else {
|
|
@@ -95,7 +94,7 @@ function handleOperation(items, defaultField, operation, cloneField, childrenFie
|
|
|
95
94
|
function parseOperation(operation, defaultField) {
|
|
96
95
|
var ids;
|
|
97
96
|
var field;
|
|
98
|
-
if ((0,
|
|
97
|
+
if ((0, kendo_react_common_1.isArray)(operation)) {
|
|
99
98
|
ids = operation;
|
|
100
99
|
field = defaultField;
|
|
101
100
|
}
|
|
@@ -108,7 +107,7 @@ function parseOperation(operation, defaultField) {
|
|
|
108
107
|
function raiseFlags(items, indices, field, cloneField, childrenField) {
|
|
109
108
|
var result = items;
|
|
110
109
|
indices.forEach(function (itemIndex) {
|
|
111
|
-
result = (0,
|
|
110
|
+
result = (0, kendo_react_common_1.updateItem)(result, itemIndex, function (item) { return raiseNestedFlag(field, item); }, cloneField, childrenField);
|
|
112
111
|
});
|
|
113
112
|
return result;
|
|
114
113
|
}
|
|
@@ -130,14 +129,14 @@ function raiseNestedFlag(fieldName, dataItem) {
|
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
function applyCheckIndeterminate(items, childrenField, check) {
|
|
133
|
-
if (check && !(0,
|
|
132
|
+
if (check && !(0, kendo_react_common_1.isArray)(check) && check.applyCheckIndeterminate) {
|
|
134
133
|
var checkField = parseOperation(check, consts_1.CHECK_FIELD).field;
|
|
135
134
|
var checkIndeterminateField = check.checkIndeterminateField || consts_1.CHECK_INDETERMINATE_FIELD;
|
|
136
135
|
for (var i = 0; i < items.length; i++) {
|
|
137
136
|
var item = items[i];
|
|
138
137
|
var subItems = item[childrenField];
|
|
139
138
|
if (subItems) {
|
|
140
|
-
applyCheckIndeterminateHelper(subItems, (0,
|
|
139
|
+
applyCheckIndeterminateHelper(subItems, (0, kendo_react_common_1.getNestedValue)(checkField, item) ? [] : [item], childrenField, checkField, checkIndeterminateField);
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
}
|
|
@@ -148,7 +147,7 @@ function applyCheckIndeterminateHelper(data, parents, childrenField, checkField,
|
|
|
148
147
|
var parentsAlreadyUpdated = false;
|
|
149
148
|
for (var i = 0; i < data.length; i++) {
|
|
150
149
|
var item = data[i];
|
|
151
|
-
if ((0,
|
|
150
|
+
if ((0, kendo_react_common_1.getNestedValue)(checkField, item)) {
|
|
152
151
|
if (!parentsAlreadyUpdated) {
|
|
153
152
|
for (var j = 0; j < parents.length; j++) {
|
|
154
153
|
raiseNestedFlag(checkIndeterminateField, parents[j]);
|