| 1 |
import React, { useId } from 'react' |
| 2 |
import { __ } from '@wordpress/i18n' |
| 3 |
import { useSnippetForm } from '../../SnippetForm/WithSnippetFormContext' |
| 4 |
import { Tooltip } from '../../../common/Tooltip' |
| 5 |
|
| 6 |
export const PriorityInput = () => { |
| 7 |
const { snippet, isReadOnly, setSnippet } = useSnippetForm() |
| 8 |
const priorityId = useId() |
| 9 |
|
| 10 |
return ( |
| 11 |
<div className="snippet-priority inline-form-field"> |
| 12 |
<label htmlFor={priorityId} id="snippet-priority-label"> |
| 13 |
{__('Priority', 'code-snippets')} |
| 14 |
</label> |
| 15 |
|
| 16 |
<Tooltip block end className="priority-input-tooltip"> |
| 17 |
{__('Snippets with a lower priority number will run before those with a higher number.', 'code-snippets')} |
| 18 |
</Tooltip> |
| 19 |
|
| 20 |
<input |
| 21 |
type="number" |
| 22 |
id={priorityId} |
| 23 |
name="snippet_priority" |
| 24 |
value={snippet.priority} |
| 25 |
disabled={isReadOnly} |
| 26 |
aria-labelledby="snippet-priority-label" |
| 27 |
onChange={event => setSnippet(previous => ({ |
| 28 |
...previous, |
| 29 |
priority: parseInt(event.target.value, 10) |
| 30 |
}))} |
| 31 |
/> |
| 32 |
</div> |
| 33 |
) |
| 34 |
} |
| 35 |
|