Skip to content

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

Sold by usAdd to cartHotAdd to cart
Any custom content can act as a "card" (balanced placement by measured height)

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

Simulate bottom (load next page)Mark as no-more

Empty state (empty slot)

No products match the current filtersClear filters

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)

Reset (filter-switch scenario)Scroll to the bottom of the list to load (240px sentinel lead) and watch the cursor advance page by page until the end of the list.

Host glue (the demo's complete loop — bottom reach → loadPage → append → cursor advance → no-more end):

js
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 as role="listitem" (column divs are presentation so the list semantics stay unbroken), with aria-label "Product list"; the load-more region is an aria-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 image alt takes the title, and the missing-image placeholder text goes into aria-label (not rendered on screen). Slotted cards get role="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 ​

AttributeDescriptionTypeDefault
columnsWaterfall 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——
currencyISO 4217 currency (passed to the built-in oas-price, default CNY)——
itemsProduct 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 contentGoodsItem[] | string—
layoutForm: waterfall (default, multi-column waterfall) / list (single vertical column); invalid values fall back to waterfall and warn once——
loadingLoad-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—
localeAmount formatting locale (passed to the built-in oas-price)——
no-moreEnd-of-list state: shows the "no more items" text and stops the bottom-reached emissionboolean—
precisionAmount decimal places (passed to the built-in oas-price, default 2)——

Property (JS property; see each row for attribute reflection) ​

PropertyDescriptionTypeDefault
itemsProduct data: get+set dual channel (array or JSON string), writes reflect the items attributeGoodsItem[] | string—

Events ​

EventDescription
oas-item-clickEmitted 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-moreEmitted 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 ​

NameDescription
defaultCard slot full replacement: with assigned elements the items rendering is ignored, and the host cards are balanced into columns in order
emptyEmpty-state content (rendered when items is empty and no slotted cards exist; default "no products yet" text)

Released under the MIT OR Apache-2.0 License.