@primestyleai/tryon 3.3.0 → 3.4.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.
Files changed (2) hide show
  1. package/dist/react/index.js +71 -17
  2. package/package.json +1 -1
@@ -589,8 +589,8 @@ function PrimeStyleTryonInner({
589
589
  if (p.weightUnit) setWeightUnit(p.weightUnit);
590
590
  setFormKey((k) => k + 1);
591
591
  }, [profiles]);
592
- const saveProfile = useCallback((name) => {
593
- const id = activeProfileId || `p_${Date.now()}`;
592
+ const saveProfile = useCallback((name, asNew) => {
593
+ const id = (asNew ? null : activeProfileId) || `p_${Date.now()}`;
594
594
  const p = {
595
595
  id,
596
596
  name,
@@ -857,6 +857,8 @@ function PrimeStyleTryonInner({
857
857
  function SizingFormView() {
858
858
  const isFemale = formGender === "female";
859
859
  const isCm = sizingUnit === "cm";
860
+ const [saveToggle, setSaveToggle] = useState(false);
861
+ const [saveFormName, setSaveFormName] = useState("");
860
862
  return /* @__PURE__ */ jsxs("div", { className: "ps-tryon-sizing-form", children: [
861
863
  /* @__PURE__ */ jsxs("button", { className: "ps-tryon-back", onClick: () => setView("sizing-choice"), children: [
862
864
  /* @__PURE__ */ jsx(ArrowLeftIcon, {}),
@@ -948,7 +950,28 @@ function PrimeStyleTryonInner({
948
950
  ] })
949
951
  ] }),
950
952
  /* @__PURE__ */ jsx("p", { className: "ps-tryon-disclaimer", children: "Fill in what you know — more measurements = better accuracy." }),
951
- /* @__PURE__ */ jsxs("button", { className: "ps-tryon-submit", onClick: handleSubmit, children: [
953
+ /* @__PURE__ */ jsxs("div", { className: "ps-tryon-form-save-toggle", children: [
954
+ /* @__PURE__ */ jsxs("label", { className: "ps-tryon-form-save-check", children: [
955
+ /* @__PURE__ */ jsx("input", { type: "checkbox", checked: saveToggle, onChange: (e) => setSaveToggle(e.target.checked) }),
956
+ /* @__PURE__ */ jsx("span", { children: "Save as profile" })
957
+ ] }),
958
+ saveToggle && /* @__PURE__ */ jsx(
959
+ "input",
960
+ {
961
+ type: "text",
962
+ className: "ps-tryon-form-save-name",
963
+ placeholder: "Profile name (e.g. John, Sarah)",
964
+ value: saveFormName,
965
+ onChange: (e) => setSaveFormName(e.target.value)
966
+ }
967
+ )
968
+ ] }),
969
+ /* @__PURE__ */ jsxs("button", { className: "ps-tryon-submit", onClick: () => {
970
+ if (saveToggle && saveFormName.trim()) {
971
+ saveProfile(saveFormName.trim());
972
+ }
973
+ handleSubmit();
974
+ }, children: [
952
975
  "Get My Size & Try On ",
953
976
  /* @__PURE__ */ jsx(ArrowRightIcon, {})
954
977
  ] })
@@ -1018,7 +1041,14 @@ function PrimeStyleTryonInner({
1018
1041
  /* @__PURE__ */ jsx("div", { className: "ps-tryon-save-label", children: "Save your measurements for next time" }),
1019
1042
  /* @__PURE__ */ jsxs("div", { className: "ps-tryon-save-row", children: [
1020
1043
  /* @__PURE__ */ jsx("input", { type: "text", placeholder: "Name this profile (e.g. John, Sarah)", value: profileName, onChange: (e) => setProfileName(e.target.value) }),
1021
- /* @__PURE__ */ jsx("button", { onClick: () => {
1044
+ activeProfileId ? /* @__PURE__ */ jsxs("div", { className: "ps-tryon-save-btn-group", children: [
1045
+ /* @__PURE__ */ jsx("button", { onClick: () => {
1046
+ if (profileName.trim()) saveProfile(profileName.trim());
1047
+ }, children: "Update" }),
1048
+ /* @__PURE__ */ jsx("button", { className: "ps-tryon-save-new-btn", onClick: () => {
1049
+ if (profileName.trim()) saveProfile(profileName.trim(), true);
1050
+ }, children: "+ New" })
1051
+ ] }) : /* @__PURE__ */ jsx("button", { onClick: () => {
1022
1052
  if (profileName.trim()) saveProfile(profileName.trim());
1023
1053
  }, children: "Save" })
1024
1054
  ] })
@@ -1058,16 +1088,21 @@ function PrimeStyleTryonInner({
1058
1088
  ] }),
1059
1089
  /* @__PURE__ */ jsx(ChevronRightIcon, {})
1060
1090
  ] }, p.id)) : history.length === 0 ? /* @__PURE__ */ jsx("div", { className: "ps-tryon-drawer-empty", children: "No history yet." }) : history.map((entry, idx) => /* @__PURE__ */ jsxs("div", { className: "ps-tryon-history-item", children: [
1061
- entry.productImage && /* @__PURE__ */ jsx("img", { src: entry.productImage, alt: "", className: "ps-tryon-history-thumb" }),
1091
+ /* @__PURE__ */ jsxs("div", { className: "ps-tryon-history-images", children: [
1092
+ entry.productImage && /* @__PURE__ */ jsx("img", { src: entry.productImage, alt: "", className: "ps-tryon-history-thumb" }),
1093
+ entry.resultImageUrl && /* @__PURE__ */ jsx("img", { src: entry.resultImageUrl, alt: "", className: "ps-tryon-history-result-img" })
1094
+ ] }),
1062
1095
  /* @__PURE__ */ jsxs("div", { className: "ps-tryon-history-info", children: [
1063
1096
  /* @__PURE__ */ jsx("div", { className: "ps-tryon-history-product", children: entry.productTitle || "Product" }),
1064
1097
  /* @__PURE__ */ jsxs("div", { className: "ps-tryon-history-meta", children: [
1065
1098
  entry.profileName ? `${entry.profileName} · ` : "",
1066
1099
  new Date(entry.date).toLocaleDateString()
1067
1100
  ] }),
1068
- entry.recommendedSize && /* @__PURE__ */ jsx("div", { className: "ps-tryon-history-sizing", children: /* @__PURE__ */ jsx("span", { className: "ps-tryon-history-size-badge", children: entry.recommendedSize }) })
1101
+ entry.recommendedSize && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-history-sizing", children: [
1102
+ /* @__PURE__ */ jsx("span", { className: "ps-tryon-history-size-badge", children: entry.recommendedSize }),
1103
+ entry.reasoning && /* @__PURE__ */ jsx("span", { className: "ps-tryon-history-sizing-reason", children: entry.reasoning })
1104
+ ] })
1069
1105
  ] }),
1070
- entry.resultImageUrl && /* @__PURE__ */ jsx("img", { src: entry.resultImageUrl, alt: "", className: "ps-tryon-history-result-img" }),
1071
1106
  /* @__PURE__ */ jsx("button", { className: "ps-tryon-history-delete", onClick: (e) => {
1072
1107
  e.stopPropagation();
1073
1108
  setHistory((prev) => prev.filter((_, i) => i !== idx));
@@ -1213,6 +1248,7 @@ const STYLES = `
1213
1248
  scrollbar-width: thin; scrollbar-color: #333 transparent;
1214
1249
  }
1215
1250
  .ps-tryon-modal-wide { max-width: 920px; }
1251
+ .ps-tryon-modal:has(.ps-tryon-drawer-open) { overflow: hidden; }
1216
1252
  @keyframes ps-slide-up { from { transform: translateY(20px) scale(0.97); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
1217
1253
 
1218
1254
  /* Header */
@@ -1412,6 +1448,19 @@ const STYLES = `
1412
1448
  .ps-tryon-shoe-section { border-top: 1px solid #333; padding-top: 14px; margin-top: 6px; display: flex; flex-direction: column; gap: 10px; }
1413
1449
  .ps-tryon-shoe-title { font-size: 13px; font-weight: 600; color: #999; }
1414
1450
  .ps-tryon-disclaimer { font-size: 11px; color: #666; margin: 4px 0 0; }
1451
+ .ps-tryon-form-save-toggle { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
1452
+ .ps-tryon-form-save-check {
1453
+ display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ccc; cursor: pointer; user-select: none;
1454
+ }
1455
+ .ps-tryon-form-save-check input[type="checkbox"] {
1456
+ width: 16px; height: 16px; accent-color: #bb945c; cursor: pointer;
1457
+ }
1458
+ .ps-tryon-form-save-name {
1459
+ padding: 8px 12px; border: 1.5px solid #333; border-radius: 10px;
1460
+ background: #1a1b1a; color: #fff; font-size: 13px; font-family: inherit; outline: none;
1461
+ transition: border-color 0.2s;
1462
+ }
1463
+ .ps-tryon-form-save-name:focus { border-color: #bb945c; }
1415
1464
 
1416
1465
  /* Processing */
1417
1466
  .ps-tryon-processing { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; }
@@ -1519,6 +1568,9 @@ const STYLES = `
1519
1568
  font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; font-family: inherit;
1520
1569
  }
1521
1570
  .ps-tryon-save-row button:hover { opacity: 0.9; }
1571
+ .ps-tryon-save-btn-group { display: flex; gap: 6px; }
1572
+ .ps-tryon-save-new-btn { background: transparent !important; border: 1.5px solid #bb945c !important; color: #bb945c !important; }
1573
+ .ps-tryon-save-new-btn:hover { background: rgba(187,148,92,0.1) !important; }
1522
1574
  .ps-tryon-save-done { font-size: 12px; color: #4ade80; margin-top: 10px; display: flex; align-items: center; gap: 6px; justify-content: center; }
1523
1575
  .ps-tryon-save-done svg { stroke: currentColor; }
1524
1576
 
@@ -1547,7 +1599,7 @@ const STYLES = `
1547
1599
  }
1548
1600
  .ps-tryon-drawer-back:hover { border-color: #bb945c; color: #bb945c; }
1549
1601
  .ps-tryon-drawer-title { font-size: 16px; font-weight: 600; color: #fff; }
1550
- .ps-tryon-drawer-list { display: flex; flex-direction: column; gap: 8px; }
1602
+ .ps-tryon-drawer-list { display: flex; flex-direction: column; gap: 10px; }
1551
1603
  .ps-tryon-drawer-empty { text-align: center; padding: 32px 16px; color: #666; font-size: 14px; }
1552
1604
 
1553
1605
  /* Profile items */
@@ -1570,22 +1622,24 @@ const STYLES = `
1570
1622
 
1571
1623
  /* History items */
1572
1624
  .ps-tryon-history-item {
1573
- display: flex; gap: 10px; padding: 12px;
1574
- border: 1px solid #333; border-radius: 12px; align-items: center; transition: all 0.2s;
1625
+ display: flex; gap: 14px; padding: 14px;
1626
+ border: 1px solid #333; border-radius: 12px; align-items: flex-start; transition: all 0.2s;
1575
1627
  }
1576
- .ps-tryon-history-item:hover { border-color: #bb945c; }
1577
- .ps-tryon-history-thumb { width: 48px; height: 60px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
1628
+ .ps-tryon-history-item:hover { border-color: #bb945c; box-shadow: 0 4px 12px rgba(187,148,92,0.06); }
1629
+ .ps-tryon-history-images { display: flex; gap: 8px; flex-shrink: 0; }
1630
+ .ps-tryon-history-thumb { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
1578
1631
  .ps-tryon-history-info { flex: 1; min-width: 0; }
1579
- .ps-tryon-history-product { font-size: 13px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1632
+ .ps-tryon-history-product { font-size: 13px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
1580
1633
  .ps-tryon-history-meta { font-size: 11px; color: #666; margin-top: 3px; }
1581
- .ps-tryon-history-sizing { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
1634
+ .ps-tryon-history-sizing { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
1635
+ .ps-tryon-history-sizing-reason { font-size: 11px; color: #999; flex: 1; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
1582
1636
  .ps-tryon-history-size-badge {
1583
- width: 28px; height: 28px; border-radius: 50%;
1637
+ flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
1584
1638
  display: flex; align-items: center; justify-content: center;
1585
1639
  background: linear-gradient(135deg, #bb945c, #d6ba7d);
1586
- color: #111; font-size: 11px; font-weight: 700; flex-shrink: 0;
1640
+ color: #111; font-size: 13px; font-weight: 700;
1587
1641
  }
1588
- .ps-tryon-history-result-img { width: 48px; height: 60px; border-radius: 8px; object-fit: cover; flex-shrink: 0; border: 1.5px solid #bb945c; }
1642
+ .ps-tryon-history-result-img { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; flex-shrink: 0; border: 2px solid #bb945c; }
1589
1643
  .ps-tryon-history-delete {
1590
1644
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
1591
1645
  border: none; background: transparent; cursor: pointer; color: #666; border-radius: 6px; transition: all 0.2s; flex-shrink: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",