@progress/kendo-react-pivotgrid 4.13.1-dev.202112140947 → 4.14.0-dev.202112151745

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.
@@ -110,11 +110,15 @@ export var PivotGrid = React.forwardRef(function (props, ref) {
110
110
  };
111
111
  var setRowsTemplate = React.useCallback(function () {
112
112
  if (element.current && columnHeadersTable.current) {
113
+ // Reset gridTemplateRows before getting the new size
114
+ element.current.style.gridTemplateRows = '';
113
115
  element.current.style.gridTemplateRows = columnHeadersTable.current.offsetHeight + "px 1fr";
114
116
  }
115
117
  }, []);
116
118
  var setColumnsTemplate = React.useCallback(function () {
117
119
  if (element.current && rowHeadersTable.current) {
120
+ // Reset gridTemplateColumns before getting the new size
121
+ element.current.style.gridTemplateColumns = '';
118
122
  element.current.style.gridTemplateColumns = rowHeadersTable.current.offsetWidth + "px 1fr";
119
123
  }
120
124
  }, []);
@@ -176,7 +180,7 @@ export var PivotGrid = React.forwardRef(function (props, ref) {
176
180
  React.createElement("div", { ref: valuesHeadersContainer, className: "k-pivotgrid-values", onScroll: handleValuesContainerScroll },
177
181
  React.createElement("table", { className: "k-pivotgrid-table" },
178
182
  React.createElement("colgroup", null, dataColumns),
179
- React.createElement("tbody", { className: "k-pivotgrid-tbody" }, measures.map(function (row, rowId) { return (React.createElement(DataRowComponent, __assign({ key: generateKey(rowHeaderLeafs[rowId].path) }, RowProps, { path: rowHeaderLeafs[rowId].path }), row.cells.map(function (cell, cellId) { return (React.createElement(CellComponent, __assign({ key: "" + generateDataKey(cell.rowTuple.members, cell.columnTuple.members), "data-key": "" + generateDataKey(cell.rowTuple.members, cell.columnTuple.members) }, CellProps, { rowPath: cell.rowTuple.members.map(function (m) { return m.name; }), columnPath: cell.columnTuple.members.map(function (m) { return m.name; }), dataItem: cell, total: rowHeaderLeafs[rowId].total || columnHeaderLeafs[cellId].total }), (cell && cell.data) ? cell.data.fmtValue : '')); }))); }))))));
183
+ React.createElement("tbody", { className: "k-pivotgrid-tbody" }, measures.map(function (row, rowId) { return (React.createElement(DataRowComponent, __assign({ key: generateKey(rowHeaderLeafs[rowId].path) }, RowProps, { path: rowHeaderLeafs[rowId].path }), row.cells.map(function (cell, cellId) { return (React.createElement(CellComponent, __assign({ key: "" + generateDataKey(cell.rowTuple.members, cell.columnTuple.members), "data-key": "" + generateDataKey(cell.rowTuple.members, cell.columnTuple.members) }, CellProps, { rowPath: cell.rowTuple.members.map(function (m) { return m.name; }), columnPath: cell.columnTuple.members.map(function (m) { return m.name; }), dataItem: cell, total: rowHeaderLeafs[rowId].total || columnHeaderLeafs[cellId].total }), (cell && cell.data && cell.data.fmtValue) ? cell.data.fmtValue : '\u00A0')); }))); }))))));
180
184
  });
