@wix/headless-stores 0.0.58 → 0.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type Category } from '../services/category-service.js';
3
3
  import { type CategoryServiceConfig } from '../services/category-service.js';
4
+ import { AsChildChildren } from '@wix/headless-utils/react';
4
5
  /**
5
6
  * Props for Category.Root component
6
7
  */
@@ -21,7 +22,7 @@ export interface CategoryTriggerProps {
21
22
  /** Whether to render as a child component */
22
23
  asChild?: boolean;
23
24
  /** Custom render function when using asChild */
24
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLButtonElement, {
25
+ children?: AsChildChildren<{
25
26
  category: Category;
26
27
  isSelected: boolean;
27
28
  onSelect: () => void;
@@ -39,7 +40,7 @@ export interface CategoryLabelProps {
39
40
  /** Whether to render as a child component */
40
41
  asChild?: boolean;
41
42
  /** Custom render function when using asChild */
42
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
43
+ children?: AsChildChildren<{
43
44
  name: string;
44
45
  category: Category;
45
46
  }>;
@@ -53,7 +54,7 @@ export interface CategoryIDProps {
53
54
  /** Whether to render as a child component */
54
55
  asChild?: boolean;
55
56
  /** Custom render function when using asChild */
56
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
57
+ children?: AsChildChildren<{
57
58
  id: string;
58
59
  category: Category;
59
60
  }>;
@@ -67,7 +68,7 @@ export interface CategoryRawProps {
67
68
  /** Whether to render as a child component */
68
69
  asChild?: boolean;
69
70
  /** Custom render function when using asChild */
70
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
71
+ children?: AsChildChildren<{
71
72
  category: Category;
72
73
  isSelected: boolean;
73
74
  }>;
@@ -1,5 +1,6 @@
1
1
  import type { V3Product } from '@wix/auto_sdk_stores_products-v-3';
2
2
  import React from 'react';
3
+ import { AsChildChildren } from '@wix/headless-utils/react';
3
4
  import { AsContent } from './types.js';
4
5
  /**
5
6
  * Context for sharing variant options state between components
@@ -59,9 +60,9 @@ export interface NameProps {
59
60
  /** Whether to render as a child component */
60
61
  asChild?: boolean;
61
62
  /** Custom render function when using asChild */
62
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
63
+ children?: AsChildChildren<{
63
64
  name: string;
64
- }> | React.ForwardRefExoticComponent<any>;
65
+ }>;
65
66
  /** CSS classes to apply to the default element */
66
67
  className?: string;
67
68
  }
@@ -97,9 +98,9 @@ export interface DescriptionProps {
97
98
  /** Whether to render as a child component */
98
99
  asChild?: boolean;
99
100
  /** Custom render function when using asChild */
100
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
101
+ children?: AsChildChildren<{
101
102
  description: string;
102
- }> | React.ForwardRefExoticComponent<any>;
103
+ }>;
103
104
  /** CSS classes to apply to the default element */
104
105
  className?: string;
105
106
  /** Format of the description content */
@@ -136,10 +137,10 @@ export interface PriceProps {
136
137
  /** Whether to render as a child component */
137
138
  asChild?: boolean;
138
139
  /** Custom render function when using asChild */
139
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
140
+ children?: AsChildChildren<{
140
141
  price: string;
141
142
  formattedPrice: string;
142
- }> | React.ForwardRefExoticComponent<any>;
143
+ }>;
143
144
  /** CSS classes to apply to the default element */
144
145
  className?: string;
145
146
  }
@@ -175,10 +176,10 @@ export interface CompareAtPriceProps {
175
176
  /** Whether to render as a child component */
176
177
  asChild?: boolean;
177
178
  /** Custom render function when using asChild */
178
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
179
+ children?: AsChildChildren<{
179
180
  price: string;
180
181
  formattedPrice: string;
181
- }> | React.ForwardRefExoticComponent<any>;
182
+ }>;
182
183
  /** CSS classes to apply to the default element */
183
184
  className?: string;
184
185
  }
@@ -219,9 +220,9 @@ export interface SlugProps {
219
220
  /** Whether to render as a child component */
220
221
  asChild?: boolean;
221
222
  /** Custom render function when using asChild */
222
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
223
+ children?: AsChildChildren<{
223
224
  slug: string;
224
- }> | React.ForwardRefExoticComponent<any>;
225
+ }>;
225
226
  /** CSS classes to apply to the default element */
226
227
  className?: string;
227
228
  }
@@ -255,9 +256,9 @@ export interface RawProps {
255
256
  /** Whether to render as a child component */
256
257
  asChild?: boolean;
257
258
  /** Custom render function when using asChild */
258
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
259
+ children?: AsChildChildren<{
259
260
  product: V3Product;
260
- }> | React.ForwardRefExoticComponent<any>;
261
+ }>;
261
262
  /** CSS classes to apply to the default element */
262
263
  className?: string;
263
264
  }
