@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,227 @@
1
+ import {
2
+ useRef,
3
+ useState,
4
+ type FormEvent,
5
+ type KeyboardEvent,
6
+ type ReactNode,
7
+ } from 'react';
8
+
9
+ import { ARRIVAL_CLASS, useArrivals } from '../hooks/use-arrivals';
10
+ import { formatDateTime, formatRelative } from '../lib/format';
11
+ import { cn } from '../lib/utils';
12
+ import { RecordMark } from './record-name';
13
+ import { Button } from './ui/button';
14
+ import { Text } from './ui/text';
15
+ import { Textarea } from './ui/textarea';
16
+
17
+ export type ActivityItem = {
18
+ id: string | number;
19
+ /** Who did it, by name. */
20
+ actor: string;
21
+ /** When it happened: a Date, an ISO timestamp or epoch milliseconds. */
22
+ at: Date | string | number;
23
+ } & (
24
+ | { kind: 'comment'; body: ReactNode }
25
+ /** A change, written as what happened, such as "moved this to Proposal". */
26
+ | { kind: 'change'; summary: ReactNode }
27
+ );
28
+
29
+ export type ActivityTimelineProps = {
30
+ /** Oldest first, as a conversation reads. */
31
+ items: ActivityItem[];
32
+ /** Adds a comment box; resolve it once the comment is saved, reject it to keep the text. */
33
+ onComment?: (body: string) => Promise<unknown>;
34
+ /** Shown when there is nothing yet. */
35
+ empty?: ReactNode;
36
+ className?: string;
37
+ locale?: string;
38
+ labels?: Partial<ActivityLabels>;
39
+ };
40
+
41
+ export type ActivityLabels = {
42
+ activity: string;
43
+ empty: string;
44
+ comment: string;
45
+ placeholder: string;
46
+ saving: string;
47
+ saveError: string;
48
+ };
49
+ const defaults: ActivityLabels = {
50
+ activity: 'Activity',
51
+ empty: 'No activity yet.',
52
+ comment: 'Comment',
53
+ placeholder: 'Leave a comment…',
54
+ saving: 'Saving…',
55
+ saveError: 'The comment was not saved. Try again.',
56
+ };
57
+
58
+ /**
59
+ * What happened to one record, oldest first: comments as messages and changes as one quiet line,
60
+ * each with how long ago, and the exact time on hover. With `onComment` a box under it adds a
61
+ * comment; ⌘ or Ctrl and Enter sends it.
62
+ */
63
+ export function ActivityTimeline({
64
+ items,
65
+ onComment,
66
+ empty,
67
+ className,
68
+ locale,
69
+ labels: suppliedLabels,
70
+ }: ActivityTimelineProps) {
71
+ const labels = { ...defaults, ...suppliedLabels };
72
+ const arrived = useArrivals(items.map((item) => item.id));
73
+ return (
74
+ <section
75
+ aria-label={labels.activity}
76
+ className={cn('flex flex-col gap-stack', className)}
77
+ >
78
+ {items.length === 0 ? (
79
+ <Text size="sm" variant="muted">
80
+ {empty ?? labels.empty}
81
+ </Text>
82
+ ) : (
83
+ <ol className="flex flex-col">
84
+ {items.map((item, index) => (
85
+ <li
86
+ key={item.id}
87
+ className={cn(
88
+ 'relative flex gap-inline pb-stack last:pb-0',
89
+ arrived(item.id) && ARRIVAL_CLASS,
90
+ )}
91
+ >
92
+ {index < items.length - 1 && (
93
+ <span
94
+ aria-hidden="true"
95
+ className="absolute top-6 bottom-0 left-0 flex w-5 justify-center"
96
+ >
97
+ <span className="w-px bg-border" />
98
+ </span>
99
+ )}
100
+ <span className="relative flex size-5 shrink-0 items-center justify-center">
101
+ {item.kind === 'comment' ? (
102
+ <RecordMark name={item.actor} round />
103
+ ) : (
104
+ <span
105
+ aria-hidden="true"
106
+ className="size-2 rounded-full bg-muted-foreground/60 ring-4 ring-background"
107
+ />
108
+ )}
109
+ </span>
110
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
111
+ <Text
112
+ size="sm"
113
+ variant={item.kind === 'change' ? 'muted' : 'default'}
114
+ className="flex flex-wrap items-baseline gap-x-1.5"
115
+ >
116
+ <Text as="span" size="sm" weight="medium" variant="default">
117
+ {item.actor}
118
+ </Text>
119
+ {item.kind === 'change' && <span>{item.summary}</span>}
120
+ <When at={item.at} locale={locale} />
121
+ </Text>
122
+ {item.kind === 'comment' && (
123
+ <div className="rounded-md bg-muted px-inset py-inline">
124
+ <Text size="sm" className="whitespace-pre-wrap break-words">
125
+ {item.body}
126
+ </Text>
127
+ </div>
128
+ )}
129
+ </div>
130
+ </li>
131
+ ))}
132
+ </ol>
133
+ )}
134
+ {onComment && <CommentBox onComment={onComment} labels={labels} />}
135
+ </section>
136
+ );
137
+ }
138
+
139
+ /** How long ago, with the exact time on hover; nothing for a time that does not parse. */
140
+ function When({ at, locale }: { at: ActivityItem['at']; locale?: string }) {
141
+ const date = new Date(at);
142
+ if (Number.isNaN(date.getTime())) return null;
143
+ return (
144
+ <Text asChild size="xs" variant="muted">
145
+ <time
146
+ dateTime={date.toISOString()}
147
+ title={formatDateTime(date, { locale })}
148
+ >
149
+ {formatRelative(date, { locale })}
150
+ </time>
151
+ </Text>
152
+ );
153
+ }
154
+
155
+ function CommentBox({
156
+ onComment,
157
+ labels,
158
+ }: {
159
+ onComment: (body: string) => Promise<unknown>;
160
+ labels: ActivityLabels;
161
+ }) {
162
+ const inFlight = useRef(false);
163
+ const [body, setBody] = useState('');
164
+ const [pending, setPending] = useState(false);
165
+ const [failed, setFailed] = useState(false);
166
+
167
+ async function send(event?: FormEvent) {
168
+ event?.preventDefault();
169
+ const text = body.trim();
170
+ if (!text || inFlight.current) return;
171
+ inFlight.current = true;
172
+ setPending(true);
173
+ setFailed(false);
174
+ try {
175
+ await onComment(text);
176
+ setBody('');
177
+ } catch {
178
+ setFailed(true);
179
+ } finally {
180
+ inFlight.current = false;
181
+ setPending(false);
182
+ }
183
+ }
184
+
185
+ function onKeyDown(event: KeyboardEvent<HTMLTextAreaElement>) {
186
+ if (
187
+ event.key === 'Enter' &&
188
+ (event.metaKey || event.ctrlKey) &&
189
+ !event.nativeEvent.isComposing
190
+ ) {
191
+ event.preventDefault();
192
+ void send();
193
+ }
194
+ }
195
+
196
+ return (
197
+ <form className="flex flex-col gap-inline" onSubmit={send}>
198
+ <Textarea
199
+ aria-label={labels.comment}
200
+ disabled={pending}
201
+ placeholder={labels.placeholder}
202
+ value={body}
203
+ rows={2}
204
+ onChange={(event) => {
205
+ if (!inFlight.current) setBody(event.target.value);
206
+ }}
207
+ onKeyDown={onKeyDown}
208
+ className="min-h-16 resize-y"
209
+ />
210
+ <div className="flex items-center justify-end gap-inline">
211
+ {failed && (
212
+ <Text
213
+ size="sm"
214
+ variant="destructive"
215
+ role="alert"
216
+ className="mr-auto"
217
+ >
218
+ {labels.saveError}
219
+ </Text>
220
+ )}
221
+ <Button type="submit" size="sm" disabled={!body.trim() || pending}>
222
+ {pending ? labels.saving : labels.comment}
223
+ </Button>
224
+ </div>
225
+ </form>
226
+ );
227
+ }