@epicbagel/saas-kit 1.10.0 → 1.11.1

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 (42) hide show
  1. package/README.md +21 -3
  2. package/dist/{chunk-VBKJXNEL.js → chunk-5OF6D3GH.js} +4 -3
  3. package/dist/chunk-D47AMKT4.cjs +293 -0
  4. package/dist/chunk-EDEN7TAL.js +293 -0
  5. package/dist/{chunk-M2ZNC3TK.js → chunk-HLAHOVEI.js} +98 -2
  6. package/dist/{chunk-KUG4ONYC.js → chunk-KF4X37DP.js} +40 -27
  7. package/dist/{chunk-XB2D4NQK.cjs → chunk-NKWHDI4C.cjs} +4 -3
  8. package/dist/{chunk-UW67GSZ4.cjs → chunk-YMI3X2YL.cjs} +38 -25
  9. package/dist/{chunk-O6F3LVZY.cjs → chunk-ZZ7ICQR2.cjs} +120 -24
  10. package/dist/hooks/use-dictation.cjs +2 -2
  11. package/dist/hooks/use-dictation.d.cts +5 -0
  12. package/dist/hooks/use-dictation.d.ts +5 -0
  13. package/dist/hooks/use-dictation.js +1 -1
  14. package/dist/primitives/agent-audio-visualizer-bar.cjs +2 -2
  15. package/dist/primitives/agent-audio-visualizer-bar.d.cts +1 -1
  16. package/dist/primitives/agent-audio-visualizer-bar.d.ts +1 -1
  17. package/dist/primitives/agent-audio-visualizer-bar.js +1 -1
  18. package/dist/primitives/alert.d.cts +1 -1
  19. package/dist/primitives/alert.d.ts +1 -1
  20. package/dist/primitives/badge.d.cts +1 -1
  21. package/dist/primitives/badge.d.ts +1 -1
  22. package/dist/primitives/bubble.d.cts +1 -1
  23. package/dist/primitives/bubble.d.ts +1 -1
  24. package/dist/primitives/button.d.cts +2 -2
  25. package/dist/primitives/button.d.ts +2 -2
  26. package/dist/primitives/chat.cjs +15 -15
  27. package/dist/primitives/chat.d.cts +2 -2
  28. package/dist/primitives/chat.d.ts +2 -2
  29. package/dist/primitives/chat.js +10 -10
  30. package/dist/primitives/dictation-provider.cjs +2 -2
  31. package/dist/primitives/dictation-provider.js +1 -1
  32. package/dist/primitives/voice-dictation-button.cjs +5 -3
  33. package/dist/primitives/voice-dictation-button.d.cts +9 -11
  34. package/dist/primitives/voice-dictation-button.d.ts +9 -11
  35. package/dist/primitives/voice-dictation-button.js +4 -2
  36. package/dist/primitives/voice-session-controls.cjs +3 -3
  37. package/dist/primitives/voice-session-controls.d.cts +3 -1
  38. package/dist/primitives/voice-session-controls.d.ts +3 -1
  39. package/dist/primitives/voice-session-controls.js +2 -2
  40. package/package.json +1 -1
  41. package/dist/chunk-HTCW6AEH.cjs +0 -223
  42. package/dist/chunk-KWV5KTOA.js +0 -223
