angel-table 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/README.md +320 -22
  2. package/package.json +22 -11
package/README.md CHANGED
@@ -1,35 +1,333 @@
1
- # React + TypeScript + Vite
1
+ # Angel Table
2
2
 
3
- This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.
3
+ A flexible and customizable React Table component with built-in sorting, pagination, search, column visibility, row selection, and responsive card layout.
4
4
 
5
- Currently, two official plugins are available:
5
+ ## Features
6
6
 
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
7
+ - **Responsive Layout** – Automatically adapts between table and card views.
8
+ - **Card View** – Display data as cards on smaller screens.
9
+ - **Sorting** – Sort columns in ascending and descending order.
10
+ - **Pagination** – Built-in pagination controls.
11
+ - **Search** – Search and filter table data.
12
+ - **Row Selection** – Select individual rows or multiple rows.
13
+ - **Column Visibility** – Show or hide columns dynamically.
14
+ - **Custom Rendering** – Customize cell content using render functions.
15
+ - **Remote Data** – Fetch data from an API using a URL.
16
+ - **Custom Styling** – Customize the appearance using CSS.
17
+ - **TypeScript Support** – Built-in TypeScript declarations.
9
18
 
10
- ## React Compiler
19
+ ## Installation
11
20
 
12
- The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
21
+ Install the package using npm:
13
22
 
