@flamingo-stack/openframe-frontend-core 0.0.608 → 0.0.609-2113.5913.1
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/dist/{chunk-4ZBC4YSQ.cjs → chunk-2JKZKICA.cjs} +33 -33
- package/dist/{chunk-4ZBC4YSQ.cjs.map → chunk-2JKZKICA.cjs.map} +1 -1
- package/dist/{chunk-FK5WVAC3.js → chunk-34BA57EO.js} +2 -2
- package/dist/{chunk-JZBRMXB7.cjs → chunk-3KC4YVCJ.cjs} +17 -17
- package/dist/{chunk-JZBRMXB7.cjs.map → chunk-3KC4YVCJ.cjs.map} +1 -1
- package/dist/{chunk-4Y7LBWRN.cjs → chunk-4BUYTRP6.cjs} +288 -276
- package/dist/chunk-4BUYTRP6.cjs.map +1 -0
- package/dist/{chunk-IK2MM26F.js → chunk-4LVCITQG.js} +5 -5
- package/dist/{chunk-L77QUPE5.cjs → chunk-4PDLKBUA.cjs} +4 -4
- package/dist/{chunk-L77QUPE5.cjs.map → chunk-4PDLKBUA.cjs.map} +1 -1
- package/dist/{chunk-LJMTURDD.cjs → chunk-5QFWF6QN.cjs} +4 -4
- package/dist/{chunk-LJMTURDD.cjs.map → chunk-5QFWF6QN.cjs.map} +1 -1
- package/dist/{chunk-4LGYBV7U.js → chunk-63SY2DW3.js} +5 -5
- package/dist/{chunk-XATCZQGR.js → chunk-6DUHRCDQ.js} +2 -2
- package/dist/{chunk-6T3252KL.cjs → chunk-6LRBV2MA.cjs} +34 -34
- package/dist/{chunk-6T3252KL.cjs.map → chunk-6LRBV2MA.cjs.map} +1 -1
- package/dist/{chunk-PLPRL4YX.js → chunk-D36QAZEX.js} +2 -2
- package/dist/{chunk-ORGNII3T.js → chunk-DPMZASCC.js} +4 -4
- package/dist/{chunk-UCKFVNYV.js → chunk-FJM3UV2Z.js} +4 -4
- package/dist/{chunk-BEAO6SUX.cjs → chunk-GIOP6KQD.cjs} +50 -50
- package/dist/{chunk-BEAO6SUX.cjs.map → chunk-GIOP6KQD.cjs.map} +1 -1
- package/dist/{chunk-WZROKAJT.cjs → chunk-GXN4OKUQ.cjs} +17 -17
- package/dist/{chunk-WZROKAJT.cjs.map → chunk-GXN4OKUQ.cjs.map} +1 -1
- package/dist/{chunk-WHHA3LVL.js → chunk-H4ZECYZH.js} +2 -2
- package/dist/{chunk-FRRNSQOG.cjs → chunk-HMBYQ7WU.cjs} +18 -18
- package/dist/{chunk-FRRNSQOG.cjs.map → chunk-HMBYQ7WU.cjs.map} +1 -1
- package/dist/{chunk-5QHY4HCC.js → chunk-I5TRPSEK.js} +99 -87
- package/dist/chunk-I5TRPSEK.js.map +1 -0
- package/dist/{chunk-YTXKRN6K.cjs → chunk-I67XY2UV.cjs} +3 -3
- package/dist/{chunk-YTXKRN6K.cjs.map → chunk-I67XY2UV.cjs.map} +1 -1
- package/dist/{chunk-C3FIMKT7.cjs → chunk-IVLODGRR.cjs} +3 -3
- package/dist/{chunk-C3FIMKT7.cjs.map → chunk-IVLODGRR.cjs.map} +1 -1
- package/dist/{chunk-JIPSQ4P7.cjs → chunk-JYCVC6OX.cjs} +10 -10
- package/dist/{chunk-JIPSQ4P7.cjs.map → chunk-JYCVC6OX.cjs.map} +1 -1
- package/dist/{chunk-BKZCYRGG.js → chunk-KKQ4FI43.js} +2 -2
- package/dist/{chunk-7EETXACY.cjs → chunk-LBIE5HAR.cjs} +13 -13
- package/dist/{chunk-7EETXACY.cjs.map → chunk-LBIE5HAR.cjs.map} +1 -1
- package/dist/{chunk-RN3DBEWX.js → chunk-MYTBZRRX.js} +2 -2
- package/dist/{chunk-MDXSLZML.js → chunk-OYHHBSJU.js} +2 -2
- package/dist/{chunk-N25MIHYE.cjs → chunk-TXTSCXZZ.cjs} +3 -3
- package/dist/{chunk-N25MIHYE.cjs.map → chunk-TXTSCXZZ.cjs.map} +1 -1
- package/dist/{chunk-AQGQVYDC.js → chunk-X5PUF7LB.js} +2 -2
- package/dist/{chunk-7ADEWG65.cjs → chunk-XJ3CHQXO.cjs} +3 -3
- package/dist/{chunk-7ADEWG65.cjs.map → chunk-XJ3CHQXO.cjs.map} +1 -1
- package/dist/{chunk-HONE2UX4.js → chunk-XKWNSPN4.js} +2 -2
- package/dist/{chunk-N6GFOA4J.js → chunk-YFF2NLYR.js} +3 -3
- package/dist/components/case-studies/index.cjs +8 -8
- package/dist/components/case-studies/index.js +2 -2
- package/dist/components/contact/index.cjs +3 -3
- package/dist/components/contact/index.js +2 -2
- package/dist/components/docs/index.cjs +6 -6
- package/dist/components/docs/index.js +5 -5
- package/dist/components/embeds/index.cjs +3 -3
- package/dist/components/embeds/index.js +2 -2
- package/dist/components/faq/index.cjs +3 -3
- package/dist/components/faq/index.js +2 -2
- package/dist/components/features/index.cjs +2 -2
- package/dist/components/features/index.js +1 -1
- package/dist/components/help-center-pages/index.cjs +22 -22
- package/dist/components/help-center-pages/index.js +13 -13
- package/dist/components/index.cjs +31 -31
- package/dist/components/index.js +12 -12
- package/dist/components/layout/list-page-layout.d.ts +1 -1
- package/dist/components/layout/list-page-layout.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +21 -21
- package/dist/components/meeting-scheduler/index.js +1 -1
- package/dist/components/navigation/index.cjs +5 -5
- package/dist/components/navigation/index.js +4 -4
- package/dist/components/onboarding-guides/index.cjs +5 -5
- package/dist/components/onboarding-guides/index.js +4 -4
- package/dist/components/tickets/index.cjs +6 -6
- package/dist/components/tickets/index.js +5 -5
- package/dist/components/ui/data-table/data-table-body.d.ts +20 -1
- package/dist/components/ui/data-table/data-table-body.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-row.d.ts +11 -2
- package/dist/components/ui/data-table/data-table-row.d.ts.map +1 -1
- package/dist/components/ui/data-table/index.d.ts +2 -2
- package/dist/components/ui/data-table/index.d.ts.map +1 -1
- package/dist/components/ui/data-table/types.d.ts +9 -0
- package/dist/components/ui/data-table/types.d.ts.map +1 -1
- package/dist/components/ui/data-table/use-table-motion.d.ts.map +1 -0
- package/dist/components/ui/filter-modal.d.ts +1 -1
- package/dist/components/ui/filter-modal.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +2 -2
- package/dist/components/ui/index.js +1 -1
- package/dist/components/ui/query-report-table/query-report-table.d.ts.map +1 -1
- package/dist/components/ui/table/table.d.ts.map +1 -1
- package/dist/components/ui/table/types.d.ts +2 -5
- package/dist/components/ui/table/types.d.ts.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +5 -5
- package/package.json +1 -1
- package/src/components/layout/list-page-layout.tsx +1 -1
- package/src/components/ui/data-table/data-table-body.tsx +53 -18
- package/src/components/ui/data-table/data-table-row.tsx +26 -3
- package/src/components/ui/data-table/index.ts +1 -1
- package/src/components/ui/data-table/types.ts +10 -0
- package/src/components/ui/filter-modal.tsx +1 -1
- package/src/components/ui/query-report-table/query-report-table.tsx +6 -2
- package/src/components/ui/table/table.tsx +1 -1
- package/src/components/ui/table/types.ts +4 -5
- package/src/stories/DataTable.stories.tsx +95 -0
- package/src/stories/FilterModal.stories.tsx +1 -1
- package/src/stories/ListPageLayout.stories.tsx +191 -112
- package/src/stories/PageLayout.stories.tsx +21 -7
- package/dist/chunk-4Y7LBWRN.cjs.map +0 -1
- package/dist/chunk-5QHY4HCC.js.map +0 -1
- package/dist/components/ui/table/use-table-motion.d.ts.map +0 -1
- /package/dist/{chunk-FK5WVAC3.js.map → chunk-34BA57EO.js.map} +0 -0
- /package/dist/{chunk-IK2MM26F.js.map → chunk-4LVCITQG.js.map} +0 -0
- /package/dist/{chunk-4LGYBV7U.js.map → chunk-63SY2DW3.js.map} +0 -0
- /package/dist/{chunk-XATCZQGR.js.map → chunk-6DUHRCDQ.js.map} +0 -0
- /package/dist/{chunk-PLPRL4YX.js.map → chunk-D36QAZEX.js.map} +0 -0
- /package/dist/{chunk-ORGNII3T.js.map → chunk-DPMZASCC.js.map} +0 -0
- /package/dist/{chunk-UCKFVNYV.js.map → chunk-FJM3UV2Z.js.map} +0 -0
- /package/dist/{chunk-WHHA3LVL.js.map → chunk-H4ZECYZH.js.map} +0 -0
- /package/dist/{chunk-BKZCYRGG.js.map → chunk-KKQ4FI43.js.map} +0 -0
- /package/dist/{chunk-RN3DBEWX.js.map → chunk-MYTBZRRX.js.map} +0 -0
- /package/dist/{chunk-MDXSLZML.js.map → chunk-OYHHBSJU.js.map} +0 -0
- /package/dist/{chunk-AQGQVYDC.js.map → chunk-X5PUF7LB.js.map} +0 -0
- /package/dist/{chunk-HONE2UX4.js.map → chunk-XKWNSPN4.js.map} +0 -0
- /package/dist/{chunk-N6GFOA4J.js.map → chunk-YFF2NLYR.js.map} +0 -0
- /package/dist/components/ui/{table → data-table}/use-table-motion.d.ts +0 -0
- /package/src/components/ui/{table → data-table}/.use-table-motion.md +0 -0
- /package/src/components/ui/{table → data-table}/use-table-motion.ts +0 -0
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/nextjs-vite';
|
|
2
2
|
import { LayoutGrid, LayoutList, Plus, RefreshCw } from 'lucide-react';
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import { ListPageLayout } from '../components/layout/list-page-layout';
|
|
5
5
|
import { Button } from '../components/ui/button';
|
|
6
|
+
import {
|
|
7
|
+
DataTable,
|
|
8
|
+
useDataTable,
|
|
9
|
+
type ColumnDef,
|
|
10
|
+
type ColumnFiltersState,
|
|
11
|
+
type OnChangeFn,
|
|
12
|
+
type TableFilters,
|
|
13
|
+
} from '../components/ui/data-table';
|
|
6
14
|
import type { FilterGroup, SortConfig, SortDirection } from '../components/ui/filter-modal';
|
|
7
|
-
import { Table, type TableColumn, type TableFilters } from '../components/ui/table';
|
|
8
15
|
|
|
9
16
|
interface Device {
|
|
10
17
|
id: string;
|
|
@@ -22,32 +29,178 @@ const sampleDevices: Device[] = [
|
|
|
22
29
|
{ id: '5', name: 'Linux Server', status: 'online', type: 'Server', lastSeen: '2024-01-20' },
|
|
23
30
|
];
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
// Module-level so `useDataTable` sees stable `columns` references. The filter
|
|
33
|
+
// option ids are the device VALUES, the same ids the mobile `FilterModal`
|
|
34
|
+
// groups use below, so one `TableFilters` object drives both controls.
|
|
35
|
+
const deviceColumns: ColumnDef<Device>[] = [
|
|
36
|
+
{ accessorKey: 'name', header: 'Device Name', meta: { width: 'flex-1 min-w-0' } },
|
|
27
37
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
accessorKey: 'type',
|
|
39
|
+
header: 'Type',
|
|
40
|
+
meta: {
|
|
41
|
+
width: 'w-[160px]',
|
|
42
|
+
hideAt: 'lg',
|
|
43
|
+
filter: {
|
|
44
|
+
options: [
|
|
45
|
+
{ id: 'Laptop', label: 'Laptop', value: 'Laptop' },
|
|
46
|
+
{ id: 'Mobile', label: 'Mobile', value: 'Mobile' },
|
|
47
|
+
{ id: 'Desktop', label: 'Desktop', value: 'Desktop' },
|
|
48
|
+
{ id: 'Tablet', label: 'Tablet', value: 'Tablet' },
|
|
49
|
+
{ id: 'Server', label: 'Server', value: 'Server' },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
accessorKey: 'status',
|
|
56
|
+
header: 'Status',
|
|
57
|
+
meta: {
|
|
58
|
+
width: 'w-[140px]',
|
|
59
|
+
filter: {
|
|
60
|
+
options: [
|
|
61
|
+
{ id: 'online', label: 'Online', value: 'online' },
|
|
62
|
+
{ id: 'offline', label: 'Offline', value: 'offline' },
|
|
63
|
+
{ id: 'pending', label: 'Pending', value: 'pending' },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{ accessorKey: 'lastSeen', header: 'Last Seen', meta: { width: 'w-[160px]' } },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const NO_FILTERS: TableFilters = {};
|
|
72
|
+
|
|
73
|
+
function rowId(row: { id: string }) {
|
|
74
|
+
return row.id;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** `FilterModal` speaks `TableFilters`; the header funnels speak TanStack's `ColumnFiltersState`. */
|
|
78
|
+
function toColumnFilters(filters: TableFilters): ColumnFiltersState {
|
|
79
|
+
return Object.entries(filters)
|
|
80
|
+
.filter(([, ids]) => ids.length > 0)
|
|
81
|
+
.map(([id, ids]) => ({ id, value: ids }));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function toTableFilters(columnFilters: ColumnFiltersState): TableFilters {
|
|
85
|
+
return Object.fromEntries(columnFilters.map(filter => [filter.id, filter.value as string[]]));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The page body the stories below show: a `DataTable` over the sample devices.
|
|
90
|
+
* `filters` / `onFiltersChange` mirror the layout's mobile filter into the
|
|
91
|
+
* header funnels (`WithMobileFilter`), so the two controls edit ONE state; the
|
|
92
|
+
* data itself is filtered by the story, the table only stores the selection.
|
|
93
|
+
*/
|
|
94
|
+
function DevicesTable({
|
|
95
|
+
data,
|
|
96
|
+
emptyMessage,
|
|
97
|
+
filters = NO_FILTERS,
|
|
98
|
+
onFiltersChange,
|
|
99
|
+
}: {
|
|
100
|
+
data: Device[];
|
|
101
|
+
emptyMessage?: string;
|
|
102
|
+
filters?: TableFilters;
|
|
103
|
+
onFiltersChange?: (filters: TableFilters) => void;
|
|
104
|
+
}) {
|
|
105
|
+
const columnFilters = useMemo(() => toColumnFilters(filters), [filters]);
|
|
106
|
+
const handleColumnFiltersChange = useCallback<OnChangeFn<ColumnFiltersState>>(
|
|
107
|
+
updater => {
|
|
108
|
+
const next = typeof updater === 'function' ? updater(columnFilters) : updater;
|
|
109
|
+
onFiltersChange?.(toTableFilters(next));
|
|
110
|
+
},
|
|
111
|
+
[columnFilters, onFiltersChange],
|
|
112
|
+
);
|
|
113
|
+
const table = useDataTable<Device>({
|
|
114
|
+
data,
|
|
115
|
+
columns: deviceColumns,
|
|
116
|
+
getRowId: rowId,
|
|
117
|
+
state: { columnFilters },
|
|
118
|
+
onColumnFiltersChange: handleColumnFiltersChange,
|
|
119
|
+
});
|
|
120
|
+
return (
|
|
121
|
+
<DataTable table={table}>
|
|
122
|
+
<DataTable.Header />
|
|
123
|
+
<DataTable.Body emptyState={emptyMessage ? { title: emptyMessage, description: undefined } : undefined} />
|
|
124
|
+
</DataTable>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Ad-hoc rows for the page examples below: any object with an `id`. */
|
|
129
|
+
function SampleTable<T extends { id: string }>({ data, columns }: { data: T[]; columns: ColumnDef<T>[] }) {
|
|
130
|
+
const table = useDataTable<T>({ data, columns, getRowId: rowId });
|
|
131
|
+
return (
|
|
132
|
+
<DataTable table={table}>
|
|
133
|
+
<DataTable.Header />
|
|
134
|
+
<DataTable.Body />
|
|
135
|
+
</DataTable>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface Script {
|
|
140
|
+
id: string;
|
|
141
|
+
name: string;
|
|
142
|
+
language: string;
|
|
143
|
+
lastRun: string;
|
|
144
|
+
status: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const sampleScripts: Script[] = [
|
|
148
|
+
{ id: '1', name: 'Deploy Script', language: 'Bash', lastRun: '2024-01-20', status: 'success' },
|
|
149
|
+
{ id: '2', name: 'Backup Database', language: 'Python', lastRun: '2024-01-19', status: 'success' },
|
|
150
|
+
{ id: '3', name: 'Clear Cache', language: 'PowerShell', lastRun: '2024-01-18', status: 'failed' },
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
const scriptColumns: ColumnDef<Script>[] = [
|
|
154
|
+
{ accessorKey: 'name', header: 'Script Name', meta: { width: 'flex-1 min-w-0' } },
|
|
155
|
+
{ accessorKey: 'language', header: 'Language', meta: { width: 'w-[160px]' } },
|
|
156
|
+
{ accessorKey: 'lastRun', header: 'Last Run', meta: { width: 'w-[160px]' } },
|
|
157
|
+
{ accessorKey: 'status', header: 'Status', meta: { width: 'w-[140px]' } },
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
interface LogEntry {
|
|
161
|
+
id: string;
|
|
162
|
+
timestamp: string;
|
|
163
|
+
level: string;
|
|
164
|
+
message: string;
|
|
165
|
+
source: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const sampleLogs: LogEntry[] = [
|
|
169
|
+
{
|
|
170
|
+
id: '1',
|
|
171
|
+
timestamp: '2024-01-20 14:32:01',
|
|
172
|
+
level: 'INFO',
|
|
173
|
+
message: 'User login successful',
|
|
174
|
+
source: 'auth-service',
|
|
39
175
|
},
|
|
40
176
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
177
|
+
id: '2',
|
|
178
|
+
timestamp: '2024-01-20 14:31:45',
|
|
179
|
+
level: 'WARNING',
|
|
180
|
+
message: 'Rate limit approaching',
|
|
181
|
+
source: 'api-gateway',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: '3',
|
|
185
|
+
timestamp: '2024-01-20 14:30:22',
|
|
186
|
+
level: 'ERROR',
|
|
187
|
+
message: 'Database connection timeout',
|
|
188
|
+
source: 'db-service',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: '4',
|
|
192
|
+
timestamp: '2024-01-20 14:29:10',
|
|
193
|
+
level: 'INFO',
|
|
194
|
+
message: 'Cache cleared successfully',
|
|
195
|
+
source: 'cache-service',
|
|
49
196
|
},
|
|
50
|
-
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
const logColumns: ColumnDef<LogEntry>[] = [
|
|
200
|
+
{ accessorKey: 'timestamp', header: 'Timestamp', meta: { width: 'w-[200px]' } },
|
|
201
|
+
{ accessorKey: 'level', header: 'Level', meta: { width: 'w-[120px]' } },
|
|
202
|
+
{ accessorKey: 'message', header: 'Message', meta: { width: 'flex-1 min-w-0' } },
|
|
203
|
+
{ accessorKey: 'source', header: 'Source', meta: { width: 'w-[160px]' } },
|
|
51
204
|
];
|
|
52
205
|
|
|
53
206
|
const meta = {
|
|
@@ -110,7 +263,7 @@ export const Basic: Story = {
|
|
|
110
263
|
searchPlaceholder: 'Search devices...',
|
|
111
264
|
searchValue: '',
|
|
112
265
|
onSearch: () => {},
|
|
113
|
-
children: <
|
|
266
|
+
children: <DevicesTable data={sampleDevices} />,
|
|
114
267
|
},
|
|
115
268
|
};
|
|
116
269
|
|
|
@@ -133,7 +286,7 @@ export const WithHeaderActions: Story = {
|
|
|
133
286
|
searchPlaceholder: 'Search devices...',
|
|
134
287
|
searchValue: '',
|
|
135
288
|
onSearch: () => {},
|
|
136
|
-
children: <
|
|
289
|
+
children: <DevicesTable data={sampleDevices} />,
|
|
137
290
|
},
|
|
138
291
|
};
|
|
139
292
|
|
|
@@ -159,7 +312,7 @@ export const WithViewToggle: Story = {
|
|
|
159
312
|
searchPlaceholder: 'Search devices...',
|
|
160
313
|
searchValue: '',
|
|
161
314
|
onSearch: () => {},
|
|
162
|
-
children: <
|
|
315
|
+
children: <DevicesTable data={sampleDevices} />,
|
|
163
316
|
},
|
|
164
317
|
};
|
|
165
318
|
|
|
@@ -191,9 +344,7 @@ export const WithSearchValue: Story = {
|
|
|
191
344
|
searchPlaceholder: 'Search devices...',
|
|
192
345
|
searchValue: 'MacBook',
|
|
193
346
|
onSearch: () => {},
|
|
194
|
-
children: (
|
|
195
|
-
<Table data={sampleDevices.filter(d => d.name.includes('MacBook'))} columns={deviceColumns} rowKey="id" />
|
|
196
|
-
),
|
|
347
|
+
children: <DevicesTable data={sampleDevices.filter(d => d.name.includes('MacBook'))} />,
|
|
197
348
|
},
|
|
198
349
|
};
|
|
199
350
|
|
|
@@ -211,14 +362,7 @@ export const EmptyState: Story = {
|
|
|
211
362
|
searchPlaceholder: 'Search devices...',
|
|
212
363
|
searchValue: '',
|
|
213
364
|
onSearch: () => {},
|
|
214
|
-
children:
|
|
215
|
-
<Table
|
|
216
|
-
data={[]}
|
|
217
|
-
columns={deviceColumns}
|
|
218
|
-
rowKey="id"
|
|
219
|
-
emptyMessage="No devices found. Add your first device to get started."
|
|
220
|
-
/>
|
|
221
|
-
),
|
|
365
|
+
children: <DevicesTable data={[]} emptyMessage="No devices found. Add your first device to get started." />,
|
|
222
366
|
},
|
|
223
367
|
};
|
|
224
368
|
|
|
@@ -232,7 +376,7 @@ export const SmallPadding: Story = {
|
|
|
232
376
|
searchValue: '',
|
|
233
377
|
onSearch: () => {},
|
|
234
378
|
padding: 'sm',
|
|
235
|
-
children: <
|
|
379
|
+
children: <DevicesTable data={sampleDevices} />,
|
|
236
380
|
},
|
|
237
381
|
};
|
|
238
382
|
|
|
@@ -246,7 +390,7 @@ export const LargePadding: Story = {
|
|
|
246
390
|
searchValue: '',
|
|
247
391
|
onSearch: () => {},
|
|
248
392
|
padding: 'lg',
|
|
249
|
-
children: <
|
|
393
|
+
children: <DevicesTable data={sampleDevices} />,
|
|
250
394
|
},
|
|
251
395
|
};
|
|
252
396
|
|
|
@@ -260,7 +404,7 @@ export const CardBackground: Story = {
|
|
|
260
404
|
searchValue: '',
|
|
261
405
|
onSearch: () => {},
|
|
262
406
|
background: 'card',
|
|
263
|
-
children: <
|
|
407
|
+
children: <DevicesTable data={sampleDevices} />,
|
|
264
408
|
},
|
|
265
409
|
};
|
|
266
410
|
|
|
@@ -301,12 +445,7 @@ export const Interactive: Story = {
|
|
|
301
445
|
searchValue={searchValue}
|
|
302
446
|
onSearch={setSearchValue}
|
|
303
447
|
>
|
|
304
|
-
<
|
|
305
|
-
data={filteredDevices}
|
|
306
|
-
columns={deviceColumns}
|
|
307
|
-
rowKey="id"
|
|
308
|
-
emptyMessage="No devices match your search criteria."
|
|
309
|
-
/>
|
|
448
|
+
<DevicesTable data={filteredDevices} emptyMessage="No devices match your search criteria." />
|
|
310
449
|
</ListPageLayout>
|
|
311
450
|
);
|
|
312
451
|
},
|
|
@@ -331,24 +470,7 @@ export const ScriptsPageExample: Story = {
|
|
|
331
470
|
searchPlaceholder: 'Search scripts...',
|
|
332
471
|
searchValue: '',
|
|
333
472
|
onSearch: () => {},
|
|
334
|
-
children:
|
|
335
|
-
<Table
|
|
336
|
-
data={[
|
|
337
|
-
{ id: '1', name: 'Deploy Script', language: 'Bash', lastRun: '2024-01-20', status: 'success' },
|
|
338
|
-
{ id: '2', name: 'Backup Database', language: 'Python', lastRun: '2024-01-19', status: 'success' },
|
|
339
|
-
{ id: '3', name: 'Clear Cache', language: 'PowerShell', lastRun: '2024-01-18', status: 'failed' },
|
|
340
|
-
]}
|
|
341
|
-
columns={
|
|
342
|
-
[
|
|
343
|
-
{ key: 'name', label: 'Script Name' },
|
|
344
|
-
{ key: 'language', label: 'Language' },
|
|
345
|
-
{ key: 'lastRun', label: 'Last Run' },
|
|
346
|
-
{ key: 'status', label: 'Status' },
|
|
347
|
-
] as TableColumn<{ id: string; name: string; language: string; lastRun: string; status: string }>[]
|
|
348
|
-
}
|
|
349
|
-
rowKey="id"
|
|
350
|
-
/>
|
|
351
|
-
),
|
|
473
|
+
children: <SampleTable data={sampleScripts} columns={scriptColumns} />,
|
|
352
474
|
},
|
|
353
475
|
};
|
|
354
476
|
|
|
@@ -366,49 +488,7 @@ export const LogsPageExample: Story = {
|
|
|
366
488
|
searchPlaceholder: 'Search logs...',
|
|
367
489
|
searchValue: '',
|
|
368
490
|
onSearch: () => {},
|
|
369
|
-
children:
|
|
370
|
-
<Table
|
|
371
|
-
data={[
|
|
372
|
-
{
|
|
373
|
-
id: '1',
|
|
374
|
-
timestamp: '2024-01-20 14:32:01',
|
|
375
|
-
level: 'INFO',
|
|
376
|
-
message: 'User login successful',
|
|
377
|
-
source: 'auth-service',
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
id: '2',
|
|
381
|
-
timestamp: '2024-01-20 14:31:45',
|
|
382
|
-
level: 'WARNING',
|
|
383
|
-
message: 'Rate limit approaching',
|
|
384
|
-
source: 'api-gateway',
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
id: '3',
|
|
388
|
-
timestamp: '2024-01-20 14:30:22',
|
|
389
|
-
level: 'ERROR',
|
|
390
|
-
message: 'Database connection timeout',
|
|
391
|
-
source: 'db-service',
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
id: '4',
|
|
395
|
-
timestamp: '2024-01-20 14:29:10',
|
|
396
|
-
level: 'INFO',
|
|
397
|
-
message: 'Cache cleared successfully',
|
|
398
|
-
source: 'cache-service',
|
|
399
|
-
},
|
|
400
|
-
]}
|
|
401
|
-
columns={
|
|
402
|
-
[
|
|
403
|
-
{ key: 'timestamp', label: 'Timestamp' },
|
|
404
|
-
{ key: 'level', label: 'Level' },
|
|
405
|
-
{ key: 'message', label: 'Message' },
|
|
406
|
-
{ key: 'source', label: 'Source' },
|
|
407
|
-
] as TableColumn<{ id: string; timestamp: string; level: string; message: string; source: string }>[]
|
|
408
|
-
}
|
|
409
|
-
rowKey="id"
|
|
410
|
-
/>
|
|
411
|
-
),
|
|
491
|
+
children: <SampleTable data={sampleLogs} columns={logColumns} />,
|
|
412
492
|
},
|
|
413
493
|
};
|
|
414
494
|
|
|
@@ -525,11 +605,10 @@ export const WithMobileFilter: Story = {
|
|
|
525
605
|
onMobileSort={handleSort}
|
|
526
606
|
mobileFilterTitle="Sort and Filter"
|
|
527
607
|
>
|
|
528
|
-
<
|
|
608
|
+
<DevicesTable
|
|
529
609
|
data={sortedDevices}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
rowKey="id"
|
|
610
|
+
filters={filters}
|
|
611
|
+
onFiltersChange={setFilters}
|
|
533
612
|
emptyMessage="No devices match your criteria."
|
|
534
613
|
/>
|
|
535
614
|
</ListPageLayout>
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
TableCellIcon,
|
|
10
10
|
} from '../components/icons-v2-generated';
|
|
11
11
|
import { PageLayout } from '../components/layout/page-layout';
|
|
12
|
+
import { DataTable, useDataTable, type ColumnDef } from '../components/ui/data-table';
|
|
12
13
|
import { TabSelector } from '../components/ui/tab-selector';
|
|
13
|
-
import { Table, type TableColumn } from '../components/ui/table';
|
|
14
14
|
|
|
15
15
|
interface Device {
|
|
16
16
|
id: string;
|
|
@@ -26,13 +26,27 @@ const sampleDevices: Device[] = [
|
|
|
26
26
|
{ id: '3', name: 'Reception PC', status: 'Inactive', os: 'Windows', lastOnline: '24/03/2026 09:11:02' },
|
|
27
27
|
];
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
{
|
|
33
|
-
{
|
|
29
|
+
// Module-level so `useDataTable` sees stable `data` / `columns` references.
|
|
30
|
+
const deviceColumns: ColumnDef<Device>[] = [
|
|
31
|
+
{ accessorKey: 'name', header: 'Device', meta: { width: 'flex-1 min-w-0' } },
|
|
32
|
+
{ accessorKey: 'status', header: 'Status', meta: { width: 'w-[140px]' } },
|
|
33
|
+
{ accessorKey: 'os', header: 'OS', meta: { width: 'w-[140px]' } },
|
|
34
|
+
{ accessorKey: 'lastOnline', header: 'Last Online', meta: { width: 'w-[200px]' } },
|
|
34
35
|
];
|
|
35
36
|
|
|
37
|
+
const getDeviceId = (device: Device) => device.id;
|
|
38
|
+
|
|
39
|
+
/** Page body stand-in: a small `DataTable` over the sample devices. */
|
|
40
|
+
function DevicesTable() {
|
|
41
|
+
const table = useDataTable<Device>({ data: sampleDevices, columns: deviceColumns, getRowId: getDeviceId });
|
|
42
|
+
return (
|
|
43
|
+
<DataTable table={table}>
|
|
44
|
+
<DataTable.Header />
|
|
45
|
+
<DataTable.Body />
|
|
46
|
+
</DataTable>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
const ORG_LOGO_DATA_URI =
|
|
37
51
|
'data:image/svg+xml;utf8,' +
|
|
38
52
|
encodeURIComponent(
|
|
@@ -63,7 +77,7 @@ The \`subtitle\` and \`image\` props are optional — when set, the title block
|
|
|
63
77
|
export default meta;
|
|
64
78
|
type Story = StoryObj<typeof meta>;
|
|
65
79
|
|
|
66
|
-
const sampleContent = <
|
|
80
|
+
const sampleContent = <DevicesTable />;
|
|
67
81
|
|
|
68
82
|
/**
|
|
69
83
|
* Title only — baseline header.
|