@progress/kendo-react-treeview 6.1.1 → 7.0.0-develop.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/{dist/es/ItemRenderProps.d.ts → ItemRenderProps.d.ts} +4 -0
  2. package/LICENSE.md +1 -1
  3. package/{dist/npm/TreeView.d.ts → TreeView.d.ts} +5 -1
  4. package/{dist/es/TreeViewDragAnalyzer.d.ts → TreeViewDragAnalyzer.d.ts} +5 -1
  5. package/{dist/npm/TreeViewDragClue.d.ts → TreeViewDragClue.d.ts} +5 -1
  6. package/{dist/npm/TreeViewItem.d.ts → TreeViewItem.d.ts} +5 -1
  7. package/{dist/es/TreeViewOperationDescriptors.d.ts → TreeViewOperationDescriptors.d.ts} +4 -0
  8. package/{dist/es/TreeViewProps.d.ts → TreeViewProps.d.ts} +4 -0
  9. package/dist/cdn/js/kendo-react-treeview.js +5 -1
  10. package/{dist/es/events.d.ts → events.d.ts} +4 -1
  11. package/{dist/npm/handleTreeViewCheckChange.d.ts → handleTreeViewCheckChange.d.ts} +4 -0
  12. package/{dist/es/main.d.ts → index.d.ts} +9 -5
  13. package/index.js +5 -0
  14. package/index.mjs +745 -0
  15. package/{dist/npm/moveTreeViewItem.d.ts → moveTreeViewItem.d.ts} +4 -0
  16. package/package-metadata.d.ts +9 -0
  17. package/package.json +28 -37
  18. package/{dist/es/processTreeViewItems.d.ts → processTreeViewItems.d.ts} +4 -0
  19. package/{dist/npm/utils → utils}/consts.d.ts +4 -0
  20. package/utils/getItemIdUponKeyboardNavigation.d.ts +9 -0
  21. package/about.md +0 -3
  22. package/dist/es/ItemRenderProps.js +0 -2
  23. package/dist/es/TreeView.d.ts +0 -124
  24. package/dist/es/TreeView.js +0 -334
  25. package/dist/es/TreeViewDragAnalyzer.js +0 -186
  26. package/dist/es/TreeViewDragClue.d.ts +0 -144
  27. package/dist/es/TreeViewDragClue.js +0 -171
  28. package/dist/es/TreeViewItem.d.ts +0 -96
  29. package/dist/es/TreeViewItem.js +0 -255
  30. package/dist/es/TreeViewOperationDescriptors.js +0 -2
  31. package/dist/es/TreeViewProps.js +0 -1
  32. package/dist/es/events.js +0 -1
  33. package/dist/es/handleTreeViewCheckChange.d.ts +0 -69
  34. package/dist/es/handleTreeViewCheckChange.js +0 -193
  35. package/dist/es/main.js +0 -10
  36. package/dist/es/moveTreeViewItem.d.ts +0 -109
  37. package/dist/es/moveTreeViewItem.js +0 -155
  38. package/dist/es/package-metadata.d.ts +0 -5
  39. package/dist/es/package-metadata.js +0 -11
  40. package/dist/es/processTreeViewItems.js +0 -163
  41. package/dist/es/utils/consts.d.ts +0 -40
  42. package/dist/es/utils/consts.js +0 -40
  43. package/dist/es/utils/getItemIdUponKeyboardNavigation.d.ts +0 -5
  44. package/dist/es/utils/getItemIdUponKeyboardNavigation.js +0 -76
  45. package/dist/npm/ItemRenderProps.d.ts +0 -13
  46. package/dist/npm/ItemRenderProps.js +0 -3
  47. package/dist/npm/TreeView.js +0 -337
  48. package/dist/npm/TreeViewDragAnalyzer.d.ts +0 -135
  49. package/dist/npm/TreeViewDragAnalyzer.js +0 -189
  50. package/dist/npm/TreeViewDragClue.js +0 -174
  51. package/dist/npm/TreeViewItem.js +0 -258
  52. package/dist/npm/TreeViewOperationDescriptors.d.ts +0 -76
  53. package/dist/npm/TreeViewOperationDescriptors.js +0 -3
  54. package/dist/npm/TreeViewProps.d.ts +0 -137
  55. package/dist/npm/TreeViewProps.js +0 -2
  56. package/dist/npm/events.d.ts +0 -159
  57. package/dist/npm/events.js +0 -2
  58. package/dist/npm/handleTreeViewCheckChange.js +0 -197
  59. package/dist/npm/main.d.ts +0 -14
  60. package/dist/npm/main.js +0 -21
  61. package/dist/npm/moveTreeViewItem.js +0 -159
  62. package/dist/npm/package-metadata.d.ts +0 -5
  63. package/dist/npm/package-metadata.js +0 -14
  64. package/dist/npm/processTreeViewItems.d.ts +0 -51
  65. package/dist/npm/processTreeViewItems.js +0 -167
  66. package/dist/npm/utils/consts.js +0 -43
  67. package/dist/npm/utils/getItemIdUponKeyboardNavigation.d.ts +0 -5
  68. package/dist/npm/utils/getItemIdUponKeyboardNavigation.js +0 -79
  69. package/dist/systemjs/kendo-react-treeview.js +0 -1
  70. package/e2e-next/basic.tests.ts +0 -24
