@oaiz/app-kit 0.0.0-stage → 0.1.4128

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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -2
  3. package/THIRD_PARTY_NOTICES.md +76 -0
  4. package/package.json +139 -4
  5. package/registry.json +1847 -0
  6. package/src/components/activity-timeline.tsx +227 -0
  7. package/src/components/app-shell.tsx +622 -0
  8. package/src/components/bar-list.tsx +47 -0
  9. package/src/components/board.tsx +700 -0
  10. package/src/components/calendar-view.tsx +1388 -0
  11. package/src/components/card-grid.tsx +462 -0
  12. package/src/components/charts.tsx +701 -0
  13. package/src/components/chat-markdown.tsx +230 -0
  14. package/src/components/chat-panel.tsx +760 -0
  15. package/src/components/code-editor.tsx +276 -0
  16. package/src/components/collection-controls.tsx +226 -0
  17. package/src/components/command-palette.tsx +403 -0
  18. package/src/components/confirm-action.tsx +123 -0
  19. package/src/components/data-table.tsx +821 -0
  20. package/src/components/date-input.tsx +429 -0
  21. package/src/components/empty-state.tsx +31 -0
  22. package/src/components/error-state.tsx +37 -0
  23. package/src/components/file-upload.tsx +595 -0
  24. package/src/components/filter-bar.tsx +415 -0
  25. package/src/components/grouped-picker.tsx +250 -0
  26. package/src/components/line-items.tsx +601 -0
  27. package/src/components/list-view.tsx +491 -0
  28. package/src/components/metrics.tsx +53 -0
  29. package/src/components/page-header.tsx +33 -0
  30. package/src/components/property-picker.tsx +546 -0
  31. package/src/components/record-detail.tsx +416 -0
  32. package/src/components/record-form.tsx +295 -0
  33. package/src/components/record-name.tsx +85 -0
  34. package/src/components/save-bar.tsx +142 -0
  35. package/src/components/sign-in.tsx +179 -0
  36. package/src/components/split-view.tsx +128 -0
  37. package/src/components/status-dot.tsx +56 -0
  38. package/src/components/stepper.tsx +153 -0
  39. package/src/components/text-diff-model.ts +111 -0
  40. package/src/components/text-diff.tsx +98 -0
  41. package/src/components/time-zone-picker.tsx +69 -0
  42. package/src/components/ui/accordion.tsx +138 -0
  43. package/src/components/ui/alert-dialog.tsx +67 -0
  44. package/src/components/ui/alert.tsx +65 -0
  45. package/src/components/ui/avatar-group.tsx +119 -0
  46. package/src/components/ui/avatar.tsx +55 -0
  47. package/src/components/ui/badge.tsx +59 -0
  48. package/src/components/ui/bottom-navigation.tsx +102 -0
  49. package/src/components/ui/breadcrumb.tsx +117 -0
  50. package/src/components/ui/button.tsx +71 -0
  51. package/src/components/ui/card.tsx +95 -0
  52. package/src/components/ui/checkbox.tsx +31 -0
  53. package/src/components/ui/collapsible.tsx +27 -0
  54. package/src/components/ui/context-menu.tsx +270 -0
  55. package/src/components/ui/count-up.tsx +136 -0
  56. package/src/components/ui/detail-disclosure-section.tsx +109 -0
  57. package/src/components/ui/dialog.tsx +157 -0
  58. package/src/components/ui/dropdown-menu.tsx +273 -0
  59. package/src/components/ui/form-field.tsx +155 -0
  60. package/src/components/ui/heading.tsx +126 -0
  61. package/src/components/ui/hover-card.tsx +45 -0
  62. package/src/components/ui/input.tsx +50 -0
  63. package/src/components/ui/label.tsx +30 -0
  64. package/src/components/ui/orb-spinner.tsx +238 -0
  65. package/src/components/ui/popover.tsx +59 -0
  66. package/src/components/ui/progress-ring.tsx +125 -0
  67. package/src/components/ui/progress.tsx +38 -0
  68. package/src/components/ui/radio-group.tsx +124 -0
  69. package/src/components/ui/resizable.tsx +48 -0
  70. package/src/components/ui/scroll-fade.tsx +98 -0
  71. package/src/components/ui/segmented-control.tsx +70 -0
  72. package/src/components/ui/select.tsx +230 -0
  73. package/src/components/ui/separator.tsx +29 -0
  74. package/src/components/ui/sheet.tsx +170 -0
  75. package/src/components/ui/shimmer-text.tsx +87 -0
  76. package/src/components/ui/shortcut.tsx +39 -0
  77. package/src/components/ui/skeleton.tsx +15 -0
  78. package/src/components/ui/slider.tsx +48 -0
  79. package/src/components/ui/switch.tsx +44 -0
  80. package/src/components/ui/table.tsx +119 -0
  81. package/src/components/ui/tabs.tsx +80 -0
  82. package/src/components/ui/text.tsx +93 -0
  83. package/src/components/ui/textarea.tsx +51 -0
  84. package/src/components/ui/toast.tsx +141 -0
  85. package/src/components/ui/toaster.tsx +40 -0
  86. package/src/components/ui/tooltip.tsx +38 -0
  87. package/src/components/ui/top-banner.tsx +108 -0
  88. package/src/components/ui/tree-view.tsx +215 -0
  89. package/src/components/ui/use-toast.tsx +184 -0
  90. package/src/components/ui/voice-orb.tsx +252 -0
  91. package/src/hooks/oaiz-chat.tsx +530 -0
  92. package/src/hooks/oaiz-data.tsx +617 -0
  93. package/src/hooks/oaiz-session.tsx +63 -0
  94. package/src/hooks/use-arrivals.ts +19 -0
  95. package/src/hooks/use-breakpoint.ts +100 -0
  96. package/src/hooks/use-media-query.ts +36 -0
  97. package/src/hooks/use-theme.ts +67 -0
  98. package/src/hooks/use-url-state.ts +77 -0
  99. package/src/lib/breakpoints.ts +81 -0
  100. package/src/lib/csp-nonce.ts +15 -0
  101. package/src/lib/format.ts +291 -0
  102. package/src/lib/speech-level.ts +118 -0
  103. package/src/lib/utils.ts +109 -0
  104. package/src/styles/oaiz/app.css +21 -0
  105. package/src/styles/oaiz/scrollbars.css +20 -0
  106. package/src/styles/oaiz/tokens.css +952 -0
  107. package/src/styles/oaiz/voice-orb.css +39 -0
