@progress/kendo-react-grid 5.19.0-dev.202309211619 → 5.19.0-dev.202309211913

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.
package/dist/es/Grid.js CHANGED
@@ -634,6 +634,8 @@ var Grid = /** @class */ (function (_super) {
634
634
  });
635
635
  var noRecords = children.filter(function (child) { return child && child.type &&
636
636
  child.type.displayName === 'KendoReactGridNoRecords'; });
637
+ var statusBar = children.filter(function (child) { return child && child.type &&
638
+ child.type.displayName === 'KendoReactGridStatusBar'; });
637
639
  var leafColumns = this._columns.filter(function (c) { return c.children.length === 0; });
638
640
  var groupingPanel = groupable && (React.createElement(GroupPanel, { group: this.props.group || [], groupChange: this.groupChange, pressHandler: this.dragLogic.pressHandler, dragHandler: this.dragLogic.dragHandler, releaseHandler: this.dragLogic.releaseHandler, refCallback: this.dragLogic.refGroupPanelDiv, resolveTitle: this.resolveTitle, ariaControls: this._gridRoleElementId }));
639
641
  var _g = this.props, sort = _g.sort, sortable = _g.sortable, group = _g.group, filter = _g.filter, filterable = _g.filterable, _h = _g.filterOperators, filterOperators = _h === void 0 ? operators : _h, headerCellRender = _g.headerCellRender, columnMenu = _g.columnMenu;
@@ -770,18 +772,17 @@ var Grid = /** @class */ (function (_super) {
770
772
  _a), this.props.className), ref: function (el) { _this._element = el; }, "aria-label": this.props.ariaLabel, onKeyDown: this.onKeyDown, onFocus: this.onFocus }, tableKeyboardNavigationScopeAttributes),
771
773
  toolbar,
772
774
  groupingPanel,
773
- React.createElement(TableSelection, { selectable: this.props.selectable, onRelease: this.selectionRelease, childRef: function (table) {
774
- _this.tableElement = table;
775
- } },
775
+ React.createElement(TableSelection, { selectable: this.props.selectable, onRelease: this.selectionRelease, childRef: function (table) { _this.tableElement = table; } },
776
776
  React.createElement("table", { className: classNames('k-table k-grid-table', (_b = {}, _b["k-table-".concat(kendoThemeMaps.sizeMap[this.props.size] || this.props.size)] = this.props.size, _b)), style: { userSelect: tableUserSelect, display: tableDisplay } },
777
777
  colGroups,
778
778
  header,
779
779
  React.createElement("tbody", __assign({ role: 'rowgroup', className: 'k-table-tbody' }, tableKeyboardNavigationBodyAttributes), body),
780
780
  footer)),
781
- this.props.pageable && pager,
782
781
  enableDragClues && (React.createElement(React.Fragment, null,
783
782
  React.createElement(DropClue, { ref: this.dragLogic.refDropElementClue }),
784
- React.createElement(DragClue, { ref: this.dragLogic.refDragElementClue }))))));
783
+ React.createElement(DragClue, { ref: this.dragLogic.refDragElementClue })))),
784
+ statusBar,
785
+ this.props.pageable && pager));
785
786
  }
786
787
  var wrapperStyle = this.props.style || {};
787
788
  if (this.props.scrollable === 'virtual') {
@@ -801,7 +802,7 @@ var Grid = /** @class */ (function (_super) {
801
802
  }, "aria-label": this.props.ariaLabel, onKeyDown: this.onKeyDown, onFocus: this.onFocus }, tableKeyboardNavigationScopeAttributes),
802
803
  toolbar,
803
804
  groupingPanel,
804
- React.createElement("div", { role: "grid", className: "k-grid-aria-root", id: this._gridRoleElementId, "aria-colcount": leafColumns.length, "aria-rowcount": total },
805
+ React.createElement("div", { className: 'k-grid-aria-root', role: "grid", "aria-colcount": leafColumns.length, "aria-rowcount": total, id: this._gridRoleElementId },
805
806
  header,
806
807
  React.createElement("div", { className: "k-grid-container", role: "presentation" },
807
808
  React.createElement("div", { ref: this.containerRef, className: "k-grid-content k-virtual-content", onScroll: this.scrollHandler, role: "presentation" },
@@ -818,13 +819,14 @@ var Grid = /** @class */ (function (_super) {
818
819
  React.createElement("tbody", __assign({ className: 'k-table-tbody', ref: this.tableBodyRef, role: 'rowgroup' }, tableKeyboardNavigationBodyAttributes), body)))),
819
820
  React.createElement("div", { className: "k-height-container", role: "presentation" },
820
821
  React.createElement("div", { style: this.props.scrollable === 'virtual' ?
821
- { 'height': (this.vs.containerHeight) + 'px' } : {} }))),
822
- footer)),
823
- this.props.pageable && pager,
824
- enableDragClues && (React.createElement(React.Fragment, null,
825
- React.createElement(DropClue, { ref: this.dragLogic.refDropElementClue }),
826
- React.createElement(DragClue, { ref: this.dragLogic.refDragElementClue }))),
827
- this.showLicenseWatermark && React.createElement(WatermarkOverlay, null))));
822
+ { 'height': (this.vs.containerHeight) + 'px' } : {} })),
823
+ footer)),
824
+ enableDragClues && (React.createElement(React.Fragment, null,
825
+ React.createElement(DropClue, { ref: this.dragLogic.refDropElementClue }),
826
+ React.createElement(DragClue, { ref: this.dragLogic.refDragElementClue }))),
827
+ this.showLicenseWatermark && React.createElement(WatermarkOverlay, null)),
828
+ statusBar,
829
+ this.props.pageable && pager)));
828
830
  };
