Skip to content

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

Waiting for submit

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

No saved title selected

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 invalid
  • save-titles: [{ "id"?: string, "type": "personal" | "company", "title": string, "taxId"?: string }]; the entry is hidden when absent or invalid
  • Submitted value: { type, title, taxId, content } via detail.value of oas-submit
  • The same-named property channels work too: contents / saveTitles accept arrays directly (serialized and reflected into the JSON attributes)
  • When content is not among the contents options (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 ​

AttributeDescriptionTypeDefault
contentSelected invoice content (controlled); must match a value in contentsstring—
contentsInvoice content options (host-injected): JSON array [{ value, label }]; the content field is hidden when absent or invalidInvoiceContent[] | string[]
disabledDisables all inputs, the popup entry and submitboolean—
readonlyRead-only: focusable and copyable, but cannot edit / select / submitboolean—
save-titlesSaved titles (host-injected): JSON array [{ id?, type, title, taxId? }]; the popup entry is hidden when absent or invalidInvoiceSavedTitle[] | string[]
tax-idTax ID (controlled); validated as 15–20 letters or digits for company titlesstring—
titleInvoice title (controlled); typing emits oas-change and a successful submit writes it backstring—
typeTitle type: personal (default) / company; company shows and validates the tax IDstringpersonal

Events ​

EventDescription
oas-changeEmitted on field or title-type change; detail { field, value } (field: type / title / taxId / content / saved)
oas-invalidEmitted when submit validation fails; detail { fields }, marks errors and focuses the first invalid field
oas-submitEmitted when validation passes; detail { value } ({ type, title, taxId, content })
oas-title-selectEmitted when a saved title is picked; detail { id, value } (value already applied to the form)

CSS Variables ​

CSS VariableDefault
--oas-invoice-width100%

Released under the MIT OR Apache-2.0 License.