@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
@@ -1,3 +1,7 @@
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
+ *-------------------------------------------------------------------------------------------*/
1
5
  /**
2
6
  * A helper function which moves a TreeView item in an immutable way.
3
7
  *
@@ -0,0 +1,9 @@
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 { PackageMetadata } from '@progress/kendo-licensing';
6
+ /**
7
+ * @hidden
8
+ */
9
+ export declare const packageMetadata: PackageMetadata;
package/package.json CHANGED
@@ -1,21 +1,30 @@
1
1
  {
2
2
  "name": "@progress/kendo-react-treeview",
3
- "version": "6.1.1",
3
+ "version": "7.0.0-develop.2",
4
4
  "description": "React TreeView displays hierarchical data in a traditional tree structure, supports user interaction. KendoReact TreeView package",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/telerik/kendo-react.git"
5
+ "author": "Progress",
6
+ "license": "SEE LICENSE IN LICENSE.md",
7
+ "homepage": "https://www.telerik.com/kendo-react-ui",
8
+ "main": "./index.js",
9
+ "types": "./index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./index.mjs",
13
+ "require": "./index.js"
14
+ }
15
+ },
16
+ "sideEffects": false,
17
+ "peerDependencies": {
18
+ "@progress/kendo-licensing": "^1.3.0",
19
+ "@progress/kendo-react-animation": "7.0.0-develop.2",
20
+ "@progress/kendo-react-common": "7.0.0-develop.2",
21
+ "@progress/kendo-svg-icons": "^2.0.0",
22
+ "react": "^16.8.2 || ^17.0.0 || ^18.0.0",
23
+ "react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
8
24
  },
9
- "main": "dist/npm/main.js",
10
- "types": "dist/npm/main.d.ts",
11
- "module": "dist/es/main.js",
12
- "jsnext:main": "dist/es/main.js",
13
- "scripts": {
14
- "test": "cd ../../ && npm run test -- --testPathPattern=/packages/treeview/.*",
15
- "build-package": "gulp build-package",
16
- "ssr": "gulp bundle-ssr-server bundle-ssr-client && node dist/ssr/server.js"
25
+ "dependencies": {
26
+ "prop-types": "^15.6.0"
17
27
  },
18
- "homepage": "https://www.telerik.com/kendo-react-ui",
19
28
  "keywords": [
20
29
  "Kendo UI",
21
30
  "React",
@@ -28,33 +37,15 @@
28
37
  "React component",
29
38
  "Telerik"
30
39
  ],
31
- "peerDependencies": {
32
- "@progress/kendo-licensing": "^1.3.0",
33
- "@progress/kendo-react-animation": "^6.0.0",
34
- "@progress/kendo-svg-icons": "^2.0.0",
35
- "react": "^16.8.2 || ^17.0.0 || ^18.0.0",
36
- "react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
37
- },
38
- "dependencies": {
39
- "@progress/kendo-react-common": "6.1.1",
40
- "prop-types": "^15.6.0"
41
- },
42
- "devDependencies": {
43
- "@progress/kendo-licensing": "^1.3.0",
44
- "@progress/kendo-react-animation": "6.1.1",
45
- "@progress/kendo-react-dropdowns": "6.1.1",
46
- "@progress/kendo-react-intl": "6.1.1",
47
- "@progress/kendo-react-layout": "6.1.1",
48
- "@progress/kendo-svg-icons": "^2.0.0"
49
- },
50
40
  "@progress": {
51
41
  "friendlyName": "TreeView",
52
42
  "framework": "KendoReact"
53
43
  },
54
- "author": "Progress",
55
- "license": "SEE LICENSE IN LICENSE.md",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/telerik/kendo-react.git"
47
+ },
56
48
  "publishConfig": {
57
49
  "access": "public"
58
- },
59
- "sideEffects": false
60
- }
50
+ }
51
+ }
@@ -1,3 +1,7 @@
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
+ *-------------------------------------------------------------------------------------------*/
1
5
  import { TreeViewOperationDescriptors } from './TreeViewOperationDescriptors';
