@seekora-ai/ui-sdk-react 0.2.17 → 0.2.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.
@@ -24,7 +24,7 @@ export function CategoriesTabs({ className, style, tabClassName }) {
24
24
  border: 'none',
25
25
  borderRadius: 'var(--seekora-border-radius, 6px)',
26
26
  backgroundColor: isActive ? 'var(--seekora-primary-light, rgba(59, 130, 246, 0.1))' : 'transparent',
27
- color: isActive ? 'var(--seekora-primary, #3b82f6)' : 'var(--seekora-text-primary, #111827)',
27
+ color: isActive ? 'var(--seekora-primary, #3b82f6)' : 'inherit',
28
28
  cursor: 'pointer',
29
29
  fontSize: '0.875rem',
30
30
  fontWeight: isActive ? 600 : 400,
@@ -40,7 +40,7 @@ const imgStyle = {
40
40
  aspectRatio: 'var(--seekora-card-aspect-ratio, 1)',
41
41
  objectFit: 'cover',
42
42
  borderRadius: BORDER_RADIUS.sm,
43
- backgroundColor: 'var(--seekora-bg-secondary, #f3f4f6)',
43
+ backgroundColor: 'var(--seekora-bg-secondary, rgba(0,0,0,0.04))',
44
44
  display: 'block',
45
45
  overflow: 'hidden',
46
46
  };
@@ -66,7 +66,7 @@ export function ItemCard({ item, position, onSelect, className, style, asLink =
66
66
  // Hover style
67
67
  const cardHoverStyle = isHovered
68
68
  ? {
69
- backgroundColor: 'var(--seekora-card-hover-bg, var(--seekora-bg-hover, #f9fafb))',
69
+ backgroundColor: 'var(--seekora-card-hover-bg, var(--seekora-bg-hover, rgba(0,0,0,0.03)))',
70
70
  boxShadow: 'var(--seekora-card-hover-shadow, 0 2px 8px rgba(0, 0, 0, 0.08))',
71
71
  }
72
72
  : {};
@@ -75,7 +75,7 @@ export function ItemCard({ item, position, onSelect, className, style, asLink =
75
75
  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" })))) : (React.createElement("div", { className: "seekora-item-card-placeholder", style: { ...imgStyle, ...(isHorizontal ? { minWidth: imageMinWidth, flexBasis: imageFlex, maxWidth: imageMaxWidth, height: imageHeight, flexShrink: 0 } : {}) }, "aria-hidden": true }));
76
76
  const textBlock = (React.createElement("div", { style: isHorizontal ? { display: 'flex', flexDirection: 'column', gap: textGap, flex: 1, minWidth: 0 } : undefined },
77
77
  React.createElement("span", { className: "seekora-item-card-title", style: { fontSize: titleFontSize, fontWeight: 500, lineHeight: 1.4, overflow: 'hidden', textOverflow: 'ellipsis', display: '-webkit-box', WebkitLineClamp: isHorizontal ? 2 : 3, WebkitBoxOrient: 'vertical' } }, String(title)),
78
- description ? (React.createElement("span", { className: "seekora-item-card-description", style: { fontSize: descriptionFontSize, color: 'var(--seekora-text-secondary, #6b7280)', lineHeight: 1.3, display: '-webkit-box', WebkitLineClamp: lineClamp, WebkitBoxOrient: 'vertical', overflow: 'hidden' } }, String(description))) : null,
78
+ description ? (React.createElement("span", { className: "seekora-item-card-description", style: { fontSize: descriptionFontSize, color: 'inherit', opacity: 0.6, lineHeight: 1.3, display: '-webkit-box', WebkitLineClamp: lineClamp, WebkitBoxOrient: 'vertical', overflow: 'hidden' } }, String(description))) : null,
79
79
  actionButtons && actionButtons.length > 0 && actionButtonsPosition === 'inline' && (React.createElement(ActionButtons, { buttons: actionButtons, position: "inline", showLabels: showActionLabels, size: "small", layout: "horizontal" }))));
80
80
  const content = isHorizontal ? (React.createElement("div", { style: { display: 'flex', gap: horizontalGap, alignItems: 'flex-start' } },
81
81
  imageBlock,
@@ -37,7 +37,7 @@ const imgStyle = {
37
37
  aspectRatio: '1',
38
38
  objectFit: 'cover',
39
39
  borderRadius: BORDER_RADIUS.sm,
40
- backgroundColor: 'var(--seekora-bg-secondary, #f3f4f6)',
40
+ backgroundColor: 'var(--seekora-bg-secondary, rgba(0,0,0,0.04))',
41
41
  };
42
42
  export function ProductCard({ product, position, section, tabId, onSelect, className, style, imageVariant = 'single', displayConfig, onVariantHover, onVariantClick, selectedVariants, asLink, actionButtons, actionButtonsPosition = 'inline', showActionLabels = false, enableImageZoom = false, imageZoomMode = 'both', imageZoomLevel = 2.5, }) {
43
43
  // Find selected variant if selections are provided
@@ -86,7 +86,7 @@ export function ProductCard({ product, position, section, tabId, onSelect, class
86
86
  const [isHovered, setIsHovered] = React.useState(false);
87
87
  const cardHoverStyle = isHovered
88
88
  ? {
89
- backgroundColor: 'var(--seekora-card-hover-bg, var(--seekora-bg-hover, #f9fafb))',
89
+ backgroundColor: 'var(--seekora-card-hover-bg, var(--seekora-bg-hover, rgba(0,0,0,0.03)))',
90
90
  boxShadow: 'var(--seekora-card-hover-shadow, 0 2px 8px rgba(0, 0, 0, 0.08))',
91
91
  }
92
92
  : {};
@@ -100,7 +100,7 @@ export function ProductCard({ product, position, section, tabId, onSelect, class
100
100
  }, "data-position": position, "data-section": section, "data-tab-id": tabId },
101
101
  images.length > 0 ? (React.createElement(ImageDisplay, { images: images, variant: imageVariant, alt: title, className: "seekora-suggestions-product-card-image", enableZoom: enableImageZoom, zoomMode: imageZoomMode, zoomLevel: imageZoomLevel })) : (React.createElement("div", { className: "seekora-suggestions-product-card-placeholder", style: imgStyle, "aria-hidden": true })),
102
102
  React.createElement("span", { className: "seekora-suggestions-product-card-title", style: { fontSize: '0.875rem', fontWeight: 500 } }, title),
103
- price != null && !Number.isNaN(price) ? (React.createElement("span", { className: "seekora-suggestions-product-card-price", style: { fontSize: '0.875rem', color: 'var(--seekora-text-secondary, #6b7280)' } },
103
+ price != null && !Number.isNaN(price) ? (React.createElement("span", { className: "seekora-suggestions-product-card-price", style: { fontSize: '0.875rem', color: 'inherit', opacity: 0.6 } },
104
104
  product.currency ?? '$',
105
105
  price.toFixed(2))) : null));
106
106
  }
@@ -23,7 +23,7 @@ const imgPlaceholderStyle = {
23
23
  aspectRatio: '1',
24
24
  objectFit: 'cover',
25
25
  borderRadius: BORDER_RADIUS.sm,
26
- backgroundColor: 'var(--seekora-bg-secondary, #f3f4f6)',
26
+ backgroundColor: 'var(--seekora-bg-secondary, rgba(0,0,0,0.04))',
27
27
  };
28
28
  function ImageBlock({ images, title, imageVariant, aspectRatio, enableZoom, zoomMode, zoomLevel }) {
29
29
  const ar = aspectRatio
@@ -43,7 +43,7 @@ export function MinimalLayout({ images, title, price, product, imageVariant, dis
43
43
  return (React.createElement(React.Fragment, null,
44
44
  React.createElement(ImageBlock, { images: images, title: title, imageVariant: imageVariant, aspectRatio: displayConfig.imageAspectRatio, enableZoom: enableImageZoom, zoomMode: imageZoomMode, zoomLevel: imageZoomLevel }),
45
45
  React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: titleFontSize, fontWeight: 500, lineHeight: 1.4, overflow: 'hidden', textOverflow: 'ellipsis', display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical' } }, title),
46
- price != null && !Number.isNaN(price) && (React.createElement("span", { className: "seekora-product-card__price seekora-suggestions-product-card-price", style: { fontSize: priceFontSize, color: 'var(--seekora-text-secondary, #6b7280)' } },
46
+ price != null && !Number.isNaN(price) && (React.createElement("span", { className: "seekora-product-card__price seekora-suggestions-product-card-price", style: { fontSize: priceFontSize, color: 'inherit', opacity: 0.6 } },
47
47
  product.currency ?? '$',
48
48
  price.toFixed(2)))));
49
49
  }
@@ -63,7 +63,7 @@ export function StandardLayout({ images, title, price, comparePrice, brand, badg
63
63
  cfg.showBadges !== false && badges.length > 0 && (React.createElement(BadgeList, { badges: badges, position: "top-left", maxBadges: 2 })),
64
64
  actionButtons && actionButtons.length > 0 && isOverlayPosition && (React.createElement(ActionButtons, { buttons: actionButtons, position: actionButtonsPosition === 'overlay-top-right' ? 'top-right' : 'bottom-center', showLabels: showActionLabels, size: "small" }))),
65
65
  React.createElement("div", { className: "seekora-product-card__body", style: { display: 'flex', flexDirection: 'column', gap: bodyGap } },
66
- cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: brandFontSize, color: 'var(--seekora-text-secondary, #6b7280)', textTransform: 'uppercase', letterSpacing: '0.02em' } }, brand)),
66
+ cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: brandFontSize, color: 'inherit', opacity: 0.6, textTransform: 'uppercase', letterSpacing: '0.02em' } }, brand)),
67
67
  React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: titleFontSize, fontWeight: 500, lineHeight: 1.4, overflow: 'hidden', textOverflow: 'ellipsis', display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical' } }, title),
68
68
  React.createElement("div", { className: "seekora-product-card__price" },
69
69
  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: priceFontSize } })),
@@ -82,7 +82,7 @@ export function DetailedLayout({ images, title, price, comparePrice, brand, badg
82
82
  cfg.showBadges !== false && badges.length > 0 && (React.createElement(BadgeList, { badges: badges, position: "top-left" })),
83
83
  actionButtons && actionButtons.length > 0 && isOverlayPosition && (React.createElement(ActionButtons, { buttons: actionButtons, position: actionButtonsPosition === 'overlay-top-right' ? 'top-right' : 'bottom-center', showLabels: showActionLabels, size: "small" }))),
84
84
  React.createElement("div", { className: "seekora-product-card__body", style: { display: 'flex', flexDirection: 'column', gap: 4 } },
85
- 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)),
85
+ cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: '0.75rem', color: 'inherit', opacity: 0.6, textTransform: 'uppercase', letterSpacing: '0.02em' } }, brand)),
86
86
  React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: '0.875rem', fontWeight: 500, lineHeight: 1.4, overflow: 'hidden', textOverflow: 'ellipsis' } }, title),
