WIP: form attachments (e-mail only) — core, endpoint, Graph large upload

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-13 16:20:02 +01:00
co-authored by Claude Fable 5.2
parent 0ba0014ed5
commit 6003b3d7d7
36 changed files with 2399 additions and 97 deletions
+27 -1
View File
@@ -8,6 +8,7 @@ import type { TurnstileTheme } from '../turnstile/Turnstile.js'
import type { BuilderField } from './builderTypes.js'
import type { BuilderFormApi, UseBuilderFormOptions } from './useBuilderForm.js'
import { formatFileSize } from './attachments/fileTypes.js'
import { honeypotInputProps } from './honeypot.js'
import { useBuilderForm } from './useBuilderForm.js'
@@ -19,7 +20,8 @@ import { useBuilderForm } from './useBuilderForm.js'
export type BuilderFormClassNames = Partial<
Record<
| 'actions' | 'back' | 'checkbox' | 'checkboxLabel' | 'choice' | 'choiceInput' | 'choiceLabel' | 'choices'
| 'error' | 'field' | 'fieldFull' | 'fieldHalf' | 'fields' | 'fixed' | 'form' | 'formError' | 'input' | 'label'
| 'error' | 'field' | 'fieldFull' | 'fieldHalf' | 'fields' | 'file' | 'fileItem' | 'fileList' | 'fileRemove' | 'fixed'
| 'form' | 'formError' | 'help' | 'input' | 'label'
| 'legend' | 'message' | 'next' | 'progress' | 'required' | 'select' | 'step' | 'stepDescription'
| 'stepTitle' | 'submit' | 'success' | 'textarea' | 'turnstile',
string
@@ -161,6 +163,30 @@ export function BuilderForm({
{errorOf(field)}
</fieldset>
)
case 'file': {
// A native file input: keyboard, touch and screen readers work as everywhere else.
const props = f.getFileProps(field)
const files = f.getFiles(field)
const remove = options.texts.fileRemove ?? 'Remove {file}'
return (
<>
<label className={cn.label} htmlFor={props.id}>{label(field)}</label>
<input {...props} className={cn.file ?? cn.input} />
{field.help ? <p className={cn.help} id={f.helpId(field)}>{field.help}</p> : null}
<ul aria-live="polite" className={cn.fileList} data-ipal="form-files">
{files.map((file, i) => (
<li className={cn.fileItem} key={`${file.name}-${file.size}-${i}`}>
<span>{file.name} ({formatFileSize(file.size)})</span>{' '}
<button className={cn.fileRemove} onClick={() => f.removeFile(field, i)} type="button">
{remove.replace('{file}', file.name)}
</button>
</li>
))}
</ul>
{errorOf(field)}
</>
)
}
case 'select': {
const props = f.getSelectProps(field)
return (