@primestyleai/tryon 4.0.0 → 4.1.1
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/react/index.js +43 -14
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -1511,15 +1511,31 @@ function PrimeStyleTryonInner({
|
|
|
1511
1511
|
const [editing, setEditing] = useState(false);
|
|
1512
1512
|
const [editVals, setEditVals] = useState({});
|
|
1513
1513
|
const [compareSize, setCompareSize] = useState("");
|
|
1514
|
-
const
|
|
1514
|
+
const cleanChart = (s) => {
|
|
1515
|
+
const nums = s.replace(/[^\d.\-–]/g, " ").trim().split(/[\s\-–]+/).filter(Boolean).map((n) => parseFloat(n)).filter((n) => !isNaN(n));
|
|
1516
|
+
if (nums.length === 0) return s;
|
|
1517
|
+
if (nums.length === 1) return `${nums[0]}`;
|
|
1518
|
+
return `${nums[0]}–${nums[1]}`;
|
|
1519
|
+
};
|
|
1520
|
+
const recSize = useMemo(() => {
|
|
1521
|
+
if (sizingResult?.recommendedSize) return sizingResult.recommendedSize;
|
|
1522
|
+
if (sizeGuide?.rows && sizeGuide.headers) {
|
|
1523
|
+
const sc = sizeGuide.headers.findIndex((h) => /size|taglia|größe|taille/i.test(h.trim()));
|
|
1524
|
+
const idx = sc >= 0 ? sc : 0;
|
|
1525
|
+
for (const row of sizeGuide.rows) {
|
|
1526
|
+
const label = row[idx]?.trim();
|
|
1527
|
+
if (label && /^(XXS|XS|S|M|L|XL|XXL|XXXL|\d{1,3})$/i.test(label)) return label;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
return "";
|
|
1531
|
+
}, [sizingResult, sizeGuide]);
|
|
1515
1532
|
const selSize = compareSize || recSize;
|
|
1516
1533
|
const sizeColIdx = useMemo(() => {
|
|
1517
1534
|
if (!sizeGuide?.headers || !sizeGuide?.rows) return -1;
|
|
1518
1535
|
const byName = sizeGuide.headers.findIndex((h) => /size|taglia|größe|taille/i.test(h.trim()));
|
|
1519
1536
|
if (byName >= 0) return byName;
|
|
1520
1537
|
for (let c = 0; c < sizeGuide.headers.length; c++) {
|
|
1521
|
-
|
|
1522
|
-
if (vals.some((v) => /^(XXS|XS|S|M|L|XL|XXL|XXXL|ONE SIZE|\d{1,2})$/i.test(v))) return c;
|
|
1538
|
+
if (sizeGuide.rows.some((r) => /^(XXS|XS|S|M|L|XL|XXL|XXXL|ONE SIZE|\d{1,2})$/i.test(r[c]?.trim() || ""))) return c;
|
|
1523
1539
|
}
|
|
1524
1540
|
return 0;
|
|
1525
1541
|
}, [sizeGuide]);
|
|
@@ -1553,7 +1569,7 @@ function PrimeStyleTryonInner({
|
|
|
1553
1569
|
const userNum = edited !== void 0 && edited !== "" ? parseFloat(edited) : origNum;
|
|
1554
1570
|
let { min: rMin, max: rMax } = pRange(m.chartRange);
|
|
1555
1571
|
let chartLabel = m.chartRange;
|
|
1556
|
-
if (compareSize && compareSize !==
|
|
1572
|
+
if (compareSize && compareSize !== recSize) {
|
|
1557
1573
|
const alt = chartRangeFor(m.measurement, compareSize);
|
|
1558
1574
|
if (alt) {
|
|
1559
1575
|
chartLabel = alt.range;
|
|
@@ -1562,9 +1578,9 @@ function PrimeStyleTryonInner({
|
|
|
1562
1578
|
}
|
|
1563
1579
|
}
|
|
1564
1580
|
const fit = userNum >= rMin && userNum <= rMax ? "good" : userNum < rMin ? "tight" : "loose";
|
|
1565
|
-
return { area: m.measurement, userNum, chartLabel, fit };
|
|
1581
|
+
return { area: m.measurement, userNum, chartLabel: cleanChart(chartLabel), fit };
|
|
1566
1582
|
});
|
|
1567
|
-
}, [sizingResult, compareSize, editVals, chartRangeFor]);
|
|
1583
|
+
}, [sizingResult, compareSize, editVals, chartRangeFor, recSize]);
|
|
1568
1584
|
const suggestedSize = useMemo(() => {
|
|
1569
1585
|
if (!Object.keys(editVals).length || !sizingResult?.matchDetails?.length || !allSizes.length) return null;
|
|
1570
1586
|
let bestSize = "";
|
|
@@ -1590,6 +1606,7 @@ function PrimeStyleTryonInner({
|
|
|
1590
1606
|
const fromTable = SIZE_CONVERSIONS[upper] || SIZE_CONVERSIONS[recSize] || {};
|
|
1591
1607
|
return { ...fromTable, ...backendIntl };
|
|
1592
1608
|
}, [sizingResult, recSize]);
|
|
1609
|
+
const confLabel = sizingResult?.confidence === "high" ? t("High Confidence") : sizingResult?.confidence === "medium" ? t("Medium Confidence") : t("Low Confidence");
|
|
1593
1610
|
return /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr", children: [
|
|
1594
1611
|
sizingLoading && !sizingResult && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-loading", children: [
|
|
1595
1612
|
/* @__PURE__ */ jsx("div", { className: "ps-tryon-size-loading-spinner" }),
|
|
@@ -1597,13 +1614,15 @@ function PrimeStyleTryonInner({
|
|
|
1597
1614
|
] }),
|
|
1598
1615
|
sizingResult && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1599
1616
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-hero", children: [
|
|
1600
|
-
recSize
|
|
1617
|
+
recSize ? /* @__PURE__ */ jsx("div", { className: "ps-tryon-sr-hero-badge", children: recSize }) : /* @__PURE__ */ jsx("div", { className: "ps-tryon-sr-hero-badge ps-tryon-sr-hero-badge-icon", children: /* @__PURE__ */ jsx(RulerIcon, { size: 22 }) }),
|
|
1601
1618
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-hero-info", children: [
|
|
1602
1619
|
/* @__PURE__ */ jsx("div", { className: "ps-tryon-sr-hero-title", children: t("Your Size") }),
|
|
1603
|
-
/* @__PURE__ */ jsx("div", { className: `ps-tryon-sr-hero-conf ps-conf-${sizingResult.confidence}`, children:
|
|
1620
|
+
/* @__PURE__ */ jsx("div", { className: `ps-tryon-sr-hero-conf ps-conf-${sizingResult.confidence}`, children: confLabel })
|
|
1604
1621
|
] })
|
|
1605
1622
|
] }),
|
|
1606
|
-
suggestedSize && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-suggestion",
|
|
1623
|
+
suggestedSize && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-suggestion", onClick: () => {
|
|
1624
|
+
setCompareSize(suggestedSize);
|
|
1625
|
+
}, children: [
|
|
1607
1626
|
/* @__PURE__ */ jsx(SparkleIcon, { size: 14 }),
|
|
1608
1627
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
1609
1628
|
t("Based on your updated measurements, size"),
|
|
@@ -1611,7 +1630,8 @@ function PrimeStyleTryonInner({
|
|
|
1611
1630
|
/* @__PURE__ */ jsx("strong", { children: suggestedSize }),
|
|
1612
1631
|
" ",
|
|
1613
1632
|
t("may be a better fit")
|
|
1614
|
-
] })
|
|
1633
|
+
] }),
|
|
1634
|
+
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
1615
1635
|
] }),
|
|
1616
1636
|
Object.keys(allIntlSizes).length > 0 && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-intl", children: [
|
|
1617
1637
|
/* @__PURE__ */ jsx("div", { className: "ps-tryon-sr-section-title", children: t("Your size in other countries") }),
|
|
@@ -1664,7 +1684,11 @@ function PrimeStyleTryonInner({
|
|
|
1664
1684
|
selSize,
|
|
1665
1685
|
")"
|
|
1666
1686
|
] }),
|
|
1667
|
-
/* @__PURE__ */
|
|
1687
|
+
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-fc-value", children: [
|
|
1688
|
+
row.chartLabel,
|
|
1689
|
+
" ",
|
|
1690
|
+
unitLbl
|
|
1691
|
+
] })
|
|
1668
1692
|
] })
|
|
1669
1693
|
] })
|
|
1670
1694
|
] }, i)) })
|
|
@@ -2369,12 +2393,17 @@ const STYLES = `
|
|
|
2369
2393
|
/* Suggestion banner */
|
|
2370
2394
|
.ps-tryon-sr-suggestion {
|
|
2371
2395
|
display: flex; align-items: center; gap: 0.52vw;
|
|
2372
|
-
padding: 0.
|
|
2373
|
-
background: rgba(187,148,92,0.
|
|
2374
|
-
|
|
2396
|
+
padding: 0.62vw 0.83vw; border-radius: 0.52vw;
|
|
2397
|
+
background: linear-gradient(135deg, rgba(187,148,92,0.1), rgba(187,148,92,0.04));
|
|
2398
|
+
border: 1px solid rgba(187,148,92,0.25);
|
|
2399
|
+
font-size: 0.73vw; color: #d6ba7d; cursor: pointer;
|
|
2400
|
+
animation: ps-fade-up 0.3s ease both; transition: background 0.2s;
|
|
2375
2401
|
}
|
|
2402
|
+
.ps-tryon-sr-suggestion:hover { background: rgba(187,148,92,0.14); }
|
|
2376
2403
|
.ps-tryon-sr-suggestion svg { stroke: #bb945c; flex-shrink: 0; }
|
|
2377
2404
|
.ps-tryon-sr-suggestion strong { color: #fff; }
|
|
2405
|
+
.ps-tryon-sr-hero-badge-icon { background: linear-gradient(135deg, #333, #444); }
|
|
2406
|
+
.ps-tryon-sr-hero-badge-icon svg { stroke: #bb945c; }
|
|
2378
2407
|
|
|
2379
2408
|
/* Section titles */
|
|
2380
2409
|
.ps-tryon-sr-section-title { font-size: 0.73vw; font-weight: 700; color: #666; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.52vw; }
|