@@ -1,7 +1,7 @@
1
1
  import type { V3Product } from '@wix/auto_sdk_stores_products-v-3';
2
2
  import React from 'react';
3
- import type { ProductsListSearchServiceConfig } from '../services/products-list-search-service.js';
4
3
  import type { ProductsListServiceConfig } from '../services/products-list-service.js';
4
+ import { AsChildChildren } from '@wix/headless-utils/react';
5
5
  /**
6
6
  * Props for the ProductList root component following the documented API
7
7
  */
@@ -9,7 +9,6 @@ export interface ProductListRootProps {
9
9
  children: React.ReactNode;
10
10
  products?: V3Product[];
11
11
  productsListConfig?: ProductsListServiceConfig;
12
- productsListSearchConfig?: ProductsListSearchServiceConfig;
13
12
  className?: string;
14
13
  }
15
14
  /**
@@ -142,9 +141,9 @@ export interface TotalsDisplayedProps {
142
141
  /** Whether to render as a child component */
143
142
  asChild?: boolean;
144
143
  /** Custom render function when using asChild */
145
- children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
144
+ children?: AsChildChildren<{
146
145
  displayedProducts: number;
147
- }> | React.ForwardRefExoticComponent<any>;
146
+ }>;
148
147
  /** CSS classes to apply to the default element */
149
148
  className?: string;
150
149
  }
