| 1 |
"use strict"; |
| 2 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 |
exports.mergeProps = void 0; |
| 4 |
const tslib_1 = require("tslib"); |
| 5 |
/** |
| 6 |
* merge-props.js |
| 7 |
* |
| 8 |
* Forked from reactabular-table version 8.14.0 |
| 9 |
* https://github.com/reactabular/reactabular/tree/v8.14.0/packages/reactabular-table/src |
| 10 |
*/ |
| 11 |
const react_1 = require("react"); |
| 12 |
const mergeWith_1 = tslib_1.__importDefault(require("lodash/mergeWith")); |
| 13 |
const react_styles_1 = require("@patternfly/react-styles"); |
| 14 |
/** |
| 15 |
* @param {any} props - Props |
| 16 |
*/ |
| 17 |
function mergeProps(...props) { |
| 18 |
const firstProps = props[0]; |
| 19 |
const restProps = props.slice(1); |
| 20 |
if (!restProps.length) { |
| 21 |
return (0, mergeWith_1.default)({}, firstProps); |
| 22 |
} |
| 23 |
// Avoid mutating the first prop collection |
| 24 |
return (0, mergeWith_1.default)((0, mergeWith_1.default)({}, firstProps), ...restProps, (a, b, key) => { |
| 25 |
if (key === 'children') { |
| 26 |
if (a && b) { |
| 27 |
// compose the two |
| 28 |
return (0, react_1.cloneElement)(a, { |
| 29 |
children: b |
| 30 |
}); |
| 31 |
} |
| 32 |
// Children have to be merged in reverse order for Reactabular |
| 33 |
// logic to work. |
| 34 |
return Object.assign(Object.assign({}, b), a); |
| 35 |
} |
| 36 |
if (key === 'className') { |
| 37 |
// Process class names through classNames to merge properly |
| 38 |
// as a string. |
| 39 |
return (0, react_styles_1.css)(a, b); |
| 40 |
} |
| 41 |
return undefined; |
| 42 |
}); |
| 43 |
} |
| 44 |
exports.mergeProps = mergeProps; |
| 45 |
//# sourceMappingURL=merge-props.js.map |