PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / ManageMenu / AiAgentDemo / DemoPromptBox.tsx

DemoPromptBox.tsx in Code Snippets 4.0.0-beta.2, at js/components/ManageMenu/AiAgentDemo/DemoPromptBox.tsx

55 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react'
2 import { __ } from '@wordpress/i18n'
3 import classnames from 'classnames'
4 import { Button } from '../../common/Button'
5
6 interface DemoPromptBoxProps {
7 value: string
8 submitLabel: string
9 placeholder: string
10 /** Whether the caret should blink at the end of the text. */
11 typing: boolean
12 /** Whether the walkthrough is clicking the send button right now. */
13 pressed?: boolean
14 /** Whether the agent is busy, as it is whenever the script is mid-step. */
15 disabled?: boolean
16 }
17
18 /**
19 * A read-only stand-in for the AI Agent's prompt box. The demo drives the text,
20 * so this renders a div rather than a textarea: nothing here accepts input.
21 */
22 export const DemoPromptBox: React.FC<DemoPromptBoxProps> = ({
23 value,
24 submitLabel,
25 placeholder,
26 typing,
27 pressed = false,
28 disabled = false
29 }) =>
30 <div className={classnames('ai-agent-prompt', 'ai-agent-demo-prompt', { 'is-typing': typing })}>
31 <div className="ai-agent-prompt__input ai-agent-demo-prompt__text" aria-live="polite">
32 {'' === value
33 ? <span className="ai-agent-demo-prompt__placeholder">{placeholder}</span>
34 : value}
35 {typing && <span className="ai-agent-demo-prompt__caret" aria-hidden="true" />}
36 </div>
37
38 <div className="ai-agent-prompt__footer">
39 <span className="ai-agent-prompt__hint">
40 {__('Enter to send · Shift/Ctrl/⌘+Enter for a new line', 'code-snippets')}
41 </span>
42
43 <Button
44 primary
45 type="button"
46 disabled={disabled}
47 className={classnames('ai-agent-demo-send', { 'demo-click': pressed })}
48 aria-hidden="true"
49 tabIndex={-1}
50 >
51 {submitLabel}
52 </Button>
53 </div>
54 </div>
55