@akinon/pz-similar-products 1.92.0-rc.27 → 1.92.0-snapshot-ZERO-3457-20250627121541

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 CHANGED
@@ -1,45 +1,7 @@
1
1
  # @akinon/pz-similar-products
2
2
 
3
- ## 1.92.0-rc.27
3
+ ## 1.92.0-snapshot-ZERO-3457-20250627121541
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - d606f4a: ZERO-3481: Add locale and currency to list endpoint
8
-
9
- ## 1.92.0-rc.26
10
-
11
- ## 1.92.0-rc.25
12
-
13
- ## 1.92.0-rc.24
14
-
15
- ## 1.92.0-rc.23
16
-
17
- ## 1.92.0-rc.22
18
-
19
- ### Minor Changes
20
-
21
- - 143be2b: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
22
-
23
- ## 1.92.0-rc.21
24
-
25
- ### Minor Changes
26
-
27
- - d99a6a7: ZERO-3457: Fixed the settings prop and made sure everything is customizable.
28
-
29
- ## 1.92.0-rc.20
30
-
31
- ### Minor Changes
32
-
33
- - 8b1d24e: ZERO-3422: Update fetch method to use dynamic request method in wallet complete redirection middleware
34
-
35
- ## 1.92.0-rc.19
36
-
37
- ### Minor Changes
38
-
39
- - d8be48f: ZERO-3422: Update fetch method to use dynamic request method in wallet complete redirection middleware
40
-
41
- ## 1.92.0-rc.18
42
-
43
- ## 1.92.0-rc.17
44
-
45
- ## 1.92.0-rc.16
7
+ - d99a6a7: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
package/README.md CHANGED
@@ -272,18 +272,6 @@ interface SimilarProductsSettings {
272
272
  mobileActiveFilters?: string;
273
273
  mobileActiveFilterTag?: string;
274
274
  mobileClearAllButton?: string;
275
-
276
- // New crop-related custom styles
277
- cropComponent?: string;
278
- cropImage?: string;
279
- cropImageActive?: string;
280
- cropImageNonCropping?: string;
281
- cropImageContainer?: string;
282
- cropOverlay?: string;
283
- cropSelection?: string;
284
- cropSelectionBorder?: string;
285
- cropOverlayBackground?: string;
286
- cropSelectionHighlight?: string;
287
275
  };
288
276
 
289
277
  // 25+ render functions for granular control
@@ -569,18 +557,7 @@ const settings = {
569
557
  productItem: 'hover:scale-105 transition-all duration-300 shadow-lg',
570
558
  filterSidebar: 'bg-gradient-to-b from-gray-50 to-white',
571
559
  paginationButton: 'rounded-full px-4 py-2 bg-blue-600 text-white',
572
- activeFilterTag: 'bg-blue-100 text-blue-800 px-3 py-1 rounded-full',
573
-
574
- // Advanced crop styling
575
- cropComponent: 'border-2 border-dashed border-blue-300 rounded-lg',
576
- cropImage: 'rounded-lg shadow-md',
577
- cropImageActive: 'brightness-110 contrast-110',
578
- cropImageNonCropping: 'hover:scale-105 transition-transform',
579
- cropImageContainer: 'bg-gray-50 rounded-lg p-2',
580
- cropOverlay: 'backdrop-blur-sm',
581
- cropOverlayBackground: 'bg-black/60',
582
- cropSelection: 'border-4 border-blue-500',
583
- cropSelectionHighlight: 'shadow-2xl shadow-blue-500/50'
560
+ activeFilterTag: 'bg-blue-100 text-blue-800 px-3 py-1 rounded-full'
584
561
  }
585
562
  };
