@native-html/heuristic-table-plugin
Version:
🔠A 100% native component using heuristics to render tables in react-native-render-html
49 lines (45 loc) • 1.05 kB
JavaScript
/**
* Customize `td` and `th` renderers while reusing default cell renderer logic.
*
* @param props - Props from custom renderer.
*
* @public
*/
export default function useHtmlTableCellProps({
propsFromParent,
...props
}) {
var _config$getStyleForCe;
const {
config,
cell
} = propsFromParent;
const styleFromConfig = config === null || config === void 0 ? void 0 : (_config$getStyleForCe = config.getStyleForCell) === null || _config$getStyleForCe === void 0 ? void 0 : _config$getStyleForCe.call(null, cell);
let spanStyles = {};
if (cell.lenY > 1) {
spanStyles = {
justifyContent: 'center'
};
}
if (cell.lenX > 1) {
spanStyles = {
alignItems: 'center'
};
}
const style = { ...props.style,
flexGrow: 1,
flexShrink: 0,
...spanStyles,
...styleFromConfig,
width: cell.width,
marginLeft: 0,
marginRight: 0,
marginTop: 0,
marginBottom: 0
};
return { ...props,
style,
propsFromParent
};
}
//# sourceMappingURL=useHtmlTableCellProps.js.map