UNPKG

1.01 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _isArray2 = require('lodash/isArray');
8
9var _isArray3 = _interopRequireDefault(_isArray2);
10
11function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13function resolveRowKey(_ref) {
14 var rowData = _ref.rowData,
15 rowIndex = _ref.rowIndex,
16 rowKey = _ref.rowKey;
17
18 if (typeof rowKey === 'function') {
19 return rowKey({ rowData: rowData, rowIndex: rowIndex }) + '-row';
20 } else if (process.env.NODE_ENV !== 'production') {
21 // Arrays cannot have rowKeys by definition so we have to go by index there.
22 if (!(0, _isArray3.default)(rowData) && !{}.hasOwnProperty.call(rowData, rowKey)) {
23 console.warn( // eslint-disable-line no-console
24 'Table.Body - Missing valid rowKey!', rowData, rowKey);
25 }
26 }
27
28 if (rowData[rowKey] === 0) {
29 return rowData[rowKey] + '-row';
30 }
31
32 return (rowData[rowKey] || rowIndex) + '-row';
33}
34
35exports.default = resolveRowKey;
\No newline at end of file