@wix/headless-stores 0.0.56 → 0.0.57

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.
@@ -27,13 +27,16 @@ import React from 'react';
27
27
  * });
28
28
  * ```
29
29
  */
30
- export function renderChildren({ children, props, ref, }) {
30
+ export function renderChildren({ children, props, ref, content, }) {
31
31
  // Early return if no children provided
32
32
  if (!children)
33
33
  return null;
34
34
  // Handle React element pattern
35
35
  if (React.isValidElement(children)) {
36
- return children;
36
+ return React.cloneElement(children, {
37
+ ref,
38
+ ...(content ? { children: content } : {}),
39
+ });
37
40
  }
38
41
  // Handle render function pattern
39
42
  if (typeof children === 'function') {
@@ -25,6 +25,7 @@ export interface CategoryTriggerProps {
25
25
  category: Category;
26
26
  isSelected: boolean;
27
27
  onSelect: () => void;
28
+ setIsSelected: (isSelected: boolean) => void;
28
29
  }>;
29
30
  /** Callback when category is selected */
30
31
  onSelect?: (category: Category) => void;
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Slot } from '@radix-ui/react-slot';
4
3
  import * as CoreCategory from './core/Category.js';
5
4
  import { CategoryServiceDefinition, } from '../services/category-service.js';
6
5
  import { useService } from '@wix/services-manager-react';
7
- import { renderChildren } from '../utils/renderChildren.js';
6
+ import { AsChildSlot } from '@wix/headless-utils/react';
8
7
  var TestIds;
9
8
  (function (TestIds) {
10
9
  TestIds["categoryItem"] = "category-item";
@@ -76,19 +75,18 @@ export const Trigger = React.forwardRef((props, ref) => {
76
75
  const categoryService = useService(CategoryServiceDefinition);
77
76
  const category = categoryService.category.get();
78
77
  const isSelected = categoryService.isSelected.get();
78
+ const setIsSelected = (isSelected) => categoryService.isSelected.set(isSelected);
79
79
  const handleSelect = () => {
80
80
  if (onSelect) {
81
81
  onSelect(category);
82
82
  }
83
83
  };
84
- const Comp = asChild && children ? Slot : 'button';
85
- return (_jsx(Comp, { ref: ref, className: className, onClick: handleSelect, "data-testid": TestIds.categoryTrigger, "data-selected": isSelected ? 'true' : 'false', children: asChild && children
86
- ? renderChildren({
87
- children,
88
- props: { category, isSelected, onSelect: handleSelect },
89
- ref,
90
- })
91
- : category.name }));
84
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleSelect, "data-testid": TestIds.categoryTrigger, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: {
85
+ category,
86
+ isSelected,
87
+ onSelect: handleSelect,
88
+ setIsSelected,
89
+ }, content: category.name, children: _jsx("button", { children: category.name }) }));
92
90
  });
93
91
  /**
94
92
  * Displays the category name or label.
@@ -121,10 +119,7 @@ export const Label = React.forwardRef((props, ref) => {
121
119
  const category = categoryService.category.get();
122
120
  const isSelected = categoryService.isSelected.get();
123
121
  return (_jsx(CoreCategory.Name, { children: ({ name }) => {
124
- const Comp = asChild && children ? Slot : 'span';
125
- return (_jsx(Comp, { ref: ref, className: className, "data-testid": TestIds.categoryLabel, "data-selected": isSelected ? 'true' : 'false', children: asChild && children
126
- ? renderChildren({ children, props: { name, category }, ref })
127
- : name }));
122
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.categoryLabel, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { name, category }, content: name, children: _jsx("span", { children: name }) }));
128
123
  } }));
129
124
  });
130
125
  /**
@@ -158,10 +153,7 @@ export const ID = React.forwardRef((props, ref) => {
158
153
  const category = categoryService.category.get();
159
154
  const isSelected = categoryService.isSelected.get();
160
155
  const id = category._id || '';
161
- const Comp = asChild && children ? Slot : 'span';
162
- return (_jsx(Comp, { ref: ref, className: className || 'sr-only', "data-testid": TestIds.categoryId, "data-selected": isSelected ? 'true' : 'false', children: asChild && children
163
- ? renderChildren({ children, props: { id, category }, ref })
164
- : id }));
156
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className || 'sr-only', "data-testid": TestIds.categoryId, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { id, category }, content: id, children: _jsx("span", { children: id }) }));
165
157
  });
166
158
  /**
167
159
  * Provides access to the full category data for advanced use cases.
@@ -190,8 +182,5 @@ export const Raw = React.forwardRef((props, ref) => {
190
182
  const categoryService = useService(CategoryServiceDefinition);
191
183
  const category = categoryService.category.get();
192
184
  const isSelected = categoryService.isSelected.get();
193
- const Comp = asChild && children ? Slot : 'span';
194
- return (_jsx(Comp, { ref: ref, className: className || 'sr-only', "data-testid": TestIds.categoryRaw, "data-selected": isSelected ? 'true' : 'false', children: asChild && children
195
- ? renderChildren({ children, props: { category, isSelected }, ref })
196
- : JSON.stringify(category) }));
185
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className || 'sr-only', "data-testid": TestIds.categoryRaw, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { category, isSelected }, children: _jsx("span", { children: JSON.stringify(category) }) }));
197
186
  });
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Slot } from '@radix-ui/react-slot';
4
3
  import * as CoreCategoryList from './core/CategoryList.js';
5
4
  import * as Category from './Category.js';
5
+ import { AsChildSlot } from '@wix/headless-utils/react';
6
6
  var TestIds;
7
7
  (function (TestIds) {
8
8
  TestIds["categoryListRoot"] = "category-list";
@@ -56,8 +56,7 @@ export function Root(props) {
56
56
  */
57
57
  export const Loading = React.forwardRef((props, ref) => {
58
58
  const { asChild, children, className } = props;
59
- const Comp = asChild && children ? Slot : 'h1';
60
- return (_jsx(CoreCategoryList.Loading, { children: _jsx(Comp, { className: className, ref: ref, children: "Loading..." }) }));
59
+ return (_jsx(CoreCategoryList.Loading, { children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, children: _jsx("h1", { children: "Loading..." }) }) }));
61
60
  });
62
61
  /**
63
62
  * Repeats for each category in the list, providing individual category context.
@@ -1,6 +1,5 @@
1
1
  import type { V3Product } from '@wix/auto_sdk_stores_products-v-3';
2
2
  import React from 'react';
3
- import { type AsChildProps } from '../utils/index.js';
4
3
  import { AsContent } from './types.js';
5
4
  /**
6
5
  * Context for sharing variant options state between components
@@ -56,9 +55,15 @@ export declare function Root(props: ProductRootProps): React.ReactNode;
56
55
  /**
57
56
  * Props for Product Name component
58
57
  */
59
- export interface NameProps extends AsChildProps<{
60
- name: string;
61
- }> {
58
+ export interface NameProps {
59
+ /** Whether to render as a child component */
60
+ asChild?: boolean;
61
+ /** Custom render function when using asChild */
62
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
63
+ name: string;
64
+ }> | React.ForwardRefExoticComponent<any>;
65
+ /** CSS classes to apply to the default element */
66
+ className?: string;
62
67
  }
63
68
  /**
64
69
  * Displays the product name with customizable rendering following the documented API.
@@ -88,9 +93,15 @@ export declare const Name: React.ForwardRefExoticComponent<NameProps & React.Ref
88
93
  /**
89
94
  * Props for Product Description component
90
95
  */
91
- export interface DescriptionProps extends AsChildProps<{
92
- description: string;
93
- }> {
96
+ export interface DescriptionProps {
97
+ /** Whether to render as a child component */
98
+ asChild?: boolean;
99
+ /** Custom render function when using asChild */
100
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
101
+ description: string;
102
+ }> | React.ForwardRefExoticComponent<any>;
103
+ /** CSS classes to apply to the default element */
104
+ className?: string;
94
105
  /** Format of the description content */
95
106
  as?: `${AsContent}`;
96
107
  }
@@ -121,10 +132,16 @@ export declare const Description: React.ForwardRefExoticComponent<DescriptionPro
121
132
  /**
122
133
  * Props for Product Price component
123
134
  */
124
- export interface PriceProps extends AsChildProps<{
125
- price: string;
126
- formattedPrice: string;
127
- }> {
135
+ export interface PriceProps {
136
+ /** Whether to render as a child component */
137
+ asChild?: boolean;
138
+ /** Custom render function when using asChild */
139
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
140
+ price: string;
141
+ formattedPrice: string;
142
+ }> | React.ForwardRefExoticComponent<any>;
143
+ /** CSS classes to apply to the default element */
144
+ className?: string;
128
145
  }
129
146
  /**
130
147
  * Displays the current product price with customizable rendering following the documented API.
@@ -154,10 +171,16 @@ export declare const Price: React.ForwardRefExoticComponent<PriceProps & React.R
154
171
  /**
155
172
  * Props for Product CompareAtPrice component
156
173
  */
157
- export interface CompareAtPriceProps extends AsChildProps<{
158
- price: string;
159
- formattedPrice: string;
160
- }> {
174
+ export interface CompareAtPriceProps {
175
+ /** Whether to render as a child component */
176
+ asChild?: boolean;
177
+ /** Custom render function when using asChild */
178
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
179
+ price: string;
180
+ formattedPrice: string;
181
+ }> | React.ForwardRefExoticComponent<any>;
182
+ /** CSS classes to apply to the default element */
183
+ className?: string;
161
184
  }
162
185
  /**
163
186
  * Displays the compare-at (original) price when on sale with customizable rendering following the documented API.
@@ -192,9 +215,15 @@ export declare const CompareAtPrice: React.ForwardRefExoticComponent<CompareAtPr
192
215
  * Props for Slug component
193
216
  * @interface SlugProps
194
217
  */
195
- export interface SlugProps extends AsChildProps<{
196
- slug: string;
197
- }> {
218
+ export interface SlugProps {
219
+ /** Whether to render as a child component */
220
+ asChild?: boolean;
221
+ /** Custom render function when using asChild */
222
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
223
+ slug: string;
224
+ }> | React.ForwardRefExoticComponent<any>;
225
+ /** CSS classes to apply to the default element */
226
+ className?: string;
198
227
  }
199
228
  /**
200
229
  * Product Slug component that displays the product's slug
@@ -222,9 +251,15 @@ export declare const Slug: React.ForwardRefExoticComponent<SlugProps & React.Ref
222
251
  /**
223
252
  * Props for Product Raw component
224
253
  */
225
- export interface RawProps extends AsChildProps<{
226
- product: V3Product;
227
- }> {
254
+ export interface RawProps {
255
+ /** Whether to render as a child component */
256
+ asChild?: boolean;
257
+ /** Custom render function when using asChild */
258
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
259
+ product: V3Product;
260
+ }> | React.ForwardRefExoticComponent<any>;
261
+ /** CSS classes to apply to the default element */
262
+ className?: string;
228
263
  }
229
264
  /**
230
265
  * Provides access to the raw product data for advanced use cases.
@@ -249,9 +284,13 @@ export declare const Raw: React.ForwardRefExoticComponent<RawProps & React.RefAt
249
284
  /**
250
285
  * Props for Product Variants container
251
286
  */
252
- export interface VariantsProps extends AsChildProps<{
253
- hasOptions: boolean;
254
- }> {
287
+ export interface VariantsProps {
288
+ /** Whether to render as a child component */
289
+ asChild?: boolean;
290
+ /** Custom render function when using asChild */
291
+ children: React.ReactNode;
292
+ /** CSS classes to apply to the default element */
293
+ className?: string;
255
294
  }
256
295
  /**
257
296
  * Container for product variant selection system.
@@ -331,7 +370,7 @@ export interface VariantOptionsProps {
331
370
  * </Product.VariantOptions>
332
371
  * ```
