GoodsList
Container for product list pages: layout="waterfall" (default) renders a waterfall — columns is a fixed number or auto by container width (<640 → 2 columns, <1024 → 3, otherwise 4), and cards are placed into the shortest column by accumulated height; layout="list" renders a single vertical column. The data face is the items JSON dual channel (built-in simple cards, aligned with oas-product-card: missing-image placeholder, struck-through original price, two-line title clamp); the default slot can fully replace the built-in cards with the host's own cards (slot wins over the default rendering). Reaching the bottom emits oas-load-more; the host sets loading for the loading state and no-more for the end-of-list state.
Basic usage
Built-in simple card: image (missing / failed load → dashed placeholder) + two-line clamped title + tag row + price (price / originalPrice, with currency / locale / precision passed to oas-price). Clicking a card emits oas-item-click (detail carries index and the full item):
Waterfall with auto columns + built-in cards
Click a product card to see oas-item-click feedback.
Fixed columns and vertical list
Write a fixed number (1–8) into columns; layout="list" ignores it and renders a single vertical column of horizontal rows (image on the start side, info column beside it):
Fixed 3 columns vs vertical list
Card-slot replacement
When the default slot has content, items is ignored — the host supplies its own cards (e.g. oas-product-card), and the container balances them into columns by measured height; card content, clicks and navigation are fully owned by the host:
Host oas-product-card in the card slot
Load more and empty state
Reaching the bottom emits oas-load-more (a sentinel enters the viewport 240px early); the host sets loading to show the spinner, appends items, then removes loading; no-more shows the end-of-list text and stops further emission. The empty slot replaces the empty state (default "no products yet" text):
Load more (button simulates bottom) + empty state
Empty state (empty slot)
Server-side pagination protocol (capability subpath)
For server-side cursor pagination over the bottom-reach protocol, use the capability subpath @oas-ui/ui/commerce/goods-list/paged (helper: headless cursor state machine, import on demand — the base API is unchanged; the integration rides entirely on the existing bottom-reach protocol). createPagedSource owns the state: the first page carries no cursor, later pages carry the previous page's trailing cursor; in-flight calls are deduplicated; a failed load leaves the cursor untouched (retry = call loadPage() again); reset() covers the filter-switch scenario (clears the accumulation with an epoch guard — a stale in-flight page is discarded once it resolves, so old responses never pollute the new list):
Server pagination closed loop (mocked cursor backend, real bottom-reach triggers)
Host glue (the demo's complete loop — bottom reach → loadPage → append → cursor advance → no-more end):
import { createPagedSource } from '@oas-ui/ui/commerce/goods-list/paged'
const source = createPagedSource({
load: ({ cursor, page }) => fetch(`/api/goods?cursor=${cursor ?? ''}&page=${page}`).then((r) => r.json()),
getItems: (res) => res.data.list, // default reads res.items
getCursor: (res) => res.data.nextCursor, // default reads res.cursor
})
list.addEventListener('oas-load-more', async () => {
if (source.pending) return // in-flight dedup
if (source.done) { list.setAttribute('no-more', ''); return }
list.setAttribute('loading', '') // answers the bottom reach
try {
await source.loadPage()
list.items = source.items // append
} catch { /* failure rendering is the host's job; cursor untouched, just call loadPage again */ } finally {
list.removeAttribute('loading')
if (source.done) list.setAttribute('no-more', '')
}
})Keyboard and accessibility
- The card grid container carries
role="list"+ built-in cards asrole="listitem"(column divs arepresentationso the list semantics stay unbroken), witharia-label"Product list"; the load-more region is anaria-live="polite"role="status"region (loading / end-of-list changes are announced) and sits outside the list semantics, along with the empty state and the sentinel. - Built-in cards are Tab-focusable and Enter emits
oas-item-click; the imagealttakes the title, and the missing-image placeholder text goes intoaria-label(not rendered on screen). Slotted cards getrole="listitem"added by the component once moved into columns (a host-provided role is not overwritten). layout="list"renders horizontal rows (fixed-size image on the start side + an info column beside it), stacked vertically.- The waterfall DOM order matches the declared card order (column placement does not change the screen-reader order); layout uses logical properties and mirrors automatically under RTL.
Styling notes
::part(grid) is the multi-column flex container (columns ::part(col) are equal-width column flex with --oas-space-3 gaps); the built-in card ::part(card) splits into ::part(media) + ::part(info) (same DOM for waterfall vertical layout and layout="list" horizontal rows — the direction is switched by CSS): ::part(info) is the info column that holds ::part(title) / ::part(tags) / ::part(tag) / ::part(price), and in list form ::part(media) is a fixed 104px square with the info column taking the remaining inline space. Column changes rebuild the column DOM — keep that in mind when overriding ::part(col) layout, since cards are re-assigned.
API
oas-goods-list
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
columns | Waterfall columns: a fixed number (1–8, clamped) or auto (default; container-width breakpoints <640 → 2, <1024 → 3, otherwise 4; a ResizeObserver re-balances when the width crosses a breakpoint); the list form is always a single column | — | — |
currency | ISO 4217 currency (passed to the built-in oas-price, default CNY) | — | — |
items | Product data as a JSON array [{ image?, title, price?, originalPrice?, tags?: string[] }] (built-in simple cards; entries without title are ignored, invalid JSON warns once and clears); ignored when the card slot has content | GoodsItem[] | string | — |
layout | Form: waterfall (default, multi-column waterfall) / list (single vertical column); invalid values fall back to waterfall and warn once | — | — |
loading | Load-more loading state: the host sets it after receiving oas-load-more (renders the spinner + loading text; setting it also releases the bottom-reached pending state) | boolean | — |
locale | Amount formatting locale (passed to the built-in oas-price) | — | — |
no-more | End-of-list state: shows the "no more items" text and stops the bottom-reached emission | boolean | — |
precision | Amount decimal places (passed to the built-in oas-price, default 2) | — | — |
Property (JS property; see each row for attribute reflection)
| Property | Description | Type | Default |
|---|---|---|---|
items | Product data: get+set dual channel (array or JSON string), writes reflect the items attribute | GoodsItem[] | string | — |
Events
| Event | Description |
|---|---|
oas-item-click | Emitted after a built-in card is clicked (or Enter), detail: { index, item }; slotted cards do not emit (content and clicks are host-owned) |
oas-load-more | Emitted when the sentinel enters the viewport (240px early) while not loading / no-more; after emission the component waits — the host sets loading or changes items to release it; doing neither stops further emission, detail: {} |
Slots
| Name | Description |
|---|---|
| default | Card slot full replacement: with assigned elements the items rendering is ignored, and the host cards are balanced into columns in order |
empty | Empty-state content (rendered when items is empty and no slotted cards exist; default "no products yet" text) |