UNPKG

@native-html/heuristic-table-plugin

Version:

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

53 lines (49 loc) • 1.41 kB
import { useMemo } from 'react'; import { useContentWidth, useRendererProps } from 'react-native-render-html'; import TableLayout from './TableLayout'; function useTableLayout({ tnode, settings }) { return useMemo(() => { return new TableLayout(tnode, settings); }, [tnode, settings]); } /** * Customize the rendering logic of the table renderer via this hook. * * @param props - Props from custom renderer props. * @param options - Customize this hook behavior. * * @returns props for the {@link HTMLTable} component. * * @public */ export default function useHtmlTableProps({ sharedProps, tnode, ...props }, options = {}) { var _table$forceStretch; const table = useRendererProps('table'); const forceStretch = (_table$forceStretch = table === null || table === void 0 ? void 0 : table.forceStretch) !== null && _table$forceStretch !== void 0 ? _table$forceStretch : false; const sharedContentWidth = useContentWidth(); const contentWidth = typeof options.overrideContentWidth === 'number' ? options.overrideContentWidth : sharedContentWidth; const settings = useMemo(() => ({ contentWidth, forceStretch }), [contentWidth, forceStretch]); const layout = useTableLayout({ tnode, settings }); return { layout, settings, config: table || {}, sharedProps, tnode, ...props }; } //# sourceMappingURL=useHtmlTableProps.js.map