333
372
  */
334
- export declare const VariantOptions: React.ForwardRefExoticComponent<VariantOptionsProps & React.RefAttributes<HTMLElement>>;
373
+ export declare const VariantOptions: React.ForwardRefExoticComponent<VariantOptionsProps & React.RefAttributes<HTMLDivElement>>;
335
374
  /**
336
375
  * Props for Product VariantOptionRepeater component
337
376
  */
@@ -347,9 +386,13 @@ export declare const VariantOptionRepeater: React.ForwardRefExoticComponent<Vari
347
386
  /**
348
387
  * Props for Product Modifiers container
349
388
  */
350
- export interface ModifiersProps extends AsChildProps<{
351
- hasModifiers: boolean;
352
- }> {
389
+ export interface ModifiersProps {
390
+ /** Whether to render as a child component */
391
+ asChild?: boolean;
392
+ /** Custom render function when using asChild */
393
+ children: React.ReactNode;
394
+ /** CSS classes to apply to the default element */
395
+ className?: string;
353
396
  }
354
397
  /**
355
398
  * Container for product modifier system.
@@ -432,7 +475,7 @@ export interface ModifierOptionsProps {
432
475
  * </Product.ModifierOptions>
433
476
  * ```
434
477
  */
435
- export declare const ModifierOptions: React.ForwardRefExoticComponent<ModifierOptionsProps & React.RefAttributes<HTMLElement>>;
478
+ export declare const ModifierOptions: React.ForwardRefExoticComponent<ModifierOptionsProps & React.RefAttributes<HTMLDivElement>>;
436
479
  /**
437
480
  * Props for Product ModifierOptionRepeater component
438
481
  */
@@ -485,7 +528,7 @@ export interface ProductMediaGalleryProps {
485
528
  * </Product.MediaGallery>
486
529
  * ```
487
530
  */
488
- export declare const ProductMediaGallery: React.ForwardRefExoticComponent<ProductMediaGalleryProps & React.RefAttributes<HTMLElement>>;
531
+ export declare const ProductMediaGallery: React.ForwardRefExoticComponent<ProductMediaGalleryProps & React.RefAttributes<HTMLDivElement>>;
489
532
  /**
490
533
  * Alias for ProductMediaGallery to match the documented API
491
534
  */
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { renderAsChild } from '../utils/index.js';
3
+ import { AsChildSlot } from '@wix/headless-utils/react';
4
4
  import { MediaGallery } from '@wix/headless-media/react';
5
5
  import * as CoreProduct from './core/Product.js';
6
6
  import * as ProductVariantSelector from './core/ProductVariantSelector.js';
@@ -99,21 +99,7 @@ export function Root(props) {
99
99
  export const Name = React.forwardRef((props, ref) => {
100
100
  const { asChild, children, className } = props;
101
101
  return (_jsx(CoreProduct.Name, { children: ({ name }) => {
102
- const attributes = {
103
- 'data-testid': TestIds.productName,
104
- };
105
- if (asChild) {
106
- const rendered = renderAsChild({
107
- children,
108
- props: { name },
109
- ref,
110
- content: name,
111
- attributes,
112
- });
113
- if (rendered)
114
- return rendered;
115
- }
116
- return (_jsx("div", { className: className, ...attributes, children: name }));
102
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productName, customElement: children, customElementProps: { name }, content: name, children: _jsx("div", { children: name }) }));
117
103
  } }));
118
104
  });
119
105
  /**
@@ -142,9 +128,6 @@ export const Name = React.forwardRef((props, ref) => {
142
128
  export const Description = React.forwardRef((props, ref) => {
143
129
  const { asChild, children, className, as = AsContent.Plain } = props;
144
130
  return (_jsx(CoreProduct.Description, { children: ({ description: richDescription, plainDescription }) => {
145
- const attributes = {
146
- 'data-testid': TestIds.productDescription,
147
- };
148
131
  // Determine which description to use based on the 'as' prop
149
132
  let description;
150
133
  switch (as) {
@@ -162,22 +145,13 @@ export const Description = React.forwardRef((props, ref) => {
162
145
  : '';
163
146
  break;
164
147
  }
165
- if (asChild) {
166
- const rendered = renderAsChild({
167
- children,
168
- props: { description },
169
- ref,
170
- content: description,
171
- attributes,
172
- });
173
- if (rendered)
174
- return rendered;
175
- }
176
- // Default rendering based on format
177
- if (as === AsContent.Html) {
178
- return (_jsx("div", { className: className, ...attributes, dangerouslySetInnerHTML: { __html: description } }));
148
+ // Handle default rendering based on format
149
+ if (!asChild || !children) {
150
+ if (as === AsContent.Html) {
151
+ return (_jsx("div", { ref: ref, className: className, "data-testid": TestIds.productDescription, dangerouslySetInnerHTML: { __html: description } }));
152
+ }
179
153
  }
180
- return (_jsx("div", { className: className, ...attributes, children: description }));
154
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productDescription, customElement: children, customElementProps: { description }, content: description, children: _jsx("div", { children: description }) }));
181
155
  } }));
182
156
  });
183
157
  /**
@@ -207,26 +181,10 @@ export const Description = React.forwardRef((props, ref) => {
207
181
  export const Price = React.forwardRef((props, ref) => {
208
182
  const { asChild, children, className } = props;
209
183
  return (_jsx(SelectedVariant.Price, { children: ({ price, compareAtPrice }) => {
210
- const attributes = {
211
- 'data-testid': TestIds.productPrice,
212
- 'data-discounted': compareAtPrice !== null,
213
- };
214
- const priceData = {
215
- price,
216
- formattedPrice: price,
217
- };
218
- if (asChild) {
219
- const rendered = renderAsChild({
220
- children,
221
- props: priceData,
222
- ref,
223
- content: price,
224
- attributes,
225
- });
226
- if (rendered)
227
- return rendered;
228
- }
229
- return (_jsx("span", { className: className, ...attributes, ref: ref, children: price }));
184
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productPrice, "data-discounted": compareAtPrice !== null, customElement: children, customElementProps: {
185
+ price,
186
+ formattedPrice: price,
187
+ }, content: price, children: _jsx("span", { children: price }) }));
230
188
  } }));
231
189
  });
232
190
  /**
@@ -261,30 +219,14 @@ export const CompareAtPrice = React.forwardRef((props, ref) => {
261
219
  const { asChild, children, className } = props;
262
220
  const testId = TestIds.productCompareAtPrice;
263
221
  return (_jsx(SelectedVariant.Price, { children: ({ compareAtPrice }) => {
264
- const attributes = {
265
- 'data-testid': testId,
266
- 'data-discounted': compareAtPrice !== null,
267
- };
268
222
  // Don't render anything if there's no compare-at price
269
223
  if (!compareAtPrice) {
270
224
  return null;
271
225
  }
272
- const priceData = {
273
- price: compareAtPrice,
274
- formattedPrice: compareAtPrice,
275
- };
276
- if (asChild) {
277
- const rendered = renderAsChild({
278
- children,
279
- props: priceData,
280
- ref,
281
- content: compareAtPrice,
282
- attributes,
283
- });
284
- if (rendered)
285
- return rendered;
286
- }
287
- return (_jsx("span", { className: className, ...attributes, ref: ref, children: compareAtPrice }));
226
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": testId, "data-discounted": compareAtPrice !== null, customElement: children, customElementProps: {
227
+ price: compareAtPrice,
228
+ formattedPrice: compareAtPrice,
229
+ }, content: compareAtPrice, children: _jsx("span", { children: compareAtPrice }) }));
288
230
  } }));
289
231
  });
290
232
  /**
@@ -310,25 +252,10 @@ export const CompareAtPrice = React.forwardRef((props, ref) => {
310
252
  * ```
311
253
  */
312
254
  export const Slug = React.forwardRef((props, ref) => {
313
- const { asChild, children } = props;
255
+ const { asChild, children, className } = props;
314
256
  const testId = TestIds.productSlug;
315
257
  return (_jsx(CoreProduct.Slug, { children: ({ slug }) => {
316
- const attributes = {
317
- 'data-testid': testId,
318
- };
319
- const slugData = { slug };
320
- if (asChild) {
321
- const rendered = renderAsChild({
322
- children,
323
- props: slugData,
324
- ref,
325
- content: slug,
326
- attributes,
327
- });
328
- if (rendered)
329
- return rendered;
330
- }
331
- return (_jsx("span", { ...attributes, ref: ref, children: slug }));
258
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": testId, customElement: children, customElementProps: { slug }, content: slug, children: _jsx("span", { children: slug }) }));
332
259
  } }));
333
260
  });
334
261
  /**
@@ -351,24 +278,13 @@ export const Slug = React.forwardRef((props, ref) => {
351
278
  * ```
352
279
  */
353
280
  export const Raw = React.forwardRef((props, ref) => {
354
- const { asChild, children } = props;
281
+ const { asChild, children, className } = props;
355
282
  return (_jsx(CoreProduct.Content, { children: ({ product }) => {
356
- const attributes = {
357
- 'data-testid': TestIds.productRaw,
358
- };
359
- if (asChild) {
360
- const rendered = renderAsChild({
361
- children,
362
- props: { product },
363
- ref,
364
- content: null,
365
- attributes,
366
- });
367
- if (rendered)
368
- return rendered;
369
- }
370
283
  // Raw component should not render anything by default when not using asChild
371
- return null;
284
+ if (!asChild || !children) {
285
+ return null;
286
+ }
287
+ return (_jsx(AsChildSlot, { ref: ref, className: className, "data-testid": TestIds.productRaw, customElement: children, customElementProps: { product } }));
372
288
  } }));
373
289
  });
374
290
  /**
@@ -414,7 +330,7 @@ export const Raw = React.forwardRef((props, ref) => {
414
330
  * ```
415
331
  */
416
332
  export const Variants = React.forwardRef((props, ref) => {
417
- const { asChild, children } = props;
333
+ const { asChild, children, className } = props;
418
334
  return (_jsx(ProductVariantSelector.Options, { children: ({ hasOptions, options }) => {
419
335
  if (!hasOptions)
420
336
  return null;
@@ -422,24 +338,7 @@ export const Variants = React.forwardRef((props, ref) => {
422
338
  hasOptions,
423
339
  options,
424
340
  };
425
- const attributes = {
426
- 'data-testid': TestIds.productVariants,
427
- };
428
- const content = (_jsx(VariantsContext.Provider, { value: contextValue, children: typeof children === 'function'
429
- ? null
430
- : children }));
431
- if (asChild) {
432
- const rendered = renderAsChild({
433
- children,
434
- props: { hasOptions },
435
- ref,
436
- content,
437
- attributes,
438
- });
439
- if (rendered)
440
- return rendered;
441
- }
442
- return (_jsx("div", { ...attributes, ref: ref, children: content }));
341
+ return (_jsx(VariantsContext.Provider, { value: contextValue, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariants, customElement: children, children: _jsx("div", { children: React.isValidElement(children) ? children : null }) }) }));
443
342
  } }));
444
343
  });
445
344
  /**
@@ -542,7 +441,7 @@ export const VariantOptionRepeater = React.forwardRef((props, _ref) => {
542
441
  * ```
543
442
  */
544
443
  export const Modifiers = React.forwardRef((props, ref) => {
545
- const { asChild, children } = props;
444
+ const { asChild, children, className } = props;
546
445
  return (_jsx(ProductModifiers.Modifiers, { children: ({ hasModifiers, modifiers }) => {
547
446
  if (!hasModifiers)
548
447
  return null;
@@ -550,24 +449,7 @@ export const Modifiers = React.forwardRef((props, ref) => {
550
449
  hasModifiers,
551
450
  modifiers,
552
451
  };
553
- const attributes = {
554
- 'data-testid': TestIds.productModifiers,
555
- };
556
- const content = (_jsx(ModifiersContext.Provider, { value: contextValue, children: typeof children === 'function'
557
- ? null
558
- : children }));
559
- if (asChild) {
560
- const rendered = renderAsChild({
561
- children,
562
- props: { hasModifiers },
563
- ref,
564
- content,
565
- attributes,
566
- });
567
- if (rendered)
568
- return rendered;
569
- }
570
- return (_jsx("div", { ...attributes, ref: ref, children: content }));
452
+ return (_jsx(ModifiersContext.Provider, { value: contextValue, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productModifiers, customElement: children, children: _jsx("div", { children: React.isValidElement(children) ? children : null }) }) }));
571
453
  } }));
572
454
  });
