Skip to content

ECard ​

E-card / stored-value card purchase panel: card radio list, custom amount, terms acceptance and confirm. Card data and amount bounds are host-injected.

Basic usage ​

cards injects card faces: value is the submitted amount (number), faceValue / price are display strings.

Card selection

Custom amount ​

Choosing “Custom amount” reveals the amount input; min-amount / max-amount bound integer values. Out-of-range submits emit oas-invalid.

Custom amount

Terms and submit ​

The confirm button is always clickable and validates card / amount / terms on click: failure emits oas-invalid (detail { fields }), success emits oas-submit (detail { card, cardId, amount, custom, agreed }). Override the terms copy with slot="agreement" (e.g. to add a link).

Terms and submit

Waiting for submit

Custom terms content

I have read and agree to the e-card terms

Data contract ​

  • cards: [{ "id": string, "name": string, "value": number, "faceValue": string, "price"?: string, "description"?: string, "disabled"?: boolean }]
  • selected-id: a card id or custom; absent picks the first enabled card, no enabled card falls back to custom
  • amount: custom amount (string, converted to number on submit); min-amount defaults to 1, max-amount to 10000; currency sets the custom amount prefix (default ¥)
  • The same-named property channel works too: cards accepts an array directly (serialized and reflected into the JSON attribute; the getter returns the parsed form)

Currency symbol ​

currency only changes the custom amount prefix (default ¥); the submitted amount stays numeric, so cross-border flows just swap the symbol.

Custom currency symbol

Accessibility ​

  • Cards form a native radio group; each radio has an aria-label with the card name
  • The custom amount block follows selection; amount errors use aria-invalid
  • Terms is a native checkbox; disabled / readonly disables all interactions

Disabled

Read-only

API ​

oas-ecard ​

Attributes ​

AttributeDescriptionTypeDefault
agreedWhether the terms are accepted (controlled boolean attribute; toggling writes it back and emits oas-change)boolean—
amountCustom amount (string, converted to number on submit)string—
cardsCard data (host-injected): JSON array [{ id, name, value, faceValue, price?, description?, disabled? }]; value is the submitted amount, faceValue / price are display stringsECard[] | string[]
currencyCurrency symbol prefix for the custom amount input (default ¥; display only)string¥
disabledDisables cards / amount / terms and the confirm buttonboolean—
max-amountCustom amount upper bound (integer, default 10000)string10000
min-amountCustom amount lower bound (integer, default 1)string1
readonlyRead-only: cannot select, type, check or submitboolean—
selected-idSelected card id (controlled) or custom (custom amount); defaults to the first enabled card, falling back to customstring—

Events ​

EventDescription
oas-changeEmitted when a card is selected, a custom amount is typed or terms are toggled; detail
oas-invalidEmitted when submit validation fails; detail { fields } (card / amount / agreement)
oas-submitEmitted when validation passes; detail

Slots ​

NameDescription
agreementCustom terms copy (replaces the default text; links allowed)

CSS Variables ​

CSS VariableDefault
--oas-ecard-width100%

Released under the MIT OR Apache-2.0 License.