@wix/headless-stores 0.0.79 → 0.0.80

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.
@@ -120,9 +120,29 @@ export declare const ProductRepeater: React.ForwardRefExoticComponent<ProductRep
120
120
  * Props for ProductList LoadMoreTrigger component
121
121
  */
122
122
  export interface LoadMoreTriggerProps {
123
- children?: React.ReactNode;
123
+ /** Custom render function when using asChild */
124
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLButtonElement, {
125
+ isLoading: boolean;
126
+ hasMoreProducts: boolean;
127
+ loadMore: () => void;
128
+ }>;
129
+ /**
130
+ * Whether to render as a child component.
131
+ * @default false
132
+ */
124
133
  asChild?: boolean;
134
+ /**
135
+ * The CSS classes to apply to the button.
136
+ */
125
137
  className?: string;
138
+ /**
139
+ * The label to display inside the button.
140
+ */
141
+ label?: string;
142
+ /**
143
+ * The loading state to display inside the button.
144
+ */
145
+ loadingState?: React.ReactNode;
126
146
  }
127
147
  /**
128
148
  * Displays a button to load more products. Not rendered if infiniteScroll is false or no products are left to load.
@@ -136,7 +156,7 @@ export interface LoadMoreTriggerProps {
136
156
  * </ProductList.LoadMoreTrigger>
137
157
  * ```
138
158
  */
139
- export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<HTMLElement>>;
159
+ export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<HTMLButtonElement>>;
140
160
  /**
141
161
  * Props for ProductList Totals Displayed component
142
162
  */
@@ -176,13 +176,17 @@ export const ProductRepeater = React.forwardRef((props, _ref) => {
176
176
  * ```
177
177
  */
178
178
  export const LoadMoreTrigger = React.forwardRef((props, ref) => {
179
- const { asChild, children, className } = props;
179
+ const { asChild, children, className, label = 'Load More', loadingState = 'Loading...', } = props;
180
180
  return (_jsx(CoreProductListPagination.LoadMoreTrigger, { children: ({ loadMore, hasMoreProducts, isLoading }) => {
181
181
  // Don't render if no more products to load
182
182
  if (!hasMoreProducts)
183
183
  return null;
184
184
  const handleClick = () => loadMore(10);
185
- return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children, children: _jsx("button", { children: children }) }));
185
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children, customElementProps: {
186
+ loadMore,
187
+ hasMoreProducts,
188
+ isLoading,
189
+ }, children: _jsx("button", { children: isLoading ? loadingState : label }) }));
186
190
  } }));
187
191
  });
188
192
  /**
@@ -120,9 +120,29 @@ export declare const ProductRepeater: React.ForwardRefExoticComponent<ProductRep
120
120
  * Props for ProductList LoadMoreTrigger component
121
121
  */
122
122
  export interface LoadMoreTriggerProps {
123
- children?: React.ReactNode;
123
+ /** Custom render function when using asChild */
124
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLButtonElement, {
125
+ isLoading: boolean;
126
+ hasMoreProducts: boolean;
127
+ loadMore: () => void;
128
+ }>;
129
+ /**
130
+ * Whether to render as a child component.
131
+ * @default false
132
+ */
124
133
  asChild?: boolean;
134
+ /**
135
+ * The CSS classes to apply to the button.
136
+ */
125
137
  className?: string;
138
+ /**
139
+ * The label to display inside the button.
140
+ */
141
+ label?: string;
142
+ /**
143
+ * The loading state to display inside the button.
144
+ */
145
+ loadingState?: React.ReactNode;
126
146
  }
127
147
  /**
128
148
  * Displays a button to load more products. Not rendered if infiniteScroll is false or no products are left to load.
@@ -136,7 +156,7 @@ export interface LoadMoreTriggerProps {
136
156
  * </ProductList.LoadMoreTrigger>
137
157
  * ```
138
158
  */
139
- export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<HTMLElement>>;
159
+ export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<HTMLButtonElement>>;
140
160
  /**
141
161
  * Props for ProductList Totals Displayed component
142
162
  */
@@ -176,13 +176,17 @@ export const ProductRepeater = React.forwardRef((props, _ref) => {
176
176
  * ```
177
177
  */
178
178
  export const LoadMoreTrigger = React.forwardRef((props, ref) => {
179
- const { asChild, children, className } = props;
179
+ const { asChild, children, className, label = 'Load More', loadingState = 'Loading...', } = props;
180
180
  return (_jsx(CoreProductListPagination.LoadMoreTrigger, { children: ({ loadMore, hasMoreProducts, isLoading }) => {
181
181
  // Don't render if no more products to load
182
182
  if (!hasMoreProducts)
183
183
  return null;
184
184
  const handleClick = () => loadMore(10);
185
- return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children, children: _jsx("button", { children: children }) }));
185
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children, customElementProps: {
186
+ loadMore,
187
+ hasMoreProducts,
188
+ isLoading,
189
+ }, children: _jsx("button", { children: isLoading ? loadingState : label }) }));
186
190
  } }));
187
191
  });
188
192
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-stores",
3
- "version": "0.0.79",
3
+ "version": "0.0.80",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "prebuild": "cd ../media && yarn build && cd ../ecom && yarn build",