Skip to content
Permalink
Browse files

fix(usegroupby): fix useGroupBy, add grouping example and fix some tests

  • Loading branch information...
tannerlinsley committed Jul 30, 2019
1 parent d7a4db0 commit af739d91d0353f95c458b1aec7fd5ddaa57e4e63
Showing with 12,311 additions and 956 deletions.
  1. +2 −4 .babelrc
  2. +1 −4 configs/tests/jest.common.js
  3. +2 −5 configs/tests/jest.unit.js
  4. +1 −0 configs/tests/setup.common.js
  5. +4 −0 examples/grouping-client-side/.babelrc
  6. +1 −0 examples/grouping-client-side/.env
  7. +7 −0 examples/grouping-client-side/.eslintrc
  8. +23 −0 examples/grouping-client-side/.gitignore
  9. +29 −0 examples/grouping-client-side/.rescriptsrc.js
  10. +6 −0 examples/grouping-client-side/README.md
  11. +35 −0 examples/grouping-client-side/package.json
  12. BIN examples/grouping-client-side/public/favicon.ico
  13. +38 −0 examples/grouping-client-side/public/index.html
  14. +15 −0 examples/grouping-client-side/public/manifest.json
  15. +260 −0 examples/grouping-client-side/src/App.js
  16. +9 −0 examples/grouping-client-side/src/App.test.js
  17. +13 −0 examples/grouping-client-side/src/index.css
  18. +12 −0 examples/grouping-client-side/src/index.js
  19. +40 −0 examples/grouping-client-side/src/makeData.js
  20. +135 −0 examples/grouping-client-side/src/serviceWorker.js
  21. +10,145 −0 examples/grouping-client-side/yarn.lock
  22. +1 −1 examples/sorting-client-side/src/App.js
  23. +9 −3 package.json
  24. +20 −0 src/aggregations.js
  25. +172 −0 src/hooks/tests/__snapshots__/useTable.test.js.snap
  26. +0 −111 src/hooks/tests/useTable.js
  27. +31 −16 src/hooks/tests/useTable.test.js
  28. +5 −5 src/hooks/useTable.js
  29. +252 −0 src/plugin-hooks/tests/__snapshots__/useSortBy.test.js.snap
  30. +40 −41 src/plugin-hooks/tests/{useSortBy.js → useSortBy.test.js}
  31. +13 −13 src/plugin-hooks/useExpanded.js
  32. +117 −72 src/plugin-hooks/useGroupBy.js
  33. +4 −5 src/utils.js
  34. +869 −676 yarn.lock
@@ -1,7 +1,7 @@
{
"presets": [
[
"@babel/env",
"@babel/preset-env",
{
"modules": false
}
@@ -10,9 +10,7 @@
],
"env": {
"test": {
"presets": [
"@babel/preset-env"
]
"presets": ["@babel/preset-env", "@babel/react"]
}
}
}
@@ -4,16 +4,13 @@ module.exports = {
moduleDirectories: [
'node_modules',
/*
* make 'test/utils' available in tests, e.g.
* __dirname makes 'test/utils' available in tests, e.g.
*
* const {myModule} = require('utils/my-test-helper')
*/
__dirname,
],

rootDir: path.resolve(__dirname, '../../'),

roots: ['<rootDir>/src', __dirname],

transformIgnorePatterns: ['node_modules'],
}
@@ -2,14 +2,11 @@ const commonConfig = require('./jest.common')

module.exports = {
...commonConfig,

displayName: 'unit',

coverageDirectory: '../../coverage',

testMatch: ['<rootDir>/src/**/tests/**/*.js'],

testMatch: ['<rootDir>/src/**/*.test.js'],
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
},
setupFilesAfterEnv: ['./configs/tests/setup.common.js'],
}
@@ -0,0 +1 @@
import 'snapshot-diff/extend-expect'
@@ -0,0 +1,4 @@
{
"presets": ["react-app"],
"plugins": ["styled-components"]
}
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
@@ -0,0 +1,7 @@
{
"extends": ["react-app", "prettier"],
"rules": {
// "eqeqeq": 0,
// "jsx-a11y/anchor-is-valid": 0
}
}
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
@@ -0,0 +1,29 @@
const path = require('path')
const resolveFrom = require('resolve-from')

const fixLinkedDependencies = config => {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
react$: resolveFrom(path.resolve('node_modules'), 'react'),
'react-dom$': resolveFrom(path.resolve('node_modules'), 'react-dom'),
},
}
return config
}

const includeSrcDirectory = config => {
config.resolve = {
...config.resolve,
modules: [path.resolve('src'), ...config.resolve.modules],
}
return config
}

module.exports = [
['use-babel-config', '.babelrc'],
['use-eslint-config', '.eslintrc'],
fixLinkedDependencies,
// includeSrcDirectory,
]
@@ -0,0 +1,6 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and Rescripts.

You can:

- [Open this example in a new CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/basic)
- `yarn` and `yarn start` to run and edit the example
@@ -0,0 +1,35 @@
{
"private": true,
"scripts": {
"start": "rescripts start",
"build": "rescripts build",
"test": "rescripts test",
"eject": "rescripts eject"
},
"dependencies": {
"namor": "^1.1.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"react-table": "next",
"styled-components": "^4.3.2"
},
"devDependencies": {
"@rescripts/cli": "^0.0.11",
"@rescripts/rescript-use-babel-config": "^0.0.8",
"@rescripts/rescript-use-eslint-config": "^0.0.9",
"babel-eslint": "10.0.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file not shown.
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

0 comments on commit af739d9

Please sign in to comment.
You can’t perform that action at this time.