UNPKG

@native-html/heuristic-table-plugin

Version:

🔠 A 100% native component using heuristics to render tables in react-native-render-html

56 lines (50 loc) • 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = useHtmlTableCellProps; /** * Customize `td` and `th` renderers while reusing default cell renderer logic. * * @param props - Props from custom renderer. * * @public */ 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