573
455
  /**
@@ -2,7 +2,6 @@ import type { V3Product } from '@wix/auto_sdk_stores_products-v-3';
2
2
  import React from 'react';
3
3
  import type { ProductsListSearchServiceConfig } from '../services/products-list-search-service.js';
4
4
  import type { ProductsListServiceConfig } from '../services/products-list-service.js';
5
- import { type AsChildProps } from '../utils/renderAsChild.js';
6
5
  /**
7
6
  * Props for the ProductList root component following the documented API
8
7
  */
@@ -139,9 +138,15 @@ export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTr
139
138
  /**
140
139
  * Props for ProductList Totals Displayed component
141
140
  */
142
- export interface TotalsDisplayedProps extends AsChildProps<{
143
- displayedProducts: number;
144
- }> {
141
+ export interface TotalsDisplayedProps {
142
+ /** Whether to render as a child component */
143
+ asChild?: boolean;
144
+ /** Custom render function when using asChild */
145
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLElement, {
146
+ displayedProducts: number;
147
+ }> | React.ForwardRefExoticComponent<any>;
148
+ /** CSS classes to apply to the default element */
149
+ className?: string;
145
150
  }
146
151
  /**
147
152
  * Displays the number of products currently displayed.
@@ -5,7 +5,7 @@ import { ProductsListServiceDefinition } from '../services/products-list-service
5
5
  import * as CoreProductList from './core/ProductList.js';
6
6
  import * as CoreProductListPagination from './core/ProductListPagination.js';
7
7
  import * as Product from './Product.js';
8
- import { renderAsChild } from '../utils/renderAsChild.js';
8
+ import { AsChildSlot } from '@wix/headless-utils/react';
9
9
  var TestIds;
10
10
  (function (TestIds) {
11
11
  TestIds["productListRoot"] = "product-list-root";
@@ -177,20 +177,7 @@ export const LoadMoreTrigger = React.forwardRef((props, ref) => {
177
177
  if (!hasMoreProducts)
178
178
  return null;
179
179
  const handleClick = () => loadMore(10);
180
- const attributes = {
181
- 'data-testid': TestIds.productListLoadMore,
182
- className,
183
- onClick: handleClick,
184
- disabled: isLoading,
185
- };
186
- if (asChild && React.isValidElement(children)) {
187
- return React.cloneElement(children, {
188
- ...attributes,
189
- onClick: handleClick,
190
- ref,
191
- });
192
- }
193
- return (_jsx("button", { ...attributes, ref: ref, children: children }));
180
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children, children: _jsx("button", { children: children }) }));
194
181
  } }));
195
182
  });
196
183
  /**
@@ -215,21 +202,5 @@ export const TotalsDisplayed = React.forwardRef((props, ref) => {
215
202
  const productsListService = useService(ProductsListServiceDefinition);
216
203
  const products = productsListService.products.get();
217
204
  const displayedProducts = products.length;
218
- const attributes = {
219
- 'data-testid': TestIds.productListTotalsDisplayed,
220
- 'data-displayed': displayedProducts,
221
- className,
222
- };
223
- if (asChild) {
224
- const rendered = renderAsChild({
225
- children,
226
- props: { displayedProducts },
227
- ref,
228
- content: displayedProducts.toString(),
229
- attributes,
230
- });
231
- if (rendered)
232
- return rendered;
233
- }
234
- return (_jsx("span", { ...attributes, ref: ref, children: displayedProducts }));
205
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListTotalsDisplayed, "data-displayed": displayedProducts, customElement: children, customElementProps: { displayedProducts }, content: displayedProducts, children: _jsx("span", { children: displayedProducts }) }));
235
206
  });