@primestyleai/tryon 5.8.12 → 5.8.14

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.
@@ -6831,50 +6831,71 @@ function SectionDetailView({
6831
6831
  }, [section, sizeColIdx, sizeHeader]);
6832
6832
  const displaySize = selectedSize || recSize;
6833
6833
  const isRecommended = displaySize === recSize;
6834
- const chartRangeFor = useCallback((measurement, size) => {
6835
- const b = measurement.toLowerCase().trim();
6836
- const preferCm = unitLbl === "cm" || unitLbl === "";
6837
- let mc = -1;
6834
+ const columnUnits = useMemo(() => {
6835
+ const units = [];
6838
6836
  for (let i = 0; i < section.headers.length; i++) {
6839
- const a = section.headers[i].toLowerCase().trim();
6840
- if (a === b) {
6841
- mc = i;
6842
- break;
6837
+ const h = (section.headers[i] || "").toLowerCase();
6838
+ if (/\(cm\)|centimeter/i.test(h)) {
6839
+ units.push("cm");
6840
+ continue;
6843
6841
  }
6844
- if (a.includes(b) || b.includes(a.replace(/\s*\(.*?\)\s*/g, "").trim())) {
6845
- const hasCm = /\(cm\)|centimeter/i.test(a);
6846
- const hasIn = /\(in\)|inch/i.test(a);
6847
- if (preferCm && hasCm) {
6848
- mc = i;
6842
+ if (/\(in\)|\(inch|inch/i.test(h)) {
6843
+ units.push("in");
6844
+ continue;
6845
+ }
6846
+ let inferred = null;
6847
+ for (const row of section.rows) {
6848
+ const cell = String(cellValFn(row, i, section.headers[i]) || "").trim();
6849
+ if (!cell) continue;
6850
+ if (/cm\b|centimeter/i.test(cell)) {
6851
+ inferred = "cm";
6849
6852
  break;
6850
6853
  }
6851
- if (!preferCm && hasIn) {
6852
- mc = i;
6854
+ if (/in\b|inch|"$/i.test(cell)) {
6855
+ inferred = "in";
6853
6856
  break;
6854
6857
  }
6855
- if (mc < 0) mc = i;
6858
+ }
6859
+ units.push(inferred);
6860
+ }
6861
+ return units;
6862
+ }, [section]);
6863
+ const chartRangeFor = useCallback((measurement, size) => {
6864
+ const b = measurement.toLowerCase().trim();
6865
+ const preferCm = unitLbl === "cm" || unitLbl === "";
6866
+ const wantUnit = preferCm ? "cm" : "in";
6867
+ const candidates = [];
6868
+ for (let i = 0; i < section.headers.length; i++) {
6869
+ const a = (section.headers[i] || "").toLowerCase().trim();
6870
+ if (a === b) {
6871
+ candidates.push(i);
6872
+ continue;
6873
+ }
6874
+ const aBare = a.replace(/\s*\(.*?\)\s*/g, "").trim();
6875
+ if (aBare === b || a.includes(b) || b.includes(aBare)) {
6876
+ candidates.push(i);
6856
6877
  }
6857
6878
  }
6858
- if (mc < 0) return null;
6879
+ if (candidates.length === 0) return null;
6880
+ let mc = candidates.find((i) => columnUnits[i] === wantUnit);
6881
+ if (mc == null) mc = candidates[0];
6859
6882
  const mHeader = section.headers[mc];
6860
6883
  const row = section.rows.find((r) => cellValFn(r, sizeColIdx, sizeHeader) === size);
6861
6884
  if (!row) return null;
6862
6885
  const val = cellValFn(row, mc, mHeader);
6863
6886
  if (!val) return null;
6864
6887
  const parsed = pRangeFn(val);
6865
- const colHdr = section.headers[mc].toLowerCase();
6866
- const colIsInch = /\(in\)|inch/i.test(colHdr);
6867
- const colIsCm = /\(cm\)|centimeter/i.test(colHdr);
6868
- if (colIsInch && preferCm) {
6888
+ const colUnit = columnUnits[mc];
6889
+ if (colUnit === "in" && preferCm) {
6869
6890
  const toCm = (v) => +(v * 2.54).toFixed(1);
6870
6891
  return { range: String(toCm(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toCm(parsed.max)) : ""), min: toCm(parsed.min), max: toCm(parsed.max) };
6871
6892
  }
6872
- if (colIsCm && !preferCm) {
6893
+ if (colUnit === "cm" && !preferCm) {
6873
6894
  const toIn = (v) => +(v / 2.54).toFixed(1);
6874
6895
  return { range: String(toIn(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toIn(parsed.max)) : ""), min: toIn(parsed.min), max: toIn(parsed.max) };
6875
6896
  }
6876
6897
  return { range: val, ...parsed };
6877
- }, [section, sizeColIdx, sizeHeader, unitLbl]);
6898
+ }, [section, sizeColIdx, sizeHeader, unitLbl, columnUnits]);
6878
6899
  const fitRows = useMemo(() => {
6879
6900
  const mainDetails = sectionResult?.matchDetails || [];
6880
6901
  const lengthDetails = lengthEntry?.secResult?.matchDetails || [];
@@ -7321,40 +7342,73 @@ function SizeResultView({
7321
7342
  if (sizeColIdx < 0 || !sizeGuide?.rows) return [];
7322
7343
  return sizeGuide.rows.map((r) => cellVal(r, sizeColIdx, sizeHeader)).filter(Boolean);
7323
7344
  }, [sizeGuide, sizeColIdx, sizeHeader, cellVal]);
7345
+ const sizeGuideColumnUnits = useMemo(() => {
7346
+ if (!sizeGuide?.headers || !sizeGuide?.rows) return [];
7347
+ const units = [];
7348
+ for (let i = 0; i < sizeGuide.headers.length; i++) {
7349
+ const h = (sizeGuide.headers[i] || "").toLowerCase();
7350
+ if (/\(cm\)|centimeter/i.test(h)) {
7351
+ units.push("cm");
7352
+ continue;
7353
+ }
7354
+ if (/\(in\)|\(inch|inch/i.test(h)) {
7355
+ units.push("in");
7356
+ continue;
7357
+ }
7358
+ let inferred = null;
7359
+ for (const row of sizeGuide.rows) {
7360
+ const cell = String(cellVal(row, i, sizeGuide.headers[i]) || "").trim();
7361
+ if (!cell) continue;
7362
+ if (/cm\b|centimeter/i.test(cell)) {
7363
+ inferred = "cm";
7364
+ break;
7365
+ }
7366
+ if (/in\b|inch|"$/i.test(cell)) {
7367
+ inferred = "in";
7368
+ break;
7369
+ }
7370
+ }
7371
+ units.push(inferred);
7372
+ }
7373
+ return units;
7374
+ }, [sizeGuide, cellVal]);
7324
7375
  const chartRangeFor = useCallback((measurement, size) => {
7325
7376
  if (!sizeGuide?.headers || !sizeGuide?.rows || sizeColIdx < 0) return null;
7326
7377
  const b = measurement.toLowerCase().trim();
7327
7378
  const preferCm = unitLbl === "cm" || unitLbl === "";
7328
- let mc = -1;
7379
+ const wantUnit = preferCm ? "cm" : "in";
7380
+ const candidates = [];
7329
7381
  for (let i = 0; i < sizeGuide.headers.length; i++) {
7330
- const a = sizeGuide.headers[i].toLowerCase().trim();
7382
+ const a = (sizeGuide.headers[i] || "").toLowerCase().trim();
7331
7383
  if (a === b) {
7332
- mc = i;
7333
- break;
7384
+ candidates.push(i);
7385
+ continue;
7334
7386
  }
7335
- if (a.includes(b) || b.includes(a.replace(/\s*\(.*?\)\s*/g, "").trim())) {
7336
- const hasCm = /\(cm\)|centimeter/i.test(a);
7337
- const hasIn = /\(in\)|inch/i.test(a);
7338
- if (preferCm && hasCm) {
7339
- mc = i;
7340
- break;
7341
- }
7342
- if (!preferCm && hasIn) {
7343
- mc = i;
7344
- break;
7345
- }
7346
- if (mc < 0) mc = i;
7387
+ const aBare = a.replace(/\s*\(.*?\)\s*/g, "").trim();
7388
+ if (aBare === b || a.includes(b) || b.includes(aBare)) {
7389
+ candidates.push(i);
7347
7390
  }
7348
7391
  }
7349
- if (mc < 0) return null;
7392
+ if (candidates.length === 0) return null;
7393
+ let mc = candidates.find((i) => sizeGuideColumnUnits[i] === wantUnit);
7394
+ if (mc == null) mc = candidates[0];
7350
7395
  const mHeader = sizeGuide.headers[mc];
7351
7396
  const row = sizeGuide.rows.find((r) => cellVal(r, sizeColIdx, sizeHeader) === size);
7352
7397
  if (!row) return null;
7353
7398
  const val = cellVal(row, mc, mHeader);
7354
7399
  if (!val) return null;
7355
7400
  const parsed = pRange(val);
7401
+ const colUnit = sizeGuideColumnUnits[mc];
7402
+ if (colUnit === "in" && preferCm) {
7403
+ const toCm = (v) => +(v * 2.54).toFixed(1);
7404
+ return { range: String(toCm(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toCm(parsed.max)) : ""), min: toCm(parsed.min), max: toCm(parsed.max) };
7405
+ }
7406
+ if (colUnit === "cm" && !preferCm) {
7407
+ const toIn = (v) => +(v / 2.54).toFixed(1);
7408
+ return { range: String(toIn(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toIn(parsed.max)) : ""), min: toIn(parsed.min), max: toIn(parsed.max) };
7409
+ }
7356
7410
  return { range: val, ...parsed };
7357
- }, [sizeGuide, sizeColIdx, sizeHeader, unitLbl, cellVal, pRange]);
7411
+ }, [sizeGuide, sizeColIdx, sizeHeader, unitLbl, cellVal, pRange, sizeGuideColumnUnits]);
7358
7412
  const origSize = sizingResult?.recommendedSize || "";
7359
7413
  const activeSize = origSize;
7360
7414
  useMemo(() => {
@@ -9531,7 +9585,7 @@ function ImageOptionCard({
9531
9585
  );
9532
9586
  }
9533
9587
  const MALE_STEPS = ["basics", "chest", "midsection", "seat"];
9534
- const FEMALE_STEPS = ["basics", "bra", "midsection", "seat", "hips"];
9588
+ const FEMALE_STEPS = ["basics", "midsection", "seat", "hips", "bra"];
9535
9589
  const BAND_SIZES = {
9536
9590
  US: ["28", "30", "32", "34", "36", "38", "40", "42", "44", "46", "48", "50", "52", "54", "56"],
9537
9591
  UK: ["28", "30", "32", "34", "36", "38", "40", "42", "44", "46", "48", "50", "52", "54", "56"],
@@ -16255,50 +16255,71 @@ function SectionDetailView({
16255
16255
  }, [section, sizeColIdx, sizeHeader]);
16256
16256
  const displaySize = selectedSize || recSize;
16257
16257
  const isRecommended = displaySize === recSize;
16258
- const chartRangeFor = reactExports.useCallback((measurement, size) => {
16259
- const b = measurement.toLowerCase().trim();
16260
- const preferCm = unitLbl === "cm" || unitLbl === "";
16261
- let mc2 = -1;
16258
+ const columnUnits = reactExports.useMemo(() => {
16259
+ const units = [];
16262
16260
  for (let i = 0; i < section.headers.length; i++) {
16263
- const a = section.headers[i].toLowerCase().trim();
16264
- if (a === b) {
16265
- mc2 = i;
16266
- break;
16261
+ const h = (section.headers[i] || "").toLowerCase();
16262
+ if (/\(cm\)|centimeter/i.test(h)) {
16263
+ units.push("cm");
16264
+ continue;
16267
16265
  }
16268
- if (a.includes(b) || b.includes(a.replace(/\s*\(.*?\)\s*/g, "").trim())) {
16269
- const hasCm = /\(cm\)|centimeter/i.test(a);
16270
- const hasIn = /\(in\)|inch/i.test(a);
16271
- if (preferCm && hasCm) {
16272
- mc2 = i;
16266
+ if (/\(in\)|\(inch|inch/i.test(h)) {
16267
+ units.push("in");
16268
+ continue;
16269
+ }
16270
+ let inferred = null;
16271
+ for (const row of section.rows) {
16272
+ const cell = String(cellValFn(row, i, section.headers[i]) || "").trim();
16273
+ if (!cell) continue;
16274
+ if (/cm\b|centimeter/i.test(cell)) {
16275
+ inferred = "cm";
16273
16276
  break;
16274
16277
  }
16275
- if (!preferCm && hasIn) {
16276
- mc2 = i;
16278
+ if (/in\b|inch|"$/i.test(cell)) {
16279
+ inferred = "in";
16277
16280
  break;
16278
16281
  }
16279
- if (mc2 < 0) mc2 = i;
16280
16282
  }
16283
+ units.push(inferred);
16281
16284
  }
16282
- if (mc2 < 0) return null;
16285
+ return units;
16286
+ }, [section]);
16287
+ const chartRangeFor = reactExports.useCallback((measurement, size) => {
16288
+ const b = measurement.toLowerCase().trim();
16289
+ const preferCm = unitLbl === "cm" || unitLbl === "";
16290
+ const wantUnit = preferCm ? "cm" : "in";
16291
+ const candidates = [];
16292
+ for (let i = 0; i < section.headers.length; i++) {
16293
+ const a = (section.headers[i] || "").toLowerCase().trim();
16294
+ if (a === b) {
16295
+ candidates.push(i);
16296
+ continue;
16297
+ }
16298
+ const aBare = a.replace(/\s*\(.*?\)\s*/g, "").trim();
16299
+ if (aBare === b || a.includes(b) || b.includes(aBare)) {
16300
+ candidates.push(i);
16301
+ }
16302
+ }
16303
+ if (candidates.length === 0) return null;
16304
+ let mc2 = candidates.find((i) => columnUnits[i] === wantUnit);
16305
+ if (mc2 == null) mc2 = candidates[0];
16283
16306
  const mHeader = section.headers[mc2];
16284
16307
  const row = section.rows.find((r2) => cellValFn(r2, sizeColIdx, sizeHeader) === size);
16285
16308
  if (!row) return null;
16286
16309
  const val = cellValFn(row, mc2, mHeader);
16287
16310
  if (!val) return null;
16288
16311
  const parsed = pRangeFn(val);
16289
- const colHdr = section.headers[mc2].toLowerCase();
16290
- const colIsInch = /\(in\)|inch/i.test(colHdr);
16291
- const colIsCm = /\(cm\)|centimeter/i.test(colHdr);
16292
- if (colIsInch && preferCm) {
16312
+ const colUnit = columnUnits[mc2];
16313
+ if (colUnit === "in" && preferCm) {
16293
16314
  const toCm = (v2) => +(v2 * 2.54).toFixed(1);
16294
16315
  return { range: String(toCm(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toCm(parsed.max)) : ""), min: toCm(parsed.min), max: toCm(parsed.max) };
16295
16316
  }
16296
- if (colIsCm && !preferCm) {
16317
+ if (colUnit === "cm" && !preferCm) {
16297
16318
  const toIn = (v2) => +(v2 / 2.54).toFixed(1);
16298
16319
  return { range: String(toIn(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toIn(parsed.max)) : ""), min: toIn(parsed.min), max: toIn(parsed.max) };
16299
16320
  }
16300
16321
  return { range: val, ...parsed };
16301
- }, [section, sizeColIdx, sizeHeader, unitLbl]);
16322
+ }, [section, sizeColIdx, sizeHeader, unitLbl, columnUnits]);
16302
16323
  const fitRows = reactExports.useMemo(() => {
16303
16324
  const mainDetails = sectionResult?.matchDetails || [];
16304
16325
  const lengthDetails = lengthEntry?.secResult?.matchDetails || [];
@@ -16745,40 +16766,73 @@ function SizeResultView({
16745
16766
  if (sizeColIdx < 0 || !sizeGuide?.rows) return [];
16746
16767
  return sizeGuide.rows.map((r2) => cellVal(r2, sizeColIdx, sizeHeader)).filter(Boolean);
16747
16768
  }, [sizeGuide, sizeColIdx, sizeHeader, cellVal]);
16769
+ const sizeGuideColumnUnits = reactExports.useMemo(() => {
16770
+ if (!sizeGuide?.headers || !sizeGuide?.rows) return [];
16771
+ const units = [];
16772
+ for (let i = 0; i < sizeGuide.headers.length; i++) {
16773
+ const h = (sizeGuide.headers[i] || "").toLowerCase();
16774
+ if (/\(cm\)|centimeter/i.test(h)) {
16775
+ units.push("cm");
16776
+ continue;
16777
+ }
16778
+ if (/\(in\)|\(inch|inch/i.test(h)) {
16779
+ units.push("in");
16780
+ continue;
16781
+ }
16782
+ let inferred = null;
16783
+ for (const row of sizeGuide.rows) {
16784
+ const cell = String(cellVal(row, i, sizeGuide.headers[i]) || "").trim();
16785
+ if (!cell) continue;
16786
+ if (/cm\b|centimeter/i.test(cell)) {
16787
+ inferred = "cm";
16788
+ break;
16789
+ }
16790
+ if (/in\b|inch|"$/i.test(cell)) {
16791
+ inferred = "in";
16792
+ break;
16793
+ }
16794
+ }
16795
+ units.push(inferred);
16796
+ }
16797
+ return units;
16798
+ }, [sizeGuide, cellVal]);
16748
16799
  const chartRangeFor = reactExports.useCallback((measurement, size) => {
16749
16800
  if (!sizeGuide?.headers || !sizeGuide?.rows || sizeColIdx < 0) return null;
16750
16801
  const b = measurement.toLowerCase().trim();
16751
16802
  const preferCm = unitLbl === "cm" || unitLbl === "";
16752
- let mc2 = -1;
16803
+ const wantUnit = preferCm ? "cm" : "in";
16804
+ const candidates = [];
16753
16805
  for (let i = 0; i < sizeGuide.headers.length; i++) {
16754
- const a = sizeGuide.headers[i].toLowerCase().trim();
16806
+ const a = (sizeGuide.headers[i] || "").toLowerCase().trim();
16755
16807
  if (a === b) {
16756
- mc2 = i;
16757
- break;
16808
+ candidates.push(i);
16809
+ continue;
16758
16810
  }
16759
- if (a.includes(b) || b.includes(a.replace(/\s*\(.*?\)\s*/g, "").trim())) {
16760
- const hasCm = /\(cm\)|centimeter/i.test(a);
16761
- const hasIn = /\(in\)|inch/i.test(a);
16762
- if (preferCm && hasCm) {
16763
- mc2 = i;
16764
- break;
16765
- }
16766
- if (!preferCm && hasIn) {
16767
- mc2 = i;
16768
- break;
16769
- }
16770
- if (mc2 < 0) mc2 = i;
16811
+ const aBare = a.replace(/\s*\(.*?\)\s*/g, "").trim();
16812
+ if (aBare === b || a.includes(b) || b.includes(aBare)) {
16813
+ candidates.push(i);
16771
16814
  }
16772
16815
  }
16773
- if (mc2 < 0) return null;
16816
+ if (candidates.length === 0) return null;
16817
+ let mc2 = candidates.find((i) => sizeGuideColumnUnits[i] === wantUnit);
16818
+ if (mc2 == null) mc2 = candidates[0];
16774
16819
  const mHeader = sizeGuide.headers[mc2];
16775
16820
  const row = sizeGuide.rows.find((r2) => cellVal(r2, sizeColIdx, sizeHeader) === size);
16776
16821
  if (!row) return null;
16777
16822
  const val = cellVal(row, mc2, mHeader);
16778
16823
  if (!val) return null;
16779
16824
  const parsed = pRange(val);
16825
+ const colUnit = sizeGuideColumnUnits[mc2];
16826
+ if (colUnit === "in" && preferCm) {
16827
+ const toCm = (v2) => +(v2 * 2.54).toFixed(1);
16828
+ return { range: String(toCm(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toCm(parsed.max)) : ""), min: toCm(parsed.min), max: toCm(parsed.max) };
16829
+ }
16830
+ if (colUnit === "cm" && !preferCm) {
16831
+ const toIn = (v2) => +(v2 / 2.54).toFixed(1);
16832
+ return { range: String(toIn(parsed.min)) + (parsed.min !== parsed.max ? "–" + String(toIn(parsed.max)) : ""), min: toIn(parsed.min), max: toIn(parsed.max) };
16833
+ }
16780
16834
  return { range: val, ...parsed };
16781
- }, [sizeGuide, sizeColIdx, sizeHeader, unitLbl, cellVal, pRange]);
16835
+ }, [sizeGuide, sizeColIdx, sizeHeader, unitLbl, cellVal, pRange, sizeGuideColumnUnits]);
16782
16836
  const origSize = sizingResult?.recommendedSize || "";
16783
16837
  const activeSize = origSize;
16784
16838
  reactExports.useMemo(() => {
@@ -18955,7 +19009,7 @@ function ImageOptionCard({
18955
19009
  );
18956
19010
  }
18957
19011
  const MALE_STEPS = ["basics", "chest", "midsection", "seat"];
18958
- const FEMALE_STEPS = ["basics", "bra", "midsection", "seat", "hips"];
19012
+ const FEMALE_STEPS = ["basics", "midsection", "seat", "hips", "bra"];
18959
19013
  const BAND_SIZES = {
18960
19014
  US: ["28", "30", "32", "34", "36", "38", "40", "42", "44", "46", "48", "50", "52", "54", "56"],
18961
19015
  UK: ["28", "30", "32", "34", "36", "38", "40", "42", "44", "46", "48", "50", "52", "54", "56"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.8.12",
3
+ "version": "5.8.14",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",