Move library files to lib/

This commit is contained in:
2020-01-27 20:03:15 +05:30
parent 1df5364928
commit 66248b8e26
22 changed files with 0 additions and 0 deletions
@@ -0,0 +1,78 @@
import React from "react";
import { connect } from "react-redux";
import * as ts from "typescript";
import { CSSTransition, TransitionGroup } from "react-transition-group";
import { AppState } from "../../store";
import { forEachChild, syntaxKindNameMapping, ObjectHash } from "../../utils";
import styles from "./ASTOutline.css";
interface ASTOutlineProps {
node?: ts.Node;
sourceFile?: ts.SourceFile;
}
function ASTOutline(props: ASTOutlineProps) {
const { node, sourceFile } = props;
if (node === undefined || sourceFile === undefined) {
return null;
}
const output = (
<>
<li>
{syntaxKindNameMapping[node.kind]}
<ul>
<TransitionGroup>
{forEachChild(node).map(childNode => (
<CSSTransition
key={ObjectHash.getHash(childNode)}
timeout={1000}
classNames={styles}
>
<ASTOutlineConnected node={childNode} />
</CSSTransition>
))}
</TransitionGroup>
</ul>
</li>
</>
);
if (ts.isSourceFile(node)) {
return (
<ul>
<TransitionGroup>{output}</TransitionGroup>
</ul>
);
} else {
return output;
}
}
type ASTOutlineStateProps = ASTOutlineProps;
const mapStateToProps = (state: AppState) => ({
node: state.sourceFiles.currentSourceFile,
sourceFile: state.sourceFiles.currentSourceFile
});
// currentSourceFile from ownProps should take preceedence
const mergeProps = (
stateProps: ASTOutlineStateProps,
_dispatchProps: never,
ownProps: ASTOutlineProps
) => {
return {
...stateProps,
...ownProps
};
};
export { ASTOutline as ASTOutlineUnconnected, ASTOutlineProps };
const ASTOutlineConnected = connect(
mapStateToProps,
null,
mergeProps
)(ASTOutline);
export default ASTOutlineConnected;