@syscore/ui-library 2.0.0-beta-publish-workflow-beta.11 → 2.0.0-beta-publish-workflow-beta.12
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/client/components/ui/button.tsx +3 -0
- package/client/components/ui/data-grid.tsx +258 -0
- package/client/components/ui/side-nav.tsx +162 -8
- package/client/components/ui/typography.tsx +4 -0
- package/client/global.css +168 -1
- package/client/ui/Button.stories.tsx +26 -0
- package/client/ui/DataGrid.stories.tsx +114 -0
- package/client/ui/SideNav.stories.tsx +39 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.es.js +258 -3
- package/package.json +3 -1
|
@@ -20,6 +20,9 @@ const buttonVariants = cva(
|
|
|
20
20
|
"general-primary": "button--general-primary",
|
|
21
21
|
"general-secondary": "button--general-secondary",
|
|
22
22
|
"general-tertiary": "button--general-tertiary",
|
|
23
|
+
// Destructive actions: delete, remove, deactivate, void. `primary` confirms, `secondary` starts the action.
|
|
24
|
+
"danger-primary": "button--danger-primary",
|
|
25
|
+
"danger-secondary": "button--danger-secondary",
|
|
23
26
|
"transparent-tertiary": "button--transparent-tertiary",
|
|
24
27
|
"tooltip-primary": "button--tooltip-primary",
|
|
25
28
|
"tooltip-secondary": "button--tooltip-secondary",
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AgGridReact } from "ag-grid-react";
|
|
3
|
+
import {
|
|
4
|
+
AllCommunityModule,
|
|
5
|
+
ModuleRegistry,
|
|
6
|
+
themeQuartz,
|
|
7
|
+
type ColDef,
|
|
8
|
+
type ICellRendererParams,
|
|
9
|
+
type SortChangedEvent,
|
|
10
|
+
} from "ag-grid-community";
|
|
11
|
+
|
|
12
|
+
import { cn } from "@/lib/utils";
|
|
13
|
+
|
|
14
|
+
ModuleRegistry.registerModules([AllCommunityModule]);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The grid's look comes from the design system, not from AG Grid's own stylesheet: the values below mirror the
|
|
18
|
+
* `Table appearance="card"` (tinted header, soft row dividers, hover highlight, rounded card), so a screen can
|
|
19
|
+
* move from one to the other without changing how it reads.
|
|
20
|
+
*/
|
|
21
|
+
const dataGridTheme = themeQuartz.withParams({
|
|
22
|
+
fontFamily: "var(--font-mazzard, 'Mazzard Soft M'), sans-serif",
|
|
23
|
+
fontSize: 14,
|
|
24
|
+
foregroundColor: "#1f2430",
|
|
25
|
+
backgroundColor: "#ffffff",
|
|
26
|
+
accentColor: "#0f748a",
|
|
27
|
+
borderColor: "#e3e8ef",
|
|
28
|
+
wrapperBorderRadius: 16,
|
|
29
|
+
headerBackgroundColor: "#f6f8fb",
|
|
30
|
+
headerTextColor: "#6b7280",
|
|
31
|
+
headerFontSize: 12,
|
|
32
|
+
headerFontWeight: 600,
|
|
33
|
+
// The pinned (action) column joins the rest of the row; no divider line.
|
|
34
|
+
pinnedColumnBorder: false,
|
|
35
|
+
rowHoverColor: "#f4f9fd",
|
|
36
|
+
columnBorder: false,
|
|
37
|
+
headerColumnBorder: false,
|
|
38
|
+
// The resize handle stays (the column still drags) but is drawn as a faint tick, not a separator line.
|
|
39
|
+
headerColumnResizeHandleColor: "transparent",
|
|
40
|
+
spacing: 8,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
type DataGridAlign = "left" | "center" | "right";
|
|
44
|
+
|
|
45
|
+
interface DataGridColumn<T> {
|
|
46
|
+
/** Stable id of the column; also the key reported by `onSortChange`. */
|
|
47
|
+
key: string;
|
|
48
|
+
header: string;
|
|
49
|
+
/**
|
|
50
|
+
* The cell's plain value. It is what sorting, filtering and the quick search work on, and what is shown unless
|
|
51
|
+
* `cell` is given.
|
|
52
|
+
*/
|
|
53
|
+
value?: (row: T) => string | number | boolean | null | undefined;
|
|
54
|
+
/** A custom cell (a badge, a row of buttons). Give `value` as well if the column should sort or be searched. */
|
|
55
|
+
cell?: (row: T) => React.ReactNode;
|
|
56
|
+
/** The user can sort by this column. Default `false`. */
|
|
57
|
+
sortable?: boolean;
|
|
58
|
+
/** Show a filter on this column's header menu (client-side data). Default `false`. */
|
|
59
|
+
filter?: boolean;
|
|
60
|
+
/** The user can drag the column edge to resize it. Default `true`. */
|
|
61
|
+
resizable?: boolean;
|
|
62
|
+
/** Fixed width in px. Leave out and use `flex` to share the leftover space. */
|
|
63
|
+
width?: number;
|
|
64
|
+
minWidth?: number;
|
|
65
|
+
/** Share of the leftover width relative to the other `flex` columns. Default `1` when no `width` is set. */
|
|
66
|
+
flex?: number;
|
|
67
|
+
align?: DataGridAlign;
|
|
68
|
+
pinned?: "left" | "right";
|
|
69
|
+
/** Let long text wrap onto more lines and grow the row, instead of being cut off with an ellipsis. */
|
|
70
|
+
wrap?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface DataGridSort {
|
|
74
|
+
key: string;
|
|
75
|
+
direction: "asc" | "desc";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface DataGridProps<T> {
|
|
79
|
+
columns: DataGridColumn<T>[];
|
|
80
|
+
rows: T[];
|
|
81
|
+
/** A stable id for a row, so the grid keeps focus and scroll when the data refreshes. */
|
|
82
|
+
getRowId?: (row: T) => string;
|
|
83
|
+
loading?: boolean;
|
|
84
|
+
/** Shown when `rows` is empty. */
|
|
85
|
+
emptyText?: string;
|
|
86
|
+
/** Hides rows that do not contain this text in any column (client-side data). */
|
|
87
|
+
quickFilter?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Controlled sort for data the SERVER sorts. When `onSortChange` is given the grid never reorders rows itself: it
|
|
90
|
+
* shows the sort indicator for `sort` and reports the user's choice, and the parent refetches in that order.
|
|
91
|
+
*/
|
|
92
|
+
sort?: DataGridSort | null;
|
|
93
|
+
onSortChange?: (sort: DataGridSort | null) => void;
|
|
94
|
+
onRowClick?: (row: T) => void;
|
|
95
|
+
/** Accessible name of the grid. */
|
|
96
|
+
"aria-label"?: string;
|
|
97
|
+
className?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const ALIGN_CLASS: Record<DataGridAlign, string | undefined> = {
|
|
101
|
+
left: undefined,
|
|
102
|
+
center: "data-grid__cell--center",
|
|
103
|
+
right: "data-grid__cell--right",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The grid only gets new column definitions when a column's SHAPE changes (its key, header, width, sorting, ...), not
|
|
108
|
+
* every time the parent re-renders and builds a fresh `columns` array: new definitions make AG Grid forget the user's
|
|
109
|
+
* sort and column sizes. The functions (`value`, `cell`) are read from the latest `columns` at call time, so they are
|
|
110
|
+
* never stale.
|
|
111
|
+
*/
|
|
112
|
+
function shapeOf<T>(columns: DataGridColumn<T>[]): string {
|
|
113
|
+
return JSON.stringify(
|
|
114
|
+
columns.map((c) => [
|
|
115
|
+
c.key,
|
|
116
|
+
c.header,
|
|
117
|
+
c.sortable ?? false,
|
|
118
|
+
c.filter ?? false,
|
|
119
|
+
c.resizable ?? true,
|
|
120
|
+
c.width ?? null,
|
|
121
|
+
c.minWidth ?? null,
|
|
122
|
+
c.flex ?? null,
|
|
123
|
+
c.align ?? null,
|
|
124
|
+
c.pinned ?? null,
|
|
125
|
+
c.wrap ?? false,
|
|
126
|
+
Boolean(c.value),
|
|
127
|
+
Boolean(c.cell),
|
|
128
|
+
]),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* DataGrid — an interactive table: sortable and resizable columns, filters, a quick search, custom cells, loading and
|
|
134
|
+
* empty states. It renders the rows it is given; paging stays with the screen (a pagination bar below), so the same
|
|
135
|
+
* grid works for a short list held in memory and for one page of a long list from the server.
|
|
136
|
+
*
|
|
137
|
+
* <DataGrid
|
|
138
|
+
* aria-label="Roles"
|
|
139
|
+
* rows={roles}
|
|
140
|
+
* getRowId={(role) => String(role.id)}
|
|
141
|
+
* columns={[
|
|
142
|
+
* { key: "name", header: "Role", value: (role) => role.name, sortable: true },
|
|
143
|
+
* { key: "scope", header: "Applies to", value: (role) => role.scopeType, sortable: true, filter: true },
|
|
144
|
+
* ]}
|
|
145
|
+
* quickFilter={search}
|
|
146
|
+
* />
|
|
147
|
+
*
|
|
148
|
+
* Client-side data: leave `onSortChange` out and the grid sorts and filters the rows itself.
|
|
149
|
+
* Server-side data: pass `sort` and `onSortChange` and refetch in that order.
|
|
150
|
+
*/
|
|
151
|
+
function DataGrid<T>({
|
|
152
|
+
columns,
|
|
153
|
+
rows,
|
|
154
|
+
getRowId,
|
|
155
|
+
loading = false,
|
|
156
|
+
emptyText = "Nothing to show.",
|
|
157
|
+
quickFilter,
|
|
158
|
+
sort,
|
|
159
|
+
onSortChange,
|
|
160
|
+
onRowClick,
|
|
161
|
+
className,
|
|
162
|
+
"aria-label": ariaLabel,
|
|
163
|
+
}: DataGridProps<T>) {
|
|
164
|
+
const serverSorted = onSortChange !== undefined;
|
|
165
|
+
const latest = React.useRef(columns);
|
|
166
|
+
latest.current = columns;
|
|
167
|
+
const shape = shapeOf(columns);
|
|
168
|
+
const sortKey = sort?.key ?? null;
|
|
169
|
+
const sortDirection = sort?.direction ?? null;
|
|
170
|
+
|
|
171
|
+
const columnDefs = React.useMemo<ColDef<T>[]>(
|
|
172
|
+
() =>
|
|
173
|
+
latest.current.map((column) => {
|
|
174
|
+
const fixed = column.width !== undefined;
|
|
175
|
+
const find = () => latest.current.find((c) => c.key === column.key);
|
|
176
|
+
return {
|
|
177
|
+
colId: column.key,
|
|
178
|
+
headerName: column.header,
|
|
179
|
+
valueGetter: column.value
|
|
180
|
+
? (params) => (params.data ? find()?.value?.(params.data) : undefined)
|
|
181
|
+
: undefined,
|
|
182
|
+
cellRenderer: column.cell
|
|
183
|
+
? (params: ICellRendererParams<T>) => (params.data ? find()?.cell?.(params.data) : null)
|
|
184
|
+
: undefined,
|
|
185
|
+
sortable: column.sortable ?? false,
|
|
186
|
+
filter: column.filter ?? false,
|
|
187
|
+
resizable: column.resizable ?? true,
|
|
188
|
+
suppressMovable: true,
|
|
189
|
+
width: column.width,
|
|
190
|
+
minWidth: column.minWidth ?? (fixed ? column.width : 96),
|
|
191
|
+
flex: fixed ? undefined : (column.flex ?? 1),
|
|
192
|
+
pinned: column.pinned,
|
|
193
|
+
wrapText: column.wrap ?? false,
|
|
194
|
+
autoHeight: column.wrap ?? false,
|
|
195
|
+
cellClass: column.align ? ALIGN_CLASS[column.align] : undefined,
|
|
196
|
+
headerClass: column.align ? ALIGN_CLASS[column.align] : undefined,
|
|
197
|
+
// Server-sorted data keeps the order it arrived in; the grid only draws the indicator.
|
|
198
|
+
...(serverSorted
|
|
199
|
+
? {
|
|
200
|
+
comparator: () => 0,
|
|
201
|
+
// Server-side sort has no "no sort": clicking again flips the direction.
|
|
202
|
+
sortingOrder: ["asc", "desc"] as ColDef<T>["sortingOrder"],
|
|
203
|
+
sort: sortKey === column.key ? sortDirection : null,
|
|
204
|
+
}
|
|
205
|
+
: {}),
|
|
206
|
+
};
|
|
207
|
+
}),
|
|
208
|
+
// `shape` stands for the column list; the list itself is a new array on most renders.
|
|
209
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
210
|
+
[shape, serverSorted, sortKey, sortDirection],
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const handleSortChanged = React.useCallback(
|
|
214
|
+
(event: SortChangedEvent<T>) => {
|
|
215
|
+
if (!serverSorted) return;
|
|
216
|
+
const active = event.api.getColumnState().find((state) => state.sort);
|
|
217
|
+
const next: DataGridSort | null = active?.colId
|
|
218
|
+
? { key: active.colId, direction: active.sort === "desc" ? "desc" : "asc" }
|
|
219
|
+
: null;
|
|
220
|
+
if (next?.key === sort?.key && next?.direction === sort?.direction) return;
|
|
221
|
+
if (!next && !sort) return;
|
|
222
|
+
onSortChange?.(next);
|
|
223
|
+
},
|
|
224
|
+
[serverSorted, sort, onSortChange],
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<div
|
|
229
|
+
role="region"
|
|
230
|
+
aria-label={ariaLabel}
|
|
231
|
+
className={cn(
|
|
232
|
+
"data-grid",
|
|
233
|
+
rows.length === 0 && "data-grid--empty",
|
|
234
|
+
onRowClick && "data-grid--clickable",
|
|
235
|
+
className,
|
|
236
|
+
)}
|
|
237
|
+
>
|
|
238
|
+
<AgGridReact<T>
|
|
239
|
+
theme={dataGridTheme}
|
|
240
|
+
rowData={rows}
|
|
241
|
+
columnDefs={columnDefs}
|
|
242
|
+
domLayout="autoHeight"
|
|
243
|
+
rowHeight={64}
|
|
244
|
+
headerHeight={48}
|
|
245
|
+
loading={loading}
|
|
246
|
+
quickFilterText={quickFilter}
|
|
247
|
+
getRowId={getRowId ? (params) => getRowId(params.data) : undefined}
|
|
248
|
+
onSortChanged={handleSortChanged}
|
|
249
|
+
onRowClicked={onRowClick ? (event) => event.data && onRowClick(event.data) : undefined}
|
|
250
|
+
suppressCellFocus
|
|
251
|
+
localeText={{ noRowsToShow: emptyText }}
|
|
252
|
+
/>
|
|
253
|
+
</div>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { DataGrid };
|
|
258
|
+
export type { DataGridColumn, DataGridProps, DataGridSort, DataGridAlign };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
3
|
+
import { ChevronDown } from "lucide-react";
|
|
3
4
|
|
|
4
5
|
import { cn } from "@/lib/utils";
|
|
5
6
|
|
|
@@ -15,6 +16,11 @@ import { cn } from "@/lib/utils";
|
|
|
15
16
|
*
|
|
16
17
|
* `collapsed` hides group labels and item text and centres the icons. A collapsed item
|
|
17
18
|
* keeps its text as a `title` tooltip and an accessible name.
|
|
19
|
+
*
|
|
20
|
+
* Long menus fold: give a group `collapsible` (its label becomes a button with a chevron) and
|
|
21
|
+
* nest sub-pages under a `SideNavBranch`. Both open and close themselves, or are controlled with
|
|
22
|
+
* `open` / `onOpenChange`. In the collapsed rail every group is shown open and a branch shows
|
|
23
|
+
* only its icon (its `onClick` can take the user to the first sub-page).
|
|
18
24
|
*/
|
|
19
25
|
|
|
20
26
|
interface SideNavContextValue {
|
|
@@ -46,14 +52,74 @@ const SideNav = React.forwardRef<HTMLElement, SideNavProps>(
|
|
|
46
52
|
);
|
|
47
53
|
SideNav.displayName = "SideNav";
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
/** Open state that the parent can control (`open` + `onOpenChange`) or leave to the component. */
|
|
56
|
+
function useDisclosure(
|
|
57
|
+
open: boolean | undefined,
|
|
58
|
+
defaultOpen: boolean,
|
|
59
|
+
onOpenChange?: (open: boolean) => void,
|
|
60
|
+
) {
|
|
61
|
+
const [inner, setInner] = React.useState(defaultOpen);
|
|
62
|
+
const isOpen = open ?? inner;
|
|
63
|
+
const setOpen = (next: boolean) => {
|
|
64
|
+
if (open === undefined) setInner(next);
|
|
65
|
+
onOpenChange?.(next);
|
|
66
|
+
};
|
|
67
|
+
return [isOpen, setOpen] as const;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface SideNavGroupProps
|
|
71
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
50
72
|
/** Group heading, shown above the items (hidden when the nav is collapsed). */
|
|
51
73
|
label?: React.ReactNode;
|
|
74
|
+
/** Fold the group: the heading becomes a button that shows or hides its items. */
|
|
75
|
+
collapsible?: boolean;
|
|
76
|
+
/** Controlled open state (with `collapsible`). */
|
|
77
|
+
open?: boolean;
|
|
78
|
+
/** Initial open state when not controlled. Default `true`. */
|
|
79
|
+
defaultOpen?: boolean;
|
|
80
|
+
onOpenChange?: (open: boolean) => void;
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
const SideNavGroup = React.forwardRef<HTMLDivElement, SideNavGroupProps>(
|
|
55
|
-
(
|
|
84
|
+
(
|
|
85
|
+
{
|
|
86
|
+
className,
|
|
87
|
+
label,
|
|
88
|
+
collapsible = false,
|
|
89
|
+
open,
|
|
90
|
+
defaultOpen = true,
|
|
91
|
+
onOpenChange,
|
|
92
|
+
children,
|
|
93
|
+
...props
|
|
94
|
+
},
|
|
95
|
+
ref,
|
|
96
|
+
) => {
|
|
97
|
+
const { collapsed } = React.useContext(SideNavContext);
|
|
56
98
|
const headingId = React.useId();
|
|
99
|
+
const itemsId = React.useId();
|
|
100
|
+
const [isOpen, setOpen] = useDisclosure(open, defaultOpen, onOpenChange);
|
|
101
|
+
|
|
102
|
+
if (!collapsible) {
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
ref={ref}
|
|
106
|
+
role="group"
|
|
107
|
+
aria-labelledby={label ? headingId : undefined}
|
|
108
|
+
className={cn("side-nav__group", className)}
|
|
109
|
+
{...props}
|
|
110
|
+
>
|
|
111
|
+
{label ? (
|
|
112
|
+
<span id={headingId} className="side-nav__heading">
|
|
113
|
+
{label}
|
|
114
|
+
</span>
|
|
115
|
+
) : null}
|
|
116
|
+
{children}
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// In the icon rail there is no heading to fold, so every item stays reachable.
|
|
122
|
+
const shown = collapsed || isOpen;
|
|
57
123
|
return (
|
|
58
124
|
<div
|
|
59
125
|
ref={ref}
|
|
@@ -63,11 +129,21 @@ const SideNavGroup = React.forwardRef<HTMLDivElement, SideNavGroupProps>(
|
|
|
63
129
|
{...props}
|
|
64
130
|
>
|
|
65
131
|
{label ? (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
id={headingId}
|
|
135
|
+
className="side-nav__heading side-nav__heading--toggle"
|
|
136
|
+
aria-expanded={shown}
|
|
137
|
+
aria-controls={itemsId}
|
|
138
|
+
onClick={() => setOpen(!isOpen)}
|
|
139
|
+
>
|
|
140
|
+
<span>{label}</span>
|
|
141
|
+
<ChevronDown className="side-nav__chevron" aria-hidden="true" />
|
|
142
|
+
</button>
|
|
69
143
|
) : null}
|
|
70
|
-
{
|
|
144
|
+
<div id={itemsId} className="side-nav__items" hidden={!shown}>
|
|
145
|
+
{children}
|
|
146
|
+
</div>
|
|
71
147
|
</div>
|
|
72
148
|
);
|
|
73
149
|
},
|
|
@@ -122,5 +198,83 @@ const SideNavItem = React.forwardRef<HTMLButtonElement, SideNavItemProps>(
|
|
|
122
198
|
);
|
|
123
199
|
SideNavItem.displayName = "SideNavItem";
|
|
124
200
|
|
|
125
|
-
|
|
126
|
-
|
|
201
|
+
interface SideNavBranchProps
|
|
202
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "onClick"> {
|
|
203
|
+
/** Leading icon. */
|
|
204
|
+
icon?: React.ReactNode;
|
|
205
|
+
/** The branch's own text. Its sub-pages (`SideNavItem`s) go in `children`. */
|
|
206
|
+
label: string;
|
|
207
|
+
/** A sub-page is the current page: the branch is highlighted even while folded. */
|
|
208
|
+
active?: boolean;
|
|
209
|
+
/** Controlled open state. */
|
|
210
|
+
open?: boolean;
|
|
211
|
+
/** Initial open state when not controlled. Default `false`. */
|
|
212
|
+
defaultOpen?: boolean;
|
|
213
|
+
onOpenChange?: (open: boolean) => void;
|
|
214
|
+
/** Runs when the branch is pressed in the collapsed icon rail (where it cannot unfold). */
|
|
215
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** An item that unfolds into sub-pages (Users → Users, Roles, Permissions). */
|
|
219
|
+
const SideNavBranch = React.forwardRef<HTMLDivElement, SideNavBranchProps>(
|
|
220
|
+
(
|
|
221
|
+
{
|
|
222
|
+
className,
|
|
223
|
+
icon,
|
|
224
|
+
label,
|
|
225
|
+
active = false,
|
|
226
|
+
open,
|
|
227
|
+
defaultOpen = false,
|
|
228
|
+
onOpenChange,
|
|
229
|
+
onClick,
|
|
230
|
+
children,
|
|
231
|
+
...props
|
|
232
|
+
},
|
|
233
|
+
ref,
|
|
234
|
+
) => {
|
|
235
|
+
const { collapsed } = React.useContext(SideNavContext);
|
|
236
|
+
const subId = React.useId();
|
|
237
|
+
const [isOpen, setOpen] = useDisclosure(open, defaultOpen, onOpenChange);
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<div ref={ref} className={cn("side-nav__branch", className)} {...props}>
|
|
241
|
+
<button
|
|
242
|
+
type="button"
|
|
243
|
+
className={cn(
|
|
244
|
+
"side-nav__item",
|
|
245
|
+
"side-nav__item--branch",
|
|
246
|
+
active && "side-nav__item--branch-active",
|
|
247
|
+
)}
|
|
248
|
+
aria-expanded={collapsed ? undefined : isOpen}
|
|
249
|
+
aria-controls={subId}
|
|
250
|
+
aria-label={collapsed ? label : undefined}
|
|
251
|
+
title={collapsed ? label : undefined}
|
|
252
|
+
onClick={(event) => {
|
|
253
|
+
if (collapsed) onClick?.(event);
|
|
254
|
+
else setOpen(!isOpen);
|
|
255
|
+
}}
|
|
256
|
+
>
|
|
257
|
+
{icon ? (
|
|
258
|
+
<span className="side-nav__icon" aria-hidden="true">
|
|
259
|
+
{icon}
|
|
260
|
+
</span>
|
|
261
|
+
) : null}
|
|
262
|
+
<span className="side-nav__label">{label}</span>
|
|
263
|
+
<ChevronDown className="side-nav__chevron" aria-hidden="true" />
|
|
264
|
+
</button>
|
|
265
|
+
<div id={subId} className="side-nav__sub" hidden={collapsed || !isOpen}>
|
|
266
|
+
{children}
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
);
|
|
270
|
+
},
|
|
271
|
+
);
|
|
272
|
+
SideNavBranch.displayName = "SideNavBranch";
|
|
273
|
+
|
|
274
|
+
export { SideNav, SideNavGroup, SideNavItem, SideNavBranch };
|
|
275
|
+
export type {
|
|
276
|
+
SideNavProps,
|
|
277
|
+
SideNavGroupProps,
|
|
278
|
+
SideNavItemProps,
|
|
279
|
+
SideNavBranchProps,
|
|
280
|
+
};
|
|
@@ -57,6 +57,8 @@ interface TextProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
57
57
|
align?: "start" | "center";
|
|
58
58
|
/** `relaxed` — a 1.5 line height for short paragraphs that should breathe. */
|
|
59
59
|
leading?: "default" | "relaxed";
|
|
60
|
+
/** `sans` — set a heading in the body typeface (Mazzard) instead of the display serif. */
|
|
61
|
+
family?: "default" | "sans";
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
const Text = React.forwardRef<HTMLElement, TextProps>(
|
|
@@ -69,6 +71,7 @@ const Text = React.forwardRef<HTMLElement, TextProps>(
|
|
|
69
71
|
strong = false,
|
|
70
72
|
align,
|
|
71
73
|
leading = "default",
|
|
74
|
+
family = "default",
|
|
72
75
|
...props
|
|
73
76
|
},
|
|
74
77
|
ref,
|
|
@@ -84,6 +87,7 @@ const Text = React.forwardRef<HTMLElement, TextProps>(
|
|
|
84
87
|
strong && "typo--strong",
|
|
85
88
|
align === "center" && "typo--center",
|
|
86
89
|
leading === "relaxed" && "typo--relaxed",
|
|
90
|
+
family === "sans" && "typo--sans",
|
|
87
91
|
className,
|
|
88
92
|
)}
|
|
89
93
|
{...props}
|
package/client/global.css
CHANGED
|
@@ -1034,6 +1034,38 @@ body {
|
|
|
1034
1034
|
0 0 0 2px var(--color-blue-200, #cbe0f1),
|
|
1035
1035
|
0 0 0 4px var(--color-white, #fff);
|
|
1036
1036
|
}
|
|
1037
|
+
/* Destructive actions — solid red to confirm, white with a red outline to start. */
|
|
1038
|
+
.button--danger-primary {
|
|
1039
|
+
background-color: var(--color-red-600, #dc2626);
|
|
1040
|
+
color: var(--color-white, #fff);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
.button--danger-primary:hover {
|
|
1044
|
+
background-color: var(--color-red-700, #b91c1c);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
.button--danger-primary:focus-visible {
|
|
1048
|
+
box-shadow:
|
|
1049
|
+
0 0 0 2px var(--color-red-600, #dc2626),
|
|
1050
|
+
0 0 0 4px var(--color-white, #fff);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
.button--danger-secondary {
|
|
1054
|
+
background-color: var(--color-white, #fff);
|
|
1055
|
+
border: 1px solid var(--color-red-200, #fecaca);
|
|
1056
|
+
color: var(--color-red-700, #b91c1c);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
.button--danger-secondary:hover {
|
|
1060
|
+
background-color: var(--color-red-50, #fef2f2);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
.button--danger-secondary:focus-visible {
|
|
1064
|
+
box-shadow:
|
|
1065
|
+
0 0 0 2px var(--color-red-200, #fecaca),
|
|
1066
|
+
0 0 0 4px var(--color-white, #fff);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1037
1069
|
.button--transparent-tertiary {
|
|
1038
1070
|
display: inline-flex;
|
|
1039
1071
|
align-items: center;
|
|
@@ -16364,7 +16396,7 @@ body {
|
|
|
16364
16396
|
padding-top: 14px;
|
|
16365
16397
|
padding-bottom: 14px;
|
|
16366
16398
|
border-bottom: 1px solid #e3e8ef;
|
|
16367
|
-
font-size:
|
|
16399
|
+
font-size: 12px;
|
|
16368
16400
|
font-weight: 600;
|
|
16369
16401
|
letter-spacing: 0.08em;
|
|
16370
16402
|
color: #6b7280;
|
|
@@ -16499,6 +16531,82 @@ body {
|
|
|
16499
16531
|
background: linear-gradient(180deg, #41d5f6, #3eecd1);
|
|
16500
16532
|
}
|
|
16501
16533
|
|
|
16534
|
+
/* Collapsible group: the heading is a button with a chevron. */
|
|
16535
|
+
.side-nav__heading--toggle {
|
|
16536
|
+
display: flex;
|
|
16537
|
+
align-items: center;
|
|
16538
|
+
justify-content: space-between;
|
|
16539
|
+
gap: 8px;
|
|
16540
|
+
width: 100%;
|
|
16541
|
+
border: 0;
|
|
16542
|
+
border-radius: 8px;
|
|
16543
|
+
background: none;
|
|
16544
|
+
font: inherit;
|
|
16545
|
+
font-size: 11px;
|
|
16546
|
+
font-weight: 600;
|
|
16547
|
+
letter-spacing: 0.08em;
|
|
16548
|
+
text-transform: uppercase;
|
|
16549
|
+
color: #8a8e9a;
|
|
16550
|
+
text-align: left;
|
|
16551
|
+
cursor: pointer;
|
|
16552
|
+
transition: color 0.15s ease;
|
|
16553
|
+
}
|
|
16554
|
+
|
|
16555
|
+
.side-nav__heading--toggle:hover {
|
|
16556
|
+
color: #4a4d58;
|
|
16557
|
+
}
|
|
16558
|
+
|
|
16559
|
+
.side-nav__heading--toggle:focus-visible {
|
|
16560
|
+
outline: 2px solid #3b8fc9;
|
|
16561
|
+
outline-offset: 1px;
|
|
16562
|
+
}
|
|
16563
|
+
|
|
16564
|
+
.side-nav__chevron {
|
|
16565
|
+
flex: none;
|
|
16566
|
+
width: 14px;
|
|
16567
|
+
height: 14px;
|
|
16568
|
+
transition: transform 0.15s ease;
|
|
16569
|
+
}
|
|
16570
|
+
|
|
16571
|
+
[aria-expanded="false"] > .side-nav__chevron {
|
|
16572
|
+
transform: rotate(-90deg);
|
|
16573
|
+
}
|
|
16574
|
+
|
|
16575
|
+
.side-nav__items,
|
|
16576
|
+
.side-nav__branch,
|
|
16577
|
+
.side-nav__sub {
|
|
16578
|
+
display: flex;
|
|
16579
|
+
flex-direction: column;
|
|
16580
|
+
gap: 2px;
|
|
16581
|
+
}
|
|
16582
|
+
|
|
16583
|
+
.side-nav__items[hidden],
|
|
16584
|
+
.side-nav__sub[hidden] {
|
|
16585
|
+
display: none;
|
|
16586
|
+
}
|
|
16587
|
+
|
|
16588
|
+
/* Branch: an item that unfolds into sub-pages, indented under its icon. */
|
|
16589
|
+
.side-nav__item--branch .side-nav__label {
|
|
16590
|
+
flex: 1;
|
|
16591
|
+
}
|
|
16592
|
+
|
|
16593
|
+
.side-nav__item--branch .side-nav__chevron {
|
|
16594
|
+
color: #8a8e9a;
|
|
16595
|
+
}
|
|
16596
|
+
|
|
16597
|
+
.side-nav__item--branch-active {
|
|
16598
|
+
color: #1f5f93;
|
|
16599
|
+
font-weight: 600;
|
|
16600
|
+
}
|
|
16601
|
+
|
|
16602
|
+
.side-nav__item--branch-active .side-nav__icon {
|
|
16603
|
+
color: #2f7a8f;
|
|
16604
|
+
}
|
|
16605
|
+
|
|
16606
|
+
.side-nav__sub .side-nav__item {
|
|
16607
|
+
padding-left: 44px;
|
|
16608
|
+
}
|
|
16609
|
+
|
|
16502
16610
|
/* Collapsed: icons only. `font-size: 0` hides the text of an item rendered with `asChild` too. */
|
|
16503
16611
|
.side-nav--collapsed .side-nav__heading,
|
|
16504
16612
|
.side-nav--collapsed .side-nav__label {
|
|
@@ -16511,6 +16619,11 @@ body {
|
|
|
16511
16619
|
font-size: 0;
|
|
16512
16620
|
}
|
|
16513
16621
|
|
|
16622
|
+
.side-nav--collapsed .side-nav__chevron,
|
|
16623
|
+
.side-nav--collapsed .side-nav__sub {
|
|
16624
|
+
display: none;
|
|
16625
|
+
}
|
|
16626
|
+
|
|
16514
16627
|
/* CheckboxField — a checkbox with its label and optional description. */
|
|
16515
16628
|
.checkbox-field {
|
|
16516
16629
|
display: inline-flex;
|
|
@@ -16794,3 +16907,57 @@ body {
|
|
|
16794
16907
|
.typo--relaxed {
|
|
16795
16908
|
line-height: 1.5;
|
|
16796
16909
|
}
|
|
16910
|
+
|
|
16911
|
+
/* DataGrid — an AG Grid themed like Table appearance="card". The colours live in the component's theme. */
|
|
16912
|
+
.data-grid {
|
|
16913
|
+
width: 100%;
|
|
16914
|
+
}
|
|
16915
|
+
|
|
16916
|
+
/* AG Grid keeps 150px of body height even for two rows; only an empty grid needs that room for its message. */
|
|
16917
|
+
.data-grid:not(.data-grid--empty) .ag-viewport {
|
|
16918
|
+
min-height: 0;
|
|
16919
|
+
}
|
|
16920
|
+
|
|
16921
|
+
/* Column headers read like the card Table's: small caps with letter spacing, but large enough to read. */
|
|
16922
|
+
.data-grid .ag-header-cell-text {
|
|
16923
|
+
text-transform: uppercase;
|
|
16924
|
+
letter-spacing: 0.06em;
|
|
16925
|
+
}
|
|
16926
|
+
|
|
16927
|
+
/* A row that grows for wrapped content keeps breathing room above and below it. */
|
|
16928
|
+
.data-grid .ag-cell {
|
|
16929
|
+
padding-top: 8px;
|
|
16930
|
+
padding-bottom: 8px;
|
|
16931
|
+
}
|
|
16932
|
+
|
|
16933
|
+
/* Every cell centres its content, so a badge or a button lines up with the text beside it. */
|
|
16934
|
+
.data-grid .ag-cell {
|
|
16935
|
+
display: flex;
|
|
16936
|
+
align-items: center;
|
|
16937
|
+
}
|
|
16938
|
+
|
|
16939
|
+
.data-grid .data-grid__cell--right {
|
|
16940
|
+
justify-content: flex-end;
|
|
16941
|
+
text-align: right;
|
|
16942
|
+
}
|
|
16943
|
+
|
|
16944
|
+
.data-grid .data-grid__cell--right .ag-header-cell-label {
|
|
16945
|
+
justify-content: flex-end;
|
|
16946
|
+
}
|
|
16947
|
+
|
|
16948
|
+
.data-grid .data-grid__cell--center {
|
|
16949
|
+
justify-content: center;
|
|
16950
|
+
text-align: center;
|
|
16951
|
+
}
|
|
16952
|
+
|
|
16953
|
+
.data-grid .data-grid__cell--center .ag-header-cell-label {
|
|
16954
|
+
justify-content: center;
|
|
16955
|
+
}
|
|
16956
|
+
|
|
16957
|
+
.data-grid--clickable .ag-row {
|
|
16958
|
+
cursor: pointer;
|
|
16959
|
+
}
|
|
16960
|
+
|
|
16961
|
+
.typo--sans {
|
|
16962
|
+
font-family: var(--font-mazzard, "Mazzard Soft M"), sans-serif;
|
|
16963
|
+
}
|