@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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -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,230 @@
1
+ import { Table, TableHead, TableCell } from './ui/table';
2
+ import { Button } from './ui/button';
3
+ import { isValidElement, memo, useEffect, useMemo, useState, type ReactNode } from 'react';
4
+ import { Check, Copy } from 'lucide-react';
5
+ import ReactMarkdown, { type Components } from 'react-markdown';
6
+ import remarkBreaks from 'remark-breaks';
7
+ import remarkGfm from 'remark-gfm';
8
+
9
+ import { cn } from '../lib/utils';
10
+ import { Heading } from './ui/heading';
11
+ import { Text } from './ui/text';
12
+ import { ScrollFade } from './ui/scroll-fade';
13
+ import { Separator } from './ui/separator';
14
+
15
+ const LINK_CLASS = 'text-primary hover:underline';
16
+ const PROMOTE_STABLE_TEXT_MS = 125;
17
+
18
+ /** Sets `copied` for two seconds after the text is on the clipboard; a refused write sets nothing. */
19
+ export function useCopy(): { copied: boolean; copy: (text: string) => Promise<void> } {
20
+ const [copied, setCopied] = useState(false);
21
+ useEffect(() => {
22
+ if (!copied) return;
23
+ const timer = window.setTimeout(() => setCopied(false), 2000);
24
+ return () => window.clearTimeout(timer);
25
+ }, [copied]);
26
+ return {
27
+ copied,
28
+ copy: (text) =>
29
+ navigator.clipboard.writeText(text).then(
30
+ () => setCopied(true),
31
+ () => undefined,
32
+ ),
33
+ };
34
+ }
35
+
36
+ function CodeBlock({ language, source }: { language: string; source: string }) {
37
+ const { copied, copy } = useCopy();
38
+ return (
39
+ <div className="my-2 overflow-hidden rounded-lg" data-testid="chat-code-block">
40
+ {language && (
41
+ <div className="flex items-center justify-between bg-muted px-3 py-1.5 font-mono text-xs text-muted-foreground">
42
+ <span>{language}</span>
43
+ <Button variant="plain" size={null}
44
+ type="button"
45
+ // The pseudo-element makes the button 24px tall to a pointer or finger.
46
+ className="relative flex items-center gap-1 transition-colors duration-fast ease-move after:absolute after:-inset-y-1 after:inset-x-0 hover:text-foreground"
47
+ onClick={() => void copy(source)}
48
+ >
49
+ {copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
50
+ <span>{copied ? 'Copied' : 'Copy'}</span>
51
+ </Button>
52
+ </div>
53
+ )}
54
+ <pre tabIndex={0} className="m-0 overflow-x-auto bg-muted/40 p-inset font-mono text-xs leading-relaxed text-foreground">
55
+ <code>{source}</code>
56
+ </pre>
57
+ </div>
58
+ );
59
+ }
60
+
61
+ // A model-written image stays a link, so the browser asks for no address until the member clicks.
62
+ const MARKDOWN: Components = {
63
+ h1: ({ children }) => (
64
+ <Heading level={2} size="lg" className="mt-stack mb-2 first:mt-0">
65
+ {children}
66
+ </Heading>
67
+ ),
68
+ h2: ({ children }) => (
69
+ <Heading level={2} size="md" className="mt-stack mb-2 first:mt-0">
70
+ {children}
71
+ </Heading>
72
+ ),
73
+ h3: ({ children }) => (
74
+ <Heading level={3} size="sm" className="mt-stack mb-2 first:mt-0">
75
+ {children}
76
+ </Heading>
77
+ ),
78
+ h4: ({ children }) => (
79
+ <Heading level={4} size="sm" className="mt-stack mb-2 first:mt-0">
80
+ {children}
81
+ </Heading>
82
+ ),
83
+ p: ({ children }) => (
84
+ <Text as="p" leading="relaxed" className="my-2 first:mt-0 last:mb-0">
85
+ {children}
86
+ </Text>
87
+ ),
88
+ ul: ({ children }) => <ul className="my-2 list-disc pl-6 text-sm">{children}</ul>,
89
+ ol: ({ children }) => <ol className="my-2 list-decimal pl-6 text-sm">{children}</ol>,
90
+ li: ({ children }) => (
91
+ <li className="my-0.5 leading-relaxed text-foreground marker:text-muted-foreground">
92
+ {children}
93
+ </li>
94
+ ),
95
+ a: ({ children, href }) =>
96
+ href ? (
97
+ <a className={LINK_CLASS} href={href} target="_blank" rel="noopener noreferrer">
98
+ {children}
99
+ </a>
100
+ ) : (
101
+ <>{children}</>
102
+ ),
103
+ img: ({ alt, src }) => (
104
+ <a className={LINK_CLASS} href={src} target="_blank" rel="noopener noreferrer">
105
+ {alt || src}
106
+ </a>
107
+ ),
108
+ blockquote: ({ children }) => (
109
+ <blockquote className="my-2 border-l-2 border-border pl-inset text-muted-foreground">
110
+ {children}
111
+ </blockquote>
112
+ ),
113
+ hr: () => <Separator decorative={false} className="my-4" />,
114
+ pre: ({ children }) => {
115
+ const code = isValidElement<{ children?: ReactNode; className?: string }>(children)
116
+ ? children.props
117
+ : {};
118
+ return (
119
+ <CodeBlock
120
+ language={/language-(\w+)/.exec(code.className ?? '')?.[1] ?? ''}
121
+ source={String(code.children ?? '').replace(/\n$/, '')}
122
+ />
123
+ );
124
+ },
125
+ code: ({ children }) => (
126
+ <code className="rounded-sm bg-muted px-1.5 py-0.5 font-mono text-sm break-words text-foreground">
127
+ {children}
128
+ </code>
129
+ ),
130
+ table: ({ children }) => (
131
+ <ScrollFade className="my-2 rounded-lg border border-border" role="group" aria-label="Table" tabIndex={0}>
132
+ <Table containerClassName="overflow-visible" className="w-full border-separate border-spacing-0 [&_tbody_tr:last-child_td]:border-b-0">
133
+ {children}
134
+ </Table>
135
+ </ScrollFade>
136
+ ),
137
+ th: ({ children, style }) => (
138
+ <Text asChild weight="medium">
139
+ <TableHead
140
+ style={style}
141
+ className="whitespace-nowrap border-r border-b border-border bg-muted px-inset py-inline text-left last:border-r-0"
142
+ >
143
+ {children}
144
+ </TableHead>
145
+ </Text>
146
+ ),
147
+ td: ({ children, style }) => (
148
+ <Text asChild>
149
+ <TableCell style={style} className="border-r border-b border-border px-inset py-inline last:border-r-0 max-mobile:min-w-32">
150
+ {children}
151
+ </TableCell>
152
+ </Text>
153
+ ),
154
+ };
155
+
156
+ const REMARK_PLUGINS = [remarkGfm, remarkBreaks];
157
+
158
+ const Markdown = memo(function Markdown({ content }: { content: string }) {
159
+ return (
160
+ <div data-testid="chat-markdown">
161
+ <ReactMarkdown remarkPlugins={REMARK_PLUGINS} components={MARKDOWN}>
162
+ {content}
163
+ </ReactMarkdown>
164
+ </div>
165
+ );
166
+ });
167
+
168
+ const FENCE = /^ {0,3}(`{3,}|~{3,})/;
169
+ const STANDALONE_LINE = /^ {0,3}(?:#{1,6}(?:\s+|$)|(?:[-+*]|\d+[.)])\s+|>\s?)/;
170
+
171
+ /** Where the finished blocks end: blank lines, closed fences, and whole headings, list items and quotes. */
172
+ export function stableMarkdownEnd(markdown: string): number {
173
+ let stable = 0;
174
+ let at = 0;
175
+ let fence: string | null = null;
176
+ while (at < markdown.length) {
177
+ const newline = markdown.indexOf('\n', at);
178
+ const line = markdown.slice(at, newline < 0 ? markdown.length : newline);
179
+ const end = newline < 0 ? markdown.length : newline + 1;
180
+ const marker = FENCE.exec(line)?.[1];
181
+ if (fence) {
182
+ if (marker?.startsWith(fence[0]!) && marker.length >= fence.length && line.trim() === marker) {
183
+ stable = end;
184
+ fence = null;
185
+ }
186
+ } else if (marker) {
187
+ fence = marker;
188
+ } else if (newline < 0) {
189
+ break;
190
+ } else if (line.trim() === '' || STANDALONE_LINE.test(line)) {
191
+ stable = end;
192
+ }
193
+ at = end;
194
+ }
195
+ return stable;
196
+ }
197
+
198
+ /** Finished blocks render as Markdown; the unfinished rest stays plain text, so half-written syntax never flickers. */
199
+ function StreamingMarkdown({ content }: { content: string }) {
200
+ const stable = useMemo(() => stableMarkdownEnd(content), [content]);
201
+ const [promoted, setPromoted] = useState(stable);
202
+ const boundary = Math.min(promoted, stable);
203
+
204
+ useEffect(() => {
205
+ if (stable <= promoted) return;
206
+ const timer = window.setTimeout(() => setPromoted(stable), PROMOTE_STABLE_TEXT_MS);
207
+ return () => window.clearTimeout(timer);
208
+ }, [promoted, stable]);
209
+
210
+ const prefix = content.slice(0, boundary);
211
+ const tail = content.slice(boundary);
212
+ return (
213
+ <>
214
+ {prefix && <Markdown content={prefix} />}
215
+ {tail && (
216
+ <Text
217
+ as="div"
218
+ leading="relaxed"
219
+ className={cn('break-words whitespace-pre-wrap', prefix && 'mt-2')}
220
+ >
221
+ {tail}
222
+ </Text>
223
+ )}
224
+ </>
225
+ );
226
+ }
227
+
228
+ export function ChatMarkdown({ content, streaming }: { content: string; streaming: boolean }) {
229
+ return streaming ? <StreamingMarkdown content={content} /> : <Markdown content={content} />;
230
+ }