simple-table-core 0.6.1 → 0.6.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 +112 -58
- package/dist/components/SimpleTable/SimpleTable.d.ts +47 -22
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
# Simple Table
|
|
2
2
|
|
|
3
|
-
Any questions, support or features requests join me on
|
|
3
|
+
Any questions, support or features requests join me on Discord <a href="https://discord.gg/RvKHCfg3PC" target="_blank" rel="noopener noreferrer">https://discord.gg/RvKHCfg3PC</a>. I am happy to help and make this table even better!
|
|
4
4
|
|
|
5
|
-
Simple Table is a React grid
|
|
5
|
+
Simple Table is a powerful yet lightweight React grid component that provides a flexible, customizable, and high-performance solution for displaying and manipulating tabular data in your applications.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **Highly Customizable**: Fully customizable appearance with CSS variables and themes
|
|
10
|
+
- **Cell Editing**: Built-in support for editable cells with controlled state
|
|
11
|
+
- **Column Management**: Resize, reorder, pin, and hide columns with intuitive UI
|
|
12
|
+
- **Pagination**: Built-in pagination with customizable controls
|
|
13
|
+
- **Infinite Scroll**: Alternative to pagination for large datasets
|
|
14
|
+
- **Row Grouping**: Hierarchical data presentation with expandable rows
|
|
15
|
+
- **Theming**: Multiple built-in themes with ability to create custom themes
|
|
16
|
+
- **Performance Optimized**: Efficiently renders thousands of rows and columns
|
|
17
|
+
|
|
18
|
+
## Documentation
|
|
19
|
+
|
|
20
|
+
For detailed documentation, visit: [Simple Table Documentation](https://docs.simple-table.com/)
|
|
6
21
|
|
|
7
22
|
## Website
|
|
8
23
|
|
|
@@ -18,6 +33,49 @@ Check out the live demo on CodeSandbox: <a href="https://codesandbox.io/p/sandbo
|
|
|
18
33
|
</a>
|
|
19
34
|
</div>
|
|
20
35
|
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# npm
|
|
40
|
+
npm install simple-table-react
|
|
41
|
+
|
|
42
|
+
# yarn
|
|
43
|
+
yarn add simple-table-react
|
|
44
|
+
|
|
45
|
+
# pnpm
|
|
46
|
+
pnpm add simple-table-react
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
```jsx
|
|
52
|
+
import React, { useState } from "react";
|
|
53
|
+
import SimpleTable from "simple-table-react";
|
|
54
|
+
import "simple-table-react/dist/styles.css";
|
|
55
|
+
|
|
56
|
+
const App = () => {
|
|
57
|
+
const [rows, setRows] = useState([
|
|
58
|
+
{ rowMeta: { rowId: 0 }, rowData: { name: "John", age: 25 } },
|
|
59
|
+
{ rowMeta: { rowId: 1 }, rowData: { name: "Jane", age: 30 } },
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
const headers = [
|
|
63
|
+
{ accessor: "name", label: "Name", width: 200 },
|
|
64
|
+
{ accessor: "age", label: "Age", width: 100 },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const handleCellChange = ({ accessor, newValue, originalRowIndex }) => {
|
|
68
|
+
const updatedRows = [...rows];
|
|
69
|
+
updatedRows[originalRowIndex].rowData[accessor] = newValue;
|
|
70
|
+
setRows(updatedRows);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return <SimpleTable defaultHeaders={headers} rows={rows} onCellChange={handleCellChange} selectableCells />;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default App;
|
|
77
|
+
```
|
|
78
|
+
|
|
21
79
|
## Props
|
|
22
80
|
|
|
23
81
|
The Simple Table component accepts the following props:
|
|
@@ -31,77 +89,73 @@ The Simple Table component accepts the following props:
|
|
|
31
89
|
- **isSortable**: An optional boolean indicating if the column is sortable.
|
|
32
90
|
- **type**: An optional string specifying the data type of the column. Can be "string", "number", "boolean", "date", or "enum".
|
|
33
91
|
- **cellRenderer**: An optional function that takes a row object and returns a `ReactNode` for custom cell rendering.
|
|
92
|
+
- **align**: Text alignment within cells - "left", "center", or "right"
|
|
93
|
+
|
|
94
|
+
- **rows**: An array of data rows to be displayed in the table. Each row object should have:
|
|
34
95
|
|
|
96
|
+
- **rowMeta**: Object containing metadata for the row
|
|
97
|
+
- **rowId**: Unique identifier for the row
|
|
98
|
+
- **isExpanded**: Optional boolean for row grouping expansion state
|
|
99
|
+
- **children**: Optional array of child rows for row grouping
|
|
100
|
+
- **rowData**: Object containing the actual data to display (keys should match header accessors)
|
|
101
|
+
|
|
102
|
+
- **theme**: Theme name to apply to the table. Options include "light", "dark", "high-contrast", etc.
|
|
103
|
+
- **height**: The height of the table. Can be a string (e.g., "500px", "calc(100vh - 100px)") or "auto".
|
|
104
|
+
- **shouldPaginate**: A boolean to enable or disable pagination. Default is `true`.
|
|
105
|
+
- **rowsPerPage**: The number of rows to display per page. Default is `10`.
|
|
35
106
|
- **columnResizing**: A boolean to enable or disable column resizing. Default is `true`.
|
|
36
107
|
- **draggable**: A boolean to enable or disable column dragging.
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
108
|
+
- **pinned**: A boolean to enable or disable column pinning.
|
|
109
|
+
- **editColumns**: A boolean to enable or disable column management.
|
|
39
110
|
- **hideFooter**: A boolean to hide or show the footer. Default is `false`.
|
|
40
|
-
- **nextIcon**: A React element to display as the next page icon. Default is `<AngleRightIcon />`.
|
|
41
|
-
- **prevIcon**: A React element to display as the previous page icon. Default is `<AngleLeftIcon />`.
|
|
42
|
-
- **rows**: An array of data rows to be displayed in the table.
|
|
43
|
-
- **rowsPerPage**: The number of rows to display per page. Default is `10`.
|
|
44
111
|
- **selectableCells**: A boolean to enable or disable cell selection.
|
|
45
|
-
- **
|
|
112
|
+
- **selectableColumns**: A boolean to enable selection of entire columns by clicking headers.
|
|
113
|
+
- **onCellChange**: A function called when a cell value changes.
|
|
114
|
+
- **nextIcon**: A React element to display as the next page icon.
|
|
115
|
+
- **prevIcon**: A React element to display as the previous page icon.
|
|
46
116
|
- **sortDownIcon**: A React element to display as the sort down icon.
|
|
47
117
|
- **sortUpIcon**: A React element to display as the sort up icon.
|
|
48
|
-
- **onCellChange**: A function that is called when a cell value changes. It receives an object with the following properties:
|
|
49
|
-
- **accessor**: The accessor of the column whose cell value changed.
|
|
50
|
-
- **newValue**: The new value of the cell.
|
|
51
|
-
- **newRowIndex**: The index of the row in the current page.
|
|
52
|
-
- **originalRowIndex**: The original index of the row in the entire dataset.
|
|
53
|
-
- **row**: The entire row object.
|
|
54
118
|
|
|
55
119
|
## Customizable Styles
|
|
56
120
|
|
|
57
|
-
All styles for the Simple Table are customizable
|
|
121
|
+
All styles for the Simple Table are customizable through CSS variables. You can override these variables in your own CSS to match your application's design system.
|
|
58
122
|
|
|
59
123
|
### CSS Variables
|
|
60
124
|
|
|
61
125
|
You can override the following CSS variables to customize the appearance of the table:
|
|
62
126
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
- `.st-selected-bottom-border`
|
|
96
|
-
- `.st-selected-left-border`
|
|
97
|
-
- `.st-selected-right-border`
|
|
98
|
-
- `.st-footer`
|
|
99
|
-
- `.st-next-prev-btn`
|
|
100
|
-
- `.st-page-btn`
|
|
101
|
-
- `.st-page-btn.active`
|
|
102
|
-
- `.editable-cell-input`
|
|
103
|
-
- `.st-column-editor`
|
|
104
|
-
- `.st-column-editor.open`
|
|
127
|
+
```css
|
|
128
|
+
:root {
|
|
129
|
+
/* Base variables */
|
|
130
|
+
--st-border-radius: 4px;
|
|
131
|
+
--st-border-width: 1px;
|
|
132
|
+
--st-cell-padding: 8px;
|
|
133
|
+
--st-font-size: 0.875rem;
|
|
134
|
+
--st-font-weight-normal: 400;
|
|
135
|
+
--st-font-weight-bold: 600;
|
|
136
|
+
--st-transition-duration: 0.2s;
|
|
137
|
+
--st-transition-ease: ease-in-out;
|
|
138
|
+
--st-opacity-disabled: 0.5;
|
|
139
|
+
--st-spacing-small: 4px;
|
|
140
|
+
--st-spacing-medium: 8px;
|
|
141
|
+
--st-spacing-large: 16px;
|
|
142
|
+
|
|
143
|
+
/* Colors */
|
|
144
|
+
--st-border-color: #e0e0e0;
|
|
145
|
+
--st-text-color: #333;
|
|
146
|
+
--st-background-color: #fff;
|
|
147
|
+
--st-header-background-color: #f5f5f5;
|
|
148
|
+
--st-resize-handle-color: #ccc;
|
|
149
|
+
--st-separator-border-color: #e0e0e0;
|
|
150
|
+
--st-odd-row-background-color: #f9f9f9;
|
|
151
|
+
--st-hover-background-color: #f0f0f0;
|
|
152
|
+
--st-dragging-background-color: #eaeaea;
|
|
153
|
+
--st-selected-cell-background-color: rgba(0, 120, 215, 0.1);
|
|
154
|
+
--st-selected-first-cell-background-color: rgba(0, 120, 215, 0.2);
|
|
155
|
+
--st-footer-background-color: #f5f5f5;
|
|
156
|
+
--st-last-group-row-separator-border-color: #4b5eaa;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
105
159
|
|
|
106
160
|
## License
|
|
107
161
|
|
|
@@ -5,27 +5,52 @@ import CellChangeProps from "../../types/CellChangeProps";
|
|
|
5
5
|
import "../../styles/simple-table.css";
|
|
6
6
|
import Theme from "../../types/Theme";
|
|
7
7
|
interface SpreadsheetProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
columnEditorPosition?: "left" | "right";
|
|
9
|
+
columnEditorText?: string;
|
|
10
|
+
columnResizing?: boolean;
|
|
11
|
+
defaultHeaders: HeaderObject[];
|
|
12
|
+
draggable?: boolean;
|
|
13
|
+
editColumns?: boolean;
|
|
14
|
+
height?: string;
|
|
15
|
+
hideFooter?: boolean;
|
|
16
|
+
nextIcon?: ReactNode;
|
|
17
|
+
onCellChange?: ({
|
|
18
|
+
accessor,
|
|
19
|
+
newValue,
|
|
20
|
+
originalRowIndex,
|
|
21
|
+
row,
|
|
22
|
+
}: CellChangeProps) => void;
|
|
23
|
+
prevIcon?: ReactNode;
|
|
24
|
+
rows: {
|
|
25
|
+
[key: string]: CellValue;
|
|
26
|
+
}[];
|
|
27
|
+
rowsPerPage?: number;
|
|
28
|
+
selectableCells?: boolean;
|
|
29
|
+
selectableColumns?: boolean;
|
|
30
|
+
shouldPaginate?: boolean;
|
|
31
|
+
sortDownIcon?: ReactNode;
|
|
32
|
+
sortUpIcon?: ReactNode;
|
|
33
|
+
theme?: Theme;
|
|
29
34
|
}
|
|
30
|
-
declare const SimpleTable: ({
|
|
35
|
+
declare const SimpleTable: ({
|
|
36
|
+
columnEditorPosition,
|
|
37
|
+
columnEditorText,
|
|
38
|
+
columnResizing,
|
|
39
|
+
defaultHeaders,
|
|
40
|
+
draggable,
|
|
41
|
+
editColumns,
|
|
42
|
+
height,
|
|
43
|
+
hideFooter,
|
|
44
|
+
nextIcon,
|
|
45
|
+
onCellChange,
|
|
46
|
+
prevIcon,
|
|
47
|
+
rows,
|
|
48
|
+
rowsPerPage,
|
|
49
|
+
selectableCells,
|
|
50
|
+
selectableColumns,
|
|
51
|
+
shouldPaginate,
|
|
52
|
+
sortDownIcon,
|
|
53
|
+
sortUpIcon,
|
|
54
|
+
theme,
|
|
55
|
+
}: SpreadsheetProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
56
|
export default SimpleTable;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-table-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
"spreadsheet-react"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
24
|
+
"@storybook/addon-a11y": "^8.6.2",
|
|
25
|
+
"@storybook/addon-controls": "^8.6.2",
|
|
26
|
+
"@storybook/addon-docs": "^8.6.2",
|
|
27
|
+
"react": "^19.0.0"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"@babel/preset-react": "^7.25.7",
|
|
@@ -37,7 +40,7 @@
|
|
|
37
40
|
"@storybook/react-webpack5": "^8.4.1",
|
|
38
41
|
"@storybook/test": "^8.4.1",
|
|
39
42
|
"@types/node": "^16.18.111",
|
|
40
|
-
"@types/react": "^
|
|
43
|
+
"@types/react": "^19.0.0",
|
|
41
44
|
"eslint-plugin-storybook": "^0.9.0",
|
|
42
45
|
"prop-types": "^15.8.1",
|
|
43
46
|
"rollup": "^2.79.2",
|