@nok-integration/storefront-react 0.19.24 → 0.19.26

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.mjs CHANGED
@@ -5689,7 +5689,6 @@ const ES = {
5689
5689
  "See all": "Ver todo",
5690
5690
  "See more": "Ver más",
5691
5691
  "Select an option": "Selecciona una opción",
5692
- Share: "Compartir",
5693
5692
  Shipping: "Envío",
5694
5693
  "Shipping address": "Dirección de envío",
5695
5694
  "Shipping and returns": "Envíos y devoluciones",
@@ -9299,22 +9298,20 @@ function CartSheetProvider({ children }) {
9299
9298
  })]
9300
9299
  });
9301
9300
  }
9302
- const gallery = "_gallery_9e68b_1";
9303
- const track$2 = "_track_9e68b_8";
9304
- const slide$1 = "_slide_9e68b_32";
9305
- const image$4 = "_image_9e68b_39";
9306
- const placeholder$1 = "_placeholder_9e68b_43";
9307
- const share = "_share_9e68b_50";
9308
- const dots$2 = "_dots_9e68b_83";
9309
- const dot$2 = "_dot_9e68b_83";
9310
- const dotActive$2 = "_dotActive_9e68b_134";
9301
+ const gallery = "_gallery_nv2a9_1";
9302
+ const track$2 = "_track_nv2a9_8";
9303
+ const slide$1 = "_slide_nv2a9_32";
9304
+ const image$4 = "_image_nv2a9_39";
9305
+ const placeholder$1 = "_placeholder_nv2a9_43";
9306
+ const dots$2 = "_dots_nv2a9_49";
9307
+ const dot$2 = "_dot_nv2a9_49";
9308
+ const dotActive$2 = "_dotActive_nv2a9_88";
9311
9309
  const styles$i = {
9312
9310
  gallery,
9313
9311
  track: track$2,
9314
9312
  slide: slide$1,
9315
9313
  image: image$4,
9316
9314
  placeholder: placeholder$1,
9317
- share,
9318
9315
  dots: dots$2,
9319
9316
  dot: dot$2,
9320
9317
  dotActive: dotActive$2
@@ -9357,37 +9354,9 @@ function MediaGallery({ media: media2, alt }) {
9357
9354
  "aria-hidden": "true"
9358
9355
  });
9359
9356
  }