package/index.mjs ADDED
@@ -0,0 +1,745 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as a from "react";
6
+ import * as p from "prop-types";
7
+ import { Keys as f, treeIdUtils as h, isEnabledAndAllParentsEnabled as M, isItemExpandedAndWithChildren as b, guid as R, classNames as g, Draggable as W, hasChildren as x, IconWrap as T, kendoThemeMaps as O, validatePackage as Y, TreeFieldsService as X, dispatchEvent as F, resolveItemId as Z, isArray as C, resolveItemsIds as q, updateItem as j, getNestedValue as v, removeItem as N, addItem as P, getAllDirectIndirectChildrenIds as Q, areAllDirectChildrenChecked as J, getAllParents as ee, toIconName as te } from "@progress/kendo-react-common";
8
+ import { TreeFieldsService as Te } from "@progress/kendo-react-common";
9
+ import { caretAltDownIcon as ie, caretAltLeftIcon as se, caretAltRightIcon as ne, plusIcon as re, insertTopIcon as oe, insertBottomIcon as de, insertMiddleIcon as le, cancelIcon as ae } from "@progress/kendo-svg-icons";
10
+ import { Reveal as he } from "@progress/kendo-react-animation";
11
+ function ce(n, e, t, i, s) {
12
+ switch (i) {
13
+ case f.left:
14
+ return r();
15
+ case f.right:
16
+ return o();
17
+ case f.up:
18
+ return d();
19
+ case f.down:
20
+ return u();
21
+ case f.home:
22
+ return h.ZERO_LEVEL_ZERO_NODE_ID;
23
+ case f.end:
24
+ return I();
25
+ default:
26
+ return e;
27
+ }
28
+ function r() {
29
+ return h.isIdZeroLevel(e) || s.expanded(n) && M(e, t, s) ? e : h.getDirectParentId(e);
30
+ }
31
+ function o() {
32
+ return b(n, s) ? h.getFirstChildId(e) : e;
33
+ }
34
+ function d() {
35
+ const m = Number(h.getShortId(e)), l = h.getDirectParentId(e);
36
+ return m ? L(h.createId(m - 1, l), t, s) : h.isIdZeroLevel(e) ? e : l;
37
+ }
38
+ function u() {
39
+ return b(n, s) ? h.getFirstChildId(e) : A(e, t, s) || e;
40
+ }
41
+ function I() {
42
+ let m = (t.length - 1).toString(), l = t[t.length - 1], c;
43
+ for (; b(l, s); )
44
+ c = l[s.getChildrenField()], m = h.createId(c.length - 1, m), l = c[c.length - 1];
45
+ return m;
46
+ }
47
+ }
48
+ function A(n, e, t) {
49
+ const i = h.getDirectParentId(n), s = i ? h.getItemById(i, e, t.getChildrenField()) : void 0, r = s ? s[t.getChildrenField()] : e, o = Number(h.getShortId(n));
50
+ return o < r.length - 1 ? h.createId(o + 1, i) : s ? A(i, e, t) : void 0;
51
+ }
52
+ function L(n, e, t) {
53
+ const i = h.getItemById(n, e, t.getChildrenField());
54
+ return b(i, t) ? L(h.createId(i[t.getChildrenField()].length - 1, n), e, t) : n;
55
+ }
56
+ const V = "expanded", pe = "text", ue = "disabled", E = "items", me = "hasChildren", U = "selected", S = "checked", G = "checkIndeterminate", k = "_kendoItemId", B = "_kendoTreeViewGuid", { sizeMap: Ie } = O, fe = a.createContext((n) => n);
57
+ class K extends a.Component {
58
+ constructor() {
59
+ super(...arguments), this.itemGuid = R(), this.onCheckChange = (e) => {
60
+ this.props.onCheckChange(e, this.item, this.itemId);
61
+ }, this.onExpandChange = (e) => {
62
+ this.props.onExpandChange(e, this.item, this.itemId);
63
+ }, this.onItemClick = (e) => {
64
+ this.props.onItemClick(e, this.item, this.itemId);
65
+ }, this.onPress = (e) => {
66
+ this.props.onPress(e.event, this.item, this.itemId);
67
+ }, this.onDrag = (e) => {
68
+ this.props.onDrag(e.event, this.item, this.itemId);
69
+ }, this.onRelease = (e) => {
70
+ this.props.onRelease(e.event, this.item, this.itemId);
71
+ }, this.onContextMenu = (e) => {
72
+ this.props.onContextMenu(e, this.item, this.itemId);
73
+ }, this.assignDraggableMeta = (e) => {
74
+ e && (e[k] = this.props.itemId, e[B] = this.props.treeGuid);
75
+ };
76
+ }
77
+ render() {
78
+ const e = this.renderSubitemsIfApplicable(), t = this.renderItemInPart();
79
+ return /* @__PURE__ */ a.createElement(
80
+ "li",
81
+ {
82
+ className: g("k-treeview-item"),
83
+ tabIndex: this.tabIndex,
84
+ role: "treeitem",
85
+ "aria-expanded": this.ariaExpanded,
86
+ "aria-selected": this.ariaSelected,
87
+ "aria-checked": this.ariaChecked,
88
+ "aria-disabled": this.disabled ? !0 : void 0,
89
+ ref: (i) => this.itemElement = i
90
+ },
91
+ /* @__PURE__ */ a.createElement("div", { className: `k-treeview-${this.props.position}`, ref: this.assignDraggableMeta }, this.renderExpandIcon(), this.renderCheckbox(), this.props.draggable ? /* @__PURE__ */ a.createElement(W, { onPress: this.onPress, onDrag: this.onDrag, onRelease: this.onRelease }, t) : t),
92
+ this.props.animate ? /* @__PURE__ */ a.createElement(
93
+ he,
94
+ {
95
+ transitionEnterDuration: 200,
96
+ transitionExitDuration: 200,
97
+ style: { display: "block" },
98
+ children: e
99
+ }
100
+ ) : e
101
+ );
102
+ }
103
+ componentDidMount() {
104
+ const e = this.props.focusedItemId, t = this.itemId;
105
+ e && e === t && this.props.onFocusDomElNeeded(this.itemElement), this.checkboxElement && (this.checkboxElement.indeterminate = this.fieldsSvc.checkIndeterminate(this.item));
106
+ }
107
+ componentDidUpdate(e) {
108
+ const t = this.props.focusedItemId;
109
+ if (t && t !== e.focusedItemId && t === this.itemId && this.props.onFocusDomElNeeded(this.itemElement), this.checkboxElement) {
110
+ const i = this.fieldsSvc.checkIndeterminate(this.item);
111
+ i !== e.fieldsService.checkIndeterminate(e.item) && (this.checkboxElement.indeterminate = i);
112
+ }
113
+ }
114
+ renderCheckbox() {
115
+ if (this.props.checkboxes) {
116
+ const e = this.props.size;
117
+ return /* @__PURE__ */ a.createElement("div", { className: g("k-checkbox-wrap") }, /* @__PURE__ */ a.createElement(
118
+ "input",
119
+ {
120
+ type: "checkbox",
121
+ className: g(
122
+ "k-checkbox k-rounded-md",
123
+ {
124
+ [`k-checkbox-${Ie[e] || e}`]: e,
125
+ "k-disabled": this.disabled
126
+ }
127
+ ),
128
+ "aria-label": this.item.text,
129
+ checked: !!this.fieldsSvc.checked(this.item),
130
+ id: this.itemGuid,
131
+ tabIndex: -1,
132
+ onChange: this.onCheckChange,
133
+ ref: (t) => this.checkboxElement = t
134
+ }
135
+ ), /* @__PURE__ */ a.createElement("label", { className: "k-checkbox-label", htmlFor: this.itemGuid }));
136
+ } else
137
+ return;
138
+ }
139
+ renderExpandIcon() {
140
+ return this.props.expandIcons && // If it is explicitly said that the item has children (even not loaded yet)
141
+ // or if the item actually has children, then render the icon.
142
+ (this.fieldsSvc.hasChildren(this.item) || x(this.item, this.fieldsSvc.getChildrenField())) && // Allowing the toggle-button even with `disabled=true` might be a valid case!
143
+ // Re-evaluate the classes bellow if such scenario occurs
144
+ /* @__PURE__ */ a.createElement("span", { className: g("k-treeview-toggle", { "k-disabled": this.disabled }), onClick: this.onExpandChange }, /* @__PURE__ */ a.createElement(T, { ...this.getIconProps() }));
145
+ }
146
+ renderSubitemsIfApplicable() {
147
+ const e = this.fieldsSvc.children(this.item);
148
+ return b(this.item, this.fieldsSvc) ? /* @__PURE__ */ a.createElement("ul", { className: "k-treeview-group", role: "group" }, e.map((t, i) => /* @__PURE__ */ a.createElement(
149
+ y,
150
+ {
151
+ item: t,
152
+ position: i === 0 ? "top" : i === e.length - 1 ? "bot" : "mid",
153
+ itemId: h.createId(i, this.itemId),
154
+ treeGuid: this.props.treeGuid,
155
+ animate: this.props.animate,
156
+ focusedItemId: this.props.focusedItemId,
157
+ tabbableItemId: this.props.tabbableItemId,
158
+ fieldsService: this.props.fieldsService,
159
+ itemUI: this.props.itemUI,
160
+ checkboxes: this.props.checkboxes,
161
+ ariaMultiSelectable: this.props.ariaMultiSelectable,
162
+ onItemClick: this.props.onItemClick,
163
+ onFocusDomElNeeded: this.props.onFocusDomElNeeded,
164
+ draggable: this.props.draggable,
165
+ onPress: this.props.onPress,
166
+ onDrag: this.props.onDrag,
167
+ onRelease: this.props.onRelease,
168
+ expandIcons: this.props.expandIcons,
169
+ onExpandChange: this.props.onExpandChange,
170
+ onCheckChange: this.props.onCheckChange,
171
+ onContextMenu: this.props.onContextMenu,
172
+ key: i,
173
+ size: this.props.size,
174
+ disabled: this.disabled,
175
+ isRtl: this.props.isRtl
176
+ }
177
+ ))) : void 0;
178
+ }
179
+ renderItemInPart() {
180
+ return /* @__PURE__ */ a.createElement(
181
+ "span",
182
+ {
183
+ className: g(
184
+ "k-treeview-leaf",
185
+ {
186
+ "k-focus": this.props.focusedItemId === this.itemId,
187
+ "k-selected": this.fieldsSvc.selected(this.item),
188
+ "k-disabled": this.disabled
189
+ }
190
+ ),
191
+ style: { touchAction: "none" },
192
+ onClick: this.onItemClick,
193
+ onContextMenu: this.onContextMenu
194
+ },
195
+ /* @__PURE__ */ a.createElement("span", { className: "k-treeview-leaf-text" }, this.props.itemUI ? /* @__PURE__ */ a.createElement(this.props.itemUI, { item: this.item, itemHierarchicalIndex: this.itemId }) : this.fieldsSvc.text(this.item))
196
+ );
197
+ }
198
+ get fieldsSvc() {
199
+ return this.props.fieldsService;
200
+ }
201
+ get itemId() {
202
+ return this.props.itemId;
203
+ }
204
+ get item() {
205
+ return this.props.item;
206
+ }
207
+ get tabIndex() {
208
+ return (this.props.focusedItemId || this.props.tabbableItemId) === this.itemId ? 0 : -1;
209
+ }
210
+ get ariaExpanded() {
211
+ return this.fieldsSvc.hasChildren(this.item) || x(this.item, this.fieldsSvc.getChildrenField()) ? !!this.fieldsSvc.expanded(this.item) : void 0;
212
+ }
213
+ get disabled() {
214
+ return this.props.disabled || this.fieldsSvc.disabled(this.item);
215
+ }
216
+ get ariaChecked() {
217
+ if (this.props.checkboxes)
218
+ return this.fieldsSvc.checked(this.item) ? "true" : this.fieldsSvc.checkIndeterminate(this.item) ? "mixed" : "false";
219
+ }
220
+ get ariaSelected() {
221
+ return this.fieldsSvc.selected(this.item) ? !0 : this.props.ariaMultiSelectable ? this.disabled ? void 0 : !1 : void 0;
222
+ }
223
+ getIconProps() {
224
+ const e = this.fieldsSvc.expanded(this.item);
225
+ return e && !x(this.item, this.fieldsSvc.getChildrenField()) ? { name: "loading" } : e ? { name: "caret-alt-down", icon: ie } : { name: this.props.isRtl ? "caret-alt-left" : "caret-alt-right", icon: this.props.isRtl ? se : ne };
226
+ }
227
+ }
228
+ K.defaultProps = {
229
+ position: "top"
230
+ };
231
+ const y = a.forwardRef((n, e) => {
232
+ const i = a.useContext(fe).call(void 0, n);
233
+ return /* @__PURE__ */ a.createElement(
234
+ K,
235
+ {
236
+ ref: e,
237
+ ...i
238
+ }
239
+ );
240
+ });
241
+ y.displayName = "TreeViewItem";
242
+ const ge = {
243
+ name: "@progress/kendo-react-treeview",
244
+ productName: "KendoReact",
245
+ productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
246
+ publishDate: 1700573084,
247
+ version: "",
248
+ licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
249
+ }, { sizeMap: be } = O;
250
+ class z extends a.Component {
251
+ constructor(e) {
252
+ super(e), this.state = { focusedItemId: void 0, focusedItemPublicId: void 0, tabbableItemId: h.ZERO_LEVEL_ZERO_NODE_ID }, this.fieldsSvc = null, this.allowExplicitFocus = !1, this.treeGuid = R(), this._element = null, this.onFocusDomElNeeded = (t) => {
253
+ this.allowExplicitFocus && this.focusDomItem(t);
254
+ }, this.onCheckChange = (t, i, s) => {
255
+ this.setFocus(s), this.dispatchCheckChange(t, i, s);
256
+ }, this.onExpandChange = (t, i, s) => {
257
+ this.setFocus(s), this.dispatchExpandChange(t, i, s);
258
+ }, this.onPress = (t, i, s) => {
259
+ this.props.onItemDragStart && this.props.onItemDragStart.call(
260
+ void 0,
261
+ { target: this, item: i, itemHierarchicalIndex: s }
262
+ );
263
+ }, this.onDrag = (t, i, s) => {
264
+ const { pageX: r, pageY: o, clientX: d, clientY: u } = t;
265
+ this.props.onItemDragOver && this.props.onItemDragOver.call(
266
+ void 0,
267
+ {
268
+ target: this,
269
+ item: i,
270
+ itemHierarchicalIndex: s,
271
+ pageX: r,
272
+ pageY: o,
273
+ clientX: d,
274
+ clientY: u
275
+ }
276
+ );
277
+ }, this.onRelease = (t, i, s) => {
278
+ const { pageX: r, pageY: o, clientX: d, clientY: u } = t;
279
+ this.props.onItemDragEnd && this.props.onItemDragEnd.call(
280
+ void 0,
281
+ {
282
+ target: this,
283
+ item: i,
284
+ itemHierarchicalIndex: s,
285
+ pageX: r,
286
+ pageY: o,
287
+ clientX: d,
288
+ clientY: u
289
+ }
290
+ );
291
+ }, this.onItemClick = (t, i, s) => {
292
+ this.setFocus(s), this.dispatchItemClick(t, i, s);
293
+ }, this.onFocus = () => {
294
+ clearTimeout(this.blurRequest), this.state.focusedItemId === void 0 && this.data.length && this.setFocus(this.state.tabbableItemId);
295
+ }, this.onBlur = () => {
296
+ clearTimeout(this.blurRequest), this.blurRequest = window.setTimeout(() => this.setFocus(void 0), 0);
297
+ }, this.onKeyDown = (t) => {
298
+ const i = this.getFocusedItem();
299
+ if (i && this.fieldsSvc) {
300
+ const s = ce(i, this.state.focusedItemId, this.data, t.keyCode, this.fieldsSvc);
301
+ s !== this.state.focusedItemId && (t.preventDefault(), this.allowExplicitFocus = !0, this.setFocus(s)), this.dispatchEventsOnKeyDown(t, i);
302
+ }
303
+ }, this.onContextMenu = (t, i, s) => {
304
+ if (this.props.onContextMenu) {
305
+ const r = {
306
+ target: this,
307
+ syntheticEvent: t,
308
+ nativeEvent: t.nativeEvent,
309
+ item: i,
310
+ itemID: s
311
+ };
312
+ this.props.onContextMenu.call(void 0, r);
313
+ }
314
+ }, Y(ge);
315
+ }
316
+ /**
317
+ * @hidden
318
+ */
319
+ get element() {
320
+ return this._element;
321
+ }
322
+ /**
323
+ * @hidden
324
+ */
325
+ render() {
326
+ this.fieldsSvc = new X(this.props);
327
+ const { size: e, className: t } = this.props;
328
+ return /* @__PURE__ */ a.createElement(
329
+ "div",
330
+ {
331
+ className: g(
332
+ "k-treeview",
333
+ {
334
+ [`k-treeview-${be[e] || e}`]: e,
335
+ ["k-user-select-none"]: this.props.draggable,
336
+ ["k-rtl"]: this.props.dir === "rtl"
337
+ },
338
+ t
339
+ ),
340
+ onKeyDown: this.onKeyDown,
341
+ onFocus: this.onFocus,
342
+ onBlur: this.onBlur,
343
+ role: "tree",
344
+ "aria-multiselectable": this.ariaMultiSelectable ? !0 : void 0,
345
+ "aria-label": this.props["aria-label"],
346
+ "aria-labelledby": this.props["aria-labelledby"],
347
+ ref: (i) => this._element = i,
348
+ tabIndex: this.props.tabIndex
349
+ },
350
+ /* @__PURE__ */ a.createElement("ul", { className: "k-treeview-lines k-treeview-group", role: "group" }, this.data.map((i, s) => /* @__PURE__ */ a.createElement(
351
+ y,
352
+ {
353
+ item: i,
354
+ position: s === 0 ? "top" : s === this.data.length - 1 ? "bot" : "mid",
355
+ itemId: s.toString(),
356
+ treeGuid: this.treeGuid,
357
+ animate: this.props.animate,
358
+ focusedItemId: this.state.focusedItemId,
359
+ tabbableItemId: this.state.tabbableItemId,
360
+ fieldsService: this.fieldsSvc,
361
+ itemUI: this.props.item,
362
+ checkboxes: this.props.checkboxes,
363
+ ariaMultiSelectable: this.ariaMultiSelectable,
364
+ onItemClick: this.onItemClick,
365
+ onFocusDomElNeeded: this.onFocusDomElNeeded,
366
+ draggable: this.props.draggable,
367
+ onPress: this.onPress,
368
+ onDrag: this.onDrag,
369
+ onRelease: this.onRelease,
370
+ expandIcons: this.props.expandIcons,
371
+ onExpandChange: this.onExpandChange,
372
+ onCheckChange: this.onCheckChange,
373
+ onContextMenu: this.onContextMenu,
374
+ key: s,
375
+ size: e,
376
+ isRtl: this.props.dir === "rtl"
377
+ }
378
+ )))
379
+ );
380
+ }
381
+ /**
382
+ * @hidden
383
+ */
384
+ componentDidUpdate() {
385
+ this.allowExplicitFocus = !1, this.refocusDueToFocusIdField();
386
+ }
387
+ dispatchEventsOnKeyDown(e, t) {
388
+ if (this.fieldsSvc === null)
389
+ return;
390
+ const i = () => this.fieldsSvc && M(this.state.focusedItemId, this.data, this.fieldsSvc);
391
+ e.keyCode === f.left && this.fieldsSvc.expanded(t) && i() ? this.dispatchExpandChange(e, t, this.state.focusedItemId) : e.keyCode === f.right && !this.fieldsSvc.expanded(t) && (this.fieldsSvc.hasChildren(t) || x(t, this.props.childrenField)) && i() ? this.dispatchExpandChange(e, t, this.state.focusedItemId) : e.keyCode === f.enter && i() ? this.dispatchItemClick(e, t, this.state.focusedItemId) : e.keyCode === f.space && i() && (e.preventDefault(), this.dispatchCheckChange(e, t, this.state.focusedItemId));
392
+ }
393
+ setFocus(e) {
394
+ if (e && this.fieldsSvc)
395
+ if (this.fieldsSvc.focusIdField) {
396
+ const t = this.getItemById(e);
397
+ this.setState({ focusedItemId: e, focusedItemPublicId: this.fieldsSvc.focusId(t) });
398
+ } else
399
+ this.setState({ focusedItemId: e });
400
+ else
401
+ this.setState((t) => ({
402
+ focusedItemId: void 0,
403
+ focusedItemPublicId: void 0,
404
+ tabbableItemId: t.focusedItemId
405
+ }));
406
+ }
407
+ getFocusedItem() {
408
+ return this.state.focusedItemId ? this.getItemById(this.state.focusedItemId) : void 0;
409
+ }
410
+ getItemById(e) {
411
+ return h.getItemById(e, this.data, this.props.childrenField || E);
412
+ }
413
+ dispatchCheckChange(e, t, i) {
414
+ F(this.props.onCheckChange, e, this, { item: t, itemHierarchicalIndex: i });
415
+ }
416
+ dispatchExpandChange(e, t, i) {
417
+ F(this.props.onExpandChange, e, this, { item: t, itemHierarchicalIndex: i });
418
+ }
419
+ dispatchItemClick(e, t, i) {
420
+ F(this.props.onItemClick, e, this, { item: t, itemHierarchicalIndex: i });
421
+ }
422
+ refocusDueToFocusIdField() {
423
+ if (this.fieldsSvc && this.fieldsSvc.focusIdField) {
424
+ const e = this.state.focusedItemPublicId;
425
+ if (e) {
426
+ const t = this.props.getFocusHierarchicalIndex ? this.props.getFocusHierarchicalIndex(e) : Z(e, this.fieldsSvc.focusIdField, this.data, this.props.childrenField);
427
+ t !== this.state.focusedItemId && (this.allowExplicitFocus = !0, this.setState({ focusedItemId: t }));
428
+ }
429
+ }
430
+ }
431
+ get ariaMultiSelectable() {
432
+ return this.props["aria-multiselectable"] === !0 || this.props["aria-multiselectable"] === "true";
433
+ }
434
+ get data() {
435
+ return this.props.data || [];
436
+ }
437
+ focusDomItem(e) {
438
+ e.focus();
439
+ }
440
+ /**
441
+ * Returns the `guid` which is associated with the TreeView.
442
+ */
443
+ get guid() {
444
+ return this.treeGuid;
445
+ }
446
+ }
447
+ z.propTypes = {
448
+ data: p.arrayOf(p.any),
449
+ animate: p.bool,
450
+ tabIndex: p.number,
451
+ focusIdField: p.string,
452
+ getHierarchicalIndexById: p.func,
453
+ onExpandChange: p.func,
454
+ onItemClick: p.func,
455
+ expandField: p.string,
456
+ selectField: p.string,
457
+ childrenField: p.string,
458
+ hasChildrenField: p.string,
459
+ textField: p.string,
460
+ disableField: p.string,
461
+ item: p.any,
462
+ "aria-multiselectable": (n, e, t) => n[e] !== void 0 && n[e] !== !0 && n[e] !== !1 && n[e] !== "true" && n[e] !== "false" ? new Error(
463
+ "Invalid prop `" + e + "` supplied to `" + t + "`. Validation failed."
464
+ ) : null,
465
+ "aria-label": p.string,
466
+ "aria-labelledby": p.string,
467
+ size: p.oneOf([null, "small", "medium", "large"]),
468
+ dir: p.string
469
+ };
470
+ z.defaultProps = {
471
+ animate: !0,
472
+ expandField: V,
473
+ selectField: U,
474
+ hasChildrenField: me,
475
+ childrenField: E,
476
+ textField: pe,
477
+ disableField: ue,
478
+ checkField: S,
479
+ checkIndeterminateField: G,
480
+ size: "medium"
481
+ };
482
+ function ye(n, e) {
483
+ if (!n || !n.length)
484
+ return [];
485
+ let t = n;
486
+ const i = e.cloneField || "cloned", s = e.expandField || V, r = e.selectField || U, o = e.checkField || S, d = e.childrenField || E;
487
+ return t = D(t, s, e.expand, i, d), t = D(t, r, e.select, i, d), t = D(t, o, e.check, i, d), Ee(t, d, e.check), t;
488
+ }
489
+ function D(n, e, t, i, s) {
490
+ if (t) {
491
+ let { ids: r, field: o } = H(t, e), d = !C(t) && t.idField ? q(r, t.idField, n, s) : r;
492
+ return Ce(n, d, o, i, s);
493
+ } else
494
+ return n;
495
+ }
496
+ function H(n, e) {
497
+ let t, i;
498
+ return C(n) ? (t = n, i = e) : (t = n.ids || [], i = n.operationField || e), { ids: t, field: i };
499
+ }
500
+ function Ce(n, e, t, i, s) {
501
+ let r = n;
502
+ return e.forEach((o) => {
503
+ r = j(r, o, (d) => $(t, d), i, s);
504
+ }), r;
505
+ }
506
+ function $(n, e) {
507
+ const t = (n || "").split(".");
508
+ let i = e;
509
+ for (let s = 0; s < t.length; s++) {
510
+ const r = t[s];
511
+ if (s === t.length - 1)
512
+ i[r] = !0;
513
+ else if (i[r] !== void 0)
514
+ i[r] = { ...i[r] }, i = i[r];
515
+ else
516
+ return;
517
+ }
518
+ }
519
+ function Ee(n, e, t) {
520
+ if (t && !C(t) && t.applyCheckIndeterminate) {
521
+ const { field: i } = H(t, S), s = t.checkIndeterminateField || G;
522
+ for (let r = 0; r < n.length; r++) {
523
+ const o = n[r], d = o[e];
524
+ d && w(
525
+ d,
526
+ v(i, o) ? [] : [o],
527
+ e,
528
+ i,
529
+ s
530
+ );
531
+ }
532
+ }
533
+ }
534
+ function w(n, e, t, i, s) {
535
+ let r = !1;
536
+ for (let o = 0; o < n.length; o++) {
537
+ const d = n[o];
538
+ if (v(i, d)) {
539
+ if (!r)
540
+ for (let u = 0; u < e.length; u++)
541
+ $(s, e[u]);
542
+ r = !0, d[t] && w(d[t], [], t, i, s);
543
+ } else
544
+ d[t] && w(
545
+ d[t],
546
+ r ? [d] : e.concat([d]),
547
+ t,
548
+ i,
549
+ s
550
+ );
551
+ }
552
+ }
553
+ function Ne(n, e, t, i, s, r) {
554
+ const o = r || E;
555
+ if (!m())
556
+ return u();
557
+ const d = h.getItemById(n, e, o);
558
+ if (!d)
559
+ return u();
560
+ if (!s || s === e) {
561
+ if (!I())
562
+ return u();
563
+ const l = N(n, o, e), c = P(
564
+ d,
565
+ t,
566
+ o,
567
+ h.getDecrementedItemIdAfterRemoval(n, i),
568
+ l
569
+ );
570
+ return s ? { sourceData: c, targetData: c } : c;
571
+ } else {
572
+ const l = N(n, o, e), c = P(d, t, o, i, s);
573
+ return { sourceData: l, targetData: c };
574
+ }
575
+ function u() {
576
+ return s ? { sourceData: e, targetData: s } : e;
577
+ }
578
+ function I() {
579
+ return !`${i}_`.startsWith(`${n}_`);
580
+ }
581
+ function m() {
582
+ if (!e || !e.length || !n || !i || s && !s.length)
583
+ return !1;
584
+ const l = !s || s === e ? e : s;
585
+ return !!h.getItemById(i, l, o);
586
+ }
587
+ }
588
+ function Pe(n, e, t, i = {}, s) {
589
+ if (!t || !t.length)
590
+ return [];
591
+ const { ids: r, idField: o } = xe(e), d = o ? v(o, n.item) : n.itemHierarchicalIndex, u = r.indexOf(d), I = u === -1, m = s || E;
592
+ let l;
593
+ return i.singleMode ? l = I ? [d] : [] : (l = r.slice(), I ? l.push(d) : l.splice(u, 1), i.checkChildren && ke(n.item, n.itemHierarchicalIndex, I, o, m, l), i.checkParents && ve(n.itemHierarchicalIndex, I, o, m, l, t)), C(e) ? l : Object.assign({}, e, { ids: l });
594
+ }
595
+ function xe(n) {
596
+ let e, t;
597
+ return C(n) ? e = n : (e = n.ids || [], t = n.idField), { ids: e, idField: t };
598
+ }
599
+ function ke(n, e, t, i, s, r) {
600
+ Q(n, e, s, i).forEach((o) => {
601
+ t && r.indexOf(o) === -1 ? r.push(o) : !t && r.indexOf(o) > -1 && r.splice(r.indexOf(o), 1);
602
+ });
603
+ }
604
+ function ve(n, e, t, i, s, r) {
605
+ const o = m();
606
+ let d = o.next();
607
+ e ? u() : I();
608
+ function u() {
609
+ for (; !d.done; ) {
610
+ const { id: l, item: c } = d.value;
611
+ if (s.indexOf(l) === -1 && J(c, l, t, i, s))
612
+ s.push(l), d = o.next();
613
+ else
614
+ break;
615
+ }
616
+ }
617
+ function I() {
618
+ for (; !d.done; ) {
619
+ const { id: l } = d.value, c = s.indexOf(l);
620
+ if (c > -1)
621
+ s.splice(c, 1), d = o.next();
622
+ else
623
+ break;
624
+ }
625
+ }
626
+ function* m() {
627
+ if (t) {
628
+ const l = ee(n, i, r);
629
+ for (let c = l.length - 1; c > -1; c--)
630
+ yield { id: v(t, l[c]), item: e ? l[c] : void 0 };
631
+ } else {
632
+ let l = h.getDirectParentId(n);
633
+ for (; l; )
634
+ yield { id: l, item: e ? h.getItemById(l, r, i) : void 0 }, l = h.getDirectParentId(l);
635
+ }
636
+ }
637
+ }
638
+ class Fe extends a.PureComponent {
639
+ constructor() {
640
+ super(...arguments), this.state = {
641
+ visible: !1,
642
+ top: 0,
643
+ left: 0,
644
+ text: "",
645
+ operationClassName: "cancel"
646
+ };
647
+ }
648
+ /**
649
+ * @hidden
650
+ */
651
+ render() {
652
+ const e = { top: this.state.top + "px", left: this.state.left + "px" };
653
+ return this.state.visible && /* @__PURE__ */ a.createElement("div", { className: "k-header k-drag-clue", style: { ...this.props.style, ...e } }, /* @__PURE__ */ a.createElement(
654
+ T,
655
+ {
656
+ className: g("k-drag-status"),
657
+ name: this.state.operationClassName && te(this.state.operationClassName),
658
+ icon: this.state.operationClassName === "k-i-plus" ? re : this.state.operationClassName === "k-i-insert-up" ? oe : this.state.operationClassName === "k-i-insert-up" ? de : this.state.operationClassName === "k-i-insert-middle" ? le : ae
659
+ }
660
+ ), this.state.text);
661
+ }
662
+ /**
663
+ * Displays the TreeViewDragClue component.
664
+ *
665
+ * @param top - The `top` CSS position of the component.
666
+ * @param left - The `left` CSS position of the component.
667
+ * @param text - The text of the component.
668
+ * @param operationClassName - The CSS class name which is related to the specific drop operation.
669
+ */
670
+ show(e, t, i, s) {
671
+ this.setState({ visible: !0, top: e, left: t, text: i, operationClassName: s });
672
+ }
673
+ /**
674
+ * Hides the TreeViewDragClue component.
675
+ */
676
+ hide() {
677
+ this.setState({ visible: !1 });
678
+ }
679
+ }
680
+ Fe.defaultProps = { style: { display: "block", position: "absolute", zIndex: 2e4, padding: "4px 6px" } };
681
+ const _ = 6;
682
+ class _e {
683
+ /**
684
+ * @param event - The event that will be analyzed.
685
+ */
686
+ constructor(e) {
687
+ this.event = e, this.initialized = !1, this.destItemId = "", this.destTreeViewGuid = "", this.itemId = e.itemHierarchicalIndex, this.treeViewGuid = e.target.guid;
688
+ }
689
+ /**
690
+ * The method which initializes the analyzer.
691
+ * Invoke the method before you call any other methods.
692
+ *
693
+ * @returns - The analyzer object of the `drag` event.
694
+ */
695
+ init() {
696
+ return this.initialized || (this.setDestimationMeta(document.elementFromPoint(this.event.clientX, this.event.clientY)), this.initialized = !0), this;
697
+ }
698
+ /**
699
+ * Returns `true` if dropping is allowed. Otherwise, returns `false`.
700
+ */
701
+ get isDropAllowed() {
702
+ return this.initialized && this.destItemId && this.destTreeViewGuid ? !`${this.destTreeViewGuid}_${this.destItemId}_`.startsWith(`${this.treeViewGuid}_${this.itemId}_`) : !1;
703
+ }
704
+ /**
705
+ * Returns an object which contains:
706
+ * * The `itemHierarchicalIndex` of the destination item (the item below the dragged item) and
707
+ * * The `guid` of the destination TreeView (the TreeView which renders the destination item).
708
+ */
709
+ get destinationMeta() {
710
+ return { itemHierarchicalIndex: this.destItemId, treeViewGuid: this.destTreeViewGuid };
711
+ }
712
+ /**
713
+ * Returns the specific drop operation.
714
+ *
715
+ * @returns - The following values are returned:
716
+ * * `before`&mdash;Indicates that the dragged item is positioned at the beginning of the destination item.
717
+ * * `after`&mdash;Indicates that the dragged item is positioned at the end of the destination item.
718
+ * * `child`&mdash;Indicates that the dragged item is positioned in the middle of the destination item.
719
+ * * `undefined`&mdash;Indicates that dropping is not allowed.
720
+ */
721
+ getDropOperation() {
722
+ if (this.initialized && this.isDropAllowed) {
723
+ const { top: e, height: t } = this.destDomNodeWithMeta.getBoundingClientRect();
724
+ return e + t - this.event.clientY < _ ? "after" : this.event.clientY - e < _ ? "before" : "child";
725
+ } else
726
+ return;
727
+ }
728
+ setDestimationMeta(e) {
729
+ let t = e;
730
+ for (; t && !t[k]; )
731
+ t = t.parentNode;
732
+ t && t[k] && (this.destDomNodeWithMeta = t, this.destItemId = t[k], this.destTreeViewGuid = t[B]);
733
+ }
734
+ }
735
+ export {
736
+ Te as FieldsService,
737
+ z as TreeView,
738
+ _e as TreeViewDragAnalyzer,
739
+ Fe as TreeViewDragClue,
740
+ fe as TreeViewItemPropsContext,
741
+ ce as getItemIdUponKeyboardNavigation,
742
+ Pe as handleTreeViewCheckChange,
743
+ Ne as moveTreeViewItem,
744
+ ye as processTreeViewItems
745
+ };