simple-table-core 0.4.3 → 0.4.5

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 CHANGED
@@ -1,157 +1,19 @@
1
1
  # Simple Table
2
2
 
3
- Any questions, support or features requests join me on Dicord [https://discord.gg/RvKHCfg3PC](https://discord.gg/RvKHCfg3PC). I am happy to help and make this table even better!
3
+ Any questions, support or features requests join me on Dicord <a href="https://discord.gg/RvKHCfg3PC" target="_blank">https://discord.gg/RvKHCfg3PC</a>. I am happy to help and make this table even better!
4
4
 
5
5
  Simple Table is a React grid package designed to provide a flexible and easy-to-use table component for your React applications.
6
6
 
7
+ ## Live Demo
8
+
9
+ Check out the live demo on CodeSandbox: <a href="https://codesandbox.io/p/sandbox/simple-table-pagination-example-rdjm5d?file=%2Fsrc%2FApp.tsx%3A33%2C24" target="_blank">Simple Table Pagination Example</a>
10
+
7
11
  <div align="center">
8
- <a href="https://github.com/petera2c/simple-table-marketing/blob/main/src/assets/simple-table-demo-fast.gif?raw=true">
12
+ <a href="https://github.com/petera2c/simple-table-marketing/blob/main/src/assets/simple-table-demo-fast.gif?raw=true" target="_blank">
9
13
  <img src="https://github.com/petera2c/simple-table-marketing/blob/main/src/assets/simple-table-demo-fast.gif?raw=true" alt="Simple Table Demo" />
10
14
  </a>
11
15
  </div>
12
16
 
13
- ## Live Demo
14
-
15
- Check out the live demo on CodeSandbox: [Simple Table Pagination Example](https://codesandbox.io/p/sandbox/simple-table-pagination-example-rdjm5d?file=%2Fsrc%2FApp.tsx%3A33%2C24)
16
-
17
- ## Example Usage
18
-
19
- ```tsx
20
- import { useState } from "react";
21
- import { SimpleTable } from "simple-table-core";
22
- import CellChangeProps from "simple-table-core/dist/types/CellChangeProps";
23
- import "simple-table-core/dist/style.css";
24
-
25
- const SAMPLE_HEADERS: any[] = [
26
- { label: "Product ID", accessor: "id", width: 150 },
27
- { label: "Product Name", accessor: "productName", width: 200 },
28
- { label: "Category", accessor: "category", width: 150 },
29
- { label: "Quantity", accessor: "quantity", width: 100 },
30
- { label: "Price", accessor: "price", width: 100 },
31
- { label: "Supplier", accessor: "supplier", width: 150 },
32
- { label: "Location", accessor: "location", width: 150 },
33
- { label: "Reorder Level", accessor: "reorderLevel", width: 100 },
34
- { label: "SKU", accessor: "sku", width: 100 },
35
- { label: "Description", accessor: "description", width: 250 },
36
- { label: "Weight", accessor: "weight", width: 100 },
37
- { label: "Dimensions", accessor: "dimensions", width: 150 },
38
- { label: "Barcode", accessor: "barcode", width: 100 },
39
- ];
40
-
41
- const inventoryData: any[] = Array.from({ length: 50 }, (_, index) => ({
42
- id: `P-${index + 1001}`,
43
- productName: [
44
- "Wireless Mouse",
45
- "Bluetooth Speaker",
46
- "LED Monitor",
47
- "Gaming Keyboard",
48
- "Smartphone",
49
- "Laptop",
50
- "Tablet",
51
- "Headphones",
52
- "Smartwatch",
53
- "External Hard Drive",
54
- ][index % 10],
55
- category: ["Electronics", "Furniture", "Clothing", "Food", "Books"][
56
- Math.floor(Math.random() * 5)
57
- ],
58
- quantity: Math.floor(Math.random() * 100) + 1,
59
- price: (Math.random() * 100).toFixed(2),
60
- supplier: [
61
- "Tech Supplies Co.",
62
- "Gadget World",
63
- "Office Essentials",
64
- "Home Comforts",
65
- "Fashion Hub",
66
- ][Math.floor(Math.random() * 5)],
67
- location: [
68
- "Warehouse A - New York",
69
- "Warehouse B - Los Angeles",
70
- "Warehouse C - Chicago",
71
- "Warehouse D - Houston",
72
- "Warehouse E - Miami",
73
- ][Math.floor(Math.random() * 5)],
74
- reorderLevel: Math.floor(Math.random() * 20) + 5,
75
- sku: `SKU-${index + 1001}`,
76
- description: `High-quality ${
77
- [
78
- "wireless mouse",
79
- "bluetooth speaker",
80
- "LED monitor",
81
- "gaming keyboard",
82
- "smartphone",
83
- "laptop",
84
- "tablet",
85
- "headphones",
86
- "smartwatch",
87
- "external hard drive",
88
- ][index % 10]
89
- } for everyday use.`,
90
- weight: `${(Math.random() * 10).toFixed(2)} kg`,
91
- dimensions: `${(Math.random() * 100).toFixed(2)}x${(
92
- Math.random() * 100
93
- ).toFixed(2)}x${(Math.random() * 100).toFixed(2)} cm`,
94
- barcode: `1234567890${index}`,
95
- expirationDate: `2024-${Math.floor(Math.random() * 12) + 1}-${
96
- Math.floor(Math.random() * 28) + 1
97
- }`,
98
- manufacturer: [
99
- "Tech Innovators Inc.",
100
- "Gadget Makers Ltd.",
101
- "Office Producers",
102
- "Home Creators",
103
- "Fashion Designers",
104
- ][Math.floor(Math.random() * 5)],
105
- }));
106
-
107
- const SimpleTableExample = () => {
108
- const [rows, setRows] = useState(inventoryData);
109
-
110
- const updateCell = ({
111
- accessor,
112
- newRowIndex,
113
- newValue,
114
- originalRowIndex,
115
- row,
116
- }: CellChangeProps) => {
117
- setRows((prevRows) => {
118
- prevRows[originalRowIndex][accessor] = newValue;
119
- return prevRows;
120
- });
121
- };
122
-
123
- return (
124
- <div style={{ padding: "2rem" }}>
125
- <SimpleTable
126
- // Enable column resizing
127
- columnResizing
128
- // Enable draggable columns
129
- draggable
130
- // Enable editing columns
131
- editColumns
132
- // Set the headers
133
- defaultHeaders={SAMPLE_HEADERS}
134
- // Set the rows
135
- rows={inventoryData}
136
- // Handle cell changes
137
- onCellChange={updateCell}
138
- // Enable selectable cells
139
- selectableCells
140
- // Use pagination
141
- shouldPaginate
142
- height="auto"
143
- rowsPerPage={8}
144
-
145
- // If you aren't using pagination a height is required
146
- // height="calc(100dvh - 4rem)"`
147
- />
148
- </div>
149
- );
150
- };
151
-
152
- export default SimpleTableExample;
153
- ```
154
-
155
17
  ## Props
156
18
 
157
19
  The Simple Table component accepts the following props:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-table-core",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,6 +42,7 @@
42
42
  "prop-types": "^15.8.1",
43
43
  "rollup": "^2.79.2",
44
44
  "rollup-plugin-babel": "^4.4.0",
45
+ "rollup-plugin-copy": "^3.5.0",
45
46
  "rollup-plugin-peer-deps-external": "^2.2.4",
46
47
  "rollup-plugin-postcss": "^4.0.2",
47
48
  "rollup-plugin-terser": "^7.0.2",
@@ -49,7 +50,7 @@
49
50
  "storybook": "^8.4.1",
50
51
  "typescript": "^4.9.5",
51
52
  "webpack": "^5.95.0",
52
- "rollup-plugin-copy": "^3.5.0"
53
+ "rollup-plugin-delete": "^2.1.0"
53
54
  },
54
55
  "scripts": {
55
56
  "publish-fast": "npm run build && git add . && git commit -m \"$npm_config_message\" && npm publish && git push",
Binary file
@@ -1,6 +0,0 @@
1
- type TableColumnEditorProps = {
2
- columnEditorText: string;
3
- editColumns: boolean;
4
- };
5
- declare const TableColumnEditor: ({ columnEditorText, editColumns, }: TableColumnEditorProps) => import("react/jsx-runtime").JSX.Element | null;
6
- export default TableColumnEditor;