@propeller-commerce/propeller-v2-react-ui 0.26.1 → 0.28.0

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/pure.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
3
4
  var propellerV2CoreUi = require('@propeller-commerce/propeller-v2-core-ui');
4
5
  var clsx = require('clsx');
5
6
  var tailwindMerge = require('tailwind-merge');
6
- var jsxRuntime = require('react/jsx-runtime');
7
7
  var React = require('react');
8
8
  var propellerSdkV2 = require('@propeller-commerce/propeller-sdk-v2');
9
9
 
@@ -27,7 +27,23 @@ function _interopNamespace(e) {
27
27
 
28
28
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
29
 
30
- // src/components/Breadcrumbs.tsx
30
+ // src/components/PropellerImg.tsx
31
+ function PropellerImg({ as: Injected, ...props }) {
32
+ if (Injected) return /* @__PURE__ */ jsxRuntime.jsx(Injected, { ...props });
33
+ const { src, alt, className, width, height, loading, onClick } = props;
34
+ return /* @__PURE__ */ jsxRuntime.jsx(
35
+ "img",
36
+ {
37
+ src,
38
+ alt,
39
+ className,
40
+ width,
41
+ height,
42
+ loading,
43
+ onClick
44
+ }
45
+ );
46
+ }
31
47
  function cn(...inputs) {
32
48
  return tailwindMerge.twMerge(clsx.clsx(inputs));
33
49
  }
@@ -267,6 +283,28 @@ function ItemStock(props) {
267
283
  ) }) : null });
268
284
  }
269
285
  var ItemStock_default = React__namespace.memo(ItemStock);
286
+ var warnedOnce = /* @__PURE__ */ new Set();
287
+ function warnOnce(key, message) {
288
+ if (warnedOnce.has(key)) return;
289
+ warnedOnce.add(key);
290
+ console.warn(message);
291
+ }
292
+ function warnMissingProps(props) {
293
+ if (process.env.NODE_ENV === "production") return;
294
+ if (!props.language) {
295
+ warnOnce(
296
+ "language",
297
+ "[OrderItemCard] No `language` prop: product names resolve in the default catalogue language, whatever page they are on. This component reads no context (it ships from the RSC-safe /pure entry), so the host must pass it."
298
+ );
299
+ }
300
+ const linkable = props.titleLinkable !== void 0 ? props.titleLinkable : true;
301
+ if (linkable && !props.configuration?.urls) {
302
+ warnOnce(
303
+ "urls",
304
+ "[OrderItemCard] Title is linkable but no `configuration.urls` was passed: links fall back to a literal /product/:id/:slug and lose the locale prefix. Pass the url builders from the host, or set titleLinkable={false}."
305
+ );
306
+ }
307
+ }
270
308
  function getProductName(orderItem, language) {
271
309
  return propellerV2CoreUi.getLocalizedValue(orderItem?.product?.names, language, "") || orderItem?.name || "Unknown Product";
272
310
  }
@@ -290,6 +328,7 @@ function getProductUrl(orderItem, language, urls) {
290
328
  function OrderItemCard(props) {
291
329
  const item = props.orderItem;
292
330
  const isChildItem = props.isChildItem || false;
331
+ warnMissingProps(props);
293
332
  const titleLinkable = props.titleLinkable !== void 0 ? props.titleLinkable : true;
294
333
  const showImage = isChildItem ? false : props.showImage !== void 0 ? props.showImage : true;
295
334
  const showSku = isChildItem ? false : props.showSku !== void 0 ? props.showSku : true;
@@ -330,11 +369,13 @@ function OrderItemCard(props) {
330
369
  className: `propeller-order-item-card__cell propeller-order-item-card__cell--product ${isChildItem ? "px-6 py-2 pl-28" : "px-6 py-4"}`,
331
370
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
332
371
  showImage ? productImage ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "propeller-order-item-card__media relative w-16 h-16 flex-shrink-0 rounded overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
333
- "img",
372
+ PropellerImg,
334
373
  {
374
+ as: props.imgComponent,
335
375
  className: "propeller-order-item-card__image object-cover w-full h-full",
336
376
  src: productImage,
337
- alt: productName
377
+ alt: productName,
378
+ loading: "lazy"
338
379
  }
339
380
  ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "propeller-order-item-card__image-placeholder w-16 h-16 bg-surface-hover rounded flex items-center justify-center text-foreground-subtle text-xs", children: propellerV2CoreUi.getLabel(props.labels, "noImage", "No Img") }) : null,
340
381
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -972,5 +1013,6 @@ exports.ProductJsonLd = ProductJsonLd_default;
972
1013
  exports.ProductPrice = ProductPrice_default;
973
1014
  exports.ProductShortDescription = ProductShortDescription_default;
974
1015
  exports.ProductVideos = ProductVideos_default;
1016
+ exports.PropellerImg = PropellerImg;
975
1017
  //# sourceMappingURL=pure.cjs.map
976
1018
  //# sourceMappingURL=pure.cjs.map