Invoice
Invoice information form: title-type switching, title and tax ID validation, invoice content selection and a saved-title popup. All data is host-injected (contents / save-titles); the component stores nothing.
Basic usage
A personal title only needs the title text; contents injects invoice content options.
Personal title
Company title and tax ID validation
type="company" shows the tax ID field; the tax ID must be 15–20 letters or digits. A failed submit emits oas-invalid and focuses the first invalid field.
Company title
Saved-title popup
save-titles injects historical titles: the trigger opens a role="listbox" popup with ↑ / ↓ navigation, Enter to pick, Esc to close and return focus, and outside click to close. Picking fills type / title / tax ID and emits oas-title-select.
Pick a saved title
Title-type switching
The type switch is a radio group (role="radiogroup") supporting ← / →. Switching keeps the typed title draft and emits oas-change (detail { field: 'type', value }).
Type switch
Data contract
contents:[{ "value": string, "label": string }]; the content field is hidden when absent or invalidsave-titles:[{ "id"?: string, "type": "personal" | "company", "title": string, "taxId"?: string }]; the entry is hidden when absent or invalid- Submitted value:
{ type, title, taxId, content }viadetail.valueofoas-submit - The same-named property channels work too:
contents/saveTitlesaccept arrays directly (serialized and reflected into the JSON attributes) - When
contentis not among thecontentsoptions (host replaced them), dev builds warn and fall back to the first option, writing it back to the attribute
Accessibility
- Inputs are label-associated; errors use
aria-invalid/aria-describedby - Saved-title popup: trigger has
aria-haspopup="listbox"+aria-expanded; the listbox has an accessible name - With
disabled/readonly, inputs, popup trigger and submit are disabled
Disabled
Read-only
API
oas-invoice
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
content | Selected invoice content (controlled); must match a value in contents | string | — |
contents | Invoice content options (host-injected): JSON array [{ value, label }]; the content field is hidden when absent or invalid | InvoiceContent[] | string | [] |
disabled | Disables all inputs, the popup entry and submit | boolean | — |
readonly | Read-only: focusable and copyable, but cannot edit / select / submit | boolean | — |
save-titles | Saved titles (host-injected): JSON array [{ id?, type, title, taxId? }]; the popup entry is hidden when absent or invalid | InvoiceSavedTitle[] | string | [] |
tax-id | Tax ID (controlled); validated as 15–20 letters or digits for company titles | string | — |
title | Invoice title (controlled); typing emits oas-change and a successful submit writes it back | string | — |
type | Title type: personal (default) / company; company shows and validates the tax ID | string | personal |
Events
| Event | Description |
|---|---|
oas-change | Emitted on field or title-type change; detail { field, value } (field: type / title / taxId / content / saved) |
oas-invalid | Emitted when submit validation fails; detail { fields }, marks errors and focuses the first invalid field |
oas-submit | Emitted when validation passes; detail { value } ({ type, title, taxId, content }) |
oas-title-select | Emitted when a saved title is picked; detail { id, value } (value already applied to the form) |
CSS Variables
| CSS Variable | Default |
|---|---|
--oas-invoice-width | 100% |