@snowcone-app/ui 0.10.5 → 0.10.8
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 +19 -0
- package/dist/index.cjs +14 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/composed/HeroProductImage.tsx +11 -2
- package/src/composed/__tests__/HeroProductImage.fit.test.tsx +30 -0
- package/src/composed/carousels/MobileProductCarousel.tsx +4 -0
- package/src/composed/zoom/EnhancedImageViewer.tsx +2 -1
- package/src/composed/zoom/types.ts +2 -0
- package/src/patterns/RealtimeProvider.tsx +7 -0
- package/src/patterns/__tests__/RealtimeProvider.shapeCrop.test.tsx +94 -0
package/dist/index.d.cts
CHANGED
|
@@ -4442,6 +4442,12 @@ interface HeroProductImageProps {
|
|
|
4442
4442
|
* today's behaviour.
|
|
4443
4443
|
*/
|
|
4444
4444
|
viewportPolicy?: boolean;
|
|
4445
|
+
/**
|
|
4446
|
+
* How the picture fills its box. `cover` (default): fills it, cropping what doesn't fit (a hero). `whole`: the
|
|
4447
|
+
* entire picture, letterboxed, nothing cropped: for a diagram with a caption (the gallery's size picture on a
|
|
4448
|
+
* phone, where cover would cut a 16:9 frame to its centre). Stamped as data-fit.
|
|
4449
|
+
*/
|
|
4450
|
+
fit?: "cover" | "whole";
|
|
4445
4451
|
}
|
|
4446
4452
|
/**
|
|
4447
4453
|
* Hero-compatible version of ProductImage that renders as a simple img element
|
|
@@ -4672,6 +4678,8 @@ interface ZoomImage {
|
|
|
4672
4678
|
isRealMockup?: boolean;
|
|
4673
4679
|
placement?: string;
|
|
4674
4680
|
mockupId?: string;
|
|
4681
|
+
/** `whole`: open the picture whole (contain), not cropped to the screen: the gallery's size picture (a diagram). */
|
|
4682
|
+
fit?: "cover" | "whole";
|
|
4675
4683
|
}
|
|
4676
4684
|
|
|
4677
4685
|
interface ResponsiveZoomProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -4442,6 +4442,12 @@ interface HeroProductImageProps {
|
|
|
4442
4442
|
* today's behaviour.
|
|
4443
4443
|
*/
|
|
4444
4444
|
viewportPolicy?: boolean;
|
|
4445
|
+
/**
|
|
4446
|
+
* How the picture fills its box. `cover` (default): fills it, cropping what doesn't fit (a hero). `whole`: the
|
|
4447
|
+
* entire picture, letterboxed, nothing cropped: for a diagram with a caption (the gallery's size picture on a
|
|
4448
|
+
* phone, where cover would cut a 16:9 frame to its centre). Stamped as data-fit.
|
|
4449
|
+
*/
|
|
4450
|
+
fit?: "cover" | "whole";
|
|
4445
4451
|
}
|
|
4446
4452
|
/**
|
|
4447
4453
|
* Hero-compatible version of ProductImage that renders as a simple img element
|
|
@@ -4672,6 +4678,8 @@ interface ZoomImage {
|
|
|
4672
4678
|
isRealMockup?: boolean;
|
|
4673
4679
|
placement?: string;
|
|
4674
4680
|
mockupId?: string;
|
|
4681
|
+
/** `whole`: open the picture whole (contain), not cropped to the screen: the gallery's size picture (a diagram). */
|
|
4682
|
+
fit?: "cover" | "whole";
|
|
4675
4683
|
}
|
|
4676
4684
|
|
|
4677
4685
|
interface ResponsiveZoomProps {
|
package/dist/index.js
CHANGED
|
@@ -6141,6 +6141,9 @@ function RealtimeProvider({
|
|
|
6141
6141
|
return;
|
|
6142
6142
|
}
|
|
6143
6143
|
if (lastShapeRef.current && lastShapeRef.current.width !== shape.width) invalidateBackgrounds();
|
|
6144
|
+
if (croppedActiveRef.current && shape.mockupIds.some((id) => !backgroundsRef.current.has(id))) {
|
|
6145
|
+
croppedActiveRef.current = false;
|
|
6146
|
+
}
|
|
6144
6147
|
lastShapeRef.current = shape;
|
|
6145
6148
|
base.mockupIds = shape.mockupIds;
|
|
6146
6149
|
base.width = shape.width;
|
|
@@ -10574,7 +10577,8 @@ var HeroProductImage = memo3(function HeroProductImage2({
|
|
|
10574
10577
|
emptyText = "No artwork",
|
|
10575
10578
|
errorText = "Error loading",
|
|
10576
10579
|
unavailableText = "Preview unavailable",
|
|
10577
|
-
viewportPolicy = false
|
|
10580
|
+
viewportPolicy = false,
|
|
10581
|
+
fit = "cover"
|
|
10578
10582
|
}) {
|
|
10579
10583
|
const context = useProductOptional();
|
|
10580
10584
|
const designContext = useDesignOptional();
|
|
@@ -11180,6 +11184,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
|
|
|
11180
11184
|
className: `relative overflow-hidden ${className || ""}`,
|
|
11181
11185
|
style,
|
|
11182
11186
|
"data-hero-image": "true",
|
|
11187
|
+
"data-fit": fit,
|
|
11183
11188
|
"data-mockup-unavailable": unavailable ? unavailable.code : void 0,
|
|
11184
11189
|
children: [
|
|
11185
11190
|
unavailable && /* @__PURE__ */ jsx61(
|
|
@@ -11196,7 +11201,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
|
|
|
11196
11201
|
{
|
|
11197
11202
|
alt: `Product mockup${placement ? ` - ${placement}` : ""}`,
|
|
11198
11203
|
crossOrigin: "anonymous",
|
|
11199
|
-
className:
|
|
11204
|
+
className: `absolute inset-0 w-full h-full ${fit === "whole" ? "object-contain" : "object-cover"}`,
|
|
11200
11205
|
draggable,
|
|
11201
11206
|
src: renderedUrl,
|
|
11202
11207
|
loading: "eager",
|
|
@@ -11254,7 +11259,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
|
|
|
11254
11259
|
{
|
|
11255
11260
|
alt: "",
|
|
11256
11261
|
crossOrigin: "anonymous",
|
|
11257
|
-
className:
|
|
11262
|
+
className: `absolute inset-0 w-full h-full ${fit === "whole" ? "object-contain" : "object-cover"}`,
|
|
11258
11263
|
src: prevUrl,
|
|
11259
11264
|
style: {
|
|
11260
11265
|
opacity: showNew ? 0 : 1,
|
|
@@ -12464,8 +12469,8 @@ var EnhancedImageViewer = ({
|
|
|
12464
12469
|
style: {
|
|
12465
12470
|
width: "100%",
|
|
12466
12471
|
height: "100%",
|
|
12467
|
-
|
|
12468
|
-
|
|
12472
|
+
// Crop 16:9 to fill the screen (a hero), or the whole picture for a size picture (a diagram).
|
|
12473
|
+
objectFit: images[propCurrentIndex ?? -1]?.fit === "whole" ? "contain" : "cover"
|
|
12469
12474
|
}
|
|
12470
12475
|
},
|
|
12471
12476
|
`${imageUrl}-${propCurrentIndex}`
|
|
@@ -13309,7 +13314,8 @@ var MobileProductCarousel = memo4(function MobileProductCarousel2({
|
|
|
13309
13314
|
errorText,
|
|
13310
13315
|
unavailableText,
|
|
13311
13316
|
className: "w-full h-full object-cover cursor-pointer pointer-events-none",
|
|
13312
|
-
viewportPolicy: true
|
|
13317
|
+
viewportPolicy: true,
|
|
13318
|
+
fit: image.galleryRole === "size-picture" ? "whole" : "cover"
|
|
13313
13319
|
}
|
|
13314
13320
|
) : image.isRealMockup && !currentArtwork ? /* @__PURE__ */ jsx74(LoadingOverlayPrismCandyInline, { visible: true, variant: "light" }) : /* @__PURE__ */ jsx74(
|
|
13315
13321
|
StaticCarouselImage,
|
|
@@ -13393,7 +13399,8 @@ var MobileProductCarousel = memo4(function MobileProductCarousel2({
|
|
|
13393
13399
|
src,
|
|
13394
13400
|
alt: img.label,
|
|
13395
13401
|
naturalWidth: img.naturalWidth,
|
|
13396
|
-
naturalHeight: img.naturalHeight
|
|
13402
|
+
naturalHeight: img.naturalHeight,
|
|
13403
|
+
...img.galleryRole === "size-picture" ? { fit: "whole" } : {}
|
|
13397
13404
|
} : null;
|
|
13398
13405
|
}).filter((img) => img !== null);
|
|
13399
13406
|
return /* @__PURE__ */ jsx74(
|