rsuite 5.6.4 → 5.6.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [5.6.5](https://github.com/rsuite/rsuite/compare/v5.6.4...v5.6.5) (2022-03-17)
2
+
3
+ ### Features
4
+
5
+ - **Pickers:** `groupBy` supports dot notation ([#2397](https://github.com/rsuite/rsuite/issues/2397)) ([2ba7c0b](https://github.com/rsuite/rsuite/commit/2ba7c0b622c68b2fc526aa7ad2feaa8e73767e9c))
6
+
1
7
  ## [5.6.4](https://github.com/rsuite/rsuite/compare/v5.6.3...v5.6.4) (2022-03-10)
2
8
 
3
9
  ### Bug Fixes
@@ -1,3 +1,3 @@
1
1
  export declare const KEY_GROUP: string | symbol;
2
2
  export declare const KEY_GROUP_TITLE = "groupTitle";
3
- export default function getDataGroupBy(data: any[] | undefined, key: string, sort: any): any[];
3
+ export default function getDataGroupBy(data: any[] | undefined, key: string, sort?: any): any[];
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  exports.__esModule = true;
4
6
  exports.default = getDataGroupBy;
5
7
  exports.KEY_GROUP_TITLE = exports.KEY_GROUP = void 0;
6
8
 
9
+ var _get2 = _interopRequireDefault(require("lodash/get"));
10
+
7
11
  var _treeUtils = require("../utils/treeUtils");
8
12
 
9
13
  var hasSymbol = typeof Symbol === 'function';
@@ -20,11 +24,17 @@ function getDataGroupBy(data, key, sort) {
20
24
  var tempData = {};
21
25
  var isSort = typeof sort === 'function';
22
26
  data.forEach(function (item) {
23
- if (!tempData[item[key]]) {
24
- tempData[item[key]] = [];
27
+ // this will allow getting data using dot notation
28
+ // i.e groupBy="country.name" as country will be a nested object
29
+ // to the item and the name will be nested key to the country object
30
+ // can be used with values in arrays, i.e groupBy="addresses.0.country.name"
31
+ var groupByValue = (0, _get2.default)(item, key, '');
32
+
33
+ if (!tempData[groupByValue]) {
34
+ tempData[groupByValue] = [];
25
35
  }
26
36
 
27
- tempData[item[key]].push(item);
37
+ tempData[groupByValue].push(item);
28
38
  });
29
39
  var nextData = Object.entries(tempData).map(function (_ref) {
30
40
  var _ref2;
package/dist/rsuite.js CHANGED
@@ -5004,7 +5004,7 @@ eval("\n\nexports.__esModule = true;\nexports.default = getDOMNode;\n\nvar _reac
5004
5004
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
5005
5005
 
5006
5006
  "use strict";
5007
- eval("\n\nexports.__esModule = true;\nexports.default = getDataGroupBy;\nexports.KEY_GROUP_TITLE = exports.KEY_GROUP = void 0;\n\nvar _treeUtils = __webpack_require__(/*! ../utils/treeUtils */ \"./src/utils/treeUtils.ts\");\n\nvar hasSymbol = typeof Symbol === 'function';\nvar KEY_GROUP = hasSymbol ? Symbol('_$grouped') : '_$grouped';\nexports.KEY_GROUP = KEY_GROUP;\nvar KEY_GROUP_TITLE = 'groupTitle';\nexports.KEY_GROUP_TITLE = KEY_GROUP_TITLE;\n\nfunction getDataGroupBy(data, key, sort) {\n if (data === void 0) {\n data = [];\n }\n\n var tempData = {};\n var isSort = typeof sort === 'function';\n data.forEach(function (item) {\n if (!tempData[item[key]]) {\n tempData[item[key]] = [];\n }\n\n tempData[item[key]].push(item);\n });\n var nextData = Object.entries(tempData).map(function (_ref) {\n var _ref2;\n\n var groupTitle = _ref[0],\n children = _ref[1];\n return _ref2 = {\n children: isSort ? children.sort(sort(false)) : children\n }, _ref2[KEY_GROUP_TITLE] = groupTitle, _ref2[KEY_GROUP] = true, _ref2;\n });\n\n if (isSort) {\n nextData = nextData.sort(sort(true));\n }\n\n return (0, _treeUtils.flattenTree)(nextData);\n}\n\n//# sourceURL=webpack://rsuite/./src/utils/getDataGroupBy.ts?");
5007
+ eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\n\nexports.__esModule = true;\nexports.default = getDataGroupBy;\nexports.KEY_GROUP_TITLE = exports.KEY_GROUP = void 0;\n\nvar _get2 = _interopRequireDefault(__webpack_require__(/*! lodash/get */ \"./node_modules/lodash/get.js\"));\n\nvar _treeUtils = __webpack_require__(/*! ../utils/treeUtils */ \"./src/utils/treeUtils.ts\");\n\nvar hasSymbol = typeof Symbol === 'function';\nvar KEY_GROUP = hasSymbol ? Symbol('_$grouped') : '_$grouped';\nexports.KEY_GROUP = KEY_GROUP;\nvar KEY_GROUP_TITLE = 'groupTitle';\nexports.KEY_GROUP_TITLE = KEY_GROUP_TITLE;\n\nfunction getDataGroupBy(data, key, sort) {\n if (data === void 0) {\n data = [];\n }\n\n var tempData = {};\n var isSort = typeof sort === 'function';\n data.forEach(function (item) {\n // this will allow getting data using dot notation\n // i.e groupBy=\"country.name\" as country will be a nested object\n // to the item and the name will be nested key to the country object\n // can be used with values in arrays, i.e groupBy=\"addresses.0.country.name\"\n var groupByValue = (0, _get2.default)(item, key, '');\n\n if (!tempData[groupByValue]) {\n tempData[groupByValue] = [];\n }\n\n tempData[groupByValue].push(item);\n });\n var nextData = Object.entries(tempData).map(function (_ref) {\n var _ref2;\n\n var groupTitle = _ref[0],\n children = _ref[1];\n return _ref2 = {\n children: isSort ? children.sort(sort(false)) : children\n }, _ref2[KEY_GROUP_TITLE] = groupTitle, _ref2[KEY_GROUP] = true, _ref2;\n });\n\n if (isSort) {\n nextData = nextData.sort(sort(true));\n }\n\n return (0, _treeUtils.flattenTree)(nextData);\n}\n\n//# sourceURL=webpack://rsuite/./src/utils/getDataGroupBy.ts?");
5008
5008
 
5009
5009
  /***/ }),
5010
5010