Skip to content

Commit

Permalink
feat: allow custom features (#5415)
Browse files Browse the repository at this point in the history
* feat: initial refactor for allowing custom features

* add example and docs for custom features

* regen lock file

* update link

* proofread feature docs

* add declaration merging caveat
  • Loading branch information
KevinVandy committed Mar 19, 2024
1 parent 01129cb commit 707a5b4
Show file tree
Hide file tree
Showing 34 changed files with 1,028 additions and 73 deletions.
8 changes: 8 additions & 0 deletions docs/api/core/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ debugRows?: boolean

Set this option to true to output row debugging information to the console.

### `_features`

```tsx
_features?: TableFeature[]
```

An array of extra features that you can add to the table instance.

### `render`

> ⚠️ This option is only necessary if you are implementing a table adapter.
Expand Down
8 changes: 8 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@
{
"label": "Virtualization",
"to": "guide/virtualization"
},
{
"label": "Custom Features",
"to": "guide/custom-features"
}
]
},
Expand Down Expand Up @@ -391,6 +395,10 @@
{
"to": "framework/react/examples/full-width-resizable-table",
"label": "React Full Width Resizable"
},
{
"to": "framework/react/examples/custom-features",
"label": "Custom Features"
}
]
},
Expand Down
269 changes: 269 additions & 0 deletions docs/guide/custom-features.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/react/basic/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const columns = [
]

function App() {
const [data, setData] = React.useState(() => [...defaultData])
const [data, _setData] = React.useState(() => [...defaultData])
const rerender = React.useReducer(() => ({}), {})[1]

const table = useReactTable({
Expand Down
5 changes: 5 additions & 0 deletions examples/react/custom-features/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
6 changes: 6 additions & 0 deletions examples/react/custom-features/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example

To run this example:

- `npm install` or `yarn`
- `npm run start` or `yarn start`
13 changes: 13 additions & 0 deletions examples/react/custom-features/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" src="https://cdn.skypack.dev/twind/shim"></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions examples/react/custom-features/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "tanstack-table-example-custom-features",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"start": "vite"
},
"dependencies": {
"@faker-js/faker": "^8.4.1",
"@tanstack/react-table": "^8.13.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.5",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.2.1",
"vite": "^5.0.11"
}
}
34 changes: 34 additions & 0 deletions examples/react/custom-features/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
html {
font-family: sans-serif;
font-size: 14px;
}

table {
border: 1px solid lightgray;
}

tbody {
border-bottom: 1px solid lightgray;
}

th {
border-bottom: 1px solid lightgray;
border-right: 1px solid lightgray;
padding: 2px 4px;
}

tfoot {
color: gray;
}

tfoot th {
font-weight: normal;
}

tr {
border-bottom: 1px solid lightgray;
}

button:disabled {
opacity: 0.5;
}

0 comments on commit 707a5b4

Please sign in to comment.