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
Custom terms content
Data contract
cards:[{ "id": string, "name": string, "value": number, "faceValue": string, "price"?: string, "description"?: string, "disabled"?: boolean }]selected-id: a card id orcustom; absent picks the first enabled card, no enabled card falls back tocustomamount: custom amount (string, converted to number on submit);min-amountdefaults to1,max-amountto10000;currencysets the custom amount prefix (default¥)- The same-named property channel works too:
cardsaccepts 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-labelwith the card name - The custom amount block follows selection; amount errors use
aria-invalid - Terms is a native checkbox;
disabled/readonlydisables all interactions
Disabled
Read-only
API
oas-ecard
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
agreed | Whether the terms are accepted (controlled boolean attribute; toggling writes it back and emits oas-change) | boolean | — |
amount | Custom amount (string, converted to number on submit) | string | — |
cards | Card data (host-injected): JSON array [{ id, name, value, faceValue, price?, description?, disabled? }]; value is the submitted amount, faceValue / price are display strings | ECard[] | string | [] |
currency | Currency symbol prefix for the custom amount input (default ¥; display only) | string | ¥ |
disabled | Disables cards / amount / terms and the confirm button | boolean | — |
max-amount | Custom amount upper bound (integer, default 10000) | string | 10000 |
min-amount | Custom amount lower bound (integer, default 1) | string | 1 |
readonly | Read-only: cannot select, type, check or submit | boolean | — |
selected-id | Selected card id (controlled) or custom (custom amount); defaults to the first enabled card, falling back to custom | string | — |
Events
| Event | Description |
|---|---|
oas-change | Emitted when a card is selected, a custom amount is typed or terms are toggled; detail |
oas-invalid | Emitted when submit validation fails; detail { fields } (card / amount / agreement) |
oas-submit | Emitted when validation passes; detail |
Slots
| Name | Description |
|---|---|
agreement | Custom terms copy (replaces the default text; links allowed) |
CSS Variables
| CSS Variable | Default |
|---|---|
--oas-ecard-width | 100% |