@progress/kendo-react-treelist 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 (176) hide show
  1. package/LICENSE.md +1 -1
  2. package/ScrollMode.d.ts +5 -0
  3. package/{dist/es/TreeList.d.ts → TreeList.d.ts} +6 -2
  4. package/{dist/es/TreeListNoRecords.d.ts → TreeListNoRecords.d.ts} +4 -0
  5. package/TreeListToolbar.d.ts +15 -0
  6. package/cells/EditCells/TreeListBooleanEditor.d.ts +11 -0
  7. package/cells/EditCells/TreeListDateEditor.d.ts +11 -0
  8. package/{dist/es/cells → cells}/EditCells/TreeListNumericEditor.d.ts +4 -0
  9. package/cells/EditCells/TreeListTextEditor.d.ts +11 -0
  10. package/{dist/npm/cells → cells}/FilterCells/TreeListBooleanFilter.d.ts +4 -0
  11. package/{dist/npm/cells → cells}/FilterCells/TreeListDateFilter.d.ts +4 -0
  12. package/{dist/es/cells → cells}/FilterCells/TreeListNumericFilter.d.ts +4 -0
  13. package/{dist/es/cells → cells}/FilterCells/TreeListTextFilter.d.ts +4 -0
  14. package/{dist/npm/cells → cells}/FilterCells/utils.d.ts +4 -0
  15. package/cells/TreeListCell.d.ts +9 -0
  16. package/cells/TreeListSelectionCell.d.ts +11 -0
  17. package/{dist/es/constants → constants}/index.d.ts +4 -0
  18. package/dist/cdn/js/kendo-react-treelist.js +5 -1
  19. package/header/TreeListHeaderCell.d.ts +7 -0
  20. package/header/TreeListHeaderSelectionCell.d.ts +15 -0
  21. package/index.d.ts +38 -0
  22. package/index.js +5 -0
  23. package/index.mjs +1181 -0
  24. package/interfaces/DataItemWrapper.d.ts +14 -0
  25. package/{dist/npm/interfaces → interfaces}/TreeListCellProps.d.ts +4 -1
  26. package/{dist/es/interfaces → interfaces}/TreeListColumnProps.d.ts +4 -0
  27. package/interfaces/TreeListFilterCellProps.d.ts +10 -0
  28. package/interfaces/TreeListFilterOperator.d.ts +10 -0
  29. package/interfaces/TreeListHeaderCellProps.d.ts +10 -0
  30. package/interfaces/TreeListNoRecordsProps.d.ts +13 -0
  31. package/{dist/es/interfaces → interfaces}/TreeListProps.d.ts +4 -1
  32. package/{dist/es/interfaces → interfaces}/TreeListRowProps.d.ts +4 -1
  33. package/{dist/es/interfaces → interfaces}/TreeListSelectableSettings.d.ts +5 -1
  34. package/interfaces/TreeListSortSettings.d.ts +13 -0
  35. package/interfaces/TreeListToolbarProps.d.ts +13 -0
  36. package/{dist/es/interfaces → interfaces}/events.d.ts +4 -0
  37. package/{dist/npm/messages → messages}/index.d.ts +4 -0
  38. package/package-metadata.d.ts +9 -0
  39. package/package.json +36 -57
  40. package/{dist/es/rows → rows}/TreeListDraggableRow.d.ts +5 -1
  41. package/rows/TreeListRow.d.ts +10 -0
  42. package/{dist/npm/utils → utils}/index.d.ts +4 -0
  43. package/about.md +0 -3
  44. package/debug.log +0 -3
  45. package/dist/es/ScrollMode.d.ts +0 -1
  46. package/dist/es/ScrollMode.js +0 -1
  47. package/dist/es/TreeList.js +0 -632
  48. package/dist/es/TreeListNoRecords.js +0 -37
  49. package/dist/es/TreeListToolbar.d.ts +0 -11
  50. package/dist/es/TreeListToolbar.js +0 -33
  51. package/dist/es/cells/EditCells/TreeListBooleanEditor.d.ts +0 -8
  52. package/dist/es/cells/EditCells/TreeListBooleanEditor.js +0 -41
  53. package/dist/es/cells/EditCells/TreeListDateEditor.d.ts +0 -8
  54. package/dist/es/cells/EditCells/TreeListDateEditor.js +0 -40
  55. package/dist/es/cells/EditCells/TreeListNumericEditor.js +0 -41
  56. package/dist/es/cells/EditCells/TreeListTextEditor.d.ts +0 -8
  57. package/dist/es/cells/EditCells/TreeListTextEditor.js +0 -39
  58. package/dist/es/cells/FilterCells/TreeListBooleanFilter.d.ts +0 -10
  59. package/dist/es/cells/FilterCells/TreeListBooleanFilter.js +0 -30
  60. package/dist/es/cells/FilterCells/TreeListDateFilter.d.ts +0 -10
  61. package/dist/es/cells/FilterCells/TreeListDateFilter.js +0 -30
  62. package/dist/es/cells/FilterCells/TreeListNumericFilter.js +0 -30
  63. package/dist/es/cells/FilterCells/TreeListTextFilter.js +0 -30
  64. package/dist/es/cells/FilterCells/utils.d.ts +0 -38
  65. package/dist/es/cells/FilterCells/utils.js +0 -66
  66. package/dist/es/cells/TreeListCell.d.ts +0 -6
  67. package/dist/es/cells/TreeListCell.js +0 -61
  68. package/dist/es/cells/TreeListSelectionCell.d.ts +0 -8
  69. package/dist/es/cells/TreeListSelectionCell.js +0 -31
  70. package/dist/es/constants/index.js +0 -7
  71. package/dist/es/header/TreeListHeaderCell.d.ts +0 -3
  72. package/dist/es/header/TreeListHeaderCell.js +0 -14
  73. package/dist/es/header/TreeListHeaderSelectionCell.d.ts +0 -11
  74. package/dist/es/header/TreeListHeaderSelectionCell.js +0 -45
  75. package/dist/es/interfaces/DataItemWrapper.d.ts +0 -10
  76. package/dist/es/interfaces/DataItemWrapper.js +0 -1
  77. package/dist/es/interfaces/TreeListCellProps.d.ts +0 -42
  78. package/dist/es/interfaces/TreeListCellProps.js +0 -1
  79. package/dist/es/interfaces/TreeListColumnProps.js +0 -1
  80. package/dist/es/interfaces/TreeListFilterCellProps.d.ts +0 -6
  81. package/dist/es/interfaces/TreeListFilterCellProps.js +0 -1
  82. package/dist/es/interfaces/TreeListFilterOperator.d.ts +0 -6
  83. package/dist/es/interfaces/TreeListFilterOperator.js +0 -1
  84. package/dist/es/interfaces/TreeListHeaderCellProps.d.ts +0 -6
  85. package/dist/es/interfaces/TreeListHeaderCellProps.js +0 -1
  86. package/dist/es/interfaces/TreeListNoRecordsProps.d.ts +0 -10
  87. package/dist/es/interfaces/TreeListNoRecordsProps.js +0 -1
  88. package/dist/es/interfaces/TreeListProps.js +0 -1
  89. package/dist/es/interfaces/TreeListRowProps.js +0 -1
  90. package/dist/es/interfaces/TreeListSelectableSettings.js +0 -2
  91. package/dist/es/interfaces/TreeListSortSettings.d.ts +0 -9
  92. package/dist/es/interfaces/TreeListSortSettings.js +0 -1
  93. package/dist/es/interfaces/TreeListToolbarProps.d.ts +0 -10
  94. package/dist/es/interfaces/TreeListToolbarProps.js +0 -1
  95. package/dist/es/interfaces/events.js +0 -1
  96. package/dist/es/main.d.ts +0 -34
  97. package/dist/es/main.js +0 -23
  98. package/dist/es/messages/index.d.ts +0 -120
  99. package/dist/es/messages/index.js +0 -121
  100. package/dist/es/package-metadata.d.ts +0 -5
  101. package/dist/es/package-metadata.js +0 -11
  102. package/dist/es/rows/TreeListDraggableRow.js +0 -171
  103. package/dist/es/rows/TreeListRow.d.ts +0 -6
  104. package/dist/es/rows/TreeListRow.js +0 -31
  105. package/dist/es/utils/index.d.ts +0 -17
  106. package/dist/es/utils/index.js +0 -68
  107. package/dist/npm/ScrollMode.d.ts +0 -1
  108. package/dist/npm/ScrollMode.js +0 -2
  109. package/dist/npm/TreeList.d.ts +0 -133
  110. package/dist/npm/TreeList.js +0 -635
  111. package/dist/npm/TreeListNoRecords.d.ts +0 -12
  112. package/dist/npm/TreeListNoRecords.js +0 -40
  113. package/dist/npm/TreeListToolbar.d.ts +0 -11
  114. package/dist/npm/TreeListToolbar.js +0 -36
  115. package/dist/npm/cells/EditCells/TreeListBooleanEditor.d.ts +0 -8
  116. package/dist/npm/cells/EditCells/TreeListBooleanEditor.js +0 -45
  117. package/dist/npm/cells/EditCells/TreeListDateEditor.d.ts +0 -8
  118. package/dist/npm/cells/EditCells/TreeListDateEditor.js +0 -44
  119. package/dist/npm/cells/EditCells/TreeListNumericEditor.d.ts +0 -8
  120. package/dist/npm/cells/EditCells/TreeListNumericEditor.js +0 -45
  121. package/dist/npm/cells/EditCells/TreeListTextEditor.d.ts +0 -8
  122. package/dist/npm/cells/EditCells/TreeListTextEditor.js +0 -43
  123. package/dist/npm/cells/FilterCells/TreeListBooleanFilter.js +0 -34
  124. package/dist/npm/cells/FilterCells/TreeListDateFilter.js +0 -34
  125. package/dist/npm/cells/FilterCells/TreeListNumericFilter.d.ts +0 -10
  126. package/dist/npm/cells/FilterCells/TreeListNumericFilter.js +0 -34
  127. package/dist/npm/cells/FilterCells/TreeListTextFilter.d.ts +0 -10
  128. package/dist/npm/cells/FilterCells/TreeListTextFilter.js +0 -34
  129. package/dist/npm/cells/FilterCells/utils.js +0 -70
  130. package/dist/npm/cells/TreeListCell.d.ts +0 -6
  131. package/dist/npm/cells/TreeListCell.js +0 -65
  132. package/dist/npm/cells/TreeListSelectionCell.d.ts +0 -8
  133. package/dist/npm/cells/TreeListSelectionCell.js +0 -35
  134. package/dist/npm/constants/index.d.ts +0 -6
  135. package/dist/npm/constants/index.js +0 -10
  136. package/dist/npm/header/TreeListHeaderCell.d.ts +0 -3
  137. package/dist/npm/header/TreeListHeaderCell.js +0 -18
  138. package/dist/npm/header/TreeListHeaderSelectionCell.d.ts +0 -11
  139. package/dist/npm/header/TreeListHeaderSelectionCell.js +0 -48
  140. package/dist/npm/interfaces/DataItemWrapper.d.ts +0 -10
  141. package/dist/npm/interfaces/DataItemWrapper.js +0 -2
  142. package/dist/npm/interfaces/TreeListCellProps.js +0 -2
  143. package/dist/npm/interfaces/TreeListColumnProps.d.ts +0 -41
  144. package/dist/npm/interfaces/TreeListColumnProps.js +0 -2
  145. package/dist/npm/interfaces/TreeListFilterCellProps.d.ts +0 -6
  146. package/dist/npm/interfaces/TreeListFilterCellProps.js +0 -2
  147. package/dist/npm/interfaces/TreeListFilterOperator.d.ts +0 -6
  148. package/dist/npm/interfaces/TreeListFilterOperator.js +0 -2
  149. package/dist/npm/interfaces/TreeListHeaderCellProps.d.ts +0 -6
  150. package/dist/npm/interfaces/TreeListHeaderCellProps.js +0 -2
  151. package/dist/npm/interfaces/TreeListNoRecordsProps.d.ts +0 -10
  152. package/dist/npm/interfaces/TreeListNoRecordsProps.js +0 -2
  153. package/dist/npm/interfaces/TreeListProps.d.ts +0 -234
  154. package/dist/npm/interfaces/TreeListProps.js +0 -2
  155. package/dist/npm/interfaces/TreeListRowProps.d.ts +0 -93
  156. package/dist/npm/interfaces/TreeListRowProps.js +0 -2
  157. package/dist/npm/interfaces/TreeListSelectableSettings.d.ts +0 -18
  158. package/dist/npm/interfaces/TreeListSelectableSettings.js +0 -3
  159. package/dist/npm/interfaces/TreeListSortSettings.d.ts +0 -9
  160. package/dist/npm/interfaces/TreeListSortSettings.js +0 -2
  161. package/dist/npm/interfaces/TreeListToolbarProps.d.ts +0 -10
  162. package/dist/npm/interfaces/TreeListToolbarProps.js +0 -2
  163. package/dist/npm/interfaces/events.d.ts +0 -265
  164. package/dist/npm/interfaces/events.js +0 -2
  165. package/dist/npm/main.d.ts +0 -34
  166. package/dist/npm/main.js +0 -63
  167. package/dist/npm/messages/index.js +0 -124
  168. package/dist/npm/package-metadata.d.ts +0 -5
  169. package/dist/npm/package-metadata.js +0 -14
  170. package/dist/npm/rows/TreeListDraggableRow.d.ts +0 -32
  171. package/dist/npm/rows/TreeListDraggableRow.js +0 -174
  172. package/dist/npm/rows/TreeListRow.d.ts +0 -6
  173. package/dist/npm/rows/TreeListRow.js +0 -34
  174. package/dist/npm/utils/index.js +0 -74
  175. package/dist/systemjs/kendo-react-treelist.js +0 -1
  176. package/e2e-next/basic.tests.ts +0 -24