2
6
  /**
3
7
  * A helper function which applies the specified operation descriptors to the data.
@@ -1,3 +1,7 @@
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
+ *-------------------------------------------------------------------------------------------*/
1
5
  /**
2
6
  * @hidden
3
7
  */
@@ -0,0 +1,9 @@
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 { TreeFieldsService } from '@progress/kendo-react-common';
6
+ /**
7
+ * @hidden
8
+ */
9
+ export default function getItemIdUponKeyboardNavigation(item: any, itemId: string, items: any[], keyCode: number, fieldsSvc: TreeFieldsService): any;
package/about.md DELETED
@@ -1,3 +0,0 @@
1
- <a href="https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-treeview&utm_content=banner" target="_blank">
2
- <img src="https://www.telerik.com/kendo-react-ui/components/npm-banner.svg" alt="KendoReact NPM Banner">
3
- </a>
@@ -1,2 +0,0 @@
1
- /* eslint-disable max-len */
2
- export {};
@@ -1,124 +0,0 @@
1
- import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- import { TreeViewProps } from './TreeViewProps';
4
- /**
5
- * @hidden
6
- */
7
- export interface TreeViewState {
8
- focusedItemId?: string;
9
- focusedItemPublicId?: any;
10
- tabbableItemId?: string;
11
- }
12
- /**
13
- * Represents the [KendoReact TreeView component]({% slug overview_treeview %}).
14
- *
15
- * @example
16
- * ```jsx
17
- * const data = [{
18
- * text: 'Furniture', expanded: true, items: [
19
- * { text: 'Tables & Chairs' }, { text: 'Sofas' }, { text: 'Occasional Furniture' }]
20
- * }, {
21
- * text: 'Decor', expanded: true, items: [
22
- * { text: 'Bed Linen' }, { text: 'Curtains & Blinds' }, { text: 'Carpets' }]
23
- * }];
24
- * class App extends React.Component {
25
- * render() {
26
- * return <TreeView data={data} />;
27
- * }
28
- * }
29
- * ReactDOM.render(<App />, document.querySelector('my-app'));
30
- * ```
31
- */
32
- export declare class TreeView extends React.Component<TreeViewProps, TreeViewState> {
33
- /**
34
- * @hidden
35
- */
36
- static propTypes: {
37
- data: PropTypes.Requireable<any[]>;
38
- animate: PropTypes.Requireable<boolean>;
39
- tabIndex: PropTypes.Requireable<number>;
40
- focusIdField: PropTypes.Requireable<string>;
41
- getHierarchicalIndexById: PropTypes.Requireable<(...args: any[]) => any>;
42
- onExpandChange: PropTypes.Requireable<(...args: any[]) => any>;
43
- onItemClick: PropTypes.Requireable<(...args: any[]) => any>;
44
- expandField: PropTypes.Requireable<string>;
45
- selectField: PropTypes.Requireable<string>;
46
- childrenField: PropTypes.Requireable<string>;
47
- hasChildrenField: PropTypes.Requireable<string>;
48
- textField: PropTypes.Requireable<string>;
49
- disableField: PropTypes.Requireable<string>;
50
- item: PropTypes.Requireable<any>;
51
- 'aria-multiselectable': (props: any, propName: string, componentName: string) => Error | null;
52
- 'aria-label': PropTypes.Requireable<string>;
53
- 'aria-labelledby': PropTypes.Requireable<string>;
54
- size: PropTypes.Requireable<"small" | "medium" | "large" | null | undefined>;
55
- dir: PropTypes.Requireable<string>;
56
- };
57
- /**
58
- * @hidden
59
- */
60
- static defaultProps: {
61
- animate: boolean;
62
- expandField: string;
63
- selectField: string;
64
- hasChildrenField: string;
65
- childrenField: string;
66
- textField: string;
67
- disableField: string;
68
- checkField: string;
69
- checkIndeterminateField: string;
70
- size: "small" | "medium" | "large" | null | undefined;
71
- };
72
- /**
73
- * @hidden
74
- */
75
- state: {
76
- focusedItemId: undefined;
77
- focusedItemPublicId: undefined;
78
- tabbableItemId: string;
79
- };
80
- private blurRequest;
81
- private fieldsSvc;
82
- private allowExplicitFocus;
83
- private treeGuid;
84
- private _element;
85
- /**
86
- * @hidden
87
- */
88
- get element(): HTMLDivElement | null;
89
- constructor(props: TreeViewProps);
90
- /**
91
- * @hidden
92
- */
93
- render(): JSX.Element;
94
- /**
95
- * @hidden
96
- */
97
- componentDidUpdate(): void;
98
- private onFocusDomElNeeded;
99
- private onCheckChange;
100
- private onExpandChange;
101
- private onPress;
102
- private onDrag;
103
- private onRelease;
104
- private onItemClick;
105
- private onFocus;
106
- private onBlur;
107
- private onKeyDown;
108
- private dispatchEventsOnKeyDown;
109
- private setFocus;
110
- private onContextMenu;
111
- private getFocusedItem;
112
- private getItemById;
113
- private dispatchCheckChange;
114
- private dispatchExpandChange;
115
- private dispatchItemClick;
116
- private refocusDueToFocusIdField;
117
- private get ariaMultiSelectable();
118
- private get data();
119
- private focusDomItem;
120
- /**
121
- * Returns the `guid` which is associated with the TreeView.
122
- */
123
- get guid(): string;
124
- }
@@ -1,334 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import * as React from 'react';
17
- import * as PropTypes from 'prop-types';
18
- import { Keys, dispatchEvent, guid, kendoThemeMaps, classNames, resolveItemId, isEnabledAndAllParentsEnabled, hasChildren, TreeFieldsService as FieldsService, treeIdUtils } from '@progress/kendo-react-common';
19
- import nav from './utils/getItemIdUponKeyboardNavigation';
20
- import { TreeViewItem } from './TreeViewItem';
21
- import { validatePackage } from '@progress/kendo-react-common';
22
- import { packageMetadata } from './package-metadata';
23
- import { CHECK_FIELD, CHECK_INDETERMINATE_FIELD, CHILDREN_FIELD, DISABLED_FIELD, EXPAND_FIELD, HAS_CHILDREN_FIELD, SELECT_FIELD, TEXT_FIELD } from './utils/consts';
24
- var sizeMap = kendoThemeMaps.sizeMap;
25
- /**
26
- * Represents the [KendoReact TreeView component]({% slug overview_treeview %}).
27
- *
28
- * @example
29
- * ```jsx
30
- * const data = [{
31
- * text: 'Furniture', expanded: true, items: [
32
- * { text: 'Tables & Chairs' }, { text: 'Sofas' }, { text: 'Occasional Furniture' }]
33
- * }, {
34
- * text: 'Decor', expanded: true, items: [
35
- * { text: 'Bed Linen' }, { text: 'Curtains & Blinds' }, { text: 'Carpets' }]
36
- * }];
37
- * class App extends React.Component {
38
- * render() {
39
- * return <TreeView data={data} />;
40
- * }
41
- * }
42
- * ReactDOM.render(<App />, document.querySelector('my-app'));
43
- * ```
44
- */
45
- var TreeView = /** @class */ (function (_super) {
46
- __extends(TreeView, _super);
47
- function TreeView(props) {
48
- var _this = _super.call(this, props) || this;
49
- /**
50
- * @hidden
51
- */
52
- _this.state = { focusedItemId: undefined, focusedItemPublicId: undefined, tabbableItemId: treeIdUtils.ZERO_LEVEL_ZERO_NODE_ID };
53
- _this.fieldsSvc = null;
54
- // When there is a change in state.focusedItemId, calling focus() on the dom element of the focused item
55
- // is most often not needed, because the browser focuses the element on its own.
56
- // https://github.com/telerik/kendo-react/issues/190
57
- _this.allowExplicitFocus = false;
58
- _this.treeGuid = guid();
59
- _this._element = null;
60
- _this.onFocusDomElNeeded = function (domItem) {
61
- if (_this.allowExplicitFocus) {
62
- _this.focusDomItem(domItem);
63
- }
64
- };
65
- _this.onCheckChange = function (event, item, itemId) {
66
- _this.setFocus(itemId);
67
- _this.dispatchCheckChange(event, item, itemId);
68
- };
69
- _this.onExpandChange = function (event, item, itemId) {
70
- _this.setFocus(itemId);
71
- _this.dispatchExpandChange(event, item, itemId);
72
- };
73
- _this.onPress = function (_event, item, itemId) {
74
- if (_this.props.onItemDragStart) {
75
- _this.props.onItemDragStart.call(undefined, { target: _this, item: item, itemHierarchicalIndex: itemId });
76
- }
77
- };
78
- _this.onDrag = function (event, item, itemId) {
79
- var pageX = event.pageX, pageY = event.pageY, clientX = event.clientX, clientY = event.clientY;
80
- if (_this.props.onItemDragOver) {
81
- _this.props.onItemDragOver.call(undefined, {
82
- target: _this,
83
- item: item,
84
- itemHierarchicalIndex: itemId,
85
- pageX: pageX,
86
- pageY: pageY,
87
- clientX: clientX,
88
- clientY: clientY
89
- });
90
- }
91
- };
92
- _this.onRelease = function (event, item, itemId) {
93
- var pageX = event.pageX, pageY = event.pageY, clientX = event.clientX, clientY = event.clientY;
94
- if (_this.props.onItemDragEnd) {
95
- _this.props.onItemDragEnd.call(undefined, {
96
- target: _this,
97
- item: item,
98
- itemHierarchicalIndex: itemId,
99
- pageX: pageX,
100
- pageY: pageY,
101
- clientX: clientX,
102
- clientY: clientY
103
- });
104
- }
105
- };
106
- _this.onItemClick = function (event, item, itemId) {
107
- _this.setFocus(itemId);
108
- _this.dispatchItemClick(event, item, itemId);
109
- };
110
- _this.onFocus = function () {
111
- clearTimeout(_this.blurRequest);
112
- if (_this.state.focusedItemId === undefined && _this.data.length) {
113
- _this.setFocus(_this.state.tabbableItemId);
114
- }
115
- };
116
- _this.onBlur = function () {
117
- clearTimeout(_this.blurRequest);
118
- _this.blurRequest = window.setTimeout(function () { return _this.setFocus(undefined); }, 0);
119
- };
120
- _this.onKeyDown = function (event) {
121
- var focusedItem = _this.getFocusedItem();
122
- if (focusedItem && _this.fieldsSvc) {
123
- var newItemId = nav(focusedItem, _this.state.focusedItemId, _this.data, event.keyCode, _this.fieldsSvc);
124
- if (newItemId !== _this.state.focusedItemId) {
125
- // This disables the auto-scroll. The scroll is achieved via item focusing.
126
- event.preventDefault();
127
- _this.allowExplicitFocus = true;
128
- _this.setFocus(newItemId);
129
- }
130
- _this.dispatchEventsOnKeyDown(event, focusedItem);
131
- }
132
- };
133
- _this.onContextMenu = function (event, item, itemId) {
134
- if (_this.props.onContextMenu) {
135
- var ev = {
136
- target: _this,
137
- syntheticEvent: event,
138
- nativeEvent: event.nativeEvent,
139
- item: item,
140
- itemID: itemId
141
- };
142
- _this.props.onContextMenu.call(undefined, ev);
143
- }
144
- };
145
- validatePackage(packageMetadata);
146
- return _this;
147
- }
148
- Object.defineProperty(TreeView.prototype, "element", {
149
- /**
150
- * @hidden
151
- */
152
- get: function () {
153
- return this._element;
154
- },
155
- enumerable: false,
156
- configurable: true
157
- });
158
- /**
159
- * @hidden
160
- */
161
- TreeView.prototype.render = function () {
162
- var _a;
163
- var _this = this;
164
- this.fieldsSvc = new FieldsService(this.props);
165
- var _b = this.props, size = _b.size, className = _b.className;
166
- return (React.createElement("div", { className: classNames('k-treeview', (_a = {},
167
- _a["k-treeview-".concat(sizeMap[size] || size)] = size,
168
- _a['k-user-select-none'] = this.props.draggable,
169
- _a['k-rtl'] = this.props.dir === 'rtl',
170
- _a), className), onKeyDown: this.onKeyDown, onFocus: this.onFocus, onBlur: this.onBlur, role: "tree", "aria-multiselectable": this.ariaMultiSelectable ? true : undefined, "aria-label": this.props['aria-label'], "aria-labelledby": this.props['aria-labelledby'], ref: function (element) { return _this._element = element; }, tabIndex: this.props.tabIndex },
171
- React.createElement("ul", { className: "k-treeview-lines k-treeview-group", role: "group" }, this.data.map(function (item, index) {
172
- return (React.createElement(TreeViewItem, { item: item, position: index === 0 ? 'top' : index === _this.data.length - 1 ? 'bot' : 'mid', itemId: index.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, onExpandChange: _this.onExpandChange, onCheckChange: _this.onCheckChange, onContextMenu: _this.onContextMenu, key: index, size: size, isRtl: _this.props.dir === 'rtl' }));
173
- }))));
174
- };
175
- /**
176
- * @hidden
177
- */
178
- TreeView.prototype.componentDidUpdate = function () {
179
- this.allowExplicitFocus = false;
180
- this.refocusDueToFocusIdField();
181
- };
182
- TreeView.prototype.dispatchEventsOnKeyDown = function (event, focusedItem) {
183
- var _this = this;
184
- if (this.fieldsSvc === null) {
185
- return;
186
- }
187
- // isEnabled is the most expensive op and that is why is left last.
188
- var isEnabled = function () {
189
- return _this.fieldsSvc && isEnabledAndAllParentsEnabled(_this.state.focusedItemId, _this.data, _this.fieldsSvc);
190
- };
191
- if (event.keyCode === Keys.left && this.fieldsSvc.expanded(focusedItem) && isEnabled()) {
192
- this.dispatchExpandChange(event, focusedItem, this.state.focusedItemId);
193
- }
194
- else if (event.keyCode === Keys.right && !this.fieldsSvc.expanded(focusedItem) &&
195
- (this.fieldsSvc.hasChildren(focusedItem) || hasChildren(focusedItem, this.props.childrenField)) && isEnabled()) {
196
- this.dispatchExpandChange(event, focusedItem, this.state.focusedItemId);
197
- }
198
- else if (event.keyCode === Keys.enter && isEnabled()) {
199
- this.dispatchItemClick(event, focusedItem, this.state.focusedItemId);
200
- }
201
- else if (event.keyCode === Keys.space && isEnabled()) {
202
- // W/o preventDefault() long TreeViews gets incorrectly scrolled.
203
- event.preventDefault();
204
- this.dispatchCheckChange(event, focusedItem, this.state.focusedItemId);
205
- }
206
- };
207
- TreeView.prototype.setFocus = function (focusedItemId) {
208
- if (focusedItemId && this.fieldsSvc) {
209
- if (this.fieldsSvc.focusIdField) {
210
- var item = this.getItemById(focusedItemId);
211
- this.setState({ focusedItemId: focusedItemId, focusedItemPublicId: this.fieldsSvc.focusId(item) });
212
- }
213
- else {
214
- this.setState({ focusedItemId: focusedItemId });
215
- }
216
- }
217
- else {
218
- this.setState(function (state) {
219
- return {
220
- focusedItemId: undefined,
221
- focusedItemPublicId: undefined,
222
- tabbableItemId: state.focusedItemId
223
- };
224
- });
225
- }
226
- };
227
- TreeView.prototype.getFocusedItem = function () {
228
- return this.state.focusedItemId ? this.getItemById(this.state.focusedItemId) : undefined;
229
- };
230
- TreeView.prototype.getItemById = function (itemId) {
231
- return treeIdUtils.getItemById(itemId, this.data, this.props.childrenField || CHILDREN_FIELD);
232
- };
233
- TreeView.prototype.dispatchCheckChange = function (dispatchedEvent, item, itemId) {
234
- dispatchEvent(this.props.onCheckChange, dispatchedEvent, this, { item: item, itemHierarchicalIndex: itemId });
235
- };
236
- TreeView.prototype.dispatchExpandChange = function (dispatchedEvent, item, itemId) {
237
- dispatchEvent(this.props.onExpandChange, dispatchedEvent, this, { item: item, itemHierarchicalIndex: itemId });
238
- };
239
- TreeView.prototype.dispatchItemClick = function (dispatchedEvent, item, itemId) {
240
- dispatchEvent(this.props.onItemClick, dispatchedEvent, this, { item: item, itemHierarchicalIndex: itemId });
241
- };
242
- TreeView.prototype.refocusDueToFocusIdField = function () {
243
- if (this.fieldsSvc && this.fieldsSvc.focusIdField) {
244
- var focusedItemPublicId = this.state.focusedItemPublicId;
245
- if (focusedItemPublicId) {
246
- var focusedItemId = this.props.getFocusHierarchicalIndex ?
247
- this.props.getFocusHierarchicalIndex(focusedItemPublicId) :
248
- resolveItemId(focusedItemPublicId, this.fieldsSvc.focusIdField, this.data, this.props.childrenField);
249
- if (focusedItemId !== this.state.focusedItemId) {
250
- this.allowExplicitFocus = true;
251
- this.setState({ focusedItemId: focusedItemId });
252
- }
253
- }
254
- }
255
- };
256
- Object.defineProperty(TreeView.prototype, "ariaMultiSelectable", {
257
- get: function () {
258
- return this.props['aria-multiselectable'] === true || this.props['aria-multiselectable'] === 'true';
259
- },
260
- enumerable: false,
261
- configurable: true
262
- });
263
- Object.defineProperty(TreeView.prototype, "data", {
264
- get: function () {
265
- return this.props.data || [];
266
- },
267
- enumerable: false,
268
- configurable: true
269
- });
270
- TreeView.prototype.focusDomItem = function (domItem) {
271
- domItem.focus();
272
- };
273
- Object.defineProperty(TreeView.prototype, "guid", {
274
- /**
275
- * Returns the `guid` which is associated with the TreeView.
276
- */
277
- get: function () {
278
- return this.treeGuid;
279
- },
280
- enumerable: false,
281
- configurable: true
282
- });
283
- /**
284
- * @hidden
285
- */
286
- TreeView.propTypes = {
287
- data: PropTypes.arrayOf(PropTypes.any),
288
- animate: PropTypes.bool,
289
- tabIndex: PropTypes.number,
290
- focusIdField: PropTypes.string,
291
- getHierarchicalIndexById: PropTypes.func,
292
- onExpandChange: PropTypes.func,
293
- onItemClick: PropTypes.func,
294
- expandField: PropTypes.string,
295
- selectField: PropTypes.string,
296
- childrenField: PropTypes.string,
297
- hasChildrenField: PropTypes.string,
298
- textField: PropTypes.string,
299
- disableField: PropTypes.string,
300
- item: PropTypes.any,
301
- 'aria-multiselectable': function (props, propName, componentName) {
302
- if (props[propName] !== undefined
303
- && props[propName] !== true
304
- && props[propName] !== false
305
- && props[propName] !== 'true'
306
- && props[propName] !== 'false') {
307
- return new Error('Invalid prop `' + propName + '` supplied to' +
308
- ' `' + componentName + '`. Validation failed.');
309
- }
310
- return null;
311
- },
312
- 'aria-label': PropTypes.string,
313
- 'aria-labelledby': PropTypes.string,
314
- size: PropTypes.oneOf([null, 'small', 'medium', 'large']),
315
- dir: PropTypes.string
316
- };
317
- /**
318
- * @hidden
319
- */
320
- TreeView.defaultProps = {
321
- animate: true,
322
- expandField: EXPAND_FIELD,
323
- selectField: SELECT_FIELD,
324
- hasChildrenField: HAS_CHILDREN_FIELD,
325
- childrenField: CHILDREN_FIELD,
326
- textField: TEXT_FIELD,
327
- disableField: DISABLED_FIELD,
328
- checkField: CHECK_FIELD,
329
- checkIndeterminateField: CHECK_INDETERMINATE_FIELD,
330
- size: 'medium'
331
- };
332
- return TreeView;
333
- }(React.Component));
334
- export { TreeView };