@snowcone-app/ui 0.10.16 → 0.10.18

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.d.cts CHANGED
@@ -5,7 +5,7 @@ import * as React$1 from 'react';
5
5
  import React__default, { ReactNode, CSSProperties, RefObject } from 'react';
6
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
7
7
  import { VariantProps } from 'class-variance-authority';
8
- import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, ProductArtAlignmentOptions, ProductArtAlignmentContext, ArtworkData } from '@snowcone-app/sdk';
8
+ import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, ProductArtAlignmentOptions, ProductArtAlignmentContext, MockupView, ArtworkData } from '@snowcone-app/sdk';
9
9
  export { ArtworkData, AspectRatio, ImageAlignment, ProductArtAlignmentContext, ProductArtAlignmentOptions, ProductData, ProductMockupData, ProductPlacement, ProductVariant, WebSocketConfig, describeProductArtAlignment, getMockupUrl, getProduct, getSnapPoints, listProducts } from '@snowcone-app/sdk';
10
10
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
11
11
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
@@ -4448,6 +4448,15 @@ interface HeroProductImageProps {
4448
4448
  * phone, where cover would cut a 16:9 frame to its centre). Stamped as data-fit.
4449
4449
  */
4450
4450
  fit?: "cover" | "whole";
4451
+ /**
4452
+ * Ask for a crop of the mockup's 8:3 strip (`aspect=8:3&view=<r>@<f>`, no width: the crop comes at its own px), or
4453
+ * `"whole-strip"` (`aspect=8:3` at the measured width: a window wider than the crop grid), instead of a width-sized
4454
+ * 16:9 picture: the desktop hero of a mockup whose catalog entry carries `strip` (www heroStrip.ts). Only the static
4455
+ * picture follows it; realtime frames (an edit) stay the session's 16:9. Stamped as data-strip-view.
4456
+ */
4457
+ stripView?: MockupView | "whole-strip";
4458
+ /** Called with the URL of each picture once it is ON SCREEN (its <img> loaded), not when it is asked for. */
4459
+ onShown?: (url: string) => void;
4451
4460
  }
4452
4461
  /**
4453
4462
  * Hero-compatible version of ProductImage that renders as a simple img element
@@ -4773,6 +4782,14 @@ interface CarouselImage {
4773
4782
  * Stamped data-gallery-role on the slide.
4774
4783
  */
4775
4784
  galleryRole?: "size-picture";
4785
+ /**
4786
+ * A plate's 8:3 strip (the catalog's `mockups[].strip`): the desktop hero asks for the crop its window shows
4787
+ * (`aspect=8:3&view=<r>@<f>`). Absent = the 16:9 hero. Phones ignore it.
4788
+ */
4789
+ strip?: {
4790
+ shape: "8:3";
4791
+ productX: number;
4792
+ };
4776
4793
  }
4777
4794
  /**
4778
4795
  * Alias for CarouselImage - used in hero contexts for semantic clarity.
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import * as React$1 from 'react';
5
5
  import React__default, { ReactNode, CSSProperties, RefObject } from 'react';
6
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
7
7
  import { VariantProps } from 'class-variance-authority';
8
- import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, ProductArtAlignmentOptions, ProductArtAlignmentContext, ArtworkData } from '@snowcone-app/sdk';
8
+ import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, ProductArtAlignmentOptions, ProductArtAlignmentContext, MockupView, ArtworkData } from '@snowcone-app/sdk';
9
9
  export { ArtworkData, AspectRatio, ImageAlignment, ProductArtAlignmentContext, ProductArtAlignmentOptions, ProductData, ProductMockupData, ProductPlacement, ProductVariant, WebSocketConfig, describeProductArtAlignment, getMockupUrl, getProduct, getSnapPoints, listProducts } from '@snowcone-app/sdk';
10
10
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
11
11
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
@@ -4448,6 +4448,15 @@ interface HeroProductImageProps {
4448
4448
  * phone, where cover would cut a 16:9 frame to its centre). Stamped as data-fit.
4449
4449
  */
4450
4450
  fit?: "cover" | "whole";
4451
+ /**
4452
+ * Ask for a crop of the mockup's 8:3 strip (`aspect=8:3&view=<r>@<f>`, no width: the crop comes at its own px), or
4453
+ * `"whole-strip"` (`aspect=8:3` at the measured width: a window wider than the crop grid), instead of a width-sized
4454
+ * 16:9 picture: the desktop hero of a mockup whose catalog entry carries `strip` (www heroStrip.ts). Only the static
4455
+ * picture follows it; realtime frames (an edit) stay the session's 16:9. Stamped as data-strip-view.
4456
+ */
4457
+ stripView?: MockupView | "whole-strip";
4458
+ /** Called with the URL of each picture once it is ON SCREEN (its <img> loaded), not when it is asked for. */
4459
+ onShown?: (url: string) => void;
4451
4460
  }
4452
4461
  /**
4453
4462
  * Hero-compatible version of ProductImage that renders as a simple img element
@@ -4773,6 +4782,14 @@ interface CarouselImage {
4773
4782
  * Stamped data-gallery-role on the slide.
4774
4783
  */
4775
4784
  galleryRole?: "size-picture";
4785
+ /**
4786
+ * A plate's 8:3 strip (the catalog's `mockups[].strip`): the desktop hero asks for the crop its window shows
4787
+ * (`aspect=8:3&view=<r>@<f>`). Absent = the 16:9 hero. Phones ignore it.
4788
+ */
4789
+ strip?: {
4790
+ shape: "8:3";
4791
+ productX: number;
4792
+ };
4776
4793
  }