87
87
  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" })),
88
88
  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' } }))),
@@ -104,7 +104,7 @@ export function CompactLayout({ images, title, price, product, imageVariant, dis
104
104
  textOverflow: 'ellipsis',
105
105
  whiteSpace: 'nowrap',
106
106
  } }, title),
107
- price != null && !Number.isNaN(price) && (React.createElement("span", { className: "seekora-product-card__price", style: { fontSize: '0.8125rem', color: 'var(--seekora-text-secondary, #6b7280)' } },
107
+ price != null && !Number.isNaN(price) && (React.createElement("span", { className: "seekora-product-card__price", style: { fontSize: '0.8125rem', color: 'inherit', opacity: 0.6 } },
108
108
  product.currency ?? '$',
109
109
  price.toFixed(2)))));
110
110
  }
@@ -128,7 +128,7 @@ export function HorizontalLayout({ images, title, price, comparePrice, brand, ba
128
128
  cfg.showBadges !== false && badges.length > 0 && (React.createElement(BadgeList, { badges: badges, position: "top-left", maxBadges: 1 })),
129
129
  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" }))),
130
130
  React.createElement("div", { className: "seekora-product-card__body", style: { display: 'flex', flexDirection: 'column', gap: bodyGap, flex: 1, minWidth: 0 } },
131
- cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: brandFontSize, color: 'var(--seekora-text-secondary, #6b7280)', textTransform: 'uppercase' } }, brand)),
131
+ cfg.showBrand !== false && brand && (React.createElement("span", { className: "seekora-product-card__brand", style: { fontSize: brandFontSize, color: 'inherit', opacity: 0.6, textTransform: 'uppercase' } }, brand)),
132
132
  React.createElement("span", { className: "seekora-product-card__title", style: { fontSize: titleFontSize, fontWeight: 500, lineHeight: 1.4, overflow: 'hidden', textOverflow: 'ellipsis', display: '-webkit-box', WebkitLineClamp: isMobile ? 3 : 2, WebkitBoxOrient: 'vertical' } }, title),
