Skip to content

Commit

Permalink
feat(heuristic-table): support [email protected] renderIndex and `renderLe…
Browse files Browse the repository at this point in the history
…ngth` props
  • Loading branch information
jsamr committed Sep 4, 2021
1 parent 5921d92 commit 961de3d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
34 changes: 17 additions & 17 deletions packages/heuristic-table-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@
"plugins"
],
"devDependencies": {
"@babel/cli": "^7.12.13",
"@babel/core": "^7.12.13",
"@babel/plugin-transform-react-jsx": "^7.12.13",
"@babel/preset-typescript": "^7.12.13",
"@babel/runtime": "^7.12.13",
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@babel/preset-typescript": "^7.15.0",
"@babel/runtime": "^7.15.4",
"@microsoft/api-documenter": "^7.12.7",
"@microsoft/api-extractor": "7.13.1",
"@release-it/conventional-changelog": "^2.0.0",
"@testing-library/react-native": "^7.1.0",
"@tsconfig/react-native": "^1.0.2",
"@types/html-validator": "^5.0.0",
"@types/jest": "^26.0.14",
"@types/react": "^16.9.49",
"@types/react-native": "^0.63.22",
"@types/react-test-renderer": "^16.9.3",
"@release-it/conventional-changelog": "^2.0.1",
"@testing-library/react-native": "^7.2.0",
"@tsconfig/react-native": "^1.0.3",
"@types/html-validator": "^5.0.1",
"@types/jest": "^26.0.24",
"@types/react": "^16.14.14",
"@types/react-native": "^0.63.53",
"@types/react-test-renderer": "^16.9.5",
"babel-jest": "^26.6.3",
"babel-plugin-inline-import": "^3.0.0",
"eslint": "^7.14.0",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"metro-react-native-babel-transformer": "^0.64.0",
Expand All @@ -58,11 +58,11 @@
"react-native-render-html": "6.1.0",
"react-test-renderer": "16.13.1",
"release-it": "^14.3.0",
"typescript": "~4.1.3"
"typescript": "~4.4.2"
},
"dependencies": {
"@types/prop-types": "^15.7.3",
"@types/ramda": "^0.27.38",
"@types/prop-types": "^15.7.4",
"@types/ramda": "^0.27.44",
"prop-types": "^15.7.2",
"ramda": "^0.27.1"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/heuristic-table-plugin/src/HTMLTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const HTMLTable = memo(function HTMLTable({
<Container tableWidth={tableWidth} availableWidth={containerWidth}>
{React.createElement(TreeRenderer, {
node: layout.renderTree,
config
config,
renderIndex: props.renderIndex,
renderLength: props.renderLength
})}
</Container>
</TDefaultRenderer>
Expand Down
16 changes: 13 additions & 3 deletions packages/heuristic-table-plugin/src/TreeRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ const styles = StyleSheet.create({

export default function TreeRenderer({
node,
config
config,
renderIndex,
renderLength
}: {
node: TableRenderNode;
renderIndex: number;
renderLength: number;
config?: HeuristicTablePluginConfig;
}) {
if (node.type === 'cell') {
return (
<View style={{ width: node.width }}>
<TNodeRenderer
renderIndex={renderIndex}
renderLength={renderLength}
propsFromParent={
{ cell: node, collapsedMarginTop: null, config } as any
}
Expand All @@ -32,7 +38,9 @@ export default function TreeRenderer({
React.createElement(TreeRenderer, {
node: v,
key: i,
config
config,
renderIndex: i,
renderLength: node.children.length
})
);
return <View style={styles.colContainer}>{children}</View>;
Expand All @@ -44,7 +52,9 @@ export default function TreeRenderer({
React.createElement(TreeRenderer, {
node: v,
key: i,
config
config,
renderIndex: i,
renderLength: node.children.length
})
)}
</View>
Expand Down

0 comments on commit 961de3d

Please sign in to comment.