@snowcone-app/ui 0.9.0 → 0.9.2
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 +18 -0
- package/README.md +1 -1
- package/dist/index.cjs +8 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/composed/ArtworkCustomizer.tsx +2 -2
- package/src/composed/ColorPicker.tsx +1 -1
- package/src/composed/CurrentSelectionDisplay.tsx +1 -1
- package/src/composed/HeroProductImage.tsx +9 -3
- package/src/composed/ProductGallery.tsx +1 -1
- package/src/hooks/useProductGallery.ts +1 -1
- package/src/patterns/RealtimeProvider.tsx +3 -4
- package/src/patterns/__tests__/RealtimeProvider.cropDelivery.test.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowcone-app/ui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "React components for merchandise visualization and customization",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"react-instantsearch": "^7.15.5",
|
|
104
104
|
"react-zoom-pan-pinch": "^3.6.4",
|
|
105
105
|
"tailwind-merge": "^3.0.0",
|
|
106
|
-
"@snowcone-app/sdk": "0.24.
|
|
106
|
+
"@snowcone-app/sdk": "0.24.4"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@chromatic-com/storybook": "^4.1.2",
|
|
@@ -65,7 +65,7 @@ export type ArtworkCustomizerProps = {
|
|
|
65
65
|
* // CORRECT: Use with ArtSelector to manage artwork via context
|
|
66
66
|
* import { Product, ArtSelector, ArtworkCustomizer } from '@snowcone-app/ui';
|
|
67
67
|
*
|
|
68
|
-
* <Product productId="
|
|
68
|
+
* <Product productId="BC43BE">
|
|
69
69
|
* <ArtSelector artworks={[
|
|
70
70
|
* { type: 'regular', src: 'https://example.com/photo.jpg' },
|
|
71
71
|
* { type: 'pattern', src: 'https://example.com/pattern.jpg', tileCount: 1 }
|
|
@@ -79,7 +79,7 @@ export type ArtworkCustomizerProps = {
|
|
|
79
79
|
* // CORRECT: Full example with ProductImage
|
|
80
80
|
* import { Product, ProductImage, ArtSelector, ArtworkCustomizer } from '@snowcone-app/ui';
|
|
81
81
|
*
|
|
82
|
-
* <Product productId="
|
|
82
|
+
* <Product productId="BC43BE">
|
|
83
83
|
* <div className="grid grid-cols-2 gap-8">
|
|
84
84
|
* <ProductImage />
|
|
85
85
|
* <div>
|
|
@@ -36,7 +36,7 @@ export interface CurrentSelectionDisplayProps {
|
|
|
36
36
|
* ```tsx
|
|
37
37
|
* import { Product, ProductOptions, CurrentSelectionDisplay } from '@yourorg/ui-react';
|
|
38
38
|
*
|
|
39
|
-
* <Product productId="
|
|
39
|
+
* <Product productId="BC43BE">
|
|
40
40
|
* <ProductOptions />
|
|
41
41
|
* <CurrentSelectionDisplay />
|
|
42
42
|
* </Product>
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
getMockupUrl,
|
|
25
25
|
type Design,
|
|
26
26
|
resolveVariantId,
|
|
27
|
+
resolvePreviewVariantId,
|
|
27
28
|
resolveMockupId,
|
|
28
29
|
} from "@snowcone-app/sdk";
|
|
29
30
|
|
|
@@ -232,13 +233,18 @@ export const HeroProductImage = memo(function HeroProductImage({
|
|
|
232
233
|
const actualProductId = product?.id || productId || context?.product?.id;
|
|
233
234
|
|
|
234
235
|
// Resolve variant and mockup IDs - MOVED UP for initial URL computation
|
|
235
|
-
const
|
|
236
|
+
const selectedGvid = useMemo(() => {
|
|
236
237
|
return resolveVariantId(context, gvid, variantId);
|
|
237
238
|
}, [gvid, variantId, context?.selection, context?.combinations]);
|
|
238
239
|
|
|
239
240
|
const actualMockupId = useMemo(() => {
|
|
240
|
-
return resolveMockupId(context,
|
|
241
|
-
}, [mockupId,
|
|
241
|
+
return resolveMockupId(context, selectedGvid, mockupId);
|
|
242
|
+
}, [mockupId, selectedGvid, context]);
|
|
243
|
+
|
|
244
|
+
// What this image renders: a selected size with no scene previews a listed one. A variant the caller named is theirs.
|
|
245
|
+
const actualGvid = useMemo(() => {
|
|
246
|
+
return gvid || variantId ? selectedGvid : resolvePreviewVariantId(context, selectedGvid, actualMockupId);
|
|
247
|
+
}, [gvid, variantId, selectedGvid, actualMockupId, context]);
|
|
242
248
|
|
|
243
249
|
// The server refused THIS mockup for the session (its scene failed render
|
|
244
250
|
// parity — E_MOCKUP_NOT_BLESSED). Shown as unavailable on top of whatever
|
|
@@ -23,7 +23,7 @@ export interface ProductGalleryProps extends UseProductGalleryOptions {
|
|
|
23
23
|
* 2. List all products: Pass empty array or omit productIds
|
|
24
24
|
*
|
|
25
25
|
* @example Specific products
|
|
26
|
-
* <ProductGallery productIds={["
|
|
26
|
+
* <ProductGallery productIds={["BC43BE", "CAXHQC", "XTNA6J"]}>
|
|
27
27
|
* {(products, loading, error) => (
|
|
28
28
|
* <div className="grid grid-cols-3 gap-4">
|
|
29
29
|
* {products.map(product => (
|
|
@@ -49,7 +49,7 @@ export interface UseProductGalleryReturn {
|
|
|
49
49
|
* ```tsx
|
|
50
50
|
* // Fetch specific products
|
|
51
51
|
* const { products, loading, error, refetch } = useProductGallery(
|
|
52
|
-
* ['
|
|
52
|
+
* ['BC43BE', 'CAXHQC'],
|
|
53
53
|
* { endpoint: 'http://localhost:3000', mode: 'mock' }
|
|
54
54
|
* );
|
|
55
55
|
*
|
|
@@ -37,7 +37,7 @@ import React, {
|
|
|
37
37
|
useMemo,
|
|
38
38
|
} from "react";
|
|
39
39
|
import { useRealtimeMockup } from "@snowcone-app/sdk/react";
|
|
40
|
-
import { resolveVariantId as resolveVariantIdUtil } from "@snowcone-app/sdk";
|
|
40
|
+
import { resolvePreviewVariantId, resolveVariantId as resolveVariantIdUtil } from "@snowcone-app/sdk";
|
|
41
41
|
import type {
|
|
42
42
|
RealtimeRenderError,
|
|
43
43
|
MockupResult as SdkMockupResult,
|
|
@@ -987,10 +987,9 @@ export function RealtimeProvider({
|
|
|
987
987
|
const placements = product.placements || [];
|
|
988
988
|
|
|
989
989
|
// Resolve variant ID based on current selection
|
|
990
|
-
const variantId =
|
|
990
|
+
const variantId = resolvePreviewVariantId(
|
|
991
991
|
productContext,
|
|
992
|
-
undefined,
|
|
993
|
-
undefined
|
|
992
|
+
resolveVariantIdUtil(productContext, undefined, undefined)
|
|
994
993
|
);
|
|
995
994
|
|
|
996
995
|
// Check if we need to send config:
|