React
Reference
Components, hooks and types exported by @cogitx/cartesian-react.
Components
| Component | Props |
|---|---|
CartesianProvider | client or config, options, listener, host, panel, children |
CartesianChat | onClose?, className?, style?. Fills its parent. |
CartesianPanel | layout? (auto, bottomSheet, sidePanel, floating, fullScreen), panel?, onHidden?, container? |
CartesianAskButton | label?, expanded?, visible?, prompt?, icon?, containerColor?, contentColor?, panel?, className?, style? |
CartesianAskBar | placeholder?, panel?, className?, style? |
AgentOrb | activity, size?, color?, paused?, onDark? |
CartesianComponents holds the default component for every slot, plus Orb, Icon, OfflineBanner, ErrorRecovery and PoweredBy.
Hooks
| Hook | Returns |
|---|---|
useCartesian() | CartesianController |
useCartesianClient() | The provider's CartesianClient |
useCartesianPanel() | The provider's CartesianPanelState |
usePanelSnapshot(panel?) | { isVisible, detent, layout, pendingPrompt } |
useCartesianHost() | The provider's CartesianHostState |
Cartesian.present(prompt?, detent?) and Cartesian.hide() control the panel of the latest mounted provider.
CartesianController
restoring, signedOut or signedIn with user.host mode they come from CartesianHostState.navigator.onLine and the restore or reconnect loop.Actions: send(text?), stop(), newChat(), retry(), rate(id, rating), addToCart(product, quantity?), setQuantity(id, quantity), toggleSaved(product), openProduct(product), openCart(), openWishlist(), showDrawer(tab | null), checkout(), saveForLater(product), moveToCart(product), dismissError(), retryConnection(). Lookups: quantityInCart(id), isSaved(id), isBusy(id).
CartesianClient
| Member | Description |
|---|---|
signIn(token) | Validates the token with GET /api/auth/session and connects. |
restore() | Re-checks a saved token. Called for you by the provider. |
signOut() | POST /api/auth/logout and clears local state. |
hasSavedSession | A token is stored. |
auth, connection, cart, wishlist, threads, license | Stores. |
chat | ChatSession. See Headless. |
| Cart and wishlist methods | refreshCart, addToCart, setCartQuantity, removeFromCart, clearCart, refreshWishlist, save, unsave |
| Threads | refreshThreads, renameThread, deleteThread |
| Other | profile, compare, readPhotoText, connect, reconnectNow, disconnect, close |
Models
Product wraps the backend JSON. Typed getters: id, name, brand, price, regularPrice, isOnSale, currency, imageUrl, productUrl, sku, size, category, department, aisle, shelf, color, description, features, promoLabel, rating, reviewCount, isUsual, isSnapEligible. get(key) reads any attribute and raw / toJson() give the full object.
Cart has lines ({ product, quantity }), itemCount, distinctItemCount, total, currency and quantityOf(id). Wishlist has products and has(id). Comparison has products, rows, summary, nextStep, recommendations and prosCons.
Options
CartesianOptionsInput: title, starters, theme (CartesianThemeInput), features (Partial<CartesianFeatures>), slots (CartesianSlots), strings (CartesianStrings). See Customize.
Accessibility
- Every icon button has a label. Product cards, the cart drawer tabs and the sheet handle are reachable with the keyboard.
- The sheet, side panel, full-screen panel and cart drawer are modal dialogs: focus is trapped inside and returns to the trigger on close. Escape closes the innermost one.
- Live activity, connection status and errors are announced with
aria-liveregions. - With
prefers-reduced-motion, transitions are shortened and the orbs stop animating.