| 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 |
|