@propeller-commerce/propeller-v2-react-ui 0.4.15 → 0.4.16

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/dist/index.js CHANGED
@@ -2025,7 +2025,13 @@ function useProductInfo(options) {
2025
2025
  setError(null);
2026
2026
  try {
2027
2027
  let orderlistIds = [];
2028
- if (options.user && options.companyId) {
2028
+ let applyOrderlists = true;
2029
+ if (options.orderlistIds && options.orderlistIds.length > 0) {
2030
+ orderlistIds = options.orderlistIds;
2031
+ applyOrderlists = options.applyOrderlists !== false;
2032
+ } else if (options.applyOrderlists === false) {
2033
+ applyOrderlists = false;
2034
+ } else if (options.user && options.companyId) {
2029
2035
  const orderlistService = createServices(graphqlClient).orderlist;
2030
2036
  const searchInput = { companyIds: [options.companyId] };
2031
2037
  const orderlists = await orderlistService.getOrderlists(searchInput);
@@ -2036,7 +2042,7 @@ function useProductInfo(options) {
2036
2042
  const variables = {
2037
2043
  productId,
2038
2044
  language,
2039
- applyOrderlists: true,
2045
+ applyOrderlists,
2040
2046
  orderlistIds,
2041
2047
  imageSearchFilters: imageSearchFilters ?? configuration.imageSearchFiltersGrid,
2042
2048
  imageVariantFilters: imageVariantFilters ?? configuration.imageVariantFiltersLarge ?? configuration.imageVariantFiltersSmall,
@@ -2220,6 +2226,10 @@ function useProductSearch(options) {
2220
2226
  const userId = options.user && "contactId" in options.user ? options.user.contactId : options.user && "customerId" in options.user ? options.user.customerId : void 0;
2221
2227
  const contactId = options.user && "contactId" in options.user ? options.user.contactId : void 0;
2222
2228
  const customerId = options.user && "customerId" in options.user ? options.user.customerId : void 0;
2229
+ const orderlistScope = options.orderlistIds && options.orderlistIds.length > 0 ? {
2230
+ applyOrderlists: options.applyOrderlists !== false,
2231
+ orderlistIds: options.orderlistIds
2232
+ } : { applyOrderlists: false };
2223
2233
  const categoryProductSearchInput = {
2224
2234
  language: lang,
2225
2235
  page: pagination.currentPage,
@@ -2237,7 +2247,8 @@ function useProductSearch(options) {
2237
2247
  ...priceFilter && { price: priceFilter },
2238
2248
  ...sortInputs.length && { sortInputs },
2239
2249
  ...options.companyId && { companyId: options.companyId },
2240
- ...userId !== void 0 && { userId }
2250
+ ...userId !== void 0 && { userId },
2251
+ ...orderlistScope
2241
2252
  };
2242
2253
  const priceCalculateProductInput = {
2243
2254
  taxZone,
@@ -7410,7 +7421,7 @@ function CategoryDescription(props) {
7410
7421
  const plain = html.replace(/<[^>]*>/g, "");
7411
7422
  if (plain.length <= maxLen) return html;
7412
7423
  const truncated = plain.substring(0, maxLen);
7413
- return truncated.substring(0, truncated.lastIndexOf(" ")) + "\xE2\u20AC\xA6";
7424
+ return truncated.substring(0, truncated.lastIndexOf(" ")) + "\u2026";
7414
7425
  }
7415
7426
  return /* @__PURE__ */ jsx(Fragment, { children: !!html ? /* @__PURE__ */ jsxs(
7416
7427
  "div",
@@ -10677,7 +10688,8 @@ function GridToolbar(rawProps) {
10677
10688
  }
10678
10689
  function getSortOptions() {
10679
10690
  const opts = props.sortOptions || [];
10680
- return opts.length > 0 ? opts : ALL_SORT_FIELDS;
10691
+ const base = opts.length > 0 ? opts : ALL_SORT_FIELDS;
10692
+ return props.hidePriceSort ? base.filter((f) => f !== ProductSortField.PRICE) : base;
10681
10693
  }
10682
10694
  function getOffsetOptions() {
10683
10695
  const opts = props.offset || [];
@@ -11100,10 +11112,12 @@ function Menu(rawProps) {
11100
11112
  }
11101
11113
  function getCategoryUrl(cat) {
11102
11114
  const lang = props.language || "NL";
11103
- return props.configuration.urls.getCategoryUrl(
11104
- { categoryId: cat.categoryId, slug: [{ value: cat.slug, language: lang }] },
11105
- lang
11106
- );
11115
+ const category = {
11116
+ categoryId: cat.categoryId,
11117
+ slug: [{ value: cat.slug, language: lang }]
11118
+ };
11119
+ if (props.getUrl) return props.getUrl(category);
11120
+ return props.configuration.urls.getCategoryUrl(category, lang);
11107
11121
  }
11108
11122
  function getSubCategories(cat) {
11109
11123
  return (cat.children || []).filter((sub) => sub.name && sub.slug);
@@ -13918,7 +13932,7 @@ function useProductGrid() {
13918
13932
  const ctx = useContext(ProductGridSearchContext);
13919
13933
  if (!ctx) {
13920
13934
  throw new Error(
13921
- "<ProductGrid.X> must be rendered inside <ProductGrid>. Got null context \xE2\u20AC\u201D wrap the subcomponents in <ProductGrid categoryId={...}>...</ProductGrid>."
13935
+ "<ProductGrid.X> must be rendered inside <ProductGrid>. Got null context \u2014 wrap the subcomponents in <ProductGrid categoryId={...}>...</ProductGrid>."
13922
13936
  );
13923
13937
  }
13924
13938
  return ctx;
@@ -13939,6 +13953,8 @@ function ProductGrid(rawProps) {
13939
13953
  categoryId: props.categoryId,
13940
13954
  term: props.term,
13941
13955
  brand: props.brand,
13956
+ orderlistIds: props.orderlistIds,
13957
+ applyOrderlists: props.applyOrderlists,
13942
13958
  language: props.language,
13943
13959
  taxZone: props.taxZone,
13944
13960
  user: props.user,
@@ -14341,9 +14357,15 @@ function useProductInfoContext() {
14341
14357
  }
14342
14358
  function ProductInfo(rawProps) {
14343
14359
  const props = useInfraProps(rawProps);
14344
- const { product: fetchedProduct, loading, fetchProduct } = useProductInfo(
14345
- props.graphqlClient ? { graphqlClient: props.graphqlClient, language: props.language, configuration: props.configuration } : { graphqlClient: {}, language: props.language, configuration: props.configuration }
14346
- );
14360
+ const { product: fetchedProduct, loading, fetchProduct } = useProductInfo({
14361
+ graphqlClient: props.graphqlClient ?? {},
14362
+ language: props.language,
14363
+ configuration: props.configuration,
14364
+ user: props.user,
14365
+ companyId: props.companyId,
14366
+ orderlistIds: props.orderlistIds,
14367
+ applyOrderlists: props.applyOrderlists
14368
+ });
14347
14369
  const activeProduct = props.product || fetchedProduct;
14348
14370
  function getProductName5() {
14349
14371
  if (!activeProduct) return "";
@@ -15061,13 +15083,14 @@ function ProductSpecifications(rawProps) {
15061
15083
  if (!props.productId || !props.graphqlClient) return;
15062
15084
  fetchSpecs(props.productId);
15063
15085
  }, [props.productId]);
15064
- return /* @__PURE__ */ jsx(Fragment, { children: !loading && hasPublicAttributes() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
15086
+ return /* @__PURE__ */ jsx(Fragment, { children: !loading && (hasPublicAttributes() || props.packageDescription) ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
15065
15087
  "div",
15066
15088
  {
15067
15089
  className: `propeller-product-specifications ${props.className || ""}`,
15068
15090
  "data-layout": props.layout === "list" ? "list" : "table",
15069
15091
  "data-grouped": props.grouping ? "true" : "false",
15070
15092
  children: [
15093
+ props.packageDescription ? /* @__PURE__ */ jsx("p", { className: "propeller-product-specifications__package-description mb-4 text-sm text-muted-foreground", children: props.packageDescription }) : null,
15071
15094
  !props.grouping ? /* @__PURE__ */ jsxs(Fragment, { children: [
15072
15095
  props.layout !== "list" ? /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-lg border border-border", children: /* @__PURE__ */ jsx("table", { className: "w-full text-sm", children: /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-border", children: getAttributes()?.map((attr, i) => /* @__PURE__ */ jsxs("tr", { className: "propeller-product-specifications__row odd:bg-card even:bg-muted/20", children: [
15073
15096
  /* @__PURE__ */ jsx("td", { className: "px-4 py-2 font-medium text-foreground w-1/2", children: getAttributeLabel(attr) }),
@@ -15296,7 +15319,8 @@ function ProductTabs(rawProps) {
15296
15319
  attributes: getSpecsAttributes(),
15297
15320
  language: props.language,
15298
15321
  layout: props.specificationsLayout,
15299
- grouping: props.specificationsGrouping
15322
+ grouping: props.specificationsGrouping,
15323
+ packageDescription: props.specificationsPackageDescription
15300
15324
  }
15301
15325
  ) }) : null,
15302
15326
  isActive("downloads") && isTabVisible("downloads") ? /* @__PURE__ */ jsx(
@@ -15399,7 +15423,8 @@ function ProductTabs(rawProps) {
15399
15423
  attributes: getSpecsAttributes(),
15400
15424
  language: props.language,
15401
15425
  layout: props.specificationsLayout,
15402
- grouping: props.specificationsGrouping
15426
+ grouping: props.specificationsGrouping,
15427
+ packageDescription: props.specificationsPackageDescription
15403
15428
  }
15404
15429
  ) }) : null
15405
15430
  ] }) : null,
@@ -16186,7 +16211,7 @@ function RegisterForm(rawProps) {
16186
16211
  const contactLabel = props.labels?.contactLabel || "Company";
16187
16212
  const customerLabel = props.labels?.customerLabel || "Consumer";
16188
16213
  const emailPlaceholder = props.labels?.emailPlaceholder || "name@example.com";
16189
- const passwordPlaceholder = props.labels?.passwordPlaceholder || "\xE2\u20AC\xA2\xE2\u20AC\xA2\xE2\u20AC\xA2\xE2\u20AC\xA2\xE2\u20AC\xA2\xE2\u20AC\xA2\xE2\u20AC\xA2\xE2\u20AC\xA2";
16214
+ const passwordPlaceholder = props.labels?.passwordPlaceholder || "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
16190
16215
  const passwordMismatchText = props.labels?.passwordMismatch || "Passwords do not match";
16191
16216
  const loginText = props.labels?.loginText || "Already have an account?";
16192
16217
  const loginLinkText = props.labels?.loginLink || "Log in";
@@ -17090,7 +17115,9 @@ function SearchBar(rawProps) {
17090
17115
  graphqlClient: props.graphqlClient,
17091
17116
  language: props.language,
17092
17117
  configuration: props.configuration || {},
17093
- companyId: props.companyId
17118
+ companyId: props.companyId,
17119
+ orderlistIds: props.orderlistIds,
17120
+ applyOrderlists: props.applyOrderlists
17094
17121
  });
17095
17122
  const results = searchResults.slice(0, maxResults).map((item) => mapToSearchBarResult(item));
17096
17123
  const itemsFound = searchItemsFound;