@seekora-ai/ui-sdk-react 0.2.11 → 0.2.12
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/components/primitives/ActionButtons.d.ts +27 -0
- package/dist/components/primitives/ActionButtons.d.ts.map +1 -0
- package/dist/components/primitives/ActionButtons.js +78 -0
- package/dist/components/primitives/AnalyticsProvider.d.ts +22 -0
- package/dist/components/primitives/AnalyticsProvider.d.ts.map +1 -0
- package/dist/components/primitives/AnalyticsProvider.js +87 -0
- package/dist/components/primitives/BadgeList.d.ts +14 -0
- package/dist/components/primitives/BadgeList.d.ts.map +1 -0
- package/dist/components/primitives/BadgeList.js +45 -0
- package/dist/components/primitives/ImageDisplay.d.ts +10 -1
- package/dist/components/primitives/ImageDisplay.d.ts.map +1 -1
- package/dist/components/primitives/ImageDisplay.js +49 -9
- package/dist/components/primitives/ImageZoom.d.ts +33 -0
- package/dist/components/primitives/ImageZoom.d.ts.map +1 -0
- package/dist/components/primitives/ImageZoom.js +357 -0
- package/dist/components/primitives/PriceDisplay.d.ts +21 -0
- package/dist/components/primitives/PriceDisplay.d.ts.map +1 -0
- package/dist/components/primitives/PriceDisplay.js +44 -0
- package/dist/components/primitives/RatingDisplay.d.ts +43 -0
- package/dist/components/primitives/RatingDisplay.d.ts.map +1 -0
- package/dist/components/primitives/RatingDisplay.js +114 -0
- package/dist/components/primitives/VariantSelector.d.ts +30 -0
- package/dist/components/primitives/VariantSelector.d.ts.map +1 -0
- package/dist/components/primitives/VariantSelector.js +162 -0
- package/dist/components/primitives/VariantSwatches.d.ts +28 -0
- package/dist/components/primitives/VariantSwatches.d.ts.map +1 -0
- package/dist/components/primitives/VariantSwatches.js +173 -0
- package/dist/components/primitives/index.d.ts +9 -0
- package/dist/components/primitives/index.d.ts.map +1 -1
- package/dist/components/primitives/index.js +9 -0
- package/dist/components/primitives/withAnalytics.d.ts +24 -0
- package/dist/components/primitives/withAnalytics.d.ts.map +1 -0
- package/dist/components/primitives/withAnalytics.js +73 -0
- package/dist/components/product-page/ProductInfo.d.ts +25 -2
- package/dist/components/product-page/ProductInfo.d.ts.map +1 -1
- package/dist/components/product-page/ProductInfo.js +20 -5
- package/dist/components/suggestions/types.d.ts +24 -0
- package/dist/components/suggestions/types.d.ts.map +1 -1
- package/dist/components/suggestions/utils.d.ts +37 -0
- package/dist/components/suggestions/utils.d.ts.map +1 -1
- package/dist/components/suggestions/utils.js +118 -0
- package/dist/components/suggestions-primitives/ItemCard.d.ts +10 -1
- package/dist/components/suggestions-primitives/ItemCard.d.ts.map +1 -1
- package/dist/components/suggestions-primitives/ItemCard.js +20 -6
- package/dist/components/suggestions-primitives/ProductCard.d.ts +27 -3
- package/dist/components/suggestions-primitives/ProductCard.d.ts.map +1 -1
- package/dist/components/suggestions-primitives/ProductCard.js +124 -17
- package/dist/components/suggestions-primitives/ProductCardLayouts.d.ts +44 -0
- package/dist/components/suggestions-primitives/ProductCardLayouts.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/ProductCardLayouts.js +105 -0
- package/dist/components/suggestions-primitives/ProductGrid.d.ts +6 -1
- package/dist/components/suggestions-primitives/ProductGrid.d.ts.map +1 -1
- package/dist/components/suggestions-primitives/ProductGrid.js +2 -2
- package/dist/hooks/useProductAnalytics.d.ts +49 -0
- package/dist/hooks/useProductAnalytics.d.ts.map +1 -0
- package/dist/hooks/useProductAnalytics.js +116 -0
- package/dist/hooks/useSuggestionsAnalytics.d.ts.map +1 -1
- package/dist/hooks/useSuggestionsAnalytics.js +6 -0
- package/dist/hooks/useVariantSelection.d.ts +28 -0
- package/dist/hooks/useVariantSelection.d.ts.map +1 -0
- package/dist/hooks/useVariantSelection.js +44 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.umd.js +1 -1
- package/dist/src/index.d.ts +1107 -679
- package/dist/src/index.esm.js +2267 -600
- package/dist/src/index.esm.js.map +1 -1
- package/dist/src/index.js +2283 -599
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProductCardLayouts – internal layout sub-components for ProductCard
|
|
3
|
+
*
|
|
4
|
+
* Not exported from the package. Each layout renders the same product data
|
|
5
|
+
* with different visual emphasis.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ImageDisplay } from '../primitives/ImageDisplay';
|
|
9
|
+
import { PriceDisplay } from '../primitives/PriceDisplay';
|
|
10
|
+
import { BadgeList } from '../primitives/BadgeList';
|
|
11
|
+
import { RatingDisplay } from '../primitives/RatingDisplay';
|
|
12
|
+
import { VariantSwatches } from '../primitives/VariantSwatches';
|
|
13
|
+
import { ActionButtons } from '../primitives/ActionButtons';
|
|
14
|
+
const imgPlaceholderStyle = {
|
|
15
|
+
width: '100%',
|
|
16
|
+
aspectRatio: '1',
|
|
17
|
+
objectFit: 'cover',
|
|
18
|
+
borderRadius: 4,
|
|
19
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f3f4f6)',
|
|
20
|
+
};
|
|
21
|
+
function ImageBlock({ images, title, imageVariant, aspectRatio, enableZoom, zoomMode, zoomLevel }) {
|
|
22
|
+
const ar = aspectRatio ? aspectRatio.replace(':', '/') : '1';
|
|
23
|
+
if (images.length > 0) {
|
|
24
|
+
return (React.createElement("div", { className: "seekora-product-card__image", style: { position: 'relative', overflow: 'hidden', borderRadius: 4 } },
|
|
25
|
+
React.createElement(ImageDisplay, { images: images, variant: images.length > 1 ? imageVariant : 'single', alt: title, className: "seekora-suggestions-product-card-image", style: { aspectRatio: ar }, enableZoom: enableZoom, zoomMode: zoomMode, zoomLevel: zoomLevel })));
|
|
26
|
+
}
|
|
27
|
+
return React.createElement("div", { className: "seekora-product-card__image seekora-suggestions-product-card-placeholder", style: { ...imgPlaceholderStyle, aspectRatio: ar }, "aria-hidden": true });
|
|
28
|
+
}
|
|
29
|
+
/** minimal: image, title, price (current default behavior) */
|
|
30
|
+
export function MinimalLayout({ images, title, price, product, imageVariant, displayConfig, enableImageZoom, imageZoomMode, imageZoomLevel }) {
|
|
31
|
+
return (React.createElement(React.Fragment, null,
|
|
32
|
+
React.createElement(ImageBlock, { images: images, title: title, imageVariant: imageVariant, aspectRatio: displayConfig.imageAspectRatio, enableZoom: enableImageZoom, zoomMode: imageZoomMode, zoomLevel: imageZoomLevel }),
|
|
33
|
+
React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: '0.875rem', fontWeight: 500 } }, title),
|
|
34
|
+
price != null && !Number.isNaN(price) && (React.createElement("span", { className: "seekora-product-card__price seekora-suggestions-product-card-price", style: { fontSize: '0.875rem', color: 'var(--seekora-text-secondary, #6b7280)' } },
|
|
35
|
+
product.currency ?? '$',
|
|
36
|
+
price.toFixed(2)))));
|
|
37
|
+
}
|
|
38
|
+
/** standard: image, badges, brand, title, price + compare price, color swatches */
|
|
39
|
+
export function StandardLayout({ images, title, price, comparePrice, brand, badges, options, variants, product, imageVariant, displayConfig, onVariantHover, onVariantClick, selectedVariants, actionButtons, actionButtonsPosition, showActionLabels, enableImageZoom, imageZoomMode, imageZoomLevel, }) {
|
|
40
|
+
const cfg = displayConfig;
|
|
41
|
+
return (React.createElement(React.Fragment, null,
|
|
42
|
+
React.createElement("div", { style: { position: 'relative' } },
|
|
43
|
+
React.createElement(ImageBlock, { images: images, title: title, imageVariant: imageVariant, aspectRatio: cfg.imageAspectRatio, enableZoom: enableImageZoom, zoomMode: imageZoomMode, zoomLevel: imageZoomLevel }),
|
|
44
|
+
cfg.showBadges !== false && badges.length > 0 && (React.createElement(BadgeList, { badges: badges, position: "top-left", maxBadges: 2 })),
|
|
45
|
+
actionButtons && actionButtons.length > 0 && actionButtonsPosition?.startsWith('overlay') && (React.createElement(ActionButtons, { buttons: actionButtons, position: actionButtonsPosition === 'overlay-top-right' ? 'top-right' : 'bottom-center', showLabels: showActionLabels, size: "small" }))),
|
|
46
|
+
React.createElement("div", { className: "seekora-product-card__body", style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
47
|
+
cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: '0.75rem', color: 'var(--seekora-text-secondary, #6b7280)', textTransform: 'uppercase', letterSpacing: '0.02em' } }, brand)),
|
|
48
|
+
React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: '0.875rem', fontWeight: 500 } }, title),
|
|
49
|
+
React.createElement("div", { className: "seekora-product-card__price" },
|
|
50
|
+
React.createElement(PriceDisplay, { price: price ?? undefined, comparePrice: comparePrice ?? undefined, currency: cfg.currency ?? product.currency, currencyPosition: cfg.currencyPosition, priceDecimals: cfg.priceDecimals, showDiscount: cfg.showDiscount, style: { fontSize: '0.875rem' } })),
|
|
51
|
+
cfg.showVariants !== false && options.length > 0 && (React.createElement(VariantSwatches, { options: options, visibleOptions: cfg.variantOptionsToShow, maxValues: cfg.maxVariantValues, selectedValues: selectedVariants, variants: variants, onSwatchHover: onVariantHover, onSwatchClick: onVariantClick })),
|
|
52
|
+
actionButtons && actionButtons.length > 0 && actionButtonsPosition === 'inline' && (React.createElement(ActionButtons, { buttons: actionButtons, position: "inline", showLabels: showActionLabels, size: "small", layout: "horizontal" })))));
|
|
53
|
+
}
|
|
54
|
+
/** detailed: image, badges, brand, title, price + compare + discount, rating, all swatches, stock */
|
|
55
|
+
export function DetailedLayout({ images, title, price, comparePrice, brand, badges, priceRange, options, variants, product, imageVariant, displayConfig, onVariantHover, onVariantClick, selectedVariants, actionButtons, actionButtonsPosition, showActionLabels, enableImageZoom, imageZoomMode, imageZoomLevel, }) {
|
|
56
|
+
const cfg = displayConfig;
|
|
57
|
+
const available = product.available;
|
|
58
|
+
return (React.createElement(React.Fragment, null,
|
|
59
|
+
React.createElement("div", { style: { position: 'relative' } },
|
|
60
|
+
React.createElement(ImageBlock, { images: images, title: title, imageVariant: imageVariant, aspectRatio: cfg.imageAspectRatio, enableZoom: enableImageZoom, zoomMode: imageZoomMode, zoomLevel: imageZoomLevel }),
|
|
61
|
+
cfg.showBadges !== false && badges.length > 0 && (React.createElement(BadgeList, { badges: badges, position: "top-left" })),
|
|
62
|
+
actionButtons && actionButtons.length > 0 && actionButtonsPosition?.startsWith('overlay') && (React.createElement(ActionButtons, { buttons: actionButtons, position: actionButtonsPosition === 'overlay-top-right' ? 'top-right' : 'bottom-center', showLabels: showActionLabels, size: "small" }))),
|
|
63
|
+
React.createElement("div", { className: "seekora-product-card__body", style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
64
|
+
cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: '0.75rem', color: 'var(--seekora-text-secondary, #6b7280)', textTransform: 'uppercase', letterSpacing: '0.02em' } }, brand)),
|
|
65
|
+
React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: '0.875rem', fontWeight: 500 } }, title),
|
|
66
|
+
cfg.showRating !== false && product.rating != null && (React.createElement(RatingDisplay, { rating: product.rating, reviewCount: product.reviewCount, variant: "compact", size: "small", showNumeric: false, showReviewCount: true, className: "seekora-product-card__rating" })),
|
|
67
|
+
React.createElement("div", { className: "seekora-product-card__price" }, cfg.showPriceRange && priceRange ? (React.createElement(PriceDisplay, { priceRange: priceRange, currency: cfg.currency ?? product.currency, currencyPosition: cfg.currencyPosition, priceDecimals: cfg.priceDecimals, style: { fontSize: '0.875rem' } })) : (React.createElement(PriceDisplay, { price: price ?? undefined, comparePrice: comparePrice ?? undefined, currency: cfg.currency ?? product.currency, currencyPosition: cfg.currencyPosition, priceDecimals: cfg.priceDecimals, showDiscount: cfg.showDiscount, style: { fontSize: '0.875rem' } }))),
|
|
68
|
+
cfg.showVariants !== false && options.length > 0 && (React.createElement(VariantSwatches, { options: options, visibleOptions: cfg.variantOptionsToShow, maxValues: cfg.maxVariantValues, selectedValues: selectedVariants, variants: variants, onSwatchHover: onVariantHover, onSwatchClick: onVariantClick })),
|
|
69
|
+
cfg.showStock !== false && available != null && (React.createElement("span", { className: "seekora-product-card__stock", style: {
|
|
70
|
+
fontSize: '0.75rem',
|
|
71
|
+
color: available ? 'var(--seekora-success, #22c55e)' : 'var(--seekora-error, #ef4444)',
|
|
72
|
+
} }, available ? 'In Stock' : 'Out of Stock')),
|
|
73
|
+
actionButtons && actionButtons.length > 0 && actionButtonsPosition === 'inline' && (React.createElement(ActionButtons, { buttons: actionButtons, position: "inline", showLabels: showActionLabels, size: "small", layout: "horizontal" })))));
|
|
74
|
+
}
|
|
75
|
+
/** compact: smaller image, 1-line title, price */
|
|
76
|
+
export function CompactLayout({ images, title, price, product, imageVariant, displayConfig, enableImageZoom, imageZoomMode, imageZoomLevel }) {
|
|
77
|
+
return (React.createElement(React.Fragment, null,
|
|
78
|
+
React.createElement(ImageBlock, { images: images, title: title, imageVariant: imageVariant, aspectRatio: displayConfig.imageAspectRatio ?? '1:1', enableZoom: enableImageZoom, zoomMode: imageZoomMode, zoomLevel: imageZoomLevel }),
|
|
79
|
+
React.createElement("span", { className: "seekora-product-card__title", style: {
|
|
80
|
+
fontSize: '0.8125rem',
|
|
81
|
+
fontWeight: 500,
|
|
82
|
+
overflow: 'hidden',
|
|
83
|
+
textOverflow: 'ellipsis',
|
|
84
|
+
whiteSpace: 'nowrap',
|
|
85
|
+
} }, title),
|
|
86
|
+
price != null && !Number.isNaN(price) && (React.createElement("span", { className: "seekora-product-card__price", style: { fontSize: '0.8125rem', color: 'var(--seekora-text-secondary, #6b7280)' } },
|
|
87
|
+
product.currency ?? '$',
|
|
88
|
+
price.toFixed(2)))));
|
|
89
|
+
}
|
|
90
|
+
/** horizontal: image left + content right (title, brand, price, swatches) */
|
|
91
|
+
export function HorizontalLayout({ images, title, price, comparePrice, brand, badges, options, variants, product, imageVariant, displayConfig, onVariantHover, onVariantClick, selectedVariants, actionButtons, actionButtonsPosition, showActionLabels, enableImageZoom, imageZoomMode, imageZoomLevel, }) {
|
|
92
|
+
const cfg = displayConfig;
|
|
93
|
+
return (React.createElement("div", { style: { display: 'flex', gap: 12, alignItems: 'flex-start' } },
|
|
94
|
+
React.createElement("div", { style: { position: 'relative', width: 80, flexShrink: 0 } },
|
|
95
|
+
React.createElement(ImageBlock, { images: images, title: title, imageVariant: imageVariant, aspectRatio: "1:1", enableZoom: enableImageZoom, zoomMode: imageZoomMode, zoomLevel: imageZoomLevel }),
|
|
96
|
+
cfg.showBadges !== false && badges.length > 0 && (React.createElement(BadgeList, { badges: badges, position: "top-left", maxBadges: 1 })),
|
|
97
|
+
actionButtons && actionButtons.length > 0 && actionButtonsPosition?.startsWith('overlay') && (React.createElement(ActionButtons, { buttons: actionButtons, position: actionButtonsPosition === 'overlay-top-right' ? 'top-right' : 'bottom-center', showLabels: showActionLabels, size: "small" }))),
|
|
98
|
+
React.createElement("div", { className: "seekora-product-card__body", style: { display: 'flex', flexDirection: 'column', gap: 4, flex: 1, minWidth: 0 } },
|
|
99
|
+
cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: '0.75rem', color: 'var(--seekora-text-secondary, #6b7280)', textTransform: 'uppercase' } }, brand)),
|
|
100
|
+
React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: '0.875rem', fontWeight: 500 } }, title),
|
|
101
|
+
React.createElement("div", { className: "seekora-product-card__price" },
|
|
102
|
+
React.createElement(PriceDisplay, { price: price ?? undefined, comparePrice: comparePrice ?? undefined, currency: cfg.currency ?? product.currency, currencyPosition: cfg.currencyPosition, priceDecimals: cfg.priceDecimals, showDiscount: cfg.showDiscount, style: { fontSize: '0.875rem' } })),
|
|
103
|
+
cfg.showVariants !== false && options.length > 0 && (React.createElement(VariantSwatches, { options: options, visibleOptions: cfg.variantOptionsToShow, maxValues: cfg.maxVariantValues ?? 3, selectedValues: selectedVariants, variants: variants, onSwatchHover: onVariantHover, onSwatchClick: onVariantClick })),
|
|
104
|
+
actionButtons && actionButtons.length > 0 && actionButtonsPosition === 'inline' && (React.createElement(ActionButtons, { buttons: actionButtons, position: "inline", showLabels: showActionLabels, size: "small", layout: "horizontal" })))));
|
|
105
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Uses trendingProducts or active tab products; each click calls context selectProduct.
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
+
import type { ProductDisplayConfig } from '../suggestions/types';
|
|
7
8
|
export interface ProductGridProps {
|
|
8
9
|
maxItems?: number;
|
|
9
10
|
/** 'trending' | tab id for filtered tab products */
|
|
@@ -12,6 +13,10 @@ export interface ProductGridProps {
|
|
|
12
13
|
className?: string;
|
|
13
14
|
style?: React.CSSProperties;
|
|
14
15
|
gridClassName?: string;
|
|
16
|
+
/** Product display configuration passed through to each ProductCard */
|
|
17
|
+
displayConfig?: ProductDisplayConfig;
|
|
18
|
+
/** Callback when a variant swatch is hovered on a card */
|
|
19
|
+
onVariantHover?: (optionName: string, value: string) => void;
|
|
15
20
|
}
|
|
16
|
-
export declare function ProductGrid({ maxItems, source, columns, className, style, gridClassName, }: ProductGridProps): React.JSX.Element | null;
|
|
21
|
+
export declare function ProductGrid({ maxItems, source, columns, className, style, gridClassName, displayConfig, onVariantHover, }: ProductGridProps): React.JSX.Element | null;
|
|
17
22
|
//# sourceMappingURL=ProductGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductGrid.d.ts","sourceRoot":"","sources":["../../../src/components/suggestions-primitives/ProductGrid.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductGrid.d.ts","sourceRoot":"","sources":["../../../src/components/suggestions-primitives/ProductGrid.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;AAKvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,0DAA0D;IAC1D,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D;AAED,wBAAgB,WAAW,CAAC,EAC1B,QAAY,EACZ,MAAmB,EACnB,OAAW,EACX,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,cAAc,GACf,EAAE,gBAAgB,4BAmDlB"}
|
|
@@ -7,7 +7,7 @@ import React, { useMemo } from 'react';
|
|
|
7
7
|
import { useSuggestionsContext } from './SuggestionsContext';
|
|
8
8
|
import { ProductCard } from './ProductCard';
|
|
9
9
|
import { clsx } from 'clsx';
|
|
10
|
-
export function ProductGrid({ maxItems = 8, source = 'trending', columns = 4, className, style, gridClassName, }) {
|
|
10
|
+
export function ProductGrid({ maxItems = 8, source = 'trending', columns = 4, className, style, gridClassName, displayConfig, onVariantHover, }) {
|
|
11
11
|
const { trendingProducts, filteredTabs, activeTabId, selectProduct, getAllNavigableItems, } = useSuggestionsContext();
|
|
12
12
|
const products = useMemo(() => {
|
|
13
13
|
if (source === 'trending')
|
|
@@ -31,6 +31,6 @@ export function ProductGrid({ maxItems = 8, source = 'trending', columns = 4, cl
|
|
|
31
31
|
const globalIndex = productStartIndex >= 0 ? productStartIndex + i : i;
|
|
32
32
|
const section = source === 'trending' ? 'products' : 'filtered_tab';
|
|
33
33
|
const tabId = source !== 'trending' ? (source === 'tab' ? activeTabId : source) : undefined;
|
|
34
|
-
return (React.createElement(ProductCard, { key: product.id ?? product.objectID ?? i, product: product, position: globalIndex, section: section, tabId: tabId, onSelect: () => selectProduct(product, globalIndex, section, tabId) }));
|
|
34
|
+
return (React.createElement(ProductCard, { key: product.id ?? product.objectID ?? i, product: product, position: globalIndex, section: section, tabId: tabId, onSelect: () => selectProduct(product, globalIndex, section, tabId), displayConfig: displayConfig, onVariantHover: onVariantHover }));
|
|
35
35
|
}))));
|
|
36
36
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useProductAnalytics – analytics event binding hook for custom components
|
|
3
|
+
*
|
|
4
|
+
* Returns event handler props ready to spread onto any element, plus imperative
|
|
5
|
+
* tracking methods. Builds on existing useAnalytics infrastructure.
|
|
6
|
+
*/
|
|
7
|
+
import type { SeekoraClient, SearchContext } from '@seekora-ai/search-sdk';
|
|
8
|
+
import type { ProductItem, ProductVariant } from '@seekora-ai/ui-sdk-types';
|
|
9
|
+
export interface UseProductAnalyticsOptions {
|
|
10
|
+
client: SeekoraClient;
|
|
11
|
+
product: ProductItem;
|
|
12
|
+
position?: number;
|
|
13
|
+
section?: string;
|
|
14
|
+
tabId?: string;
|
|
15
|
+
query?: string;
|
|
16
|
+
context?: SearchContext | Partial<SearchContext>;
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface UseProductAnalyticsReturn {
|
|
20
|
+
/** Spread onto any clickable element to track product click */
|
|
21
|
+
clickProps: {
|
|
22
|
+
onClick: (e?: React.MouseEvent) => void;
|
|
23
|
+
'data-seekora-product-id': string;
|
|
24
|
+
'data-seekora-position': number;
|
|
25
|
+
};
|
|
26
|
+
/** Spread onto any element to track variant selection */
|
|
27
|
+
variantSelectProps: (optionName: string, value: string) => {
|
|
28
|
+
onClick: (e?: React.MouseEvent) => void;
|
|
29
|
+
'data-seekora-variant-option': string;
|
|
30
|
+
'data-seekora-variant-value': string;
|
|
31
|
+
};
|
|
32
|
+
/** Spread onto any element to track add-to-cart */
|
|
33
|
+
addToCartProps: (variant?: ProductVariant) => {
|
|
34
|
+
onClick: (e?: React.MouseEvent) => void;
|
|
35
|
+
'data-seekora-action': 'add-to-cart';
|
|
36
|
+
};
|
|
37
|
+
/** Spread onto any element to track impression (uses IntersectionObserver) */
|
|
38
|
+
impressionRef: React.RefCallback<HTMLElement>;
|
|
39
|
+
/** Imperative: track product click */
|
|
40
|
+
trackClick: () => void;
|
|
41
|
+
/** Imperative: track variant select */
|
|
42
|
+
trackVariantSelect: (optionName: string, value: string) => void;
|
|
43
|
+
/** Imperative: track add to cart */
|
|
44
|
+
trackAddToCart: (variant?: ProductVariant) => void;
|
|
45
|
+
/** Imperative: track custom event with product context */
|
|
46
|
+
trackCustomEvent: (eventName: string, metadata?: Record<string, any>) => void;
|
|
47
|
+
}
|
|
48
|
+
export declare function useProductAnalytics({ client, product, position, section, tabId, query, context, enabled, }: UseProductAnalyticsOptions): UseProductAnalyticsReturn;
|
|
49
|
+
//# sourceMappingURL=useProductAnalytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProductAnalytics.d.ts","sourceRoot":"","sources":["../../src/hooks/useProductAnalytics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG5E,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,+DAA+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@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useProductAnalytics – analytics event binding hook for custom components
|
|
3
|
+
*
|
|
4
|
+
* Returns event handler props ready to spread onto any element, plus imperative
|
|
5
|
+
* tracking methods. Builds on existing useAnalytics infrastructure.
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useRef, useEffect } from 'react';
|
|
8
|
+
import { log } from '@seekora-ai/ui-sdk-core';
|
|
9
|
+
export function useProductAnalytics({ client, product, position = 0, section, tabId, query, context, enabled = true, }) {
|
|
10
|
+
const impressionTrackedRef = useRef(false);
|
|
11
|
+
const observerRef = useRef(null);
|
|
12
|
+
const elementRef = useRef(null);
|
|
13
|
+
const productId = product.id || product.objectID || '';
|
|
14
|
+
const sendEvent = useCallback(async (eventName, metadata) => {
|
|
15
|
+
if (!enabled || !client)
|
|
16
|
+
return;
|
|
17
|
+
try {
|
|
18
|
+
await client.trackEvent?.({
|
|
19
|
+
event_name: eventName,
|
|
20
|
+
metadata: {
|
|
21
|
+
product_id: productId,
|
|
22
|
+
product_title: product.title || product.name,
|
|
23
|
+
product_price: product.price,
|
|
24
|
+
position,
|
|
25
|
+
section,
|
|
26
|
+
tab_id: tabId,
|
|
27
|
+
original_query: query,
|
|
28
|
+
timestamp: Date.now(),
|
|
29
|
+
source: 'product_analytics',
|
|
30
|
+
...metadata,
|
|
31
|
+
},
|
|
32
|
+
}, context);
|
|
33
|
+
log.verbose(`ProductAnalytics: ${eventName}`, metadata);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
log.warn(`Failed to track ${eventName}`, { error });
|
|
37
|
+
}
|
|
38
|
+
}, [client, enabled, productId, product, position, section, tabId, query, context]);
|
|
39
|
+
const trackClick = useCallback(() => {
|
|
40
|
+
sendEvent('product.click', {});
|
|
41
|
+
// Also fire via client.trackClick for V3 compat
|
|
42
|
+
if (client?.trackClick) {
|
|
43
|
+
Promise.resolve(client.trackClick(productId, position + 1, context)).catch(() => { });
|
|
44
|
+
}
|
|
45
|
+
}, [sendEvent, client, productId, position, context]);
|
|
46
|
+
const trackVariantSelect = useCallback((optionName, value) => {
|
|
47
|
+
sendEvent('product.variant_select', {
|
|
48
|
+
option_name: optionName,
|
|
49
|
+
option_value: value,
|
|
50
|
+
});
|
|
51
|
+
}, [sendEvent]);
|
|
52
|
+
const trackAddToCart = useCallback((variant) => {
|
|
53
|
+
sendEvent('product.add_to_cart', {
|
|
54
|
+
variant_id: variant?.id,
|
|
55
|
+
variant_sku: variant?.sku,
|
|
56
|
+
variant_title: variant?.title,
|
|
57
|
+
variant_price: variant?.price,
|
|
58
|
+
});
|
|
59
|
+
}, [sendEvent]);
|
|
60
|
+
const trackCustomEvent = useCallback((eventName, metadata) => {
|
|
61
|
+
sendEvent(eventName, metadata ?? {});
|
|
62
|
+
}, [sendEvent]);
|
|
63
|
+
// Impression tracking via IntersectionObserver
|
|
64
|
+
const impressionRef = useCallback((node) => {
|
|
65
|
+
// Cleanup previous observer
|
|
66
|
+
if (observerRef.current) {
|
|
67
|
+
observerRef.current.disconnect();
|
|
68
|
+
observerRef.current = null;
|
|
69
|
+
}
|
|
70
|
+
elementRef.current = node;
|
|
71
|
+
if (!node || !enabled || impressionTrackedRef.current)
|
|
72
|
+
return;
|
|
73
|
+
if (typeof IntersectionObserver === 'undefined')
|
|
74
|
+
return;
|
|
75
|
+
observerRef.current = new IntersectionObserver((entries) => {
|
|
76
|
+
for (const entry of entries) {
|
|
77
|
+
if (entry.isIntersecting && !impressionTrackedRef.current) {
|
|
78
|
+
impressionTrackedRef.current = true;
|
|
79
|
+
sendEvent('product.impression', {});
|
|
80
|
+
observerRef.current?.disconnect();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, { threshold: 0.5 });
|
|
84
|
+
observerRef.current.observe(node);
|
|
85
|
+
}, [enabled, sendEvent]);
|
|
86
|
+
// Cleanup on unmount
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
return () => {
|
|
89
|
+
observerRef.current?.disconnect();
|
|
90
|
+
};
|
|
91
|
+
}, []);
|
|
92
|
+
const clickProps = {
|
|
93
|
+
onClick: () => trackClick(),
|
|
94
|
+
'data-seekora-product-id': productId,
|
|
95
|
+
'data-seekora-position': position,
|
|
96
|
+
};
|
|
97
|
+
const variantSelectProps = (optionName, value) => ({
|
|
98
|
+
onClick: () => trackVariantSelect(optionName, value),
|
|
99
|
+
'data-seekora-variant-option': optionName,
|
|
100
|
+
'data-seekora-variant-value': value,
|
|
101
|
+
});
|
|
102
|
+
const addToCartProps = (variant) => ({
|
|
103
|
+
onClick: () => trackAddToCart(variant),
|
|
104
|
+
'data-seekora-action': 'add-to-cart',
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
clickProps,
|
|
108
|
+
variantSelectProps,
|
|
109
|
+
addToCartProps,
|
|
110
|
+
impressionRef,
|
|
111
|
+
trackClick,
|
|
112
|
+
trackVariantSelect,
|
|
113
|
+
trackAddToCart,
|
|
114
|
+
trackCustomEvent,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuggestionsAnalytics.d.ts","sourceRoot":"","sources":["../../src/hooks/useSuggestionsAnalytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACf,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,8BAA8B;IAC7C,8BAA8B;IAC9B,MAAM,EAAE,aAAa,CAAC;IACtB,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,sCAAsC;IACtC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iDA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B,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,2BAA2B;IAC3B,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AA8BD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,8BAA8B,GACtC,6BAA6B,CAkQ/B;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -25,6 +25,12 @@ const EVENTS = {
|
|
|
25
25
|
SEARCH_SUBMIT: 'suggestions.search_submit',
|
|
26
26
|
DROPDOWN_OPEN: 'suggestions.dropdown_open',
|
|
27
27
|
DROPDOWN_CLOSE: 'suggestions.dropdown_close',
|
|
28
|
+
// Variant & product interaction events
|
|
29
|
+
VARIANT_SELECT: 'product.variant_select',
|
|
30
|
+
VARIANT_HOVER: 'product.variant_hover',
|
|
31
|
+
ADD_TO_CART: 'product.add_to_cart',
|
|
32
|
+
PRODUCT_IMPRESSION: 'product.impression',
|
|
33
|
+
SWATCH_CLICK: 'product.swatch_click',
|
|
28
34
|
};
|
|
29
35
|
// ============================================================================
|
|
30
36
|
// Hook Implementation
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useVariantSelection – manages variant selection state
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for variant interactions on product pages.
|
|
5
|
+
* Cards display variants passively; product pages use this hook.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProductOption, ProductVariant } from '@seekora-ai/ui-sdk-types';
|
|
8
|
+
export interface UseVariantSelectionOptions {
|
|
9
|
+
options?: ProductOption[];
|
|
10
|
+
variants?: ProductVariant[];
|
|
11
|
+
initialSelections?: Record<string, string>;
|
|
12
|
+
onVariantChange?: (variant: ProductVariant | null, selections: Record<string, string>) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface UseVariantSelectionReturn {
|
|
15
|
+
selections: Record<string, string>;
|
|
16
|
+
setSelection: (optionName: string, value: string) => void;
|
|
17
|
+
resetSelections: () => void;
|
|
18
|
+
selectedVariant: ProductVariant | null;
|
|
19
|
+
availableValues: Record<string, {
|
|
20
|
+
value: string;
|
|
21
|
+
available: boolean;
|
|
22
|
+
}[]>;
|
|
23
|
+
isComplete: boolean;
|
|
24
|
+
effectivePrice: number | null;
|
|
25
|
+
effectiveComparePrice: number | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function useVariantSelection({ options, variants, initialSelections, onVariantChange, }?: UseVariantSelectionOptions): UseVariantSelectionReturn;
|
|
28
|
+
//# sourceMappingURL=useVariantSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVariantSelection.d.ts","sourceRoot":"","sources":["../../src/hooks/useVariantSelection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG9E,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAChG;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAC;IACzE,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAY,EACZ,QAAa,EACb,iBAAsB,EACtB,eAAe,GAChB,GAAE,0BAA+B,GAAG,yBAAyB,CAwD7D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useVariantSelection – manages variant selection state
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for variant interactions on product pages.
|
|
5
|
+
* Cards display variants passively; product pages use this hook.
|
|
6
|
+
*/
|
|
7
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
8
|
+
import { findVariantBySelections, getAvailableValuesForOption } from '../components/suggestions/utils';
|
|
9
|
+
export function useVariantSelection({ options = [], variants = [], initialSelections = {}, onVariantChange, } = {}) {
|
|
10
|
+
const [selections, setSelections] = useState(initialSelections);
|
|
11
|
+
const selectedVariant = useMemo(() => findVariantBySelections(options, variants, selections), [options, variants, selections]);
|
|
12
|
+
const isComplete = useMemo(() => options.length > 0 && options.every((opt) => !!selections[opt.name]), [options, selections]);
|
|
13
|
+
const availableValues = useMemo(() => {
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const option of options) {
|
|
16
|
+
result[option.name] = getAvailableValuesForOption(option.name, options, variants, selections);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}, [options, variants, selections]);
|
|
20
|
+
const effectivePrice = selectedVariant?.price ?? null;
|
|
21
|
+
const effectiveComparePrice = selectedVariant?.comparePrice ?? null;
|
|
22
|
+
const setSelection = useCallback((optionName, value) => {
|
|
23
|
+
setSelections((prev) => {
|
|
24
|
+
const next = { ...prev, [optionName]: value };
|
|
25
|
+
const variant = findVariantBySelections(options, variants, next);
|
|
26
|
+
onVariantChange?.(variant, next);
|
|
27
|
+
return next;
|
|
28
|
+
});
|
|
29
|
+
}, [options, variants, onVariantChange]);
|
|
30
|
+
const resetSelections = useCallback(() => {
|
|
31
|
+
setSelections({});
|
|
32
|
+
onVariantChange?.(null, {});
|
|
33
|
+
}, [onVariantChange]);
|
|
34
|
+
return {
|
|
35
|
+
selections,
|
|
36
|
+
setSelection,
|
|
37
|
+
resetSelections,
|
|
38
|
+
selectedVariant,
|
|
39
|
+
availableValues,
|
|
40
|
+
isComplete,
|
|
41
|
+
effectivePrice,
|
|
42
|
+
effectiveComparePrice,
|
|
43
|
+
};
|
|
44
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export { FederatedDropdown } from './components/FederatedDropdown';
|
|
|
29
29
|
export { SearchBarWithSuggestions } from './components/SearchBarWithSuggestions';
|
|
30
30
|
export { SuggestionsProvider, useSuggestionsContext, SearchInput, DropdownPanel, SuggestionList, SuggestionItem, ItemCard, ItemGrid, ProductCard, ProductGrid, CategoriesTabs, SuggestionsLoading, SuggestionsError, SuggestionsDropdownComposition, RecentSearchesList, TrendingList, parseHighlightMarkup, } from './components/suggestions-primitives';
|
|
31
31
|
export type { SuggestionsDropdownCompositionProps, RecentSearchesListProps, TrendingListProps, SuggestionsContextValue, SuggestionsProviderProps, SearchInputProps, DropdownPanelProps, SuggestionListProps, SuggestionItemProps, HighlightMarkupOptions, GenericItem, ItemCardProps, ItemGridProps, ProductCardProps, ProductGridProps, CategoriesTabsProps, SuggestionsLoadingProps, SuggestionsErrorProps, ItemCardImageVariant, ProductCardImageVariant, } from './components/suggestions-primitives';
|
|
32
|
-
export { ImageDisplay } from './components/primitives';
|
|
33
|
-
export type { ImageDisplayVariant, ImageDisplayProps } from './components/primitives';
|
|
32
|
+
export { ImageDisplay, ImageZoom, PriceDisplay, BadgeList, RatingDisplay, VariantSwatches, VariantSelector, ActionButtons, withAnalytics, AnalyticsProvider, useAnalyticsProvider, } from './components/primitives';
|
|
33
|
+
export type { ImageDisplayVariant, ImageDisplayProps, ImageZoomProps, ImageZoomMode, PriceDisplayProps, BadgeListProps, RatingDisplayProps, RatingVariant, RatingSize, VariantSwatchesProps, VariantSelectorProps, ActionButtonsProps, ActionButton, ActionButtonType, WithAnalyticsConfig, WithAnalyticsInjectedProps, AnalyticsProviderProps, } from './components/primitives';
|
|
34
34
|
export { SectionSearchProvider, useSectionSearchContext, SectionItemGrid, SectionLoading, SectionError, } from './components/section-primitives';
|
|
35
35
|
export type { SectionSearchProviderProps, SectionSearchContextValue, RefinementInput, SectionItemGridProps, SectionLoadingProps, SectionErrorProps, } from './components/section-primitives';
|
|
36
36
|
export { ProductGallery, ProductInfo, ProductRecommendations } from './components/product-page';
|
|
@@ -55,10 +55,12 @@ export { useAnalytics } from './hooks/useAnalytics';
|
|
|
55
55
|
export { useSearchState } from './hooks/useSearchState';
|
|
56
56
|
export { useSmartSuggestions } from './hooks/useSmartSuggestions';
|
|
57
57
|
export { useNaturalLanguageFilters, formatParsedFilters } from './hooks/useNaturalLanguageFilters';
|
|
58
|
+
export { useVariantSelection } from './hooks/useVariantSelection';
|
|
59
|
+
export { useProductAnalytics } from './hooks/useProductAnalytics';
|
|
58
60
|
export { Fingerprint, getFingerprint, type FingerprintConfig, type FingerprintResult, type FingerprintComponents, } from '@seekora-ai/ui-sdk-core';
|
|
59
61
|
export type { SearchBarProps, SearchBarTheme, } from './components/SearchBar';
|
|
60
62
|
export type { SearchResultsProps, SearchResultsTheme } from './components/SearchResults';
|
|
61
|
-
export type { ResultItem, FieldMapping, ViewMode } from '@seekora-ai/ui-sdk-types';
|
|
63
|
+
export type { ResultItem, FieldMapping, ViewMode, ProductOption, ProductVariant, ProductBadge, PriceRange, } from '@seekora-ai/ui-sdk-types';
|
|
62
64
|
export type { QuerySuggestionsProps, QuerySuggestionsTheme, } from './components/QuerySuggestions';
|
|
63
65
|
export type { QuerySuggestionsDropdownProps, QuerySuggestionsDropdownRef, } from './components/QuerySuggestionsDropdown';
|
|
64
66
|
export type { RichQuerySuggestionsProps, RichQuerySuggestionsRef, } from './components/RichQuerySuggestions';
|
|
@@ -78,6 +80,8 @@ export type { UseAnalyticsOptions, UseAnalyticsReturn, AnalyticsEventPayload, }
|
|
|
78
80
|
export type { UseQuerySuggestionsEnhancedOptions, UseQuerySuggestionsEnhancedReturn, NavigableItem, } from './hooks/useQuerySuggestionsEnhanced';
|
|
79
81
|
export type { UseSuggestionsAnalyticsOptions, UseSuggestionsAnalyticsReturn, SuggestionClickEventData, ProductClickEventData, SuggestionImpressionEventData, } from './hooks/useSuggestionsAnalytics';
|
|
80
82
|
export type { SmartSuggestion, SmartSuggestionsOptions, UseSmartSuggestionsReturn, } from './hooks/useSmartSuggestions';
|
|
83
|
+
export type { UseVariantSelectionOptions, UseVariantSelectionReturn, } from './hooks/useVariantSelection';
|
|
84
|
+
export type { UseProductAnalyticsOptions, UseProductAnalyticsReturn, } from './hooks/useProductAnalytics';
|
|
81
85
|
export type { ParsedFilter, NaturalLanguageResult, NaturalLanguageFiltersOptions, } from './hooks/useNaturalLanguageFilters';
|
|
82
86
|
export type { Theme, ThemeConfig, } from './themes/types';
|
|
83
87
|
export { defaultTheme } from './themes/default';
|
|
@@ -89,4 +93,5 @@ export { createTheme } from './themes/createTheme';
|
|
|
89
93
|
export { mergeThemes } from './themes/mergeThemes';
|
|
90
94
|
export { getSuggestionsCache, createSuggestionsCache, clearSuggestionsCache, } from './components/suggestions/utils';
|
|
91
95
|
export type { SuggestionsCache } from './components/suggestions/utils';
|
|
96
|
+
export { extractBadges, getPriceRange, formatPriceRange, getAvailableValuesForOption, findVariantBySelections, } from './components/suggestions/utils';
|
|
92
97
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAA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AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAQtE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,gCAAgC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export { SearchBarWithSuggestions } from './components/SearchBarWithSuggestions'
|
|
|
37
37
|
// Composable Suggestions Primitives (generic + product-specific)
|
|
38
38
|
// ============================================================================
|
|
39
39
|
export { SuggestionsProvider, useSuggestionsContext, SearchInput, DropdownPanel, SuggestionList, SuggestionItem, ItemCard, ItemGrid, ProductCard, ProductGrid, CategoriesTabs, SuggestionsLoading, SuggestionsError, SuggestionsDropdownComposition, RecentSearchesList, TrendingList, parseHighlightMarkup, } from './components/suggestions-primitives';
|
|
40
|
-
export { ImageDisplay } from './components/primitives';
|
|
40
|
+
export { ImageDisplay, ImageZoom, PriceDisplay, BadgeList, RatingDisplay, VariantSwatches, VariantSelector, ActionButtons, withAnalytics, AnalyticsProvider, useAnalyticsProvider, } from './components/primitives';
|
|
41
41
|
export { SectionSearchProvider, useSectionSearchContext, SectionItemGrid, SectionLoading, SectionError, } from './components/section-primitives';
|
|
42
42
|
export { ProductGallery, ProductInfo, ProductRecommendations } from './components/product-page';
|
|
43
43
|
// ============================================================================
|
|
@@ -81,6 +81,8 @@ export { useAnalytics } from './hooks/useAnalytics';
|
|
|
81
81
|
export { useSearchState } from './hooks/useSearchState';
|
|
82
82
|
export { useSmartSuggestions } from './hooks/useSmartSuggestions';
|
|
83
83
|
export { useNaturalLanguageFilters, formatParsedFilters } from './hooks/useNaturalLanguageFilters';
|
|
84
|
+
export { useVariantSelection } from './hooks/useVariantSelection';
|
|
85
|
+
export { useProductAnalytics } from './hooks/useProductAnalytics';
|
|
84
86
|
// ============================================================================
|
|
85
87
|
// Fingerprinting (from core - visitor ID for analytics/identity)
|
|
86
88
|
// ============================================================================
|
|
@@ -102,3 +104,5 @@ export { createTheme } from './themes/createTheme';
|
|
|
102
104
|
export { mergeThemes } from './themes/mergeThemes';
|
|
103
105
|
// Cache utilities for suggestions
|
|
104
106
|
export { getSuggestionsCache, createSuggestionsCache, clearSuggestionsCache, } from './components/suggestions/utils';
|
|
107
|
+
// Variant utilities
|
|
108
|
+
export { extractBadges, getPriceRange, formatPriceRange, getAvailableValuesForOption, findVariantBySelections, } from './components/suggestions/utils';
|