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