@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.
- package/LICENSE +21 -0
- package/README.md +143 -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,252 @@
|
|
|
1
|
+
import { useEffect, useId, useRef } from 'react';
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
import {
|
|
4
|
+
SPEECH_AIR_BAND_HZ,
|
|
5
|
+
SPEECH_AIR_GAIN,
|
|
6
|
+
bandEnergy,
|
|
7
|
+
followEnvelope,
|
|
8
|
+
initialSpeechGate,
|
|
9
|
+
normalizeSpeechRms,
|
|
10
|
+
rmsFromTimeDomain,
|
|
11
|
+
stepSpeechGate,
|
|
12
|
+
} from '../../lib/speech-level';
|
|
13
|
+
|
|
14
|
+
const STAGE_SIZE_PX = { desktop: 200, mobile: 180 } as const;
|
|
15
|
+
const COMPOSER_SIZE_PX = { desktop: 32, mobile: 28 } as const;
|
|
16
|
+
|
|
17
|
+
/** Blur of the resting mesh. Loud consonants pull it toward the speaking value. */
|
|
18
|
+
const REST_BLUR = 15;
|
|
19
|
+
const SPEAKING_BLUR = 9;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* How much each spot swells at full loudness. Three different gains make the
|
|
23
|
+
* mesh wobble on a syllable instead of the whole orb zooming.
|
|
24
|
+
*/
|
|
25
|
+
const SPOT_SWELL = [0.18, 0.32, 0.45] as const;
|
|
26
|
+
|
|
27
|
+
export type VoiceOrbState = 'idle' | 'connecting' | 'live' | 'closing';
|
|
28
|
+
|
|
29
|
+
interface VoiceOrbProps {
|
|
30
|
+
size: 'stage' | 'composer';
|
|
31
|
+
state: VoiceOrbState;
|
|
32
|
+
isMobile?: boolean;
|
|
33
|
+
/** Analyser on the assistant playback track. Its loudness drives the speaking look. */
|
|
34
|
+
outputAnalyser?: AnalyserNode | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Drift mesh: three soft spots traveling farther than Rest, clipped to a
|
|
39
|
+
* circle. Connecting and closing keep the same spots and only slow the drift.
|
|
40
|
+
*
|
|
41
|
+
* While the assistant is audible, a gated loudness envelope swells each spot
|
|
42
|
+
* through the `--voice-body` custom property, high-band energy sharpens the
|
|
43
|
+
* blur, and `data-speaking` switches on the sway animation from the stylesheet.
|
|
44
|
+
*/
|
|
45
|
+
export function VoiceOrb({
|
|
46
|
+
size,
|
|
47
|
+
state,
|
|
48
|
+
isMobile = false,
|
|
49
|
+
outputAnalyser = null,
|
|
50
|
+
}: VoiceOrbProps) {
|
|
51
|
+
const reactId = useId().replace(/:/g, '');
|
|
52
|
+
const blurId = `voice-orb-blur-${reactId}`;
|
|
53
|
+
const clipId = `voice-orb-clip-${reactId}`;
|
|
54
|
+
const gradientId = (name: string) => `voice-orb-${name}-${reactId}`;
|
|
55
|
+
const svgRef = useRef<SVGSVGElement>(null);
|
|
56
|
+
const blurRef = useRef<SVGFEGaussianBlurElement>(null);
|
|
57
|
+
const pixels =
|
|
58
|
+
size === 'stage'
|
|
59
|
+
? isMobile
|
|
60
|
+
? STAGE_SIZE_PX.mobile
|
|
61
|
+
: STAGE_SIZE_PX.desktop
|
|
62
|
+
: isMobile
|
|
63
|
+
? COMPOSER_SIZE_PX.mobile
|
|
64
|
+
: COMPOSER_SIZE_PX.desktop;
|
|
65
|
+
const durationScale = state === 'live' ? 1 : 2.4;
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const svg = svgRef.current;
|
|
69
|
+
const blur = blurRef.current;
|
|
70
|
+
if (!svg || !blur || !outputAnalyser) return;
|
|
71
|
+
|
|
72
|
+
const reducedMotion =
|
|
73
|
+
window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
74
|
+
const samples = new Float32Array(outputAnalyser.fftSize);
|
|
75
|
+
const bins = new Uint8Array(outputAnalyser.frequencyBinCount);
|
|
76
|
+
const binHz = outputAnalyser.context.sampleRate / outputAnalyser.fftSize;
|
|
77
|
+
let envelope = 0;
|
|
78
|
+
let gate = initialSpeechGate();
|
|
79
|
+
let frame = 0;
|
|
80
|
+
// Last values written, so a silent orb costs no DOM writes per frame.
|
|
81
|
+
let writtenBody = '';
|
|
82
|
+
let writtenBlur = '';
|
|
83
|
+
let writtenSpeaking = '';
|
|
84
|
+
|
|
85
|
+
const tick = () => {
|
|
86
|
+
outputAnalyser.getFloatTimeDomainData(samples);
|
|
87
|
+
envelope = followEnvelope(
|
|
88
|
+
envelope,
|
|
89
|
+
normalizeSpeechRms(rmsFromTimeDomain(samples)),
|
|
90
|
+
);
|
|
91
|
+
gate = stepSpeechGate(gate, envelope);
|
|
92
|
+
|
|
93
|
+
const animate = gate.open && !reducedMotion;
|
|
94
|
+
let air = 0;
|
|
95
|
+
if (animate) {
|
|
96
|
+
outputAnalyser.getByteFrequencyData(bins);
|
|
97
|
+
air = Math.min(
|
|
98
|
+
1,
|
|
99
|
+
bandEnergy(bins, binHz, ...SPEECH_AIR_BAND_HZ) * SPEECH_AIR_GAIN,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const body = (animate ? envelope : 0).toFixed(3);
|
|
103
|
+
const blurValue = (REST_BLUR - (REST_BLUR - SPEAKING_BLUR) * air).toFixed(
|
|
104
|
+
1,
|
|
105
|
+
);
|
|
106
|
+
const speaking = gate.open ? 'true' : 'false';
|
|
107
|
+
|
|
108
|
+
if (body !== writtenBody) {
|
|
109
|
+
svg.style.setProperty('--voice-body', body);
|
|
110
|
+
writtenBody = body;
|
|
111
|
+
}
|
|
112
|
+
if (blurValue !== writtenBlur) {
|
|
113
|
+
blur.setAttribute('stdDeviation', blurValue);
|
|
114
|
+
writtenBlur = blurValue;
|
|
115
|
+
}
|
|
116
|
+
if (speaking !== writtenSpeaking) {
|
|
117
|
+
svg.setAttribute('data-speaking', speaking);
|
|
118
|
+
writtenSpeaking = speaking;
|
|
119
|
+
}
|
|
120
|
+
frame = requestAnimationFrame(tick);
|
|
121
|
+
};
|
|
122
|
+
frame = requestAnimationFrame(tick);
|
|
123
|
+
|
|
124
|
+
return () => {
|
|
125
|
+
cancelAnimationFrame(frame);
|
|
126
|
+
svg.style.removeProperty('--voice-body');
|
|
127
|
+
blur.setAttribute('stdDeviation', String(REST_BLUR));
|
|
128
|
+
svg.setAttribute('data-speaking', 'false');
|
|
129
|
+
};
|
|
130
|
+
}, [outputAnalyser]);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<svg
|
|
134
|
+
ref={svgRef}
|
|
135
|
+
width={pixels}
|
|
136
|
+
height={pixels}
|
|
137
|
+
viewBox="0 0 200 200"
|
|
138
|
+
aria-hidden
|
|
139
|
+
data-testid="chat-live-voice-orb"
|
|
140
|
+
data-size={size}
|
|
141
|
+
data-state={state}
|
|
142
|
+
data-speaking="false"
|
|
143
|
+
className={cn('shrink-0', size === 'composer' && 'self-start')}
|
|
144
|
+
>
|
|
145
|
+
<defs>
|
|
146
|
+
<linearGradient id={gradientId('blue-lime')}>
|
|
147
|
+
<stop stopColor="var(--role-orb-blue)" />
|
|
148
|
+
<stop offset="1" stopColor="var(--role-orb-lime)" />
|
|
149
|
+
</linearGradient>
|
|
150
|
+
<radialGradient id={gradientId('green-gold')}>
|
|
151
|
+
<stop stopColor="var(--role-orb-center-light)" />
|
|
152
|
+
<stop offset="0.25" stopColor="var(--role-orb-center)" />
|
|
153
|
+
<stop offset="0.5" stopColor="var(--role-orb-gold)" />
|
|
154
|
+
<stop offset="0.75" stopColor="var(--role-orb-lime-bright)" />
|
|
155
|
+
<stop offset="1" stopColor="var(--role-orb-green)" />
|
|
156
|
+
</radialGradient>
|
|
157
|
+
<radialGradient id={gradientId('warm')}>
|
|
158
|
+
<stop stopColor="var(--role-orb-red)" />
|
|
159
|
+
<stop offset="0.25" stopColor="var(--role-orb-orange)" />
|
|
160
|
+
<stop offset="1" stopColor="var(--role-orb-amber)" />
|
|
161
|
+
</radialGradient>
|
|
162
|
+
<filter
|
|
163
|
+
id={blurId}
|
|
164
|
+
x="-50%"
|
|
165
|
+
y="-50%"
|
|
166
|
+
width="200%"
|
|
167
|
+
height="200%"
|
|
168
|
+
colorInterpolationFilters="sRGB"
|
|
169
|
+
>
|
|
170
|
+
<feGaussianBlur ref={blurRef} stdDeviation={REST_BLUR} />
|
|
171
|
+
</filter>
|
|
172
|
+
<clipPath id={clipId}>
|
|
173
|
+
<circle cx="100" cy="100" r="100" />
|
|
174
|
+
</clipPath>
|
|
175
|
+
</defs>
|
|
176
|
+
<g
|
|
177
|
+
className="voice-orb-mesh"
|
|
178
|
+
clipPath={`url(#${clipId})`}
|
|
179
|
+
filter={`url(#${blurId})`}
|
|
180
|
+
>
|
|
181
|
+
<circle
|
|
182
|
+
className="voice-orb-spot"
|
|
183
|
+
style={{ transform: spotSwell(SPOT_SWELL[0]) }}
|
|
184
|
+
fill={`url(#${gradientId('green-gold')})`}
|
|
185
|
+
r="78"
|
|
186
|
+
cx="58"
|
|
187
|
+
cy="72"
|
|
188
|
+
>
|
|
189
|
+
<animate
|
|
190
|
+
attributeName="cx"
|
|
191
|
+
values="58;142;46;58"
|
|
192
|
+
dur={`${8 * durationScale}s`}
|
|
193
|
+
repeatCount="indefinite"
|
|
194
|
+
/>
|
|
195
|
+
<animate
|
|
196
|
+
attributeName="cy"
|
|
197
|
+
values="72;48;138;72"
|
|
198
|
+
dur={`${10 * durationScale}s`}
|
|
199
|
+
repeatCount="indefinite"
|
|
200
|
+
/>
|
|
201
|
+
</circle>
|
|
202
|
+
<circle
|
|
203
|
+
className="voice-orb-spot"
|
|
204
|
+
style={{ transform: spotSwell(SPOT_SWELL[1]) }}
|
|
205
|
+
fill={`url(#${gradientId('blue-lime')})`}
|
|
206
|
+
r="70"
|
|
207
|
+
cx="128"
|
|
208
|
+
cy="64"
|
|
209
|
+
>
|
|
210
|
+
<animate
|
|
211
|
+
attributeName="cx"
|
|
212
|
+
values="128;52;150;128"
|
|
213
|
+
dur={`${9 * durationScale}s`}
|
|
214
|
+
repeatCount="indefinite"
|
|
215
|
+
/>
|
|
216
|
+
<animate
|
|
217
|
+
attributeName="cy"
|
|
218
|
+
values="64;146;40;64"
|
|
219
|
+
dur={`${11 * durationScale}s`}
|
|
220
|
+
repeatCount="indefinite"
|
|
221
|
+
/>
|
|
222
|
+
</circle>
|
|
223
|
+
<circle
|
|
224
|
+
className="voice-orb-spot"
|
|
225
|
+
style={{ transform: spotSwell(SPOT_SWELL[2]) }}
|
|
226
|
+
fill={`url(#${gradientId('warm')})`}
|
|
227
|
+
r="74"
|
|
228
|
+
cx="96"
|
|
229
|
+
cy="132"
|
|
230
|
+
>
|
|
231
|
+
<animate
|
|
232
|
+
attributeName="cx"
|
|
233
|
+
values="96;40;154;96"
|
|
234
|
+
dur={`${7 * durationScale}s`}
|
|
235
|
+
repeatCount="indefinite"
|
|
236
|
+
/>
|
|
237
|
+
<animate
|
|
238
|
+
attributeName="cy"
|
|
239
|
+
values="132;58;150;132"
|
|
240
|
+
dur={`${12 * durationScale}s`}
|
|
241
|
+
repeatCount="indefinite"
|
|
242
|
+
/>
|
|
243
|
+
</circle>
|
|
244
|
+
</g>
|
|
245
|
+
</svg>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Each spot scales from its own centre by the shared loudness property. */
|
|
250
|
+
function spotSwell(gain: number): string {
|
|
251
|
+
return `scale(calc(1 + var(--voice-body, 0) * ${gain}))`;
|
|
252
|
+
}
|