@@ -1,223 +0,0 @@
1
- "use client";
2
- import {
3
- Button
4
- } from "./chunk-W326GKML.js";
5
- import {
6
- cn
7
- } from "./chunk-G6SRSWXB.js";
8
- import {
9
- useDictation
10
- } from "./chunk-M2ZNC3TK.js";
11
-
12
- // src/primitives/voice-dictation-button.tsx
13
- import {
14
- useCallback,
15
- useEffect,
16
- useRef,
17
- useState
18
- } from "react";
19
- import * as DialogPrimitive from "@radix-ui/react-dialog";
20
- import { Mic, X } from "lucide-react";
21
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
22
- function VoiceDictationButton({
23
- onCommit,
24
- onCancel,
25
- title = "Dictate your message",
26
- caption = "listening",
27
- lang = "en-US",
28
- continuous = true,
29
- className,
30
- size = "sm",
31
- showLabel = false,
32
- children,
33
- disabled = false,
34
- visibility = "visible",
35
- shrink = true
36
- }) {
37
- const [open, setOpen] = useState(false);
38
- const capture = useDictation({ lang, continuous });
39
- const { transcript, interimTranscript: interim, supported, error } = capture;
40
- const generation = useRef(0);
41
- const finishing = useRef(false);
42
- const busy = capture.state === "requesting" || capture.state === "transcribing";
43
- const openOverlay = useCallback(() => {
44
- generation.current++;
45
- finishing.current = false;
46
- setOpen(true);
47
- void capture.start();
48
- }, [capture.start]);
49
- const closeOverlay = useCallback(() => {
50
- generation.current++;
51
- finishing.current = false;
52
- capture.cancel();
53
- setOpen(false);
54
- }, [capture.cancel]);
55
- const handleDone = useCallback(async () => {
56
- if (finishing.current || busy) return;
57
- if (capture.state === "error" && !capture.canRetry) {
58
- void capture.start();
59
- return;
60
- }
61
- finishing.current = true;
62
- const started = generation.current;
63
- const final = await (capture.canRetry ? capture.retry() : capture.stop());
64
- if (started !== generation.current) return;
65
- finishing.current = false;
66
- if (final === null) return;
67
- closeOverlay();
68
- if (final) onCommit(final);
69
- else onCancel?.();
70
- }, [busy, capture.canRetry, capture.retry, capture.start, capture.state, capture.stop, onCommit, onCancel, closeOverlay]);
71
- const handleCancel = useCallback(() => {
72
- closeOverlay();
73
- onCancel?.();
74
- }, [closeOverlay, onCancel]);
75
- useEffect(() => {
76
- if (open && capture.state === "idle") handleCancel();
77
- }, [capture.state, handleCancel, open]);
78
- useEffect(() => {
79
- if (!open) return;
80
- const onKey = (e) => {
81
- if (e.key === "Enter" && !e.shiftKey) {
82
- e.preventDefault();
83
- void handleDone();
84
- }
85
- };
86
- document.addEventListener("keydown", onKey);
87
- return () => document.removeEventListener("keydown", onKey);
88
- }, [open, handleDone]);
89
- useEffect(() => {
90
- return () => {
91
- generation.current++;
92
- };
93
- }, []);
94
- if (!supported) return null;
95
- const displayTranscript = `${transcript}${interim ? (transcript ? " " : "") + interim : ""}`;
96
- return /* @__PURE__ */ jsxs(Fragment, { children: [
97
- children ? /* @__PURE__ */ jsx(
98
- "button",
99
- {
100
- type: "button",
101
- onClick: openOverlay,
102
- disabled,
103
- "aria-label": "Start dictation",
104
- className: cn(visibility === "hidden" && "hidden", className),
105
- children
106
- }
107
- ) : /* @__PURE__ */ jsx(
108
- Button,
109
- {
110
- type: "button",
111
- onClick: openOverlay,
112
- disabled,
113
- variant: "outline",
114
- size,
115
- "aria-label": "Start dictation",
116
- className: cn("transition-colors", visibility === "hidden" && "hidden", !shrink && "shrink-0", className),
117
- children: /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-center gap-2", children: [
118
- /* @__PURE__ */ jsx(Mic, { className: "h-4 w-4" }),
119
- showLabel && /* @__PURE__ */ jsx("span", { children: "Speak" })
120
- ] })
121
- }
122
- ),
123
- /* @__PURE__ */ jsx(
124
- DialogPrimitive.Root,
125
- {
126
- open,
127
- onOpenChange: (next) => {
128
- if (!next) handleCancel();
129
- },
130
- children: /* @__PURE__ */ jsx(DialogPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
131
- DialogPrimitive.Content,
132
- {
133
- "aria-label": "Voice dictation",
134
- onOpenAutoFocus: (e) => e.preventDefault(),
135
- onMouseDown: (e) => {
136
- if (e.target === e.currentTarget) handleCancel();
137
- },
138
- className: "fixed inset-0 z-[200] flex flex-col bg-background outline-hidden md:items-center md:justify-center md:bg-black/40 md:backdrop-blur-sm",
139
- children: [
140
- /* @__PURE__ */ jsx(DialogPrimitive.Title, { className: "sr-only", children: "Voice dictation" }),
141
- /* @__PURE__ */ jsx(DialogPrimitive.Description, { className: "sr-only", children: "Record your message, then choose Done to add the text. Cancel discards the recording." }),
142
- /* @__PURE__ */ jsxs("div", { className: "flex-1 md:flex-initial w-full md:max-w-lg md:rounded-xl bg-background flex flex-col md:max-h-[80vh] md:shadow-2xl md:border md:border-border", children: [
143
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-3 border-b border-border md:rounded-t-xl", children: [
144
- /* @__PURE__ */ jsx("span", { role: "status", className: "font-mono text-xs uppercase tracking-wider text-muted-foreground", children: capture.state === "transcribing" ? "transcribing" : capture.state === "requesting" ? "microphone" : caption }),
145
- /* @__PURE__ */ jsx(
146
- "button",
147
- {
148
- type: "button",
149
- onClick: handleCancel,
150
- "aria-label": "Cancel",
151
- className: "p-1 -m-1 rounded-sm hover:bg-muted/60 transition-colors",
152
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
153
- }
154
- )
155
- ] }),
156
- /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col items-center justify-center px-6 text-center", children: [
157
- /* @__PURE__ */ jsxs("div", { className: "relative w-24 h-24 mb-10 flex items-center justify-center", children: [
158
- /* @__PURE__ */ jsx(
159
- "span",
160
- {
161
- "aria-hidden": true,
162
- className: cn(
163
- "absolute inset-0 rounded-full",
164
- error || busy || capture.state !== "recording" ? "bg-destructive/20" : "bg-destructive/20 animate-ping"
165
- )
166
- }
167
- ),
168
- /* @__PURE__ */ jsx(
169
- "span",
170
- {
171
- "aria-hidden": true,
172
- className: cn(
173
- "absolute inset-2 rounded-full",
174
- "bg-destructive/40"
175
- )
176
- }
177
- ),
178
- /* @__PURE__ */ jsx(Mic, { className: "relative h-9 w-9 text-destructive-foreground" })
179
- ] }),
180
- title && /* @__PURE__ */ jsx("div", { className: "text-base font-medium text-muted-foreground mb-3", children: title }),
181
- /* @__PURE__ */ jsx("p", { className: "text-xl md:text-2xl leading-relaxed min-h-[5rem] max-w-xl text-foreground", children: displayTranscript ? /* @__PURE__ */ jsxs(Fragment, { children: [
182
- /* @__PURE__ */ jsx("span", { children: transcript }),
183
- interim && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
184
- transcript ? " " : "",
185
- interim
186
- ] })
187
- ] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground italic text-base", children: capture.state === "transcribing" ? "Converting your recording to text\u2026" : capture.state === "requesting" ? "Allow microphone access to start." : "Start speaking, then choose Done." }) }),
188
- error && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive mt-4", children: error })
189
- ] }),
190
- /* @__PURE__ */ jsxs("div", { className: "border-t border-border px-4 py-4 pb-[calc(1rem+env(safe-area-inset-bottom))] md:pb-4 md:rounded-b-xl flex flex-col items-stretch gap-2", children: [
191
- /* @__PURE__ */ jsx(
192
- Button,
193
- {
194
- size: "lg",
195
- className: "h-12 w-full",
196
- onClick: () => void handleDone(),
197
- disabled: busy,
198
- children: capture.state === "transcribing" ? "Transcribing\u2026" : capture.canRetry ? "Retry transcription" : error ? "Try again" : "Done"
199
- }
200
- ),
201
- capture.canRetry && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => void capture.start(), children: "Record again" }),
202
- /* @__PURE__ */ jsx(
203
- "button",
204
- {
205
- type: "button",
206
- onClick: handleCancel,
207
- className: "text-sm text-muted-foreground hover:text-foreground py-1",
208
- children: "Cancel"
209
- }
210
- )
211
- ] })
212
- ] })
213
- ]
214
- }
215
- ) })
216
- }
217
- )
218
- ] });
219
- }
220
-
221
- export {
222
- VoiceDictationButton
223
- };