├── .editorconfig
├── .github
├── CODEOWNERS
├── ISSUE_TEMPLATE.md
├── PULL_REQUEST_TEMPLATE.md
├── dependabot.yml
└── workflows
│ ├── codeql.yml
│ ├── dependabot.yml
│ ├── publish.yml
│ ├── release.yml
│ └── tests.yml
├── .gitignore
├── .husky
├── .gitignore
└── pre-commit
├── .npmignore
├── .nvmrc
├── .prettierignore
├── .prettierrc.json
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── TODO.md
├── babel.config.js
├── docs
└── index.html
├── eslint.config.mjs
├── example
└── index.js
├── jest.config.js
├── jest.setup.ts
├── lib
├── SmartDataTable.tsx
├── __mocks__
│ └── fileMock.ts
├── components
│ ├── CellValue.test.tsx
│ ├── CellValue.tsx
│ ├── ErrorBoundary.tsx
│ ├── HighlightValue.tsx
│ ├── Paginator.test.tsx
│ ├── Paginator.tsx
│ ├── PaginatorItem.tsx
│ ├── SelectAll.test.tsx
│ ├── SelectAll.tsx
│ ├── Table.tsx
│ ├── Toggles.tsx
│ └── helpers
│ │ └── with-pagination.tsx
├── css
│ ├── basic.css
│ ├── paginate.css
│ ├── paginator.css
│ └── toggles.css
├── helpers
│ ├── constants.ts
│ ├── context.ts
│ ├── default-state.ts
│ ├── file-extensions.ts
│ ├── functions.helpers.test.ts
│ ├── functions.table.test.ts
│ ├── functions.ts
│ └── tests.ts
├── index.ts
└── types.ts
├── package.json
├── pnpm-lock.yaml
├── tsconfig.declaration.json
├── tsconfig.eslint.json
├── tsconfig.json
├── webpack.config.js
└── webpack.dev.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | trim_trailing_whitespace = true
8 |
9 | [*.md]
10 | indent_style = space
11 | indent_size = 2
12 | trim_trailing_whitespace = false
13 |
14 | [*.{yml,yaml,json}]
15 | indent_style = space
16 | indent_size = 2
17 |
18 | [*.{js,jsx,ts,tsx}]
19 | indent_style = space
20 | indent_size = 2
21 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # These owners will be the default owners for everything in
2 | # the repo. Unless a later match takes precedence,
3 | # @global-owner1 and @global-owner2 will be requested for
4 | # review when someone opens a pull request.
5 | * @joaocarmo
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Expected Behavior
2 |
3 |
4 |
5 | ### Actual Behavior
6 |
7 |
8 |
9 | ### Steps to Reproduce
10 |
11 |
12 |
13 | ### Screenshot(s)
14 |
15 |
16 |
17 | ### Your Environment
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ### Request type
4 |
5 |
6 |
7 | - [ ] Chore
8 | - [ ] Feature
9 | - [ ] Fix
10 | - [ ] Refactor
11 | - [ ] Tests
12 | - [ ] Documentation
13 |
14 | ### Summary
15 |
16 |
17 |
18 | {Please write here what's the main purpose of this PR}
19 |
20 | ### Change description
21 |
22 |
23 |
24 | {Please write here a summary of the change}
25 |
26 | ### Check lists
27 |
28 |
29 |
30 | - [ ] Tests passed
31 | - [ ] Coding style respected
32 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Set update schedule for each package manager
2 | version: 2
3 | updates:
4 | # Check for updates to GitHub Actions
5 | - package-ecosystem: 'github-actions'
6 | directory: '/'
7 | schedule:
8 | interval: 'weekly'
9 | # Maintain dependencies for npm packages
10 | - package-ecosystem: 'npm'
11 | directory: '/'
12 | schedule:
13 | interval: 'weekly'
14 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | name: 'CodeQL'
2 |
3 | on:
4 | push:
5 | branches: ['main']
6 | pull_request:
7 | branches: ['main']
8 | schedule:
9 | - cron: '3 10 * * 4'
10 |
11 | jobs:
12 | analyze:
13 | name: Analyze
14 | runs-on: ubuntu-latest
15 | permissions:
16 | actions: read
17 | contents: read
18 | security-events: write
19 |
20 | strategy:
21 | fail-fast: false
22 | matrix:
23 | language: [javascript]
24 |
25 | steps:
26 | - name: Checkout
27 | uses: actions/checkout@v4
28 |
29 | - name: Initialize CodeQL
30 | uses: github/codeql-action/init@v3
31 | with:
32 | languages: ${{ matrix.language }}
33 | queries: +security-and-quality
34 |
35 | - name: Autobuild
36 | uses: github/codeql-action/autobuild@v3
37 |
38 | - name: Perform CodeQL Analysis
39 | uses: github/codeql-action/analyze@v3
40 | with:
41 | category: '/language:${{ matrix.language }}'
42 |
--------------------------------------------------------------------------------
/.github/workflows/dependabot.yml:
--------------------------------------------------------------------------------
1 | name: Dependabot
2 | on: pull_request
3 |
4 | permissions:
5 | contents: write
6 |
7 | jobs:
8 | dependabot:
9 | runs-on: ubuntu-latest
10 | if: ${{ github.actor == 'dependabot[bot]' }}
11 |
12 | steps:
13 | - name: Dependabot metadata
14 | id: metadata
15 | uses: dependabot/fetch-metadata@v2.3.0
16 | with:
17 | github-token: '${{ secrets.GITHUB_TOKEN }}'
18 |
19 | - name: Enable auto-merge for Dependabot PRs
20 | if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
21 | run: gh pr merge --auto --merge "$PR_URL"
22 | env:
23 | PR_URL: ${{github.event.pull_request.html_url}}
24 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
25 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | publish-npm:
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - name: Checkout
12 | uses: actions/checkout@v4
13 | with:
14 | token: ${{ secrets.GH_PAT }}
15 | ref: 'main'
16 |
17 | - name: Enable corepack
18 | run: |
19 | corepack enable pnpm
20 |
21 | - name: Use Node.js
22 | uses: actions/setup-node@v4
23 | with:
24 | node-version: '20'
25 | cache: 'pnpm'
26 | registry-url: https://registry.npmjs.org/
27 |
28 | - name: Install dependencies
29 | run: pnpm install --frozen-lockfile
30 |
31 | - name: Build
32 | run: |
33 | pnpm build
34 | pnpm build:types
35 |
36 | - name: Publish to NPM
37 | run: pnpm publish
38 | env:
39 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
40 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release Version
2 |
3 | on:
4 | release:
5 | types: [created]
6 |
7 | jobs:
8 | bump-version:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v4
14 | with:
15 | token: ${{ secrets.GH_PAT }}
16 | ref: 'main'
17 |
18 | - name: Enable corepack
19 | run: |
20 | corepack enable pnpm
21 |
22 | - name: Use Node.js
23 | uses: actions/setup-node@v4
24 | with:
25 | node-version: '20'
26 | cache: 'pnpm'
27 | registry-url: https://registry.npmjs.org/
28 |
29 | - name: Install dependencies
30 | run: pnpm install --frozen-lockfile
31 |
32 | - name: Get release
33 | id: get_release
34 | uses: bruceadams/get-release@v1.3.2
35 | env:
36 | GITHUB_TOKEN: ${{ secrets.GH_PAT }}
37 |
38 | - name: Bump the version
39 | run: |
40 | git config --local user.name "${{ secrets.GIT_AUTHOR_NAME }}"
41 | git config --local user.email "${{ secrets.GIT_AUTHOR_EMAIL }}"
42 | npm version --no-commit-hooks --no-git-tag-version ${{ steps.get_release.outputs.tag_name }}
43 |
44 | - name: Commit and push the version change
45 | run: |
46 | git add .
47 | git commit -m "Release ${{ steps.get_release.outputs.tag_name }}" --no-gpg-sign --no-verify --signoff
48 | git push
49 |
50 | - name: Trigger the Publish Action
51 | uses: benc-uk/workflow-dispatch@v1.2.4
52 | with:
53 | workflow: Publish
54 | token: ${{ secrets.GH_PAT }}
55 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yml:
--------------------------------------------------------------------------------
1 | name: Tests
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 | branches: [main]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - name: Checkout
15 | uses: actions/checkout@v4
16 |
17 | - name: Enable corepack
18 | run: |
19 | corepack enable pnpm
20 |
21 | - name: Use Node.js
22 | uses: actions/setup-node@v4
23 | with:
24 | node-version: '20'
25 | cache: 'pnpm'
26 | registry-url: https://registry.npmjs.org/
27 |
28 | - name: Install dependencies
29 | run: pnpm install --frozen-lockfile
30 |
31 | - name: Check the typings
32 | run: pnpm type-check
33 |
34 | - name: Execute the tests
35 | run: pnpm test
36 |
37 | - name: Build the library and the example
38 | run: pnpm prd
39 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 | .eslintcache
11 |
12 | # Directory for instrumented libs generated by jscoverage/JSCover
13 | lib-cov
14 |
15 | # Coverage directory used by tools like istanbul
16 | coverage
17 |
18 | # nyc test coverage
19 | .nyc_output
20 |
21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
22 | .grunt
23 |
24 | # node-waf configuration
25 | .lock-wscript
26 |
27 | # Compiled binary addons (http://nodejs.org/api/addons.html)
28 | build/Release
29 |
30 | # Dependency directories
31 | node_modules
32 | jspm_packages
33 |
34 | # Optional npm cache directory
35 | .npm
36 |
37 | # Optional REPL history
38 | .node_repl_history
39 |
40 | # Mac files
41 | .DS_Store
42 |
43 | # Custom function testers
44 | test/*.func.*
45 |
46 | # Build directory
47 | dist
48 |
--------------------------------------------------------------------------------
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | pnpm lint-staged
2 | pnpm type-check
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (http://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directories
30 | node_modules
31 | jspm_packages
32 |
33 | # Optional npm cache directory
34 | .npm
35 |
36 | # Optional REPL history
37 | .node_repl_history
38 |
39 | # Mac files
40 | .DS_Store
41 |
42 | # Development helpers
43 | npm-reinstall
44 |
45 | # Test, deployment and development stuff
46 | dev/
47 | dist/example.*
48 | docs/
49 | example/
50 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | v20
2 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | dist/
2 | docs/
3 | test/
4 |
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "jsxSingleQuote": false,
3 | "semi": false,
4 | "singleQuote": true,
5 | "tabWidth": 2,
6 | "trailingComma": "all"
7 | }
8 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.16.0
4 |
5 | > Jun 21, 2022
6 |
7 | - Creates and implements a SmartDataTableContext
8 | - Removes the `dev` and `dist` dirs
9 | - Upgrades the example to use the React 18 API
10 | - Moves the example to gh-pages
11 |
12 | ## 0.15.0
13 |
14 | > Apr 3, 2022
15 |
16 | - Adds support for a custom sort `compareFn` per column which can be used to
17 | leverage [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
18 |
19 | ## no-release (2022-02-06)
20 |
21 | > Feb 6, 2022
22 |
23 | - Moved the docs to this repo
24 |
25 | ## 0.14.0
26 |
27 | > Jan 7, 2022
28 |
29 | - Adds data attributes to columns that allow individual column targeting, e.g.
30 | by CSS
31 |
32 | ## 0.13.1
33 |
34 | > Nov 14, 2021
35 |
36 | - Removed the compiled example from the npm package to remove the overall
37 | bundle/download size
38 |
39 | ## 0.13.0
40 |
41 | > Nov 13, 2021
42 |
43 | - Ported the tests to TypeScript
44 | - Added a `SelectAll` component to the `Toggles` component
45 | ([Issue \#49](https://github.com/joaocarmo/react-smart-data-table/issues/49))
46 |
47 | ## no-release (2021-11-10)
48 |
49 | > Nov 10, 2021
50 |
51 | - Updated some of the dependencies
52 |
53 | ## no-release (2021-11-09)
54 |
55 | > Nov 9, 2021
56 |
57 | - Migrated the react testing library from enzyme to @testing-library/react
58 |
59 | ## 0.12.0
60 |
61 | > Apr 24, 2021
62 |
63 | - Added a `dataSampling` prop which tells the sampling algorithm how much of the
64 | data to sample in order to compute the headers, useful for data which is not
65 | uniform
66 |
67 | ## 0.11.0
68 |
69 | > Apr 17, 2021
70 |
71 | - Converted the codebase to TypeScript
72 | - Fixed an issue where columns might get duplicated
73 | [Issue \#39](https://github.com/joaocarmo/react-smart-data-table/issues/39)
74 |
75 | ## 0.10.1
76 |
77 | > Mar 22, 2021
78 |
79 | - Improved the CI workflows
80 | - Updated the documentation
81 | - Updated the required React version
82 |
83 | ## 0.10.0
84 |
85 | > Mar 2, 2021
86 |
87 | - Added a new `dataRequestOptions` to allow passing options directly to the
88 | underlying `fetch` API call
89 |
90 | ## 0.9.0
91 |
92 | > Feb 17, 2021
93 |
94 | - Added a new `dataKeyResolver` prop that accepts custom function which takes
95 | the response as its only argument and returns the data
96 | - Fixed a bug rendering the cell value introduced in the previous refactoring
97 | - Fixed a long lasting bug regarding the `headers` prop overriding behavior
98 | - Fixed the loader not appearing if the data was empty
99 | - Added more tests
100 |
101 | ## no-release (2021-02-15)
102 |
103 | > Feb 15, 2021
104 |
105 | - Converted the CellValue component to a FC and added `React.memo` to try and
106 | get some performance gains
107 |
108 | ## no-release (2021-02-14)
109 |
110 | > Feb 14, 2021
111 |
112 | - Upgraded the codebase to the new [JSX transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
113 | - Removed the `memoize-one` dependency
114 | - Cleaned up the internal code
115 | - Refactored the dev workflow
116 | - Changed the files with `JSX` syntax to use the `.jsx` extension
117 | - Converted some Class Components to Functional Components
118 | - Toggles
119 | - Converted some `div` elements to more semantic HTML elements
120 | - Converted Promises to async-await
121 | - Improved the pagination's basic CSS
122 | - Added custom API URL to the example
123 |
124 | ### Breaking Changes
125 |
126 | - `TableCell` was renamed to `CellValue`
127 |
128 | ## 0.8.0
129 |
130 | > Sep 1, 2020
131 |
132 | ### Breaking Changes
133 |
134 | - Removed the styling to a dedicated file
135 |
136 | ## no-release (2020-06-07)
137 |
138 | > Jun 7, 2020
139 |
140 | - Started to add component testing using _enzyme_
141 |
142 | ## no-release (2020-05-18)
143 |
144 | > May 18, 2020
145 |
146 | - Switched from _npm_ to _yarn_
147 | - Updated the dependencies
148 | - Fixed the example
149 | - Added _GitHub_ workflows for _push_ and _PR_ to the main branch
150 |
151 | ## 0.7.4
152 |
153 | > Mar 20, 2020
154 |
155 | - Improved the tests
156 | - Fixes
157 | [Issue \#22](https://github.com/joaocarmo/react-smart-data-table/issues/22)
158 | - Updated the dependencies due to:
159 | - [CVE-2020-7598](https://nvd.nist.gov/vuln/detail/CVE-2020-7598)
160 |
161 | ## no-release (2020-03-08)
162 |
163 | > Mar 8, 2020
164 |
165 | - Added some unit tests
166 | - Added [husky](https://github.com/typicode/husky) for pre-commit hooks
167 |
168 | ## no-release (2020-03-07)
169 |
170 | > Mar 7, 2020
171 |
172 | - Updated the dependencies due to:
173 | - [CVE-2019-16769](https://nvd.nist.gov/vuln/detail/CVE-2019-16769)
174 | - Improved the docs
175 | - Added a `code of conduct`
176 | - Added `contributing guidelines`
177 | - Added a `pull request template`
178 |
179 | ## 0.7.3
180 |
181 | > Oct 18, 2019
182 |
183 | - Merged
184 | [Pull \#20](https://github.com/joaocarmo/react-smart-data-table/pull/20)
185 | to fix
186 | [Issue \#19](https://github.com/joaocarmo/react-smart-data-table/issues/19)
187 | ([\@tisoap](https://github.com/tisoap))
188 | - Added support for the _parseImg_ option to parse Data URLs as well
189 |
190 | ## 0.7.2
191 |
192 | > Sep 29, 2019
193 |
194 | - Removed the deprecation warning for _footer_ and _withHeaders_
195 | - Added the _orderedHeaders_ prop that allows to customize the headers order
196 | - Added the _hideUnordered_ prop that allows to hide unordered headers
197 |
198 | ## 0.7.1
199 |
200 | > Jun 20, 2019
201 |
202 | - Updated the dependencies due to:
203 | - [CVE-2019-11358](https://nvd.nist.gov/vuln/detail/CVE-2019-11358)
204 | - [WS-2019-0032](https://github.com/nodeca/js-yaml/issues/475)
205 | - Replaced _@babel/polyfill_ with _core-js/stable_
206 |
207 | ## 0.7.0
208 |
209 | > Feb 4, 2019
210 |
211 | - Added the possibility of passing a custom _Paginator_ component to render the
212 | pagination
213 | - Removed the _segmentize_ dependency
214 |
215 | ## 0.6.7
216 |
217 | > Dec 25, 2018
218 |
219 | - Removed the _lodash_ dependency completely
220 | - Fixed a bug where the rows, when filtered, would cause the sorting to not work
221 | - Didn't change the behavior where the _index_ passed down to _transform_
222 | function in the _headers_ does not correspond to the index of the original data,
223 | but of the sorted data instead, because a different algorithm can be used to
224 | achieve the same result (example in the documentation)
225 |
226 | ## 0.6.6
227 |
228 | > Dec 20, 2018
229 |
230 | - Fixes [Issue \#14](https://github.com/joaocarmo/react-smart-data-table/issues/14)
231 |
232 | ## 0.6.5
233 |
234 | > Oct 10, 2018
235 |
236 | - Added the prop _emptyTable_ to display a message when the table is empty
237 | (Fixes [Issue \#13](https://github.com/joaocarmo/react-smart-data-table/issues/13))
238 |
239 | ## 0.6.4
240 |
241 | > Sep 28, 2018
242 |
243 | - Added _transform_ and _isImage_ properties to the _headers_ prop accepted
244 | options
245 |
246 | ## 0.6.3
247 |
248 | > Sep 28, 2018
249 |
250 | - Added prop to pass custom _header_ prop with options to override individual
251 | columns default behavior
252 | - Added the _dynamic_ prop
253 | - Added a _.npmignore_ file to reduce the package size by excluding examples
254 | and tests
255 |
256 | ## 0.6.2
257 |
258 | > Sep 6, 2018
259 |
260 | - Removed the _Python_ dependency and replaced the development server with
261 | _webpack-dev-server_
262 | - Updated the _webpack_ configuration for the new _babel-loader_
263 | - Helper functions improvements
264 |
265 | ## 0.6.1
266 |
267 | > Sep 5, 2018
268 |
269 | - Fixes [Issue \#12](https://github.com/joaocarmo/react-smart-data-table/issues/12)
270 |
271 | ## 0.6.0
272 |
273 | > Aug 29, 2018
274 |
275 | - Webpack reorganization
276 | - Package structure reorganization
277 |
278 | ### Breaking Changes
279 |
280 | - Removed the _styled_ prop deprecation warning
281 | - Added the _footer_ deprecation warning
282 | - Added the _withHeaders_ deprecation warning
283 | - Added the _withFooter_ prop as the flag to render the footer in convergence
284 | with the _withHeader_ prop
285 |
286 | _Note_: This version is exactly the same as `0.5.15` with some props name
287 | changes. If this breaks your app, keep using the previous version.
288 |
289 | ## 0.5.15
290 |
291 | > Aug 19, 2018
292 |
293 | - Added _className_ to options that can be provided to _parseImg_ to be passed
294 | down to the _img_ tag
295 | - Several minor enhancements, bug fixes and code reduction
296 | - Added memoization through [memoize-one](https://github.com/alexreardon/memoize-one)
297 |
298 | ## 0.5.14
299 |
300 | > Aug 19, 2018
301 |
302 | - Added a parser for images and the possibility to render the image instead of
303 | displaying the URL which also accepts an object with a _style_ key containing a
304 | _style object_ which will be passed down to the `` tag with the CSS
305 | attributes as defined in
306 | [Common CSS Properties Reference](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference)
307 |
308 | ### Bug Fixes
309 |
310 | - Stopped the event propagation to _onRowClick_ when links rendered with
311 | _withLinks_ are clicked
312 |
313 | ## 0.5.13
314 |
315 | > Aug 14, 2018
316 |
317 | - Added the possibility to convert _true_ and _false_ to _[Yes Word]_ and
318 | _[No Word]_ when the value is of _Boolean_ type where each can be customized
319 | by supplying an object to the _parseBool_ prop
320 |
321 | ## 0.5.12
322 |
323 | > Aug 14, 2018
324 |
325 | - Added the possibility to convert _true_ and _false_ to _Yes_ and _No_ when the
326 | value is of _Boolean_ type through the _parseBool_ prop
327 |
328 | ## 0.5.11
329 |
330 | > Aug 12, 2018
331 |
332 | - Added _onRowClick_ prop, check the [README](README.md) for the function
333 | signature (courtesy of [occult](https://github.com/occult))
334 |
335 | ## 0.5.10
336 |
337 | > Aug 1, 2018
338 |
339 | ## Bug fixes
340 |
341 | - When filtering by value, reset the page (pagination) back to 1
342 |
343 | ## 0.5.9
344 |
345 | > Jul 23, 2018
346 |
347 | - Added a condition to reload the async data if the URL changes
348 |
349 | ## 0.5.8
350 |
351 | > Jul 18, 2018
352 |
353 | - The RSDT now correctly re-renders when data is changed in props and the loader
354 | is correctly called, it also correctly re-renders even when the data type is
355 | changed
356 |
357 | ## 0.5.7
358 |
359 | > Jun 24, 2018
360 |
361 | - Added ESLint with babel-eslint and eslint-config-airbnb
362 | - Added a new prop for a _loader_ component to be rendered while fetching async
363 | data
364 | - Added intelligence to parse boolean values
365 |
366 | ## 0.5.6
367 |
368 | > Jun 10, 2018
369 |
370 | - Added async data loading from remote url
371 |
372 | ## 0.5.5
373 |
374 | > Apr 30, 2018
375 |
376 | - Added an [Error Boundary](https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html#introducing-error-boundaries)
377 |
378 | ## 0.5.4
379 |
380 | > Apr 25, 2018
381 |
382 | - Exposed the library as a compiled bundle in order to avoid import errors due
383 | to the ES6 syntax
384 |
385 | ## 0.5.3
386 |
387 | > Apr 2, 2018
388 |
389 | - Added the prop _withHeaders_ (courtesy of [Derush](https://github.com/Derush))
390 |
391 | ## 0.5.2
392 |
393 | > Mar 18, 2018
394 |
395 | - Tested and updated the dependencies, will bring improvements very soon
396 |
397 | ## 0.5.1
398 |
399 | > Aug 2, 2017
400 |
401 | - Highlighting text now works with _withLinks_
402 | - Added pagination with ellipsis for large amounts of data
403 | - Added deprecation warning for _styled_ prop
404 |
405 | ## 0.5.0
406 |
407 | > Jul 25, 2017
408 |
409 | - Complete re-write of the whole component, makes the internal gears more
410 | flexible for future improvements
411 | - Removed the _styled_ prop and the ability to render the table using _div_'s
412 | - Removed sorting by clicking on table header
413 | - Added sorting by clicking on table header sorting icon
414 | - Added different icons to represent sorting directions
415 | - Added string highlight to search filter
416 | - Added _withLinks_ prop that detects and converts links to `` tags
417 | - Column toggles no longer require the custom component, it's built-in
418 | - Added example with per page dropdown selection
419 | - Converted pagination _span_ tags to _a_ tags
420 |
421 | ## 0.4.1
422 |
423 | > May 27, 2017
424 |
425 | - Fixed a bug where the visibility toggles wouldn't function introduced by the
426 | pagination support
427 |
428 | ## 0.4.0
429 |
430 | > May 26, 2017
431 |
432 | - Added pagination support
433 |
434 | ## 0.3.4
435 |
436 | > May 6, 2017
437 |
438 | - Package dependencies updated
439 |
440 | ## 0.3.3
441 |
442 | > Apr 25, 2017
443 |
444 | - Fixed the toggles and sorting compatibility bug
445 | - Added documentation for toggles
446 |
447 | ## 0.3.2
448 |
449 | > Apr 24, 2017
450 |
451 | - Added column visibility toggles
452 | - Bug: need to fix compatibility with sorting
453 |
454 | ## 0.3.1
455 |
456 | > Apr 23, 2017
457 |
458 | - Fixed a bug where sorting would reset the filtering
459 | - Added a filtering example to _README.md_
460 |
461 | ## 0.3.0
462 |
463 | > Apr 21, 2017
464 |
465 | - Added filtering of all columns through a new prop _filterValue_ that accepts
466 | a string input as the value to use for the filter
467 |
468 | ## 0.2.3
469 |
470 | > Apr 15, 2017
471 |
472 | - Added live examples to _README.md_
473 |
474 | ## 0.2.2
475 |
476 | > Apr 15, 2017
477 |
478 | - Added PropTypes from the _prop-types_ npm module instead of the main _react_
479 |
480 | ## 0.2.1
481 |
482 | > Mar 26, 2017
483 |
484 | - Added SmartDataTable as a default export
485 |
486 | ## 0.2.0
487 |
488 | > Mar 25, 2017
489 |
490 | - Added sortable option to make the table sortable by individual columns
491 |
492 | ## 0.1.0
493 |
494 | > Mar 11, 2017
495 |
496 | - Added support for nested objects and for more header formats
497 | - Added _lodash_ dependency
498 | - Started to document the code, updated the _README.md_
499 |
500 | ## 0.0.1
501 |
502 | > Feb 12, 2017
503 |
504 | - Wrote most of the logic for the smart data table
505 |
506 | ## 0.0.0
507 |
508 | > Jan 30, 2017
509 |
510 | - Created the index export and wrote the basic react component structure
511 | - Created the environment for proper development and testing
512 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | - Demonstrating empathy and kindness toward other people
21 | - Being respectful of differing opinions, viewpoints, and experiences
22 | - Giving and gracefully accepting constructive feedback
23 | - Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | - Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | - The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | - Trolling, insulting or derogatory comments, and personal or political attacks
33 | - Public or private harassment
34 | - Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | - Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | info@joaocarmo.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | All contributions are welcome, even without prior discussion. In the event of
4 | the later, please make sure to create a very clear and summarized _pull
5 | request_.
6 |
7 | ## Pull Request Process
8 |
9 | Make use of the _pull request template_ if you don't know where to start.
10 |
11 | 1. Let's try to follow the versioning scheme of [SemVer][1].
12 |
13 | 2. Update the relevant docs whenever necessary, e.g. _README.md_.
14 |
15 | 3. When introducing breaking changes, make a _very good_ case for it.
16 |
17 | 4. Write unit/functional tests, if possible.
18 |
19 | ## Code of conduct
20 |
21 | Respect the community and follow the guidelines in the [code of conduct][2].
22 |
23 | [1]: http://semver.org/
24 | [2]: ./CODE_OF_CONDUCT.md
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 João Carmo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-smart-data-table
2 |
3 | [][npm]
4 | [][jest]
5 | [][contributor]
6 | 
7 |
8 | A smart data table component for React.js meant to be configuration free,
9 | batteries included.
10 |
11 | ## About
12 |
13 | This is meant to be a _zero configuration_ data table component for React.js
14 | in the spirit of _plug and play_.
15 |
16 | Just feed it an array of equal JSON objects and it will create a template free
17 | table that can be customized easily with any framework (or custom CSS).
18 |
19 | If you want more control over the data rendering process or don't need the
20 | _smarts_, check out
21 | [react-very-simple-data-table][react-very-simple-data-table].
22 |
23 | ## Features
24 |
25 | It currently supports:
26 |
27 | 1. Humanized column names based on object keys
28 | 1. Sortable columns
29 | - Accepts a custom sort `compareFn` function
30 | 1. Rows filtering / searchable
31 | 1. Search term highlight in the results
32 | 1. Column visibility toggles
33 | 1. Automatic pagination
34 | 1. Server-side/remote data
35 | 1. Control over row clicks
36 | 1. Smart data rendering
37 | - URLs and E-Mail addresses rendered as the _href_ in an _anchor_ tag
38 | ``
39 | - _boolean_ value parsing to yes/no word
40 | - Image URLs rendered as the _src_ for an image tag ``
41 | 1. Custom override if the default behavior is unwanted for some columns
42 | 1. Custom components
43 | - Paginator
44 | 1. Control the order of the columns
45 | - Using the above, it's also possible to select which columns to display
46 |
47 | ## Installation
48 |
49 | ```sh
50 | yarn add react-smart-data-table
51 |
52 | # or
53 |
54 | npm install react-smart-data-table
55 | ```
56 |
57 | There is some very basic styling you can use to get started, but since `v0.8.0`
58 | you need to import it specifically. You can also copy the file and use it as the
59 | basis for your own theme.
60 |
61 | ```js
62 | // Import basic styling
63 | import 'react-smart-data-table/dist/react-smart-data-table.css'
64 | ```
65 |
66 | ## Context
67 |
68 | You can access the SmartDataTable's internal context in your own component by
69 | using the `useSmartDataTableContext` hook.
70 |
71 | **Note:** You must be within the context of `SmartDataTable`, e.g. passing a
72 | custom component to `emptyTable`, `loading`, or `paginator`.
73 |
74 | ```jsx
75 | import { useSmartDataTableContext } from 'react-smart-data-table'
76 |
77 | const MyComponent = () => {
78 | const { columns, data } = useSmartDataTableContext()
79 |
80 | return (
81 |
82 |
My Component
83 |
Columns: {columns.length}
84 |
Rows: {data.length}
85 |
86 | )
87 | }
88 | ```
89 |
90 | ## Props
91 |
92 | | Name | Default | Type | Description |
93 | | :----------------- | :-------------------- | :-------------------- | :---------------------------------------------------------------- |
94 | | data | [] | {array|string} | An array of plain objects (can be nested) or a URL |
95 | | dataKey | 'data' | {string} | The object key where the async data is available |
96 | | dataKeyResolver | _null_ | {function} | Supply a function to extract the data from the async response |
97 | | dataRequestOptions | {} | {object} | Fetch API options passed directly into the async request call |
98 | | dataSampling | 0 | {number} | **Percentage** of the data to sample before computing the headers |
99 | | dynamic | false | {boolean} | Use this if your column structure changes dynamically |
100 | | emptyTable | _null_ | {element} | Pass a renderable object to render when there is no data |
101 | | filterValue | '' | {string} | Filters all columns by its value |
102 | | headers | {} | {object} | The object that overrides default column behavior |
103 | | hideUnordered | false | {boolean} | Hides all the columns not passed to _orderedHeaders_ |
104 | | loader | _null_ | {element} | Element to be rendered while fetching async data |
105 | | name | 'reactsmartdatatable' | {string} | The name for the table |
106 | | onRowClick | _undefined_ | {function} | If present, it will execute on every row click |
107 | | orderedHeaders | [] | {array} | An ordered array of the column keys |
108 | | paginator | _elements_ | {element} | Pass a renderable object to handle the table pagination |
109 | | parseBool | false | {boolean|object} | When true, boolean values will be converted to Yes/No |
110 | | parseImg | false | {boolean|object} | When true, image URLs will be rendered as an _img_ tag |
111 | | perPage | 0 | {number} | Paginates the results with the value as rows per page |
112 | | sortable | false | {boolean} | Enables the columns of the table to be sortable |
113 | | withFooter | false | {boolean} | Copy the header to the footer |
114 | | withHeader | true | {boolean} | Can be used to disable the rendering of column headers |
115 | | withLinks | false | {boolean} | Converts e-mails and url addresses to links |
116 | | withToggles | false | {boolean|object} | Enables the column visibility toggles |
117 |
118 | ### emptyTable
119 |
120 | ```jsx
121 | // Any renderable object can be passed
122 | const emptyTable =
There is no data available at the time.
123 | ```
124 |
125 | ### headers
126 |
127 | ```js
128 | /*
129 | Use the following structure to overwrite the default behavior for columns
130 | Undefined column keys will present the default behavior
131 | text: Humanized text based on the column key name
132 | invisible: Columns are visible by default
133 | sortable: Columns are sortable by default
134 | filterable: Columns are filterable by default
135 | isImg: Will force the render as an image, e.g. for dynamic URLs
136 | transform: Allows the custom rendering of the cells content
137 | Should be a function and these are the arguments passed:
138 | (value, index, row)
139 | The index is the position of the row as being rendered and
140 | not the index of the row in the original data
141 | Nested structures can be defined by a string-dot representation
142 | 'key1.key2.key3.[...].key99'
143 | */
144 | const headers = {
145 | columnKey: {
146 | text: 'Column 1',
147 | invisible: false,
148 | sortable: true,
149 | filterable: true,
150 | },
151 | 'nested.columnKey': {
152 | text: 'Nested Column',
153 | invisible: false,
154 | sortable: (a, b) => b['nested.columnKey'] - a['nested.columnKey'],
155 | filterable: true,
156 | },
157 | // If a dummy column is inserted into the data, it can be used to customize
158 | // the table by allowing actions per row to be implemented, for example
159 | tableActions: {
160 | text: 'Actions',
161 | invisible: false,
162 | sortable: false,
163 | filterable: false,
164 | transform: (value, index, row) => {
165 | // The following results should be identical
166 | console.log(value, row.tableActions)
167 | // Example of table actions: Delete row from data by row index
168 | return
169 | },
170 | },
171 | }
172 | ```
173 |
174 | ### onRowClick()
175 |
176 | ```js
177 | const onRowClick = (event, { rowData, rowIndex, tableData }) => {
178 | // The following results should be identical
179 | console.log(rowData, tableData[rowIndex])
180 | }
181 | ```
182 |
183 | ### paginator
184 |
185 | The _CustomComponent_ passed down as a prop will be rendered with the following
186 | props which can be used to perform all the necessary calculations and makes it
187 | fully compatible with Semantic UI's [Pagination][pagination]
188 | component.
189 |
190 | ```jsx
191 | const CustomComponent = ({
192 | activePage, totalPages, onPageChange,
193 | }) => (/* ... */)
194 |
195 |
199 |
200 | // To change the page, call the onPageChange function with the next activePage
201 |
202 | this.onPageChange(e, { activePage: nextActivePage })}
205 | />
206 | ```
207 |
208 | ### parseBool
209 |
210 | ```js
211 | // Default
212 | const parseBool = {
213 | yesWord: 'Yes',
214 | noWord: 'No',
215 | }
216 | ```
217 |
218 | ### parseImg
219 |
220 | ```js
221 | // You can pass a regular style object that will be passed down to
222 | // Or a Class Name
223 | const parseImg = {
224 | style: {
225 | border: '1px solid #ddd',
226 | borderRadius: '4px',
227 | padding: '5px',
228 | width: '150px',
229 | },
230 | className: 'my-custom-image-style',
231 | }
232 | ```
233 |
234 | ### orderedHeaders / hideUnordered
235 |
236 | If you want to control the order of the columns, simply pass an array containing
237 | the keys in the desired order. All the omitted headers will be appended
238 | afterwards unpredictably. Additionally, you can pass the _hideUnordered_ in
239 | order to render only the headers in _orderedHeaders_ and hide the remaining.
240 |
241 | ```js
242 | const hideUnordered = true
243 |
244 | const orderedHeaders = [
245 | 'key1',
246 | 'key2.subkey3',
247 | ...
248 | ]
249 | ```
250 |
251 | ### withToggles
252 |
253 | You can control the _Toggles_ by passing an object with the following structure:
254 |
255 | ```ts
256 | // Default toggles enabled
257 | const withToggles = true
258 |
259 | // Default toggles enabled with default select all
260 | const withToggles = {
261 | selectAll: true,
262 | }
263 |
264 | // Toggles with a custom locale
265 | const withToggles = {
266 | // The options to be passed as props to the `SelectAll` component
267 | selectAll: {
268 | // The text to be displayed in the Select All input
269 | locale: {
270 | // The default label for the `unchecked` state
271 | selectAllWord: 'Select All',
272 | // The default label for the `checked` state
273 | unSelectAllWord: 'Unselect All',
274 | },
275 | // You should not need to use this, but it is here for completeness
276 | handleToggleAll: (isChecked: boolean): void => {
277 | // ...
278 | },
279 | },
280 | }
281 | ```
282 |
283 | ## Examples
284 |
285 | ### Async data loading (fetch)
286 |
287 | By passing a string to the `data` prop, the component will interpret it as an
288 | URL and try to load the data from that location using _[fetch][fetch]_. If a
289 | successful request is returned, the data will be extracted from the response
290 | object. By default, it will grab the `data` key from the response. If it's in a
291 | different key, you can specify it with the `dataKey` prop. Just in case it's
292 | not a first-level attribute, you can supply a custom function to locate the
293 | data using the `dataKeyResolver` prop.
294 |
295 | `response from /api/v1/user`
296 |
297 | ```json
298 | {
299 | "status": "success",
300 | "message": "",
301 | "users": [{ "id": 0, "other": "..." }, { "id": 1, "other": "..." }, "..."]
302 | }
303 | ```
304 |
305 | `response from /api/v1/post`
306 |
307 | ```json
308 | {
309 | "status": "success",
310 | "message": "",
311 | "results": {
312 | "posts": [{ "id": 0, "other": "..." }, { "id": 1, "other": "..." }, "..."]
313 | }
314 | }
315 | ```
316 |
317 | `component`
318 |
319 | ```jsx
320 | // Using `dataKey`
321 |
326 |
327 | // Using `dataKeyResolver`
328 | response.results.posts}
331 | name="test-table"
332 | />
333 | ```
334 |
335 | ### Simple sortable table (with Semantic UI)
336 |
337 | ```jsx
338 | import React from 'react'
339 | import ReactDOM from 'react-dom'
340 | import faker from 'faker'
341 | import SmartDataTable from 'react-smart-data-table'
342 |
343 | const testData = []
344 | const numResults = 100
345 |
346 | for (let i = 0; i < numResults; i++) {
347 | testData.push({
348 | _id: i,
349 | fullName: faker.name.findName(),
350 | 'email.address': faker.internet.email(),
351 | phone_number: faker.phone.phoneNumber(),
352 | address: {
353 | city: faker.address.city(),
354 | state: faker.address.state(),
355 | country: faker.address.country(),
356 | },
357 | })
358 | }
359 |
360 | ReactDOM.render(
361 | ,
367 | document.getElementById('app'),
368 | )
369 | ```
370 |
371 | ## Demos
372 |
373 | You can try _react-smart-data-table_ with different UI libraries in the demo
374 | pages below. You can experiment with different features as well.
375 |
376 | - [Semantic UI: All Features][semantic]
377 |
378 | Take a look at the full featured example's [source code][example-source].
379 |
380 | Also, see it in full integration with a simple user/group management dashboard
381 | application. Feel free to play around with it, it's built with hot reloading.
382 |
383 | - [Somewhere I Belong][somewhere-i-belong]
384 |
385 | If you want to play around, check out this [codepen][codepen].
386 |
387 | ## FAQ
388 |
389 | If you're having trouble with _react-smart-data-table_, please check out the
390 | answers below. Otherwise, feel free to open a new issue!
391 |
392 | - Check [this answer][hide-pagination] to see how to hide the pagination for an
393 | empty table
394 | - Check [this answer][ssr-integration] if you're integrating with Server Side
395 | Rendering (SSR)
396 | - Check [this answer][double-click] if you want to implement a double click
397 | event on a row
398 | - Check [this answer][control-page] if you want to control the active page
399 | manually (e.g., based on a URL parameter)
400 | - Check [this answer][column-selector] if you want to style individual columns
401 | differently
402 |
403 | ## Forking / Contributing
404 |
405 | If you want to fork or [contribute][contribute], it's easy to test your changes.
406 | Just run the following development commands. The _start_ instruction will start
407 | a development HTTP server in your computer accessible from your browser at the
408 | address `http://localhost:3000/`.
409 |
410 | ```sh
411 | pnpm start
412 | ```
413 |
414 |
415 |
416 | [codepen]: https://codepen.io/joaocarmo/pen/oNBNZBO
417 | [column-selector]: https://github.com/joaocarmo/react-smart-data-table/issues/62#issuecomment-1002973644
418 | [contribute]: ./CONTRIBUTING.md
419 | [contributor]: ./CODE_OF_CONDUCT.md
420 | [control-page]: https://github.com/joaocarmo/react-smart-data-table/issues/60#issuecomment-974718595
421 | [double-click]: https://github.com/joaocarmo/react-smart-data-table/issues/59#issuecomment-969371513
422 | [example-source]: ./example/index.js
423 | [fetch]: https://fetch.spec.whatwg.org/
424 | [hide-pagination]: https://github.com/joaocarmo/react-smart-data-table/issues/42#issuecomment-828593880
425 | [jest]: https://github.com/facebook/jest
426 | [lgtm-alerts]: https://lgtm.com/projects/g/joaocarmo/react-smart-data-table/alerts/
427 | [lgtm-context]: https://lgtm.com/projects/g/joaocarmo/react-smart-data-table/context:javascript
428 | [npm]: https://badge.fury.io/js/react-smart-data-table
429 | [pagination]: https://react.semantic-ui.com/addons/pagination/
430 | [react-very-simple-data-table]: https://github.com/joaocarmo/react-very-simple-data-table
431 | [semantic]: http://joaocarmo.com/react-smart-data-table/
432 | [somewhere-i-belong]: https://github.com/joaocarmo/somewhere-i-belong
433 | [ssr-integration]: https://github.com/joaocarmo/react-smart-data-table/issues/50#issuecomment-963060887
434 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
3 | - Add horizontal scrolling (top and bottom)
4 | - Add multiple column sorting
5 | - Add sticky headers
6 | - Allow custom elements: _ErrorBoundary_, _Toggles_, _CellValue_
7 | - Improve performance
8 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | [
4 | '@babel/preset-env',
5 | {
6 | corejs: '3',
7 | modules: 'umd',
8 | useBuiltIns: 'usage',
9 | targets: {
10 | browsers:
11 | process.env.NODE_ENV === 'development'
12 | ? 'last 2 versions'
13 | : '> 0.25%, not dead',
14 | },
15 | },
16 | ],
17 | [
18 | '@babel/preset-react',
19 | {
20 | runtime: 'automatic',
21 | },
22 | ],
23 | '@babel/preset-typescript',
24 | ],
25 | plugins: ['@babel/plugin-transform-runtime'],
26 | }
27 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | React Smart Data Table
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
464 | {useApi
465 | ? 'While using async data, the state is controlled internally by the table'
466 | : `Total rows in the table: ${data.length}`}
467 |