@@ -38,7 +38,7 @@ var TestIds;
38
38
  * ```
39
39
  */
40
40
  export const Root = React.forwardRef((props, ref) => {
41
- const { children, products, productsListConfig, productsListSearchConfig, className, } = props;
41
+ const { children, products, productsListConfig, className } = props;
42
42
  const serviceConfig = productsListConfig || {
43
43
  products: products || [],
44
44
  searchOptions: {
@@ -50,7 +50,7 @@ export const Root = React.forwardRef((props, ref) => {
50
50
  aggregations: {}, // Empty aggregation data
51
51
  customizations: [],
52
52
  };
53
- return (_jsx(CoreProductList.Root, { productsListConfig: serviceConfig, productsListSearchConfig: productsListSearchConfig, children: _jsx(RootContent, { children: children, className: className, ref: ref }) }));
53
+ return (_jsx(CoreProductList.Root, { productsListConfig: serviceConfig, children: _jsx(RootContent, { children: children, className: className, ref: ref }) }));
54
54
  });
55
55
  /**
56
56
  * Internal component to handle the Root content with service access
@@ -1,6 +1,5 @@
1
1
  import { type ProductsListServiceConfig } from '../../services/products-list-service.js';
2
2
  import { productsV3 } from '@wix/stores';
3
- import { ProductsListSearchServiceConfig } from '../../services/products-list-search-service.js';
4
3
  import { CategoriesListServiceConfig } from '../../services/categories-list-service.js';
5
4
  /**
6
5
  * Props for Root headless component
@@ -10,8 +9,6 @@ export interface RootProps {
10
9
  children: React.ReactNode;
11
10
  /** Configuration for the ProductList service */
12
11
  productsListConfig: ProductsListServiceConfig;
13
- /** Configuration for the ProductListSearch service */
14
- productsListSearchConfig?: ProductsListSearchServiceConfig;
15
12
  /** Configuration for the CategoriesList service */
16
13
  categoriesListConfig?: CategoriesListServiceConfig;
17
14
  }
@@ -3,7 +3,6 @@ import { useService, WixServices } from '@wix/services-manager-react';
3
3
  import { createServicesMap } from '@wix/services-manager';
4
4
  import { ProductListService, ProductsListServiceDefinition, } from '../../services/products-list-service.js';
5
5
  import { ProductService, ProductServiceDefinition, } from '../../services/product-service.js';
6
- import { ProductsListSearchService, ProductsListSearchServiceDefinition, } from '../../services/products-list-search-service.js';
7
6
  import { CategoriesListService, CategoriesListServiceDefinition, } from '../../services/categories-list-service.js';
8
7
  /**
9
8
  * Root component that provides both ProductList and ProductListSearch service contexts to its children.
@@ -66,8 +65,7 @@ import { CategoriesListService, CategoriesListServiceDefinition, } from '../../s
66
65
  export function Root(props) {
67
66
  return (_jsx(WixServices, { servicesMap: createServicesMap()
68
67
  .addService(CategoriesListServiceDefinition, CategoriesListService, props.categoriesListConfig)
69
- .addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig)
70
- .addService(ProductsListSearchServiceDefinition, ProductsListSearchService, props.productsListSearchConfig), children: props.children }));
68
+ .addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig), children: props.children }));
71
69
  }
72
70
  /**
73
71
  * Component that renders content when the products list is empty.
@@ -3,5 +3,4 @@ export { CategoriesListService, CategoriesListServiceDefinition, loadCategoriesL
3
3
  export { ProductModifiersService, ProductModifiersServiceDefinition, } from './product-modifiers-service.js';
4
4
  export { ProductService, ProductServiceDefinition, loadProductServiceConfig, } from './product-service.js';
5
5
  export { SelectedVariantService, SelectedVariantServiceDefinition, } from './selected-variant-service.js';
6
- export { ProductListService, ProductsListServiceDefinition, loadProductsListServiceConfig, ProductsListServiceConfig, ProductOption, ProductChoice, } from './products-list-service.js';
7
- export { InventoryStatusType, SortType, ProductsListSearchService, ProductsListSearchServiceDefinition, ProductsListSearchServiceConfig, loadProductsListSearchServiceConfig, parseUrlToSearchOptions, convertUrlSortToSortType, } from './products-list-search-service.js';
6
+ export { ProductListService, ProductsListServiceDefinition, loadProductsListServiceConfig, ProductsListServiceConfig, ProductOption, ProductChoice, InventoryStatusType, SortType, InitialSearchState, parseUrlToSearchOptions, convertUrlSortToSortType, } from './products-list-service.js';
@@ -3,5 +3,4 @@ export { CategoriesListService, CategoriesListServiceDefinition, loadCategoriesL
3
3
  export { ProductModifiersService, ProductModifiersServiceDefinition, } from './product-modifiers-service.js';
4
4
  export { ProductService, ProductServiceDefinition, loadProductServiceConfig, } from './product-service.js';
5
5
  export { SelectedVariantService, SelectedVariantServiceDefinition, } from './selected-variant-service.js';
6
- export { ProductListService, ProductsListServiceDefinition, loadProductsListServiceConfig, } from './products-list-service.js';
7
- export { InventoryStatusType, SortType, ProductsListSearchService, ProductsListSearchServiceDefinition, loadProductsListSearchServiceConfig, parseUrlToSearchOptions, convertUrlSortToSortType, } from './products-list-search-service.js';
6
+ export { ProductListService, ProductsListServiceDefinition, loadProductsListServiceConfig, InventoryStatusType, SortType, parseUrlToSearchOptions, convertUrlSortToSortType, } from './products-list-service.js';
@@ -1,128 +1 @@
1
- import { productsV3, customizationsV3 } from '@wix/stores';
2
- import { type Category } from './category-service.js';
3
- import { SortType } from './../enums/sort-enums.js';
4
- export { SortType } from './../enums/sort-enums.js';
5
- /**
6
- * Enumeration of inventory status types available for filtering.
7
- * Re-exports the Wix inventory availability status enum values.
8
- */
9
- export declare const InventoryStatusType: typeof productsV3.InventoryAvailabilityStatus;
10
- /**
11
- * Type for inventory status values.
12
- * Re-exports the Wix inventory availability status enum type.
13
- */
14
- export type InventoryStatusType = productsV3.InventoryAvailabilityStatus;
15
- /**
16
- * Initial search state that can be loaded from URL parameters.
17
- */
18
- export type InitialSearchState = {
19
- sort?: SortType;
20
- limit?: number;
21
- cursor?: string | null;
22
- priceRange?: {
23
- min?: number;
24
- max?: number;
25
- };
26
- inventoryStatuses?: InventoryStatusType[];
27
- productOptions?: Record<string, string[]>;
28
- category?: Category;
29
- visible?: boolean;
30
- productType?: string;
31
- };
32
- /**
33
- * Configuration interface for the Products List Search service.
34
- */
35
- export type ProductsListSearchServiceConfig = {
36
- initialSearchState?: InitialSearchState;
37
- };
38
- /**
39
- * Service definition for the Products List Search service.
40
- * This consolidates sort, pagination, and filtering functionality.
41
- */
42
- export declare const ProductsListSearchServiceDefinition: string & {
43
- __api: {};
44
- __config: {};
45
- isServiceDefinition?: boolean;
46
- };
47
- /**
48
- * Convert URL sort format to SortType enum
49
- */
50
- export declare function convertUrlSortToSortType(urlSort: string): SortType | null;
51
- /**
52
- * Parse URL and build complete search options with all filters, sort, and pagination.
53
- * This function extracts search parameters, filters, sorting, and pagination from a URL
54
- * and converts them into the format expected by the Wix Stores API.
55
- *
56
- * @param {string} url - The URL to parse search parameters from
57
- * @param {Category[]} categoriesList - List of available categories for category slug resolution
58
- * @param {productsV3.V3ProductSearch} [defaultSearchOptions] - Default search options to merge with parsed URL parameters
59
- * @returns {Promise<{searchOptions: productsV3.V3ProductSearch, initialSearchState: InitialSearchState}>}
60
- * Object containing both API-ready search options and UI-ready initial state
61
- *
62
- * @example
63
- * ```tsx
64
- * // Parse URL with filters, sort, and pagination
65
- * const categories = await loadCategoriesListServiceConfig();
66
- * const { searchOptions, initialSearchState } = await parseUrlToSearchOptions(
67
- * 'https://example.com/products?sort=price:desc&Color=red,blue&minPrice=50',
68
- * categories.categories
69
- * );
70
- *
71
- * // Use searchOptions for API calls
72
- * const products = await productsV3.searchProducts(searchOptions);
73
- *
74
- * // Use initialSearchState for UI initialization
75
- * const filterState = initialSearchState.productOptions; // { colorId: ['red-id', 'blue-id'] }
76
- * ```
77
- */
78
- export declare function parseUrlToSearchOptions(url: string, categoriesList: Category[], customizations: customizationsV3.Customization[], defaultSearchOptions?: productsV3.V3ProductSearch): Promise<{
79
- searchOptions: productsV3.V3ProductSearch;
80
- initialSearchState: InitialSearchState;
81
- }>;
82
- /**
83
- * Load search service configuration from URL or parsed URL result.
84
- * This function provides the configuration for the Products List Search service,
85
- * including customizations and initial search state.
86
- *
87
- * @param {string | { searchOptions: productsV3.V3ProductSearch; initialSearchState: InitialSearchState }} input - Either a URL to parse or parsed URL result from parseUrlToSearchOptions
88
- * @returns {Promise<ProductsListSearchServiceConfig>} Promise that resolves to the search service configuration
89
- *
90
- * @example
91
- * ```tsx
92
- * // Option 1: Load from URL (will parse filters, sort, pagination from URL params)
93
- * const searchConfig = await loadProductsListSearchServiceConfig(window.location.href);
94
- *
95
- * // Option 2: Custom parsing with defaults
96
- * const categories = await loadCategoriesListServiceConfig();
97
- * const parsed = await parseUrlToSearchOptions(
98
- * window.location.href,
99
- * categories.categories,
100
- * {
101
- * cursorPaging: { limit: 12 },
102
- * filter: { 'categoryIds': ['123'] },
103
- * sort: [{ fieldName: 'name' as const, order: 'ASC' as const }]
104
- * }
105
- * );
106
- * const searchConfig = await loadProductsListSearchServiceConfig(parsed);
107
- *
108
- * // Option 3: Performance optimization - use parsed result for both services (no duplicate parsing)
109
- * const categories = await loadCategoriesListServiceConfig();
110
- * const parsed = await parseUrlToSearchOptions(url, categories.categories);
111
- * const [productsConfig, searchConfig] = await Promise.all([
112
- * loadProductsListServiceConfig(parsed),
113
- * loadProductsListSearchServiceConfig(parsed),
114
- * ]);
115
- * ```
116
- */
117
- export declare function loadProductsListSearchServiceConfig(input: string | {
118
- searchOptions: productsV3.V3ProductSearch;
119
- initialSearchState: InitialSearchState;
120
- }): Promise<ProductsListSearchServiceConfig>;
121
- /**
122
- * Implementation of the Products List Search service
123
- */
124
- export declare const ProductsListSearchService: import("@wix/services-definitions").ServiceFactory<string & {
125
- __api: {};
126
- __config: {};
127
- isServiceDefinition?: boolean;
128
- }, ProductsListSearchServiceConfig>;
1
+ export {};