Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions skills/tedi-angular/references/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,28 @@ Both entry points declare `[tedi-floating-button]`. The Community component is
the component owns the rule. No `registerOnValidatorChange` is needed — `validate()` is a pure
function of the control value, which Angular already revalidates on every change.
- **`tedi-file-dropzone` emits `fileRemove` alongside `filesChange`.** `filesChange` gives the new list;
`fileRemove` gives the single entry the user deleted, so an in-flight upload can be aborted or a blob
URL revoked without diffing the two arrays.
`fileRemove` gives each entry that left it — one the user deleted, the file a single-file zone
replaced, or one `duplicates="replace"` swapped out — so an in-flight upload can be aborted or a blob
URL revoked without diffing the two arrays. It fires after the list change.
- **`tedi-file-dropzone` selects files, it does not upload them.** It validates against `accept` and
`maxSize` and hands you the list; the upload, and setting each file's `isLoading` / `isValid` as it
progresses, is yours. A `validator` input adds a rule of your own on top, run on every selected file;
progresses, is yours. It does announce the result you report back: a listed file whose `isLoading`
ends is announced as uploaded, and one that turns invalid (`isValid: false`, or an `error`) as
failed, with its `error` as the reason. A file is followed by its `id`, so give every file one and
keep it unchanged in the array you set. Without an `id` a file is followed by its name, and files that
share a name may not be announced. A `validator` input adds a rule of your own on top, run on every selected file;
the reason it returns lands on that file's `error` after the built-in ones and joins the summary,
with the files it rejected named after it. Describe the rule in `hint`, which follows the allowed
types and size in the one hint. `keepRejectedFiles` decides what happens to a file that fails
`accept`, `maxSize` or `validator`: off (the default) discards it and summarises every rejection in
one message under the dropzone, which paints the border red. On keeps it in the list with its
reason in that file's `error` and writes no summary of its own — so the form value holds it with
reason in that file's `error` and summarises only the files it did not list — a single-file zone
keeps a valid file over a rejected one — so the form value holds a listed one with
`isValid: false`, and you must drop the files marked `isValid: false` before uploading. Filter on
that, not on a truthy `isValid`: a preloaded file leaves it unset, and such a file is eligible. The
dropzone's own border stays neutral, but a bound control fails on that file, so the border turns
red once the control is touched or dirty. `error` is writable, so a failure the upload came back
dropzone's own border stays neutral for a listed rejected file, but a bound control fails on it, so
the border turns red once the control is touched or dirty; a rejected file it could not list turns
it red at once. `error` is writable, so a failure the upload came back
with lands on the file it belongs to.
- **`tedi-file-dropzone` shows at most one hint and one validation message, error first.** Pass your
own text through `hint`, `error` and `success`, not projected `tedi-feedback-text`. `error` joins
Expand All @@ -256,7 +263,8 @@ Both entry points declare `[tedi-floating-button]`. The Community component is
— so two different files sharing a name still both land. `duplicates` changes that: `rename` keeps
both with the newcomer as `scan (1).pdf`, `replace` swaps the listed file for it. Those two match on
the name alone, since that is the collision the user sees, and only a file that passes displaces its
namesake. Project an `*tediFileDropzoneFile` template to replace the built-in `tedi-attachment` row
namesake. A single-file zone always skips: the same file picked again is left alone, and any other
file replaces the one held under its own name. Project an `*tediFileDropzoneFile` template to replace the built-in `tedi-attachment` row
when a file needs a progress bar, an icon or its own feedback.
- **`accept`, `maxSize` and `validator` apply to what is picked next.** Files already listed keep the
verdict they were given, so clear them yourself if you tighten a restriction while they are listed.
Expand All @@ -275,7 +283,9 @@ Both entry points declare `[tedi-floating-button]`. The Community component is
required dropzone is marked in two places: `[required]` on the label draws the asterisk, which is
`aria-hidden`, and `[required]` on the dropzone adds the word to the zone's accessible name. The
zone is a button, which ARIA gives no `aria-required`, and the file input behind it is hidden from
assistive technology, so the name is the only carrier left. Don't wrap it in `tedi-form-field` —
assistive technology, so the name is the only carrier left. A required dropzone therefore always
needs a visible label marked `[required]`; without one no asterisk is shown and a warning is logged
in dev mode. Only an optional dropzone can go without a label. Don't wrap it in `tedi-form-field` —
that would place projected feedback after the file list rather than under the dropzone.
- **The drop zone is a `div[role="button"]`, not a `<label>` or a native `<button>`** — the same shape
React and react-dropzone use, and the reason is screen readers, not styling. The file input is
Expand All @@ -285,9 +295,9 @@ Both entry points declare `[tedi-floating-button]`. The Community component is
activation, Enter and Space are wired by hand in `handleKeydown`, and `disabled` is `aria-disabled`
plus `tabindex="-1"` with both the click and key paths guarded. Carbon, USWDS, GOV.UK and Polaris all
avoid making the file input the focus target for the same reason.
- **Selections are announced assertively and on a delay; removals are polite and immediate.** Closing
- **Selections are announced politely after a delay; removals are polite and immediate.** Closing
the file dialog leaves the screen reader busy for a moment, and a message inserted during it is
dropped rather than queued. Removal involves no dialog, so it needs neither. Announcements go through
dropped rather than queued. Removal involves no dialog, so it needs no delay. Announcements go through
`ToastAnnouncerService`, whose regions live on `<body>`: a live region inside the component is
silently dropped when the rows around it re-render, which is what happens on every selection.

