@primestyleai/tryon 5.6.1 → 5.6.2

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.
@@ -7169,11 +7169,12 @@ function MySizingProfilesView({
7169
7169
  activeProfileId,
7170
7170
  onSelectProfile,
7171
7171
  onEditProfile,
7172
- onCreateProfile,
7172
+ onSaveNewProfile,
7173
7173
  onDeleteProfile,
7174
7174
  onClose,
7175
7175
  t
7176
7176
  }) {
7177
+ const [creating, setCreating] = useState(false);
7177
7178
  const allHistory = useMemo(() => {
7178
7179
  const items = [];
7179
7180
  for (const p of profiles) {
@@ -7183,19 +7184,48 @@ function MySizingProfilesView({
7183
7184
  }
7184
7185
  return items.sort((a, b) => b.entry.savedAt - a.entry.savedAt).slice(0, 12);
7185
7186
  }, [profiles]);
7187
+ const handleSaveNewProfile = (data) => {
7188
+ onSaveNewProfile(data);
7189
+ setCreating(false);
7190
+ };
7186
7191
  return /* @__PURE__ */ jsxs("div", { className: "ps-msp-root", children: [
7187
7192
  /* @__PURE__ */ jsxs("div", { className: "ps-msp-topbar", children: [
7188
- /* @__PURE__ */ jsx("button", { type: "button", className: "ps-msp-back", onClick: onClose, "aria-label": t("Back"), children: /* @__PURE__ */ jsx(ArrowLeftIcon, {}) }),
7189
- /* @__PURE__ */ jsx("span", { className: "ps-msp-topbar-title", children: t("MY SIZING PROFILES") }),
7193
+ /* @__PURE__ */ jsx(
7194
+ "button",
7195
+ {
7196
+ type: "button",
7197
+ className: "ps-msp-back",
7198
+ onClick: () => creating ? setCreating(false) : onClose(),
7199
+ "aria-label": t("Back"),
7200
+ children: /* @__PURE__ */ jsx(ArrowLeftIcon, {})
7201
+ }
7202
+ ),
7203
+ /* @__PURE__ */ jsx("span", { className: "ps-msp-topbar-title", children: creating ? t("CREATE PROFILE") : t("MY SIZING PROFILES") }),
7190
7204
  /* @__PURE__ */ jsx("span", { className: "ps-msp-topbar-spacer" })
7191
7205
  ] }),
7192
- /* @__PURE__ */ jsxs("div", { className: "ps-msp-scroll", children: [
7206
+ /* @__PURE__ */ jsx("div", { className: "ps-msp-scroll", children: creating ? (
7207
+ /* ── Inline create form (ProfileEditView) ── */
7208
+ /* @__PURE__ */ jsxs("div", { className: "ps-msp-create-form-wrap", children: [
7209
+ /* @__PURE__ */ jsxs("div", { className: "ps-msp-header", children: [
7210
+ /* @__PURE__ */ jsx("h2", { className: "ps-msp-title", children: t("Create New Profile") }),
7211
+ /* @__PURE__ */ jsx("p", { className: "ps-msp-subtitle", children: t("Add a name, your basics, and we'll compute your full body measurements automatically.") })
7212
+ ] }),
7213
+ /* @__PURE__ */ jsx(
7214
+ ProfileEditView,
7215
+ {
7216
+ onSave: handleSaveNewProfile,
7217
+ onCancel: () => setCreating(false),
7218
+ t
7219
+ }
7220
+ )
7221
+ ] })
7222
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
7193
7223
  /* @__PURE__ */ jsxs("div", { className: "ps-msp-header", children: [
7194
7224
  /* @__PURE__ */ jsx("h2", { className: "ps-msp-title", children: t("My Sizing Profiles") }),
7195
7225
  /* @__PURE__ */ jsx("p", { className: "ps-msp-subtitle", children: t("Manage your bespoke silhouettes. Switch between profiles for different fits or create a new one for specific garment types.") })
7196
7226
  ] }),
7197
7227
  /* @__PURE__ */ jsxs("div", { className: "ps-msp-grid", children: [
7198
- /* @__PURE__ */ jsx(CreateProfileCard, { onClick: onCreateProfile, t }),
7228
+ /* @__PURE__ */ jsx(CreateProfileCard, { onClick: () => setCreating(true), t }),
7199
7229
  profiles.map((p) => /* @__PURE__ */ jsx(
7200
7230
  ProfileCard,
7201
7231
  {
@@ -7212,7 +7242,7 @@ function MySizingProfilesView({
7212
7242
  /* @__PURE__ */ jsx("h3", { className: "ps-msp-history-title", children: t("Recent Size Calculations") }),
7213
7243
  /* @__PURE__ */ jsx("div", { className: "ps-msp-history-list", children: allHistory.map(({ entry, profileName }) => /* @__PURE__ */ jsx(SizeHistoryCard, { entry, profileName, t }, `${entry.productId}-${entry.savedAt}`)) })
7214
7244
  ] })
7215
- ] })
7245
+ ] }) })
7216
7246
  ] });
7217
7247
  }
7218
7248
  function ResultView({ setView }) {
@@ -9541,12 +9571,36 @@ function PrimeStyleTryonInner({
9541
9571
  onEditProfile: (p) => {
9542
9572
  setProfileDetail(p);
9543
9573
  },
9544
- onCreateProfile: () => {
9545
- setActiveProfileId$1(null);
9546
- formRef.current = {};
9547
- setFormGender("male");
9548
- setFormKey((k) => k + 1);
9549
- setView("body-profile");
9574
+ onSaveNewProfile: (data) => {
9575
+ const newProfile = {
9576
+ ...data,
9577
+ id: Date.now().toString(36) + Math.random().toString(36).slice(2, 6),
9578
+ createdAt: Date.now(),
9579
+ lastUsedAt: Date.now()
9580
+ };
9581
+ setProfiles((prev) => [newProfile, ...prev]);
9582
+ setActiveProfileId$1(newProfile.id);
9583
+ const heightVal = newProfile.heightCm || newProfile.height || 0;
9584
+ const weightVal = newProfile.weightKg || newProfile.weight || 0;
9585
+ const heightUnitVal = newProfile.sizingUnit === "in" ? "in" : "cm";
9586
+ const weightUnitVal = newProfile.sizingUnit === "in" ? "lbs" : "kg";
9587
+ if (heightVal > 0 && weightVal > 0) {
9588
+ estimateFullMeasurements({
9589
+ apiUrl,
9590
+ height: heightVal,
9591
+ weight: weightVal,
9592
+ heightUnit: heightUnitVal,
9593
+ weightUnit: weightUnitVal,
9594
+ gender: newProfile.gender,
9595
+ age: newProfile.age
9596
+ }).then((est) => {
9597
+ if (est) {
9598
+ updateProfileMeasurements(newProfile.id, est.estimates, est.unit);
9599
+ setProfiles(lsGet("profiles", []));
9600
+ }
9601
+ }).catch(() => {
9602
+ });
9603
+ }
9550
9604
  },
9551
9605
  onDeleteProfile: (id) => setProfiles((prev) => prev.filter((p) => p.id !== id)),
9552
9606
  onClose: () => setView("body-profile"),
@@ -14,10 +14,13 @@ interface MySizingProfilesViewProps {
14
14
  activeProfileId: string | null;
15
15
  onSelectProfile: (id: string) => void;
16
16
  onEditProfile: (p: Profile) => void;
17
- onCreateProfile: () => void;
17
+ /** Save a new profile (called from the inline ProfileEditView form). Parent
18
+ should add it to the profiles list and run estimateFullMeasurements in
19
+ the background to populate measurements. */
20
+ onSaveNewProfile: (data: Omit<Profile, "id" | "createdAt">) => void;
18
21
  onDeleteProfile: (id: string) => void;
19
22
  onClose: () => void;
20
23
  t: TranslateFn;
21
24
  }
22
- export declare function MySizingProfilesView({ profiles, activeProfileId, onSelectProfile, onEditProfile, onCreateProfile, onDeleteProfile, onClose, t, }: MySizingProfilesViewProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function MySizingProfilesView({ profiles, activeProfileId, onSelectProfile, onEditProfile, onSaveNewProfile, onDeleteProfile, onClose, t, }: MySizingProfilesViewProps): import("react/jsx-runtime").JSX.Element;
23
26
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.6.1",
3
+ "version": "5.6.2",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",