@syscore/ui-library 2.0.0-beta-publish-workflow-beta.11 → 2.0.0-beta-publish-workflow-beta.13

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.
@@ -10,6 +10,10 @@ const alertVariants = cva(
10
10
  variant: {
11
11
  default: "alert--default",
12
12
  destructive: "alert--destructive",
13
+ // Neutral help/explainer callout — e.g. the activity-type guidance
14
+ // text on the WELL AP "Report CE hours" form. Blue, not red/coral:
15
+ // informational, not a warning or error.
16
+ info: "alert--info",
13
17
  },
14
18
  },
15
19
  defaultVariants: {
@@ -16,10 +16,18 @@ const buttonVariants = cva(
16
16
  "primary-dark": "button--primary-dark",
17
17
  "secondary-light": "button--secondary-light",
18
18
  "tertiary-light": "button--tertiary-light",
19
+ // Same pill shape as tertiary-light, red instead of blue — for a
20
+ // destructive inline action (e.g. "Remove" on an applied discount
21
+ // code) that isn't severe enough for a confirm dialog but shouldn't
22
+ // read as a neutral/affirmative action either.
23
+ "tertiary-danger": "button--tertiary-danger",
19
24
  // Utility variants
20
25
  "general-primary": "button--general-primary",
21
26
  "general-secondary": "button--general-secondary",
22
27
  "general-tertiary": "button--general-tertiary",
28
+ // Destructive actions: delete, remove, deactivate, void. `primary` confirms, `secondary` starts the action.
29
+ "danger-primary": "button--danger-primary",
30
+ "danger-secondary": "button--danger-secondary",
23
31
  "transparent-tertiary": "button--transparent-tertiary",
24
32
  "tooltip-primary": "button--tooltip-primary",
25
33
  "tooltip-secondary": "button--tooltip-secondary",
@@ -12,6 +12,10 @@ const cardVariants = cva("card", {
12
12
  elevated: "card--elevated",
13
13
  filled: "card--filled",
14
14
  interactive: "card--interactive",
15
+ // A dark, colored promo banner (e.g. the WELL AP credentials page's
16
+ // "WELL Forum" callout) — content on it needs the inverse text tone,
17
+ // same as any other dark surface in the app.
18
+ gradient: "card--gradient",
15
19
  /** A bordered 16px-radius panel for a side summary. */
16
20
  panel: "card--panel",
17
21
  /** A bordered 12px-radius box nested inside a form or another card. */
@@ -20,6 +24,7 @@ const cardVariants = cva("card", {
20
24
  padding: {
21
25
  default: "",
22
26
  spacious: "card--padding-spacious",
27
+ compact: "card--padding-compact",
23
28
  },
24
29
  /** `relaxed` — more air between heading, description and content (dense back-office pages). */
25
30
  spacing: {
@@ -58,9 +63,19 @@ Card.displayName = "Card";
58
63
 
59
64
  const CardHeader = React.forwardRef<
60
65
  HTMLDivElement,
61
- React.HTMLAttributes<HTMLDivElement>
62
- >(({ className, ...props }, ref) => (
63
- <div ref={ref} className={cn("card-header", className)} {...props} />
66
+ React.HTMLAttributes<HTMLDivElement> & {
67
+ /** A light gray strip, full-bleed to the card edges with a bottom
68
+ * divider — for a receipt/invoice-style card whose header reads as a
69
+ * distinct band from the body below it (e.g. "Receipt: #123" + a status
70
+ * pill), rather than the default header that's just extra top padding. */
71
+ tinted?: boolean;
72
+ }
73
+ >(({ className, tinted = false, ...props }, ref) => (
74
+ <div
75
+ ref={ref}
76
+ className={cn("card-header", tinted && "card-header--tinted", className)}
77
+ {...props}
78
+ />
64
79
  ));
65
80
  CardHeader.displayName = "CardHeader";
66
81
 
@@ -158,6 +173,30 @@ const CardActions = React.forwardRef<
158
173
  ));
159
174
  CardActions.displayName = "CardActions";
160
175
 
176
+ /**
177
+ * Swatch — a small solid rounded-square accent, e.g. preceding a metric
178
+ * label/value pair inside a stat card. Purely decorative; no icon/content
179
+ * slot by design (a blank color block, not an icon wrapper).
180
+ */
181
+ type SwatchTone = "primary" | "muted";
182
+ type SwatchSize = "sm" | "md";
183
+
184
+ interface SwatchProps extends React.HTMLAttributes<HTMLDivElement> {
185
+ tone?: SwatchTone;
186
+ size?: SwatchSize;
187
+ }
188
+
189
+ const Swatch = React.forwardRef<HTMLDivElement, SwatchProps>(
190
+ ({ className, tone = "primary", size = "md", ...props }, ref) => (
191
+ <div
192
+ ref={ref}
193
+ className={cn("swatch", `swatch--${tone}`, `swatch--${size}`, className)}
194
+ {...props}
195
+ />
196
+ ),
197
+ );
198
+ Swatch.displayName = "Swatch";
199
+
161
200
  interface CardMetricProps extends React.HTMLAttributes<HTMLDivElement> {
162
201
  value: string | number;
163
202
  label: string;
@@ -217,4 +256,5 @@ export {
217
256
  CardActions,
218
257
  CardMetric,
219
258
  CardWithIcon,
259
+ Swatch,
220
260
  };
@@ -14,7 +14,7 @@ import { cn } from "@/lib/utils";
14
14
  * (`.body-base.copy`) so it wins on specificity without `!important`.
15
15
  */
16
16
 
17
- type CopyTone = "default" | "muted" | "subtle" | "link" | "error" | "success" | "inverse";
17
+ type CopyTone = "default" | "muted" | "subtle" | "link" | "error" | "success" | "inverse" | "coral";
18
18
  type CopySize = "large" | "base" | "small";
19
19
  type CopyWeight = "regular" | "medium" | "semibold";
20
20
  type CopyAlign = "start" | "center" | "end";
@@ -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 };
@@ -58,9 +58,12 @@ function DialogContent({
58
58
  innerClassName?: string;
59
59
  closeClassName?: string;
60
60
  /** `"fullscreen"` — PRD-009 course-access iframe: near-full-viewport chrome
61
- * (`height: calc(100vh - 90px)`), no fixed max-width. Default is the
62
- * existing centered modal. */
63
- size?: "default" | "fullscreen";
61
+ * (`height: calc(100vh - 90px)`), no fixed max-width. `"lg"` — a wider
62
+ * centered modal (`width: min(42rem, calc(100% - 2rem))`) for a longer
63
+ * single-column form (e.g. the WELL AP "Report CE hours" form) where the
64
+ * default modal's intrinsic auto-grid width leaves every input reading as
65
+ * narrow. Default is the existing centered modal, sized to its content. */
66
+ size?: "default" | "fullscreen" | "lg";
64
67
  /** `"form"` — the back-office dialog: a 560px panel with roomier padding, a
65
68
  * left-aligned title and description (16px, page font) and a 12px footer gap.
66
69
  * Default is the centred customer-facing modal, unchanged. */
@@ -79,16 +82,23 @@ function DialogContent({
79
82
  className={cn(
80
83
  "dialog-content",
81
84
  size === "fullscreen" && "dialog-content--fullscreen",
85
+ size === "lg" && "dialog-content--lg",
82
86
  appearance === "form" && "dialog-content--form",
83
87
  className,
84
88
  )}
85
89
  {...props}
86
90
  >
87
- <div className="dialog-content-wrapper">
91
+ <div
92
+ className={cn(
93
+ "dialog-content-wrapper",
94
+ size === "lg" && "dialog-content-wrapper--lg",
95
+ )}
96
+ >
88
97
  <div
89
98
  className={cn(
90
99
  "dialog-content-inner",
91
100
  size === "fullscreen" && "dialog-content-inner--fullscreen",
101
+ size === "lg" && "dialog-content-inner--lg",
92
102
  innerClassName,
93
103
  )}
94
104
  >
@@ -115,11 +125,20 @@ function DialogContent({
115
125
  );
116
126
  }
117
127
 
118
- function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
128
+ function DialogHeader({
129
+ className,
130
+ spacious = false,
131
+ ...props
132
+ }: React.ComponentProps<"div"> & {
133
+ /** Extra top/bottom padding around the header — for a `size="lg"` dialog
134
+ * whose title otherwise sits flush against the overlay edge and the first
135
+ * field below it. */
136
+ spacious?: boolean;
137
+ }) {
119
138
  return (
120
139
  <div
121
140
  data-slot="dialog-header"
122
- className={cn("dialog-header", className)}
141
+ className={cn("dialog-header", spacious && "dialog-header--spacious", className)}
123
142
  {...props}
124
143
  />
125
144
  );
@@ -137,12 +156,20 @@ function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
137
156
 
138
157
  function DialogTitle({
139
158
  className,
159
+ size = "default",
140
160
  ...props
141
- }: React.ComponentProps<typeof DialogPrimitive.Title>) {
161
+ }: React.ComponentProps<typeof DialogPrimitive.Title> & {
162
+ /** `"md"` — `heading-xsmall` (22px). `"lg"` — `heading-small` (30px), for a
163
+ * dialog wide enough to carry it. Default (`heading-xxsmall`, 20px) stays
164
+ * unchanged for every existing dialog. */
165
+ size?: "default" | "md" | "lg";
166
+ }) {
167
+ const sizeClass =
168
+ size === "lg" ? "heading-small" : size === "md" ? "heading-xsmall" : "heading-xxsmall";
142
169
  return (
143
170
  <DialogPrimitive.Title
144
171
  data-slot="dialog-title"
145
- className={cn("dialog-title heading-xxsmall text-center", className)}
172
+ className={cn("dialog-title text-center", sizeClass, className)}
146
173
  {...props}
147
174
  />
148
175
  );
@@ -323,12 +323,13 @@ const Grid = React.forwardRef<HTMLElement, GridProps>(
323
323
  )}
324
324
  style={{
325
325
  gridTemplateColumns: template,
326
- gap:
327
- rowGap === undefined && resolvedColumnGap === undefined
328
- ? gapCss(gap)
329
- : undefined,
330
- rowGap: gapCss(rowGap),
331
- columnGap: gapCss(resolvedColumnGap),
326
+ // Never emit the `gap` shorthand alongside `rowGap`/`columnGap` —
327
+ // React warns on mixing a shorthand and its longhands in the same
328
+ // style object across re-renders, even when one side is
329
+ // `undefined`. Decomposing into the two longhands always, with
330
+ // `gap` as their shared fallback, avoids the shorthand entirely.
331
+ rowGap: gapCss(rowGap ?? gap),
332
+ columnGap: gapCss(resolvedColumnGap ?? gap),
332
333
  width: toCssSize(width),
333
334
  height: toCssSize(height),
334
335
  maxWidth: toCssSize(maxWidth),
@@ -454,12 +455,10 @@ const Columns = React.forwardRef<HTMLElement, ColumnsProps>(
454
455
  )}
455
456
  style={{
456
457
  gridTemplateColumns: template ?? ColumnsPresetMap[preset],
457
- gap:
458
- rowGap === undefined && resolvedColumnGap === undefined
459
- ? gapCss(gap)
460
- : undefined,
461
- rowGap: gapCss(rowGap),
462
- columnGap: gapCss(resolvedColumnGap),
458
+ // See Grid's identical comment — never mix the `gap` shorthand
459
+ // with `rowGap`/`columnGap` longhands in the same style object.
460
+ rowGap: gapCss(rowGap ?? gap),
461
+ columnGap: gapCss(resolvedColumnGap ?? gap),
463
462
  ...style,
464
463
  }}
465
464
  {...props}