import React from 'react'; import * as CoreCmsCollection from './core/CmsCollection.js'; import { WixDataQueryResult, type CmsQueryOptions } from '../services/cms-collection-service.js'; import { AsChildChildren } from '@wix/headless-utils/react'; import { Sort as SortPrimitive, type SortValue, type SortOption, type FilterOption, type FilterValue } from '@wix/headless-components/react'; import * as CoreCmsCollectionFilters from './core/CmsCollectionFilters.js'; import type { LineItem } from '@wix/headless-ecom/services'; /** * Props for CmsCollection.Root component */ export interface RootProps { children: (props: CoreCmsCollection.RootRenderProps) => React.ReactNode; collection: { id: string; queryResult?: WixDataQueryResult; queryOptions?: CmsQueryOptions; initialSort?: SortValue; /** Default filters that are always applied (set by site owner). * These filters are combined with user-applied filters using AND logic. * @example * ```tsx * // Only show yellow or red cars * defaultFilter={{ color: { $hasSome: ['yellow', 'red'] } }} * * // When user filters by model: Toyota * // Result: Toyota cars that are yellow or red * ``` */ defaultFilter?: FilterValue; /** List of field IDs for single reference fields to include */ singleRefFieldIds?: string[]; /** List of field IDs for multi reference fields to include */ multiRefFieldIds?: string[]; }; className?: string; } /** * Root component that provides the CMS Collection service context to its children. * This component exposes all collection service properties via render props pattern. * * @component * @example * ```tsx * import { CmsCollection } from '@wix/cms/components'; * * function CollectionPage() { * return ( * * * * ); * } * * // With reference fields included * function CollectionWithReferences() { * return ( * * // Custom rendering logic here * * ); * } * * // With pagination * function CollectionWithPagination() { * return ( * * {({ queryResult, loading, nextPage, prevPage }) => ( * <> * {queryResult?.items.map(item =>
{item.title}
)} * * * * )} *
* ); * } * ``` */ export declare const Root: React.ForwardRefExoticComponent>; /** * Props for CmsCollection.Sort component */ export interface SortProps { /** Predefined sort options for declarative API */ sortOptions?: Array; /** Children components or render function */ children?: React.ComponentProps['children']; /** CSS classes to apply */ className?: string; } /** * Sort component that provides sorting controls for the collection items. * Wraps the Sort primitive with CMS collection state management. * * @component * @example * ```tsx * // Define sort options * const sortOptions = [ * { fieldName: 'title', order: 'ASC' as const, label: 'Title (A-Z)' }, * { fieldName: 'title', order: 'DESC' as const, label: 'Title (Z-A)' }, * { fieldName: 'price', order: 'ASC' as const, label: 'Price (Low to High)' }, * { fieldName: 'price', order: 'DESC' as const, label: 'Price (High to Low)' }, * { fieldName: '_createdDate', order: 'DESC' as const, label: 'Newest First' }, * { fieldName: '_createdDate', order: 'ASC' as const, label: 'Oldest First' }, * ]; * * // Custom implementation with render function (asChild is automatically true) * * {({ currentSort, options, onChange }) => ( * * )} * * * // Custom list container with render function * * {({ currentSort, options, onChange }) => ( *
    * {options.map((option, i) => ( *
  • * *
  • * ))} *
* )} *
* ``` */ export declare const Sort: React.ForwardRefExoticComponent>; /** * Props for CmsCollection.FilterResetTrigger component */ export interface FilterResetTriggerProps { /** Whether to render as a child component */ asChild?: boolean; /** Custom render function when using asChild */ children?: AsChildChildren<{ resetFilters: () => void; isFiltered: boolean; }>; /** CSS classes to apply to the default element */ className?: string; /** Label for the button */ label?: string; } /** * Reset trigger component for clearing all applied filters. * Provides reset functionality and filter state to custom render functions. * Only renders when filters are applied. * * @component * @example * ```tsx * // Default usage * * * // Custom rendering with asChild * * {({ resetFilters, isFiltered }, ref) => ( * * )} * * ``` */ export declare const FilterResetTrigger: React.ForwardRefExoticComponent>; /** * Single selection filter component for CMS collections. * Renders the full platform filter structure and provides filter state via render props. * * @component * @example * ```tsx * * {({ value, onChange }) => ( *
* * * * {value && } *
* )} *
* ``` */ export declare const SingleFilter: React.ForwardRefExoticComponent>; /** * Multi-selection filter component for CMS collections. * Renders the full platform filter structure and provides filter state via render props. * * @component * @example * ```tsx * * {({ values, onChange, resetFilter }) => ( *
* * * * {values.length > 0 && } *
* )} *
* ``` */ export declare const MultiFilter: React.ForwardRefExoticComponent>; /** * Range filter component for CMS collections. * Renders the full platform filter structure and provides filter state via render props. * * @component * @example * ```tsx * * {({ values, onChange, minBound, maxBound }) => ( *
* onChange([Number(e.target.value), values[1] ?? maxBound])} * /> * {String(values[0] ?? minBound)} *
* )} *
* ``` */ export declare const RangeFilter: React.ForwardRefExoticComponent>; /** * Props for CmsCollection.Action.AddToCart component */ export interface ActionAddToCartProps extends Omit, 'children'> { /** When true, the component will not render its own element but forward its props to its child */ asChild?: boolean; /** * Content to render inside the button. * Can be static content or a render function for custom behavior. */ children?: React.ReactNode | React.ForwardRefRenderFunction Promise; /** Line items that will be processed */ lineItems: LineItem[]; /** Error message if any */ error?: string | null; }>; /** Text or content to display when not loading */ label?: string | React.ReactNode; /** Text or content to display when loading */ loadingState?: string | React.ReactNode; /** The item ID to add to cart */ itemId: string; /** Additional disabled state (combined with loading state) */ disabled?: boolean; /** Quantity to add (defaults to 1) */ quantity?: number; } /** * Add to Cart action button component for CMS collection items. * Uses CoreCmsCollection.Action.AddToCart to get CMS data and wraps Commerce.Actions.AddToCart. * * @component * @example * ```tsx * * {({ queryResult }) => ( *
* {queryResult?.items.map(item => ( *
*

{item.title}

* *
* ))} *
* )} *
* ``` */ export declare const ActionAddToCart: React.ForwardRefExoticComponent>; /** * Props for CmsCollection.Action.BuyNow component */ export interface ActionBuyNowProps extends Omit, 'children'> { /** When true, the component will not render its own element but forward its props to its child */ asChild?: boolean; /** * Content to render inside the button. * Can be static content or a render function for custom behavior. */ children?: React.ReactNode | React.ForwardRefRenderFunction Promise; /** Line items that will be processed */ lineItems: LineItem[]; /** Error message if any */ error?: string | null; }>; /** Text or content to display when not loading */ label?: string | React.ReactNode; /** Text or content to display when loading */ loadingState?: string | React.ReactNode; /** The item IDs to buy now */ itemIds: string[]; /** Additional disabled state (combined with loading state) */ disabled?: boolean; /** Quantity to purchase (defaults to 1) */ quantity?: number; } /** * Buy Now action button component for CMS collection items. * Uses CoreCmsCollection.Action.BuyNow to get CMS data and wraps Commerce.Actions.BuyNow. * * @component * @example * ```tsx * // BuyNow button per item * * {({ queryResult }) => ( *
* {queryResult?.items.map(item => ( *
*

{item.title}

* *
* ))} *
* )} *
* ``` * * @example * ```tsx * // One BuyNow button for multiple items * function CollectionWithMultiSelect() { * const [selectedItemIds, setSelectedItemIds] = React.useState([]); * * const toggleItem = (itemId: string) => { * setSelectedItemIds(prev => * prev.includes(itemId) * ? prev.filter(id => id !== itemId) * : [...prev, itemId] * ); * }; * * return ( * * {({ queryResult }) => ( *
* {queryResult?.items.map(item => ( *
* toggleItem(item._id)} * /> *

{item.title}

*
* ))} * {selectedItemIds.length > 0 && ( * * {({ onClick, disabled, isLoading, lineItems }, ref) => ( * * )} * * )} *
* )} *
* ); * } * ``` */ export declare const ActionBuyNow: React.ForwardRefExoticComponent>; /** * Namespace containing all CMS collection action components. */ export declare const Action: { /** Add to Cart button for adding collection items to cart */ readonly AddToCart: React.ForwardRefExoticComponent>; /** Buy Now button for immediate purchase of collection items */ readonly BuyNow: React.ForwardRefExoticComponent>; }; export type { FilterOption };