@@ -1,632 +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
- var __assign = (this && this.__assign) || function () {
17
- __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
- t[p] = s[p];
22
- }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- var __rest = (this && this.__rest) || function (s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
- import * as React from 'react';
48
- import * as PropTypes from 'prop-types';
49
- import { classNames, noop, getter, guid, canUseDOM, memoizeOne, validatePackage, getNestedValue } from '@progress/kendo-react-common';
50
- import { Header, HeaderRow, FilterRow as TreeListFilterRow, ColumnResize, CommonDragLogic, DragClue, DropClue, tableColumnsVirtualization, readColumns, mapColumns, tableKeyboardNavigation, TableKeyboardNavigationContext, tableKeyboardNavigationScopeAttributes, tableKeyboardNavigationTools as navigationTools, tableKeyboardNavigationBodyAttributes, getSelectionOptions, TableSelection, flatData } from '@progress/kendo-react-data-tools';
51
- import { setHeaderRowsTop, tableRowsVirtualization } from './utils/index';
52
- import { TreeListCell } from './cells/TreeListCell';
53
- import { TreeListNoRecords } from './TreeListNoRecords';
54
- import { TreeListRow } from './rows/TreeListRow';
55
- import { packageMetadata } from './package-metadata';
56
- /**
57
- * Represents the [KendoReact TreeList component]({% slug getstarted_treelist %}).
58
- */
59
- var TreeList = /** @class */ (function (_super) {
60
- __extends(TreeList, _super);
61
- function TreeList(props) {
62
- var _this = _super.call(this, props) || this;
63
- _this.wrapperScrollLeft = 0;
64
- _this.wrapperScrollTop = 0;
65
- _this.updateOnScroll = false;
66
- _this.tbodyOffsetTop = 0;
67
- _this.prevData = [];
68
- _this.flattedData = [];
69
- _this.extendedColumn = [];
70
- _this.columnsMap = [];
71
- _this.element = null;
72
- _this._treeListId = guid();
73
- _this.contextStateRef = { current: undefined };
74
- _this.navigationStateRef = { current: undefined };
75
- /**
76
- * Method to allow the scroll to be set to a specific row index.
77
- *
78
- * @param options - Object, containing the rowIndex to which is going to be scrolled.
79
- */
80
- _this.scrollIntoView = function (options) {
81
- if (!_this.element) {
82
- return;
83
- }
84
- var _a = options.rowIndex, rowIndex = _a === void 0 ? 0 : _a;
85
- var _b = _this.props, scrollable = _b.scrollable, _c = _b.rowHeight, rowHeight = _c === void 0 ? 0 : _c;
86
- if (scrollable === 'virtual' || rowHeight) {
87
- _this.element.scroll(0, (rowIndex - 1) * rowHeight);
88
- }
89
- else {
90
- var selectedRow = _this.element.querySelector("tbody > tr:nth-child(".concat(rowIndex, ")"));
91
- if (selectedRow) {
92
- var offsetTop = selectedRow.offsetTop - _this.tbodyOffsetTop;
93
- _this.element.scroll(0, offsetTop);
94
- }
95
- }
96
- };
97
- _this.getExtendedColumn = memoizeOne(function (columns, idPrefix) {
98
- return readColumns(columns, { prevId: 0, idPrefix: idPrefix });
99
- });
100
- _this.getColumnsMap = memoizeOne(function (extendedColumn) {
101
- return mapColumns(extendedColumn);
102
- });
103
- _this.onKeyDown = function (event) {
104
- tableKeyboardNavigation.onKeyDown(event, {
105
- contextStateRef: _this.contextStateRef,
106
- navigationStateRef: _this.navigationStateRef
107
- });
108
- if (_this.props.onKeyDown) {
109
- var _a = getSelectionOptions(_this.props.selectable), mode = _a.mode, cell = _a.cell;
110
- var ev = __assign({ dataItems: _this.getLeafDataItems(), mode: mode, cell: cell, componentId: _this._treeListId, selectedField: _this.props.selectedField }, _this.getArguments(event));
111
- _this.props.onKeyDown.call(undefined, ev);
112
- }
113
- };
114
- _this.onFocus = function (event) {
115
- tableKeyboardNavigation.onFocus(event, {
116
- contextStateRef: _this.contextStateRef
117
- });
118
- };
119
- _this.onRowDrag = function (event) {
120
- if (_this.props.onRowDrag) {
121
- _this.props.onRowDrag.call(undefined, __assign(__assign({}, event), { target: _this }));
122
- }
123
- };
124
- _this.onRowDrop = function (event) {
125
- if (_this.props.onRowDrop) {
126
- _this.props.onRowDrop.call(undefined, __assign(__assign({}, event), { target: _this }));
127
- }
128
- };
129
- _this.columnReorder = function (prev, next, nativeEvent) {
130
- var _a;
131
- var depth = _this.extendedColumn[prev].depth;
132
- var end = function (index) {
133
- do {
134
- index++;
135
- } while (index < _this.extendedColumn.length && _this.extendedColumn[index].depth > depth);
136
- return index;
137
- };
138
- var spliced = _this.extendedColumn.splice(prev, end(prev) - prev);
139
- (_a = _this.extendedColumn).splice.apply(_a, __spreadArray([prev < next ? end(next - spliced.length) : next, 0], spliced, false));
140
- _this.extendedColumn.filter(function (q) { return q.declarationIndex >= 0; }).forEach(function (c, i) { return c.orderIndex = i; });
141
- if (_this.props.onColumnReorder) {
142
- var event_1 = {
143
- target: _this,
144
- columns: _this.columns,
145
- nativeEvent: nativeEvent
146
- };
147
- _this.props.onColumnReorder.call(undefined, event_1);
148
- }
149
- };
150
- _this.onResize = function (index, newWidth, oldWidth, nativeEvent, end) {
151
- if (_this.props.onColumnResize) {
152
- var sumWidth = _this.extendedColumn.filter(function (c) { return c.children.length === 0; }).
153
- reduce(function (acc, column) { return acc += parseFloat(String(column.width)); }, 0);
154
- var event_2 = {
155
- columns: _this.columns,
156
- totalWidth: sumWidth,
157
- index: index,
158
- nativeEvent: nativeEvent,
159
- newWidth: newWidth,
160
- oldWidth: oldWidth,
161
- end: end,
162
- target: _this
163
- };
164
- _this.props.onColumnResize.call(undefined, event_2);
165
- }
166
- };
167
- _this.handleOnScroll = function (event) {
168
- var scrollLeft = event.currentTarget.scrollLeft;
169
- var scrollTop = event.currentTarget.scrollTop;
170
- var _a = _this.props, columnVirtualization = _a.columnVirtualization, scrollable = _a.scrollable, _b = _a.rowHeight, rowHeight = _b === void 0 ? 0 : _b;
171
- var minTopChange = rowHeight;
172
- var minLeftChange = 0;
173
- var shouldForceUpdate = false;
174
- if (columnVirtualization && Math.abs(_this.wrapperScrollLeft - scrollLeft) > minLeftChange) {
175
- _this.wrapperScrollLeft = scrollLeft;
176
- shouldForceUpdate = true;
177
- }
178
- if (scrollable === 'virtual' && Math.abs(_this.wrapperScrollTop - scrollTop) > minTopChange) {
179
- _this.wrapperScrollTop = scrollTop;
180
- shouldForceUpdate = true;
181
- }
182
- if (shouldForceUpdate) {
183
- _this.updateOnScroll = true;
184
- _this.forceUpdate();
185
- }
186
- };
187
- _this.calculateSizes = function (div) {
188
- if (!div || _this.props.scrollable === 'none') {
189
- return;
190
- }
191
- var children = Array.from(div.childNodes);
192
- var table = children.find(function (n) { return n.nodeName === 'TABLE'; });
193
- var toolbar = _this.props.toolbar &&
194
- children.find(function (n) {
195
- return n.nodeType === 1 && n.classList.contains('k-grid-toolbar');
196
- });
197
- var toolbarHeight = 0;
198
- if (toolbar) {
199
- var boxSizing = toolbar.style.boxSizing;
200
- toolbar.style.boxSizing = 'border-box';
201
- toolbarHeight = parseFloat(String(window.getComputedStyle(toolbar).height)) ||
202
- toolbar.offsetHeight;
203
- toolbar.style.boxSizing = boxSizing;
204
- if (!toolbar.getAttribute('style')) {
205
- toolbar.removeAttribute('style');
206
- }
207
- }
208
- _this.tbodyOffsetTop = table.tBodies[0].offsetTop;
209
- setHeaderRowsTop(table, toolbarHeight);
210
- };
211
- _this.itemChange = function (event) {
212
- var itemChange = _this.props.onItemChange;
213
- if (event.field === _this.props.expandField) {
214
- var expandChange = _this.props.onExpandChange;
215
- if (expandChange) {
216
- var expandEvent = __assign(__assign({}, _this.getArguments(event.syntheticEvent)), { dataItem: event.dataItem, level: event.level, value: event.value });
217
- expandChange.call(undefined, expandEvent);
218
- }
219
- return;
220
- }
221
- if (itemChange) {
222
- var itemChangeEvent = __assign(__assign({}, _this.getArguments(event.syntheticEvent)), { dataItem: event.dataItem, level: event.level, field: event.field, value: event.value });
223
- itemChange.call(undefined, itemChangeEvent);
224
- }
225
- };
226
- _this.onHeaderSelectionChange = function (event) {
227
- if (_this.props.onHeaderSelectionChange) {
228
- var selectionEvent = {
229
- field: event.field,
230
- nativeEvent: event.syntheticEvent && event.syntheticEvent.nativeEvent,
231
- syntheticEvent: event.syntheticEvent,
232
- target: _this,
233
- dataItems: _this.getLeafDataItems()
234
- };
235
- _this.props.onHeaderSelectionChange.call(undefined, selectionEvent);
236
- }
237
- };
238
- _this.selectionRelease = function (event) {
239
- if (_this.props.onSelectionChange) {
240
- var selectionEvent = __assign({ syntheticEvent: undefined, target: _this, selectedField: _this.props.selectedField || '', componentId: _this._treeListId, dataItems: _this.getLeafDataItems(), dataItem: null, level: [] }, event);
241
- _this.props.onSelectionChange.call(undefined, selectionEvent);
242
- }
243
- };
244
- _this.sortChange = function (syntheticEvent, sort, field) {
245
- _this.raiseDataEvent(_this.props.onSortChange, { sort: sort, field: field }, syntheticEvent);
246
- };
247
- _this.headerFilterChange = function (syntheticEvent, filter, field) {
248
- _this.raiseDataEvent(_this.props.onFilterChange, { filter: filter, field: field }, syntheticEvent);
249
- };
250
- _this.filterChange = function (event) {
251
- var filter = event.filter, field = event.field;
252
- _this.raiseDataEvent(_this.props.onFilterChange, { filter: filter, field: field }, event.syntheticEvent);
253
- };
254
- _this.columnMenuFilterChange = function (syntheticEvent, filter, field) {
255
- var onColumnMenuFilterChange = _this.props.onColumnMenuFilterChange;
256
- if (!onColumnMenuFilterChange) {
257
- return;
258
- }
259
- var event = {
260
- syntheticEvent: syntheticEvent,
261
- filter: filter,
262
- field: field,
263
- target: _this,
264
- nativeEvent: syntheticEvent.nativeEvent
265
- };
266
- onColumnMenuFilterChange.call(undefined, event);
267
- };
268
- _this.expandChange = function (event, dataItem, level) {
269
- var _a = _this.props, expandField = _a.expandField, onExpandChange = _a.onExpandChange;
270
- if (expandField && onExpandChange) {
271
- var expandEvent = __assign(__assign({}, _this.getArguments(event)), { dataItem: dataItem, level: level, value: _this.expanded(dataItem) });
272
- onExpandChange.call(undefined, expandEvent);
273
- }
274
- };
275
- _this.rowClick = function (e, item) {
276
- if (_this.props.onRowClick && e.target.nodeName === 'TD') {
277
- var rowClickEvent = __assign({ dataItem: item.dataItem, level: item.level }, _this.getArguments(e));
278
- _this.props.onRowClick.call(undefined, rowClickEvent);
279
- }
280
- };
281
- _this.rowDoubleClick = function (e, item) {
282
- if (_this.props.onRowDoubleClick && e.target.nodeName === 'TD') {
283
- var rowDoubleClickEvent = __assign({ dataItem: item.dataItem, level: item.level }, _this.getArguments(e));
284
- _this.props.onRowDoubleClick.call(undefined, rowDoubleClickEvent);
285
- }
286
- };
287
- _this.rowContextMenu = function (e, item) {
288
- if (_this.props.onRowContextMenu && e.target.nodeName === 'TD') {
289
- var rowContextMenuEvent = __assign({ dataItem: item.dataItem, level: item.level }, _this.getArguments(e));
290
- _this.props.onRowContextMenu.call(undefined, rowContextMenuEvent);
291
- }
292
- };
293
- _this.onPageChange = function (e) {
294
- if (_this.props.onPageChange) {
295
- var event_3 = __assign(__assign({}, _this.getArguments(e.syntheticEvent)), { skip: e.skip, take: e.take });
296
- _this.props.onPageChange.call(undefined, event_3);
297
- }
298
- };
299
- _this.expandedSubItems = function (dataItem) {
300
- var items = [];
301
- if (_this.expanded(dataItem) && _this.hasChildren(dataItem)) {
302
- items.push.apply(items, getNestedValue(_this.props.subItemsField, dataItem));
303
- }
304
- return items;
305
- };
306
- _this.getLeafDataItems = function () {
307
- return _this.flatData.map(function (item) { return item.dataItem; });
308
- };
309
- _this.expanded = function (dataItem) { return Boolean(getNestedValue(_this.props.expandField, dataItem)); };
310
- _this.hasChildren = function (dataItem) { return Boolean(getNestedValue(_this.props.subItemsField, dataItem)); };
311
- validatePackage(packageMetadata);
312
- _this.dragLogic = new CommonDragLogic(_this.columnReorder, noop, noop);
313
- _this.columnResize = new ColumnResize(_this.onResize.bind(_this));
314
- tableKeyboardNavigation.onConstructor({
315
- navigatable: Boolean(props.navigatable),
316
- contextStateRef: _this.contextStateRef,
317
- navigationStateRef: _this.navigationStateRef
318
- });
319
- return _this;
320
- }
321
- Object.defineProperty(TreeList.prototype, "document", {
322
- get: function () {
323
- if (!canUseDOM) {
324
- return;
325
- }
326
- // useful only for user actions
327
- return (this.element && this.element.ownerDocument) || document;
328
- },
329
- enumerable: false,
330
- configurable: true
331
- });
332
- /**
333
- * @hidden
334
- */
335
- TreeList.prototype.componentDidMount = function () {
336
- this.calculateSizes(this.element);
337
- tableKeyboardNavigation.onComponentDidMount({
338
- scope: this.element || undefined,
339
- contextStateRef: this.contextStateRef,
340
- navigationStateRef: this.navigationStateRef
341
- });
342
- };
343
- /**
344
- * @hidden
345
- */
346
- TreeList.prototype.getSnapshotBeforeUpdate = function () {
347
- tableKeyboardNavigation.onGetSnapshotBeforeUpdate({
348
- document: this.document,
349
- contextStateRef: this.contextStateRef,
350
- navigationStateRef: this.navigationStateRef
351
- });
352
- return null;
353
- };
354
- /**
355
- * @hidden
356
- */
357
- TreeList.prototype.componentDidUpdate = function (prevProps) {
358
- if (prevProps.columns !== this.props.columns) {
359
- this.calculateSizes(this.element);
360
- }
361
- tableKeyboardNavigation.onComponentDidUpdate({
362
- scope: this.element || undefined,
363
- contextStateRef: this.contextStateRef,
364
- navigationStateRef: this.navigationStateRef
365
- });
366
- };
367
- /**
368
- * @hidden
369
- */
370
- TreeList.prototype.componentWillUnmount = function () {
371
- this.columnsMap = [];
372
- this.prevData = [];
373
- this.flattedData = [];
374
- this.updateOnScroll = false;
375
- this.getExtendedColumn.clear();
376
- this.getColumnsMap.clear();
377
- };
378
- /**
379
- * @hidden
380
- */
381
- TreeList.prototype.render = function () {
382
- var _this = this;
383
- var _a = this.props, _b = _a.columns, columns = _b === void 0 ? [] : _b, filterRow = _a.filterRow, _c = _a.scrollable, scrollable = _c === void 0 ? 'scrollable' : _c, _d = _a.resizable, resizable = _d === void 0 ? false : _d, _e = _a.reorderable, reorderable = _e === void 0 ? false : _e, skip = _a.skip, take = _a.take;
384
- var filterable = columns.some(function (c) { return Boolean(c.filter) || Boolean(c.filterCell); }) || filterRow !== undefined;
385
- var FilterRow = filterRow || TreeListFilterRow;
386
- var idPrefix = navigationTools.getIdPrefix(this.navigationStateRef);
387
- this.extendedColumn = this.getExtendedColumn(columns, idPrefix);
388
- this.columnsMap = this.getColumnsMap(this.extendedColumn);
389
- var leafColumns = this.extendedColumn.filter(function (c) { return c.children.length === 0; });
390
- this.columnResize.columns = this.extendedColumn;
391
- this.columnResize.resizable = resizable;
392
- this.dragLogic.columns = this.extendedColumn;
393
- this.dragLogic.reorderable = reorderable;
394
- this.dragLogic.groupable = false;
395
- var header = (React.createElement(Header, { headerRow: React.createElement(HeaderRow, { sort: this.props.sort, sortable: this.props.sortable, sortChange: this.sortChange, selectionChange: this.onHeaderSelectionChange, columns: this.extendedColumn, columnsMap: this.columnsMap, cellRender: this.props.headerCellRender, columnResize: this.columnResize, columnMenu: this.props.columnMenu, columnMenuFilter: this.props.columnMenuFilter, columnMenuFilterChange: this.columnMenuFilterChange, pressHandler: this.dragLogic.pressHandler, dragHandler: this.dragLogic.dragHandler, releaseHandler: this.dragLogic.releaseHandler, filterChange: this.headerFilterChange }), filterRow: filterable && React.createElement(FilterRow, { columns: leafColumns, filter: this.props.filter, filterChange: this.filterChange, sort: this.props.sort, ariaRowIndex: this.columnsMap.length + 1 }) || undefined, columnResize: this.columnResize }));
396
- var wrapperStyles = this.props.style || {};
397
- var _f = tableColumnsVirtualization({
398
- enabled: this.props.columnVirtualization,
399
- columns: leafColumns,
400
- scrollLeft: this.wrapperScrollLeft,
401
- tableViewPortWidth: parseFloat((wrapperStyles.width || '').toString())
402
- }), colSpans = _f.colSpans, hiddenColumns = _f.hiddenColumns;
403
- var dataRow = function (item, inEdit, rowId, isRowExpanded, rowDataIndex, selectedValue) { return leafColumns.map(function (column, columnIndex) {
404
- if (hiddenColumns[columnIndex]) {
405
- return null;
406
- }
407
- var columnKey = column.id ? column.id : columnIndex;
408
- var className = "".concat(column.className ? column.className + ' ' : '')
409
- + "".concat(column.locked ? 'k-grid-content-sticky' : '');
410
- var cellProps = {
411
- id: navigationTools.generateNavigatableId("".concat(rowId, "-").concat(String(columnIndex)), idPrefix),
412
- colSpan: colSpans[columnIndex],
413
- dataItem: item.dataItem,
414
- field: column.field,
415
- format: column.format,
416
- className: className || undefined,
417
- render: _this.props.cellRender,
418
- onChange: _this.itemChange,
419
- selectionChange: (_this.props.onSelectionChange) ? (function (e) {
420
- _this.selectionChange({ event: e, item: item, columnIndex: columnIndex, dataIndex: rowDataIndex });
421
- }) : undefined,
422
- level: item.level,
423
- expandable: column.expandable,
424
- expanded: isRowExpanded,
425
- hasChildren: _this.hasChildren(item.dataItem),
426
- onExpandChange: _this.expandChange,
427
- colIndex: columnIndex,
428
- ariaColumnIndex: column.ariaColumnIndex,
429
- style: (column.left !== undefined) && {
430
- left: column.left,
431
- right: column.right,
432
- borderRightWidth: column.rightBorder ? '1px' : ''
433
- } || {},
434
- isSelected: Array.isArray(selectedValue) && selectedValue.indexOf(columnIndex) > -1
435
- };
436
- if (inEdit && column.editCell) {
437
- return (React.createElement(column.editCell, __assign({ key: columnKey }, cellProps, { onChange: _this.itemChange })));
438
- }
439
- if (column.cell) {
440
- return React.createElement(column.cell, __assign({ key: columnKey }, cellProps));
441
- }
442
- return React.createElement(TreeListCell, __assign({ key: columnKey }, cellProps));
443
- }); };
444
- var flattedData = this.flatData;
445
- var total = flattedData.length;
446
- if (skip !== undefined && take !== undefined) {
447
- flattedData = flattedData.slice(skip, skip + take);
448
- }
449
- if (scrollable === 'virtual') {
450
- flattedData = tableRowsVirtualization({
451
- rows: flattedData,
452
- tableViewPortHeight: parseFloat((wrapperStyles.height || wrapperStyles.maxHeight || '').toString()),
453
- scrollTop: this.wrapperScrollTop
454
- });
455
- this.updateOnScroll = false;
456
- }
457
- var levels = flattedData.map(function (i) { return i.level; });
458
- var rowIndexStart = this.columnsMap.length + (filterable ? 1 : 0) + 1;
459
- var body = flattedData.length > 0 && flattedData.map(function (item, rowIndex) {
460
- var inEdit = getNestedValue(_this.props.editField, item.dataItem);
461
- var dataItemKeyValue = _this.props.dataItemKey && getter(_this.props.dataItemKey)(item.dataItem);
462
- var rowId = String(dataItemKeyValue ? dataItemKeyValue : item.level.join('.'));
463
- var isRowExpanded = _this.expanded(item.dataItem);
464
- var selectedValue = _this.props.selectedField ? getNestedValue(_this.props.selectedField, item.dataItem) : undefined;
465
- var rowProps = {
466
- key: rowId,
467
- level: item.level,
468
- levels: levels,
469
- dataItem: item.dataItem,
470
- selectedField: _this.props.selectedField,
471
- rowHeight: scrollable === 'virtual' ? item.height : _this.props.rowHeight,
472
- render: _this.props.rowRender,
473
- onDrop: _this.onRowDrop,
474
- onDrag: _this.onRowDrag,
475
- onClick: function (e) { return _this.rowClick(e, item); },
476
- onDoubleClick: function (e) { return _this.rowDoubleClick(e, item); },
477
- onContextMenu: function (e) { return _this.rowContextMenu(e, item); },
478
- isAltRow: rowIndex % 2 !== 0,
479
- expanded: isRowExpanded,
480
- rowIndex: rowIndex,
481
- ariaRowIndex: rowIndexStart + rowIndex,
482
- ariaSetSize: item.levelCount,
483
- ariaPosInSet: item.level[item.level.length - 1] + 1,
484
- isSelected: typeof selectedValue === 'boolean' && selectedValue
485
- };
486
- var EditRow = _this.props.editRow;
487
- var Row = _this.props.row || TreeListRow;
488
- var cells = dataRow(item, inEdit, rowId, isRowExpanded, rowIndex, selectedValue);
489
- return inEdit && EditRow ?
490
- React.createElement(EditRow, __assign({}, rowProps), cells) :
491
- React.createElement(Row, __assign({}, rowProps), cells);
492
- }) || (React.createElement("tr", { className: "k-table-row k-grid-norecords" },
493
- React.createElement("td", { colSpan: leafColumns.length }, this.props.noRecords || React.createElement(TreeListNoRecords, null))));
494
- var sorted = function (field) {
495
- return _this.props.sort && _this.props.sort.some(function (descriptor) { return descriptor.field === field; });
496
- };
497
- var colGroups = (React.createElement("colgroup", { ref: function (c) { _this.columnResize.colGroupMain = c; } }, leafColumns.map(function (column, index) { return (React.createElement("col", { key: index.toString(), className: sorted(column.field) ? 'k-sorted' : undefined, style: column.width !== undefined ? { width: column.width } : undefined })); })));
498
- var virtualScroll = this.props.columnVirtualization || this.props.scrollable === 'virtual';
499
- var tableUserSelect = this.props.selectable && this.props.selectable.drag ? 'none' : undefined;
500
- var tableProps = (this.props.tableProps || {});
501
- return (React.createElement(TableKeyboardNavigationContext.Provider, { value: this.contextStateRef.current },
502
- React.createElement("div", __assign({ style: this.props.style, className: classNames('k-grid k-grid-md', this.props.className, { 'k-treelist-scrollable': scrollable !== 'none' }), ref: function (e) { return _this.element = e; }, onScroll: virtualScroll ? this.handleOnScroll : undefined, onKeyDown: this.onKeyDown, onFocus: this.onFocus, "aria-rowcount": total, "aria-colcount": leafColumns.length, role: 'treegrid' }, tableKeyboardNavigationScopeAttributes),
503
- this.props.toolbar,
504
- React.createElement(TableSelection, { selectable: this.props.selectable, onRelease: this.selectionRelease },
505
- React.createElement("table", __assign({ className: 'k-table k-table-md k-grid-table' }, tableProps, { style: __assign(__assign({}, (tableProps.style || {})), { userSelect: tableUserSelect }), role: 'presentation' }),
506
- colGroups,
507
- header,
508
- React.createElement("tbody", __assign({ className: 'k-table-tbody' }, tableKeyboardNavigationBodyAttributes, { role: 'presentation' }), body))),
509
- this.props.pager && (React.createElement(this.props.pager, { className: "k-grid-pager", total: total, skip: skip, take: take, onPageChange: this.onPageChange })),
510
- reorderable && (React.createElement(React.Fragment, null,
511
- React.createElement(DropClue, { ref: this.dragLogic.refDropElementClue }),
512
- React.createElement(DragClue, { ref: this.dragLogic.refDragElementClue }))))));
513
- };
514
- Object.defineProperty(TreeList.prototype, "columns", {
515
- get: function () {
516
- var shuffledColumns = this.extendedColumn.filter(function (q) { return q.declarationIndex >= 0 && q.parentIndex === -1; });
517
- var sanitize = function (columns) {
518
- columns.sort(function (a, b) { return a.declarationIndex - b.declarationIndex; });
519
- return columns.map(function (column) {
520
- var declarationIndex = column.declarationIndex, parentIndex = column.parentIndex, depth = column.depth, colSpan = column.colSpan, rowSpan = column.rowSpan, index = column.index, kFirst = column.kFirst, groupable = column.groupable, children = column.children, props = __rest(column, ["declarationIndex", "parentIndex", "depth", "colSpan", "rowSpan", "index", "kFirst", "groupable", "children"]);
521
- return children.length ? __assign({ children: sanitize(children) }, props) : props;
522
- });
523
- };
524
- return sanitize(shuffledColumns);
525
- },
526
- enumerable: false,
527
- configurable: true
528
- });
529
- Object.defineProperty(TreeList.prototype, "flatData", {
530
- get: function () {
531
- var _a = this.props, _b = _a.data, data = _b === void 0 ? [] : _b, _c = _a.rowHeight, rowHeight = _c === void 0 ? 0 : _c;
532
- var offsetTop = 0;
533
- var itemDataMap = function (_item) {
534
- var result = { height: rowHeight, offsetTop: offsetTop };
535
- offsetTop += result.height;
536
- return result;
537
- };
538
- var flattedData = (this.updateOnScroll &&
539
- this.prevData === data &&
540
- this.tbodyOffsetTop > 0 &&
541
- this.flattedData.length) ?
542
- this.flattedData :
543
- flatData(data, this.expandedSubItems, itemDataMap);
544
- this.prevData = data;
545
- this.flattedData = flattedData;
546
- return flattedData;
547
- },
548
- enumerable: false,
549
- configurable: true
550
- });
551
- TreeList.prototype.selectionChange = function (options) {
552
- if (this.props.onSelectionChange) {
553
- var event_4 = options.event, item = options.item, dataIndex = options.dataIndex, columnIndex = options.columnIndex;
554
- var _a = getSelectionOptions(this.props.selectable), mode = _a.mode, cell = _a.cell;
555
- var selectionEvent = __assign(__assign({}, this.getArguments(event_4.syntheticEvent)), { dataItem: item.dataItem, level: item.level, startColIndex: columnIndex, endColIndex: columnIndex, startRowIndex: dataIndex, endRowIndex: dataIndex, dataItems: this.getLeafDataItems(), altKey: false, ctrlKey: false, shiftKey: false, metaKey: false, mode: mode, cell: cell, isDrag: false, componentId: this._treeListId, selectedField: this.props.selectedField || '' });
556
- this.props.onSelectionChange.call(undefined, selectionEvent);
557
- }
558
- };
559
- TreeList.prototype.raiseDataEvent = function (handler, data, syntheticEvent) {
560
- var dataStateChange = this.props.onDataStateChange;
561
- if (handler) {
562
- handler.call(undefined, __assign(__assign({}, this.getArguments(syntheticEvent)), data));
563
- }
564
- else if (dataStateChange) {
565
- var dataStateEvent = __assign(__assign({}, this.getArguments(syntheticEvent)), { dataState: __assign(__assign({}, this.getDataState()), data) });
566
- dataStateChange.call(undefined, dataStateEvent);
567
- }
568
- };
569
- TreeList.prototype.getDataState = function () {
570
- return {
571
- filter: this.props.filter,
572
- sort: this.props.sort
573
- };
574
- };
575
- TreeList.prototype.getArguments = function (syntheticEvent) {
576
- return {
577
- nativeEvent: syntheticEvent && syntheticEvent.nativeEvent,
578
- syntheticEvent: syntheticEvent,
579
- target: this
580
- };
581
- };
582
- /**
583
- * @hidden
584
- */
585
- TreeList.propTypes = {
586
- data: PropTypes.array,
587
- resizable: PropTypes.bool,
588
- reorderable: PropTypes.bool,
589
- sortable: PropTypes.oneOfType([
590
- PropTypes.bool,
591
- PropTypes.shape({
592
- mode: PropTypes.oneOf(['single', 'multiple']),
593
- allowUnsort: PropTypes.bool
594
- })
595
- ]),
596
- onSortChange: PropTypes.func,
597
- sort: PropTypes.array,
598
- columns: PropTypes.arrayOf(PropTypes.object),
599
- columnVirtualization: PropTypes.bool,
600
- filter: PropTypes.array,
601
- onFilterChange: PropTypes.func,
602
- filterRow: PropTypes.any,
603
- toolbar: PropTypes.any,
604
- noRecords: PropTypes.any,
605
- onExpandChange: PropTypes.func,
606
- expandField: PropTypes.string,
607
- subItemsField: PropTypes.string,
608
- selectedField: PropTypes.string,
609
- onSelectionChange: PropTypes.func,
610
- onHeaderSelectionChange: PropTypes.func,
611
- onRowClick: PropTypes.func,
612
- onItemChange: PropTypes.func,
613
- editField: PropTypes.string,
614
- scrollable: PropTypes.oneOf(['none', 'scrollable', 'virtual']),
615
- rowHeight: PropTypes.number,
616
- style: PropTypes.object,
617
- tableProps: PropTypes.object,
618
- pager: PropTypes.any,
619
- skip: PropTypes.number,
620
- take: PropTypes.number,
621
- onPageChange: PropTypes.func,
622
- onDataStateChange: PropTypes.func,
623
- onColumnResize: PropTypes.func,
624
- onColumnReorder: PropTypes.func,
625
- dataItemKey: PropTypes.string,
626
- navigatable: PropTypes.bool
627
- };
628
- /** @hidden */
629
- TreeList.contextType = TableKeyboardNavigationContext;
630
- return TreeList;
631
- }(React.Component));
632
- export { TreeList };
@@ -1,37 +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 { registerForLocalization, provideLocalizationService as intl } from '@progress/kendo-react-intl';
18
- import { messages, noRecords } from './messages';
19
- /**
20
- * Represents the TreeListNoRecords component.
21
- * The component is rendered when the `data` property of the TreeList is an empty array or undefined.
22
- */
23
- var TreeListNoRecords = /** @class */ (function (_super) {
24
- __extends(TreeListNoRecords, _super);
25
- function TreeListNoRecords() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- /**
29
- * @hidden
30
- */
31
- TreeListNoRecords.prototype.render = function () {
32
- return this.props.children || intl(this).toLanguageString(noRecords, messages[noRecords]);
33
- };
34
- return TreeListNoRecords;
35
- }(React.Component));
36
- export { TreeListNoRecords };
37
- registerForLocalization(TreeListNoRecords);