14
- Note: This will impact Vite dev & build performances.
15
- You can also try [the experimental native React Compiler support in plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md#rust-react-compiler) by using `compiler: true` in the plugin options instead of using the Babel plugin.
23
+ ```bash
24
+ npm install angel-table
25
+ ```
26
+
27
+ Or using yarn:
28
+
29
+ ```bash
30
+ yarn add angel-table
31
+ ```
32
+
33
+ Or using pnpm:
34
+
35
+ ```bash
36
+ pnpm add angel-table
37
+ ```
38
+
39
+ ## Basic Usage
40
+
41
+ Import the `Table` component:
42
+
43
+ ```tsx
44
+ import { Table } from 'angel-table';
45
+
46
+ function App() {
47
+ return (
48
+ <Table
49
+ columns={[
50
+ {
51
+ title: 'Name',
52
+ field: 'name',
53
+ },
54
+ {
55
+ title: 'Email',
56
+ field: 'email',
57
+ },
58
+ {
59
+ title: 'Age',
60
+ field: 'age',
61
+ },
62
+ ]}
63
+ rows={[
64
+ {
65
+ id: 1,
66
+ name: 'John Doe',
67
+ email: 'john@example.com',
68
+ age: 25,
69
+ },
70
+ {
71
+ id: 2,
72
+ name: 'Jane Smith',
73
+ email: 'jane@example.com',
74
+ age: 28,
75
+ },
76
+ ]}
77
+ />
78
+ );
79
+ }
80
+
81
+ export default App;
82
+ ```
83
+
84
+ ## API Integration
85
+
86
+ Angel Table supports loading data from an API through `setup.url`.
87
+
88
+ ```tsx
89
+ import { Table } from 'angel-table';
90
+
91
+ function App() {
92
+ return (
93
+ <Table
94
+ setup={{
95
+ keyObject: '_id',
96
+ url: 'https://fakestoreapi.noksha.dev/api/products',
97
+ }}
98
+ columns={[
99
+ {
100
+ title: 'Product',
101
+ field: 'title',
102
+ sort: true,
103
+ },
104
+ {
105
+ title: 'Category',
106
+ field: 'category',
107
+ sort: true,
108
+ },
109
+ {
110
+ title: 'Price',
111
+ field: 'price',
112
+ sort: true,
113
+ },
114
+ ]}
115
+ />
116
+ );
117
+ }
118
+
119
+ export default App;
120
+ ```
121
+
122
+ ## Advanced Usage
123
+
124
+ The following example demonstrates custom columns, responsive card view, column visibility, sorting, and custom cell rendering.
125
+
126
+ ```tsx
127
+ import { Table } from 'angel-table';
128
+ import './App.css';
129
+
130
+ function App() {
131
+ return (
132
+ <Table
133
+ className='e'
134
+ setup={{
135
+ viewDefault: 'card',
136
+ keyObject: '_id',
137
+ showColumns: true,
138
+ url: 'https://fakestoreapi.noksha.dev/api/products',
139
+ }}
140
+ columns={[
141
+ {
142
+ title: 'No.',
143
+ field: 'index_field',
144
+ width: '70px',
145
+ },
146
+ {
147
+ title: 'Image',
148
+ field: 'image',
149
+ width: '100px',
150
+ render: (row) => (
151
+ <img
152
+ src={row.image}
153
+ loading='lazy'
154
+ alt={row.title}
155
+ style={{
156
+ width: '50px',
157
+ height: '50px',
158
+ objectFit: 'cover',
159
+ borderRadius: '6px',
160
+ }}
161
+ />
162
+ ),
163
+ },
164
+ {
165
+ title: 'Product',
166
+ field: 'title',
167
+ width: '200px',
168
+ sort: true,
169
+ },
170
+ {
171
+ title: 'Category',
172
+ field: 'category',
173
+ sort: true,
174
+ },
175
+ {
176
+ title: 'Type',
177
+ field: 'type',
178
+ sort: true,
179
+ },
180
+ {
181
+ title: 'Brand',
182
+ field: 'brand',
183
+ sort: true,
184
+ },
185
+ {
186
+ title: 'Old Price',
187
+ field: 'oldPrice',
188
+ sort: true,
189
+ render: (row) => `$${row.oldPrice}`,
190
+ },
191
+ {
192
+ title: 'Price',
193
+ field: 'price',
194
+ sort: true,
195
+ render: (row) => `$${row.price}`,
196
+ },
197
+ {
198
+ title: 'Discounted Price',
199
+ field: 'discountedPrice',
200
+ sort: true,
201
+ render: (row) => `$${row.discountedPrice}`,
202
+ },
203
+ {
204
+ title: 'Stock',
205
+ field: 'stock',
206
+ sort: true,
207
+ },
208
+ {
209
+ title: 'Size',
210
+ field: 'size',
211
+ render: (row) => row.size?.join(', '),
212
+ },
213
+ {
214
+ title: 'New',
215
+ field: 'isNew',
216
+ render: (row) => (row.isNew ? 'Yes' : 'No'),
217
+ },
218
+ {
219
+ title: 'Description',
220
+ field: 'description',
221
+ show: false,
222
+ },
223
+ {
224
+ title: 'Actions',
225
+ field: 'action_field',
226
+ width: '120px',
227
+ },
228
+ ]}
229
+ />
230
+ );
231
+ }
232
+
233
+ export default App;
234
+ ```
16
235
 
17
- ## Expanding the Oxlint configuration
236
+ ## Column Configuration
18
237
 
19
- If you are developing a production application, we recommend enabling type-aware lint rules by installing `oxlint-tsgolint` and editing `.oxlintrc.json`:
238
+ Each column supports the following properties:
20
239
 
21
- ```json
240
+ | Property | Type | Description |
241
+ | ----------- | ---------- | --------------------------- |
242
+ | `title` | `string` | Column heading |
243
+ | `field` | `string` | Data field or special field |
244
+ | `width` | `string` | Column width |
245
+ | `className` | `string` | Custom CSS class |
246
+ | `sort` | `boolean` | Enable sorting |
247
+ | `sortLabel` | `object` | Custom sorting labels |
248
+ | `show` | `boolean` | Control column visibility |
249
+ | `render` | `function` | Custom cell rendering |
250
+
251
+ ### Special Fields
252
+
253
+ Angel Table provides special fields for common table functionality:
254
+
255
+ | Field | Description |
256
+ | -------------- | ---------------------- |
257
+ | `index_field` | Display row index |
258
+ | `check_field` | Row selection checkbox |
259
+ | `action_field` | Action column |
260
+
261
+ ### Custom Rendering
262
+
263
+ Use `render` to customize how cell values are displayed.
264
+
265
+ ```tsx
22
266
  {
23
- "$schema": "./node_modules/oxlint/configuration_schema.json",
24
- "plugins": ["react", "typescript", "oxc"],
25
- "options": {
26
- "typeAware": true
27
- },
28
- "rules": {
29
- "react/rules-of-hooks": "error",
30
- "react/only-export-components": ["warn", { "allowConstantExport": true }]
31
- }
267
+ title: 'Status',
268
+ field: 'status',
269
+ render: (row) => (
270
+ <span className={`status status-${row.status}`}>
271
+ {row.status}
272
+ </span>
273
+ ),
32
274
  }
33
275
  ```
34
276
 
35
- See the [Oxlint rules documentation](https://oxc.rs/docs/guide/usage/linter/rules) for the full list of rules and categories.
277
+ ## Table Configuration
278
+
279
+ The `setup` property controls the table's behavior.
280
+
281
+ | Property | Type | Description |
282
+ | ------------- | --------- | ---------------------------------------- |
283
+ | `keyObject` | `string` | Unique identifier for each row |
284
+ | `url` | `string` | API endpoint for remote data |
285
+ | `viewDefault` | `string` | Default display mode (`table` or `card`) |
286
+ | `showColumns` | `boolean` | Enable column visibility controls |
287
+
288
+ Example:
289
+
290
+ ```tsx
291
+ <Table
292
+ setup={{
293
+ keyObject: 'id',
294
+ viewDefault: 'table',
295
+ showColumns: true,
296
+ url: 'https://example.com/api/data',
297
+ }}
298
+ columns={columns}
299
+ />
300
+ ```
301
+
302
+ ## Import Styles
303
+
304
+ Angel Table requires its stylesheet to be imported separately.
305
+
306
+ ```tsx
307
+ import { Table } from 'angel-table';
308
+ import 'angel-table/style.css';
309
+ ```
310
+
311
+ Make sure to import the stylesheet once in your application entry point or main component.
312
+
313
+ Without importing the stylesheet, the table may not display correctly.
314
+
315
+ For dark mode, the component supports theme styling through:
316
+
317
+ ```tsx
318
+ <Table columns={columns} setup={{ mode: 'dark' }} />
319
+ ```
320
+
321
+ You can also override the CSS variables to customize colors, borders, backgrounds, and other visual properties.
322
+
323
+ ## TypeScript
324
+
325
+ Angel Table includes TypeScript type declarations, allowing you to get autocomplete and type checking when configuring columns and table data.
326
+
327
+ ```tsx
328
+ import { Table } from 'angel-table';
329
+ ```
330
+
331
+ ## License
332
+
333
+ Mit
package/package.json CHANGED
@@ -1,30 +1,39 @@
1
1
  {
2
2
  "name": "angel-table",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
+ "description": "A flexible and customizable React Table component",
4
5
  "type": "module",
5
6
  "files": [
6
- "dist"
7
+ "dist",
8
+ "README.md"
7
9
  ],
8
10
  "main": "./dist/angel-table.umd.cjs",
9
11
  "module": "./dist/angel-table.js",
12
+ "types": "./dist/lib/main.d.ts",
13
+ "style": "./dist/style.css",
10
14
  "exports": {
11
15
  ".": {
16
+ "types": "./dist/lib/main.d.ts",
12
17
  "import": "./dist/angel-table.js",
13
18
  "require": "./dist/angel-table.umd.cjs"
14
- }
19
+ },
20
+ "./style.css": "./dist/style.css"
15
21
  },
22
+ "sideEffects": [
23
+ "**/*.css"
24
+ ],
16
25
  "scripts": {
17
26
  "dev": "vite",
18
27
  "prebuild": "rm -rf dist",
19
28
  "build": "tsc -b && vite build",
20
29
  "lint": "oxlint",
21
30
  "preview": "vite preview",
22
- "publish": "npm run build && npm publish"
31
+ "prepublishOnly": "npm run build",
32
+ "publish": "npm publish"
23
33
  },
24
- "dependencies": {
25
- "react": "^19.3.1",
26
- "react-dom": "^19.3.1",
27
- "vite-plugin-dts": "^5.1.2"
34
+ "peerDependencies": {
35
+ "react": ">=18.0.0",
36
+ "react-dom": ">=18.0.0"
28
37
  },
29
38
  "devDependencies": {
30
39
  "@babel/core": "^7.29.7",
@@ -33,11 +42,13 @@
33
42
  "@types/node": "^24.19.2",
34
43
  "@types/react": "^19.3.0",
35
44
  "@types/react-dom": "^19.3.0",
36
- "@typescript/typescript6": "^6.0.2",
37
45
  "@vitejs/plugin-react": "^6.1.2",
38
46
  "babel-plugin-react-compiler": "^1.0.0",
39
47
  "oxlint": "^1.90.0",
40
- "typescript": "~7.0.2",
41
- "vite": "^8.3.6"
48
+ "react": "^19.3.1",
49
+ "react-dom": "^19.3.1",
50
+ "typescript": "^6.0.3",
51
+ "vite": "^8.3.6",
52
+ "vite-plugin-dts": "^5.1.2"
42
53
  }
43
54
  }