Add text import export for toolbox modules
This commit is contained in:
parent
a9b5ca423a
commit
117b7b79e1
27 changed files with 1430 additions and 181 deletions
|
|
@ -1,10 +1,10 @@
|
|||
// Rôle : affiche la modale d'import texte partagée par les outils compatibles.
|
||||
// Rôle : affiche la modale d'import/export texte partagée par les outils compatibles.
|
||||
import { useEffect } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { Icon } from "../../../components/Icon.jsx";
|
||||
import { lockBodyScroll } from "../../../utils/bodyScrollLock.js";
|
||||
|
||||
export function TextImportModal({ title, value, placeholder, submitLabel, onChange, onSubmit, onClose }) {
|
||||
export function TextImportModal({ title, value, placeholder, submitLabel, readOnly = false, error = "", info = "", onChange, onSubmit, onCopy, onClose }) {
|
||||
useEffect(() => {
|
||||
function handleKeyDown(event) {
|
||||
if (event.key === "Escape") onClose();
|
||||
|
|
@ -31,14 +31,34 @@ export function TextImportModal({ title, value, placeholder, submitLabel, onChan
|
|||
<form className="text-import-modal-form" onSubmit={onSubmit}>
|
||||
<textarea
|
||||
autoFocus
|
||||
className={error ? "has-error" : ""}
|
||||
readOnly={readOnly}
|
||||
value={value}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
onChange={(event) => onChange?.(event.target.value)}
|
||||
placeholder={placeholder}
|
||||
rows={9}
|
||||
aria-invalid={Boolean(error)}
|
||||
aria-describedby={error ? "text-import-error" : undefined}
|
||||
/>
|
||||
{info && (
|
||||
<p className="text-import-info">
|
||||
<Icon name="info" />
|
||||
<span>{info}</span>
|
||||
</p>
|
||||
)}
|
||||
{error && (
|
||||
<p className="text-import-error" id="text-import-error" role="alert">
|
||||
<Icon name="close" />
|
||||
<span>{error}</span>
|
||||
</p>
|
||||
)}
|
||||
<footer>
|
||||
<button type="button" onClick={onClose}>Annuler</button>
|
||||
<button className="primary" type="submit">{submitLabel}</button>
|
||||
{readOnly ? (
|
||||
<button className="primary" type="button" onClick={onCopy}>{submitLabel}</button>
|
||||
) : (
|
||||
<button className="primary" type="submit">{submitLabel}</button>
|
||||
)}
|
||||
</footer>
|
||||
</form>
|
||||
</section>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue