@progress/kendo-react-treeview 13.3.0-develop.9 → 13.4.0-develop.1

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.
@@ -0,0 +1,341 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { CSSProperties, ComponentType } from 'react';
9
+ import { ItemRenderProps } from './ItemRenderProps.js';
10
+ import { TreeViewContextMenuEvent } from './events.js';
11
+ import * as events from './events.js';
12
+ /**
13
+ * Represents the props of the [KendoReact TreeView component](https://www.telerik.com/kendo-react-ui/components/treeview).
14
+ */
15
+ export interface TreeViewProps {
16
+ /**
17
+ * Adds a custom CSS class to the TreeView container element.
18
+ *
19
+ * Example:
20
+ * ```jsx
21
+ * <TreeView className="custom-treeview-class" />
22
+ * ```
23
+ */
24
+ className?: string;
25
+ /**
26
+ * Specifies the `id` attribute of the TreeView container element.
27
+ *
28
+ * Example:
29
+ * ```jsx
30
+ * <TreeView id="treeview-component" />
31
+ * ```
32
+ */
33
+ id?: string;
34
+ /**
35
+ * Sets the inline styles for the TreeView container element.
36
+ *
37
+ * Example:
38
+ * ```jsx
39
+ * <TreeView style={{ width: '300px', height: '400px' }} />
40
+ * ```
41
+ */
42
+ style?: CSSProperties;
43
+ /**
44
+ * Provides the hierarchical data to be displayed in the TreeView.
45
+ *
46
+ * Example:
47
+ * ```jsx
48
+ * <TreeView data={[{ text: 'Item 1', items: [{ text: 'Sub-item 1' }] }]} />
49
+ * ```
50
+ */
51
+ data?: any[] | null;
52
+ /**
53
+ * Enables or disables the expand and collapse animations.
54
+ *
55
+ * @default true
56
+ *
57
+ * @example
58
+ * ```jsx
59
+ * <TreeView animate={false} />
60
+ * ```
61
+ */
62
+ animate?: boolean;
63
+ /**
64
+ * Specifies the `tabIndex` attribute of the TreeView container element.
65
+ *
66
+ * Example:
67
+ * ```jsx
68
+ * <TreeView tabIndex={0} />
69
+ * ```
70
+ */
71
+ tabIndex?: number;
72
+ /**
73
+ * The TreeView has a built-in implementation of focusing and keyboard navigation. By default, the component uses
74
+ * hierarchical indices to uniquely match the focused item. You can use the `focusIdField` prop for specifying the
75
+ * name of the field which will uniquely describe an
76
+ * item as an alternative to its hierarchical index ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/data-reload#toc-using-item-ids)).
77
+ *
78
+ * Example:
79
+ * ```jsx
80
+ * <TreeView focusIdField="id" />
81
+ * ```
82
+ */
83
+ focusIdField?: string;
84
+ /**
85
+ * When `focusIdField` is set, the TreeView executes a depth-first search on the data to find the currently focused item.
86
+ * The `getFocusHierarchicalIndex` prop specifies the function that will be used as an alternative to the default search algorithm.
87
+ *
88
+ * Example:
89
+ * ```jsx
90
+ * <TreeView getFocusHierarchicalIndex={(id) => `custom-index-${id}`} />
91
+ * ```
92
+ */
93
+ getFocusHierarchicalIndex?: (itemId: any) => string | undefined;
94
+ /**
95
+ * Controls the rendering of the expand (collapse) icons. By default, the icons are not rendered ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/expansion/update-expanded-items)).
96
+ *
97
+ * Example:
98
+ * ```jsx
99
+ * <TreeView expandIcons={true} />
100
+ * ```
101
+ */
102
+ expandIcons?: boolean;
103
+ /**
104
+ * Triggered when an item is expanded or collapsed.
105
+ *
106
+ * Example:
107
+ * ```jsx
108
+ * <TreeView onExpandChange={(event) => console.log(event.item)} />
109
+ * ```
110
+ */
111
+ onExpandChange?: (event: events.TreeViewExpandChangeEvent) => void;
112
+ /**
113
+ * Fires when an item is clicked or when `Enter` is pressed on a focused item ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/selection/update-selected-items)).
114
+ *
115
+ * Example:
116
+ * ```jsx
117
+ * <TreeView onItemClick={(event) => console.log(event.item)} />
118
+ * ```
119
+ */
120
+ onItemClick?: (event: events.TreeViewItemClickEvent) => void;
121
+ /**
122
+ * Specifies the name of the field which will provide a Boolean representation for the expanded state of the item.
123
+ *
124
+ * @default "expanded"
125
+ *
126
+ * @example
127
+ * ```jsx
128
+ * <TreeView expandField="isExpanded" />
129
+ * ```
130
+ */
131
+ expandField?: string;
132
+ /**
133
+ * Specifies the name of the field which will provide a Boolean representation for the selected state of the item.
134
+ *
135
+ * @default "selected"
136
+ *
137
+ * @example
138
+ * ```jsx
139
+ * <TreeView selectField="isSelected" />
140
+ * ```
141
+ */
142
+ selectField?: string;
143
+ /**
144
+ * Specifies the name of the field which will provide an icon for the specific TreeView item.
145
+ *
146
+ * @default "svgIcon"
147
+ *
148
+ * @example
149
+ * ```jsx
150
+ * <TreeView iconField="icon" />
151
+ * ```
152
+ */
153
+ iconField?: string;
154
+ /**
155
+ * 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](https://www.telerik.com/kendo-react-ui/components/treeview/data-binding#toc-loading-data-on-demand)).
156
+ *
157
+ * @default "hasChildren"
158
+ *
159
+ * @example
160
+ * ```jsx
161
+ * <TreeView hasChildrenField="hasSubItems" />
162
+ * ```
163
+ */
164
+ hasChildrenField?: string;
165
+ /**
166
+ * Specifies the name of the field which will provide an array representation of the item children.
167
+ *
168
+ * @default "items"
169
+ *
170
+ * @example
171
+ * ```jsx
172
+ * <TreeView childrenField="subItems" />
173
+ * ```
174
+ */
175
+ childrenField?: string;
176
+ /**
177
+ * Specifies the name of the field which will provide a text representation for the item.
178
+ *
179
+ * @default "text"
180
+ *
181
+ * @example
182
+ * ```jsx
183
+ * <TreeView textField="label" />
184
+ * ```
185
+ */
186
+ textField?: string;
187
+ /**
188
+ * Specifies the name of the field which will provide a Boolean representation for the disabled state of the item.
189
+ *
190
+ * @default "disabled"
191
+ *
192
+ * @example
193
+ * ```jsx
194
+ * <TreeView disableField="isDisabled" />
195
+ * ```
196
+ */
197
+ disableField?: string;
198
+ /**
199
+ * Defines the component that will be used for rendering each of the TreeView items ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/custom-rendering)).
200
+ *
201
+ * Example:
202
+ * ```jsx
203
+ * <TreeView item={(props) => <CustomTreeViewItem {...props} />} />
204
+ * ```
205
+ */
206
+ item?: ComponentType<ItemRenderProps>;
207
+ /**
208
+ * Indicates that the user can select more than one TreeView items.
209
+ * If the TreeView is in a multiple selection mode, set the `aria-multiselectable`
210
+ * prop to `true` ([more on accessibility by the TreeView](https://www.telerik.com/kendo-react-ui/components/treeview/accessibility/wai-aria-support)).
211
+ *
212
+ * Example:
213
+ * ```jsx
214
+ * <TreeView aria-multiselectable={true} />
215
+ * ```
216
+ */
217
+ 'aria-multiselectable'?: boolean | 'false' | 'true';
218
+ /**
219
+ * Defines a string value that labels the TreeView ([more on accessibility by the TreeView](https://www.telerik.com/kendo-react-ui/components/treeview/accessibility/wai-aria-support)).
220
+ *
221
+ * Example:
222
+ * ```jsx
223
+ * <TreeView aria-label="TreeView Label" />
224
+ * ```
225
+ */
226
+ 'aria-label'?: string;
227
+ /**
228
+ * Identifies the element or elements which will label the TreeView ([more on accessibility by the TreeView](https://www.telerik.com/kendo-react-ui/components/treeview/accessibility/wai-aria-support)).
229
+ *
230
+ * Example:
231
+ * ```jsx
232
+ * <TreeView aria-labelledby="treeview-label" />
233
+ * ```
234
+ */
235
+ 'aria-labelledby'?: string;
236
+ /**
237
+ * Controls the rendering of checkboxes. By default, the checkboxes are not rendered.
238
+ *
239
+ * Example:
240
+ * ```jsx
241
+ * <TreeView checkboxes={true} />
242
+ * ```
243
+ */
244
+ checkboxes?: boolean;
245
+ /**
246
+ * Specifies the name of the field which will provide a Boolean representation for the checked state of the item.
247
+ *
248
+ * @default "checked"
249
+ *
250
+ * @example
251
+ * ```jsx
252
+ * <TreeView checkField="isChecked" />
253
+ * ```
254
+ */
255
+ checkField?: string;
256
+ /**
257
+ * Specifies the name of the field which will provide a Boolean representation for the check indeterminate state of the item.
258
+ *
259
+ * @default "checkIndeterminate"
260
+ *
261
+ * @example
262
+ * ```jsx
263
+ * <TreeView checkIndeterminateField="isPartiallyChecked" />
264
+ * ```
265
+ */
266
+ checkIndeterminateField?: string;
267
+ /**
268
+ * Fires when a checkbox is clicked or when `Space` is pressed on a focused item.
269
+ *
270
+ * Example:
271
+ * ```jsx
272
+ * <TreeView onCheckChange={(event) => console.log(event.item)} />
273
+ * ```
274
+ */
275
+ onCheckChange?: (event: events.TreeViewCheckChangeEvent) => void;
276
+ /**
277
+ * Controls the dispatching of the `drag` events. By default, the `drag` events are not dispatched ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/drag-drop)).
278
+ */
279
+ draggable?: boolean;
280
+ /**
281
+ * Fires when the dragging of an item has started.
282
+ *
283
+ * Example:
284
+ * ```jsx
285
+ * <TreeView onItemDragStart={(event) => console.log(event.item)} />
286
+ * ```
287
+ */
288
+ onItemDragStart?: (event: events.TreeViewItemDragStartEvent) => void;
289
+ /**
290
+ * Fires when a dragged item changes its position ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/drag-drop)).
291
+ *
292
+ * Example:
293
+ * ```jsx
294
+ * <TreeView onItemDragOver={(event) => console.log(event.item)} />
295
+ * ```
296
+ */
297
+ onItemDragOver?: (event: events.TreeViewItemDragOverEvent) => void;
298
+ /**
299
+ * Fires when a dragged item is dropped ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/drag-drop)).
300
+ *
301
+ * Example:
302
+ * ```jsx
303
+ * <TreeView onItemDragEnd={(event) => console.log(event.item)} />
304
+ * ```
305
+ */
306
+ onItemDragEnd?: (event: events.TreeViewItemDragEndEvent) => void;
307
+ /**
308
+ * Configures the `size` of the TreeView.
309
+ *
310
+ * The available options are:
311
+ * - small
312
+ * - medium
313
+ * - large
314
+ *
315
+ * @default undefined (theme-controlled)
316
+ *
317
+ * @example
318
+ * ```jsx
319
+ * <TreeView size="large" />
320
+ * ```
321
+ */
322
+ size?: 'small' | 'medium' | 'large';
323
+ /**
324
+ * Sets the direction of the component.
325
+ *
326
+ * Example:
327
+ * ```jsx
328
+ * <TreeView dir="rtl" />
329
+ * ```
330
+ */
331
+ dir?: string;
332
+ /**
333
+ * The event that is fired when the ContextMenu is activated.
334
+ *
335
+ * Example:
336
+ * ```jsx
337
+ * <TreeView onContextMenu={(event) => console.log(event.item)} />
338
+ * ```
339
+ */
340
+ onContextMenu?: (event: TreeViewContextMenuEvent) => void;
341
+ }
@@ -12,4 +12,4 @@
12
12
  * Licensed under commercial license. See LICENSE.md in the package root for more information
