@propeller-commerce/propeller-v2-react-ui 0.4.26 → 0.4.28
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.
- package/CHANGELOG.md +37 -0
- package/dist/index.cjs +39 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +39 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6624,6 +6624,21 @@ interface SearchBarProps {
|
|
|
6624
6624
|
* Omit to keep the div-based fallback.
|
|
6625
6625
|
*/
|
|
6626
6626
|
getViewAllHref?: (term: string) => string;
|
|
6627
|
+
/**
|
|
6628
|
+
* Show the price column on each autosuggest result. Defaults to `true`.
|
|
6629
|
+
* Set `false` to hide prices entirely in the dropdown — e.g. a B2B
|
|
6630
|
+
* contract-catalogue context where prices are quote-only and shouldn't
|
|
6631
|
+
* appear in the live preview. Ignored when {@link renderPrice} is provided.
|
|
6632
|
+
*/
|
|
6633
|
+
showPrice?: boolean;
|
|
6634
|
+
/**
|
|
6635
|
+
* Replace the price cell of each result with custom content. When provided,
|
|
6636
|
+
* this fully overrides the default price rendering (and `showPrice`) — return
|
|
6637
|
+
* any node (e.g. a "Price by quotation" label for a contract catalogue), or
|
|
6638
|
+
* `null` to render nothing for that result. Keeps price/quotation wording
|
|
6639
|
+
* app-specific rather than baked into the package.
|
|
6640
|
+
*/
|
|
6641
|
+
renderPrice?: (result: SearchBarResult) => React$1.ReactNode;
|
|
6627
6642
|
/** Custom price formatting function */
|
|
6628
6643
|
formatPrice?: (price: number) => string;
|
|
6629
6644
|
/** Currency symbol for prices. Resolved from PropellerProvider when omitted; defaults to '€'. */
|
package/dist/index.d.ts
CHANGED
|
@@ -6624,6 +6624,21 @@ interface SearchBarProps {
|
|
|
6624
6624
|
* Omit to keep the div-based fallback.
|
|
6625
6625
|
*/
|
|
6626
6626
|
getViewAllHref?: (term: string) => string;
|
|
6627
|
+
/**
|
|
6628
|
+
* Show the price column on each autosuggest result. Defaults to `true`.
|
|
6629
|
+
* Set `false` to hide prices entirely in the dropdown — e.g. a B2B
|
|
6630
|
+
* contract-catalogue context where prices are quote-only and shouldn't
|
|
6631
|
+
* appear in the live preview. Ignored when {@link renderPrice} is provided.
|
|
6632
|
+
*/
|
|
6633
|
+
showPrice?: boolean;
|
|
6634
|
+
/**
|
|
6635
|
+
* Replace the price cell of each result with custom content. When provided,
|
|
6636
|
+
* this fully overrides the default price rendering (and `showPrice`) — return
|
|
6637
|
+
* any node (e.g. a "Price by quotation" label for a contract catalogue), or
|
|
6638
|
+
* `null` to render nothing for that result. Keeps price/quotation wording
|
|
6639
|
+
* app-specific rather than baked into the package.
|
|
6640
|
+
*/
|
|
6641
|
+
renderPrice?: (result: SearchBarResult) => React$1.ReactNode;
|
|
6627
6642
|
/** Custom price formatting function */
|
|
6628
6643
|
formatPrice?: (price: number) => string;
|
|
6629
6644
|
/** Currency symbol for prices. Resolved from PropellerProvider when omitted; defaults to '€'. */
|
package/dist/index.js
CHANGED
|
@@ -2344,9 +2344,21 @@ function useProductSearch(options) {
|
|
|
2344
2344
|
if (!graphqlClient) return;
|
|
2345
2345
|
setSearchLoading(true);
|
|
2346
2346
|
try {
|
|
2347
|
-
const service = createServices(graphqlClient).
|
|
2348
|
-
const
|
|
2349
|
-
|
|
2347
|
+
const service = createServices(graphqlClient).category;
|
|
2348
|
+
const catId = configuration?.baseCategoryId ?? 0;
|
|
2349
|
+
if (!catId) {
|
|
2350
|
+
setSearchResults([]);
|
|
2351
|
+
setSearchItemsFound(0);
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
const orderlistScope = options.orderlistIds && options.orderlistIds.length > 0 ? {
|
|
2355
|
+
applyOrderlists: options.applyOrderlists !== false,
|
|
2356
|
+
orderlistIds: options.orderlistIds
|
|
2357
|
+
} : { applyOrderlists: false };
|
|
2358
|
+
const userId = options.user && "contactId" in options.user ? options.user.contactId : options.user && "customerId" in options.user ? options.user.customerId : void 0;
|
|
2359
|
+
const contactId = options.user && "contactId" in options.user ? options.user.contactId : void 0;
|
|
2360
|
+
const customerId = options.user && "customerId" in options.user ? options.user.customerId : void 0;
|
|
2361
|
+
const categoryProductSearchInput = {
|
|
2350
2362
|
language,
|
|
2351
2363
|
page: 1,
|
|
2352
2364
|
offset: 10,
|
|
@@ -2356,7 +2368,8 @@ function useProductSearch(options) {
|
|
|
2356
2368
|
ProductStatus.T,
|
|
2357
2369
|
ProductStatus.S
|
|
2358
2370
|
],
|
|
2359
|
-
|
|
2371
|
+
hidden: false,
|
|
2372
|
+
term,
|
|
2360
2373
|
searchFields: [
|
|
2361
2374
|
{
|
|
2362
2375
|
fieldNames: [
|
|
@@ -2383,17 +2396,31 @@ function useProductSearch(options) {
|
|
|
2383
2396
|
],
|
|
2384
2397
|
boost: 1
|
|
2385
2398
|
}
|
|
2386
|
-
]
|
|
2399
|
+
],
|
|
2400
|
+
sortInputs: [{ field: ProductSortField.RELEVANCE, order: SortOrder.DESC }],
|
|
2401
|
+
...options.companyId && { companyId: options.companyId },
|
|
2402
|
+
...userId !== void 0 && { userId },
|
|
2403
|
+
...orderlistScope
|
|
2404
|
+
};
|
|
2405
|
+
const priceCalculateProductInput = {
|
|
2406
|
+
taxZone,
|
|
2407
|
+
...options.companyId && { companyId: options.companyId },
|
|
2408
|
+
...contactId !== void 0 && { contactId },
|
|
2409
|
+
...customerId !== void 0 && { customerId }
|
|
2387
2410
|
};
|
|
2388
2411
|
const variables = {
|
|
2389
|
-
|
|
2412
|
+
categoryId: catId,
|
|
2390
2413
|
language,
|
|
2414
|
+
categoryProductSearchInput,
|
|
2415
|
+
priceCalculateProductInput,
|
|
2416
|
+
imageSearchFilters: configuration?.imageSearchFiltersGrid,
|
|
2391
2417
|
imageVariantFilters: configuration?.imageVariantFiltersMedium
|
|
2392
2418
|
};
|
|
2393
|
-
const
|
|
2394
|
-
const
|
|
2419
|
+
const response = await service.getCategory(variables);
|
|
2420
|
+
const productsResponse = response?.products;
|
|
2421
|
+
const items = productsResponse?.items ?? [];
|
|
2395
2422
|
setSearchResults(items);
|
|
2396
|
-
setSearchItemsFound(
|
|
2423
|
+
setSearchItemsFound(productsResponse?.itemsFound ?? items.length);
|
|
2397
2424
|
} catch {
|
|
2398
2425
|
setSearchResults([]);
|
|
2399
2426
|
setSearchItemsFound(0);
|
|
@@ -2402,7 +2429,8 @@ function useProductSearch(options) {
|
|
|
2402
2429
|
}
|
|
2403
2430
|
}, 300);
|
|
2404
2431
|
},
|
|
2405
|
-
|
|
2432
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2433
|
+
[graphqlClient, language, configuration, userKey, JSON.stringify(options.orderlistIds ?? []), options.applyOrderlists]
|
|
2406
2434
|
);
|
|
2407
2435
|
useEffect(() => {
|
|
2408
2436
|
if (!isControlled) fetchProducts();
|
|
@@ -17362,7 +17390,7 @@ function SearchBar(rawProps) {
|
|
|
17362
17390
|
result.sku
|
|
17363
17391
|
] }) : null
|
|
17364
17392
|
] }),
|
|
17365
|
-
result.price !== void 0 && result.price !== null ? /* @__PURE__ */ jsxs("div", { className: "propeller-search-bar__result-price text-sm font-semibold text-foreground flex-shrink-0 text-right", children: [
|
|
17393
|
+
props.renderPrice ? props.renderPrice(result) : props.showPrice !== false && result.price !== void 0 && result.price !== null ? /* @__PURE__ */ jsxs("div", { className: "propeller-search-bar__result-price text-sm font-semibold text-foreground flex-shrink-0 text-right", children: [
|
|
17366
17394
|
/* @__PURE__ */ jsx("span", { className: "propeller-search-bar__result-price-value", children: formatItemPrice(leadingPrice(result)) }),
|
|
17367
17395
|
/* @__PURE__ */ jsx("span", { className: "propeller-search-bar__result-price-label block text-xs font-normal text-muted-foreground", children: priceTaxLabel() })
|
|
17368
17396
|
] }) : null
|