this.elem = elem} className="rv-sticky-tree" style={style} onScroll={this.onScroll}>
+
{this.treeToRender}
);
diff --git a/src/index.js b/src/index.js
deleted file mode 100644
index f81df8d..0000000
--- a/src/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-
-export StickyTree from './StickyTree';
-export AutoSizedStickyTree from './AutoSizedStickyTree';
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 0000000..7684c70
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1,8 @@
+export { default as StickyTree } from './StickyTree.js';
+export * from './StickyTree.js';
+export { default as AutoSizedStickyTree } from './AutoSizedStickyTree.js';
+export * from './AutoSizedStickyTree.js';
+export * from './StickyList.js';
+export { default as StickyList } from './StickyList.js';
+export * from './AutoSizedStickyList.js';
+export { default as AutoSizedStickyList } from './AutoSizedStickyList.js';
diff --git a/src/vendorSticky.js b/src/vendorSticky.ts
similarity index 100%
rename from src/vendorSticky.js
rename to src/vendorSticky.ts
diff --git a/test/StickyTree.spec.js b/test/StickyTree.spec.js
deleted file mode 100644
index 5f0ab1d..0000000
--- a/test/StickyTree.spec.js
+++ /dev/null
@@ -1,58 +0,0 @@
-import { expect } from 'chai';
-
-import { StickyTree } from '../src/index';
-
-describe('StickyTree test', () => {
- let tree;
- let props;
-
- it('flattenTree returns a cache of all required info', () => {
- const treeNodes = [
- { name: 'root', children: [1, 4] },
- { name: 'node1', children: [2, 3] },
- { name: 'node1-1' },
- { name: 'node1-2' },
- { name: 'node2', children: [5, 6, 7] },
- { name: 'node2-1' },
- { name: 'node2-2' },
- { name: 'node2-3' }
- ];
-
- props = {
- getChildren: pos => treeNodes[pos].children,
- getHeight: pos => 10
-
- };
- tree = new StickyTree(props);
- const nodePosCache = tree.flattenTree(0);
-
- expect(nodePosCache[0]).to.deep.equal({
- node: 0,
- top: 0,
- parentIndex: undefined,
- index: 0,
- children: [1, 4],
- height: 80
- });
-
- expect(nodePosCache[1]).to.deep.equal({
- node: 1,
- top: 10,
- parentIndex: 0,
- index: 1,
- children: [2, 3],
- height: 30
- });
-
- expect(nodePosCache[2]).to.deep.equal({ node: 2, top: 20, parentIndex: 1, index: 2, height: 10 });
-
- expect(nodePosCache[4]).to.deep.equal({
- node: 4,
- top: 40,
- parentIndex: 0,
- index: 4,
- children: [5, 6, 7],
- height: 40
- });
- });
-});
diff --git a/tsconfig-base.json b/tsconfig-base.json
new file mode 100644
index 0000000..29cf3a0
--- /dev/null
+++ b/tsconfig-base.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "baseUrl": "src",
+ "target": "es2022",
+ "declaration": true,
+ "jsx": "react",
+ "lib": ["es2022", "dom", "esnext"],
+ "strict": true,
+ "noImplicitAny": true,
+ "skipLibCheck": true, // no node_modules checks
+ "strictNullChecks": true,
+ "alwaysStrict": true,
+ "moduleResolution": "node",
+ "allowSyntheticDefaultImports": true,
+ "esModuleInterop": true,
+ "noUnusedLocals": true,
+ "strictPropertyInitialization": false,
+ "resolveJsonModule": true
+ },
+ "compileOnSave": false,
+ "exclude": ["node_modules", "dist"],
+ "include": ["src/", "example/"]
+}
diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json
new file mode 100644
index 0000000..01351fd
--- /dev/null
+++ b/tsconfig-cjs.json
@@ -0,0 +1,8 @@
+{
+ "extends": "./tsconfig-base.json",
+ "compilerOptions": {
+ "module": "commonjs",
+ "outDir": "dist/cjs",
+ "target": "es2015"
+ }
+}
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..8ae7d62
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,8 @@
+{
+ "extends": "./tsconfig-base.json",
+ "compilerOptions": {
+ "module": "esnext",
+ "outDir": "dist/mjs",
+ "target": "esnext"
+ }
+}
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 0000000..4cc185e
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,36 @@
+const path = require('path');
+const HtmlWebpackPlugin = require('html-webpack-plugin');
+
+module.exports = {
+ entry: path.join(__dirname, 'example', 'app.tsx'),
+ target: 'web',
+ mode: 'development',
+ output: {
+ path: path.resolve(__dirname, 'dist'),
+ publicPath: '/',
+ filename: 'app.bundle.js',
+ },
+
+ devServer: {
+ port: 9000
+ },
+
+ resolve: {
+ extensions: ['.ts', '.tsx', '.js', '.json'],
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(ts|js)x?$/,
+ exclude: /node_modules/,
+ loader: 'babel-loader',
+ },
+ ],
+ },
+ plugins: [
+ new HtmlWebpackPlugin({
+ template: path.resolve(__dirname, 'example', 'index.html'),
+ hash: true
+ })
+ ],
+};