133
133
  React.createElement("div", { className: "seekora-product-card__price" },
134
134
  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: priceFontSize } })),
@@ -15,7 +15,7 @@ const itemStyle = {
15
15
  fontSize: 'inherit',
16
16
  fontFamily: 'inherit',
17
17
  backgroundColor: 'transparent',
18
- color: 'var(--seekora-text-primary, #111827)',
18
+ color: 'inherit',
19
19
  transition: 'background-color 120ms ease',
20
20
  };
21
21
  function RecentSearchItem({ search, onSelect }) {
@@ -23,7 +23,7 @@ function RecentSearchItem({ search, onSelect }) {
23
23
  return (React.createElement("li", null,
24
24
  React.createElement("button", { type: "button", className: clsx('seekora-suggestions-recent-item', isHovered && 'seekora-suggestions-recent-item--hover'), style: {
25
25
  ...itemStyle,
26
- ...(isHovered ? { backgroundColor: 'var(--seekora-bg-hover, #f3f4f6)' } : {}),
26
+ ...(isHovered ? { backgroundColor: 'var(--seekora-bg-hover, rgba(0,0,0,0.05))' } : {}),
27
27
  }, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onMouseDown: (e) => {
28
28
  e.preventDefault();
29
29
  onSelect();
@@ -35,7 +35,7 @@ export function RecentSearchesList({ title = 'Recent', maxItems = 8, className,
35
35
  if (items.length === 0)
36
36
  return null;
37
37
  return (React.createElement("div", { className: clsx('seekora-suggestions-recent-list', className), style: style },
38
- title ? (React.createElement("div", { className: "seekora-suggestions-recent-title", style: { padding: '8px 12px', fontSize: '0.75rem', fontWeight: 600, color: 'var(--seekora-text-secondary, #6b7280)', textTransform: 'uppercase' } }, title)) : null,
38
+ title ? (React.createElement("div", { className: "seekora-suggestions-recent-title", style: { padding: '8px 12px', fontSize: '0.75rem', fontWeight: 600, color: 'inherit', opacity: 0.6, textTransform: 'uppercase' } }, title)) : null,
39
39
  React.createElement("ul", { className: clsx('seekora-suggestions-recent-ul', listClassName), style: { margin: 0, padding: 0, listStyle: 'none' } }, items.map((search, i) => {
40
40
  const onSelect = () => selectRecentSearch(search);
41
41
  if (renderItem) {
@@ -94,14 +94,14 @@ export function SearchInput({ placeholder = 'Powered by Seekora', autoFocus = fa
94
94
  }, [setQuery]);
95
95
  return (React.createElement("div", { className: clsx('seekora-suggestions-search-input-wrapper', className), style: { ...defaultStyles, ...style } },
96
96
  React.createElement("div", { className: "seekora-suggestions-input-wrapper", style: inputWrapperStyles },
97
- leftIcon ? (React.createElement("span", { className: "seekora-suggestions-input-left-icon", style: { display: 'flex', flexShrink: 0, color: 'var(--seekora-text-secondary, #6b7280)' } }, leftIcon)) : null,
97
+ leftIcon ? (React.createElement("span", { className: "seekora-suggestions-input-left-icon", style: { display: 'flex', flexShrink: 0, color: 'inherit', opacity: 0.5 } }, leftIcon)) : null,
98
98
  React.createElement("input", { ref: inputRef, type: "text", value: query, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, placeholder: placeholder, autoFocus: autoFocus, autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: false, "aria-label": ariaLabel, "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-autocomplete": "list", role: "combobox", className: clsx('seekora-suggestions-input', inputClassName), style: { ...inputStyles, ...inputStyle } }),
99
99
  showClearButton && query ? (React.createElement("button", { type: "button", onClick: handleClear, className: "seekora-suggestions-input-clear", "aria-label": "Clear search", style: {
100
100
  padding: 8,
101
101
  border: 'none',
102
102
  background: 'transparent',
103
103
  cursor: 'pointer',
104
- color: 'var(--seekora-text-secondary, #6b7280)',
104
+ color: 'inherit', opacity: 0.5,
105
105
  display: 'flex',
106
106
  alignItems: 'center',
107
107
  justifyContent: 'center',
@@ -19,7 +19,7 @@ const defaultItemStyle = {
19
19
  fontSize: 'inherit',
20
20
  fontFamily: 'inherit',
21
21
  backgroundColor: 'transparent',
22
- color: 'var(--seekora-text-primary, #111827)',
22
+ color: 'inherit',
23
23
  transition: 'background-color 120ms ease',
24
24
  overflow: 'hidden',
25
25
  textOverflow: 'ellipsis',
@@ -36,12 +36,12 @@ export function SuggestionItem({ suggestion, index, isActive, onSelect, classNam
36
36
  const showHighlight = isActive || isHovered;
37
37
  return (React.createElement("li", { role: "option", "aria-selected": isActive, id: `seekora-suggestion-${index}`, className: clsx('seekora-suggestions-item', isActive && 'seekora-suggestions-item--active', isHovered && 'seekora-suggestions-item--hover', className), style: {
38
38
  ...defaultItemStyle,
39
- ...(showHighlight ? { backgroundColor: 'var(--seekora-bg-hover, #f3f4f6)' } : {}),
39
+ ...(showHighlight ? { backgroundColor: 'var(--seekora-bg-hover, rgba(0,0,0,0.05))' } : {}),
40
40
  ...style,
41
41
  }, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onMouseDown: (e) => {
42
42
  e.preventDefault();
43
43
  onSelect();
44
44
  } },
45
45
  content,
46
- suggestion.count != null ? (React.createElement("span", { className: "seekora-suggestions-item-count", style: { marginLeft: 8, color: 'var(--seekora-text-secondary, #6b7280)', fontSize: '0.875em' } }, suggestion.count)) : null));
46
+ suggestion.count != null ? (React.createElement("span", { className: "seekora-suggestions-item-count", style: { marginLeft: 8, color: 'inherit', opacity: 0.6, fontSize: '0.875em' } }, suggestion.count)) : null));
47
47
  }
@@ -18,6 +18,8 @@ export interface SuggestionsContextValue {
18
18
  recentSearches: RecentSearch[];
19
19
  trendingSearches: TrendingSearch[];
20
20
  trendingProducts: ProductItem[];
21
+ /** Products prefetched on mount via client.search("*") — available before dropdown opens */
22
+ prefetchedProducts: unknown[];
21
23
  filteredTabs: FilteredTab[];
22
24
  activeTabId: string;
23
25
  setActiveTabId: (id: string) => void;
@@ -31,6 +33,7 @@ export interface SuggestionsContextValue {
31
33
  selectTrendingSearch: (trending: TrendingSearch, position: number) => void;
32
34
  setActiveTab: (tab: FilteredTab) => void;
33
35
  submitSearch: (query: string, fromSuggestion?: boolean, suggestion?: SuggestionItem) => void;
36
+ clearRecentSearches: () => void;
34
37
  close: () => void;
35
38
  navigateNext: () => void;
36
39
  navigatePrev: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"SuggestionsContext.d.ts","sourceRoot":"","sources":["../../../src/components/suggestions-primitives/SuggestionsContext.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAE7E,MAAM,WAAW,uBAAuB;IAEtC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,cAAc,EAAE,YAAY,EAAE,CAAC;IAC/B,gBAAgB,EAAE,cAAc,EAAE,CAAC;IACnC,gBAAgB,EAAE,W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AM,CAAA;KAAE,CAAC,CAAC;IACrE,4BAA4B;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1D,0CAA0C;IAC1C,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CACjD;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,cAAkB,EAClB,UAAgB,EAChB,cAAmB,EACnB,8BAAqC,EACrC,YAAY,EACZ,eAAsB,EACtB,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,cAAc,GACf,EAAE,wBAAwB,qBA8O1B"}
1
+ {"version":3,"file":"SuggestionsProvider.d.ts","sourceRoot":"","sources":["../../../src/components/suggestions-primitives/SuggestionsProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAMN,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAA6C,MAAM,0BAA0B,CAAC;AAGvH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,4CAA4C;IAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kEAAkE;IAClE,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC,2BAA2B;IAC3B,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,4BAA4B;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1D,0CAA0C;IAC1C,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CACjD;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,cAAkB,EAClB,UAAgB,EAChB,cAAmB,EACnB,8BAAqC,EACrC,YAAY,EACZ,eAAsB,EACtB,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,cAAc,GACf,EAAE,wBAAwB,qBAoR1B"}
@@ -16,10 +16,28 @@ export function SuggestionsProvider({ children, minQueryLength = 1, debounceMs =
16
16
  const [isOpen, setIsOpenState] = useState(false);
17
17
  const [activeIndex, setActiveIndex] = useState(-1);
18
18
  const [activeTabId, setActiveTabId] = useState('');
19
+ const [prefetchedProducts, setPrefetchedProducts] = useState([]);
20
+ // Prefetch product results on mount so they're available instantly when dropdown opens
21
+ const prefetchedProductsRef = useRef(false);
22
+ useEffect(() => {
23
+ if (prefetchedProductsRef.current || !client?.search)
24
+ return;
25
+ prefetchedProductsRef.current = true;
26
+ client.search('*', { per_page: 12, page: 1 })
27
+ .then((res) => {
28
+ const data = res?.data;
29
+ const items = data?.results || data?.data || res?.results || res?.hits || [];
30
+ if (Array.isArray(items) && items.length > 0) {
31
+ setPrefetchedProducts(items);
32
+ }
33
+ })
34
+ .catch(() => { });
35
+ }, [client]);
19
36
  const suggestionsData = useQuerySuggestionsEnhanced({
20
37
  client,
21
38
  query,
22
39
  enabled: isOpen,
40
+ prefetch: minQueryLength === 0,
23
41
  minQueryLength,
24
42
  debounceMs,
25
43
  maxSuggestions,
@@ -37,7 +55,22 @@ export function SuggestionsProvider({ children, minQueryLength = 1, debounceMs =
37
55
  trackClicks: true,
38
56
  trackImpressions: true,
39
57
  });
40
- const { suggestions, recentSearches, trendingSearches, trendingProducts, filteredTabs: filteredTabsData, loading, error, hasContent, getAllNavigableItems, addRecentSearch, } = suggestionsData;
58
+ const { suggestions, recentSearches, trendingSearches, trendingProducts, filteredTabs: filteredTabsData, loading, error, hasContent, getAllNavigableItems, addRecentSearch, clearRecentSearches, } = suggestionsData;
59
+ // Wrap getAllNavigableItems to include prefetchedProducts when trendingProducts is empty
60
+ const getAllNavigableItemsWithPrefetched = useCallback(() => {
61
+ const items = getAllNavigableItems();
62
+ // If there are already product items in the list, return as-is
63
+ if (items.some(i => i.type === 'product'))
64
+ return items;
65
+ // Otherwise append prefetchedProducts as navigable product items
66
+ if (prefetchedProducts.length > 0) {
67
+ let idx = items.length;
68
+ prefetchedProducts.forEach(product => {
69
+ items.push({ type: 'product', index: idx++, data: product });
70
+ });
71
+ }
72
+ return items;
73
+ }, [getAllNavigableItems, prefetchedProducts]);
41
74
  const onSearchRef = useRef(onSearch);
42
75
  const onSuggestionSelectRef = useRef(onSuggestionSelect);
43
76
  const onProductClickRef = useRef(onProductClick);
@@ -115,19 +148,19 @@ export function SuggestionsProvider({ children, minQueryLength = 1, debounceMs =
115
148
  onSearchRef.current?.(trimmed);
116
149
  }, [analytics, addRecentSearch, close]);
117
150
  const navigateNext = useCallback(() => {
118
- const items = getAllNavigableItems();
151
+ const items = getAllNavigableItemsWithPrefetched();
119
152
  if (items.length === 0)
120
153
  return;
121
154
  setActiveIndex((i) => (i < items.length - 1 ? i + 1 : 0));
122
- }, [getAllNavigableItems]);
155
+ }, [getAllNavigableItemsWithPrefetched]);
123
156
  const navigatePrev = useCallback(() => {
124
- const items = getAllNavigableItems();
157
+ const items = getAllNavigableItemsWithPrefetched();
125
158
  if (items.length === 0)
126
159
  return;
127
160
  setActiveIndex((i) => (i <= 0 ? items.length - 1 : i - 1));
128
- }, [getAllNavigableItems]);
161
+ }, [getAllNavigableItemsWithPrefetched]);
129
162
  const selectActive = useCallback(() => {
130
- const items = getAllNavigableItems();
163
+ const items = getAllNavigableItemsWithPrefetched();
131
164
  if (activeIndex < 0 || activeIndex >= items.length) {
132
165
  submitSearch(query);
133
166
  return;
@@ -149,7 +182,7 @@ export function SuggestionsProvider({ children, minQueryLength = 1, debounceMs =
149
182
  default:
150
183
  submitSearch(query);
151
184
  }
152
- }, [activeIndex, getAllNavigableItems, query, submitSearch, selectSuggestion, selectProduct, selectRecentSearch, selectTrendingSearch]);
185
+ }, [activeIndex, getAllNavigableItemsWithPrefetched, query, submitSearch, selectSuggestion, selectProduct, selectRecentSearch, selectTrendingSearch]);
153
186
  // Impression when open and content changes
154
187
  useEffect(() => {
155
188
  if (!isOpen || !hasContent || !query)
@@ -172,19 +205,21 @@ export function SuggestionsProvider({ children, minQueryLength = 1, debounceMs =
172
205
  recentSearches,
173
206
  trendingSearches,
174
207
  trendingProducts,
208
+ prefetchedProducts,
175
209
  filteredTabs: filteredTabsData,
176
210
  activeTabId,
177
211
  setActiveTabId,
178
212
  loading,
179
213
  error,
180
214
  hasContent,
181
- getAllNavigableItems,
215
+ getAllNavigableItems: getAllNavigableItemsWithPrefetched,
182
216
  selectSuggestion,
183
217
  selectProduct,
184
218
  selectRecentSearch,
185
219
  selectTrendingSearch,
186
220
  setActiveTab,
187
221
  submitSearch,
222
+ clearRecentSearches,
188
223
  close,
189
224
  navigateNext,
190
225
  navigatePrev,
@@ -200,19 +235,21 @@ export function SuggestionsProvider({ children, minQueryLength = 1, debounceMs =
200
235
  recentSearches,
201
236
  trendingSearches,
202
237
  trendingProducts,
238
+ prefetchedProducts,
203
239
  filteredTabsData,
204
240
  activeTabId,
205
241
  setActiveTabId,
206
242
  loading,
207
243
  error,
208
244
  hasContent,
209
- getAllNavigableItems,
245
+ getAllNavigableItemsWithPrefetched,
210
246
  selectSuggestion,
211
247
  selectProduct,
212
248
  selectRecentSearch,
213
249
  selectTrendingSearch,
214
250
  setActiveTab,
215
251
  submitSearch,
252
+ clearRecentSearches,
216
253
  close,
217
254
  navigateNext,
218
255
  navigatePrev,
@@ -15,7 +15,7 @@ const itemStyle = {
15
15
  fontSize: 'inherit',
16
16
  fontFamily: 'inherit',
17
17
  backgroundColor: 'transparent',
18
- color: 'var(--seekora-text-primary, #111827)',
18
+ color: 'inherit',
19
19
  transition: 'background-color 120ms ease',
20
20
  };
21
21
  function TrendingItem({ trending, onSelect }) {
@@ -23,13 +23,13 @@ function TrendingItem({ trending, onSelect }) {
23
23
  return (React.createElement("li", null,
24
24
  React.createElement("button", { type: "button", className: clsx('seekora-suggestions-trending-item', isHovered && 'seekora-suggestions-trending-item--hover'), style: {
25
25
  ...itemStyle,
26
- ...(isHovered ? { backgroundColor: 'var(--seekora-bg-hover, #f3f4f6)' } : {}),
26
+ ...(isHovered ? { backgroundColor: 'var(--seekora-bg-hover, rgba(0,0,0,0.05))' } : {}),
27
27
  }, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onMouseDown: (e) => {
28
28
  e.preventDefault();
29
29
  onSelect();
30
30
  } },
31
31
  trending.query,
32
- trending.count != null ? (React.createElement("span", { style: { marginLeft: 8, color: 'var(--seekora-text-secondary, #6b7280)', fontSize: '0.875em' } }, trending.count)) : null)));
32
+ trending.count != null ? (React.createElement("span", { style: { marginLeft: 8, color: 'inherit', opacity: 0.6, fontSize: '0.875em' } }, trending.count)) : null)));
33
33
  }
34
34
  export function TrendingList({ title = 'Trending', maxItems = 8, className, style, listClassName, renderItem, }) {
35
35
  const { trendingSearches, selectTrendingSearch } = useSuggestionsContext();
@@ -37,7 +37,7 @@ export function TrendingList({ title = 'Trending', maxItems = 8, className, styl
37
37
  if (items.length === 0)
38
38
  return null;
39
39
  return (React.createElement("div", { className: clsx('seekora-suggestions-trending-list', className), style: style },
40
- title ? (React.createElement("div", { className: "seekora-suggestions-trending-title", style: { padding: '8px 12px', fontSize: '0.75rem', fontWeight: 600, color: 'var(--seekora-text-secondary, #6b7280)', textTransform: 'uppercase' } }, title)) : null,
40
+ title ? (React.createElement("div", { className: "seekora-suggestions-trending-title", style: { padding: '8px 12px', fontSize: '0.75rem', fontWeight: 600, color: 'inherit', opacity: 0.6, textTransform: 'uppercase' } }, title)) : null,
41
41
  React.createElement("ul", { className: clsx('seekora-suggestions-trending-ul', listClassName), style: { margin: 0, padding: 0, listStyle: 'none' } }, items.map((trending, i) => {
42
42
  const onSelect = () => selectTrendingSearch(trending, i);
43
43
  if (renderItem) {
@@ -17,6 +17,8 @@ export interface UseQuerySuggestionsEnhancedOptions {
17
17
  query: string;
18
18
  /** Enable/disable the hook */
19
19
  enabled?: boolean;
20
+ /** Prefetch initial (empty-query) data on mount even if not enabled yet */
21
+ prefetch?: boolean;
20
22
  /** Debounce delay in ms */
21
23
  debounceMs?: number;
22
24
  /** Max suggestions to fetch */
@@ -1 +1 @@
1
- {"version":3,"file":"useQuerySuggestionsEnhanced.d.ts","sourceRoot":"","sources":["../../src/hooks/useQuerySuggestionsEnhanced.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAgC,MAAM,wBAAwB,CAAC;AAE1F,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,uBAAuB,EACvB,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,SAAS,EACT,aAAa,EACb,YAAY,EACZ,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,kCAAkC;IACjD,8BAA8B;IAC9B,MAAM,EAAE,aAAa,CAAC;IACtB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,cAAc,CAA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GAAG,WAAW,CAAC;CACtH;AA8FD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,kCAAkC,GAC1C,iCAAiC,CA8YnC;AAED,eAAe,2BAA2B,CAAC"}
@@ -97,7 +97,7 @@ function transformFilteredTab(raw) {
97
97
  // Main Hook
98
98
  // ============================================================================
99
99
  export function useQuerySuggestionsEnhanced(options) {
100
- const { client, query, enabled = true, debounceMs = 200, maxSuggestions = 10, minQueryLength = 1, includeDropdownRecommendations = false, includeDropdownProductList = true, includeFilteredTabs = true, includeCategories = true, includeFacets = true, // CHANGED: Enable facets by default
100
+ const { client, query, enabled = true, prefetch = false, debounceMs = 200, maxSuggestions = 10, minQueryLength = 1, includeDropdownRecommendations = false, includeDropdownProductList = true, includeFilteredTabs = true, includeCategories = true, includeFacets = true, // CHANGED: Enable facets by default
101
101
  maxCategories = 3, maxFacets = 5, filteredTabs, minPopularity, timeRange, disableTypoTolerance, analyticsTags, enableRecentSearches = true, maxRecentSearches = MAX_RECENT_SEARCHES_DEFAULT, recentSearchesKey = RECENT_SEARCHES_DEFAULT_KEY, onSuggestionsLoaded, onError, } = options;
102
102
  // State
103
103
  const [suggestions, setSuggestions] = useState([]);
@@ -270,17 +270,41 @@ export function useQuerySuggestionsEnhanced(options) {
270
270
  onSuggestionsLoaded,
271
271
  onError,
272
272
  ]);
273
+ // Prefetch: fire initial empty-query fetch once client is ready (before dropdown opens)
274
+ const prefetchedRef = useRef(false);
275
+ useEffect(() => {
276
+ if (!prefetch || prefetchedRef.current)
277
+ return;
278
+ if (minQueryLength > 0)
279
+ return;
280
+ if (!client?.getSuggestions)
281
+ return;
282
+ prefetchedRef.current = true;
283
+ fetchSuggestions('');
284
+ }, [prefetch, client, minQueryLength, fetchSuggestions]);
273
285
  // Debounced fetch effect
274
286
  useEffect(() => {
275
287
  if (debounceTimerRef.current) {
276
288
  clearTimeout(debounceTimerRef.current);
277
289
  }
278
290
  if (!enabled || query.length < minQueryLength) {
291
+ // Don't clear prefetched data when dropdown is closed
292
+ if (prefetch && prefetchedRef.current && query === '') {
293
+ // Keep prefetched data intact
294
+ setLoading(false);
295
+ setError(null);
296
+ return;
297
+ }
279
298
  setSuggestions([]);
299
+ setDropdownRecommendations(null);
280
300
  setLoading(false);
281
301
  setError(null);
282
302
  return;
283
303
  }
304
+ // When dropdown opens with empty query and we already have prefetched data, skip re-fetch
305
+ if (prefetch && prefetchedRef.current && query === '') {
306
+ return;
307
+ }
284
308
  setLoading(true);
285
309
  debounceTimerRef.current = setTimeout(() => {
286
310
  fetchSuggestions(query);
@@ -290,7 +314,7 @@ export function useQuerySuggestionsEnhanced(options) {
290
314
  clearTimeout(debounceTimerRef.current);
291
315
  }
292
316
  };
293
- }, [query, enabled, minQueryLength, debounceMs, fetchSuggestions]);
317
+ }, [query, enabled, prefetch, minQueryLength, debounceMs, fetchSuggestions]);
294
318
  // Recent search management
295
319
  const addRecentSearch = useCallback((searchQuery, resultsCount) => {
296
320
  if (!enableRecentSearches || !searchQuery.trim())