@thefittingroom/shop-ui 3.0.0-alpha-13 → 3.0.0-alpha-15

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.
@@ -51,6 +51,7 @@ export declare class SizeRecComponent {
51
51
  private init;
52
52
  private setElements;
53
53
  private bindEvents;
54
+ private _preloadNeighborVTO;
54
55
  private onSizeRecSelectClick;
55
56
  private renderSizeRec;
56
57
  private renderSizeRecTable;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v3.0.0-alpha-13 (2025-04-18T19:25:18.466Z)
2
+ * thefittingroom v3.0.0-alpha-14 (2025-06-30T17:08:48.412Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  function loadImageRecursive(imageURL, imageURLs) {
@@ -27621,18 +27621,30 @@ class SizeRecComponent {
27621
27621
  try {
27622
27622
  // Get all size buttons
27623
27623
  const allSizeButtons = Array.from(document.querySelectorAll('.tfr-size-rec-select-button'));
27624
- // Request frames for all sizes concurrently
27625
- await Promise.all(allSizeButtons.map(async (button) => {
27626
- const sizeId = Number(button.getAttribute('data-size-id'));
27627
- if (Number.isNaN(sizeId))
27628
- return;
27629
- // Only display the active size, others are just requested
27630
- const shouldDisplay = button === activeButton;
27631
- await this.onTryOnClick(this.styleId, sizeId, shouldDisplay);
27632
- }));
27624
+ const activeIndex = allSizeButtons.indexOf(activeButton);
27625
+ if (this.styleId !== null) {
27626
+ // 1. Fetch and display the VTO for the active (recommended) size
27627
+ try {
27628
+ await this.onTryOnClick(this.styleId, selectedSizeId, true);
27629
+ }
27630
+ catch (e) {
27631
+ console.error(`Error trying on active size ${selectedSizeId}:`, e);
27632
+ // Optionally, inform the user about the error for the primary VTO
27633
+ }
27634
+ // 2. Fetch VTO for the size to the left (if it exists)
27635
+ if (activeIndex > 0) {
27636
+ const leftButton = allSizeButtons[activeIndex - 1];
27637
+ await this._preloadNeighborVTO(leftButton);
27638
+ }
27639
+ // 3. Fetch VTO for the size to the right (if it exists)
27640
+ if (activeIndex >= 0 && activeIndex < allSizeButtons.length - 1) {
27641
+ const rightButton = allSizeButtons[activeIndex + 1];
27642
+ await this._preloadNeighborVTO(rightButton);
27643
+ }
27644
+ }
27633
27645
  }
27634
27646
  catch (error) {
27635
- console.error('Error during try-on:', error);
27647
+ console.error('Error during sequential try-on process:', error);
27636
27648
  }
27637
27649
  finally {
27638
27650
  // Reset loading state
@@ -27642,6 +27654,21 @@ class SizeRecComponent {
27642
27654
  }
27643
27655
  });
27644
27656
  }
27657
+ async _preloadNeighborVTO(buttonElement) {
27658
+ var _a;
27659
+ // this.styleId is assumed to be non-null here because the calling context (bindEvents)
27660
+ // is wrapped in 'if (this.styleId !== null)'
27661
+ const sizeId = Number(buttonElement.getAttribute('data-size-id'));
27662
+ if (!Number.isNaN(sizeId)) {
27663
+ try {
27664
+ await this.onTryOnClick(this.styleId, sizeId, false);
27665
+ }
27666
+ catch (e) {
27667
+ const buttonText = ((_a = buttonElement.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || 'N/A';
27668
+ console.error(`Error pre-loading try-on for size ${sizeId} (button: ${buttonText}):`, e);
27669
+ }
27670
+ }
27671
+ }
27645
27672
  onSizeRecSelectClick(e) {
27646
27673
  const target = e.target;
27647
27674
  if (!target.classList.contains('tfr-size-rec-select-button') || target.classList.contains('tfr-disabled'))
@@ -27900,10 +27927,10 @@ class TfrSizeRec {
27900
27927
  if (!sizeRec)
27901
27928
  return null;
27902
27929
  return {
27903
- recommended: sizeRec.recommended_size.size_value.size,
27930
+ recommended: sizeRec.recommended_size.size_value.name,
27904
27931
  sizes: sizeRec.fits.map((fit) => {
27905
27932
  return {
27906
- size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).size_value.size,
27933
+ size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).size_value.name,
27907
27934
  size_id: fit.size_id,
27908
27935
  locations: fit.measurement_location_fits
27909
27936
  .map((locationFit) => {