829
831
  Grid.prototype.selectionChange = function (options) {
830
832
  if (this.props.onSelectionChange) {
@@ -0,0 +1,47 @@
1
+ import * as React from 'react';
2
+ import { GridSelectionChangeEvent } from './interfaces/events';
3
+ import { GridColumnProps } from './interfaces/GridColumnProps';
4
+ /**
5
+ * Represents the KendoReact Grid's StatusItem object.
6
+ */
7
+ export interface StatusItem {
8
+ /**
9
+ * The type of the status item.
10
+ * Could be `sum`, `min`, `max`, `average`, `count`, `isTrue`, `isFalse`, `earliest` or `latest`.
11
+ */
12
+ type: string;
13
+ /**
14
+ * The calculated value of the status item.
15
+ */
16
+ value: number | boolean | Date;
17
+ /**
18
+ * The formatted value of the status item.
19
+ */
20
+ formattedValue: string;
21
+ }
22
+ /**
23
+ * Represents the props of the KendoReact Grid's StatusBar component.
24
+ */
25
+ export interface StatusBarProps {
26
+ data: StatusItem[];
27
+ }
28
+ /**
29
+ * Represents the KendoReact Grid's StatusBar component.
30
+ */
31
+ export declare const StatusBar: React.FunctionComponent<StatusBarProps>;
32
+ /**
33
+ * @hidden
34
+ */
35
+ export declare const leafColumns: (columns: GridColumnProps[]) => GridColumnProps[];
36
+ /**
37
+ * Represents the arguments of the getStatusData function.
38
+ */
39
+ export interface StatusDataArgs extends Pick<GridSelectionChangeEvent, 'dataItems' | 'target' | 'startColIndex' | 'endColIndex' | 'startRowIndex' | 'endRowIndex' | 'cell'> {
40
+ }
41
+ /**
42
+ * Calculates the status data.
43
+ *
44
+ * @param args StatusDataArgs
45
+ * @returns StatusItem[]
46
+ */
47
+ export declare const getStatusData: (args: StatusDataArgs) => StatusItem[];
@@ -0,0 +1,109 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import * as React from 'react';
11
+ import { getter } from '@progress/kendo-react-common';
12
+ /**
13
+ * Represents the KendoReact Grid's StatusBar component.
14
+ */
15
+ export var StatusBar = function (props) {
16
+ var _a = props.data, data = _a === void 0 ? [] : _a;
17
+ return (React.createElement("div", { className: "k-selection-aggregates k-grid-selection-aggregates" }, data.map(function (item, index) { return (React.createElement("div", { key: index },
18
+ React.createElement("span", { className: "k-selection-aggregates-item-text" },
19
+ item.type,
20
+ ": "),
21
+ React.createElement("span", { className: "k-selection-aggregates-item-value" }, item.formattedValue))); })));
22
+ };
23
+ StatusBar.displayName = 'KendoReactGridStatusBar';
24
+ ;
25
+ ;
26
+ /**
27
+ * @hidden
28
+ */
29
+ export var leafColumns = function (columns) {
30
+ var _a;
31
+ var result = columns.slice();
32
+ for (var i = 0; i < result.length; i++) {
33
+ while (result[i] && ((_a = result[i].children) === null || _a === void 0 ? void 0 : _a.length)) {
34
+ result.splice.apply(result, __spreadArray([i, 1], result[i].children, false));
35
+ }
36
+ }
37
+ return result;
38
+ };
39
+ ;
40
+ /**
41
+ * Calculates the status data.
42
+ *
43
+ * @param args StatusDataArgs
44
+ * @returns StatusItem[]
45
+ */
46
+ export var getStatusData = function (args) {
47
+ var dataItems = args.dataItems, target = args.target, startColIndex = args.startColIndex, endColIndex = args.endColIndex, startRowIndex = args.startRowIndex, endRowIndex = args.endRowIndex;
48
+ var columns = leafColumns(target.columns);
49
+ if (args.cell) {
50
+ columns = columns.slice(startColIndex, endColIndex + 1);
51
+ }
52
+ var getters = columns.map(function (c) { return c.field; }).filter(function (f) { return f && typeof f === 'string'; }).map(function (f) { return getter(f); });
53
+ var data = dataItems.slice(startRowIndex, endRowIndex + 1);
54
+ var grouped = { dates: [], numbers: [], booleans: [], others: [] };
55
+ var add = function (value) {
56
+ if (typeof value === 'number') {
57
+ grouped.numbers.push(value);
58
+ }
59
+ else if (typeof value === 'boolean') {
60
+ grouped.booleans.push(value);
61
+ }
62
+ else if (value instanceof Date) {
63
+ grouped.dates.push(value);
64
+ }
65
+ else if (value) {
66
+ grouped.others.push(value);
67
+ }
68
+ };
69
+ data.forEach(function (item) {
70
+ getters.forEach(function (fieldGetter) {
71
+ add(fieldGetter(item));
72
+ });
73
+ });
74
+ var datesAsNumbers = grouped.dates.map(function (d) { return d.getTime(); });
75
+ var isTrueCount = grouped.booleans.filter(function (bool) { return bool; }).length;
76
+ var isFalseCount = grouped.booleans.filter(function (bool) { return !bool; }).length;
77
+ var sum = grouped.numbers.length ? grouped.numbers.reduce(function (acc, curr) { return acc += curr; }, 0) : undefined;
78
+ var aggregates = {
79
+ sum: sum,
80
+ average: typeof sum === 'number' ? sum / grouped.numbers.length : undefined,
81
+ min: grouped.numbers.length ? Math.min.apply(Math, grouped.numbers) : undefined,
82
+ max: grouped.numbers.length ? Math.max.apply(Math, grouped.numbers) : undefined,
83
+ count: grouped.numbers.length + grouped.booleans.length + grouped.dates.length + grouped.others.length,
84
+ isTrue: isTrueCount > 0 ? isTrueCount : undefined,
85
+ isFalse: isFalseCount > 0 ? isFalseCount : undefined,
86
+ earliest: grouped.dates.length ? new Date(Math.min.apply(Math, datesAsNumbers)) : undefined,
87
+ latest: grouped.dates.length ? new Date(Math.max.apply(Math, datesAsNumbers)) : undefined
88
+ };
89
+ var format = function (value, key) {
90
+ if ((key === 'sum' || key === 'average') && typeof value === 'number') {
91
+ return value.toFixed(2);
92
+ }
93
+ else if ((key === 'earliest' || key === 'latest') && value instanceof Date) {
94
+ return value.toLocaleDateString();
95
+ }
96
+ else {
97
+ return String(value);
98
+ }
99
+ };
100
+ var result = [];
101
+ Object.keys(aggregates).forEach(function (a) {
102
+ var type = a;
103
+ var value = aggregates[type];
104
+ if (value !== undefined) {
105
+ result.push({ type: type, value: value, formattedValue: format(value, type) });
106
+ }
107
+ });
108
+ return result;
109
+ };
@@ -15,8 +15,7 @@ var __extends = (this && this.__extends) || (function () {
15
15
  })();
16
16
  import * as React from 'react';
17
17
  import { Draggable, IconWrap } from '@progress/kendo-react-common';
18
- import { ungroupColumn, messages } from '../messages';
19
- import { provideLocalizationService, registerForLocalization } from '@progress/kendo-react-intl';
18
+ import { registerForLocalization } from '@progress/kendo-react-intl';
20
19
  import { sortAscSmallIcon, sortDescSmallIcon, xCircleIcon } from '@progress/kendo-svg-icons';
21
20
  /**
22
21
  * @hidden
@@ -71,7 +70,6 @@ var GroupingIndicator = /** @class */ (function (_super) {
71
70
  }
72
71
  GroupingIndicator.prototype.render = function () {
73
72
  var _this = this;
74
- var localizationService = provideLocalizationService(this);
75
73
  var dir = this.props.dir;
76
74
  return (React.createElement(Draggable, { onPress: this.onPress, onDrag: this.onDrag, onRelease: this.onRelease, ref: function (component) { _this.draggable = component; } },
77
75
  React.createElement("div", { className: "k-chip k-chip-md k-chip-solid k-chip-solid-base k-rounded-md", onClick: this.sortChange, role: "button", style: { touchAction: 'none' } },
@@ -79,7 +77,7 @@ var GroupingIndicator = /** @class */ (function (_super) {
79
77
  React.createElement(IconWrap, { name: 'sort-' + dir + '-small', icon: dir === 'asc' ? sortAscSmallIcon : sortDescSmallIcon, size: 'small' })),
80
78
  React.createElement("span", { className: 'k-chip-content' }, this.props.title),
81
79
  React.createElement("span", { className: "k-chip-actions" },
82
- React.createElement("span", { className: "k-chip-action k-chip-remove-action", onClick: this.groupRemove, "aria-label": localizationService.toLanguageString(ungroupColumn, messages[ungroupColumn]) },
80
+ React.createElement("span", { className: "k-chip-action k-chip-remove-action", onClick: this.groupRemove },
83
81
  React.createElement(IconWrap, { name: 'x-circle', icon: xCircleIcon, size: 'small' }))))));
84
82
  };
85
83
  return GroupingIndicator;
@@ -46,9 +46,8 @@ var FooterRow = /** @class */ (function (_super) {
46
46
  : {},
47
47
  className: classNames('k-table-td', column.locked && column.left !== undefined ? 'k-grid-footer-sticky' : ''),
48
48
  key: index,
49
- role: 'columnfooter'
49
+ role: 'gridcell'
50
50
  },
51
- _a['aria-selected'] = false,
52
51
  _a['aria-colindex'] = column.ariaColumnIndex,
53
52
  _a);
54
53
  var cellProps = __assign({ field: column.field, ariaColumnIndex: column.ariaColumnIndex }, tdProps);
@@ -45,7 +45,7 @@ var GroupPanel = /** @class */ (function (_super) {
45
45
  }, onSortChange: function (event, dir) {
46
46
  _this.onGroupSortChange(event, index, groupDesc, dir);
47
47
  }, onPress: _this.props.pressHandler, onDrag: _this.props.dragHandler, onRelease: _this.props.releaseHandler })); });
48
- return (React.createElement("div", { ref: this.props.refCallback, className: "k-grouping-header", role: "toolbar", "aria-label": intl(this).toLanguageString(groupPanelAriaLabel, messages[groupPanelAriaLabel]), "aria-controls": this.props.ariaControls },
48
+ return (React.createElement("div", { ref: this.props.refCallback, className: "k-grouping-header", role: "toolbar", "aria-label": intl(this).toLanguageString(groupPanelAriaLabel, messages[groupPanelAriaLabel]), "aria-controls": this.props.ariaControls || '' },
49
49
  React.createElement("div", { className: "k-chip-list k-chip-list-md", role: "none" }, groups),
50
50
  React.createElement("div", { className: "k-grouping-drop-container" },
51
51
  !groups.length && intl(this).toLanguageString(messageKey, messages[messageKey]),
package/dist/es/main.d.ts CHANGED
@@ -34,6 +34,7 @@ import { GridNoRecordsProps } from './interfaces/GridNoRecordsProps';
34
34
  export * from './interfaces/events';
35
35
  export * from './interfaces/GridCellsSettings';
36
36
  export { messages as gridMessages, pagerInfo, pagerFirstPage, pagerPreviousPage, pagerNextPage, pagerLastPage, pagerItemPerPage } from './messages';
37
+ export * from './StatusBar';
37
38
  import { GridSortSettings } from './interfaces/GridSortSettings';
38
39
  import { GridPagerSettings } from './paging/GridPagerSettings';
39
40
  import { GridGroupableSettings } from './interfaces/GridGroupableSettings';
@@ -41,10 +42,10 @@ import { GridColumnMenuItem } from './columnMenu/GridColumnMenuItem';
41
42
  import { GridColumnMenuItemContent } from './columnMenu/GridColumnMenuItemContent';
42
43
  import { GridColumnMenuItemGroup } from './columnMenu/GridColumnMenuItemGroup';
43
44
  import { GridFooterCellProps } from './interfaces/GridFooterCellProps';
44
- import { GridSelectableMode } from './interfaces/GridSelectableSettings';
45
+ import { GridSelectableMode, GridSelectableSettings } from './interfaces/GridSelectableSettings';
45
46
  import { GridColumnMenuFilterUIProps } from './interfaces/GridColumnMenuFilterUIProps';
46
47
  import { GRID_COL_INDEX_ATTRIBUTE, GRID_ROW_INDEX_ATTRIBUTE } from './constants';
47
48
  import { getSelectedState, getSelectedStateFromKeyDown, setSelectedState } from '@progress/kendo-react-data-tools';
48
49
  import { CommonDragLogic as GridCommonDragLogic } from './drag/CommonDragLogic';
49
50
  import { booleanFilterValues, operators } from './filterCommon';
50
- export { Grid, GridProps, GridColumn, GridColumnProps, GridCellProps, GridCell, GridEditCell, GridGroupCell, GridHierarchyCell, GridDetailRow, GridDetailRowProps, GridRow, GridRowProps, GridFilterCell, GridFilterCellProps, GridHeaderCell, GridHeaderCellProps, GridSelectionCell, GridColumnMenuProps, GridColumnMenuSort, GridColumnMenuFilter, GridColumnMenuGroup, GridColumnMenuItem, GridColumnMenuItemContent, GridColumnMenuItemGroup, GridColumnMenuFilterUI, GridColumnMenuFilterUIProps, GridColumnMenuFilterCell, GridColumnMenuFilterCellProps, GridColumnMenuCheckboxFilter, GridColumnMenuCheckboxFilterProps, GridColumnMenuColumnsList, GridColumnMenuColumnsListProps, GridToolbar, GridToolbarProps, GridNoRecords, GridNoRecordsProps, GridSortSettings, GridPagerSettings, GridGroupableSettings, GridFooterCellProps, GridSelectableMode, GridFilterOperators, GridFilterOperator, GridColumnMenuWrapper, GridColumnMenuWrapperProps, getSelectedState, setSelectedState, getSelectedStateFromKeyDown, GRID_COL_INDEX_ATTRIBUTE, GRID_ROW_INDEX_ATTRIBUTE, GridCommonDragLogic, rootFilterOrDefault, filterGroupByField, GridColumnMenuFilterProps, booleanFilterValues, operators };
51
+ export { Grid, GridProps, GridColumn, GridColumnProps, GridCellProps, GridCell, GridEditCell, GridGroupCell, GridHierarchyCell, GridDetailRow, GridDetailRowProps, GridRow, GridRowProps, GridFilterCell, GridFilterCellProps, GridHeaderCell, GridHeaderCellProps, GridSelectionCell, GridColumnMenuProps, GridColumnMenuSort, GridColumnMenuFilter, GridColumnMenuGroup, GridColumnMenuItem, GridColumnMenuItemContent, GridColumnMenuItemGroup, GridColumnMenuFilterUI, GridColumnMenuFilterUIProps, GridColumnMenuFilterCell, GridColumnMenuFilterCellProps, GridColumnMenuCheckboxFilter, GridColumnMenuCheckboxFilterProps, GridColumnMenuColumnsList, GridColumnMenuColumnsListProps, GridToolbar, GridToolbarProps, GridNoRecords, GridNoRecordsProps, GridSortSettings, GridPagerSettings, GridGroupableSettings, GridFooterCellProps, GridSelectableMode, GridSelectableSettings, GridFilterOperators, GridFilterOperator, GridColumnMenuWrapper, GridColumnMenuWrapperProps, getSelectedState, setSelectedState, getSelectedStateFromKeyDown, GRID_COL_INDEX_ATTRIBUTE, GRID_ROW_INDEX_ATTRIBUTE, GridCommonDragLogic, rootFilterOrDefault, filterGroupByField, GridColumnMenuFilterProps, booleanFilterValues, operators };
package/dist/es/main.js CHANGED
@@ -22,6 +22,7 @@ import { GridNoRecords } from './GridNoRecords';
22
22
  export * from './interfaces/events';
23
23
  export * from './interfaces/GridCellsSettings';
24
24
  export { messages as gridMessages, pagerInfo, pagerFirstPage, pagerPreviousPage, pagerNextPage, pagerLastPage, pagerItemPerPage } from './messages';
25
+ export * from './StatusBar';
25
26
  import { GridColumnMenuItem } from './columnMenu/GridColumnMenuItem';
26
27
  import { GridColumnMenuItemContent } from './columnMenu/GridColumnMenuItemContent';
27
28
  import { GridColumnMenuItemGroup } from './columnMenu/GridColumnMenuItemGroup';
@@ -30,6 +30,10 @@ export declare const pagerItemPerPage = "grid.pagerItemsPerPage";
30
30
  * @hidden
31
31
  */
32
32
  export declare const pagerPage = "grid.pagerPage";
33
+ /**
34
+ * @hidden
35
+ */
36
+ export declare const pagerPageSizeAriaLabel = "grid.pagerPageSizeAriaLabel";
33
37
  /**
34
38
  * @hidden
35
39
  */
@@ -144,6 +148,7 @@ export declare const messages: {
144
148
  "grid.pagerNextPage": string;
145
149
  "grid.pagerLastPage": string;
146
150
  "grid.pagerPage": string;
151
+ "grid.pagerPageSizeAriaLabel": string;
147
152
  "grid.pagerOf": string;
148
153
  "grid.pagerTotalPages": string;
149
154
  "grid.searchPlaceholder": string;
@@ -31,6 +31,10 @@ export var pagerItemPerPage = 'grid.pagerItemsPerPage';
31
31
  * @hidden
32
32
  */
33
33
  export var pagerPage = 'grid.pagerPage';
34
+ /**
35
+ * @hidden
36
+ */
37
+ export var pagerPageSizeAriaLabel = 'grid.pagerPageSizeAriaLabel';
34
38
  /**
35
39
  * @hidden
36
40
  */
@@ -145,6 +149,7 @@ export var messages = (_a = {},
145
149
  _a[pagerNextPage] = 'Go to the next page',
146
150
  _a[pagerLastPage] = 'Go to the last page',
147
151
  _a[pagerPage] = 'Page',
152
+ _a[pagerPageSizeAriaLabel] = 'Page size',
148
153
  _a[pagerOf] = 'of',
149
154
  _a[pagerTotalPages] = '{0}',
150
155
  _a[searchPlaceholder] = 'Search',
@@ -5,7 +5,7 @@ export var packageMetadata = {
5
5
  name: '@progress/kendo-react-grid',
6
6
  productName: 'KendoReact',
7
7
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1695311831,
8
+ publishDate: 1695321920,
9
9
  version: '',
10
10
  licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
11
  };
package/dist/npm/Grid.js CHANGED
@@ -637,6 +637,8 @@ var Grid = /** @class */ (function (_super) {
637
637
  });
638
638
  var noRecords = children.filter(function (child) { return child && child.type &&
639
639
  child.type.displayName === 'KendoReactGridNoRecords'; });
640
+ var statusBar = children.filter(function (child) { return child && child.type &&
641
+ child.type.displayName === 'KendoReactGridStatusBar'; });
640
642
  var leafColumns = this._columns.filter(function (c) { return c.children.length === 0; });
641
643
  var groupingPanel = groupable && (React.createElement(GroupPanel_1.GroupPanel, { group: this.props.group || [], groupChange: this.groupChange, pressHandler: this.dragLogic.pressHandler, dragHandler: this.dragLogic.dragHandler, releaseHandler: this.dragLogic.releaseHandler, refCallback: this.dragLogic.refGroupPanelDiv, resolveTitle: this.resolveTitle, ariaControls: this._gridRoleElementId }));
642
644
  var _g = this.props, sort = _g.sort, sortable = _g.sortable, group = _g.group, filter = _g.filter, filterable = _g.filterable, _h = _g.filterOperators, filterOperators = _h === void 0 ? filterCommon_1.operators : _h, headerCellRender = _g.headerCellRender, columnMenu = _g.columnMenu;
@@ -773,18 +775,17 @@ var Grid = /** @class */ (function (_super) {
773
775
  _a), this.props.className), ref: function (el) { _this._element = el; }, "aria-label": this.props.ariaLabel, onKeyDown: this.onKeyDown, onFocus: this.onFocus }, kendo_react_data_tools_1.tableKeyboardNavigationScopeAttributes),
774
776
  toolbar,
775
777
  groupingPanel,
776
- React.createElement(kendo_react_data_tools_1.TableSelection, { selectable: this.props.selectable, onRelease: this.selectionRelease, childRef: function (table) {
777
- _this.tableElement = table;
778
- } },
778
+ React.createElement(kendo_react_data_tools_1.TableSelection, { selectable: this.props.selectable, onRelease: this.selectionRelease, childRef: function (table) { _this.tableElement = table; } },
779
779
  React.createElement("table", { className: (0, kendo_react_common_1.classNames)('k-table k-grid-table', (_b = {}, _b["k-table-".concat(kendo_react_common_1.kendoThemeMaps.sizeMap[this.props.size] || this.props.size)] = this.props.size, _b)), style: { userSelect: tableUserSelect, display: tableDisplay } },
780
780
  colGroups,
781
781
  header,
782
782
  React.createElement("tbody", __assign({ role: 'rowgroup', className: 'k-table-tbody' }, kendo_react_data_tools_1.tableKeyboardNavigationBodyAttributes), body),
783
783
  footer)),
784
- this.props.pageable && pager,
785
784
  enableDragClues && (React.createElement(React.Fragment, null,
786
785
  React.createElement(kendo_react_data_tools_1.DropClue, { ref: this.dragLogic.refDropElementClue }),
787
- React.createElement(kendo_react_data_tools_1.DragClue, { ref: this.dragLogic.refDragElementClue }))))));
786
+ React.createElement(kendo_react_data_tools_1.DragClue, { ref: this.dragLogic.refDragElementClue })))),
787
+ statusBar,
788
+ this.props.pageable && pager));
788
789
  }