181
185
  var defaultProps = {
182
186
  rowAxes: [],
@@ -79,13 +79,13 @@ export var PivotGridAxisEditor = React.forwardRef(function (props, ref) {
79
79
  dispatchState({ type: PIVOT_CONFIGURATOR_ACTION.setDragItem, payload: props.dataItem });
80
80
  };
81
81
  var handleRelease = function () {
82
+ setDrag(false);
82
83
  if (state.dragItem) {
83
84
  if (element.current) {
84
85
  element.current.style.transform = null;
85
86
  }
86
87
  dispatchState({ type: PIVOT_CONFIGURATOR_ACTION.drop, payload: props.dataItem });
87
88
  }
88
- setDrag(false);
89
89
  };
90
90
  var handleMouseEnter = function (event) {
91
91
  if (state.dragItem) {
@@ -65,7 +65,7 @@ export var usePivotConfiguratorEditor = function (props, target) {
65
65
  props.onChange('measureAxes', { value: newState.measureAxes });
66
66
  }
67
67
  if (newState.sort !== undefined) {
68
- props.onChange('sort', { value: sort });
68
+ props.onChange('sort', { value: newState.sort });
69
69
  }
70
70
  if (newState.filter !== undefined) {
71
71
  props.onChange('filter', { value: newState.filter });
@@ -0,0 +1,73 @@
1
+ import { PivotGridAxis, Measure, Dimension } from '@progress/kendo-pivotgrid-common';
2
+ import { SortDescriptor, FilterDescriptor } from '@progress/kendo-data-query';
3
+ import { PivotGridProps } from '../PivotGrid';
4
+ import { PivotGridConfiguratorProps } from '../components/Configurator';
5
+ /**
6
+ * Represents the arguments of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook.
7
+ */
8
+ export interface PivotLocalDataServiceArgs {
9
+ /**
10
+ * Represents the dimensions object of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
11
+ */
12
+ dimensions: {
13
+ [key: string]: Dimension;
14
+ };
15
+ /**
16
+ * Represents the measures collection of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
17
+ */
18
+ measures: Measure[];
19
+ /**
20
+ * Represents the local data of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
21
+ */
22
+ data: any[];
23
+ /**
24
+ * Represents the default column axes configuration of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
25
+ */
26
+ defaultColumnAxes: PivotGridAxis[];
27
+ /**
28
+ * Represents the default row axes configuration of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
29
+ */
30
+ defaultRowAxes: PivotGridAxis[];
31
+ /**
32
+ * Represents the default measure axes configuration of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
33
+ */
34
+ defaultMeasureAxes: PivotGridAxis[];
35
+ /**
36
+ * Represents the default sort descriptors of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
37
+ */
38
+ defaultSort: SortDescriptor[];
39
+ /**
40
+ * Represents the default filter descriptors of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
41
+ */
42
+ defaultFilter: FilterDescriptor[];
43
+ }
44
+ /**
45
+ * Represents the `state` of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
46
+ */
47
+ export interface PivotLocalDataServiceState {
48
+ /**
49
+ * Represents the `PivotGrid` component props.
50
+ */
51
+ pivotProps: PivotGridProps;
52
+ /**
53
+ * Represents the `PivotGridConfigurator` component props.
54
+ */
55
+ configuratorProps: PivotGridConfiguratorProps;
56
+ }
57
+ /**
58
+ * A [custom React hook](https://reactjs.org/docs/hooks-custom.html) which provides data-binding to local data.
59
+ */
60
+ export declare const usePivotLocalDataService: (args: PivotLocalDataServiceArgs) => PivotLocalDataServiceState;
61
+ /**
62
+ * Represents the properties of the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
63
+ */
64
+ export interface PivotLocalDataServiceProps extends PivotLocalDataServiceArgs {
65
+ /**
66
+ * Represents the children prop of the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
67
+ */
68
+ children: (args: PivotLocalDataServiceState) => any;
69
+ }
70
+ /**
71
+ * A [React higher-order component](https://reactjs.org/docs/higher-order-components.html) which provides data-binding to local data.
72
+ */
73
+ export declare const PivotLocalDataService: (props: PivotLocalDataServiceProps) => any;
@@ -0,0 +1,88 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ /* eslint-disable max-len */
13
+ import * as React from 'react';
14
+ import { createDataTree, rootFields, createLocalDataState, createFlatSchemaDimensions } from '@progress/kendo-pivotgrid-common';
15
+ ;
16
+ var dataField = 'aggregate';
17
+ var columnsData = 'columns';
18
+ var bindingFields = { dataField: dataField, columnsData: columnsData };
19
+ var stringSeparator = '&';
20
+ /**
21
+ * A [custom React hook](https://reactjs.org/docs/hooks-custom.html) which provides data-binding to local data.
22
+ */
23
+ export var usePivotLocalDataService = function (args) {
24
+ var _a = React.useState(args.defaultColumnAxes || []), columnAxes = _a[0], setColumnAxes = _a[1];
25
+ var _b = React.useState(args.defaultRowAxes || []), rowAxes = _b[0], setRowAxes = _b[1];
26
+ var _c = React.useState(args.defaultMeasureAxes || []), measureAxes = _c[0], setMeasureAxes = _c[1];
27
+ var _d = React.useState(args.defaultSort || []), sort = _d[0], setSort = _d[1];
28
+ var _e = React.useState(args.defaultFilter || []), filter = _e[0], setFilter = _e[1];
29
+ var handleRowAxesChange = React.useCallback(function (event) {
30
+ setRowAxes(event.value);
31
+ }, []);
32
+ var handleColumnAxesChange = React.useCallback(function (event) {
33
+ setColumnAxes(event.value);
34
+ }, []);
35
+ var handleMeasureAxesChange = function (event) {
36
+ setMeasureAxes(event.value);
37
+ };
38
+ var handleSortChange = function (event) {
39
+ setSort(event.value);
40
+ };
41
+ var handleFilterChange = function (event) {
42
+ setFilter(event.value);
43
+ };
44
+ var rootColumnAxes = React.useMemo(function () { return Array.from(rootFields(columnAxes).keys()).join(stringSeparator); }, [columnAxes]);
45
+ var rootRowAxes = React.useMemo(function () { return Array.from(rootFields(rowAxes).keys()).join(stringSeparator); }, [rowAxes]);
46
+ var createAxisSettings = React.useCallback(function (key) { return (__assign({ key: key }, args.dimensions[key])); }, [args.dimensions]);
47
+ var columnSettings = React.useMemo(function () { return rootColumnAxes.split(stringSeparator).map(createAxisSettings); }, [rootColumnAxes, createAxisSettings]);
48
+ var rowSettings = React.useMemo(function () { return rootRowAxes.split(stringSeparator).map(createAxisSettings); }, [rootRowAxes, createAxisSettings]);
49
+ var measuresSettings = React.useMemo(function () { return measureAxes.map(function (m) { return args.measures.find(function (meas) { return String(meas.name) === String(m.name); }); }).filter(Boolean); }, [measureAxes, args.measures]);
50
+ var dataTree = React.useMemo(function () { return createDataTree(args.data, rowSettings, columnSettings, measuresSettings, bindingFields, filter); }, [args.data, rowSettings, columnSettings, measuresSettings, filter]);
51
+ var configuratorData = React.useMemo(function () { return createFlatSchemaDimensions(args.dimensions, args.measures); }, [args.dimensions, args.measures]);
52
+ var dataState = React.useMemo(function () { return createLocalDataState({
53
+ dataTree: dataTree, rowSettings: rowSettings, columnSettings: columnSettings,
54
+ rowAxes: rowAxes, columnAxes: columnAxes, measures: measuresSettings,
55
+ sort: sort, fields: bindingFields
56
+ }); }, [columnAxes, columnSettings, dataTree, measuresSettings, rowAxes, rowSettings, sort]);
57
+ return {
58
+ pivotProps: {
59
+ rowAxes: rowAxes,
60
+ columnAxes: columnAxes,
61
+ data: dataState.data,
62
+ rows: dataState.rows,
63
+ columns: dataState.columns,
64
+ onRowAxesChange: handleRowAxesChange,
65
+ onColumnAxesChange: handleColumnAxesChange
66
+ },
67
+ configuratorProps: {
68
+ sort: sort,
69
+ onSortChange: handleSortChange,
70
+ filter: filter,
71
+ onFilterChange: handleFilterChange,
72
+ data: configuratorData,
73
+ rowAxes: rowAxes,
74
+ columnAxes: columnAxes,
75
+ measureAxes: measureAxes,
76
+ onRowAxesChange: handleRowAxesChange,
77
+ onColumnAxesChange: handleColumnAxesChange,
78
+ onMeasureAxesChange: handleMeasureAxesChange
79
+ }
80
+ };
81
+ };
82
+ /**
83
+ * A [React higher-order component](https://reactjs.org/docs/higher-order-components.html) which provides data-binding to local data.
84
+ */
85
+ export var PivotLocalDataService = function (props) {
86
+ var args = usePivotLocalDataService(props);
87
+ return props.children(args);
88
+ };
package/dist/es/main.d.ts CHANGED
@@ -12,5 +12,6 @@ export { PivotGridAxesEditor, PivotGridAxesEditorProps, PivotGridAxesEditorHandl
12
12
  export { PivotGridAxisEditor, PivotGridAxisEditorProps, PivotGridAxisEditorHandle } from './components/AxisEditor';
13
13
  export { PivotGridAxisFilterFieldsEditor, PivotGridAxisFilterFieldsEditorProps, PivotGridAxisFilterFieldsEditorHandle, PivotGridAxisFilterFieldExpandEvent, PivotGridAxisFilterFieldsExpandChangeEvent } from './components/AxisFilterFieldsEditor';
14
14
  export { PivotOLAPService, usePivotOLAPService, PivotOLAPServiceArgs, PivotOLAPServiceProps, PivotOLAPServiceState } from './hooks/usePivotOLAPService';
15
+ export { usePivotLocalDataService, PivotLocalDataService, PivotLocalDataServiceArgs, PivotLocalDataServiceProps, PivotLocalDataServiceState } from './hooks/usePivotLocalDataService';
15
16
  export { PivotGridTreeViewData, PivotGridAxesChangeEvent, PivotGridConfiguratorAxesChangeEvent, PivotGridConfiguratorSortChangeEvent, PivotGridConfiguratorFilterChangeEvent } from './models';
16
- export { PivotGridAxis, AxisDataItem, DimensionField, HierarchyField, KPIField, KPIMeasureField, LevelField, MeasureField, MemberField, PivotDataItem } from '@progress/kendo-pivotgrid-common';
17
+ export { PivotGridAxis, AxisDataItem, DimensionField, HierarchyField, KPIField, KPIMeasureField, LevelField, MeasureField, MemberField, PivotDataItem, sumAggregate, averageAggregate, minAggregate, maxAggregate, Aggregate, Dimension, Measure } from '@progress/kendo-pivotgrid-common';
package/dist/es/main.js CHANGED
@@ -12,3 +12,5 @@ export { PivotGridAxesEditor, PivotGridConfiguratorEditorAxesContext } from './c
12
12
  export { PivotGridAxisEditor } from './components/AxisEditor';
13
13
  export { PivotGridAxisFilterFieldsEditor } from './components/AxisFilterFieldsEditor';
14
14
  export { PivotOLAPService, usePivotOLAPService } from './hooks/usePivotOLAPService';
15
+ export { usePivotLocalDataService, PivotLocalDataService } from './hooks/usePivotLocalDataService';
16
+ export { sumAggregate, averageAggregate, minAggregate, maxAggregate } from '@progress/kendo-pivotgrid-common';
@@ -5,7 +5,7 @@ export var packageMetadata = {
5
5
  name: '@progress/kendo-react-pivotgrid',
6
6
  productName: 'KendoReact',
7
7
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1639474815,
8
+ publishDate: 1639589901,
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
  };
@@ -112,11 +112,15 @@ exports.PivotGrid = React.forwardRef(function (props, ref) {
112
112
  };
113
113
  var setRowsTemplate = React.useCallback(function () {
114
114
  if (element.current && columnHeadersTable.current) {
115
+ // Reset gridTemplateRows before getting the new size
116
+ element.current.style.gridTemplateRows = '';
115
117
  element.current.style.gridTemplateRows = columnHeadersTable.current.offsetHeight + "px 1fr";
116
118
  }
117
119
  }, []);
118
120
  var setColumnsTemplate = React.useCallback(function () {
119
121
  if (element.current && rowHeadersTable.current) {
122
+ // Reset gridTemplateColumns before getting the new size
123
+ element.current.style.gridTemplateColumns = '';
120
124
  element.current.style.gridTemplateColumns = rowHeadersTable.current.offsetWidth + "px 1fr";
121
125
  }
122
126
  }, []);
@@ -178,7 +182,7 @@ exports.PivotGrid = React.forwardRef(function (props, ref) {
178
182
  React.createElement("div", { ref: valuesHeadersContainer, className: "k-pivotgrid-values", onScroll: handleValuesContainerScroll },
179
183
  React.createElement("table", { className: "k-pivotgrid-table" },
180
184
  React.createElement("colgroup", null, dataColumns),
181
- React.createElement("tbody", { className: "k-pivotgrid-tbody" }, measures.map(function (row, rowId) { return (React.createElement(DataRowComponent, __assign({ key: utils_1.generateKey(rowHeaderLeafs[rowId].path) }, RowProps, { path: rowHeaderLeafs[rowId].path }), row.cells.map(function (cell, cellId) { return (React.createElement(CellComponent, __assign({ key: "" + utils_1.generateDataKey(cell.rowTuple.members, cell.columnTuple.members), "data-key": "" + utils_1.generateDataKey(cell.rowTuple.members, cell.columnTuple.members) }, CellProps, { rowPath: cell.rowTuple.members.map(function (m) { return m.name; }), columnPath: cell.columnTuple.members.map(function (m) { return m.name; }), dataItem: cell, total: rowHeaderLeafs[rowId].total || columnHeaderLeafs[cellId].total }), (cell && cell.data) ? cell.data.fmtValue : '')); }))); }))))));
185
+ React.createElement("tbody", { className: "k-pivotgrid-tbody" }, measures.map(function (row, rowId) { return (React.createElement(DataRowComponent, __assign({ key: utils_1.generateKey(rowHeaderLeafs[rowId].path) }, RowProps, { path: rowHeaderLeafs[rowId].path }), row.cells.map(function (cell, cellId) { return (React.createElement(CellComponent, __assign({ key: "" + utils_1.generateDataKey(cell.rowTuple.members, cell.columnTuple.members), "data-key": "" + utils_1.generateDataKey(cell.rowTuple.members, cell.columnTuple.members) }, CellProps, { rowPath: cell.rowTuple.members.map(function (m) { return m.name; }), columnPath: cell.columnTuple.members.map(function (m) { return m.name; }), dataItem: cell, total: rowHeaderLeafs[rowId].total || columnHeaderLeafs[cellId].total }), (cell && cell.data && cell.data.fmtValue) ? cell.data.fmtValue : '\u00A0')); }))); }))))));
182
186
  });
183
187
  var defaultProps = {
184
188
  rowAxes: [],
@@ -81,13 +81,13 @@ exports.PivotGridAxisEditor = React.forwardRef(function (props, ref) {
81
81
  dispatchState({ type: hooks_1.PIVOT_CONFIGURATOR_ACTION.setDragItem, payload: props.dataItem });
82
82
  };
83
83
  var handleRelease = function () {
84
+ setDrag(false);
84
85
  if (state.dragItem) {
85
86
  if (element.current) {
86
87
  element.current.style.transform = null;
87
88
  }
88
89
  dispatchState({ type: hooks_1.PIVOT_CONFIGURATOR_ACTION.drop, payload: props.dataItem });
89
90
  }
90
- setDrag(false);
91
91
  };
92
92
  var handleMouseEnter = function (event) {
93
93
  if (state.dragItem) {
@@ -67,7 +67,7 @@ exports.usePivotConfiguratorEditor = function (props, target) {
67
67
  props.onChange('measureAxes', { value: newState.measureAxes });
68
68
  }
69
69
  if (newState.sort !== undefined) {
70
- props.onChange('sort', { value: sort });
70
+ props.onChange('sort', { value: newState.sort });
71
71
  }
72
72
  if (newState.filter !== undefined) {
73
73
  props.onChange('filter', { value: newState.filter });
@@ -0,0 +1,73 @@
1
+ import { PivotGridAxis, Measure, Dimension } from '@progress/kendo-pivotgrid-common';
2
+ import { SortDescriptor, FilterDescriptor } from '@progress/kendo-data-query';
3
+ import { PivotGridProps } from '../PivotGrid';
4
+ import { PivotGridConfiguratorProps } from '../components/Configurator';
5
+ /**
6
+ * Represents the arguments of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook.
7
+ */
8
+ export interface PivotLocalDataServiceArgs {
9
+ /**
10
+ * Represents the dimensions object of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
11
+ */
12
+ dimensions: {
13
+ [key: string]: Dimension;
14
+ };
15
+ /**
16
+ * Represents the measures collection of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
17
+ */
18
+ measures: Measure[];
19
+ /**
20
+ * Represents the local data of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
21
+ */
22
+ data: any[];
23
+ /**
24
+ * Represents the default column axes configuration of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
25
+ */
26
+ defaultColumnAxes: PivotGridAxis[];
27
+ /**
28
+ * Represents the default row axes configuration of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
29
+ */
30
+ defaultRowAxes: PivotGridAxis[];
31
+ /**
32
+ * Represents the default measure axes configuration of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
33
+ */
34
+ defaultMeasureAxes: PivotGridAxis[];
35
+ /**
36
+ * Represents the default sort descriptors of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
37
+ */
38
+ defaultSort: SortDescriptor[];
39
+ /**
40
+ * Represents the default filter descriptors of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
41
+ */
42
+ defaultFilter: FilterDescriptor[];
43
+ }
44
+ /**
45
+ * Represents the `state` of the [usePivotLocalDataService]({% slug api_pivotgrid_usepivotlocaldataservice %}) hook and the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
46
+ */
47
+ export interface PivotLocalDataServiceState {
48
+ /**
49
+ * Represents the `PivotGrid` component props.
50
+ */
51
+ pivotProps: PivotGridProps;
52
+ /**
53
+ * Represents the `PivotGridConfigurator` component props.
54
+ */
55
+ configuratorProps: PivotGridConfiguratorProps;
56
+ }
57
+ /**
58
+ * A [custom React hook](https://reactjs.org/docs/hooks-custom.html) which provides data-binding to local data.
59
+ */
60
+ export declare const usePivotLocalDataService: (args: PivotLocalDataServiceArgs) => PivotLocalDataServiceState;
61
+ /**
62
+ * Represents the properties of the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
63
+ */
64
+ export interface PivotLocalDataServiceProps extends PivotLocalDataServiceArgs {
65
+ /**
66
+ * Represents the children prop of the [PivotLocalDataService]({% slug api_pivotgrid_pivotlocaldataservice %}) component.
67
+ */
68
+ children: (args: PivotLocalDataServiceState) => any;
69
+ }
70
+ /**
71
+ * A [React higher-order component](https://reactjs.org/docs/higher-order-components.html) which provides data-binding to local data.
72
+ */
73
+ export declare const PivotLocalDataService: (props: PivotLocalDataServiceProps) => any;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ /* eslint-disable max-len */
15
+ var React = require("react");
16
+ var kendo_pivotgrid_common_1 = require("@progress/kendo-pivotgrid-common");
17
+ ;
18
+ var dataField = 'aggregate';
19
+ var columnsData = 'columns';
20
+ var bindingFields = { dataField: dataField, columnsData: columnsData };
21
+ var stringSeparator = '&';
22
+ /**
23
+ * A [custom React hook](https://reactjs.org/docs/hooks-custom.html) which provides data-binding to local data.
24
+ */
25
+ exports.usePivotLocalDataService = function (args) {
26
+ var _a = React.useState(args.defaultColumnAxes || []), columnAxes = _a[0], setColumnAxes = _a[1];
27
+ var _b = React.useState(args.defaultRowAxes || []), rowAxes = _b[0], setRowAxes = _b[1];
28
+ var _c = React.useState(args.defaultMeasureAxes || []), measureAxes = _c[0], setMeasureAxes = _c[1];
29
+ var _d = React.useState(args.defaultSort || []), sort = _d[0], setSort = _d[1];
30
+ var _e = React.useState(args.defaultFilter || []), filter = _e[0], setFilter = _e[1];
31
+ var handleRowAxesChange = React.useCallback(function (event) {
32
+ setRowAxes(event.value);
33
+ }, []);
34
+ var handleColumnAxesChange = React.useCallback(function (event) {
35
+ setColumnAxes(event.value);
36
+ }, []);
37
+ var handleMeasureAxesChange = function (event) {
38
+ setMeasureAxes(event.value);
39
+ };
40
+ var handleSortChange = function (event) {
41
+ setSort(event.value);
42
+ };
43
+ var handleFilterChange = function (event) {
44
+ setFilter(event.value);
45
+ };
46
+ var rootColumnAxes = React.useMemo(function () { return Array.from(kendo_pivotgrid_common_1.rootFields(columnAxes).keys()).join(stringSeparator); }, [columnAxes]);
47
+ var rootRowAxes = React.useMemo(function () { return Array.from(kendo_pivotgrid_common_1.rootFields(rowAxes).keys()).join(stringSeparator); }, [rowAxes]);
48
+ var createAxisSettings = React.useCallback(function (key) { return (__assign({ key: key }, args.dimensions[key])); }, [args.dimensions]);
49
+ var columnSettings = React.useMemo(function () { return rootColumnAxes.split(stringSeparator).map(createAxisSettings); }, [rootColumnAxes, createAxisSettings]);
50
+ var rowSettings = React.useMemo(function () { return rootRowAxes.split(stringSeparator).map(createAxisSettings); }, [rootRowAxes, createAxisSettings]);
51
+ var measuresSettings = React.useMemo(function () { return measureAxes.map(function (m) { return args.measures.find(function (meas) { return String(meas.name) === String(m.name); }); }).filter(Boolean); }, [measureAxes, args.measures]);
52
+ var dataTree = React.useMemo(function () { return kendo_pivotgrid_common_1.createDataTree(args.data, rowSettings, columnSettings, measuresSettings, bindingFields, filter); }, [args.data, rowSettings, columnSettings, measuresSettings, filter]);
53
+ var configuratorData = React.useMemo(function () { return kendo_pivotgrid_common_1.createFlatSchemaDimensions(args.dimensions, args.measures); }, [args.dimensions, args.measures]);
54
+ var dataState = React.useMemo(function () { return kendo_pivotgrid_common_1.createLocalDataState({
55
+ dataTree: dataTree, rowSettings: rowSettings, columnSettings: columnSettings,
56
+ rowAxes: rowAxes, columnAxes: columnAxes, measures: measuresSettings,
57
+ sort: sort, fields: bindingFields
58
+ }); }, [columnAxes, columnSettings, dataTree, measuresSettings, rowAxes, rowSettings, sort]);
59
+ return {
60
+ pivotProps: {
61
+ rowAxes: rowAxes,
62
+ columnAxes: columnAxes,
63
+ data: dataState.data,
64
+ rows: dataState.rows,
65
+ columns: dataState.columns,
66
+ onRowAxesChange: handleRowAxesChange,
67
+ onColumnAxesChange: handleColumnAxesChange
68
+ },
69
+ configuratorProps: {
70
+ sort: sort,
71
+ onSortChange: handleSortChange,
72
+ filter: filter,
73
+ onFilterChange: handleFilterChange,
74
+ data: configuratorData,
75
+ rowAxes: rowAxes,
76
+ columnAxes: columnAxes,
77
+ measureAxes: measureAxes,
78
+ onRowAxesChange: handleRowAxesChange,
79
+ onColumnAxesChange: handleColumnAxesChange,
80
+ onMeasureAxesChange: handleMeasureAxesChange
81
+ }
82
+ };
83
+ };
84
+ /**
85
+ * A [React higher-order component](https://reactjs.org/docs/higher-order-components.html) which provides data-binding to local data.
86
+ */
87
+ exports.PivotLocalDataService = function (props) {
88
+ var args = exports.usePivotLocalDataService(props);
89
+ return props.children(args);
90
+ };
@@ -12,5 +12,6 @@ export { PivotGridAxesEditor, PivotGridAxesEditorProps, PivotGridAxesEditorHandl
12
12
  export { PivotGridAxisEditor, PivotGridAxisEditorProps, PivotGridAxisEditorHandle } from './components/AxisEditor';
13
13
  export { PivotGridAxisFilterFieldsEditor, PivotGridAxisFilterFieldsEditorProps, PivotGridAxisFilterFieldsEditorHandle, PivotGridAxisFilterFieldExpandEvent, PivotGridAxisFilterFieldsExpandChangeEvent } from './components/AxisFilterFieldsEditor';
14
14
  export { PivotOLAPService, usePivotOLAPService, PivotOLAPServiceArgs, PivotOLAPServiceProps, PivotOLAPServiceState } from './hooks/usePivotOLAPService';
15
+ export { usePivotLocalDataService, PivotLocalDataService, PivotLocalDataServiceArgs, PivotLocalDataServiceProps, PivotLocalDataServiceState } from './hooks/usePivotLocalDataService';
15
16
  export { PivotGridTreeViewData, PivotGridAxesChangeEvent, PivotGridConfiguratorAxesChangeEvent, PivotGridConfiguratorSortChangeEvent, PivotGridConfiguratorFilterChangeEvent } from './models';
16
- export { PivotGridAxis, AxisDataItem, DimensionField, HierarchyField, KPIField, KPIMeasureField, LevelField, MeasureField, MemberField, PivotDataItem } from '@progress/kendo-pivotgrid-common';
17
+ export { PivotGridAxis, AxisDataItem, DimensionField, HierarchyField, KPIField, KPIMeasureField, LevelField, MeasureField, MemberField, PivotDataItem, sumAggregate, averageAggregate, minAggregate, maxAggregate, Aggregate, Dimension, Measure } from '@progress/kendo-pivotgrid-common';
package/dist/npm/main.js CHANGED
@@ -30,3 +30,11 @@ exports.PivotGridAxisFilterFieldsEditor = AxisFilterFieldsEditor_1.PivotGridAxis
30
30
  var usePivotOLAPService_1 = require("./hooks/usePivotOLAPService");
31
31
  exports.PivotOLAPService = usePivotOLAPService_1.PivotOLAPService;
32
32
  exports.usePivotOLAPService = usePivotOLAPService_1.usePivotOLAPService;
33
+ var usePivotLocalDataService_1 = require("./hooks/usePivotLocalDataService");
34
+ exports.usePivotLocalDataService = usePivotLocalDataService_1.usePivotLocalDataService;
35
+ exports.PivotLocalDataService = usePivotLocalDataService_1.PivotLocalDataService;
36
+ var kendo_pivotgrid_common_1 = require("@progress/kendo-pivotgrid-common");
37
+ exports.sumAggregate = kendo_pivotgrid_common_1.sumAggregate;
38
+ exports.averageAggregate = kendo_pivotgrid_common_1.averageAggregate;
39
+ exports.minAggregate = kendo_pivotgrid_common_1.minAggregate;
40
+ exports.maxAggregate = kendo_pivotgrid_common_1.maxAggregate;
@@ -7,7 +7,7 @@ exports.packageMetadata = {
7
7
  name: '@progress/kendo-react-pivotgrid',
8
8
  productName: 'KendoReact',
9
9
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
10
- publishDate: 1639474815,
10
+ publishDate: 1639589901,
11
11
  version: '',
12
12
  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'
13
13
  };