@oaiz/app-kit 0.0.0-stage → 0.1.4130
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/LICENSE +21 -0
- package/README.md +149 -2
- package/THIRD_PARTY_NOTICES.md +76 -0
- package/package.json +139 -4
- package/registry.json +1847 -0
- package/src/components/activity-timeline.tsx +227 -0
- package/src/components/app-shell.tsx +622 -0
- package/src/components/bar-list.tsx +47 -0
- package/src/components/board.tsx +700 -0
- package/src/components/calendar-view.tsx +1388 -0
- package/src/components/card-grid.tsx +462 -0
- package/src/components/charts.tsx +701 -0
- package/src/components/chat-markdown.tsx +230 -0
- package/src/components/chat-panel.tsx +760 -0
- package/src/components/code-editor.tsx +276 -0
- package/src/components/collection-controls.tsx +226 -0
- package/src/components/command-palette.tsx +403 -0
- package/src/components/confirm-action.tsx +123 -0
- package/src/components/data-table.tsx +821 -0
- package/src/components/date-input.tsx +429 -0
- package/src/components/empty-state.tsx +31 -0
- package/src/components/error-state.tsx +37 -0
- package/src/components/file-upload.tsx +595 -0
- package/src/components/filter-bar.tsx +415 -0
- package/src/components/grouped-picker.tsx +250 -0
- package/src/components/line-items.tsx +601 -0
- package/src/components/list-view.tsx +491 -0
- package/src/components/metrics.tsx +53 -0
- package/src/components/page-header.tsx +33 -0
- package/src/components/property-picker.tsx +546 -0
- package/src/components/record-detail.tsx +416 -0
- package/src/components/record-form.tsx +295 -0
- package/src/components/record-name.tsx +85 -0
- package/src/components/save-bar.tsx +142 -0
- package/src/components/sign-in.tsx +179 -0
- package/src/components/split-view.tsx +128 -0
- package/src/components/status-dot.tsx +56 -0
- package/src/components/stepper.tsx +153 -0
- package/src/components/text-diff-model.ts +111 -0
- package/src/components/text-diff.tsx +98 -0
- package/src/components/time-zone-picker.tsx +69 -0
- package/src/components/ui/accordion.tsx +138 -0
- package/src/components/ui/alert-dialog.tsx +67 -0
- package/src/components/ui/alert.tsx +65 -0
- package/src/components/ui/avatar-group.tsx +119 -0
- package/src/components/ui/avatar.tsx +55 -0
- package/src/components/ui/badge.tsx +59 -0
- package/src/components/ui/bottom-navigation.tsx +102 -0
- package/src/components/ui/breadcrumb.tsx +117 -0
- package/src/components/ui/button.tsx +71 -0
- package/src/components/ui/card.tsx +95 -0
- package/src/components/ui/checkbox.tsx +31 -0
- package/src/components/ui/collapsible.tsx +27 -0
- package/src/components/ui/context-menu.tsx +270 -0
- package/src/components/ui/count-up.tsx +136 -0
- package/src/components/ui/detail-disclosure-section.tsx +109 -0
- package/src/components/ui/dialog.tsx +157 -0
- package/src/components/ui/dropdown-menu.tsx +273 -0
- package/src/components/ui/form-field.tsx +155 -0
- package/src/components/ui/heading.tsx +126 -0
- package/src/components/ui/hover-card.tsx +45 -0
- package/src/components/ui/input.tsx +50 -0
- package/src/components/ui/label.tsx +30 -0
- package/src/components/ui/orb-spinner.tsx +238 -0
- package/src/components/ui/popover.tsx +59 -0
- package/src/components/ui/progress-ring.tsx +125 -0
- package/src/components/ui/progress.tsx +38 -0
- package/src/components/ui/radio-group.tsx +124 -0
- package/src/components/ui/resizable.tsx +48 -0
- package/src/components/ui/scroll-fade.tsx +98 -0
- package/src/components/ui/segmented-control.tsx +70 -0
- package/src/components/ui/select.tsx +230 -0
- package/src/components/ui/separator.tsx +29 -0
- package/src/components/ui/sheet.tsx +170 -0
- package/src/components/ui/shimmer-text.tsx +87 -0
- package/src/components/ui/shortcut.tsx +39 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/slider.tsx +48 -0
- package/src/components/ui/switch.tsx +44 -0
- package/src/components/ui/table.tsx +119 -0
- package/src/components/ui/tabs.tsx +80 -0
- package/src/components/ui/text.tsx +93 -0
- package/src/components/ui/textarea.tsx +51 -0
- package/src/components/ui/toast.tsx +141 -0
- package/src/components/ui/toaster.tsx +40 -0
- package/src/components/ui/tooltip.tsx +38 -0
- package/src/components/ui/top-banner.tsx +108 -0
- package/src/components/ui/tree-view.tsx +215 -0
- package/src/components/ui/use-toast.tsx +184 -0
- package/src/components/ui/voice-orb.tsx +252 -0
- package/src/hooks/oaiz-chat.tsx +530 -0
- package/src/hooks/oaiz-data.tsx +617 -0
- package/src/hooks/oaiz-session.tsx +63 -0
- package/src/hooks/use-arrivals.ts +19 -0
- package/src/hooks/use-breakpoint.ts +100 -0
- package/src/hooks/use-media-query.ts +36 -0
- package/src/hooks/use-theme.ts +67 -0
- package/src/hooks/use-url-state.ts +77 -0
- package/src/lib/breakpoints.ts +81 -0
- package/src/lib/csp-nonce.ts +15 -0
- package/src/lib/format.ts +291 -0
- package/src/lib/speech-level.ts +118 -0
- package/src/lib/utils.ts +109 -0
- package/src/styles/oaiz/app.css +21 -0
- package/src/styles/oaiz/scrollbars.css +20 -0
- package/src/styles/oaiz/tokens.css +952 -0
- package/src/styles/oaiz/voice-orb.css +39 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useId,
|
|
4
|
+
useState,
|
|
5
|
+
type CSSProperties,
|
|
6
|
+
type MouseEvent,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from 'react';
|
|
9
|
+
|
|
10
|
+
import { cn } from '../lib/utils';
|
|
11
|
+
import { ErrorState, type ErrorStateProps } from './error-state';
|
|
12
|
+
import { Skeleton } from './ui/skeleton';
|
|
13
|
+
import { Text } from './ui/text';
|
|
14
|
+
import { Button } from './ui/button';
|
|
15
|
+
import { Checkbox } from './ui/checkbox';
|
|
16
|
+
|
|
17
|
+
export type CardGridKey = string | number;
|
|
18
|
+
|
|
19
|
+
export type CardGridImage = { src: string; alt: string };
|
|
20
|
+
|
|
21
|
+
export type CardGridProps<Row> = {
|
|
22
|
+
rows: Row[] | undefined;
|
|
23
|
+
rowKey: (row: Row) => CardGridKey;
|
|
24
|
+
/** The card's title and its accessible name, such as a product's name. */
|
|
25
|
+
title: (row: Row) => string;
|
|
26
|
+
/** One muted line under the title, such as "WD-1001 · Furniture". */
|
|
27
|
+
meta?: (row: Row) => ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* The picture in the card's media box. Without one, or when it does not load, the box shows
|
|
30
|
+
* `fallback` on a tint.
|
|
31
|
+
*/
|
|
32
|
+
image?: (row: Row) => CardGridImage | null | undefined;
|
|
33
|
+
/** What the media box shows without a picture, such as a category icon; the title's initials by default. */
|
|
34
|
+
fallback?: (row: Row) => ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* The fallback's colour: a number picks one of the five chart colours in turn, such as a
|
|
37
|
+
* category's index, so up to five categories never share one; a string, such as a category,
|
|
38
|
+
* always gets the same colour. The title by default.
|
|
39
|
+
*/
|
|
40
|
+
tint?: (row: Row) => number | string;
|
|
41
|
+
/** A small label on the media box's corner, such as `<Badge>Draft</Badge>`. */
|
|
42
|
+
badge?: (row: Row) => ReactNode;
|
|
43
|
+
/** The start of the card's last line, such as a `StatusDot`. */
|
|
44
|
+
status?: (row: Row) => ReactNode;
|
|
45
|
+
/** The end of the card's last line, such as a price. */
|
|
46
|
+
figure?: (row: Row) => ReactNode;
|
|
47
|
+
/** Opens a card: a click, or Enter or Space on the focused card. */
|
|
48
|
+
onOpen?: (row: Row) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Makes each card a link to this address, so it opens in a new tab too. A plain click calls
|
|
51
|
+
* `onOpen` instead of following it, when `onOpen` is set.
|
|
52
|
+
*/
|
|
53
|
+
href?: (row: Row) => string;
|
|
54
|
+
/** The open card, such as the record shown in a dialog; it shows a ring and `aria-current`. */
|
|
55
|
+
selected?: CardGridKey | null;
|
|
56
|
+
/** Bulk selection, independent of the open/current record. */
|
|
57
|
+
selectedKeys?: ReadonlySet<CardGridKey>;
|
|
58
|
+
onSelectedKeysChange?: (keys: Set<CardGridKey>) => void;
|
|
59
|
+
/** Independent controls; never nested inside the primary record link/button. */
|
|
60
|
+
actions?: (row: Row) => ReactNode;
|
|
61
|
+
/** Rich preview content below the primary record control. */
|
|
62
|
+
preview?: (row: Row) => ReactNode;
|
|
63
|
+
density?: 'default' | 'compact';
|
|
64
|
+
/** The grid's accessible name, such as "Products". */
|
|
65
|
+
label: string;
|
|
66
|
+
/** Shown in place of the grid when there are no rows. */
|
|
67
|
+
empty: ReactNode;
|
|
68
|
+
/** Cards on the grid stay while new ones load; with no rows, skeleton cards appear after a short wait. */
|
|
69
|
+
loading?: boolean;
|
|
70
|
+
/** Shown instead of the grid. */
|
|
71
|
+
error?: { message: string } | null;
|
|
72
|
+
onRetry?: () => void;
|
|
73
|
+
labels?: ErrorStateProps['labels'] & { select?: (name: string) => string };
|
|
74
|
+
/** The media box's shape; `none` leaves it out. */
|
|
75
|
+
aspect?: 'landscape' | 'square' | 'none';
|
|
76
|
+
/** The narrowest a card gets before the grid drops a column, from a large phone up. */
|
|
77
|
+
minCardWidth?: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const LOADING_CARDS = 8;
|
|
81
|
+
const SKELETON_DELAY_MS = 300;
|
|
82
|
+
const TINTS = [
|
|
83
|
+
'bg-chart-1/15 text-foreground',
|
|
84
|
+
'bg-chart-2/15 text-foreground',
|
|
85
|
+
'bg-chart-3/15 text-foreground',
|
|
86
|
+
'bg-chart-4/15 text-foreground',
|
|
87
|
+
'bg-chart-5/15 text-foreground',
|
|
88
|
+
];
|
|
89
|
+
const ASPECT = {
|
|
90
|
+
landscape: 'mobile:aspect-[4/3]',
|
|
91
|
+
square: 'mobile:aspect-square',
|
|
92
|
+
} as const;
|
|
93
|
+
|
|
94
|
+
/** True once `on` has held for `delay` ms, so a quick load shows no flash. */
|
|
95
|
+
function useAfterDelay(on: boolean, delay: number): boolean {
|
|
96
|
+
const [late, setLate] = useState(false);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (!on) {
|
|
99
|
+
setLate(false);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const timer = setTimeout(() => setLate(true), delay);
|
|
103
|
+
return () => clearTimeout(timer);
|
|
104
|
+
}, [on, delay]);
|
|
105
|
+
return on && late;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The same tint for the same value on every render and every device. */
|
|
109
|
+
function tintOf(value: number | string): string {
|
|
110
|
+
let index = 0;
|
|
111
|
+
if (typeof value === 'number') index = Math.abs(Math.trunc(value));
|
|
112
|
+
else
|
|
113
|
+
for (const char of value) index = (index * 31 + char.charCodeAt(0)) >>> 0;
|
|
114
|
+
return TINTS[index % TINTS.length]!;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function initials(title: string): string {
|
|
118
|
+
return title
|
|
119
|
+
.split(/\s+/)
|
|
120
|
+
.filter(Boolean)
|
|
121
|
+
.slice(0, 2)
|
|
122
|
+
.map((word) => word[0]!.toUpperCase())
|
|
123
|
+
.join('');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function Media({
|
|
127
|
+
image,
|
|
128
|
+
fallback,
|
|
129
|
+
tint,
|
|
130
|
+
aspect,
|
|
131
|
+
}: {
|
|
132
|
+
image: CardGridImage | null | undefined;
|
|
133
|
+
fallback: ReactNode;
|
|
134
|
+
tint: number | string;
|
|
135
|
+
aspect: 'landscape' | 'square';
|
|
136
|
+
}) {
|
|
137
|
+
const [failed, setFailed] = useState(false);
|
|
138
|
+
useEffect(() => setFailed(false), [image?.src]);
|
|
139
|
+
const showImage = image && !failed;
|
|
140
|
+
return (
|
|
141
|
+
<span
|
|
142
|
+
className={cn(
|
|
143
|
+
// On a phone the media is a thumbnail beside the text, so a column of cards stays scannable.
|
|
144
|
+
'relative flex size-20 shrink-0 items-center justify-center overflow-hidden rounded-md mobile:size-auto mobile:w-full mobile:rounded-none',
|
|
145
|
+
ASPECT[aspect],
|
|
146
|
+
showImage ? 'bg-muted' : tintOf(tint),
|
|
147
|
+
)}
|
|
148
|
+
>
|
|
149
|
+
{showImage ? (
|
|
150
|
+
<img
|
|
151
|
+
src={image.src}
|
|
152
|
+
alt={image.alt}
|
|
153
|
+
loading="lazy"
|
|
154
|
+
decoding="async"
|
|
155
|
+
className="size-full object-cover transition-transform duration-slow ease-move motion-safe:group-hover/card:scale-[1.03]"
|
|
156
|
+
onError={() => setFailed(true)}
|
|
157
|
+
/>
|
|
158
|
+
) : (
|
|
159
|
+
<span
|
|
160
|
+
aria-hidden="true"
|
|
161
|
+
className="flex items-center justify-center text-lg font-semibold mobile:text-2xl [&_svg]:size-6 mobile:[&_svg]:size-10"
|
|
162
|
+
>
|
|
163
|
+
{fallback}
|
|
164
|
+
</span>
|
|
165
|
+
)}
|
|
166
|
+
</span>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function SkeletonCard({
|
|
171
|
+
aspect,
|
|
172
|
+
}: {
|
|
173
|
+
aspect: CardGridProps<unknown>['aspect'];
|
|
174
|
+
}) {
|
|
175
|
+
return (
|
|
176
|
+
<li className="flex gap-inset overflow-hidden rounded-lg border bg-card max-mobile:p-inset mobile:flex-col mobile:gap-0">
|
|
177
|
+
{aspect !== 'none' && (
|
|
178
|
+
<Skeleton
|
|
179
|
+
className={cn(
|
|
180
|
+
'size-20 shrink-0 mobile:size-auto mobile:w-full mobile:rounded-none',
|
|
181
|
+
ASPECT[aspect ?? 'landscape'],
|
|
182
|
+
)}
|
|
183
|
+
/>
|
|
184
|
+
)}
|
|
185
|
+
<span className="flex min-w-0 flex-1 flex-col gap-inline mobile:p-inset">
|
|
186
|
+
<Skeleton className="h-4 w-3/4" />
|
|
187
|
+
<Skeleton className="h-3 w-1/2" />
|
|
188
|
+
<span className="flex justify-between gap-inline pt-1">
|
|
189
|
+
<Skeleton className="h-3 w-16" />
|
|
190
|
+
<Skeleton className="h-3 w-12" />
|
|
191
|
+
</span>
|
|
192
|
+
</span>
|
|
193
|
+
</li>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Records as cards in a responsive grid: one column of compact cards on a phone, as many columns
|
|
199
|
+
* as fit from a large phone up. A primary button or link presents the record; selection, actions
|
|
200
|
+
* and rich previews are independent siblings.
|
|
201
|
+
*/
|
|
202
|
+
export function CardGrid<Row>({
|
|
203
|
+
rows,
|
|
204
|
+
rowKey,
|
|
205
|
+
title,
|
|
206
|
+
meta,
|
|
207
|
+
image,
|
|
208
|
+
fallback,
|
|
209
|
+
tint,
|
|
210
|
+
badge,
|
|
211
|
+
status,
|
|
212
|
+
figure,
|
|
213
|
+
onOpen,
|
|
214
|
+
href,
|
|
215
|
+
selected,
|
|
216
|
+
selectedKeys,
|
|
217
|
+
onSelectedKeysChange,
|
|
218
|
+
actions,
|
|
219
|
+
preview,
|
|
220
|
+
density = 'default',
|
|
221
|
+
label,
|
|
222
|
+
empty,
|
|
223
|
+
loading = false,
|
|
224
|
+
error,
|
|
225
|
+
onRetry,
|
|
226
|
+
labels,
|
|
227
|
+
aspect = 'landscape',
|
|
228
|
+
minCardWidth,
|
|
229
|
+
}: CardGridProps<Row>) {
|
|
230
|
+
const id = useId();
|
|
231
|
+
const noRows = rows === undefined || rows.length === 0;
|
|
232
|
+
const waiting = loading && noRows;
|
|
233
|
+
const showSkeleton = useAfterDelay(waiting, SKELETON_DELAY_MS);
|
|
234
|
+
|
|
235
|
+
if (error) {
|
|
236
|
+
return (
|
|
237
|
+
<ErrorState
|
|
238
|
+
error={error}
|
|
239
|
+
onRetry={onRetry}
|
|
240
|
+
retrying={loading}
|
|
241
|
+
labels={labels}
|
|
242
|
+
/>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (noRows && !waiting) {
|
|
247
|
+
return (
|
|
248
|
+
<div data-testid="card-grid-empty">
|
|
249
|
+
{typeof empty === 'string' ? (
|
|
250
|
+
<Text
|
|
251
|
+
size="sm"
|
|
252
|
+
variant="muted"
|
|
253
|
+
className="px-page py-section text-center"
|
|
254
|
+
>
|
|
255
|
+
{empty}
|
|
256
|
+
</Text>
|
|
257
|
+
) : (
|
|
258
|
+
empty
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const columns = {
|
|
265
|
+
'--card-grid-min':
|
|
266
|
+
minCardWidth ?? (density === 'compact' ? '11rem' : '14rem'),
|
|
267
|
+
} as CSSProperties;
|
|
268
|
+
|
|
269
|
+
const toggle = (key: CardGridKey, checked: boolean) => {
|
|
270
|
+
const next = new Set(selectedKeys);
|
|
271
|
+
if (checked) next.add(key);
|
|
272
|
+
else next.delete(key);
|
|
273
|
+
onSelectedKeysChange?.(next);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
<ul
|
|
278
|
+
aria-label={label}
|
|
279
|
+
aria-busy={loading}
|
|
280
|
+
data-testid="card-grid"
|
|
281
|
+
style={columns}
|
|
282
|
+
className="grid grid-cols-1 gap-inset mobile:grid-cols-[repeat(auto-fill,minmax(min(var(--card-grid-min),100%),1fr))] mobile:gap-stack"
|
|
283
|
+
>
|
|
284
|
+
{waiting
|
|
285
|
+
? showSkeleton &&
|
|
286
|
+
Array.from({ length: LOADING_CARDS }, (_, index) => (
|
|
287
|
+
<SkeletonCard key={index} aspect={aspect} />
|
|
288
|
+
))
|
|
289
|
+
: rows!.map((row) => {
|
|
290
|
+
const key = rowKey(row);
|
|
291
|
+
const name = title(row);
|
|
292
|
+
const titleId = `${id}-${key}-title`;
|
|
293
|
+
const detailsId = `${id}-${key}-details`;
|
|
294
|
+
const isSelected =
|
|
295
|
+
selected !== undefined && selected !== null && selected === key;
|
|
296
|
+
const metaLine = meta?.(row);
|
|
297
|
+
const statusLine = status?.(row);
|
|
298
|
+
const figureLine = figure?.(row);
|
|
299
|
+
const badgeLine = badge?.(row);
|
|
300
|
+
const link = href?.(row);
|
|
301
|
+
const checked = selectedKeys?.has(key) ?? false;
|
|
302
|
+
const cardActions = actions?.(row);
|
|
303
|
+
const cardPreview = preview?.(row);
|
|
304
|
+
const interactive = link !== undefined || onOpen !== undefined;
|
|
305
|
+
const content = (
|
|
306
|
+
<>
|
|
307
|
+
{aspect !== 'none' && (
|
|
308
|
+
<Media
|
|
309
|
+
image={image?.(row)}
|
|
310
|
+
fallback={fallback ? fallback(row) : initials(name)}
|
|
311
|
+
tint={tint ? tint(row) : name}
|
|
312
|
+
aspect={aspect}
|
|
313
|
+
/>
|
|
314
|
+
)}
|
|
315
|
+
<span
|
|
316
|
+
className={cn(
|
|
317
|
+
'flex min-w-0 flex-1 flex-col gap-1',
|
|
318
|
+
density === 'compact'
|
|
319
|
+
? 'mobile:p-inline'
|
|
320
|
+
: 'mobile:p-inset',
|
|
321
|
+
)}
|
|
322
|
+
>
|
|
323
|
+
<Text
|
|
324
|
+
as="span"
|
|
325
|
+
id={titleId}
|
|
326
|
+
size="sm"
|
|
327
|
+
weight="medium"
|
|
328
|
+
className="line-clamp-2 break-words"
|
|
329
|
+
>
|
|
330
|
+
{name}
|
|
331
|
+
</Text>
|
|
332
|
+
<span
|
|
333
|
+
id={detailsId}
|
|
334
|
+
className="flex min-w-0 flex-1 flex-col gap-1"
|
|
335
|
+
>
|
|
336
|
+
{(metaLine || badgeLine) && (
|
|
337
|
+
<span className="flex min-w-0 items-center gap-inline">
|
|
338
|
+
{badgeLine && (
|
|
339
|
+
// From a large phone up the badge sits on the media's corner; it stays in the
|
|
340
|
+
// card's description either way.
|
|
341
|
+
<span
|
|
342
|
+
className={cn(
|
|
343
|
+
'flex shrink-0',
|
|
344
|
+
aspect !== 'none' &&
|
|
345
|
+
'mobile:absolute mobile:left-inline mobile:top-inline',
|
|
346
|
+
)}
|
|
347
|
+
>
|
|
348
|
+
{badgeLine}
|
|
349
|
+
</span>
|
|
350
|
+
)}
|
|
351
|
+
{metaLine && (
|
|
352
|
+
<Text
|
|
353
|
+
as="span"
|
|
354
|
+
size="xs"
|
|
355
|
+
variant="muted"
|
|
356
|
+
className="min-w-0 truncate"
|
|
357
|
+
>
|
|
358
|
+
{metaLine}
|
|
359
|
+
</Text>
|
|
360
|
+
)}
|
|
361
|
+
</span>
|
|
362
|
+
)}
|
|
363
|
+
{(statusLine || figureLine) && (
|
|
364
|
+
<span className="mt-auto flex min-w-0 items-center justify-between gap-inline pt-1">
|
|
365
|
+
<span className="min-w-0 truncate">{statusLine}</span>
|
|
366
|
+
{figureLine !== undefined && figureLine !== null && (
|
|
367
|
+
<Text
|
|
368
|
+
as="span"
|
|
369
|
+
size="sm"
|
|
370
|
+
weight="semibold"
|
|
371
|
+
className="shrink-0 tabular-nums"
|
|
372
|
+
>
|
|
373
|
+
{figureLine}
|
|
374
|
+
</Text>
|
|
375
|
+
)}
|
|
376
|
+
</span>
|
|
377
|
+
)}
|
|
378
|
+
</span>
|
|
379
|
+
</span>
|
|
380
|
+
</>
|
|
381
|
+
);
|
|
382
|
+
const cardClass = cn(
|
|
383
|
+
'group/card relative flex h-full w-full justify-start gap-inset whitespace-normal p-0 text-left text-card-foreground max-mobile:p-inset mobile:flex-col mobile:gap-0',
|
|
384
|
+
interactive &&
|
|
385
|
+
'cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring hover:bg-muted/50',
|
|
386
|
+
);
|
|
387
|
+
const shared = {
|
|
388
|
+
'aria-labelledby': titleId,
|
|
389
|
+
'aria-describedby': detailsId,
|
|
390
|
+
'aria-current': isSelected ? ('true' as const) : undefined,
|
|
391
|
+
'data-testid': 'card-grid-card',
|
|
392
|
+
'data-state': isSelected ? 'selected' : undefined,
|
|
393
|
+
className: cardClass,
|
|
394
|
+
};
|
|
395
|
+
return (
|
|
396
|
+
<li
|
|
397
|
+
key={key}
|
|
398
|
+
className={cn(
|
|
399
|
+
'flex min-w-0 flex-col overflow-hidden rounded-lg border bg-card text-card-foreground',
|
|
400
|
+
(isSelected || checked) &&
|
|
401
|
+
'border-primary ring-2 ring-primary/30',
|
|
402
|
+
)}
|
|
403
|
+
>
|
|
404
|
+
{(onSelectedKeysChange || cardActions) && (
|
|
405
|
+
<div className="flex items-center justify-between gap-inline px-inline py-inline">
|
|
406
|
+
{onSelectedKeysChange && (
|
|
407
|
+
<Checkbox
|
|
408
|
+
aria-label={labels?.select?.(name) ?? `Select ${name}`}
|
|
409
|
+
checked={checked}
|
|
410
|
+
onCheckedChange={(value) => toggle(key, value === true)}
|
|
411
|
+
/>
|
|
412
|
+
)}
|
|
413
|
+
{cardActions && (
|
|
414
|
+
<div className="ml-auto flex min-w-0 items-center gap-inline">
|
|
415
|
+
{cardActions}
|
|
416
|
+
</div>
|
|
417
|
+
)}
|
|
418
|
+
</div>
|
|
419
|
+
)}
|
|
420
|
+
{link !== undefined ? (
|
|
421
|
+
<a
|
|
422
|
+
{...shared}
|
|
423
|
+
href={link}
|
|
424
|
+
onClick={(event: MouseEvent<HTMLAnchorElement>) => {
|
|
425
|
+
if (
|
|
426
|
+
!onOpen ||
|
|
427
|
+
event.metaKey ||
|
|
428
|
+
event.ctrlKey ||
|
|
429
|
+
event.shiftKey ||
|
|
430
|
+
event.altKey ||
|
|
431
|
+
event.button !== 0
|
|
432
|
+
)
|
|
433
|
+
return;
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
onOpen(row);
|
|
436
|
+
}}
|
|
437
|
+
>
|
|
438
|
+
{content}
|
|
439
|
+
</a>
|
|
440
|
+
) : onOpen ? (
|
|
441
|
+
<Button
|
|
442
|
+
{...shared}
|
|
443
|
+
variant="plain"
|
|
444
|
+
size={null}
|
|
445
|
+
shape={null}
|
|
446
|
+
type="button"
|
|
447
|
+
onClick={() => onOpen(row)}
|
|
448
|
+
>
|
|
449
|
+
{content}
|
|
450
|
+
</Button>
|
|
451
|
+
) : (
|
|
452
|
+
<article {...shared}>{content}</article>
|
|
453
|
+
)}
|
|
454
|
+
{cardPreview && (
|
|
455
|
+
<div className="min-w-0 border-t p-inline">{cardPreview}</div>
|
|
456
|
+
)}
|
|
457
|
+
</li>
|
|
458
|
+
);
|
|
459
|
+
})}
|
|
460
|
+
</ul>
|
|
461
|
+
);
|
|
462
|
+
}
|