9360
- function share2() {
9361
- if (typeof navigator !== "undefined" && navigator.share) {
9362
- void navigator.share({
9363
- title: alt,
9364
- url: window.location.href
9365
- }).catch(() => {
9366
- });
9367
- }
9368
- }
9369
9357
  return jsxs("div", {
9370
9358
  className: styles$i.gallery,
9371
- children: [jsx("button", {
9372
- type: "button",
9373
- className: styles$i.share,
9374
- onClick: share2,
9375
- "aria-label": t("Share"),
9376
- children: jsx("svg", {
9377
- width: "20",
9378
- height: "20",
9379
- viewBox: "0 0 24 24",
9380
- fill: "none",
9381
- "aria-hidden": "true",
9382
- children: jsx("path", {
9383
- d: "M12 3v12M12 3 8 7m4-4 4 4M5 12v6a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6",
9384
- stroke: "currentColor",
9385
- strokeWidth: "1.6",
9386
- strokeLinecap: "round",
9387
- strokeLinejoin: "round"
9388
- })
9389
- })
9390
- }), jsx("div", {
9359
+ children: [jsx("div", {
9391
9360
  className: styles$i.track,
9392
9361
  ref: trackRef,
9393
9362
  role: "group",
@@ -10068,7 +10037,14 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
10068
10037
  const colourSoldOut = hasColours && selectedColour ? !colours.find((c) => c.value === selectedColour)?.available : false;
10069
10038
  const purchasable = anyInStock && !colourSoldOut;
10070
10039
  const colourImage = useMemo(() => selectedColour ? baseColours.find((c) => c.value === selectedColour)?.image : void 0, [baseColours, selectedColour]);
10071
- const media2 = useMemo(() => colourImage ? [colourImage, ...product.media.filter((m) => m !== colourImage)] : product.media, [colourImage, product.media]);
10040
+ const shootColour = baseColours[0]?.value;
10041
+ const media2 = useMemo(() => {
10042
+ if (!colourImage) return product.media;
10043
+ if (selectedColour === shootColour) {
10044
+ return [colourImage, ...product.media.filter((m) => m !== colourImage)];
10045
+ }
10046
+ return [colourImage];
10047
+ }, [colourImage, product.media, selectedColour, shootColour]);
10072
10048
  function selectSize(value2) {
10073
10049
  setSelectedSize(value2);
10074
10050
  setSizeError(false);
@@ -10690,37 +10666,50 @@ function CategoryView({ code, initialData, onNotFound }) {
10690
10666
  function ProductView({ sku, initialData, showRecommendations = true, onNotFound }) {
10691
10667
  const t = useT();
10692
10668
  const { api, market, emit } = useShop();
10693
- const [product, setProduct] = useState(initialData?.product ?? null);
10694
- const [inventory2, setInventory] = useState(initialData?.inventory ?? null);
10695
- const [recommendations, setRecommendations] = useState([]);
10696
- const [error2, setError] = useState();
10697
- const [loading, setLoading] = useState(!initialData);
10669
+ const [loaded, setLoaded] = useState(initialData ? {
10670
+ sku,
10671
+ product: initialData.product,
10672
+ inventory: initialData.inventory ?? null,
10673
+ recommendations: []
10674
+ } : null);
10675
+ const [failure, setFailure] = useState(null);
10676
+ const current2 = loaded?.sku === sku ? loaded : null;
10677
+ const error2 = failure?.sku === sku ? failure.code : void 0;
10698
10678
  useEffect(() => {
10699
10679
  let live = true;
10700
- setError(void 0);
10701
10680
  (async () => {
10702
10681
  try {
10703
10682
  const p = await api.catalog.getProduct(sku, market);
10704
10683
  if (!live) return;
10705
- setProduct(p);
10684
+ setLoaded({
10685
+ sku,
10686
+ product: p,
10687
+ inventory: null,
10688
+ recommendations: []
10689
+ });
10706
10690
  const hasVariants = (p.variants?.length ?? 0) > 0;
10707
10691
  const [inv, recs] = await Promise.allSettled([hasVariants ? Promise.resolve(null) : api.inventory.get(sku), showRecommendations ? api.catalog.getRecommendations(sku, market) : Promise.resolve({
10708
10692
  data: []
10709
10693
  })]);
10710
10694
  if (!live) return;
10711
- setInventory(inv.status === "fulfilled" ? inv.value : null);
10712
- setRecommendations(recs.status === "fulfilled" ? recs.value.data : []);
10695
+ setLoaded({
10696
+ sku,
10697
+ product: p,
10698
+ inventory: inv.status === "fulfilled" ? inv.value : null,
10699
+ recommendations: recs.status === "fulfilled" ? recs.value.data : []
10700
+ });
10713
10701
  } catch (err) {
10714
10702
  if (!live) return;
10715
10703
  const c = codeOf(err);
10716
- setError(c);
10704
+ setFailure({
10705
+ sku,
10706
+ code: c
10707
+ });
10717
10708
  emit({
10718
10709
  type: "error",
10719
10710
  code: c,
10720
10711
  scope: "product"
10721
10712
  });
10722
- } finally {
10723
- if (live) setLoading(false);
10724
10713
  }
10725
10714
  })();
10726
10715
  return () => {
@@ -10741,26 +10730,23 @@ function ProductView({ sku, initialData, showRecommendations = true, onNotFound
10741
10730
  });
10742
10731
  return unavailable;
10743
10732
  }
10744
- if (product) {
10733
+ if (current2) {
10745
10734
  return jsx(ProductDetail, {
10746
- product,
10747
- inventory: inventory2,
10748
- recommendations
10735
+ product: current2.product,
10736
+ inventory: current2.inventory,
10737
+ recommendations: current2.recommendations
10749
10738
  });
10750
10739
  }
10751
- if (loading) return jsx(ScreenSkeleton, {
10740
+ if (!error2) return jsx(ScreenSkeleton, {
10752
10741
  tone: "light"
10753
10742
  });
10754
- if (error2) {
10755
- return jsx(ShopSurface, {
10756
- tone: "light",
10757
- fill: true,
10758
- children: jsx(ErrorState, {
10759
- code: error2
10760
- })
10761
- });
10762
- }
10763
- return unavailable;
10743
+ return jsx(ShopSurface, {
10744
+ tone: "light",
10745
+ fill: true,
10746
+ children: jsx(ErrorState, {
10747
+ code: error2
10748
+ })
10749
+ });
10764
10750
  }
10765
10751
  const showcase = "_showcase_1qnt2_44";
10766
10752
  const panel = "_panel_1qnt2_48";
@@ -5689,7 +5689,6 @@ const ES = {
5689
5689
  "See all": "Ver todo",
5690
5690
  "See more": "Ver más",
5691
5691
  "Select an option": "Selecciona una opción",
5692
- Share: "Compartir",
5693
5692
  Shipping: "Envío",
5694
5693
  "Shipping address": "Dirección de envío",
5695
5694
  "Shipping and returns": "Envíos y devoluciones",
@@ -9299,22 +9298,20 @@ function CartSheetProvider({ children }) {
9299
9298
  })]
9300
9299
  });
9301
9300
  }
9302
- const gallery = "_gallery_9e68b_1";
9303
- const track$2 = "_track_9e68b_8";
9304
- const slide$1 = "_slide_9e68b_32";
9305
- const image$4 = "_image_9e68b_39";
9306
- const placeholder$1 = "_placeholder_9e68b_43";
9307
- const share = "_share_9e68b_50";
9308
- const dots$2 = "_dots_9e68b_83";
9309
- const dot$2 = "_dot_9e68b_83";
9310
- const dotActive$2 = "_dotActive_9e68b_134";
9301
+ const gallery = "_gallery_nv2a9_1";
9302
+ const track$2 = "_track_nv2a9_8";
9303
+ const slide$1 = "_slide_nv2a9_32";
9304
+ const image$4 = "_image_nv2a9_39";
9305
+ const placeholder$1 = "_placeholder_nv2a9_43";
9306
+ const dots$2 = "_dots_nv2a9_49";
9307
+ const dot$2 = "_dot_nv2a9_49";
9308
+ const dotActive$2 = "_dotActive_nv2a9_88";
9311
9309
  const styles$i = {
9312
9310
  gallery,
9313
9311
  track: track$2,
9314
9312
  slide: slide$1,
9315
9313
  image: image$4,
9316
9314
  placeholder: placeholder$1,
9317
- share,
9318
9315
  dots: dots$2,
9319
9316
  dot: dot$2,
9320
9317
  dotActive: dotActive$2
@@ -9357,37 +9354,9 @@ function MediaGallery({ media: media2, alt }) {
9357
9354
  "aria-hidden": "true"
9358
9355
  });
9359
9356
  }
9360
- function share2() {
9361
- if (typeof navigator !== "undefined" && navigator.share) {
9362
- void navigator.share({
9363
- title: alt,
9364
- url: window.location.href
9365
- }).catch(() => {
9366
- });
9367
- }
9368
- }
9369
9357
  return jsxs("div", {
9370
9358
  className: styles$i.gallery,
9371
- children: [jsx("button", {
9372
- type: "button",
9373
- className: styles$i.share,
9374
- onClick: share2,
9375
- "aria-label": t("Share"),
9376
- children: jsx("svg", {
9377
- width: "20",
9378
- height: "20",
9379
- viewBox: "0 0 24 24",
9380
- fill: "none",
9381
- "aria-hidden": "true",
9382
- children: jsx("path", {
9383
- d: "M12 3v12M12 3 8 7m4-4 4 4M5 12v6a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6",
9384
- stroke: "currentColor",
9385
- strokeWidth: "1.6",
9386
- strokeLinecap: "round",
9387
- strokeLinejoin: "round"
9388
- })
9389
- })
9390
- }), jsx("div", {
9359
+ children: [jsx("div", {
9391
9360
  className: styles$i.track,
9392
9361
  ref: trackRef,
9393
9362
  role: "group",
@@ -10068,7 +10037,14 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
10068
10037
  const colourSoldOut = hasColours && selectedColour ? !colours.find((c) => c.value === selectedColour)?.available : false;
10069
10038
  const purchasable = anyInStock && !colourSoldOut;
10070
10039
  const colourImage = useMemo(() => selectedColour ? baseColours.find((c) => c.value === selectedColour)?.image : void 0, [baseColours, selectedColour]);
10071
- const media2 = useMemo(() => colourImage ? [colourImage, ...product.media.filter((m) => m !== colourImage)] : product.media, [colourImage, product.media]);
10040
+ const shootColour = baseColours[0]?.value;
10041
+ const media2 = useMemo(() => {
10042
+ if (!colourImage) return product.media;
10043
+ if (selectedColour === shootColour) {
10044
+ return [colourImage, ...product.media.filter((m) => m !== colourImage)];
10045
+ }
10046
+ return [colourImage];
10047
+ }, [colourImage, product.media, selectedColour, shootColour]);
10072
10048
  function selectSize(value2) {
10073
10049
  setSelectedSize(value2);
10074
10050
  setSizeError(false);
@@ -10690,37 +10666,50 @@ function CategoryView({ code, initialData, onNotFound }) {
10690
10666
  function ProductView({ sku, initialData, showRecommendations = true, onNotFound }) {
10691
10667
  const t = useT();
10692
10668
  const { api, market, emit } = useShop();
10693
- const [product, setProduct] = useState(initialData?.product ?? null);
10694
- const [inventory2, setInventory] = useState(initialData?.inventory ?? null);
10695
- const [recommendations, setRecommendations] = useState([]);
10696
- const [error2, setError] = useState();
10697
- const [loading, setLoading] = useState(!initialData);
10669
+ const [loaded, setLoaded] = useState(initialData ? {
10670
+ sku,
10671
+ product: initialData.product,
10672
+ inventory: initialData.inventory ?? null,
10673
+ recommendations: []
10674
+ } : null);
10675
+ const [failure, setFailure] = useState(null);
10676
+ const current2 = loaded?.sku === sku ? loaded : null;
10677
+ const error2 = failure?.sku === sku ? failure.code : void 0;
10698
10678
  useEffect(() => {
10699
10679
  let live = true;
10700
- setError(void 0);
10701
10680
  (async () => {
10702
10681
  try {
10703
10682
  const p = await api.catalog.getProduct(sku, market);
10704
10683
  if (!live) return;
10705
- setProduct(p);
10684
+ setLoaded({
10685
+ sku,
10686
+ product: p,
10687
+ inventory: null,
10688
+ recommendations: []
10689
+ });
10706
10690
  const hasVariants = (p.variants?.length ?? 0) > 0;
10707
10691
  const [inv, recs] = await Promise.allSettled([hasVariants ? Promise.resolve(null) : api.inventory.get(sku), showRecommendations ? api.catalog.getRecommendations(sku, market) : Promise.resolve({
10708
10692
  data: []
10709
10693
  })]);
10710
10694
  if (!live) return;
10711
- setInventory(inv.status === "fulfilled" ? inv.value : null);
10712
- setRecommendations(recs.status === "fulfilled" ? recs.value.data : []);
10695
+ setLoaded({
10696
+ sku,
10697
+ product: p,
10698
+ inventory: inv.status === "fulfilled" ? inv.value : null,
10699
+ recommendations: recs.status === "fulfilled" ? recs.value.data : []
10700
+ });
10713
10701
  } catch (err) {
10714
10702
  if (!live) return;
10715
10703
  const c = codeOf(err);
10716
- setError(c);
10704
+ setFailure({
10705
+ sku,
10706
+ code: c
10707
+ });
10717
10708
  emit({
10718
10709
  type: "error",
10719
10710
  code: c,
10720
10711
  scope: "product"
10721
10712
  });
10722
- } finally {
10723
- if (live) setLoading(false);
10724
10713
  }
10725
10714
  })();
10726
10715
  return () => {
@@ -10741,26 +10730,23 @@ function ProductView({ sku, initialData, showRecommendations = true, onNotFound
10741
10730
  });
10742
10731
  return unavailable;
10743
10732
  }
10744
- if (product) {
10733
+ if (current2) {
10745
10734
  return jsx(ProductDetail, {
10746
- product,
10747
- inventory: inventory2,
10748
- recommendations
10735
+ product: current2.product,
10736
+ inventory: current2.inventory,
10737
+ recommendations: current2.recommendations
10749
10738
  });
10750
10739
  }
10751
- if (loading) return jsx(ScreenSkeleton, {
10740
+ if (!error2) return jsx(ScreenSkeleton, {
10752
10741
  tone: "light"
10753
10742
  });
10754
- if (error2) {
10755
- return jsx(ShopSurface, {
10756
- tone: "light",
10757
- fill: true,
10758
- children: jsx(ErrorState, {
10759
- code: error2
10760
- })
10761
- });
10762
- }
10763
- return unavailable;
10743
+ return jsx(ShopSurface, {
10744
+ tone: "light",
10745
+ fill: true,
10746
+ children: jsx(ErrorState, {
10747
+ code: error2
10748
+ })
10749
+ });
10764
10750
  }
10765
10751
  const showcase = "_showcase_1qnt2_44";
10766
10752
  const panel = "_panel_1qnt2_48";
@@ -2429,13 +2429,13 @@
2429
2429
  flex-direction: column;
2430
2430
  gap: var(--space-20);
2431
2431
  }
2432
- ._gallery_9e68b_1 {
2432
+ ._gallery_nv2a9_1 {
2433
2433
  position: relative;
2434
2434
  display: flex;
2435
2435
  flex-direction: column;
2436
2436
  gap: var(--space-12);
2437
2437
  }
2438
- ._track_9e68b_8 {
2438
+ ._track_nv2a9_8 {
2439
2439
  display: flex;
2440
2440
  overflow-x: auto;
2441
2441
  scroll-snap-type: x mandatory;
@@ -2444,51 +2444,29 @@
2444
2444
  background: var(--color-surface-soft);
2445
2445
  scrollbar-width: none;
2446
2446
  }
2447
- ._track_9e68b_8::-webkit-scrollbar {
2447
+ ._track_nv2a9_8::-webkit-scrollbar {
2448
2448
  display: none;
2449
2449
  }
2450
- ._slide_9e68b_32 {
2450
+ ._slide_nv2a9_32 {
2451
2451
  position: relative;
2452
2452
  flex: 0 0 100%;
2453
2453
  scroll-snap-align: center;
2454
2454
  aspect-ratio: 375 / 475;
2455
2455
  }
2456
- ._image_9e68b_39 {
2456
+ ._image_nv2a9_39 {
2457
2457
  object-fit: cover;
2458
2458
  }
2459
- ._placeholder_9e68b_43 {
2459
+ ._placeholder_nv2a9_43 {
2460
2460
  width: 100%;
2461
2461
  aspect-ratio: 375 / 475;
2462
2462
  background: var(--color-surface-soft);
2463
2463
  }
2464
- ._share_9e68b_50 {
2465
- position: absolute;
2466
- z-index: 1;
2467
- top: var(--space-16);
2468
- right: var(--space-16);
2469
- display: inline-flex;
2470
- align-items: center;
2471
- justify-content: center;
2472
- width: 32px;
2473
- height: 32px;
2474
- padding: 0;
2475
- border: none;
2476
- border-radius: var(--radius-8);
2477
- background: var(--color-surface-soft);
2478
- color: var(--color-text-default);
2479
- cursor: pointer;
2480
- }
2481
- ._dots_9e68b_83 {
2464
+ ._dots_nv2a9_49 {
2482
2465
  display: flex;
2483
2466
  justify-content: center;
2484
2467
  gap: var(--space-6);
2485
2468
  }
2486
- ._share_9e68b_50::after {
2487
- content: "";
2488
- position: absolute;
2489
- inset: -6px;
2490
- }
2491
- ._dot_9e68b_83 {
2469
+ ._dot_nv2a9_49 {
2492
2470
  width: 8px;
2493
2471
  height: 8px;
2494
2472
  padding: 0;
@@ -2498,12 +2476,12 @@
2498
2476
  cursor: pointer;
2499
2477
  position: relative;
2500
2478
  }
2501
- ._dot_9e68b_83::after {
2479
+ ._dot_nv2a9_49::after {
2502
2480
  content: "";
2503
2481
  position: absolute;
2504
2482
  inset: -18px -3px;
2505
2483
  }
2506
- ._dotActive_9e68b_134 {
2484
+ ._dotActive_nv2a9_88 {
2507
2485
  background: var(--color-surface-max);
2508
2486
  }
2509
2487
  ._scrim_ddqa4_8 {
package/dist/styles.css CHANGED
@@ -2429,13 +2429,13 @@
2429
2429
  flex-direction: column;
2430
2430
  gap: var(--space-20);
2431
2431
  }
2432
- ._gallery_9e68b_1 {
2432
+ ._gallery_nv2a9_1 {
2433
2433
  position: relative;
2434
2434
  display: flex;
2435
2435
  flex-direction: column;
2436
2436
  gap: var(--space-12);
2437
2437
  }
2438
- ._track_9e68b_8 {
2438
+ ._track_nv2a9_8 {
2439
2439
  display: flex;
2440
2440
  overflow-x: auto;
2441
2441
  scroll-snap-type: x mandatory;
@@ -2444,51 +2444,29 @@
2444
2444
  background: var(--color-surface-soft);
2445
2445
  scrollbar-width: none;
2446
2446
  }
2447
- ._track_9e68b_8::-webkit-scrollbar {
2447
+ ._track_nv2a9_8::-webkit-scrollbar {
2448
2448
  display: none;
2449
2449
  }
2450
- ._slide_9e68b_32 {
2450
+ ._slide_nv2a9_32 {
2451
2451
  position: relative;
2452
2452
  flex: 0 0 100%;
2453
2453
  scroll-snap-align: center;
2454
2454
  aspect-ratio: 375 / 475;
2455
2455
  }
2456
- ._image_9e68b_39 {
2456
+ ._image_nv2a9_39 {
2457
2457
  object-fit: cover;
2458
2458
  }
2459
- ._placeholder_9e68b_43 {
2459
+ ._placeholder_nv2a9_43 {
2460
2460
  width: 100%;
2461
2461
  aspect-ratio: 375 / 475;
2462
2462
  background: var(--color-surface-soft);
2463
2463
  }
2464
- ._share_9e68b_50 {
2465
- position: absolute;
2466
- z-index: 1;
2467
- top: var(--space-16);
2468
- right: var(--space-16);
2469
- display: inline-flex;
2470
- align-items: center;
2471
- justify-content: center;
2472
- width: 32px;
2473
- height: 32px;
2474
- padding: 0;
2475
- border: none;
2476
- border-radius: var(--radius-8);
2477
- background: var(--color-surface-soft);
2478
- color: var(--color-text-default);
2479
- cursor: pointer;
2480
- }
2481
- ._dots_9e68b_83 {
2464
+ ._dots_nv2a9_49 {
2482
2465
  display: flex;
2483
2466
  justify-content: center;
2484
2467
  gap: var(--space-6);
2485
2468
  }
2486
- ._share_9e68b_50::after {
2487
- content: "";
2488
- position: absolute;
2489
- inset: -6px;
2490
- }
2491
- ._dot_9e68b_83 {
2469
+ ._dot_nv2a9_49 {
2492
2470
  width: 8px;
2493
2471
  height: 8px;
2494
2472
  padding: 0;
@@ -2498,12 +2476,12 @@
2498
2476
  cursor: pointer;
2499
2477
  position: relative;
2500
2478
  }
2501
- ._dot_9e68b_83::after {
2479
+ ._dot_nv2a9_49::after {
2502
2480
  content: "";
2503
2481
  position: absolute;
2504
2482
  inset: -18px -3px;
2505
2483
  }
2506
- ._dotActive_9e68b_134 {
2484
+ ._dotActive_nv2a9_88 {
2507
2485
  background: var(--color-surface-max);
2508
2486
  }
2509
2487
  ._scrim_ddqa4_8 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nok-integration/storefront-react",
3
- "version": "0.19.24",
3
+ "version": "0.19.26",
4
4
  "description": "Mountable React storefront components: catalogue, product detail and cart, mounted directly into a host DOM tree. No iframe.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {