@primestyleai/tryon 4.0.0 → 4.1.0
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 +38 -14
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -1511,15 +1511,26 @@ 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) => s.replace(/\s*(cm|CM|in|IN|inches|mm|MM)\s*$/i, "").trim();
|
|
1515
|
+
const recSize = useMemo(() => {
|
|
1516
|
+
if (sizingResult?.recommendedSize) return sizingResult.recommendedSize;
|
|
1517
|
+
if (sizeGuide?.rows && sizeGuide.headers) {
|
|
1518
|
+
const sc = sizeGuide.headers.findIndex((h) => /size|taglia|größe|taille/i.test(h.trim()));
|
|
1519
|
+
const idx = sc >= 0 ? sc : 0;
|
|
1520
|
+
for (const row of sizeGuide.rows) {
|
|
1521
|
+
const label = row[idx]?.trim();
|
|
1522
|
+
if (label && /^(XXS|XS|S|M|L|XL|XXL|XXXL|\d{1,3})$/i.test(label)) return label;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
return "";
|
|
1526
|
+
}, [sizingResult, sizeGuide]);
|
|
1515
1527
|
const selSize = compareSize || recSize;
|
|
1516
1528
|
const sizeColIdx = useMemo(() => {
|
|
1517
1529
|
if (!sizeGuide?.headers || !sizeGuide?.rows) return -1;
|
|
1518
1530
|
const byName = sizeGuide.headers.findIndex((h) => /size|taglia|größe|taille/i.test(h.trim()));
|
|
1519
1531
|
if (byName >= 0) return byName;
|
|
1520
1532
|
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;
|
|
1533
|
+
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
1534
|
}
|
|
1524
1535
|
return 0;
|
|
1525
1536
|
}, [sizeGuide]);
|
|
@@ -1553,7 +1564,7 @@ function PrimeStyleTryonInner({
|
|
|
1553
1564
|
const userNum = edited !== void 0 && edited !== "" ? parseFloat(edited) : origNum;
|
|
1554
1565
|
let { min: rMin, max: rMax } = pRange(m.chartRange);
|
|
1555
1566
|
let chartLabel = m.chartRange;
|
|
1556
|
-
if (compareSize && compareSize !==
|
|
1567
|
+
if (compareSize && compareSize !== recSize) {
|
|
1557
1568
|
const alt = chartRangeFor(m.measurement, compareSize);
|
|
1558
1569
|
if (alt) {
|
|
1559
1570
|
chartLabel = alt.range;
|
|
@@ -1562,9 +1573,9 @@ function PrimeStyleTryonInner({
|
|
|
1562
1573
|
}
|
|
1563
1574
|
}
|
|
1564
1575
|
const fit = userNum >= rMin && userNum <= rMax ? "good" : userNum < rMin ? "tight" : "loose";
|
|
1565
|
-
return { area: m.measurement, userNum, chartLabel, fit };
|
|
1576
|
+
return { area: m.measurement, userNum, chartLabel: cleanChart(chartLabel), fit };
|
|
1566
1577
|
});
|
|
1567
|
-
}, [sizingResult, compareSize, editVals, chartRangeFor]);
|
|
1578
|
+
}, [sizingResult, compareSize, editVals, chartRangeFor, recSize]);
|
|
1568
1579
|
const suggestedSize = useMemo(() => {
|
|
1569
1580
|
if (!Object.keys(editVals).length || !sizingResult?.matchDetails?.length || !allSizes.length) return null;
|
|
1570
1581
|
let bestSize = "";
|
|
@@ -1590,6 +1601,7 @@ function PrimeStyleTryonInner({
|
|
|
1590
1601
|
const fromTable = SIZE_CONVERSIONS[upper] || SIZE_CONVERSIONS[recSize] || {};
|
|
1591
1602
|
return { ...fromTable, ...backendIntl };
|
|
1592
1603
|
}, [sizingResult, recSize]);
|
|
1604
|
+
const confLabel = sizingResult?.confidence === "high" ? t("High Confidence") : sizingResult?.confidence === "medium" ? t("Medium Confidence") : t("Low Confidence");
|
|
1593
1605
|
return /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr", children: [
|
|
1594
1606
|
sizingLoading && !sizingResult && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-loading", children: [
|
|
1595
1607
|
/* @__PURE__ */ jsx("div", { className: "ps-tryon-size-loading-spinner" }),
|
|
@@ -1597,13 +1609,15 @@ function PrimeStyleTryonInner({
|
|
|
1597
1609
|
] }),
|
|
1598
1610
|
sizingResult && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1599
1611
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-hero", children: [
|
|
1600
|
-
recSize
|
|
1612
|
+
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
1613
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-hero-info", children: [
|
|
1602
1614
|
/* @__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:
|
|
1615
|
+
/* @__PURE__ */ jsx("div", { className: `ps-tryon-sr-hero-conf ps-conf-${sizingResult.confidence}`, children: confLabel })
|
|
1604
1616
|
] })
|
|
1605
1617
|
] }),
|
|
1606
|
-
suggestedSize && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-suggestion",
|
|
1618
|
+
suggestedSize && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-suggestion", onClick: () => {
|
|
1619
|
+
setCompareSize(suggestedSize);
|
|
1620
|
+
}, children: [
|
|
1607
1621
|
/* @__PURE__ */ jsx(SparkleIcon, { size: 14 }),
|
|
1608
1622
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
1609
1623
|
t("Based on your updated measurements, size"),
|
|
@@ -1611,7 +1625,8 @@ function PrimeStyleTryonInner({
|
|
|
1611
1625
|
/* @__PURE__ */ jsx("strong", { children: suggestedSize }),
|
|
1612
1626
|
" ",
|
|
1613
1627
|
t("may be a better fit")
|
|
1614
|
-
] })
|
|
1628
|
+
] }),
|
|
1629
|
+
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
1615
1630
|
] }),
|
|
1616
1631
|
Object.keys(allIntlSizes).length > 0 && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-intl", children: [
|
|
1617
1632
|
/* @__PURE__ */ jsx("div", { className: "ps-tryon-sr-section-title", children: t("Your size in other countries") }),
|
|
@@ -1664,7 +1679,11 @@ function PrimeStyleTryonInner({
|
|
|
1664
1679
|
selSize,
|
|
1665
1680
|
")"
|
|
1666
1681
|
] }),
|
|
1667
|
-
/* @__PURE__ */
|
|
1682
|
+
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-sr-fc-value", children: [
|
|
1683
|
+
row.chartLabel,
|
|
1684
|
+
" ",
|
|
1685
|
+
unitLbl
|
|
1686
|
+
] })
|
|
1668
1687
|
] })
|
|
1669
1688
|
] })
|
|
1670
1689
|
] }, i)) })
|
|
@@ -2369,12 +2388,17 @@ const STYLES = `
|
|
|
2369
2388
|
/* Suggestion banner */
|
|
2370
2389
|
.ps-tryon-sr-suggestion {
|
|
2371
2390
|
display: flex; align-items: center; gap: 0.52vw;
|
|
2372
|
-
padding: 0.
|
|
2373
|
-
background: rgba(187,148,92,0.
|
|
2374
|
-
|
|
2391
|
+
padding: 0.62vw 0.83vw; border-radius: 0.52vw;
|
|
2392
|
+
background: linear-gradient(135deg, rgba(187,148,92,0.1), rgba(187,148,92,0.04));
|
|
2393
|
+
border: 1px solid rgba(187,148,92,0.25);
|
|
2394
|
+
font-size: 0.73vw; color: #d6ba7d; cursor: pointer;
|
|
2395
|
+
animation: ps-fade-up 0.3s ease both; transition: background 0.2s;
|
|
2375
2396
|
}
|
|
2397
|
+
.ps-tryon-sr-suggestion:hover { background: rgba(187,148,92,0.14); }
|
|
2376
2398
|
.ps-tryon-sr-suggestion svg { stroke: #bb945c; flex-shrink: 0; }
|
|
2377
2399
|
.ps-tryon-sr-suggestion strong { color: #fff; }
|
|
2400
|
+
.ps-tryon-sr-hero-badge-icon { background: linear-gradient(135deg, #333, #444); }
|
|
2401
|
+
.ps-tryon-sr-hero-badge-icon svg { stroke: #bb945c; }
|
|
2378
2402
|
|
|
2379
2403
|
/* Section titles */
|
|
2380
2404
|
.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; }
|