ai-design-system 0.1.101 → 0.1.102

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.
@@ -16,6 +16,7 @@ const meta = {
16
16
  args: {
17
17
  onBack: fn(),
18
18
  onClose: fn(),
19
+ onSubmit: fn(),
19
20
  onPublish: fn(),
20
21
  onSceneChange: fn(),
21
22
  },
@@ -1,8 +1,11 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
+ import type { FormEvent } from "react";
4
5
  import { Button } from "@/components/primitives/Button";
5
6
  import { Icon } from "@/components/primitives/Icon";
7
+ import { PromptInput } from "@/components/composites/PromptInput";
8
+ import type { PromptInputMessage } from "@/components/ai-elements/prompt-input";
6
9
  import { cn } from "@/lib/utils";
7
10
 
8
11
  export interface SceneItem {
@@ -18,7 +21,7 @@ export interface SceneItem {
18
21
  [key: string]: unknown;
19
22
  }
20
23
 
21
- export interface ScenePlayerProps extends React.HTMLAttributes<HTMLDivElement> {
24
+ export interface ScenePlayerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSubmit"> {
22
25
  scenes: SceneItem[];
23
26
  title?: string;
24
27
  avatarInitials?: string;
@@ -27,7 +30,17 @@ export interface ScenePlayerProps extends React.HTMLAttributes<HTMLDivElement> {
27
30
  isMuted?: boolean;
28
31
  onBack?: () => void;
29
32
  onClose?: () => void;
30
- onPublish?: (currentScene: SceneItem) => void;
33
+ placeholder?: string;
34
+ promptValue?: string;
35
+ onPromptValueChange?: (value: string) => void;
36
+ onSubmit?: (
37
+ message: PromptInputMessage,
38
+ event: FormEvent<HTMLFormElement>
39
+ ) => void | Promise<void>;
40
+ loading?: boolean;
41
+ onStop?: () => void;
42
+ enableSpeech?: boolean;
43
+ onPublish?: (currentScene: SceneItem, text?: string) => void;
31
44
  publishPlaceholder?: string;
32
45
  onSceneChange?: (sceneIndex: number, scene: SceneItem) => void;
33
46
  }
@@ -43,8 +56,15 @@ export const ScenePlayer = React.forwardRef<HTMLDivElement, ScenePlayerProps>(
43
56
  isMuted: initialMuted = false,
44
57
  onBack,
45
58
  onClose,
59
+ placeholder,
60
+ promptValue,
61
+ onPromptValueChange,
62
+ onSubmit,
63
+ loading = false,
64
+ onStop,
65
+ enableSpeech = true,
46
66
  onPublish,
47
- publishPlaceholder = "Ready to publish...",
67
+ publishPlaceholder = "Ask a question or provide instructions...",
48
68
  onSceneChange,
49
69
  className,
50
70
  ...props
@@ -65,6 +85,19 @@ export const ScenePlayer = React.forwardRef<HTMLDivElement, ScenePlayerProps>(
65
85
 
66
86
  const activeScene = scenes[currentSceneIndex] || scenes[0];
67
87
 
88
+ const handlePromptSubmit = React.useCallback(
89
+ (message: PromptInputMessage, event: FormEvent<HTMLFormElement>) => {
90
+ if (onSubmit) {
91
+ onSubmit(message, event);
92
+ return;
93
+ }
94
+ if (onPublish) {
95
+ onPublish(activeScene, message.text);
96
+ }
97
+ },
98
+ [onSubmit, onPublish, activeScene]
99
+ );
100
+
68
101
  const handlePrev = React.useCallback(() => {
69
102
  if (!scenes.length) return;
70
103
  setCurrentSceneIndex((prev) => {
@@ -269,21 +302,18 @@ export const ScenePlayer = React.forwardRef<HTMLDivElement, ScenePlayerProps>(
269
302
  </div>
270
303
  </div>
271
304
 
272
- {/* Bottom Action Bar */}
273
- <div className="flex items-center gap-3 px-4 py-3.5 bg-black z-20 shrink-0">
274
- <div className="flex-1 h-11 rounded-full bg-white/15 border border-white/25 px-4 flex items-center text-sm text-white/65 select-none truncate">
275
- {publishPlaceholder}
276
- </div>
277
- <Button
278
- variant="ghost"
279
- size="icon"
280
- data-testid="btn-publish-scene"
281
- aria-label="Publish scene"
282
- onClick={() => onPublish?.(activeScene)}
283
- className="w-11 h-11 rounded-full bg-emerald-500 hover:bg-emerald-600 text-white shrink-0 p-0 shadow-md cursor-pointer transition-transform active:scale-95"
284
- >
285
- <Icon name="send" className="w-4 h-4 text-white" />
286
- </Button>
305
+ {/* Bottom PromptInput Composite from Design System */}
306
+ <div className="p-3 bg-gradient-to-t from-black via-black/90 to-transparent pt-4 z-20 shrink-0">
307
+ <PromptInput
308
+ placeholder={placeholder || publishPlaceholder}
309
+ value={promptValue}
310
+ onChange={onPromptValueChange}
311
+ onSubmit={handlePromptSubmit}
312
+ loading={loading}
313
+ onStop={onStop}
314
+ enableSpeech={enableSpeech}
315
+ className="border border-border bg-background shadow-md overflow-hidden rounded-2xl"
316
+ />
287
317
  </div>
288
318
  </div>
289
319
  );
package/dist/index.cjs CHANGED
@@ -14577,8 +14577,15 @@ var ScenePlayer = React3__namespace.forwardRef(
14577
14577
  isMuted: initialMuted = false,
14578
14578
  onBack,
14579
14579
  onClose,
14580
+ placeholder,
14581
+ promptValue,
14582
+ onPromptValueChange,
14583
+ onSubmit,
14584
+ loading = false,
14585
+ onStop,
14586
+ enableSpeech = true,
14580
14587
  onPublish,
14581
- publishPlaceholder = "Ready to publish...",
14588
+ publishPlaceholder = "Ask a question or provide instructions...",
14582
14589
  onSceneChange,
14583
14590
  className
14584
14591
  } = _b, props = __objRest(_b, [
@@ -14590,6 +14597,13 @@ var ScenePlayer = React3__namespace.forwardRef(
14590
14597
  "isMuted",
14591
14598
  "onBack",
14592
14599
  "onClose",
14600
+ "placeholder",
14601
+ "promptValue",
14602
+ "onPromptValueChange",
14603
+ "onSubmit",
14604
+ "loading",
14605
+ "onStop",
14606
+ "enableSpeech",
14593
14607
  "onPublish",
14594
14608
  "publishPlaceholder",
14595
14609
  "onSceneChange",
@@ -14606,6 +14620,18 @@ var ScenePlayer = React3__namespace.forwardRef(
14606
14620
  const [isMuted, setIsMuted] = React3__namespace.useState(initialMuted);
14607
14621
  const videoRef = React3__namespace.useRef(null);
14608
14622
  const activeScene = scenes[currentSceneIndex] || scenes[0];
14623
+ const handlePromptSubmit = React3__namespace.useCallback(
14624
+ (message, event) => {
14625
+ if (onSubmit) {
14626
+ onSubmit(message, event);
14627
+ return;
14628
+ }
14629
+ if (onPublish) {
14630
+ onPublish(activeScene, message.text);
14631
+ }
14632
+ },
14633
+ [onSubmit, onPublish, activeScene]
14634
+ );
14609
14635
  const handlePrev = React3__namespace.useCallback(() => {
14610
14636
  if (!scenes.length) return;
14611
14637
  setCurrentSceneIndex((prev) => {
@@ -14805,21 +14831,19 @@ var ScenePlayer = React3__namespace.forwardRef(
14805
14831
  )
14806
14832
  ] })
14807
14833
  ] }),
14808
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 px-4 py-3.5 bg-black z-20 shrink-0", children: [
14809
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-11 rounded-full bg-white/15 border border-white/25 px-4 flex items-center text-sm text-white/65 select-none truncate", children: publishPlaceholder }),
14810
- /* @__PURE__ */ jsxRuntime.jsx(
14811
- Button2,
14812
- {
14813
- variant: "ghost",
14814
- size: "icon",
14815
- "data-testid": "btn-publish-scene",
14816
- "aria-label": "Publish scene",
14817
- onClick: () => onPublish == null ? void 0 : onPublish(activeScene),
14818
- className: "w-11 h-11 rounded-full bg-emerald-500 hover:bg-emerald-600 text-white shrink-0 p-0 shadow-md cursor-pointer transition-transform active:scale-95",
14819
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "send", className: "w-4 h-4 text-white" })
14820
- }
14821
- )
14822
- ] })
14834
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 bg-gradient-to-t from-black via-black/90 to-transparent pt-4 z-20 shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
14835
+ PromptInput2,
14836
+ {
14837
+ placeholder: placeholder || publishPlaceholder,
14838
+ value: promptValue,
14839
+ onChange: onPromptValueChange,
14840
+ onSubmit: handlePromptSubmit,
14841
+ loading,
14842
+ onStop,
14843
+ enableSpeech,
14844
+ className: "border border-border bg-background shadow-md overflow-hidden rounded-2xl"
14845
+ }
14846
+ ) })
14823
14847
  ]
14824
14848
  })
14825
14849
  );