Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/headless-components/cms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wix/headless-cms",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
Expand Down
27 changes: 26 additions & 1 deletion packages/headless-components/cms/src/react/CmsCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
type SortOption,
Filter as FilterPrimitive,
type FilterOption,
type FilterValue as Filter,
} from '@wix/headless-components/react';
import { CmsCollectionSort as CmsCollectionSortPrimitive } from './core/CmsCollectionSort.js';
import * as CoreCmsCollectionFilters from './core/CmsCollectionFilters.js';
Expand Down Expand Up @@ -44,6 +45,8 @@ export interface RootProps {
queryResult?: WixDataQueryResult;
queryOptions?: CmsQueryOptions;
initialSort?: SortValue;
/** Initial filter to apply before user interactions */
initialFilter?: Filter;
/** List of field IDs for single reference fields to include */
singleRefFieldIds?: string[];
/** List of field IDs for multi reference fields to include */
Expand Down Expand Up @@ -79,6 +82,27 @@ export interface RootProps {
* );
* }
*
* // With initial filter applied
* function CollectionWithFilter() {
* return (
* <CmsCollection.Root
* collection={{
* id: 'MyCollection',
* initialFilter: {
* status: { $eq: 'published' },
* category: { $hasSome: ['tech', 'lifestyle'] }
* }
* }}
* >
* <CmsCollection.Items>
* <CmsCollection.ItemRepeater>
* <CmsItem.Field fieldId="title" />
* </CmsCollection.ItemRepeater>
* </CmsCollection.Items>
* </CmsCollection.Root>
* );
* }
*
* // With reference fields included
* function CollectionWithReferences() {
* return (
Expand Down Expand Up @@ -109,6 +133,7 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(
queryResult: collection?.queryResult,
queryOptions: collection?.queryOptions,
initialSort: collection?.initialSort,
initialFilter: collection?.initialFilter,
singleRefFieldIds: collection?.singleRefFieldIds,
multiRefFieldIds: collection?.multiRefFieldIds,
};
Expand Down Expand Up @@ -1303,4 +1328,4 @@ export const FilterResetTrigger = React.forwardRef<

FilterResetTrigger.displayName = 'CmsCollection.FilterResetTrigger';

export type { FilterOption };
export type { FilterOption, Filter };