789
790
  var wrapperStyle = this.props.style || {};
790
791
  if (this.props.scrollable === 'virtual') {
@@ -804,7 +805,7 @@ var Grid = /** @class */ (function (_super) {
804
805
  }, "aria-label": this.props.ariaLabel, onKeyDown: this.onKeyDown, onFocus: this.onFocus }, kendo_react_data_tools_1.tableKeyboardNavigationScopeAttributes),
805
806
  toolbar,
806
807
  groupingPanel,
807
- React.createElement("div", { role: "grid", className: "k-grid-aria-root", id: this._gridRoleElementId, "aria-colcount": leafColumns.length, "aria-rowcount": total },
808
+ React.createElement("div", { className: 'k-grid-aria-root', role: "grid", "aria-colcount": leafColumns.length, "aria-rowcount": total, id: this._gridRoleElementId },
808
809
  header,
809
810
  React.createElement("div", { className: "k-grid-container", role: "presentation" },
810
811
  React.createElement("div", { ref: this.containerRef, className: "k-grid-content k-virtual-content", onScroll: this.scrollHandler, role: "presentation" },
@@ -821,13 +822,14 @@ var Grid = /** @class */ (function (_super) {
821
822
  React.createElement("tbody", __assign({ className: 'k-table-tbody', ref: this.tableBodyRef, role: 'rowgroup' }, kendo_react_data_tools_1.tableKeyboardNavigationBodyAttributes), body)))),
822
823
  React.createElement("div", { className: "k-height-container", role: "presentation" },
823
824
  React.createElement("div", { style: this.props.scrollable === 'virtual' ?
824
- { 'height': (this.vs.containerHeight) + 'px' } : {} }))),
825
- footer)),
826
- this.props.pageable && pager,
827
- enableDragClues && (React.createElement(React.Fragment, null,
828
- React.createElement(kendo_react_data_tools_1.DropClue, { ref: this.dragLogic.refDropElementClue }),
829
- React.createElement(kendo_react_data_tools_1.DragClue, { ref: this.dragLogic.refDragElementClue }))),
830
- this.showLicenseWatermark && React.createElement(kendo_react_common_2.WatermarkOverlay, null))));
825
+ { 'height': (this.vs.containerHeight) + 'px' } : {} })),
826
+ footer)),
827
+ enableDragClues && (React.createElement(React.Fragment, null,
828
+ React.createElement(kendo_react_data_tools_1.DropClue, { ref: this.dragLogic.refDropElementClue }),
829
+ React.createElement(kendo_react_data_tools_1.DragClue, { ref: this.dragLogic.refDragElementClue }))),
830
+ this.showLicenseWatermark && React.createElement(kendo_react_common_2.WatermarkOverlay, null)),
831
+ statusBar,
832
+ this.props.pageable && pager)));
831
833
  };
