jattac.libs.web.responsive-table 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +580 -579
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/gemini/commit_message.txt +1 -0
- package/gemini/index.md +1 -0
- package/gemini/release_git_steps.md +80 -64
- package/package.json +60 -60
- package/src/Data/IResponsiveTableColumnDefinition.tsx +12 -12
- package/src/Plugins/FilterPlugin.tsx +71 -71
- package/src/Plugins/IResponsiveTablePlugin.ts +48 -48
- package/src/Plugins/InfiniteScrollPlugin.tsx +73 -73
- package/src/Styles/ResponsiveTable.module.css +1 -1
- package/src/UI/ResponsiveTable.tsx +25 -26
- package/src/index.tsx +10 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chore: Bump version to 0.2.2
|
package/gemini/index.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Please inspect this directory recursively to understand the project in depth. Analyze its purpose, technology stack, core features, and overall structure. Provide a comprehensive explanation based on your findings. Start by listing all relevant files and then read the contents of key files like `package.json`, `README.md`, and any other configuration or source files that seem important.
|
|
@@ -1,64 +1,80 @@
|
|
|
1
|
-
## Release Git Steps
|
|
2
|
-
|
|
3
|
-
This document outlines the sequence of Git commands to perform at the end of every release cycle to ensure the `master` branch is up-to-date, tagged, and all changes are pushed to the remote repository.
|
|
4
|
-
|
|
5
|
-
**Prerequisites:**
|
|
6
|
-
- Ensure all development work for the release is complete and committed to the `develop` branch.
|
|
7
|
-
- Ensure you are on the `develop` branch (`git checkout develop`).
|
|
8
|
-
|
|
9
|
-
**Steps:**
|
|
10
|
-
|
|
11
|
-
1. **Stage all changes (if any uncommitted changes exist on `develop`):**
|
|
12
|
-
```bash
|
|
13
|
-
git add .
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
2. **Commit changes on `develop` (if not already done):**
|
|
17
|
-
```bash
|
|
18
|
-
git commit -m "feat(release):
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
git push origin
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
## Release Git Steps
|
|
2
|
+
|
|
3
|
+
This document outlines the sequence of Git commands to perform at the end of every release cycle to ensure the `master` branch is up-to-date, tagged, and all changes are pushed to the remote repository.
|
|
4
|
+
|
|
5
|
+
**Prerequisites:**
|
|
6
|
+
- Ensure all development work for the release is complete and committed to the `develop` branch.
|
|
7
|
+
- Ensure you are on the `develop` branch (`git checkout develop`).
|
|
8
|
+
|
|
9
|
+
**Steps:**
|
|
10
|
+
|
|
11
|
+
1. **Stage all changes (if any uncommitted changes exist on `develop`):**
|
|
12
|
+
```bash
|
|
13
|
+
git add .
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. **Commit changes on `develop` (if not already done):**
|
|
17
|
+
```bash
|
|
18
|
+
git commit -m "feat(release): Release vX.Y.Z
|
|
19
|
+
|
|
20
|
+
Summarize the key changes, new features, bug fixes, and any breaking changes
|
|
21
|
+
introduced in this release. This message should provide a high-level overview
|
|
22
|
+
of what's new since the last release.
|
|
23
|
+
|
|
24
|
+
Example:
|
|
25
|
+
- Introduced extensible plugin system with Filter and Infinite Scroll plugins.
|
|
26
|
+
- Refactored animation props into a dedicated object.
|
|
27
|
+
- Added virtualized scrolling for large datasets.
|
|
28
|
+
- Updated dependencies."
|
|
29
|
+
# Or, if you have a multi-line message, use a temporary file:
|
|
30
|
+
# echo "Your detailed commit message" > commit_message.txt
|
|
31
|
+
# git commit -F commit_message.txt
|
|
32
|
+
```
|
|
33
|
+
*(Note: We assume the main feature/bugfix commits are already on `develop`.)*
|
|
34
|
+
|
|
35
|
+
3. **Switch to the `master` branch:**
|
|
36
|
+
```bash
|
|
37
|
+
git checkout master
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
4. **Merge `develop` into `master`:**
|
|
41
|
+
```bash
|
|
42
|
+
git merge develop
|
|
43
|
+
```
|
|
44
|
+
*This will bring all the latest changes from `develop` into `master`.*
|
|
45
|
+
|
|
46
|
+
5. **Get the current version from `package.json`:**
|
|
47
|
+
```bash
|
|
48
|
+
# Manually read the "version" field from package.json
|
|
49
|
+
# Example: "version": "1.0.0"
|
|
50
|
+
# Let's assume the version is X.Y.Z
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
6. **Create a new Git tag for the release:**
|
|
54
|
+
```bash
|
|
55
|
+
git tag vX.Y.Z
|
|
56
|
+
```
|
|
57
|
+
*Replace `X.Y.Z` with the actual version number obtained from `package.json`.*
|
|
58
|
+
|
|
59
|
+
7. **Push the `master` branch and all tags to the remote repository:**
|
|
60
|
+
```bash
|
|
61
|
+
git push origin master --tags
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
8. **Switch back to the `develop` branch:**
|
|
65
|
+
```bash
|
|
66
|
+
git checkout develop
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
9. **Push the `develop` branch to the remote repository (to ensure it's up-to-date after the merge):**
|
|
70
|
+
```bash
|
|
71
|
+
git push origin develop
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This sequence ensures a clean release process, updating `master`, creating a version tag, and synchronizing both branches with the remote.
|
|
75
|
+
|
|
76
|
+
10. **Delete temporary files:**
|
|
77
|
+
```bash
|
|
78
|
+
del commit_message.txt
|
|
79
|
+
```
|
|
80
|
+
*Ensure to delete any temporary files created during the release process.*
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "jattac.libs.web.responsive-table",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.es.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "rollup -c",
|
|
10
|
-
"lint": "eslint './{src,app}/**/*.{ts,tsx}'",
|
|
11
|
-
"size": "size-limit",
|
|
12
|
-
"prepare": "npm run build"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"react",
|
|
16
|
-
"typescript"
|
|
17
|
-
],
|
|
18
|
-
"author": "Nyingi Maina",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"peerDependencies": {
|
|
21
|
-
"react": ">=18.2.0",
|
|
22
|
-
"react-dom": ">=18.2.0",
|
|
23
|
-
"typescript": ">=3.7.0"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@rollup/plugin-commonjs": "^25.0.7",
|
|
27
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
28
|
-
"@rollup/plugin-typescript": "^11.1.5",
|
|
29
|
-
"@size-limit/preset-small-lib": "^10.0.1",
|
|
30
|
-
"@testing-library/react": "^14.0.0",
|
|
31
|
-
"@types/react": "^18.2.33",
|
|
32
|
-
"@types/react-dom": "^18.2.14",
|
|
33
|
-
"@types/react-window": "^1.8.8",
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
35
|
-
"@typescript-eslint/parser": "^6.9.1",
|
|
36
|
-
"eslint": "^8.52.0",
|
|
37
|
-
"eslint-config-prettier": "^9.0.0",
|
|
38
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
39
|
-
"eslint-plugin-react": "^7.33.2",
|
|
40
|
-
"identity-obj-proxy": "^3.0.0",
|
|
41
|
-
"npm": "^10.2.2",
|
|
42
|
-
"postcss": "^8.4.31",
|
|
43
|
-
"prettier": "^3.0.3",
|
|
44
|
-
"react": "^18.2.0",
|
|
45
|
-
"react-dom": "^18.2.0",
|
|
46
|
-
"rollup": "^4.2.0",
|
|
47
|
-
"rollup-plugin-copy": "^3.5.0",
|
|
48
|
-
"rollup-plugin-delete": "^2.0.0",
|
|
49
|
-
"rollup-plugin-generate-package-json": "^3.2.0",
|
|
50
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
51
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
52
|
-
"size-limit": "^10.0.1",
|
|
53
|
-
"typescript": "^5.2.2"
|
|
54
|
-
},
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
57
|
-
"react-window": "^1.8.11",
|
|
58
|
-
"tslib": "^2.6.2"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "jattac.libs.web.responsive-table",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rollup -c",
|
|
10
|
+
"lint": "eslint './{src,app}/**/*.{ts,tsx}'",
|
|
11
|
+
"size": "size-limit",
|
|
12
|
+
"prepare": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"typescript"
|
|
17
|
+
],
|
|
18
|
+
"author": "Nyingi Maina",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": ">=18.2.0",
|
|
22
|
+
"react-dom": ">=18.2.0",
|
|
23
|
+
"typescript": ">=3.7.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
27
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
28
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
29
|
+
"@size-limit/preset-small-lib": "^10.0.1",
|
|
30
|
+
"@testing-library/react": "^14.0.0",
|
|
31
|
+
"@types/react": "^18.2.33",
|
|
32
|
+
"@types/react-dom": "^18.2.14",
|
|
33
|
+
"@types/react-window": "^1.8.8",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
35
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
36
|
+
"eslint": "^8.52.0",
|
|
37
|
+
"eslint-config-prettier": "^9.0.0",
|
|
38
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
39
|
+
"eslint-plugin-react": "^7.33.2",
|
|
40
|
+
"identity-obj-proxy": "^3.0.0",
|
|
41
|
+
"npm": "^10.2.2",
|
|
42
|
+
"postcss": "^8.4.31",
|
|
43
|
+
"prettier": "^3.0.3",
|
|
44
|
+
"react": "^18.2.0",
|
|
45
|
+
"react-dom": "^18.2.0",
|
|
46
|
+
"rollup": "^4.2.0",
|
|
47
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
48
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
49
|
+
"rollup-plugin-generate-package-json": "^3.2.0",
|
|
50
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
51
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
52
|
+
"size-limit": "^10.0.1",
|
|
53
|
+
"typescript": "^5.2.2"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
57
|
+
"react-window": "^1.8.11",
|
|
58
|
+
"tslib": "^2.6.2"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export default interface IResponsiveTableColumnDefinition<TData> {
|
|
4
|
-
displayLabel: ReactNode;
|
|
5
|
-
cellRenderer: (data: TData) => ReactNode;
|
|
6
|
-
interactivity?: {
|
|
7
|
-
id: string;
|
|
8
|
-
onHeaderClick?: (id: string) => void;
|
|
9
|
-
className?: string;
|
|
10
|
-
};
|
|
11
|
-
getFilterableValue?: (data: TData) => string | number;
|
|
12
|
-
}
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export default interface IResponsiveTableColumnDefinition<TData> {
|
|
4
|
+
displayLabel: ReactNode;
|
|
5
|
+
cellRenderer: (data: TData) => ReactNode;
|
|
6
|
+
interactivity?: {
|
|
7
|
+
id: string;
|
|
8
|
+
onHeaderClick?: (id: string) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
getFilterableValue?: (data: TData) => string | number;
|
|
12
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { IResponsiveTablePlugin, IPluginAPI } from './IResponsiveTablePlugin';
|
|
3
|
-
import IResponsiveTableColumnDefinition from '../Data/IResponsiveTableColumnDefinition';
|
|
4
|
-
|
|
5
|
-
export class FilterPlugin<TData> implements IResponsiveTablePlugin<TData> {
|
|
6
|
-
public id = 'filter';
|
|
7
|
-
private filterText = '';
|
|
8
|
-
private api!: IPluginAPI<TData>;
|
|
9
|
-
|
|
10
|
-
constructor() {
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public onPluginInit = (api: IPluginAPI<TData>) => {
|
|
14
|
-
this.api = api;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
public renderHeader = () => {
|
|
18
|
-
if (!this.api.filterProps?.showFilter) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return (
|
|
22
|
-
<div style={{ float: 'right', marginBottom: '1rem' }}>
|
|
23
|
-
<input
|
|
24
|
-
type="text"
|
|
25
|
-
placeholder={this.api.filterProps.filterPlaceholder || "Search..."}
|
|
26
|
-
onChange={this.handleFilterChange}
|
|
27
|
-
style={{
|
|
28
|
-
padding: '0.5rem',
|
|
29
|
-
border: '1px solid #ccc',
|
|
30
|
-
borderRadius: '4px',
|
|
31
|
-
}}
|
|
32
|
-
/>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
public processData = (data: TData[]): TData[] => {
|
|
38
|
-
if (!this.filterText || !this.api.columnDefinitions) {
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const lowercasedFilter = this.filterText.toLowerCase();
|
|
43
|
-
|
|
44
|
-
return data.filter((row) => {
|
|
45
|
-
return this.api.columnDefinitions!.some((colDef) => {
|
|
46
|
-
// If colDef is a function, it won't have getFilterableValue, so skip it.
|
|
47
|
-
if (typeof colDef === 'function') {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Now we know colDef is an object (IResponsiveTableColumnDefinition<TData>)
|
|
52
|
-
const typedColDef = colDef as IResponsiveTableColumnDefinition<TData>;
|
|
53
|
-
|
|
54
|
-
// Check if getFilterableValue exists and is a function
|
|
55
|
-
if (typedColDef.getFilterableValue && typeof typedColDef.getFilterableValue === 'function') {
|
|
56
|
-
const value = typedColDef.getFilterableValue(row);
|
|
57
|
-
return value?.toString().toLowerCase().includes(lowercasedFilter);
|
|
58
|
-
}
|
|
59
|
-
return false; // If getFilterableValue is not present or not a function
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
private handleFilterChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
65
|
-
// Debounce the filter change
|
|
66
|
-
setTimeout(() => {
|
|
67
|
-
this.filterText = e.target.value;
|
|
68
|
-
this.api.forceUpdate();
|
|
69
|
-
}, 300);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IResponsiveTablePlugin, IPluginAPI } from './IResponsiveTablePlugin';
|
|
3
|
+
import IResponsiveTableColumnDefinition from '../Data/IResponsiveTableColumnDefinition';
|
|
4
|
+
|
|
5
|
+
export class FilterPlugin<TData> implements IResponsiveTablePlugin<TData> {
|
|
6
|
+
public id = 'filter';
|
|
7
|
+
private filterText = '';
|
|
8
|
+
private api!: IPluginAPI<TData>;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public onPluginInit = (api: IPluginAPI<TData>) => {
|
|
14
|
+
this.api = api;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
public renderHeader = () => {
|
|
18
|
+
if (!this.api.filterProps?.showFilter) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (
|
|
22
|
+
<div style={{ float: 'right', marginBottom: '1rem' }}>
|
|
23
|
+
<input
|
|
24
|
+
type="text"
|
|
25
|
+
placeholder={this.api.filterProps.filterPlaceholder || "Search..."}
|
|
26
|
+
onChange={this.handleFilterChange}
|
|
27
|
+
style={{
|
|
28
|
+
padding: '0.5rem',
|
|
29
|
+
border: '1px solid #ccc',
|
|
30
|
+
borderRadius: '4px',
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
public processData = (data: TData[]): TData[] => {
|
|
38
|
+
if (!this.filterText || !this.api.columnDefinitions) {
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const lowercasedFilter = this.filterText.toLowerCase();
|
|
43
|
+
|
|
44
|
+
return data.filter((row) => {
|
|
45
|
+
return this.api.columnDefinitions!.some((colDef) => {
|
|
46
|
+
// If colDef is a function, it won't have getFilterableValue, so skip it.
|
|
47
|
+
if (typeof colDef === 'function') {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Now we know colDef is an object (IResponsiveTableColumnDefinition<TData>)
|
|
52
|
+
const typedColDef = colDef as IResponsiveTableColumnDefinition<TData>;
|
|
53
|
+
|
|
54
|
+
// Check if getFilterableValue exists and is a function
|
|
55
|
+
if (typedColDef.getFilterableValue && typeof typedColDef.getFilterableValue === 'function') {
|
|
56
|
+
const value = typedColDef.getFilterableValue(row);
|
|
57
|
+
return value?.toString().toLowerCase().includes(lowercasedFilter);
|
|
58
|
+
}
|
|
59
|
+
return false; // If getFilterableValue is not present or not a function
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
private handleFilterChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
65
|
+
// Debounce the filter change
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
this.filterText = e.target.value;
|
|
68
|
+
this.api.forceUpdate();
|
|
69
|
+
}, 300);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { ColumnDefinition } from '../UI/ResponsiveTable';
|
|
3
|
-
|
|
4
|
-
export interface IResponsiveTablePlugin<TData> {
|
|
5
|
-
// A unique identifier for the plugin
|
|
6
|
-
id: string;
|
|
7
|
-
|
|
8
|
-
// Optional: Renders a UI component above the table
|
|
9
|
-
renderHeader?: () => ReactNode;
|
|
10
|
-
|
|
11
|
-
// Optional: Renders a UI component below the table
|
|
12
|
-
renderFooter?: () => ReactNode;
|
|
13
|
-
|
|
14
|
-
// Optional: Processes the data before it's rendered
|
|
15
|
-
processData?: (data: TData[]) => TData[];
|
|
16
|
-
|
|
17
|
-
// Optional: A callback that the table can use to provide the plugin with its own API
|
|
18
|
-
onPluginInit?: (api: IPluginAPI<TData>) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface IPluginAPI<TData> {
|
|
22
|
-
// Function to get the current data from the table
|
|
23
|
-
getData: () => TData[];
|
|
24
|
-
|
|
25
|
-
// Function to force the table to re-render
|
|
26
|
-
forceUpdate: () => void;
|
|
27
|
-
|
|
28
|
-
// Function to get the column definitions from the table
|
|
29
|
-
columnDefinitions: ColumnDefinition<TData>[];
|
|
30
|
-
|
|
31
|
-
// Function to get the scrollable element of the table
|
|
32
|
-
getScrollableElement?: () => HTMLElement | null;
|
|
33
|
-
|
|
34
|
-
// Optional: Infinite scroll props from the ResponsiveTable component
|
|
35
|
-
infiniteScrollProps?: {
|
|
36
|
-
enableInfiniteScroll?: boolean;
|
|
37
|
-
onLoadMore?: (currentData: TData[]) => Promise<TData[] | null>;
|
|
38
|
-
hasMore?: boolean;
|
|
39
|
-
loadingMoreComponent?: ReactNode;
|
|
40
|
-
noMoreDataComponent?: ReactNode;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Optional: Filter props from the ResponsiveTable component
|
|
44
|
-
filterProps?: {
|
|
45
|
-
showFilter?: boolean;
|
|
46
|
-
filterPlaceholder?: string;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ColumnDefinition } from '../UI/ResponsiveTable';
|
|
3
|
+
|
|
4
|
+
export interface IResponsiveTablePlugin<TData> {
|
|
5
|
+
// A unique identifier for the plugin
|
|
6
|
+
id: string;
|
|
7
|
+
|
|
8
|
+
// Optional: Renders a UI component above the table
|
|
9
|
+
renderHeader?: () => ReactNode;
|
|
10
|
+
|
|
11
|
+
// Optional: Renders a UI component below the table
|
|
12
|
+
renderFooter?: () => ReactNode;
|
|
13
|
+
|
|
14
|
+
// Optional: Processes the data before it's rendered
|
|
15
|
+
processData?: (data: TData[]) => TData[];
|
|
16
|
+
|
|
17
|
+
// Optional: A callback that the table can use to provide the plugin with its own API
|
|
18
|
+
onPluginInit?: (api: IPluginAPI<TData>) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IPluginAPI<TData> {
|
|
22
|
+
// Function to get the current data from the table
|
|
23
|
+
getData: () => TData[];
|
|
24
|
+
|
|
25
|
+
// Function to force the table to re-render
|
|
26
|
+
forceUpdate: () => void;
|
|
27
|
+
|
|
28
|
+
// Function to get the column definitions from the table
|
|
29
|
+
columnDefinitions: ColumnDefinition<TData>[];
|
|
30
|
+
|
|
31
|
+
// Function to get the scrollable element of the table
|
|
32
|
+
getScrollableElement?: () => HTMLElement | null;
|
|
33
|
+
|
|
34
|
+
// Optional: Infinite scroll props from the ResponsiveTable component
|
|
35
|
+
infiniteScrollProps?: {
|
|
36
|
+
enableInfiniteScroll?: boolean;
|
|
37
|
+
onLoadMore?: (currentData: TData[]) => Promise<TData[] | null>;
|
|
38
|
+
hasMore?: boolean;
|
|
39
|
+
loadingMoreComponent?: ReactNode;
|
|
40
|
+
noMoreDataComponent?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Optional: Filter props from the ResponsiveTable component
|
|
44
|
+
filterProps?: {
|
|
45
|
+
showFilter?: boolean;
|
|
46
|
+
filterPlaceholder?: string;
|
|
47
|
+
};
|
|
48
|
+
}
|