Debian Codegraph @

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

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