Expand All @@ -312,8 +322,9 @@ Both entry points declare `[tedi-floating-button]`. The Community component is
- **`tedi-file-upload` validates itself.** It registers on `NG_VALIDATORS`, so a bound control fails
with a `rejectedFiles` error while any `isValid: false` file is listed. By default a file that
fails `accept`, `maxSize` or `validator` is discarded and only the summary under the field remains;
`keepRejectedFiles` keeps it in the list, marked invalid, instead. It shows as a danger tag; only a
single file in a field without `multiple` shows just its name. Drop the files marked
`keepRejectedFiles` keeps it in the list, marked invalid, as a danger tag; only a single file in a
field without `multiple` shows just its name. A field without `multiple` keeps a valid file over a
rejected pick and names the pick in the summary. Drop the files marked
`isValid: false` before uploading either way; a preloaded file leaves `isValid` unset and is
eligible. `accept`, `maxSize` and `validator` apply to the next selection; files already
listed keep their verdict, so clear them yourself if you tighten a rule.
Expand All @@ -326,7 +337,10 @@ Both entry points declare `[tedi-floating-button]`. The Community component is
whether removed, cleared or replaced by the next pick in a single-file field, so an in-flight upload can be aborted without diffing
`filesChange`. Set `isLoading` on a file yourself while it uploads: its tag shows a spinner and
loses its remove button. The clear button still removes it, so a stuck upload is
never stranded; clear `isLoading` and set `isValid: false` on failure or timeout.
never stranded; clear `isLoading` and set `isValid: false` on failure or timeout. The field
announces either outcome: uploaded when `isLoading` ends, failed when the file turns invalid. It
follows a file by its `id`, so give every file one and keep it unchanged; without one a file is followed
by its name, and files that share a name may not be announced.
- **Below `md` it stacks**: files above a full-width button row, and the clear button becomes a text
button. There is no input for this.
- **`readOnly` renders the files as a list named by the label**, even a single file, which is a list of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
[name]="row.name"
[fileSize]="row.size"
[error]="row.file.error"
[invalid]="row.file.isValid === false"
[invalid]="row.isRejected"
>
<tedi-attachment-actions>
<tedi-tooltip>
Expand Down
Loading
Loading