@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,118 @@
1
+ /**
2
+ * Pure signal math for the voice orb. The orb's animation frame reads an
3
+ * AnalyserNode and feeds the numbers through these; nothing here touches
4
+ * the DOM so every step is unit-testable.
5
+ */
6
+
7
+ /** Amplitude of one AnalyserNode time-domain window. */
8
+ export function rmsFromTimeDomain(samples: Float32Array | number[]): number {
9
+ if (samples.length === 0) return 0;
10
+ let sum = 0;
11
+ for (const sample of samples) {
12
+ sum += sample * sample;
13
+ }
14
+ return Math.sqrt(sum / samples.length);
15
+ }
16
+
17
+ /**
18
+ * Speech RMS sits well below 1.0 even when loud, so the raw value goes
19
+ * through a gain before it drives anything visible.
20
+ */
21
+ export function normalizeSpeechRms(rms: number, gain = 6): number {
22
+ return Math.min(1, Math.max(0, rms * gain));
23
+ }
24
+
25
+ /**
26
+ * Envelope follower with a fast attack and a slow release. Syllables snap the
27
+ * level up and it eases down between words instead of flickering.
28
+ */
29
+ export function followEnvelope(
30
+ previous: number,
31
+ next: number,
32
+ attack = 0.5,
33
+ release = 0.12,
34
+ ): number {
35
+ const alpha = next > previous ? attack : release;
36
+ return previous + (next - previous) * alpha;
37
+ }
38
+
39
+ export interface SpeechGate {
40
+ open: boolean;
41
+ /** Consecutive frames above the opening threshold while closed. */
42
+ aboveFrames: number;
43
+ /** Frames left before a quiet stretch closes the gate. */
44
+ holdFrames: number;
45
+ }
46
+
47
+ export interface SpeechGateOptions {
48
+ openAbove: number;
49
+ closeBelow: number;
50
+ openFrames: number;
51
+ holdFrames: number;
52
+ }
53
+
54
+ export const SPEECH_GATE_DEFAULTS: SpeechGateOptions = {
55
+ openAbove: 0.12,
56
+ closeBelow: 0.06,
57
+ openFrames: 3,
58
+ holdFrames: 12,
59
+ };
60
+
61
+ export function initialSpeechGate(): SpeechGate {
62
+ return { open: false, aboveFrames: 0, holdFrames: 0 };
63
+ }
64
+
65
+ /**
66
+ * Noise gate with hysteresis and a hold. It needs a few loud frames to open,
67
+ * closes only below a lower threshold, and waits out short pauses so the
68
+ * speaking look does not chatter between words.
69
+ */
70
+ export function stepSpeechGate(
71
+ gate: SpeechGate,
72
+ level: number,
73
+ options: SpeechGateOptions = SPEECH_GATE_DEFAULTS,
74
+ ): SpeechGate {
75
+ if (!gate.open) {
76
+ const aboveFrames = level > options.openAbove ? gate.aboveFrames + 1 : 0;
77
+ if (aboveFrames >= options.openFrames) {
78
+ return { open: true, aboveFrames: 0, holdFrames: options.holdFrames };
79
+ }
80
+ return { open: false, aboveFrames, holdFrames: 0 };
81
+ }
82
+
83
+ if (level > options.closeBelow) {
84
+ return { open: true, aboveFrames: 0, holdFrames: options.holdFrames };
85
+ }
86
+ const holdFrames = gate.holdFrames - 1;
87
+ if (holdFrames <= 0) {
88
+ return { open: false, aboveFrames: 0, holdFrames: 0 };
89
+ }
90
+ return { open: true, aboveFrames: 0, holdFrames };
91
+ }
92
+
93
+ /**
94
+ * Mean magnitude of the byte-frequency bins between two frequencies, on a
95
+ * 0..1 scale. `binHz` is sampleRate / fftSize.
96
+ */
97
+ export function bandEnergy(
98
+ bins: Uint8Array,
99
+ binHz: number,
100
+ fromHz: number,
101
+ toHz: number,
102
+ ): number {
103
+ if (bins.length === 0 || binHz <= 0) return 0;
104
+ const first = Math.max(0, Math.floor(fromHz / binHz));
105
+ const last = Math.min(bins.length - 1, Math.ceil(toHz / binHz));
106
+ if (last < first) return 0;
107
+ let sum = 0;
108
+ for (const magnitude of bins.subarray(first, last + 1)) {
109
+ sum += magnitude;
110
+ }
111
+ return sum / ((last - first + 1) * 255);
112
+ }
113
+
114
+ /** Fricatives and sibilants live here; they sharpen the mesh edges. */
115
+ export const SPEECH_AIR_BAND_HZ: readonly [number, number] = [2000, 6000];
116
+
117
+ /** Gain that lifts typical speech "air" energy into a usable 0..1 range. */
118
+ export const SPEECH_AIR_GAIN = 2.5;
@@ -0,0 +1,109 @@
1
+ import * as React from 'react';
2
+ import { type ClassValue, clsx } from 'clsx';
3
+ import { twMerge } from 'tailwind-merge';
4
+
5
+ export function cn(...inputs: ClassValue[]) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+
9
+ /**
10
+ * Suppresses the false-positive `:focus-visible` ring browsers paint when an
11
+ * overlay unmounts after a pointer selection and programmatically restores DOM
12
+ * focus onto its trigger. Focus stays on the trigger for WAI-ARIA continuity
13
+ * and scoped shortcuts; the marker clears on the next keydown or blur.
14
+ */
15
+ export function suppressPointerAutoFocusRing(): void {
16
+ const previousActive =
17
+ typeof document !== 'undefined' ? document.activeElement : null;
18
+ queueMicrotask(() => {
19
+ const active =
20
+ typeof document !== 'undefined' ? document.activeElement : null;
21
+ if (
22
+ !(active instanceof HTMLElement) ||
23
+ active === document.body ||
24
+ active === previousActive
25
+ ) {
26
+ return;
27
+ }
28
+ active.dataset.pointerCloseFocus = '';
29
+ const clear = () => {
30
+ delete active.dataset.pointerCloseFocus;
31
+ active.removeEventListener('blur', clear);
32
+ window.removeEventListener('keydown', clear, true);
33
+ };
34
+ active.addEventListener('blur', clear, { once: true });
35
+ window.addEventListener('keydown', clear, { capture: true, once: true });
36
+ });
37
+ }
38
+
39
+ interface PointerCloseFocusHandlers<
40
+ TEscape extends Event,
41
+ TPointerOutside extends Event,
42
+ TCloseAutoFocus extends Event,
43
+ > {
44
+ onPointerDownCapture?: React.PointerEventHandler | undefined;
45
+ onClickCapture?: React.MouseEventHandler | undefined;
46
+ onKeyDownCapture?: React.KeyboardEventHandler | undefined;
47
+ onEscapeKeyDown?: ((event: TEscape) => void) | undefined;
48
+ onPointerDownOutside?: ((event: TPointerOutside) => void) | undefined;
49
+ onCloseAutoFocus?: ((event: TCloseAutoFocus) => void) | undefined;
50
+ }
51
+
52
+ /**
53
+ * Wraps an overlay content's handlers so that closing by pointer hides the
54
+ * focus ring on the trigger Radix refocuses. Spread the result onto the Radix
55
+ * content after the caller's remaining props; the caller's own handlers still
56
+ * run first.
57
+ */
58
+ export function usePointerCloseFocus<
59
+ TEscape extends Event,
60
+ TPointerOutside extends Event,
61
+ TCloseAutoFocus extends Event,
62
+ >(
63
+ handlers: PointerCloseFocusHandlers<
64
+ TEscape,
65
+ TPointerOutside,
66
+ TCloseAutoFocus
67
+ >,
68
+ ) {
69
+ const {
70
+ onPointerDownCapture,
71
+ onClickCapture,
72
+ onKeyDownCapture,
73
+ onEscapeKeyDown,
74
+ onPointerDownOutside,
75
+ onCloseAutoFocus,
76
+ } = handlers;
77
+ const closedByPointerRef = React.useRef(false);
78
+
79
+ return {
80
+ onPointerDownCapture: (event: React.PointerEvent) => {
81
+ closedByPointerRef.current = true;
82
+ onPointerDownCapture?.(event);
83
+ },
84
+ onClickCapture: (event: React.MouseEvent) => {
85
+ if (event.detail > 0) closedByPointerRef.current = true;
86
+ onClickCapture?.(event);
87
+ },
88
+ onKeyDownCapture: (event: React.KeyboardEvent) => {
89
+ closedByPointerRef.current = false;
90
+ onKeyDownCapture?.(event);
91
+ },
92
+ onEscapeKeyDown: (event: TEscape) => {
93
+ closedByPointerRef.current = false;
94
+ onEscapeKeyDown?.(event);
95
+ },
96
+ onPointerDownOutside: (event: TPointerOutside) => {
97
+ onPointerDownOutside?.(event);
98
+ closedByPointerRef.current = !event.defaultPrevented;
99
+ },
100
+ onCloseAutoFocus: (event: TCloseAutoFocus) => {
101
+ const closedByPointer = closedByPointerRef.current;
102
+ closedByPointerRef.current = false;
103
+ onCloseAutoFocus?.(event);
104
+ if (!event.defaultPrevented && closedByPointer) {
105
+ suppressPointerAutoFocusRing();
106
+ }
107
+ },
108
+ };
109
+ }
@@ -0,0 +1,21 @@
1
+ /* ============================================================================
2
+ OAIZ APP STYLES
3
+
4
+ What apps built on the OAIZ app kit add to tokens.css. Import this file
5
+ after tokens.css. Apps keep their own typeface: `font-sans` in
6
+ tokens.css, the system font stack.
7
+
8
+ - The enter and exit animations (`animate-in`, `fade-in-0`,
9
+ `slide-in-from-*`) that dialogs, popovers, sheets, menus and toasts use.
10
+ Reduced motion stops them with every other animation in tokens.css.
11
+ - The timing of the cross-fade between screens (`useUrlState` with
12
+ `history: 'push'`), which the hook skips under reduced motion.
13
+ ============================================================================ */
14
+
15
+ @import 'tw-animate-css';
16
+
17
+ ::view-transition-old(root),
18
+ ::view-transition-new(root) {
19
+ animation-duration: var(--duration-200);
20
+ animation-timing-function: var(--ease-move);
21
+ }
@@ -0,0 +1,20 @@
1
+ @layer base {
2
+ ::-webkit-scrollbar {
3
+ width: 0.3125rem;
4
+ }
5
+
6
+ ::-webkit-scrollbar-track {
7
+ background: transparent;
8
+ }
9
+
10
+ ::-webkit-scrollbar-thumb {
11
+ background: var(--color-border);
12
+ /* No matching radius token; the narrow thumb should remain fully round. */
13
+ border-radius: calc(infinity * 1px);
14
+ }
15
+
16
+ * {
17
+ scrollbar-width: thin;
18
+ scrollbar-color: var(--color-border) transparent;
19
+ }
20
+ }