@mistersee/global-table 0.1.1 → 0.1.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 +14 -14
- package/dist/SeeTable.d.ts +2 -2
- package/dist/global-table.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Adjust the `@source` path to match your project layout.
|
|
|
64
64
|
## Quick start
|
|
65
65
|
|
|
66
66
|
```tsx
|
|
67
|
-
import {
|
|
67
|
+
import { MisterSeeGlobalTable } from '@mistersee/global-table'
|
|
68
68
|
import type { ColumnDef } from '@mistersee/global-table'
|
|
69
69
|
|
|
70
70
|
type Customer = {
|
|
@@ -95,7 +95,7 @@ const columns: ColumnDef<Customer>[] = [
|
|
|
95
95
|
|
|
96
96
|
export function CustomersTable({ rows }: { rows: Customer[] }) {
|
|
97
97
|
return (
|
|
98
|
-
<
|
|
98
|
+
<MisterSeeGlobalTable
|
|
99
99
|
columns={columns}
|
|
100
100
|
data={rows}
|
|
101
101
|
getRowId={(row) => row.id}
|
|
@@ -158,7 +158,7 @@ Use `width: 'auto'` for content-sized columns such as action button groups.
|
|
|
158
158
|
|
|
159
159
|
---
|
|
160
160
|
|
|
161
|
-
## `
|
|
161
|
+
## `MisterSeeGlobalTable` props
|
|
162
162
|
|
|
163
163
|
### Data & columns
|
|
164
164
|
|
|
@@ -178,7 +178,7 @@ Use `width: 'auto'` for content-sized columns such as action button groups.
|
|
|
178
178
|
| `stickyRight` | `string[]` | — | Column keys pinned to the right |
|
|
179
179
|
|
|
180
180
|
```tsx
|
|
181
|
-
<
|
|
181
|
+
<MisterSeeGlobalTable
|
|
182
182
|
stickyLeft={['firstName']}
|
|
183
183
|
stickyRight={['actions']}
|
|
184
184
|
{...props}
|
|
@@ -209,7 +209,7 @@ When `stickyLeft` / `stickyRight` are provided, they become the source of truth
|
|
|
209
209
|
| `columnsLabel` | `ReactNode` | `"Columns"` | Button label |
|
|
210
210
|
|
|
211
211
|
```tsx
|
|
212
|
-
<
|
|
212
|
+
<MisterSeeGlobalTable showColumnToggle={false} {...props} />
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
### Column reorder (drag & drop)
|
|
@@ -223,7 +223,7 @@ When `stickyLeft` / `stickyRight` are provided, they become the source of truth
|
|
|
223
223
|
```tsx
|
|
224
224
|
const [columnOrder, setColumnOrder] = useState(columns.map((c) => c.key))
|
|
225
225
|
|
|
226
|
-
<
|
|
226
|
+
<MisterSeeGlobalTable
|
|
227
227
|
columnOrder={columnOrder}
|
|
228
228
|
onColumnOrderChange={setColumnOrder}
|
|
229
229
|
enableColumnReorder
|
|
@@ -234,7 +234,7 @@ const [columnOrder, setColumnOrder] = useState(columns.map((c) => c.key))
|
|
|
234
234
|
To disable reordering entirely:
|
|
235
235
|
|
|
236
236
|
```tsx
|
|
237
|
-
<
|
|
237
|
+
<MisterSeeGlobalTable enableColumnReorder={false} {...props} />
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
### Actions column
|
|
@@ -246,7 +246,7 @@ To disable reordering entirely:
|
|
|
246
246
|
| `actionsHeader` | `ReactNode` | `"Actions"` | Header if column is auto-created |
|
|
247
247
|
|
|
248
248
|
```tsx
|
|
249
|
-
<
|
|
249
|
+
<MisterSeeGlobalTable
|
|
250
250
|
renderActions={(row) => (
|
|
251
251
|
<div className="flex gap-1.5">
|
|
252
252
|
<button type="button">View</button>
|
|
@@ -276,7 +276,7 @@ To disable reordering entirely:
|
|
|
276
276
|
| `fieldClassNames` | `Record<string, string \| ((row, rowIndex) => string \| undefined)>` | Per-field Tailwind classes |
|
|
277
277
|
|
|
278
278
|
```tsx
|
|
279
|
-
<
|
|
279
|
+
<MisterSeeGlobalTable
|
|
280
280
|
fieldClassNames={{
|
|
281
281
|
spent: 'text-green-500 font-medium',
|
|
282
282
|
orders: 'text-blue-500',
|
|
@@ -305,7 +305,7 @@ To disable reordering entirely:
|
|
|
305
305
|
| `pagination` | Footer controls |
|
|
306
306
|
|
|
307
307
|
```tsx
|
|
308
|
-
<
|
|
308
|
+
<MisterSeeGlobalTable
|
|
309
309
|
classNames={{
|
|
310
310
|
root: 'rounded-xl bg-white p-3 shadow-sm',
|
|
311
311
|
th: 'bg-zinc-100 font-medium text-zinc-700',
|
|
@@ -322,7 +322,7 @@ Sticky headers/cells respect `classNames.th` / `classNames.td` (including custom
|
|
|
322
322
|
## Loading state
|
|
323
323
|
|
|
324
324
|
```tsx
|
|
325
|
-
<
|
|
325
|
+
<MisterSeeGlobalTable columns={columns} data={rows} loading />
|
|
326
326
|
```
|
|
327
327
|
|
|
328
328
|
When `loading` is `true`, skeleton rows are rendered to match the current page size and visible column count.
|
|
@@ -333,7 +333,7 @@ When `loading` is `true`, skeleton rows are rendered to match the current page s
|
|
|
333
333
|
|
|
334
334
|
```ts
|
|
335
335
|
import {
|
|
336
|
-
|
|
336
|
+
MisterSeeGlobalTable,
|
|
337
337
|
INDEX_COLUMN_KEY,
|
|
338
338
|
DEFAULT_COL_MIN_WIDTH, // 120
|
|
339
339
|
DEFAULT_COL_MAX_WIDTH, // 310
|
|
@@ -341,8 +341,8 @@ import {
|
|
|
341
341
|
|
|
342
342
|
import type {
|
|
343
343
|
ColumnDef,
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
MisterSeeGlobalTableProps,
|
|
345
|
+
MisterSeeGlobalTableClassNames,
|
|
346
346
|
StickySide,
|
|
347
347
|
} from '@mistersee/global-table'
|
|
348
348
|
```
|
package/dist/SeeTable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MisterSeeGlobalTableProps } from './types';
|
|
2
2
|
export declare const INDEX_COLUMN_KEY = "__see_table_index__";
|
|
3
3
|
export declare const DEFAULT_COL_MIN_WIDTH = 120;
|
|
4
4
|
export declare const DEFAULT_COL_MAX_WIDTH = 310;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function MisterSeeGlobalTable<T extends Record<string, unknown>>({ columns, data, getRowId, defaultVisibleColumns, limit: limitProp, skip: skipProp, total: totalProp, onPaginationChange, limitOptions, loading, stickyLeft, stickyRight, renderActions, actionsKey, actionsHeader, columnOrder, onColumnOrderChange, enableColumnReorder, showColumnToggle, columnsLabel, showIndex, indexHeader, indexWidth, renderIndex, fieldClassNames, classNames, }: MisterSeeGlobalTableProps<T>): import("react").JSX.Element;
|
package/dist/global-table.js
CHANGED
|
@@ -2441,4 +2441,4 @@ function ht({ columns: e, data: t, getRowId: o, defaultVisibleColumns: s, limit:
|
|
|
2441
2441
|
});
|
|
2442
2442
|
}
|
|
2443
2443
|
//#endregion
|
|
2444
|
-
export { lt as DEFAULT_COL_MAX_WIDTH, ct as DEFAULT_COL_MIN_WIDTH, st as INDEX_COLUMN_KEY, ht as
|
|
2444
|
+
export { lt as DEFAULT_COL_MAX_WIDTH, ct as DEFAULT_COL_MIN_WIDTH, st as INDEX_COLUMN_KEY, ht as MisterSeeGlobalTable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type { ColumnDef,
|
|
1
|
+
export { MisterSeeGlobalTable, INDEX_COLUMN_KEY, DEFAULT_COL_MIN_WIDTH, DEFAULT_COL_MAX_WIDTH, } from './SeeTable';
|
|
2
|
+
export type { ColumnDef, MisterSeeGlobalTableClassNames, MisterSeeGlobalTableProps, StickySide, } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ColumnDef<T> {
|
|
|
15
15
|
cell?: (row: T, rowIndex: number) => ReactNode;
|
|
16
16
|
className?: string;
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
18
|
+
export interface MisterSeeGlobalTableClassNames {
|
|
19
19
|
root?: string;
|
|
20
20
|
toolbar?: string;
|
|
21
21
|
tableWrapper?: string;
|
|
@@ -29,7 +29,7 @@ export interface SeeTableClassNames {
|
|
|
29
29
|
columnToggle?: string;
|
|
30
30
|
pagination?: string;
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
32
|
+
export interface MisterSeeGlobalTableProps<T extends Record<string, unknown>> {
|
|
33
33
|
columns: ColumnDef<T>[];
|
|
34
34
|
data: T[];
|
|
35
35
|
getRowId?: (row: T, index: number) => string;
|
|
@@ -107,5 +107,5 @@ export interface SeeTableProps<T extends Record<string, unknown>> {
|
|
|
107
107
|
* Value can be a static class string or a function of the row.
|
|
108
108
|
*/
|
|
109
109
|
fieldClassNames?: Partial<Record<string, string | ((row: T, rowIndex: number) => string | undefined)>>;
|
|
110
|
-
classNames?:
|
|
110
|
+
classNames?: MisterSeeGlobalTableClassNames;
|
|
111
111
|
}
|