832
834
  Grid.prototype.selectionChange = function (options) {
833
835
  if (this.props.onSelectionChange) {
@@ -0,0 +1,47 @@
1
+ import * as React from 'react';
2
+ import { GridSelectionChangeEvent } from './interfaces/events';
3
+ import { GridColumnProps } from './interfaces/GridColumnProps';
4
+ /**
5
+ * Represents the KendoReact Grid's StatusItem object.
6
+ */
7
+ export interface StatusItem {
8
+ /**
9
+ * The type of the status item.
10
+ * Could be `sum`, `min`, `max`, `average`, `count`, `isTrue`, `isFalse`, `earliest` or `latest`.
11
+ */
12
+ type: string;
13
+ /**
14
+ * The calculated value of the status item.
15
+ */
16
+ value: number | boolean | Date;
17
+ /**
18
+ * The formatted value of the status item.
19
+ */
20
+ formattedValue: string;
21
+ }
22
+ /**
23
+ * Represents the props of the KendoReact Grid's StatusBar component.
24
+ */
25
+ export interface StatusBarProps {
26
+ data: StatusItem[];
27
+ }
28
+ /**
29
+ * Represents the KendoReact Grid's StatusBar component.
30
+ */
31
+ export declare const StatusBar: React.FunctionComponent<StatusBarProps>;
32
+ /**
33
+ * @hidden
34
+ */
35
+ export declare const leafColumns: (columns: GridColumnProps[]) => GridColumnProps[];
36
+ /**
37
+ * Represents the arguments of the getStatusData function.
38
+ */
39
+ export interface StatusDataArgs extends Pick<GridSelectionChangeEvent, 'dataItems' | 'target' | 'startColIndex' | 'endColIndex' | 'startRowIndex' | 'endRowIndex' | 'cell'> {
40
+ }
41
+ /**
42
+ * Calculates the status data.
43
+ *
44
+ * @param args StatusDataArgs
45
+ * @returns StatusItem[]
46
+ */
47
+ export declare const getStatusData: (args: StatusDataArgs) => StatusItem[];
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getStatusData = exports.leafColumns = exports.StatusBar = void 0;
13
+ var React = require("react");
14
+ var kendo_react_common_1 = require("@progress/kendo-react-common");
15
+ /**
16
+ * Represents the KendoReact Grid's StatusBar component.
17
+ */
18
+ var StatusBar = function (props) {
19
+ var _a = props.data, data = _a === void 0 ? [] : _a;
20
+ return (React.createElement("div", { className: "k-selection-aggregates k-grid-selection-aggregates" }, data.map(function (item, index) { return (React.createElement("div", { key: index },
21
+ React.createElement("span", { className: "k-selection-aggregates-item-text" },
22
+ item.type,
23
+ ": "),
24
+ React.createElement("span", { className: "k-selection-aggregates-item-value" }, item.formattedValue))); })));
25
+ };
26
+ exports.StatusBar = StatusBar;
27
+ exports.StatusBar.displayName = 'KendoReactGridStatusBar';
28
+ ;
29
+ ;
30
+ /**
31
+ * @hidden
32
+ */
33
+ var leafColumns = function (columns) {
34
+ var _a;
35
+ var result = columns.slice();
36
+ for (var i = 0; i < result.length; i++) {
37
+ while (result[i] && ((_a = result[i].children) === null || _a === void 0 ? void 0 : _a.length)) {
38
+ result.splice.apply(result, __spreadArray([i, 1], result[i].children, false));
39
+ }
40
+ }
41
+ return result;
42
+ };
43
+ exports.leafColumns = leafColumns;
44
+ ;
45
+ /**
46
+ * Calculates the status data.
47
+ *
48
+ * @param args StatusDataArgs
49
+ * @returns StatusItem[]
50
+ */
51
+ var getStatusData = function (args) {
52
+ var dataItems = args.dataItems, target = args.target, startColIndex = args.startColIndex, endColIndex = args.endColIndex, startRowIndex = args.startRowIndex, endRowIndex = args.endRowIndex;
53
+ var columns = (0, exports.leafColumns)(target.columns);
54
+ if (args.cell) {
55
+ columns = columns.slice(startColIndex, endColIndex + 1);
56
+ }
57
+ var getters = columns.map(function (c) { return c.field; }).filter(function (f) { return f && typeof f === 'string'; }).map(function (f) { return (0, kendo_react_common_1.getter)(f); });
58
+ var data = dataItems.slice(startRowIndex, endRowIndex + 1);
59
+ var grouped = { dates: [], numbers: [], booleans: [], others: [] };
60
+ var add = function (value) {
61
+ if (typeof value === 'number') {
62
+ grouped.numbers.push(value);
63
+ }
64
+ else if (typeof value === 'boolean') {
65
+ grouped.booleans.push(value);
66
+ }
67
+ else if (value instanceof Date) {
68
+ grouped.dates.push(value);
69
+ }
70
+ else if (value) {
71
+ grouped.others.push(value);
72
+ }
73
+ };
74
+ data.forEach(function (item) {
75
+ getters.forEach(function (fieldGetter) {
76
+ add(fieldGetter(item));
77
+ });
78
+ });
79
+ var datesAsNumbers = grouped.dates.map(function (d) { return d.getTime(); });
80
+ var isTrueCount = grouped.booleans.filter(function (bool) { return bool; }).length;
81
+ var isFalseCount = grouped.booleans.filter(function (bool) { return !bool; }).length;
82
+ var sum = grouped.numbers.length ? grouped.numbers.reduce(function (acc, curr) { return acc += curr; }, 0) : undefined;
83
+ var aggregates = {
84
+ sum: sum,
85
+ average: typeof sum === 'number' ? sum / grouped.numbers.length : undefined,
86
+ min: grouped.numbers.length ? Math.min.apply(Math, grouped.numbers) : undefined,
87
+ max: grouped.numbers.length ? Math.max.apply(Math, grouped.numbers) : undefined,
88
+ count: grouped.numbers.length + grouped.booleans.length + grouped.dates.length + grouped.others.length,
89
+ isTrue: isTrueCount > 0 ? isTrueCount : undefined,
90
+ isFalse: isFalseCount > 0 ? isFalseCount : undefined,
91
+ earliest: grouped.dates.length ? new Date(Math.min.apply(Math, datesAsNumbers)) : undefined,
92
+ latest: grouped.dates.length ? new Date(Math.max.apply(Math, datesAsNumbers)) : undefined
93
+ };
94
+ var format = function (value, key) {
95
+ if ((key === 'sum' || key === 'average') && typeof value === 'number') {
96
+ return value.toFixed(2);
97
+ }
98
+ else if ((key === 'earliest' || key === 'latest') && value instanceof Date) {
99
+ return value.toLocaleDateString();
100
+ }
101
+ else {
102
+ return String(value);
103
+ }
104
+ };
105
+ var result = [];
106
+ Object.keys(aggregates).forEach(function (a) {
107
+ var type = a;
108
+ var value = aggregates[type];
109
+ if (value !== undefined) {
110
+ result.push({ type: type, value: value, formattedValue: format(value, type) });
111
+ }
112
+ });
113
+ return result;
114
+ };
115
+ exports.getStatusData = getStatusData;
@@ -18,7 +18,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.GroupingIndicator = void 0;
19
19
  var React = require("react");
20
20
  var kendo_react_common_1 = require("@progress/kendo-react-common");
21
- var messages_1 = require("../messages");
22
21
  var kendo_react_intl_1 = require("@progress/kendo-react-intl");
23
22
  var kendo_svg_icons_1 = require("@progress/kendo-svg-icons");
24
23
  /**
@@ -74,7 +73,6 @@ var GroupingIndicator = /** @class */ (function (_super) {
74
73
  }
75
74
  GroupingIndicator.prototype.render = function () {
76
75
  var _this = this;
77
- var localizationService = (0, kendo_react_intl_1.provideLocalizationService)(this);
78
76
  var dir = this.props.dir;
79
77
  return (React.createElement(kendo_react_common_1.Draggable, { onPress: this.onPress, onDrag: this.onDrag, onRelease: this.onRelease, ref: function (component) { _this.draggable = component; } },
80
78
  React.createElement("div", { className: "k-chip k-chip-md k-chip-solid k-chip-solid-base k-rounded-md", onClick: this.sortChange, role: "button", style: { touchAction: 'none' } },
@@ -82,7 +80,7 @@ var GroupingIndicator = /** @class */ (function (_super) {
82
80
  React.createElement(kendo_react_common_1.IconWrap, { name: 'sort-' + dir + '-small', icon: dir === 'asc' ? kendo_svg_icons_1.sortAscSmallIcon : kendo_svg_icons_1.sortDescSmallIcon, size: 'small' })),
83
81
  React.createElement("span", { className: 'k-chip-content' }, this.props.title),
84
82
  React.createElement("span", { className: "k-chip-actions" },
85
- React.createElement("span", { className: "k-chip-action k-chip-remove-action", onClick: this.groupRemove, "aria-label": localizationService.toLanguageString(messages_1.ungroupColumn, messages_1.messages[messages_1.ungroupColumn]) },
83
+ React.createElement("span", { className: "k-chip-action k-chip-remove-action", onClick: this.groupRemove },
86
84
  React.createElement(kendo_react_common_1.IconWrap, { name: 'x-circle', icon: kendo_svg_icons_1.xCircleIcon, size: 'small' }))))));
87
85
  };
88
86
  return GroupingIndicator;
@@ -49,9 +49,8 @@ var FooterRow = /** @class */ (function (_super) {
49
49
  : {},
50
50
  className: (0, kendo_react_common_1.classNames)('k-table-td', column.locked && column.left !== undefined ? 'k-grid-footer-sticky' : ''),
51
51
  key: index,
52
- role: 'columnfooter'
52
+ role: 'gridcell'
53
53
  },
54
- _a['aria-selected'] = false,
55
54
  _a['aria-colindex'] = column.ariaColumnIndex,
56
55
  _a);
57
56
  var cellProps = __assign({ field: column.field, ariaColumnIndex: column.ariaColumnIndex }, tdProps);
@@ -48,7 +48,7 @@ var GroupPanel = /** @class */ (function (_super) {
48
48
  }, onSortChange: function (event, dir) {
49
49
  _this.onGroupSortChange(event, index, groupDesc, dir);
50
50
  }, onPress: _this.props.pressHandler, onDrag: _this.props.dragHandler, onRelease: _this.props.releaseHandler })); });
51
- return (React.createElement("div", { ref: this.props.refCallback, className: "k-grouping-header", role: "toolbar", "aria-label": (0, kendo_react_intl_1.provideLocalizationService)(this).toLanguageString(messages_1.groupPanelAriaLabel, messages_1.messages[messages_1.groupPanelAriaLabel]), "aria-controls": this.props.ariaControls },
51
+ return (React.createElement("div", { ref: this.props.refCallback, className: "k-grouping-header", role: "toolbar", "aria-label": (0, kendo_react_intl_1.provideLocalizationService)(this).toLanguageString(messages_1.groupPanelAriaLabel, messages_1.messages[messages_1.groupPanelAriaLabel]), "aria-controls": this.props.ariaControls || '' },
52
52
  React.createElement("div", { className: "k-chip-list k-chip-list-md", role: "none" }, groups),
53
53
  React.createElement("div", { className: "k-grouping-drop-container" },
54
54
  !groups.length && (0, kendo_react_intl_1.provideLocalizationService)(this).toLanguageString(messages_1.groupPanelEmpty, messages_1.messages[messages_1.groupPanelEmpty]),