4777
4794
  /**
4778
4795
  * Alias for CarouselImage - used in hero contexts for semantic clarity.
package/dist/index.js CHANGED
@@ -10541,13 +10541,20 @@ function buildHeroMockupUrl(args) {
10541
10541
  return getMockupUrl(args.productCode, {
10542
10542
  shop: snow.shop,
10543
10543
  design: publicDesign,
10544
- width: args.width,
10544
+ ..."stripView" in args.size ? { aspect: "8:3", stripView: args.size.stripView } : { width: args.size.width, ...args.size.aspect ? { aspect: args.size.aspect } : {} },
10545
10545
  view: args.mockupId,
10546
10546
  variant: args.variantId,
10547
10547
  ...args.bg ? { bg: args.bg } : {},
10548
10548
  ...snow.resolver ? { base: snow.resolver } : {}
10549
10549
  });
10550
10550
  }
10551
+ function isCrop(stripView) {
10552
+ return stripView !== void 0 && stripView !== "whole-strip";
10553
+ }
10554
+ function heroSize(stripView, width) {
10555
+ if (isCrop(stripView)) return { stripView };
10556
+ return stripView === "whole-strip" ? { width, aspect: "8:3" } : { width };
10557
+ }
10551
10558
  var EMPTY_IMAGES = [];
10552
10559
  var HeroProductImage = memo3(function HeroProductImage2({
10553
10560
  productId,
@@ -10580,7 +10587,9 @@ var HeroProductImage = memo3(function HeroProductImage2({
10580
10587
  errorText = "Error loading",
10581
10588
  unavailableText = "Preview unavailable",
10582
10589
  viewportPolicy = false,
10583
- fit = "cover"
10590
+ fit = "cover",
10591
+ stripView,
10592
+ onShown
10584
10593
  }) {
10585
10594
  const context = useProductOptional();
10586
10595
  const designContext = useDesignOptional();
@@ -10617,7 +10626,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
10617
10626
  }
10618
10627
  if (context?.loading) return null;
10619
10628
  if (!effectiveArtworkSrc || effectiveArtworkSrc.trim() === "") return null;
10620
- if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !width) return null;
10629
+ if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !(isCrop(stripView) || width)) return null;
10621
10630
  const allPlacements = product?.placements || context?.product?.placements || [];
10622
10631
  if (allPlacements.length === 0) return null;
10623
10632
  const placementDesigns = {};
@@ -10642,10 +10651,11 @@ var HeroProductImage = memo3(function HeroProductImage2({
10642
10651
  placements: allPlacements,
10643
10652
  mockupId: actualMockupId,
10644
10653
  variantId: actualGvid,
10645
- width,
10654
+ size: heroSize(stripView, width),
10646
10655
  bg: mockupBg
10647
10656
  });
10648
10657
  }, [
10658
+ stripView,
10649
10659
  realtimeUrl,
10650
10660
  mode,
10651
10661
  context?.loading,
@@ -10696,6 +10706,8 @@ var HeroProductImage = memo3(function HeroProductImage2({
10696
10706
  const isPendingExportRef = useRef23(false);
10697
10707
  const onUrlGeneratedRef = useRef23(onUrlGenerated);
10698
10708
  onUrlGeneratedRef.current = onUrlGenerated;
10709
+ const onShownRef = useRef23(onShown);
10710
+ onShownRef.current = onShown;
10699
10711
  const layersLengthRef = useRef23(layers.length);
10700
10712
  layersLengthRef.current = layers.length;
10701
10713
  useEffect32(() => {
@@ -11004,7 +11016,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
11004
11016
  setTargetUrl(null);
11005
11017
  return;
11006
11018
  }
11007
- if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !width) {
11019
+ if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !(isCrop(stripView) || width)) {
11008
11020
  return;
11009
11021
  }
11010
11022
  const allPlacements = product?.placements || context?.product?.placements || [];
@@ -11018,7 +11030,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
11018
11030
  placements: allPlacements,
11019
11031
  mockupId: actualMockupId,
11020
11032
  variantId: actualGvid,
11021
- width,
11033
+ size: heroSize(stripView, width),
11022
11034
  bg: mockupBg
11023
11035
  });
11024
11036
  if (!url) return;
@@ -11063,6 +11075,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
11063
11075
  mockupBg,
11064
11076
  images,
11065
11077
  width,
11078
+ stripView,
11066
11079
  effects,
11067
11080
  // Use primitive values extracted at the top of the component
11068
11081
  artworkSrc,
@@ -11197,6 +11210,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
11197
11210
  "data-hero-image": "true",
11198
11211
  "data-mockup-id": actualMockupId || void 0,
11199
11212
  "data-fit": fit,
11213
+ "data-strip-view": stripView,
11200
11214
  "data-picture-failed": imgFailed ? "E_PICTURE_UNDISPLAYED" : void 0,
11201
11215
  "data-picture-failed-src": failedSrc,
11202
11216
  "data-mockup-unavailable": unavailable ? unavailable.code : void 0,
@@ -11235,6 +11249,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
11235
11249
  onLoad();
11236
11250
  }
11237
11251
  onUrlGeneratedRef.current?.(renderedUrl);
11252
+ if (renderedUrl) onShownRef.current?.(renderedUrl);
11238
11253
  },
11239
11254
  onError: () => {
11240
11255
  if (renderedUrl && retriedUrlRef.current !== renderedUrl) {