586
563
  ```
@@ -1513,7 +1490,6 @@ const hybridAdvancedSettings = {
1513
1490
  - `filterSidebar`, `filterSidebarMobileHeader`, `filterGroup`, `filterGroupTitle`, `filterGroupContent`
1514
1491
  - `filterItem`, `filterItemInput`, `filterItemLabel`, `filterItemCount`
1515
1492
  - `imageSection`, `imageContainer`, `imageWrapper`, `cropButton`, `tickButton`, `uploadButton`, `resetButton`, `errorMessage`, `cropControls`
1516
- - `cropComponent`, `cropImage`, `cropImageActive`, `cropImageNonCropping`, `cropImageContainer`, `cropOverlay`, `cropSelection`, `cropSelectionBorder`, `cropOverlayBackground`, `cropSelectionHighlight`
1517
1493
  - `mobileActiveFilters`, `mobileActiveFilterTag`, `mobileClearAllButton`
1518
1494
 
1519
1495
  **Products & Results:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-similar-products",
3
- "version": "1.92.0-rc.27",
3
+ "version": "1.92.0-snapshot-ZERO-3457-20250627121541",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "peerDependencies": {
@@ -874,14 +874,6 @@ export function useSimilarProducts(product: Product) {
874
874
  setFileError('');
875
875
  }, []);
876
876
 
877
- const clearResults = useCallback(() => {
878
- setSearchResults(null);
879
- setResultsKey(0);
880
- setLastProductIds([]);
881
- setAllLoadedProducts([]);
882
- setLoadedPages(new Set([1]));
883
- }, []);
884
-
885
877
  const clearFileInput = useCallback(
886
878
  (fileInputRef: React.RefObject<HTMLInputElement>) => {
887
879
  if (fileInputRef.current) {
@@ -948,7 +940,6 @@ export function useSimilarProducts(product: Product) {
948
940
  loadedPages: Array.from(loadedPages),
949
941
  allLoadedProducts,
950
942
  clearError,
951
- clearResults,
952
943
  clearFileInput
953
944
  };
954
945
  }
@@ -357,19 +357,6 @@ export interface SimilarProductsSettings {
357
357
  errorMessage?: string;
358
358
  cropControls?: string;
359
359
 
360
- // Detailed crop styling
361
- cropComponent?: string;
362
- cropImage?: string;
363
- cropImageActive?: string;
364
- cropOverlay?: string;
365
- cropSelection?: string;
366
- cropSelectionBorder?: string;
367
- cropImageNonCropping?: string;
368
- cropImageContainer?: string;
369
- cropImageWrapper?: string;
370
- cropOverlayBackground?: string;
371
- cropSelectionHighlight?: string;
372
-
373
360
  resultsContainer?: string;
374
361
  gridContainer?: string;
375
362
  productItem?: string;
@@ -445,10 +445,7 @@ export function SimilarProductsFilterSidebar({
445
445
  onDragEnd={() => {}}
446
446
  ruleOfThirds={false}
447
447
  aspect={settings?.cropAspectRatio}
448
- className={twMerge(
449
- 'slider-crop',
450
- settings?.customStyles?.cropComponent
451
- )}
448
+ className="slider-crop"
452
449
  disabled={isLoading}
453
450
  keepSelection={true}
454
451
  >
@@ -456,45 +453,22 @@ export function SimilarProductsFilterSidebar({
456
453
  ref={imageRef}
457
454
  src={currentImageUrl || ''}
458
455
  alt={product?.name || 'Product image'}
459
- className={twMerge(
460
- 'max-w-full max-h-[200px] md:max-h-[280px]',
461
- settings?.customStyles?.cropImage,
462
- settings?.customStyles?.cropImageActive
463
- )}
456
+ className="max-w-full max-h-[200px] md:max-h-[280px]"
464
457
  style={{ transform: `scale(1) rotate(0deg)` }}
465
458
  />
466
459
  </ReactCrop>
467
460
  ) : (
468
- <div
469
- className={twMerge(
470
- 'relative w-full h-full flex items-center justify-center',
471
- settings?.customStyles?.cropImageContainer
472
- )}
473
- >
461
+ <div className="relative w-full h-full flex items-center justify-center">
474
462
  <img
475
463
  ref={imageRef}
476
464
  src={currentImageUrl || ''}
477
465
  alt={product?.name || 'Product image'}
478
- className={twMerge(
479
- 'max-w-full max-h-[200px] md:max-h-[280px] object-contain',
480
- settings?.customStyles?.cropImage,
481
- settings?.customStyles?.cropImageNonCropping
482
- )}
466
+ className="max-w-full max-h-[200px] md:max-h-[280px] object-contain"
483
467
  />
484
468
  {!isCropping && completedCrop && (
485
- <div
486
- className={twMerge(
487
- 'hidden md:block absolute inset-0 bg-black bg-opacity-50 transition-opacity duration-300 ease-in-out',
488
- settings?.customStyles?.cropOverlay,
489
- settings?.customStyles?.cropOverlayBackground
490
- )}
491
- >
469
+ <div className="hidden md:block absolute inset-0 bg-black bg-opacity-50 transition-opacity duration-300 ease-in-out">
492
470
  <div
493
- className={twMerge(
494
- 'absolute transition-all duration-300 ease-in-out',
495
- settings?.customStyles?.cropSelection,
496
- settings?.customStyles?.cropSelectionHighlight
497
- )}
471
+ className="absolute transition-all duration-300 ease-in-out"
498
472
  style={{
499
473
  width: `${completedCrop.width}px`,
500
474
  height: `${completedCrop.height}px`,
@@ -56,8 +56,7 @@ export function SimilarProductsPlugin({
56
56
  loadedPages,
57
57
  fetchSimilarProductsByImageUrl,
58
58
  fetchSimilarProductsByImageCrop,
59
- clearError,
60
- clearResults
59
+ clearError
61
60
  } = useSimilarProducts(product);
62
61
 
63
62
  const {
@@ -109,7 +108,6 @@ export function SimilarProductsPlugin({
109
108
  if (!isOpen) {
110
109
  setHasInitialSearchDone(false);
111
110
  clearError();
112
- clearResults();
113
111
  }
114
112
  }, [
115
113
  isOpen,
@@ -117,8 +115,7 @@ export function SimilarProductsPlugin({
117
115
  activeIndex,
118
116
  hasUploadedImage,
119
117
  hasInitialSearchDone,
120
- clearError,
121
- clearResults
118
+ clearError
122
119
  ]);
123
120
 
124
121
  useEffect(() => {
@@ -145,11 +142,6 @@ export function SimilarProductsPlugin({
145
142
  }
146
143
  };
147
144
 
148
- const handleModalClose = () => {
149
- resetCrop();
150
- onClose();
151
- };
152
-
153
145
  const ModalComponent =
154
146
  settings.customRenderers?.Modal || SimilarProductsModal;
155
147
  const ImageSearchModalComponent =
@@ -159,7 +151,7 @@ export function SimilarProductsPlugin({
159
151
  <>
160
152
  <ModalComponent
161
153
  isOpen={isOpen}
162
- onClose={handleModalClose}
154
+ onClose={onClose}
163
155
  searchResults={searchResults}
164
156
  resultsKey={resultsKey}
165
157
  isLoading={isLoading}
@@ -526,14 +526,10 @@ export function SimilarProductsResultsGrid({
526
526
  );
527
527
  };
528
528
 
529
- if (isLoading && (!searchResults || !searchResults.products?.length)) {
529
+ if (isLoading && (!searchResults || !searchResults.products)) {
530
530
  return renderLoadingState();
531
531
  }
532
532
 
533
- if (!isLoading && searchResults && searchResults.products?.length === 0) {
534
- return renderEmptyState();
535
- }
536
-
537
533
  const renderLoadingOverlay = () => {
538
534
  if (settings?.customRenderers?.render?.resultsGrid?.renderLoadingOverlay) {
539
535
  return settings.customRenderers.render.resultsGrid.renderLoadingOverlay();
@@ -589,14 +585,16 @@ export function SimilarProductsResultsGrid({
589
585
  <div className={gridClassName}>
590
586
  {isLoading &&
591
587
  searchResults &&
592
- searchResults.products?.length > 0 &&
588
+ searchResults.products &&
593
589
  renderLoadingOverlay()}
594
590
 
595
- {searchResults && searchResults.products?.length > 0 && (
591
+ {searchResults && searchResults.products?.length > 0 ? (
596
592
  <div className={resultsContainerClassName}>
597
593
  {renderGridContainer()}
598
594
  {renderPagination()}
599
595
  </div>
596
+ ) : (
597
+ renderEmptyState()
600
598
  )}
601
599
  </div>
602
600
  );
@@ -326,10 +326,6 @@ export function SimilarProductsModal({
326
326
  };
327
327
 
328
328
  const renderSortDropdown = () => {
329
- if (!searchResults?.products?.length || !searchResults?.sorters?.length) {
330
- return null;
331
- }
332
-
333
329
  if (settings?.customRenderers?.render?.modal?.renderSortDropdown) {
334
330
  return settings.customRenderers.render.modal.renderSortDropdown({
335
331
  sorters: searchResults?.sorters || [],