Debian Codegraph @

node/@patternfly/react-table/dist/js/deprecated/components/Table/base/resolve-row-key.js

raw
1 "use strict";
2 /**
3 * resolve-row-key.ts
4 *
5 * Forked from reactabular-table version 8.14.0
6 * https://github.com/reactabular/reactabular/tree/v8.14.0/packages/reactabular-table/src
7 */
8 Object.defineProperty(exports, "__esModule", { value: true });
9 exports.resolveRowKey = void 0;
10 /**
11 * @param {{rowData: RowType, rowIndex: number, rowKey: RowKeyType}} rowData - row data
12 */
13 function resolveRowKey({ rowData, rowIndex, rowKey }) {
14 if (typeof rowKey === 'function') {
15 return `${rowKey({ rowData, rowIndex })}-row`;
16 }
17 else if (process.env.NODE_ENV !== 'production') {
18 // Arrays cannot have rowKeys by definition so we have to go by index there.
19 if (!Array.isArray(rowData) && rowData[rowKey] === undefined) {
20 // eslint-disable-next-line no-console
21 console.warn('Table.Body - Missing valid rowKey!', rowData, rowKey);
22 }
23 }
24 if (rowData[rowKey] === 0) {
25 return `${rowData[rowKey]}-row`;
26 }
27 return `${rowData[rowKey] || rowIndex}-row`;
28 }
29 exports.resolveRowKey = resolveRowKey;
30 //# sourceMappingURL=resolve-row-key.js.map