13
13
  *-------------------------------------------------------------------------------------------
14
14
  */
15
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-animation")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@progress/kendo-react-common","@progress/kendo-svg-icons","@progress/kendo-react-animation"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactTreeview={},e.React,e.PropTypes,e.KendoReactCommon,e.KendoSvgIcons,e.KendoReactAnimation)}(this,(function(e,t,i,s,n,r){"use strict";function d(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var a=d(t);function o(e,t,i,n,r){switch(n){case s.Keys.left:return s.treeIdUtils.isIdZeroLevel(t)||r.expanded(e)&&s.isEnabledAndAllParentsEnabled(t,i,r)?t:s.treeIdUtils.getDirectParentId(t);case s.Keys.right:return s.isItemExpandedAndWithChildren(e,r)?s.treeIdUtils.getFirstChildId(t):t;case s.Keys.up:return function(){const e=Number(s.treeIdUtils.getShortId(t)),n=s.treeIdUtils.getDirectParentId(t);return e?c(s.treeIdUtils.createId(e-1,n),i,r):s.treeIdUtils.isIdZeroLevel(t)?t:n}();case s.Keys.down:return s.isItemExpandedAndWithChildren(e,r)?s.treeIdUtils.getFirstChildId(t):l(t,i,r)||t;case s.Keys.home:return s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID;case s.Keys.end:return function(){let e,t=(i.length-1).toString(),n=i[i.length-1];for(;s.isItemExpandedAndWithChildren(n,r);)e=n[r.getChildrenField()],t=s.treeIdUtils.createId(e.length-1,t),n=e[e.length-1];return t}();default:return t}}function l(e,t,i){const n=s.treeIdUtils.getDirectParentId(e),r=n?s.treeIdUtils.getItemById(n,t,i.getChildrenField()):void 0,d=r?r[i.getChildrenField()]:t,a=Number(s.treeIdUtils.getShortId(e));return a<d.length-1?s.treeIdUtils.createId(a+1,n):r?l(n,t,i):void 0}function c(e,t,i){const n=s.treeIdUtils.getItemById(e,t,i.getChildrenField());return s.isItemExpandedAndWithChildren(n,i)?c(s.treeIdUtils.createId(n[i.getChildrenField()].length-1,e),t,i):e}const h=(e,t)=>{const i=((e,t)=>e===t.length-1)(e,t);return 0!==e||i?i?"bot":"mid":"top"},p="expanded",m="items",u="selected",I="checked",g="checkIndeterminate",f="_kendoItemId",b="_kendoTreeViewGuid",{sizeMap:v}=s.kendoThemeMaps,C=a.createContext((e=>e)),x=class extends a.Component{constructor(){super(...arguments),this.onCheckChange=e=>{this.props.onCheckChange(e,this.item,this.itemId)},this.onExpandChange=e=>{this.props.onExpandChange(e,this.item,this.itemId)},this.onItemClick=e=>{this.props.onItemClick(e,this.item,this.itemId)},this.onPress=e=>{this.props.onPress(e.event,this.item,this.itemId)},this.onDrag=e=>{this.props.onDrag(e.event,this.item,this.itemId)},this.onRelease=e=>{this.props.onRelease(e.event,this.item,this.itemId)},this.onContextMenu=e=>{this.props.onContextMenu(e,this.item,this.itemId)},this.assignDraggableMeta=e=>{e&&(e[f]=this.props.itemId,e[b]=this.props.treeGuid)}}render(){const e=this.renderItemInPart();return a.createElement("li",{className:s.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||void 0,ref:e=>{this.itemElement=e}},a.createElement("span",{className:`k-treeview-${this.props.position}`,ref:this.assignDraggableMeta},this.renderExpandIcon(),this.renderCheckbox(),this.props.draggable?a.createElement(s.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease},e):e),this.renderSubitemsWithAnimation())}componentDidMount(){const e=this.props.focusedItemId,t=this.itemId;e&&e===t&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement&&(this.checkboxElement.indeterminate=this.fieldsSvc.checkIndeterminate(this.item))}componentDidUpdate(e){const t=this.props.focusedItemId;if(t&&t!==e.focusedItemId&&t===this.itemId&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement){const e=this.fieldsSvc.checkIndeterminate(this.item);this.checkboxElement.indeterminate!==e&&(this.checkboxElement.indeterminate=e)}}renderCheckbox(){if(this.props.checkboxes){const e=this.props.size;return a.createElement("span",{className:s.classNames("k-checkbox-wrap")},a.createElement("input",{type:"checkbox",className:s.classNames("k-checkbox k-rounded-md",{[`k-checkbox-${v[e]||e}`]:e,"k-disabled":this.disabled}),"aria-label":this.item.text,checked:!!this.fieldsSvc.checked(this.item),id:this.props.id,tabIndex:-1,onChange:this.onCheckChange,ref:e=>{this.checkboxElement=e}}))}}renderExpandIcon(){return this.props.expandIcons&&(this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField()))&&a.createElement("span",{className:s.classNames("k-treeview-toggle",{"k-disabled":this.disabled}),onClick:this.onExpandChange},a.createElement(s.IconWrap,{...this.getIconProps()}))}renderSubitemsIfApplicable(){const e=this.fieldsSvc.children(this.item);return s.isItemExpandedAndWithChildren(this.item,this.fieldsSvc)?a.createElement("ul",{className:"k-treeview-group",role:"group"},e.map(((t,i)=>a.createElement(E,{item:t,position:h(i,e),itemId:s.treeIdUtils.createId(i,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,iconField:this.props.iconField,onExpandChange:this.props.onExpandChange,onCheckChange:this.props.onCheckChange,onContextMenu:this.props.onContextMenu,key:i,size:this.props.size,disabled:this.disabled,isRtl:this.props.isRtl})))):void 0}renderSubitemsWithAnimation(){const e=this.renderSubitemsIfApplicable(),t=this.fieldsSvc.children(this.item).length>0;return this.props.animate&&t?a.createElement(r.Reveal,{transitionEnterDuration:200,transitionExitDuration:200,style:{display:"block"}},e):e}renderItemInPart(){const e=this.props.iconField,t=e&&this.item[e];return a.createElement("span",{className:s.classNames("k-treeview-leaf",{"k-focus":this.props.focusedItemId===this.itemId,"k-selected":this.fieldsSvc.selected(this.item),"k-disabled":this.disabled,"k-touch-action-none":this.props.draggable}),onClick:this.onItemClick,onContextMenu:this.onContextMenu},t&&a.createElement(s.IconWrap,{name:t.name,icon:t}),a.createElement("span",{className:"k-treeview-leaf-text"},this.props.itemUI?a.createElement(this.props.itemUI,{item:this.item,itemHierarchicalIndex:this.itemId}):this.fieldsSvc.text(this.item)))}get fieldsSvc(){return this.props.fieldsService}get itemId(){return this.props.itemId}get item(){return this.props.item}get tabIndex(){return(this.props.focusedItemId||this.props.tabbableItemId)===this.itemId?0:-1}get ariaExpanded(){return this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?!!this.fieldsSvc.expanded(this.item):void 0}get disabled(){return this.props.disabled||this.fieldsSvc.disabled(this.item)}get ariaChecked(){if(this.props.checkboxes)return this.fieldsSvc.checked(this.item)?"true":this.fieldsSvc.checkIndeterminate(this.item)?"mixed":"false"}get ariaSelected(){return!!this.fieldsSvc.selected(this.item)||(this.props.ariaMultiSelectable?!!this.disabled&&void 0:void 0)}getIconProps(){const e=this.fieldsSvc.expanded(this.item);return e&&!s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?{name:"loading"}:e?{name:"caret-alt-down",icon:n.caretAltDownIcon}:{name:this.props.isRtl?"caret-alt-left":"caret-alt-right",icon:this.props.isRtl?n.caretAltLeftIcon:n.caretAltRightIcon}}};x.defaultProps={position:"top",iconField:"svgIcon"};let k=x;const E=s.withIdHOC(a.forwardRef(((e,t)=>{const i=a.useContext(C).call(void 0,e);return a.createElement(k,{ref:t,...i})})));E.displayName="TreeViewItem";const F=Object.freeze({name:"@progress/kendo-react-treeview",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"13.3.0-develop.9",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"}),{sizeMap:y}=s.kendoThemeMaps,D=class extends a.Component{constructor(e){super(e),this.state={focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID},this.fieldsSvc=null,this.allowExplicitFocus=!1,this.showLicenseWatermark=!1,this._element=null,this.onFocusDomElNeeded=e=>{this.allowExplicitFocus&&this.focusDomItem(e)},this.onCheckChange=(e,t,i)=>{this.setFocus(i),this.dispatchCheckChange(e,t,i)},this.onExpandChange=(e,t,i)=>{this.setFocus(i),this.dispatchExpandChange(e,t,i)},this.onPress=(e,t,i)=>{this.props.onItemDragStart&&this.props.onItemDragStart.call(void 0,{target:this,item:t,itemHierarchicalIndex:i})},this.onDrag=(e,t,i)=>{const{pageX:s,pageY:n,clientX:r,clientY:d}=e;this.props.onItemDragOver&&this.props.onItemDragOver.call(void 0,{target:this,item:t,itemHierarchicalIndex:i,pageX:s,pageY:n,clientX:r,clientY:d})},this.onRelease=(e,t,i)=>{const{pageX:s,pageY:n,clientX:r,clientY:d}=e;this.props.onItemDragEnd&&this.props.onItemDragEnd.call(void 0,{target:this,item:t,itemHierarchicalIndex:i,pageX:s,pageY:n,clientX:r,clientY:d})},this.onItemClick=(e,t,i)=>{this.setFocus(i),this.dispatchItemClick(e,t,i)},this.onFocus=()=>{clearTimeout(this.blurRequest),void 0===this.state.focusedItemId&&this.data.length&&this.setFocus(this.state.tabbableItemId)},this.onBlur=()=>{clearTimeout(this.blurRequest),this.blurRequest=window.setTimeout((()=>this.setFocus(void 0)),0)},this.onKeyDown=e=>{const t=this.getFocusedItem();if(t&&this.fieldsSvc){const i=o(t,this.state.focusedItemId,this.data,e.keyCode,this.fieldsSvc);i!==this.state.focusedItemId&&(e.preventDefault(),this.allowExplicitFocus=!0,this.setFocus(i)),this.dispatchEventsOnKeyDown(e,t)}},this.onContextMenu=(e,t,i)=>{if(this.props.onContextMenu){const s={target:this,syntheticEvent:e,nativeEvent:e.nativeEvent,item:t,itemID:i};this.props.onContextMenu.call(void 0,s)}},this.showLicenseWatermark=!s.validatePackage(F,{component:"TreeView"}),this.licenseMessage=s.getLicenseMessage(F)}get treeGuid(){return this.props.id+"-accessibility-id"}get element(){return this._element}render(){this.fieldsSvc=new s.TreeFieldsService(this.props);const{size:e,className:t}=this.props;return a.createElement("div",{id:this.props.id,style:{position:"relative",...this.props.style},className:s.classNames("k-treeview",{[`k-treeview-${y[e]||e}`]:e,"k-user-select-none":this.props.draggable,"k-rtl":"rtl"===this.props.dir},t),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,role:"tree","aria-multiselectable":!!this.ariaMultiSelectable||void 0,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],ref:e=>{this._element=e},tabIndex:this.props.tabIndex},a.createElement("ul",{className:"k-treeview-lines k-treeview-group",role:"group"},this.data.map(((t,i)=>a.createElement(E,{id:this.props.id+"-item-"+i,item:t,position:h(i,this.data),itemId:i.toString(),treeGuid:this.treeGuid,animate:this.props.animate,focusedItemId:this.state.focusedItemId,tabbableItemId:this.state.tabbableItemId,fieldsService:this.fieldsSvc,itemUI:this.props.item,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.ariaMultiSelectable,onItemClick:this.onItemClick,onFocusDomElNeeded:this.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,expandIcons:this.props.expandIcons,iconField:this.props.iconField,onExpandChange:this.onExpandChange,onCheckChange:this.onCheckChange,onContextMenu:this.onContextMenu,key:i,size:e,isRtl:"rtl"===this.props.dir})))),this.showLicenseWatermark&&a.createElement(s.WatermarkOverlay,{message:this.licenseMessage}))}componentDidUpdate(){this.allowExplicitFocus=!1,this.refocusDueToFocusIdField()}dispatchEventsOnKeyDown(e,t){if(null===this.fieldsSvc)return;const i=()=>this.fieldsSvc&&s.isEnabledAndAllParentsEnabled(this.state.focusedItemId,this.data,this.fieldsSvc);e.keyCode===s.Keys.left&&this.fieldsSvc.expanded(t)&&i()||e.keyCode===s.Keys.right&&!this.fieldsSvc.expanded(t)&&(this.fieldsSvc.hasChildren(t)||s.hasChildren(t,this.props.childrenField))&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.enter&&i()?this.dispatchItemClick(e,t,this.state.focusedItemId):e.keyCode===s.Keys.space&&i()&&(e.preventDefault(),this.dispatchCheckChange(e,t,this.state.focusedItemId))}setFocus(e){if(e&&this.fieldsSvc)if(this.fieldsSvc.focusIdField){const t=this.getItemById(e);this.setState({focusedItemId:e,focusedItemPublicId:this.fieldsSvc.focusId(t)})}else this.setState({focusedItemId:e});else this.setState((e=>({focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:e.focusedItemId})))}getFocusedItem(){return this.state.focusedItemId?this.getItemById(this.state.focusedItemId):void 0}getItemById(e){return s.treeIdUtils.getItemById(e,this.data,this.props.childrenField||m)}dispatchCheckChange(e,t,i){s.dispatchEvent(this.props.onCheckChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchExpandChange(e,t,i){s.dispatchEvent(this.props.onExpandChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchItemClick(e,t,i){s.dispatchEvent(this.props.onItemClick,e,this,{item:t,itemHierarchicalIndex:i})}refocusDueToFocusIdField(){if(this.fieldsSvc&&this.fieldsSvc.focusIdField){const e=this.state.focusedItemPublicId;if(e){const t=this.props.getFocusHierarchicalIndex?this.props.getFocusHierarchicalIndex(e):s.resolveItemId(e,this.fieldsSvc.focusIdField,this.data,this.props.childrenField);t!==this.state.focusedItemId&&(this.allowExplicitFocus=!0,this.setState({focusedItemId:t}))}}}get ariaMultiSelectable(){return!0===this.props["aria-multiselectable"]||"true"===this.props["aria-multiselectable"]}get data(){return this.props.data||[]}focusDomItem(e){e.focus()}get guid(){return this.treeGuid}};D.propTypes={data:i.arrayOf(i.any),animate:i.bool,tabIndex:i.number,focusIdField:i.string,getHierarchicalIndexById:i.func,onExpandChange:i.func,onItemClick:i.func,expandField:i.string,selectField:i.string,iconField:i.string,childrenField:i.string,hasChildrenField:i.string,textField:i.string,disableField:i.string,item:i.any,"aria-multiselectable":(e,t,i)=>void 0!==e[t]&&!0!==e[t]&&!1!==e[t]&&"true"!==e[t]&&"false"!==e[t]?new Error("Invalid prop `"+t+"` supplied to `"+i+"`. Validation failed."):null,"aria-label":i.string,"aria-labelledby":i.string,size:i.oneOf([null,"small","medium","large"]),dir:i.string},D.defaultProps={animate:!0,expandField:p,selectField:u,iconField:"svgIcon",hasChildrenField:"hasChildren",childrenField:m,textField:"text",disableField:"disabled",checkField:I,checkIndeterminateField:g,size:"medium"};let S=D;function w(e,t,i,n,r){if(i){const{ids:d,field:a}=N(i,t);return function(e,t,i,n,r){let d=e;return t.forEach((e=>{d=s.updateItem(d,e,(e=>P(i,e)),n,r)})),d}(e,!s.isArray(i)&&i.idField?s.resolveItemsIds(d,i.idField,e,r):d,a,n,r)}return e}function N(e,t){let i,n;return s.isArray(e)?(i=e,n=t):(i=e.ids||[],n=e.operationField||t),{ids:i,field:n}}function P(e,t){const i=(e||"").split(".");let s=t;for(let e=0;e<i.length;e++){const t=i[e];if(e===i.length-1)s[t]=!0;else{if(void 0===s[t])return;s[t]={...s[t]},s=s[t]}}}function U(e,t,i,n,r){let d=!1;for(let a=0;a<e.length;a++){const o=e[a];if(s.getNestedValue(n,o)){if(!d)for(let e=0;e<t.length;e++)P(r,t[e]);d=!0,o[i]&&U(o[i],[],i,n,r)}else o[i]&&U(o[i],d?[o]:t.concat([o]),i,n,r)}}const M=class extends a.PureComponent{constructor(){super(...arguments),this.state={visible:!1,top:0,left:0,text:"",operationClassName:"cancel"}}render(){const e={top:this.state.top+"px",left:this.state.left+"px"};return this.state.visible&&a.createElement("div",{className:"k-header k-drag-clue",style:{...this.props.style,...e}},a.createElement(s.IconWrap,{className:s.classNames("k-drag-status"),name:this.state.operationClassName&&s.toIconName(this.state.operationClassName),icon:"k-i-plus"===this.state.operationClassName?n.plusIcon:"k-i-insert-up"===this.state.operationClassName?n.insertTopIcon:"k-i-insert-down"===this.state.operationClassName?n.insertBottomIcon:"k-i-insert-middle"===this.state.operationClassName?n.insertMiddleIcon:n.cancelIcon}),this.state.text)}show(e,t,i,s){this.setState({visible:!0,top:e,left:t,text:i,operationClassName:s})}hide(){this.setState({visible:!1})}};M.defaultProps={style:{display:"block",position:"absolute",zIndex:2e4,padding:"4px 6px"}};let R=M;const O=s.withIdHOC(S);O.displayName="KendoReactTreeView",Object.defineProperty(e,"FieldsService",{enumerable:!0,get:function(){return s.TreeFieldsService}}),e.TreeView=O,e.TreeViewClassComponent=S,e.TreeViewDragAnalyzer=class{constructor(e){this.event=e,this.initialized=!1,this.destItemId="",this.destTreeViewGuid="",this.itemId=e.itemHierarchicalIndex,this.treeViewGuid=e.target.guid}init(){return this.initialized||(this.setDestimationMeta(document.elementFromPoint(this.event.clientX,this.event.clientY)),this.initialized=!0),this}get isDropAllowed(){return!!(this.initialized&&this.destItemId&&this.destTreeViewGuid)&&!`${this.destTreeViewGuid}_${this.destItemId}_`.startsWith(`${this.treeViewGuid}_${this.itemId}_`)}get destinationMeta(){return{itemHierarchicalIndex:this.destItemId,treeViewGuid:this.destTreeViewGuid}}getDropOperation(){if(this.initialized&&this.isDropAllowed){const{top:e,height:t}=this.destDomNodeWithMeta.getBoundingClientRect();return e+t-this.event.clientY<6?"after":this.event.clientY-e<6?"before":"child"}}setDestimationMeta(e){let t=e;for(;t&&!t[f];)t=t.parentNode;t&&t[f]&&(this.destDomNodeWithMeta=t,this.destItemId=t[f],this.destTreeViewGuid=t[b])}},e.TreeViewDragClue=R,e.TreeViewItemPropsContext=C,e.getItemIdUponKeyboardNavigation=o,e.handleTreeViewCheckChange=function(e,t,i,n={},r){if(!i||!i.length)return[];const{ids:d,idField:a}=function(e){let t,i;return s.isArray(e)?t=e:(t=e.ids||[],i=e.idField),{ids:t,idField:i}}(t),o=a?s.getNestedValue(a,e.item):e.itemHierarchicalIndex,l=d.indexOf(o),c=-1===l,h=r||m;let p;return n.singleMode?p=c?[o]:[]:(p=d.slice(),c?p.push(o):p.splice(l,1),n.checkChildren&&function(e,t,i,n,r,d){s.getAllDirectIndirectChildrenIds(e,t,r,n).forEach((e=>{i&&-1===d.indexOf(e)?d.push(e):!i&&d.indexOf(e)>-1&&d.splice(d.indexOf(e),1)}))}(e.item,e.itemHierarchicalIndex,c,a,h,p),n.checkParents&&function(e,t,i,n,r,d){const a=h();let o=a.next();function l(){for(;!o.done;){const{id:e,item:t}=o.value;if(-1!==r.indexOf(e)||!s.areAllDirectChildrenChecked(t,e,i,n,r))break;r.push(e),o=a.next()}}function c(){for(;!o.done;){const{id:e}=o.value,t=r.indexOf(e);if(!(t>-1))break;r.splice(t,1),o=a.next()}}function*h(){if(i){const r=s.getAllParents(e,n,d);for(let e=r.length-1;e>-1;e--)yield{id:s.getNestedValue(i,r[e]),item:t?r[e]:void 0}}else{let i=s.treeIdUtils.getDirectParentId(e);for(;i;)yield{id:i,item:t?s.treeIdUtils.getItemById(i,d,n):void 0},i=s.treeIdUtils.getDirectParentId(i)}}t?l():c()}(e.itemHierarchicalIndex,c,a,h,p,i)),s.isArray(t)?p:Object.assign({},t,{ids:p})},e.moveTreeViewItem=function(e,t,i,n,r,d){const a=d||m;if(!function(){if(!t||!t.length||!e||!n||r&&!r.length)return!1;const i=r&&r!==t?r:t;return!!s.treeIdUtils.getItemById(n,i,a)}())return l();const o=s.treeIdUtils.getItemById(e,t,a);if(!o)return l();if(!r||r===t){if(`${n}_`.startsWith(`${e}_`))return l();const d=s.removeItem(e,a,t),c=s.addItem(o,i,a,s.treeIdUtils.getDecrementedItemIdAfterRemoval(e,n),d);return r?{sourceData:c,targetData:c}:c}return{sourceData:s.removeItem(e,a,t),targetData:s.addItem(o,i,a,n,r)};function l(){return r?{sourceData:t,targetData:r}:t}},e.processTreeViewItems=function(e,t){if(!e||!e.length)return[];let i=e;const n=t.cloneField||"cloned",r=t.expandField||p,d=t.selectField||u,a=t.checkField||I,o=t.childrenField||m;return i=w(i,r,t.expand,n,o),i=w(i,d,t.select,n,o),i=w(i,a,t.check,n,o),function(e,t,i){if(i&&!s.isArray(i)&&i.applyCheckIndeterminate){const{field:n}=N(i,I),r=i.checkIndeterminateField||g;for(let i=0;i<e.length;i++){const d=e[i],a=d[t];a&&U(a,s.getNestedValue(n,d)?[]:[d],t,n,r)}}}(i,o,t.check),i}}));
15
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-animation")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@progress/kendo-react-common","@progress/kendo-svg-icons","@progress/kendo-react-animation"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactTreeview={},e.React,e.PropTypes,e.KendoReactCommon,e.KendoSvgIcons,e.KendoReactAnimation)}(this,function(e,t,i,s,n,r){"use strict";function d(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var o=d(t);function a(e,t,i,n,r){switch(n){case s.Keys.left:return s.treeIdUtils.isIdZeroLevel(t)||r.expanded(e)&&s.isEnabledAndAllParentsEnabled(t,i,r)?t:s.treeIdUtils.getDirectParentId(t);case s.Keys.right:return s.isItemExpandedAndWithChildren(e,r)?s.treeIdUtils.getFirstChildId(t):t;case s.Keys.up:return function(){const e=Number(s.treeIdUtils.getShortId(t)),n=s.treeIdUtils.getDirectParentId(t);return e?c(s.treeIdUtils.createId(e-1,n),i,r):s.treeIdUtils.isIdZeroLevel(t)?t:n}();case s.Keys.down:return s.isItemExpandedAndWithChildren(e,r)?s.treeIdUtils.getFirstChildId(t):l(t,i,r)||t;case s.Keys.home:return s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID;case s.Keys.end:return function(){let e,t=(i.length-1).toString(),n=i[i.length-1];for(;s.isItemExpandedAndWithChildren(n,r);)e=n[r.getChildrenField()],t=s.treeIdUtils.createId(e.length-1,t),n=e[e.length-1];return t}();default:return t}}function l(e,t,i){const n=s.treeIdUtils.getDirectParentId(e),r=n?s.treeIdUtils.getItemById(n,t,i.getChildrenField()):void 0,d=r?r[i.getChildrenField()]:t,o=Number(s.treeIdUtils.getShortId(e));return o<d.length-1?s.treeIdUtils.createId(o+1,n):r?l(n,t,i):void 0}function c(e,t,i){const n=s.treeIdUtils.getItemById(e,t,i.getChildrenField());return s.isItemExpandedAndWithChildren(n,i)?c(s.treeIdUtils.createId(n[i.getChildrenField()].length-1,e),t,i):e}const h=(e,t)=>{const i=((e,t)=>e===t.length-1)(e,t);return 0!==e||i?i?"bot":"mid":"top"},p="expanded",m="items",u="selected",I="checked",g="checkIndeterminate",f="_kendoItemId",b="_kendoTreeViewGuid",{sizeMap:v}=s.kendoThemeMaps,C=o.createContext(e=>e),k=class extends o.Component{constructor(){super(...arguments),this.onCheckChange=e=>{this.props.onCheckChange(e,this.item,this.itemId)},this.onExpandChange=e=>{this.props.onExpandChange(e,this.item,this.itemId)},this.onItemClick=e=>{this.props.onItemClick(e,this.item,this.itemId)},this.onPress=e=>{this.props.onPress(e.event,this.item,this.itemId)},this.onDrag=e=>{this.props.onDrag(e.event,this.item,this.itemId)},this.onRelease=e=>{this.props.onRelease(e.event,this.item,this.itemId)},this.onContextMenu=e=>{this.props.onContextMenu(e,this.item,this.itemId)},this.assignDraggableMeta=e=>{e&&(e[f]=this.props.itemId,e[b]=this.props.treeGuid)}}render(){const e=this.renderItemInPart(),t=this.props.itemId.split("_").length;return o.createElement("li",{className:s.classNames("k-treeview-item"),style:{"--kendo-treeview-level":t},tabIndex:this.tabIndex,role:"treeitem","aria-expanded":this.ariaExpanded,"aria-selected":this.ariaSelected,"aria-checked":this.ariaChecked,"aria-disabled":!!this.disabled||void 0,ref:e=>{this.itemElement=e}},o.createElement("span",{className:s.classNames("k-treeview-item-content",{"k-focus":this.props.focusedItemId===this.itemId,"k-selected":this.fieldsSvc.selected(this.item),"k-disabled":this.disabled,"k-touch-action-none":this.props.draggable}),ref:this.assignDraggableMeta},this.renderExpandIcon(),this.renderCheckbox(),this.props.draggable?o.createElement(s.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease},e):e),this.renderSubitemsWithAnimation())}componentDidMount(){const e=this.props.focusedItemId,t=this.itemId;e&&e===t&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement&&(this.checkboxElement.indeterminate=this.fieldsSvc.checkIndeterminate(this.item))}componentDidUpdate(e){const t=this.props.focusedItemId;if(t&&t!==e.focusedItemId&&t===this.itemId&&this.props.onFocusDomElNeeded(this.itemElement),this.checkboxElement){const e=this.fieldsSvc.checkIndeterminate(this.item);this.checkboxElement.indeterminate!==e&&(this.checkboxElement.indeterminate=e)}}renderCheckbox(){if(this.props.checkboxes){const e=this.props.size,t=!!this.fieldsSvc.checked(this.item);return o.createElement("span",{className:s.classNames("k-checkbox-wrap")},o.createElement("input",{type:"checkbox",className:s.classNames("k-checkbox",{[`k-checkbox-${v[e]||e}`]:e,"k-disabled":this.disabled,"k-checked":t}),"aria-label":this.item.text,checked:t,id:this.props.id,tabIndex:-1,onChange:this.onCheckChange,ref:e=>{this.checkboxElement=e}}))}}renderExpandIcon(){return this.props.expandIcons&&(this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField()))&&o.createElement("span",{className:s.classNames("k-treeview-toggle",{"k-disabled":this.disabled}),onClick:this.onExpandChange},o.createElement(s.IconWrap,{...this.getIconProps()}))}renderSubitemsIfApplicable(){const e=this.fieldsSvc.children(this.item);return s.isItemExpandedAndWithChildren(this.item,this.fieldsSvc)?o.createElement("ul",{className:"k-treeview-group",role:"group"},e.map((t,i)=>o.createElement(E,{item:t,position:h(i,e),itemId:s.treeIdUtils.createId(i,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,iconField:this.props.iconField,onExpandChange:this.props.onExpandChange,onCheckChange:this.props.onCheckChange,onContextMenu:this.props.onContextMenu,key:i,size:this.props.size,disabled:this.disabled,isRtl:this.props.isRtl}))):void 0}renderSubitemsWithAnimation(){const e=this.renderSubitemsIfApplicable(),t=this.fieldsSvc.children(this.item).length>0;return this.props.animate&&t?o.createElement(r.Reveal,{transitionEnterDuration:200,transitionExitDuration:200,style:{display:"block"}},e):e}renderItemInPart(){const e=this.props.iconField,t=e&&this.item[e];return o.createElement("span",{className:s.classNames("k-treeview-leaf"),onClick:this.onItemClick,onContextMenu:this.onContextMenu},t&&o.createElement(s.IconWrap,{name:t.name,icon:t}),o.createElement("span",{className:"k-treeview-leaf-text"},this.props.itemUI?o.createElement(this.props.itemUI,{item:this.item,itemHierarchicalIndex:this.itemId}):this.fieldsSvc.text(this.item)))}get fieldsSvc(){return this.props.fieldsService}get itemId(){return this.props.itemId}get item(){return this.props.item}get tabIndex(){return(this.props.focusedItemId||this.props.tabbableItemId)===this.itemId?0:-1}get ariaExpanded(){return this.fieldsSvc.hasChildren(this.item)||s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?!!this.fieldsSvc.expanded(this.item):void 0}get disabled(){return this.props.disabled||this.fieldsSvc.disabled(this.item)}get ariaChecked(){if(this.props.checkboxes)return this.fieldsSvc.checked(this.item)?"true":this.fieldsSvc.checkIndeterminate(this.item)?"mixed":"false"}get ariaSelected(){return!!this.fieldsSvc.selected(this.item)||(this.props.ariaMultiSelectable?!!this.disabled&&void 0:void 0)}getIconProps(){const e=this.fieldsSvc.expanded(this.item);return e&&!s.hasChildren(this.item,this.fieldsSvc.getChildrenField())?{name:"loading"}:e?{name:"chevron-down",icon:n.chevronDownIcon}:{name:this.props.isRtl?"chevron-left":"chevron-right",icon:this.props.isRtl?n.chevronLeftIcon:n.chevronRightIcon}}};k.defaultProps={position:"top",iconField:"svgIcon"};let x=k;const E=s.withIdHOC(o.forwardRef((e,t)=>{const i=o.useContext(C).call(void 0,e);return o.createElement(x,{ref:t,...i})}));E.displayName="TreeViewItem";const F=Object.freeze({name:"@progress/kendo-react-treeview",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"13.4.0-develop.1",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"}),{sizeMap:y}=s.kendoThemeMaps,D=class extends o.Component{constructor(e){super(e),this.state={focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:s.treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID},this.fieldsSvc=null,this.allowExplicitFocus=!1,this.showLicenseWatermark=!1,this._element=null,this.onFocusDomElNeeded=e=>{this.allowExplicitFocus&&this.focusDomItem(e)},this.onCheckChange=(e,t,i)=>{this.setFocus(i),this.dispatchCheckChange(e,t,i)},this.onExpandChange=(e,t,i)=>{this.setFocus(i),this.dispatchExpandChange(e,t,i)},this.onPress=(e,t,i)=>{this.props.onItemDragStart&&this.props.onItemDragStart.call(void 0,{target:this,item:t,itemHierarchicalIndex:i})},this.onDrag=(e,t,i)=>{const{pageX:s,pageY:n,clientX:r,clientY:d}=e;this.props.onItemDragOver&&this.props.onItemDragOver.call(void 0,{target:this,item:t,itemHierarchicalIndex:i,pageX:s,pageY:n,clientX:r,clientY:d})},this.onRelease=(e,t,i)=>{const{pageX:s,pageY:n,clientX:r,clientY:d}=e;this.props.onItemDragEnd&&this.props.onItemDragEnd.call(void 0,{target:this,item:t,itemHierarchicalIndex:i,pageX:s,pageY:n,clientX:r,clientY:d})},this.onItemClick=(e,t,i)=>{this.setFocus(i),this.dispatchItemClick(e,t,i)},this.onFocus=()=>{clearTimeout(this.blurRequest),void 0===this.state.focusedItemId&&this.data.length&&this.setFocus(this.state.tabbableItemId)},this.onBlur=()=>{clearTimeout(this.blurRequest),this.blurRequest=window.setTimeout(()=>this.setFocus(void 0),0)},this.onKeyDown=e=>{const t=this.getFocusedItem();if(t&&this.fieldsSvc){const i=a(t,this.state.focusedItemId,this.data,e.keyCode,this.fieldsSvc);i!==this.state.focusedItemId&&(e.preventDefault(),this.allowExplicitFocus=!0,this.setFocus(i)),this.dispatchEventsOnKeyDown(e,t)}},this.onContextMenu=(e,t,i)=>{if(this.props.onContextMenu){const s={target:this,syntheticEvent:e,nativeEvent:e.nativeEvent,item:t,itemID:i};this.props.onContextMenu.call(void 0,s)}},this.showLicenseWatermark=!s.validatePackage(F,{component:"TreeView"}),this.licenseMessage=s.getLicenseMessage(F)}get treeGuid(){return this.props.id+"-accessibility-id"}get element(){return this._element}render(){this.fieldsSvc=new s.TreeFieldsService(this.props);const{size:e,className:t}=this.props;return o.createElement("div",{id:this.props.id,style:{position:"relative",...this.props.style},className:s.classNames("k-treeview",{[`k-treeview-${y[e]||e}`]:e,"k-user-select-none":this.props.draggable,"k-rtl":"rtl"===this.props.dir},t),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,role:"tree","aria-multiselectable":!!this.ariaMultiSelectable||void 0,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],ref:e=>{this._element=e},tabIndex:this.props.tabIndex},o.createElement("ul",{className:"k-treeview-lines k-treeview-group",role:"group"},this.data.map((t,i)=>o.createElement(E,{id:this.props.id+"-item-"+i,item:t,position:h(i,this.data),itemId:i.toString(),treeGuid:this.treeGuid,animate:this.props.animate,focusedItemId:this.state.focusedItemId,tabbableItemId:this.state.tabbableItemId,fieldsService:this.fieldsSvc,itemUI:this.props.item,checkboxes:this.props.checkboxes,ariaMultiSelectable:this.ariaMultiSelectable,onItemClick:this.onItemClick,onFocusDomElNeeded:this.onFocusDomElNeeded,draggable:this.props.draggable,onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,expandIcons:this.props.expandIcons,iconField:this.props.iconField,onExpandChange:this.onExpandChange,onCheckChange:this.onCheckChange,onContextMenu:this.onContextMenu,key:i,size:e,isRtl:"rtl"===this.props.dir}))),this.showLicenseWatermark&&o.createElement(s.WatermarkOverlay,{message:this.licenseMessage}))}componentDidUpdate(){this.allowExplicitFocus=!1,this.refocusDueToFocusIdField()}dispatchEventsOnKeyDown(e,t){if(null===this.fieldsSvc)return;const i=()=>this.fieldsSvc&&s.isEnabledAndAllParentsEnabled(this.state.focusedItemId,this.data,this.fieldsSvc);e.keyCode===s.Keys.left&&this.fieldsSvc.expanded(t)&&i()||e.keyCode===s.Keys.right&&!this.fieldsSvc.expanded(t)&&(this.fieldsSvc.hasChildren(t)||s.hasChildren(t,this.props.childrenField))&&i()?this.dispatchExpandChange(e,t,this.state.focusedItemId):e.keyCode===s.Keys.enter&&i()?this.dispatchItemClick(e,t,this.state.focusedItemId):e.keyCode===s.Keys.space&&i()&&(e.preventDefault(),this.dispatchCheckChange(e,t,this.state.focusedItemId))}setFocus(e){if(e&&this.fieldsSvc)if(this.fieldsSvc.focusIdField){const t=this.getItemById(e);this.setState({focusedItemId:e,focusedItemPublicId:this.fieldsSvc.focusId(t)})}else this.setState({focusedItemId:e});else this.setState(e=>({focusedItemId:void 0,focusedItemPublicId:void 0,tabbableItemId:e.focusedItemId}))}getFocusedItem(){return this.state.focusedItemId?this.getItemById(this.state.focusedItemId):void 0}getItemById(e){return s.treeIdUtils.getItemById(e,this.data,this.props.childrenField||m)}dispatchCheckChange(e,t,i){s.dispatchEvent(this.props.onCheckChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchExpandChange(e,t,i){s.dispatchEvent(this.props.onExpandChange,e,this,{item:t,itemHierarchicalIndex:i})}dispatchItemClick(e,t,i){s.dispatchEvent(this.props.onItemClick,e,this,{item:t,itemHierarchicalIndex:i})}refocusDueToFocusIdField(){if(this.fieldsSvc&&this.fieldsSvc.focusIdField){const e=this.state.focusedItemPublicId;if(e){const t=this.props.getFocusHierarchicalIndex?this.props.getFocusHierarchicalIndex(e):s.resolveItemId(e,this.fieldsSvc.focusIdField,this.data,this.props.childrenField);t!==this.state.focusedItemId&&(this.allowExplicitFocus=!0,this.setState({focusedItemId:t}))}}}get ariaMultiSelectable(){return!0===this.props["aria-multiselectable"]||"true"===this.props["aria-multiselectable"]}get data(){return this.props.data||[]}focusDomItem(e){e.focus()}get guid(){return this.treeGuid}};D.propTypes={data:i.arrayOf(i.any),animate:i.bool,tabIndex:i.number,focusIdField:i.string,getHierarchicalIndexById:i.func,onExpandChange:i.func,onItemClick:i.func,expandField:i.string,selectField:i.string,iconField:i.string,childrenField:i.string,hasChildrenField:i.string,textField:i.string,disableField:i.string,item:i.any,"aria-multiselectable":(e,t,i)=>void 0!==e[t]&&!0!==e[t]&&!1!==e[t]&&"true"!==e[t]&&"false"!==e[t]?new Error("Invalid prop `"+t+"` supplied to `"+i+"`. Validation failed."):null,"aria-label":i.string,"aria-labelledby":i.string,size:i.oneOf(["small","medium","large"]),dir:i.string},D.defaultProps={animate:!0,expandField:p,selectField:u,iconField:"svgIcon",hasChildrenField:"hasChildren",childrenField:m,textField:"text",disableField:"disabled",checkField:I,checkIndeterminateField:g,size:void 0};let S=D;function w(e,t,i,n,r){if(i){const{ids:d,field:o}=N(i,t);return function(e,t,i,n,r){let d=e;return t.forEach(e=>{d=s.updateItem(d,e,e=>P(i,e),n,r)}),d}(e,!s.isArray(i)&&i.idField?s.resolveItemsIds(d,i.idField,e,r):d,o,n,r)}return e}function N(e,t){let i,n;return s.isArray(e)?(i=e,n=t):(i=e.ids||[],n=e.operationField||t),{ids:i,field:n}}function P(e,t){const i=(e||"").split(".");let s=t;for(let e=0;e<i.length;e++){const t=i[e];if(e===i.length-1)s[t]=!0;else{if(void 0===s[t])return;s[t]={...s[t]},s=s[t]}}}function U(e,t,i,n,r){let d=!1;for(let o=0;o<e.length;o++){const a=e[o];if(s.getNestedValue(n,a)){if(!d)for(let e=0;e<t.length;e++)P(r,t[e]);d=!0,a[i]&&U(a[i],[],i,n,r)}else a[i]&&U(a[i],d?[a]:t.concat([a]),i,n,r)}}const M=class extends o.PureComponent{constructor(){super(...arguments),this.state={visible:!1,top:0,left:0,text:"",operationClassName:"cancel"}}render(){const e={top:this.state.top+"px",left:this.state.left+"px"};return this.state.visible&&o.createElement("div",{className:"k-header k-drag-clue",style:{...this.props.style,...e}},o.createElement(s.IconWrap,{className:s.classNames("k-drag-status"),name:this.state.operationClassName&&s.toIconName(this.state.operationClassName),icon:"k-i-plus"===this.state.operationClassName?n.plusIcon:"k-i-insert-up"===this.state.operationClassName?n.insertTopIcon:"k-i-insert-down"===this.state.operationClassName?n.insertBottomIcon:"k-i-insert-middle"===this.state.operationClassName?n.insertMiddleIcon:n.cancelIcon}),this.state.text)}show(e,t,i,s){this.setState({visible:!0,top:e,left:t,text:i,operationClassName:s})}hide(){this.setState({visible:!1})}};M.defaultProps={style:{display:"block",position:"absolute",zIndex:2e4,padding:"4px 6px"}};let R=M;const O=s.withIdHOC(S);O.displayName="KendoReactTreeView",Object.defineProperty(e,"FieldsService",{enumerable:!0,get:function(){return s.TreeFieldsService}}),e.TreeView=O,e.TreeViewClassComponent=S,e.TreeViewDragAnalyzer=class{constructor(e){this.event=e,this.initialized=!1,this.destItemId="",this.destTreeViewGuid="",this.itemId=e.itemHierarchicalIndex,this.treeViewGuid=e.target.guid}init(){return this.initialized||(this.setDestimationMeta(document.elementFromPoint(this.event.clientX,this.event.clientY)),this.initialized=!0),this}get isDropAllowed(){return!!(this.initialized&&this.destItemId&&this.destTreeViewGuid)&&!`${this.destTreeViewGuid}_${this.destItemId}_`.startsWith(`${this.treeViewGuid}_${this.itemId}_`)}get destinationMeta(){return{itemHierarchicalIndex:this.destItemId,treeViewGuid:this.destTreeViewGuid}}getDropOperation(){if(this.initialized&&this.isDropAllowed){const{top:e,height:t}=this.destDomNodeWithMeta.getBoundingClientRect();return e+t-this.event.clientY<6?"after":this.event.clientY-e<6?"before":"child"}}setDestimationMeta(e){let t=e;for(;t&&!t[f];)t=t.parentNode;t&&t[f]&&(this.destDomNodeWithMeta=t,this.destItemId=t[f],this.destTreeViewGuid=t[b])}},e.TreeViewDragClue=R,e.TreeViewItemPropsContext=C,e.getItemIdUponKeyboardNavigation=a,e.handleTreeViewCheckChange=function(e,t,i,n={},r){if(!i||!i.length)return[];const{ids:d,idField:o}=function(e){let t,i;return s.isArray(e)?t=e:(t=e.ids||[],i=e.idField),{ids:t,idField:i}}(t),a=o?s.getNestedValue(o,e.item):e.itemHierarchicalIndex,l=d.indexOf(a),c=-1===l,h=r||m;let p;return n.singleMode?p=c?[a]:[]:(p=d.slice(),c?p.push(a):p.splice(l,1),n.checkChildren&&function(e,t,i,n,r,d){s.getAllDirectIndirectChildrenIds(e,t,r,n).forEach(e=>{i&&-1===d.indexOf(e)?d.push(e):!i&&d.indexOf(e)>-1&&d.splice(d.indexOf(e),1)})}(e.item,e.itemHierarchicalIndex,c,o,h,p),n.checkParents&&function(e,t,i,n,r,d){const o=h();let a=o.next();function l(){for(;!a.done;){const{id:e,item:t}=a.value;if(-1!==r.indexOf(e)||!s.areAllDirectChildrenChecked(t,e,i,n,r))break;r.push(e),a=o.next()}}function c(){for(;!a.done;){const{id:e}=a.value,t=r.indexOf(e);if(!(t>-1))break;r.splice(t,1),a=o.next()}}function*h(){if(i){const r=s.getAllParents(e,n,d);for(let e=r.length-1;e>-1;e--)yield{id:s.getNestedValue(i,r[e]),item:t?r[e]:void 0}}else{let i=s.treeIdUtils.getDirectParentId(e);for(;i;)yield{id:i,item:t?s.treeIdUtils.getItemById(i,d,n):void 0},i=s.treeIdUtils.getDirectParentId(i)}}t?l():c()}(e.itemHierarchicalIndex,c,o,h,p,i)),s.isArray(t)?p:Object.assign({},t,{ids:p})},e.moveTreeViewItem=function(e,t,i,n,r,d){const o=d||m;if(!function(){if(!t||!t.length||!e||!n||r&&!r.length)return!1;const i=r&&r!==t?r:t;return!!s.treeIdUtils.getItemById(n,i,o)}())return l();const a=s.treeIdUtils.getItemById(e,t,o);if(!a)return l();if(!r||r===t){if(`${n}_`.startsWith(`${e}_`))return l();const d=s.removeItem(e,o,t),c=s.addItem(a,i,o,s.treeIdUtils.getDecrementedItemIdAfterRemoval(e,n),d);return r?{sourceData:c,targetData:c}:c}return{sourceData:s.removeItem(e,o,t),targetData:s.addItem(a,i,o,n,r)};function l(){return r?{sourceData:t,targetData:r}:t}},e.processTreeViewItems=function(e,t){if(!e||!e.length)return[];let i=e;const n=t.cloneField||"cloned",r=t.expandField||p,d=t.selectField||u,o=t.checkField||I,a=t.childrenField||m;return i=w(i,r,t.expand,n,a),i=w(i,d,t.select,n,a),i=w(i,o,t.check,n,a),function(e,t,i){if(i&&!s.isArray(i)&&i.applyCheckIndeterminate){const{field:n}=N(i,I),r=i.checkIndeterminateField||g;for(let i=0;i<e.length;i++){const d=e[i],o=d[t];o&&U(o,s.getNestedValue(n,d)?[]:[d],t,n,r)}}}(i,a,t.check),i}});
package/events.d.ts ADDED
@@ -0,0 +1,165 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { BaseEvent } from '@progress/kendo-react-common';
9
+ import { TreeView } from './TreeView.js';
10
+ /**
11
+ * Represents the object of the `onExpandChange` event ([see example](https://www.telerik.com/kendo-react-ui/components/treeview)).
12
+ */
13
+ export interface TreeViewExpandChangeEvent extends BaseEvent<TreeView> {
14
+ /**
15
+ * The item that is expanded or collapsed.
16
+ */
17
+ item: any;
18
+ /**
19
+ * The hierarchical index of the item. The 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.
20
+ */
21
+ itemHierarchicalIndex: string;
22
+ }
23
+ /**
24
+ * Represents the object of the `onItemClick` event ([see example](https://www.telerik.com/kendo-react-ui/components/treeview)).
25
+ */
26
+ export interface TreeViewItemClickEvent extends BaseEvent<TreeView> {
27
+ /**
28
+ * The item that is clicked.
29
+ */
30
+ item: any;
31
+ /**
32
+ * The hierarchical index of the item. The indices are zero-based.
33
+ * 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.
34
+ */
35
+ itemHierarchicalIndex: string;
36
+ }
37
+ /**
38
+ * Represents the object of the `onCheckChange` event ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/checkboxes/helper-functions)).
39
+ */
40
+ export interface TreeViewCheckChangeEvent extends BaseEvent<TreeView> {
41
+ /**
42
+ * The item that is selected or deselected.
43
+ */
44
+ item: any;
45
+ /**
46
+ * The hierarchical index of the item. The indices are zero-based.
47
+ * 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.
48
+ */
49
+ itemHierarchicalIndex: string;
50
+ }
51
+ /**
52
+ * Represents the object of the `onContextMenu` event ([see example](https://www.telerik.com/kendo-react-ui/components/treeview)).
53
+ */
54
+ export interface TreeViewContextMenuEvent extends BaseEvent<TreeView> {
55
+ /**
56
+ * An event target.
57
+ */
58
+ target: TreeView;
59
+ /**
60
+ * The data object that represents the current item.
61
+ */
62
+ item: any;
63
+ /**
64
+ * The ID of the current item.
65
+ */
66
+ itemID: string;
67
+ /**
68
+ * A React Synthetic Event.
69
+ */
70
+ syntheticEvent: React.MouseEvent<any>;
71
+ }
72
+ /**
73
+ * Represents the object of the `onItemDragStart` event.
74
+ */
75
+ export interface TreeViewItemDragStartEvent {
76
+ /**
77
+ * An event target.
78
+ */
79
+ target: TreeView;
80
+ /**
81
+ * The item that is dragged.
82
+ */
83
+ item: any;
84
+ /**
85
+ * The hierarchical index of the dragged item. The indices are zero-based.
86
+ * 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.
87
+ */
88
+ itemHierarchicalIndex: string;
89
+ }
90
+ /**
91
+ * Represents the object of the `onItemDragOver` event ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/drag-drop)).
92
+ */
93
+ export interface TreeViewItemDragOverEvent {
94
+ /**
95
+ * The target that is associated with the dragged item.
96
+ */
97
+ target: TreeView;
98
+ /**
99
+ * The item that is dragged.
100
+ */
101
+ item: any;
102
+ /**
103
+ * The hierarchical index of the dragged item. The indices are zero-based.
104
+ * 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.
105
+ */
106
+ itemHierarchicalIndex: string;
107
+ /**
108
+ * The X (horizontal) coordinate (in pixels) at which the event occurred that is relative to the left edge of the entire document.
109
+ * Includes any portion of the document which is not currently visible.
110
+ */
111
+ pageX: number;
112
+ /**
113
+ * The Y (vertical) coordinate (in pixels) at which the event occurred that is relative to the whole document.
114
+ * `pageY` observes any vertical scrolling of the page.
115
+ */
116
+ pageY: number;
117
+ /**
118
+ * Provides the horizontal coordinate within the client area of the application at which the event occurred
119
+ * (as opposed to the coordinate within the page).
120
+ */
121
+ clientX: number;
122
+ /**
123
+ * Provides the vertical coordinate within the client area of the application at which the event occurred
124
+ * (as opposed to the coordinate within the page).
125
+ */
126
+ clientY: number;
127
+ }
128
+ /**
129
+ * Represents the object of the `onItemDragEnd` event ([see example](https://www.telerik.com/kendo-react-ui/components/treeview/drag-drop)).
130
+ */
131
+ export interface TreeViewItemDragEndEvent {
132
+ /**
133
+ * The target that is associated with the dragged item.
134
+ */
135
+ target: TreeView;
136
+ /**
137
+ * The item that is dragged.
138
+ */
139
+ item: any;
140
+ /**
141
+ * The hierarchical index of the dragged item. The indices are zero-based.
142
+ * 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.
143
+ */
144
+ itemHierarchicalIndex: string;
145
+ /**
146
+ * The X (horizontal) coordinate (in pixels) at which the event occured that is relative to the left edge of the entire document.
147
+ * `pageX` includes any portion of the document that is not currently visible.
148
+ */
149
+ pageX: number;
150
+ /**
151
+ * The Y (vertical) coordinate (in pixels) at which the event occured that is relative to the whole document.
152
+ * `pageY` observes any vertical scrolling of the page.
153
+ */
154
+ pageY: number;
155
+ /**
156
+ * Provides the horizontal coordinate within the client area of the application at which the event occurred
157
+ * (as opposed to the coordinate within the page).
158
+ */
159
+ clientX: number;
160
+ /**
161
+ * Provides the vertical coordinate within the client area of the application at which the event occurred
162
+ * (as opposed to the coordinate within the page).
163
+ */
164
+ clientY: number;
165
+ }