@umituz/web-dashboard 10.4.0 → 11.1.0
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/package.json +5 -3
- package/src/domains/layouts/components/index.ts +0 -20
- package/src/domains/pages/components/ListPage.test.tsx +129 -0
- package/src/domains/pages/components/ListPage.tsx +194 -0
- package/src/domains/pages/components/index.ts +1 -0
- package/src/domains/pages/index.ts +12 -0
- package/src/domains/pages/types.ts +74 -0
- package/src/index.ts +1 -0
- package/src/styles/chrome.css +0 -343
- package/src/domains/layouts/components/FilterBar.test.tsx +0 -33
- package/src/domains/layouts/components/FilterBar.tsx +0 -38
- package/src/domains/layouts/components/FilterPanel.test.tsx +0 -76
- package/src/domains/layouts/components/FilterPanel.tsx +0 -129
- package/src/domains/layouts/components/FilterSelect.test.tsx +0 -28
- package/src/domains/layouts/components/FilterSelect.tsx +0 -47
- package/src/domains/layouts/components/NextSteps.test.tsx +0 -25
- package/src/domains/layouts/components/NextSteps.tsx +0 -36
- package/src/domains/layouts/components/PageHeader.test.tsx +0 -63
- package/src/domains/layouts/components/PageHeader.tsx +0 -67
- package/src/domains/layouts/components/SectionHeader.test.tsx +0 -29
- package/src/domains/layouts/components/SectionHeader.tsx +0 -36
- package/src/domains/layouts/components/TabNav.test.tsx +0 -33
- package/src/domains/layouts/components/TabNav.tsx +0 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-dashboard",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"./organization": "./src/domains/organization/index.ts",
|
|
39
39
|
"./organization/components": "./src/domains/organization/components/index.ts",
|
|
40
40
|
"./package.json": "./package.json",
|
|
41
|
+
"./pages": "./src/domains/pages/index.ts",
|
|
42
|
+
"./pages/components": "./src/domains/pages/components/index.ts",
|
|
41
43
|
"./permissions": "./src/domains/permissions/index.ts",
|
|
42
44
|
"./settings": "./src/domains/settings/index.ts",
|
|
43
45
|
"./settings/components": "./src/domains/settings/components/index.ts",
|
|
@@ -66,7 +68,7 @@
|
|
|
66
68
|
"version:major": "npm version major -m 'chore: release v%s'"
|
|
67
69
|
},
|
|
68
70
|
"peerDependencies": {
|
|
69
|
-
"@umituz/web-design-system": "^6.
|
|
71
|
+
"@umituz/web-design-system": "^6.2.0",
|
|
70
72
|
"framer-motion": "^12.0.0",
|
|
71
73
|
"react": "^18.0.0 || ^19.0.0",
|
|
72
74
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
@@ -89,7 +91,7 @@
|
|
|
89
91
|
"@types/react-dom": "^19.2.3",
|
|
90
92
|
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
91
93
|
"@typescript-eslint/parser": "^8.57.2",
|
|
92
|
-
"@umituz/web-design-system": "^6.
|
|
94
|
+
"@umituz/web-design-system": "^6.2.0",
|
|
93
95
|
"eslint": "^10.0.2",
|
|
94
96
|
"framer-motion": "^12.23.12",
|
|
95
97
|
"jsdom": "^29.1.1",
|
|
@@ -3,23 +3,3 @@ export { defaultLayoutLabels } from './labels';
|
|
|
3
3
|
export { DashboardHeader } from './DashboardHeader';
|
|
4
4
|
export { DashboardSidebar } from './DashboardSidebar';
|
|
5
5
|
export { BrandLogo } from './BrandLogo';
|
|
6
|
-
export { FilterBar } from './FilterBar';
|
|
7
|
-
export type { FilterBarProps, FilterBarSearch } from './FilterBar';
|
|
8
|
-
export { FilterSelect } from './FilterSelect';
|
|
9
|
-
export type { FilterSelectProps, FilterSelectOption } from './FilterSelect';
|
|
10
|
-
export { PageHeader } from './PageHeader';
|
|
11
|
-
export type { PageHeaderProps, PageHeaderCrumb } from './PageHeader';
|
|
12
|
-
export { SectionHeader } from './SectionHeader';
|
|
13
|
-
export type { SectionHeaderProps } from './SectionHeader';
|
|
14
|
-
export { TabNav } from './TabNav';
|
|
15
|
-
export type { TabNavItem, TabNavProps } from './TabNav';
|
|
16
|
-
export { FilterPanel, FilterSection, CheckFilterList, SingleSelectFilterList } from './FilterPanel';
|
|
17
|
-
export type {
|
|
18
|
-
FilterPanelProps,
|
|
19
|
-
FilterSectionProps,
|
|
20
|
-
FilterListOption,
|
|
21
|
-
CheckFilterListProps,
|
|
22
|
-
SingleSelectFilterListProps,
|
|
23
|
-
} from './FilterPanel';
|
|
24
|
-
export { NextSteps } from './NextSteps';
|
|
25
|
-
export type { NextStepsProps, NextStepLink } from './NextSteps';
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router';
|
|
4
|
+
import { ListPage } from './ListPage';
|
|
5
|
+
|
|
6
|
+
interface Device {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
status: 'online' | 'offline';
|
|
10
|
+
site: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const DEVICES: readonly Device[] = [
|
|
14
|
+
{ id: 'dev-1', name: 'North Gate Reader', status: 'online', site: 'HQ' },
|
|
15
|
+
{ id: 'dev-2', name: 'Server Door Sensor', status: 'offline', site: 'DC' },
|
|
16
|
+
{ id: 'dev-3', name: 'Lobby Camera', status: 'online', site: 'HQ' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const COLUMNS = [
|
|
20
|
+
{ key: 'name', header: 'Device' },
|
|
21
|
+
{ key: 'status', header: 'Status' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
function mount(props: Partial<Parameters<typeof ListPage<Device>>[0]> = {}) {
|
|
25
|
+
return render(
|
|
26
|
+
<MemoryRouter>
|
|
27
|
+
<ListPage<Device>
|
|
28
|
+
title="Devices"
|
|
29
|
+
description="Field hardware"
|
|
30
|
+
data={DEVICES}
|
|
31
|
+
getRowId={(row) => row.id}
|
|
32
|
+
columns={COLUMNS}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
</MemoryRouter>,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('ListPage', () => {
|
|
40
|
+
it('renders header and every row', () => {
|
|
41
|
+
mount();
|
|
42
|
+
expect(screen.getByText('Devices')).toBeDefined();
|
|
43
|
+
expect(screen.getByText('North Gate Reader')).toBeDefined();
|
|
44
|
+
expect(screen.getByText('Server Door Sensor')).toBeDefined();
|
|
45
|
+
expect(screen.getByText('Lobby Camera')).toBeDefined();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('filters rows by search terms', () => {
|
|
49
|
+
mount({
|
|
50
|
+
search: { terms: (row) => [row.name, row.site] },
|
|
51
|
+
});
|
|
52
|
+
const input = screen.getByPlaceholderText('Search…');
|
|
53
|
+
fireEvent.change(input, { target: { value: 'camera' } });
|
|
54
|
+
expect(screen.getByText('Lobby Camera')).toBeDefined();
|
|
55
|
+
expect(screen.queryByText('North Gate Reader')).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('filters rows by select default matcher and custom matcher', () => {
|
|
59
|
+
mount({
|
|
60
|
+
filters: [{ id: 'status', label: 'Status', options: [{ value: 'online', label: 'Online' }] }],
|
|
61
|
+
});
|
|
62
|
+
fireEvent.change(screen.getByLabelText('Status'), { target: { value: 'online' } });
|
|
63
|
+
expect(screen.queryByText('Server Door Sensor')).toBeNull();
|
|
64
|
+
expect(screen.getByText('Lobby Camera')).toBeDefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('shows the count of shown vs total', () => {
|
|
68
|
+
mount({
|
|
69
|
+
search: { terms: (row) => row.name },
|
|
70
|
+
});
|
|
71
|
+
fireEvent.change(screen.getByPlaceholderText('Search…'), { target: { value: 'gate' } });
|
|
72
|
+
expect(screen.getByTestId('list-page-count').textContent).toBe('1 of 3');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('renders first column as a link via rowLink', () => {
|
|
76
|
+
mount({ rowLink: (row) => `/devices/${row.id}` });
|
|
77
|
+
const link = screen.getByText('Lobby Camera').closest('a');
|
|
78
|
+
expect(link?.getAttribute('href')).toBe('/devices/dev-3');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('renders custom cells and per-row actions', () => {
|
|
82
|
+
mount({
|
|
83
|
+
columns: [
|
|
84
|
+
{ key: 'name', header: 'Device', render: (row) => `${row.name}!` },
|
|
85
|
+
{ key: 'status', header: 'Status', render: (row) => <em>{row.status}</em> },
|
|
86
|
+
],
|
|
87
|
+
rowActions: (row) => <button type="button">open-{row.id}</button>,
|
|
88
|
+
});
|
|
89
|
+
expect(screen.getByText('Lobby Camera!')).toBeDefined();
|
|
90
|
+
expect(screen.getAllByText('online', { selector: 'em' }).length).toBe(2);
|
|
91
|
+
expect(screen.getByText('open-dev-3')).toBeDefined();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('shows the empty state when no row matches', () => {
|
|
95
|
+
mount({
|
|
96
|
+
search: { terms: (row) => row.name },
|
|
97
|
+
empty: { title: 'No devices', description: 'Try another search' },
|
|
98
|
+
});
|
|
99
|
+
fireEvent.change(screen.getByPlaceholderText('Search…'), { target: { value: 'zzz' } });
|
|
100
|
+
expect(screen.getByText('No devices')).toBeDefined();
|
|
101
|
+
expect(screen.getByText('Try another search')).toBeDefined();
|
|
102
|
+
expect(screen.queryByText('Lobby Camera')).toBeNull();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('renders skeleton rows while loading an empty dataset', () => {
|
|
106
|
+
const { container } = mount({ data: [], loading: true, empty: { title: 'No devices' } });
|
|
107
|
+
expect(screen.queryByText('No devices')).toBeNull();
|
|
108
|
+
expect(container.querySelectorAll('.animate-pulse').length).toBeGreaterThan(0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('honours label overrides', () => {
|
|
112
|
+
mount({
|
|
113
|
+
search: { terms: (row) => row.name },
|
|
114
|
+
labels: { searchPlaceholder: 'Cihaz ara', countShown: () => 'üç' },
|
|
115
|
+
});
|
|
116
|
+
expect(screen.getByPlaceholderText('Cihaz ara')).toBeDefined();
|
|
117
|
+
expect(screen.getByTestId('list-page-count').textContent).toBe('üç');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('fires the empty action onClick', () => {
|
|
121
|
+
const onClick = vi.fn();
|
|
122
|
+
mount({
|
|
123
|
+
data: [],
|
|
124
|
+
empty: { title: 'No devices', action: { label: 'Add device', onClick } },
|
|
125
|
+
});
|
|
126
|
+
fireEvent.click(screen.getByText('Add device'));
|
|
127
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { useMemo, useState, type ReactNode } from 'react';
|
|
2
|
+
import { Link } from 'react-router';
|
|
3
|
+
import { PageHeader } from '@umituz/web-design-system/templates';
|
|
4
|
+
import {
|
|
5
|
+
EmptyState,
|
|
6
|
+
FilterBar,
|
|
7
|
+
Table,
|
|
8
|
+
TableBody,
|
|
9
|
+
TableCell,
|
|
10
|
+
TableHead,
|
|
11
|
+
TableHeader,
|
|
12
|
+
TableRow,
|
|
13
|
+
} from '@umituz/web-design-system/organisms';
|
|
14
|
+
import { FilterSelect } from '@umituz/web-design-system/molecules';
|
|
15
|
+
import { Skeleton } from '@umituz/web-design-system/atoms';
|
|
16
|
+
import {
|
|
17
|
+
defaultListPageLabels,
|
|
18
|
+
type ListPageColumn,
|
|
19
|
+
type ListPageFilter,
|
|
20
|
+
type ListPageLabels,
|
|
21
|
+
type ListPageProps,
|
|
22
|
+
} from '../types';
|
|
23
|
+
|
|
24
|
+
const matchesFilterDefault = <T,>(row: T, filterId: string, value: string): boolean =>
|
|
25
|
+
String((row as Record<string, unknown>)[filterId] ?? '') === value;
|
|
26
|
+
|
|
27
|
+
const toSearchTerms = (value: string | readonly string[]): readonly string[] =>
|
|
28
|
+
typeof value === 'string' ? [value] : value;
|
|
29
|
+
|
|
30
|
+
export function ListPage<T>({
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
kicker,
|
|
34
|
+
meta,
|
|
35
|
+
actions,
|
|
36
|
+
data,
|
|
37
|
+
getRowId,
|
|
38
|
+
columns,
|
|
39
|
+
search,
|
|
40
|
+
filters,
|
|
41
|
+
matchFilter,
|
|
42
|
+
rowLink,
|
|
43
|
+
rowActions,
|
|
44
|
+
loading = false,
|
|
45
|
+
empty,
|
|
46
|
+
toolbar,
|
|
47
|
+
footer,
|
|
48
|
+
labels,
|
|
49
|
+
}: ListPageProps<T>) {
|
|
50
|
+
const merged: ListPageLabels = { ...defaultListPageLabels, ...labels };
|
|
51
|
+
const [query, setQuery] = useState('');
|
|
52
|
+
const [values, setValues] = useState<Record<string, string>>({});
|
|
53
|
+
|
|
54
|
+
const activeFilters = useMemo(
|
|
55
|
+
() => Object.entries(values).filter(([, value]) => value !== ''),
|
|
56
|
+
[values],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const rows = useMemo(() => {
|
|
60
|
+
let list = data as readonly T[];
|
|
61
|
+
for (const [id, value] of activeFilters) {
|
|
62
|
+
const match = matchFilter ?? matchesFilterDefault;
|
|
63
|
+
list = list.filter((row) => match(row, id, value));
|
|
64
|
+
}
|
|
65
|
+
const q = query.trim().toLowerCase();
|
|
66
|
+
if (q !== '' && search) {
|
|
67
|
+
list = list.filter((row) =>
|
|
68
|
+
toSearchTerms(search.terms(row)).some((term) =>
|
|
69
|
+
term.toLowerCase().includes(q),
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return list;
|
|
74
|
+
}, [data, activeFilters, query, search, matchFilter]);
|
|
75
|
+
|
|
76
|
+
const hasToolbar = Boolean(search || (filters && filters.length > 0) || toolbar);
|
|
77
|
+
const showEmpty = !loading && rows.length === 0;
|
|
78
|
+
|
|
79
|
+
const renderCell = (column: ListPageColumn<T>, row: T, isFirst: boolean): ReactNode => {
|
|
80
|
+
const content = column.render ? column.render(row) : String((row as Record<string, unknown>)[column.key] ?? '');
|
|
81
|
+
const href = isFirst && rowLink ? rowLink(row) : undefined;
|
|
82
|
+
if (href === undefined) return content;
|
|
83
|
+
return <Link to={href}>{content}</Link>;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className="flex w-full flex-col gap-6">
|
|
88
|
+
<PageHeader
|
|
89
|
+
kicker={kicker}
|
|
90
|
+
title={title}
|
|
91
|
+
description={description}
|
|
92
|
+
meta={meta}
|
|
93
|
+
actions={actions}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
{hasToolbar && (
|
|
97
|
+
<FilterBar
|
|
98
|
+
search={
|
|
99
|
+
search
|
|
100
|
+
? {
|
|
101
|
+
value: query,
|
|
102
|
+
onChange: setQuery,
|
|
103
|
+
placeholder: search.placeholder ?? merged.searchPlaceholder,
|
|
104
|
+
}
|
|
105
|
+
: undefined
|
|
106
|
+
}
|
|
107
|
+
actions={
|
|
108
|
+
<>
|
|
109
|
+
{toolbar}
|
|
110
|
+
<span className="text-sm text-muted-foreground" data-testid="list-page-count">
|
|
111
|
+
{merged.countShown(rows.length, data.length)}
|
|
112
|
+
</span>
|
|
113
|
+
</>
|
|
114
|
+
}
|
|
115
|
+
>
|
|
116
|
+
{(filters ?? []).map((filter: ListPageFilter) => (
|
|
117
|
+
<FilterSelect
|
|
118
|
+
key={filter.id}
|
|
119
|
+
value={values[filter.id] ?? ''}
|
|
120
|
+
onChange={(value) =>
|
|
121
|
+
setValues((prev) => ({ ...prev, [filter.id]: value }))
|
|
122
|
+
}
|
|
123
|
+
options={filter.options}
|
|
124
|
+
ariaLabel={filter.label}
|
|
125
|
+
allLabel={merged.filterAll}
|
|
126
|
+
/>
|
|
127
|
+
))}
|
|
128
|
+
</FilterBar>
|
|
129
|
+
)}
|
|
130
|
+
|
|
131
|
+
<Table>
|
|
132
|
+
<TableHeader>
|
|
133
|
+
<TableRow>
|
|
134
|
+
{columns.map((column) => (
|
|
135
|
+
<TableHead key={column.key} className={column.headerClassName}>
|
|
136
|
+
{column.header}
|
|
137
|
+
</TableHead>
|
|
138
|
+
))}
|
|
139
|
+
{rowActions && <TableHead className="w-0" />}
|
|
140
|
+
</TableRow>
|
|
141
|
+
</TableHeader>
|
|
142
|
+
<TableBody>
|
|
143
|
+
{loading && data.length === 0
|
|
144
|
+
? Array.from({ length: 5 }, (_, rowIndex) => (
|
|
145
|
+
<TableRow key={`skeleton-${rowIndex}`}>
|
|
146
|
+
{columns.map((column) => (
|
|
147
|
+
<TableCell key={column.key}>
|
|
148
|
+
<Skeleton variant="text" />
|
|
149
|
+
</TableCell>
|
|
150
|
+
))}
|
|
151
|
+
{rowActions && <TableCell />}
|
|
152
|
+
</TableRow>
|
|
153
|
+
))
|
|
154
|
+
: showEmpty
|
|
155
|
+
? (
|
|
156
|
+
<TableRow>
|
|
157
|
+
<TableCell colSpan={columns.length + (rowActions ? 1 : 0)}>
|
|
158
|
+
<EmptyState
|
|
159
|
+
title={empty?.title ?? merged.emptyTitle}
|
|
160
|
+
description={empty?.description}
|
|
161
|
+
icon={empty?.icon}
|
|
162
|
+
action={
|
|
163
|
+
empty?.action ? (
|
|
164
|
+
empty.action.to ? (
|
|
165
|
+
<Link to={empty.action.to}>{empty.action.label}</Link>
|
|
166
|
+
) : empty.action.onClick ? (
|
|
167
|
+
{
|
|
168
|
+
label: empty.action.label,
|
|
169
|
+
onClick: empty.action.onClick,
|
|
170
|
+
}
|
|
171
|
+
) : undefined
|
|
172
|
+
) : undefined
|
|
173
|
+
}
|
|
174
|
+
/>
|
|
175
|
+
</TableCell>
|
|
176
|
+
</TableRow>
|
|
177
|
+
)
|
|
178
|
+
: rows.map((row) => (
|
|
179
|
+
<TableRow key={getRowId(row)}>
|
|
180
|
+
{columns.map((column, columnIndex) => (
|
|
181
|
+
<TableCell key={column.key} className={column.className}>
|
|
182
|
+
{renderCell(column, row, columnIndex === 0)}
|
|
183
|
+
</TableCell>
|
|
184
|
+
))}
|
|
185
|
+
{rowActions && <TableCell>{rowActions(row)}</TableCell>}
|
|
186
|
+
</TableRow>
|
|
187
|
+
))}
|
|
188
|
+
</TableBody>
|
|
189
|
+
</Table>
|
|
190
|
+
|
|
191
|
+
{footer}
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListPage } from './ListPage';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ListPage } from './components';
|
|
2
|
+
export {
|
|
3
|
+
defaultListPageLabels,
|
|
4
|
+
type ListPageColumn,
|
|
5
|
+
type ListPageEmpty,
|
|
6
|
+
type ListPageEmptyAction,
|
|
7
|
+
type ListPageFilter,
|
|
8
|
+
type ListPageFilterOption,
|
|
9
|
+
type ListPageLabels,
|
|
10
|
+
type ListPageProps,
|
|
11
|
+
type ListPageSearchConfig,
|
|
12
|
+
} from './types';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { EmptyStateProps } from '@umituz/web-design-system/organisms';
|
|
3
|
+
|
|
4
|
+
export interface ListPageFilterOption {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ListPageFilter {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
options: readonly ListPageFilterOption[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ListPageColumn<T> {
|
|
16
|
+
key: string;
|
|
17
|
+
header: ReactNode;
|
|
18
|
+
render?: (row: T) => ReactNode;
|
|
19
|
+
headerClassName?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ListPageSearchConfig<T> {
|
|
24
|
+
terms: (row: T) => string | readonly string[];
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ListPageEmptyAction {
|
|
29
|
+
label: string;
|
|
30
|
+
to?: string;
|
|
31
|
+
onClick?: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ListPageEmpty {
|
|
35
|
+
title: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
icon?: EmptyStateProps['icon'];
|
|
38
|
+
action?: ListPageEmptyAction;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ListPageLabels {
|
|
42
|
+
searchPlaceholder: string;
|
|
43
|
+
filterAll: string;
|
|
44
|
+
emptyTitle: string;
|
|
45
|
+
countShown: (shown: number, total: number) => string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ListPageProps<T> {
|
|
49
|
+
title: ReactNode;
|
|
50
|
+
description?: ReactNode;
|
|
51
|
+
kicker?: ReactNode;
|
|
52
|
+
meta?: ReactNode;
|
|
53
|
+
actions?: ReactNode;
|
|
54
|
+
data: readonly T[];
|
|
55
|
+
getRowId: (row: T) => string;
|
|
56
|
+
columns: readonly ListPageColumn<T>[];
|
|
57
|
+
search?: ListPageSearchConfig<T>;
|
|
58
|
+
filters?: readonly ListPageFilter[];
|
|
59
|
+
matchFilter?: (row: T, filterId: string, value: string) => boolean;
|
|
60
|
+
rowLink?: (row: T) => string | undefined;
|
|
61
|
+
rowActions?: (row: T) => ReactNode;
|
|
62
|
+
loading?: boolean;
|
|
63
|
+
empty?: ListPageEmpty;
|
|
64
|
+
toolbar?: ReactNode;
|
|
65
|
+
footer?: ReactNode;
|
|
66
|
+
labels?: Partial<ListPageLabels>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const defaultListPageLabels: ListPageLabels = {
|
|
70
|
+
searchPlaceholder: 'Search…',
|
|
71
|
+
filterAll: 'All',
|
|
72
|
+
emptyTitle: 'Nothing here yet',
|
|
73
|
+
countShown: (shown, total) => `${shown} of ${total}`,
|
|
74
|
+
};
|