API key field
Enter and manage an API key for an AI provider; ds::provider-keys is a
panel of them. Host-driven: the component never holds a key.
Form control. It takes input in a form, so it is drawn on the Every input type block, beside every other control, as it starts and with an error where it has one.
Anatomy
form|div[x-data][data-ds-api-key-field=status] (listeners on the tag land here)
├── div logo (slot or img) + label[for]
├── [hint] button[type=submit][hidden] value=save the form's default button
├── [hint] div key icon · "Saved key:" (sr) code hint · Test · confirm-button Remove (intent=remove)
├── [hint] details > summary "Replace key" > input row open with an error
│ [no hint] input row
│ ds::input type=password reveal (revealLabel "Show key") · Test · Save (with action)
├── p#status[role=status] agent mark + words empty:sr-only
├── p#error
└── p#help help + "Keys start with sk-."
Security, enforced in the view
- A
valueattribute throws. The input never has a value on the page; onlyhint, masked by the host, is rendered. autocomplete=off,spellcheck=false,autocapitalize=off,autocorrect=off;data-1p-ignore,data-lpignore,data-bwignore,data-form-type=otherwritten as a courtesy, documented as not relied on.- Reveal is ds::input's (
dsPassword): it shows only what is being typed and goes back to hidden on submit. The script stores and logs nothing. - With a hint, a hidden first submit button (
intent=save) is the form's default button: measured in Chromium, Enter in the replacement field otherwise clicked Remove's confirm control, the first submit in tree order.
Status
unset (nothing), set (lock, "Saved"), checking, valid, invalid
drawn with the agent marks of running, done and failed. invalid or an
error sets aria-invalid. message replaces the words.
Intents
Test, Remove and Save post {intent}=test|remove|save; ds::provider-keys
gives each row keys[id] and intent[id] in one form. Test dispatches
test (bubbling, cancelable) first; cancelled, nothing posts.
Accessibility
| Role | a labelled password field; Replace a native disclosure |
| Name | the label (":provider API key"); reveal "Show key" (aria-pressed) |
| Description | status, error, help by aria-describedby |
| Keyboard | Tab: Test, Remove (then its Cancel and confirm), Replace, the field, reveal, Save |
| Announcement | the status line is polite and always in the page |
| Focus | every control draws the system ring |
Do not
- Do not pass the key. Not as
value, not as a hint that is most of it. - Do not turn
prefixinto validation. It is a hint.
From the package repo: edit this page on GitHub.