@@ -0,0 +1,85 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import { cn } from '../lib/utils';
4
+ import { Avatar, AvatarFallback } from './ui/avatar';
5
+
6
+ export type RecordNameProps = {
7
+ name: string;
8
+ /** A circle for a person, a square for a company or other thing. */
9
+ round?: boolean;
10
+ /** Compact inline mark or the Avatar primitive's default size. */
11
+ size?: 'compact' | 'default';
12
+ /** Muted text after the name, such as a job title. */
13
+ detail?: ReactNode;
14
+ className?: string;
15
+ };
16
+
17
+ function initialsOf(name: string): string {
18
+ return name
19
+ .split(/\s+/)
20
+ .filter(Boolean)
21
+ .slice(0, 2)
22
+ .map((word) => word[0]!.toUpperCase())
23
+ .join('');
24
+ }
25
+
26
+ const MARKS = [
27
+ 'bg-integration-icon-blue/15',
28
+ 'bg-integration-icon-emerald/15',
29
+ 'bg-integration-icon-amber/15',
30
+ 'bg-integration-icon-violet/15',
31
+ 'bg-integration-icon-coral/15',
32
+ 'bg-integration-icon-teal/15',
33
+ 'bg-integration-icon-indigo/15',
34
+ 'bg-integration-icon-rose/15',
35
+ ];
36
+
37
+ function markOf(name: string): string {
38
+ let sum = 0;
39
+ for (const character of name) sum += character.codePointAt(0)!;
40
+ return MARKS[sum % MARKS.length]!;
41
+ }
42
+
43
+ /** A small mark of a record's initials, coloured by its name, as the icon of a palette item or a card. */
44
+ export function RecordMark({
45
+ name,
46
+ round = false,
47
+ size = 'compact',
48
+ }: Pick<RecordNameProps, 'name' | 'round' | 'size'>) {
49
+ return (
50
+ <Avatar
51
+ aria-hidden="true"
52
+ className={cn(size === 'compact' && 'size-5', !round && 'rounded-md')}
53
+ >
54
+ <AvatarFallback
55
+ className={cn(
56
+ 'font-semibold text-foreground',
57
+ size === 'compact' && 'text-2xs',
58
+ markOf(name),
59
+ !round && 'rounded-md',
60
+ )}
61
+ >
62
+ {initialsOf(name)}
63
+ </AvatarFallback>
64
+ </Avatar>
65
+ );
66
+ }
67
+
68
+ /** A record's name after its mark, so that a list scans by who or what it is. */
69
+ export function RecordName({
70
+ name,
71
+ round = false,
72
+ size = 'compact',
73
+ detail,
74
+ className,
75
+ }: RecordNameProps) {
76
+ return (
77
+ <span className={cn('flex min-w-0 items-center gap-inline', className)}>
78
+ <RecordMark name={name} round={round} size={size} />
79
+ <span className="truncate font-medium">{name}</span>
80
+ {detail && (
81
+ <span className="truncate text-muted-foreground">{detail}</span>
82
+ )}
83
+ </span>
84
+ );
85
+ }
@@ -0,0 +1,142 @@
1
+ import { useRef, useState, type ReactNode } from 'react';
2
+ import { cn } from '../lib/utils';
3
+ import { ConfirmAction } from './confirm-action';
4
+ import { Button } from './ui/button';
5
+ import { Text } from './ui/text';
6
+
7
+ export type SaveBarLabels = {
8
+ dirty: string;
9
+ saving: string;
10
+ saved: string;
11
+ error: string;
12
+ save: string;
13
+ discard: string;
14
+ };
15
+ const defaults: SaveBarLabels = {
16
+ dirty: 'Unsaved changes',
17
+ saving: 'Saving…',
18
+ saved: 'Saved',
19
+ error: 'Changes could not be saved.',
20
+ save: 'Save changes',
21
+ discard: 'Discard',
22
+ };
23
+ export type SaveBarProps = {
24
+ dirty: boolean;
25
+ saving?: boolean;
26
+ saved?: boolean;
27
+ error?: { message: string } | null;
28
+ onSave: () => unknown;
29
+ onDiscard: () => void;
30
+ labels?: Partial<SaveBarLabels>;
31
+ className?: string;
32
+ };
33
+ export function SaveBar({
34
+ dirty,
35
+ saving = false,
36
+ saved = false,
37
+ error,
38
+ onSave,
39
+ onDiscard,
40
+ labels: suppliedLabels,
41
+ className,
42
+ }: SaveBarProps) {
43
+ const labels = { ...defaults, ...suppliedLabels };
44
+ const [pending, setPending] = useState(false);
45
+ const [failure, setFailure] = useState<string | null>(null);
46
+ const inFlight = useRef(false);
47
+ const busy = saving || pending;
48
+ async function save() {
49
+ if (!dirty || saving || inFlight.current) return;
50
+ inFlight.current = true;
51
+ setPending(true);
52
+ setFailure(null);
53
+ try {
54
+ await onSave();
55
+ } catch (cause) {
56
+ setFailure(cause instanceof Error ? cause.message : labels.error);
57
+ } finally {
58
+ inFlight.current = false;
59
+ setPending(false);
60
+ }
61
+ }
62
+ if (!dirty && !busy && !saved && !error && !failure) return null;
63
+ return (
64
+ <div
65
+ className={cn(
66
+ 'flex flex-wrap items-center justify-between gap-inline rounded-md border bg-background p-inset',
67
+ className,
68
+ )}
69
+ aria-busy={busy}
70
+ >
71
+ <Text
72
+ size="sm"
73
+ role={error || failure ? 'alert' : 'status'}
74
+ variant={error || failure ? 'destructive' : 'muted'}
75
+ >
76
+ {error?.message ??
77
+ failure ??
78
+ (busy ? labels.saving : dirty ? labels.dirty : labels.saved)}
79
+ </Text>
80
+ {dirty && (
81
+ <div className="flex gap-inline">
82
+ <Button
83
+ type="button"
84
+ variant="outline"
85
+ disabled={busy}
86
+ onClick={() => {
87
+ if (!inFlight.current) {
88
+ setFailure(null);
89
+ onDiscard();
90
+ }
91
+ }}
92
+ >
93
+ {labels.discard}
94
+ </Button>
95
+ <Button type="button" disabled={busy} onClick={() => void save()}>
96
+ {busy ? labels.saving : labels.save}
97
+ </Button>
98
+ </div>
99
+ )}
100
+ </div>
101
+ );
102
+ }
103
+
104
+ export type UnsavedChangesProps = {
105
+ /** The consuming router/dialog sets open when a dirty editor requests to leave. */
106
+ open: boolean;
107
+ onOpenChange: (open: boolean) => void;
108
+ onDiscard: () => unknown;
109
+ title?: ReactNode;
110
+ description?: ReactNode;
111
+ discardLabel?: string;
112
+ keepEditingLabel?: string;
113
+ pendingLabel?: string;
114
+ errorLabel?: string;
115
+ };
116
+ /** Explicit navigation policy: close without discarding to keep editing; resolve discard to leave. */
117
+ export function UnsavedChanges({
118
+ open,
119
+ onOpenChange,
120
+ onDiscard,
121
+ title = 'Discard unsaved changes?',
122
+ description = 'Your changes have not been saved.',
123
+ discardLabel = 'Discard changes',
124
+ keepEditingLabel = 'Keep editing',
125
+ pendingLabel,
126
+ errorLabel,
127
+ }: UnsavedChangesProps) {
128
+ return (
129
+ <ConfirmAction
130
+ open={open}
131
+ onOpenChange={onOpenChange}
132
+ title={title}
133
+ description={description}
134
+ confirmLabel={discardLabel}
135
+ cancelLabel={keepEditingLabel}
136
+ pendingLabel={pendingLabel}
137
+ errorLabel={errorLabel}
138
+ onConfirm={onDiscard}
139
+ destructive
140
+ />
141
+ );
142
+ }
@@ -0,0 +1,179 @@
1
+ import { useEffect, useState, type ReactNode } from 'react';
2
+ import type { OaizAuth, OaizUser } from '@oaiz/sdk';
3
+
4
+ import { useOaizSession } from '../hooks/oaiz-session';
5
+ import { Alert, AlertDescription, AlertTitle } from './ui/alert';
6
+ import { Button } from './ui/button';
7
+ import { Heading } from './ui/heading';
8
+ import { Skeleton } from './ui/skeleton';
9
+ import { Text } from './ui/text';
10
+
11
+ export type SignInScreenProps = {
12
+ title?: ReactNode;
13
+ /** Use a div when this screen is embedded inside an existing page landmark. */
14
+ as?: 'main' | 'div';
15
+ errorTitle?: ReactNode;
16
+ description?: ReactNode;
17
+ /** Shown above the title, for example the app's logo. */
18
+ logo?: ReactNode;
19
+ signInLabel?: ReactNode;
20
+ onSignIn: () => unknown;
21
+ loading?: boolean;
22
+ error?: { message: string } | null;
23
+ /** Small text under the card. */
24
+ footer?: ReactNode;
25
+ };
26
+
27
+ /** A centred sign-in card with its loading and error states. */
28
+ export function SignInScreen({
29
+ title = 'Welcome',
30
+ as: Container = 'main',
31
+ errorTitle = 'Something went wrong',
32
+ description = 'Sign in with your OAIZ account to continue.',
33
+ logo,
34
+ signInLabel = 'Sign in with OAIZ',
35
+ onSignIn,
36
+ loading = false,
37
+ error,
38
+ footer,
39
+ }: SignInScreenProps) {
40
+ const [pending, setPending] = useState(false);
41
+
42
+ async function signIn() {
43
+ setPending(true);
44
+ try {
45
+ await onSignIn();
46
+ } finally {
47
+ setPending(false);
48
+ }
49
+ }
50
+
51
+ return (
52
+ <Container
53
+ aria-busy={loading}
54
+ className="flex min-h-svh flex-col items-center justify-center gap-stack bg-muted p-page"
55
+ >
56
+ <section className="flex w-full max-w-sm flex-col gap-section rounded-lg border bg-card p-section text-card-foreground shadow-sm">
57
+ {loading ? (
58
+ <div className="flex flex-col items-center gap-stack">
59
+ <Skeleton className="size-12 rounded-full" />
60
+ <Skeleton className="h-6 w-40" />
61
+ <Skeleton className="h-4 w-56" />
62
+ <Skeleton className="h-10 w-full" />
63
+ </div>
64
+ ) : (
65
+ <>
66
+ <div className="flex flex-col items-center gap-stack text-center">
67
+ {logo}
68
+ <div className="flex flex-col gap-1">
69
+ <Heading level={1} size="2xl">
70
+ {title}
71
+ </Heading>
72
+ <Text variant="muted">{description}</Text>
73
+ </div>
74
+ </div>
75
+ <Button
76
+ size="lg"
77
+ className="w-full"
78
+ disabled={pending}
79
+ onClick={() => void signIn()}
80
+ >
81
+ {signInLabel}
82
+ </Button>
83
+ </>
84
+ )}
85
+ {error && (
86
+ <Alert variant="destructive">
87
+ <AlertTitle level={2}>{errorTitle}</AlertTitle>
88
+ <AlertDescription className="break-words">
89
+ {error.message}
90
+ </AlertDescription>
91
+ </Alert>
92
+ )}
93
+ </section>
94
+ {footer && (
95
+ <Text size="xs" variant="muted">
96
+ {footer}
97
+ </Text>
98
+ )}
99
+ </Container>
100
+ );
101
+ }
102
+
103
+ export type SessionGateProps = Omit<
104
+ SignInScreenProps,
105
+ 'onSignIn' | 'loading' | 'error'
106
+ > & {
107
+ /** `client.auth` of the app's `@oaiz/sdk` client. */
108
+ auth: OaizAuth;
109
+ /**
110
+ * Signs the member in without a click, once, while the page is framed.
111
+ * OAIZ frames only an app's canvas preview, where the member is already
112
+ * signed in to OAIZ. Pass `false` to always show the sign-in screen.
113
+ */
114
+ autoSignIn?: boolean;
115
+ /** The app, for a signed-in member. */
116
+ children: (session: {
117
+ user: OaizUser;
118
+ signOut: () => Promise<void>;
119
+ }) => ReactNode;
120
+ };
121
+
122
+ const AUTO_SIGN_IN_KEY = 'oaiz.autoSignIn';
123
+
124
+ function isFramed() {
125
+ try {
126
+ return window.self !== window.top;
127
+ } catch {
128
+ return true;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Shows the sign-in screen until a member is signed in, then the app. In a
134
+ * frame it starts the sign-in itself, once per tab: the mark it leaves stops a
135
+ * refused sign-in or a sign-out from starting another until the member is
136
+ * signed in again.
137
+ */
138
+ export function SessionGate({
139
+ auth,
140
+ children,
141
+ autoSignIn = isFramed(),
142
+ ...screen
143
+ }: SessionGateProps) {
144
+ const session = useOaizSession(auth);
145
+ const { status, signIn } = session;
146
+ const [starting, setStarting] = useState(false);
147
+
148
+ useEffect(() => {
149
+ if (!autoSignIn) return;
150
+ if (status === 'signed-in') {
151
+ sessionStorage.removeItem(AUTO_SIGN_IN_KEY);
152
+ return;
153
+ }
154
+ if (status !== 'signed-out' || sessionStorage.getItem(AUTO_SIGN_IN_KEY)) {
155
+ return;
156
+ }
157
+ sessionStorage.setItem(AUTO_SIGN_IN_KEY, '1');
158
+ setStarting(true);
159
+ void signIn();
160
+ }, [autoSignIn, status, signIn]);
161
+
162
+ if (status === 'signed-in' && session.user) {
163
+ return children({
164
+ user: session.user,
165
+ signOut: async () => {
166
+ sessionStorage.setItem(AUTO_SIGN_IN_KEY, '1');
167
+ await session.signOut();
168
+ },
169
+ });
170
+ }
171
+ return (
172
+ <SignInScreen
173
+ {...screen}
174
+ loading={status === 'loading' || (starting && !session.error)}
175
+ error={session.error}
176
+ onSignIn={signIn}
177
+ />
178
+ );
179
+ }
@@ -0,0 +1,128 @@
1
+ import { useEffect, useRef, type ReactNode } from 'react';
2
+ import { ArrowLeft } from 'lucide-react';
3
+
4
+ import { useBreakpointBelow } from '../hooks/use-breakpoint';
5
+ import { cn } from '../lib/utils';
6
+ import { Button } from './ui/button';
7
+
8
+ export type SplitViewProps = {
9
+ /** The records to choose from, such as a `ListView` or a `ul`. */
10
+ list: ReactNode;
11
+ /** The list pane's accessible name, such as "Tickets". */
12
+ listLabel: string;
13
+ /** The open record; `null` or `undefined` while none is open. */
14
+ detail?: ReactNode;
15
+ /** The open record's name, such as a ticket's subject: the detail pane's accessible name. */
16
+ detailLabel?: string;
17
+ /** The open record's key, so each record opens at the top of its pane. */
18
+ detailKey?: string | number;
19
+ /** Closes the record: the phone's Back button calls it. */
20
+ onBack: () => void;
21
+ /** The Back button's text. */
22
+ backLabel?: string;
23
+ /**
24
+ * Fills the detail pane from `half` up while no record is open, such as an `EmptyState`. Without
25
+ * it the list takes the full width until a record opens.
26
+ */
27
+ placeholder?: ReactNode;
28
+ className?: string;
29
+ };
30
+
31
+ /**
32
+ * A list and the record opened from it, side by side from the `half` breakpoint, each pane
33
+ * scrolling on its own. On a phone the record replaces the list, with a Back button above it, and
34
+ * Back returns the focus to the list.
35
+ */
36
+ export function SplitView({
37
+ list,
38
+ listLabel,
39
+ detail,
40
+ detailLabel,
41
+ detailKey,
42
+ onBack,
43
+ backLabel = 'Back',
44
+ placeholder,
45
+ className,
46
+ }: SplitViewProps) {
47
+ const open = detail !== null && detail !== undefined && detail !== false;
48
+ const split = open || placeholder !== undefined;
49
+ const phone = useBreakpointBelow('half');
50
+ const listRef = useRef<HTMLDivElement>(null);
51
+ const detailRef = useRef<HTMLElement>(null);
52
+ const wentBack = useRef(false);
53
+ const origin = useRef<HTMLElement | null>(null);
54
+ const scrollTop = useRef(0);
55
+
56
+ // On a phone the pane that appears takes the focus, as the one that held it is now hidden.
57
+ useEffect(() => {
58
+ if (!phone) return;
59
+ if (open) {
60
+ detailRef.current?.focus({ preventScroll: true });
61
+ } else if (wentBack.current) {
62
+ const target = origin.current?.isConnected
63
+ ? origin.current
64
+ : listRef.current;
65
+ target?.focus({ preventScroll: true });
66
+ if (listRef.current) listRef.current.scrollTop = scrollTop.current;
67
+ }
68
+ wentBack.current = false;
69
+ }, [phone, open, detailKey]);
70
+
71
+ return (
72
+ <div className={cn('flex h-full min-h-0', className)}>
73
+ <div
74
+ ref={listRef}
75
+ onFocusCapture={(event) => {
76
+ if (!open) {
77
+ origin.current = event.target;
78
+ scrollTop.current = event.currentTarget.scrollTop;
79
+ }
80
+ }}
81
+ onScroll={(event) => {
82
+ if (!open) scrollTop.current = event.currentTarget.scrollTop;
83
+ }}
84
+ role="region"
85
+ aria-label={listLabel}
86
+ tabIndex={-1}
87
+ className={cn(
88
+ 'min-h-0 min-w-0 flex-[2] overflow-y-auto outline-none',
89
+ split && 'half:max-w-md half:border-r',
90
+ open && 'max-half:hidden',
91
+ )}
92
+ >
93
+ {list}
94
+ </div>
95
+ {open ? (
96
+ <section
97
+ key={detailKey}
98
+ ref={detailRef}
99
+ aria-label={detailLabel}
100
+ tabIndex={0}
101
+ className="flex min-h-0 min-w-0 flex-[3] flex-col overflow-y-auto outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
102
+ >
103
+ <div className="sticky top-0 z-10 shrink-0 border-b bg-background px-page py-1 half:hidden">
104
+ <Button
105
+ variant="ghost"
106
+ size="sm"
107
+ className="-ml-3 max-mobile:h-11"
108
+ onClick={() => {
109
+ wentBack.current = true;
110
+ onBack();
111
+ }}
112
+ >
113
+ <ArrowLeft />
114
+ {backLabel}
115
+ </Button>
116
+ </div>
117
+ <div className="flex min-h-0 flex-1 flex-col">{detail}</div>
118
+ </section>
119
+ ) : (
120
+ placeholder !== undefined && (
121
+ <div className="hidden min-h-0 min-w-0 flex-[3] flex-col items-center justify-center overflow-y-auto half:flex">
122
+ {placeholder}
123
+ </div>
124
+ )
125
+ )}
126
+ </div>
127
+ );
128
+ }
@@ -0,0 +1,56 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import { cn } from '../lib/utils';
4
+
5
+ export type StatusDotTone =
6
+ | 'neutral'
7
+ | 'info'
8
+ | 'success'
9
+ | 'warning'
10
+ | 'danger';
11
+
12
+ export type StatusDotProps = {
13
+ children: ReactNode;
14
+ tone?: StatusDotTone;
15
+ className?: string;
16
+ };
17
+
18
+ /** Each tone's dot colour, for a mark beside a status that is not a `StatusDot`. */
19
+ export const STATUS_DOT_TONES: Record<StatusDotTone, string> = {
20
+ neutral: 'bg-muted-foreground',
21
+ info: 'bg-info-solid',
22
+ success: 'bg-success',
23
+ warning: 'bg-warning',
24
+ danger: 'bg-destructive',
25
+ };
26
+
27
+ /** A status as plain text with a small dot, so that it does not compete with the data around it. */
28
+ export function StatusDot({
29
+ children,
30
+ tone = 'neutral',
31
+ className,
32
+ }: StatusDotProps) {
33
+ return (
34
+ <span className={cn('inline-flex items-center gap-1.5 text-sm', className)}>
35
+ <StatusMark tone={tone} />
36
+ {children}
37
+ </span>
38
+ );
39
+ }
40
+
41
+ /** A decorative status mark beside a separately rendered label. */
42
+ export function StatusMark({
43
+ tone = 'neutral',
44
+ className,
45
+ }: Pick<StatusDotProps, 'tone' | 'className'>) {
46
+ return (
47
+ <span
48
+ aria-hidden="true"
49
+ className={cn(
50
+ 'size-2 shrink-0 rounded-full',
51
+ STATUS_DOT_TONES[tone],
52
+ className,
53
+ )}
54
+ />
55
+ );
56
+ }