jattac.libs.web.responsive-table 0.0.1 → 0.0.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 +75 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,47 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ResponsiveTable
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ResponsiveTable is a reusable React component that displays tabular data in a responsive layout.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
- Handles mobile and desktop layouts
|
|
8
|
+
- Customizable columns
|
|
9
|
+
- Dynamic column definitions
|
|
10
|
+
- Card-style mobile view
|
|
11
|
+
- Generic types for flexible data
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
import React from 'react';
|
|
15
|
-
import FormField from 'jattac.libs.web.form-field';
|
|
16
|
-
|
|
17
|
-
const MyForm = () => {
|
|
18
|
-
const validationErrors = [
|
|
19
|
-
// Your validation errors here
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<form>
|
|
24
|
-
<FormField
|
|
25
|
-
label="Email"
|
|
26
|
-
id="email"
|
|
27
|
-
validationErrors={[{ key: 'email', errors: ['Invalid email address'] }]}
|
|
28
|
-
optional={true}
|
|
29
|
-
hint="We'll never share your email with anyone else."
|
|
30
|
-
>
|
|
31
|
-
<input type="email" />
|
|
32
|
-
</FormField>
|
|
33
|
-
|
|
34
|
-
{/* Add more FormField components for other form elements */}
|
|
35
|
-
</form>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
15
|
+
```jsx
|
|
16
|
+
<ResponsiveTable columnDefinitions={columns} data={data} />
|
|
38
17
|
```
|
|
39
18
|
|
|
19
|
+
- 'columnDefinitions' defines an array of columns, which can be a simple configuration object or dynamic function
|
|
20
|
+
- 'data' is an array of data objects to display in rows
|
|
21
|
+
|
|
22
|
+
The component handles switching layout based on screen width to optimize for desktop and mobile.
|
|
23
|
+
|
|
24
|
+
## Custom Columns
|
|
25
|
+
|
|
26
|
+
Columns can be configured using the 'IResponsiveTableColumnDefinition' interface.
|
|
27
|
+
|
|
28
|
+
Some key configuration options:
|
|
29
|
+
|
|
30
|
+
- 'displayLabel': Header label
|
|
31
|
+
- 'dataKey': Maps column to data property
|
|
32
|
+
- 'cellRenderer': Renders cell value
|
|
33
|
+
|
|
34
|
+
See docs for more details on customization.
|
|
35
|
+
|
|
36
|
+
## Dynamic Columns
|
|
37
|
+
|
|
38
|
+
Column definitions can also be a function allowing dynamic configurations per row.
|
|
39
|
+
|
|
40
|
+
## Styling
|
|
41
|
+
|
|
42
|
+
Use CSS modules or global styles to customize visual layout:
|
|
43
|
+
|
|
44
|
+
- '.responsiveTable': Root table
|
|
45
|
+
- '.card': Mobile card containers
|
|
46
|
+
|
|
40
47
|
## Props
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
Prop definitions provide detailed specification of component contract.
|
|
50
|
+
|
|
51
|
+
### IProps
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
interface IProps<TData> {
|
|
55
|
+
/** Column definitions */
|
|
56
|
+
columnDefinitions: ColumnDefinition<TData>[];
|
|
57
|
+
|
|
58
|
+
/** Table data rows */
|
|
59
|
+
data: TData[];
|
|
60
|
+
|
|
61
|
+
/** Optional styling */
|
|
62
|
+
className?: string;
|
|
63
|
+
|
|
64
|
+
/** row click handler */
|
|
65
|
+
onRowClicked?: (row: TData) => void;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
type ColumnDefinition<TData> =
|
|
71
|
+
| IResponsiveTableColumnDefinition<TData>
|
|
72
|
+
| ((rowData: TData, rowIndex?: number) => IResponsiveTableColumnDefinition<TData>);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
interface IResponsiveTableColumnDefinition<TData> {
|
|
77
|
+
displayLabel: string | ReactNode;
|
|
78
|
+
|
|
79
|
+
dataKey?: keyof TData;
|
|
80
|
+
|
|
81
|
+
cellRenderer: (rowData: TData) => ReactNode;
|
|
82
|
+
}
|
|
83
|
+
```
|