@neurodyn/react-ai-try-on 0.0.2 → 0.0.3

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/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
2
2
  import { JSX } from 'react/jsx-runtime';
3
3
  import * as React_2 from 'react';
4
4
 
5
- export declare function AiTryOnDialog({ defaultOpen, language, onOpenChange, open, productImageSrc, productName, productType, productUrl, apiKey, ...props }: AiTryOnDialogProps): JSX.Element;
5
+ export declare function AiTryOnDialog({ defaultOpen, language, onOpenChange, open, productImageSrc, productName, productPrice, productType, productUrl, apiKey, ...props }: AiTryOnDialogProps): JSX.Element;
6
6
 
7
7
  declare interface AiTryOnDialogOwnProps extends Omit<DialogProps, 'children' | 'modal'> {
8
8
  /** UI language override. */
@@ -11,6 +11,8 @@ declare interface AiTryOnDialogOwnProps extends Omit<DialogProps, 'children' | '
11
11
  productImageSrc: string;
12
12
  /** Product name for product preview alt text and product page CTA. */
13
13
  productName: string;
14
+ /** Optional already-formatted product price shown in Add-to-Cart CTAs. */
15
+ productPrice?: string;
14
16
  /** Canonical product category sent unchanged to AI try-on generation. */
15
17
  productType: ProductType;
16
18
  /** Product page URL opened from the result product CTA. */
@@ -115,7 +117,8 @@ declare const resources: {
115
117
  readonly resultReset: "Save";
116
118
  readonly resultShare: "Share";
117
119
  readonly resultTitle: "Here's how it looks on you";
118
- readonly resultTryAnother: "Add To Cart – $430";
120
+ readonly resultTryAnother: "Add To Cart";
121
+ readonly resultTryAnotherWithPrice: "Add To Cart – {{price}}";
119
122
  readonly share: "Share";
120
123
  readonly startHistory: "View previous results";
121
124
  readonly startTitle: "Want to see it on you?";
@@ -226,7 +229,8 @@ declare const resources: {
226
229
  readonly resultReset: "Сохранить";
227
230
  readonly resultShare: "Поделиться";
228
231
  readonly resultTitle: "Вот как это выглядит на вас";
229
- readonly resultTryAnother: "Add To Cart – $430";
232
+ readonly resultTryAnother: "Add To Cart";
233
+ readonly resultTryAnotherWithPrice: "Add To Cart – {{price}}";
230
234
  readonly share: "Поделиться";
231
235
  readonly startHistory: "Смотреть прошлые результаты";
232
236
  readonly startTitle: "Хотите увидеть это на себе?";
package/dist/index.js CHANGED
@@ -10226,7 +10226,8 @@ const ns1 = {
10226
10226
  resultReset: 'Save',
10227
10227
  resultShare: 'Share',
10228
10228
  resultTitle: 'Here\'s how it looks on you',
10229
- resultTryAnother: 'Add To Cart – $430',
10229
+ resultTryAnother: 'Add To Cart',
10230
+ resultTryAnotherWithPrice: 'Add To Cart – {{price}}',
10230
10231
  share: 'Share',
10231
10232
  startHistory: 'View previous results',
10232
10233
  startTitle: 'Want to see it on you?',
@@ -10335,7 +10336,8 @@ const ru_ns1 = {
10335
10336
  resultReset: 'Сохранить',
10336
10337
  resultShare: 'Поделиться',
10337
10338
  resultTitle: 'Вот как это выглядит на вас',
10338
- resultTryAnother: 'Add To Cart – $430',
10339
+ resultTryAnother: 'Add To Cart',
10340
+ resultTryAnotherWithPrice: 'Add To Cart – {{price}}',
10339
10341
  share: 'Поделиться',
10340
10342
  startHistory: 'Смотреть прошлые результаты',
10341
10343
  startTitle: 'Хотите увидеть это на себе?',
@@ -18179,9 +18181,13 @@ function ResultImagePanel({ className, onOpenComparison, productLabel, productUr
18179
18181
  });
18180
18182
  }
18181
18183
  const COMPARISON_DIALOG_BACKGROUND_CLASS_NAME = 'bg-[#212124E5]';
18182
- function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult, onShareResult, portalContainer, productName, productUrl, result }) {
18184
+ function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult, onShareResult, portalContainer, productName, productPrice, productUrl, result }) {
18183
18185
  const { t } = useTranslation();
18184
18186
  const productLabel = productName ?? t('resultProductLink');
18187
+ const normalizedProductPrice = normalizeProductPrice(productPrice);
18188
+ const addToCartLabel = normalizedProductPrice ? t('resultTryAnotherWithPrice', {
18189
+ price: normalizedProductPrice
18190
+ }) : t('resultTryAnother');
18185
18191
  function handleDelete() {
18186
18192
  onDeleteResult();
18187
18193
  }
@@ -18306,7 +18312,7 @@ function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult,
18306
18312
  }),
18307
18313
  /*#__PURE__*/ jsx_runtime_jsx("span", {
18308
18314
  className: "truncate",
18309
- children: t('resultTryAnother')
18315
+ children: addToCartLabel
18310
18316
  })
18311
18317
  ]
18312
18318
  }),
@@ -18347,6 +18353,10 @@ function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult,
18347
18353
  })
18348
18354
  });
18349
18355
  }
18356
+ function normalizeProductPrice(value) {
18357
+ const normalized = value?.trim();
18358
+ return normalized || void 0;
18359
+ }
18350
18360
  const badgeVariants = cva('inline-flex w-fit items-center justify-center overflow-hidden rounded-full whitespace-nowrap', {
18351
18361
  variants: {
18352
18362
  variant: {
@@ -19169,6 +19179,10 @@ function ErrorScreen({ view }) {
19169
19179
  }
19170
19180
  function ResultScreen({ view }) {
19171
19181
  const { t } = useTranslation();
19182
+ const normalizedProductPrice = try_on_screens_normalizeProductPrice(view.productPrice);
19183
+ const addToCartLabel = normalizedProductPrice ? t('resultTryAnotherWithPrice', {
19184
+ price: normalizedProductPrice
19185
+ }) : t('resultTryAnother');
19172
19186
  if (view.myFitsOpen) return /*#__PURE__*/ jsx_runtime_jsx("div", {
19173
19187
  className: "min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain pb-4",
19174
19188
  children: /*#__PURE__*/ jsx_runtime_jsx("div", {
@@ -19177,6 +19191,7 @@ function ResultScreen({ view }) {
19177
19191
  compact: index > 0,
19178
19192
  onAddToCart: view.addToCart,
19179
19193
  productName: historyItem.productName ?? view.productName,
19194
+ productPrice: historyItem.productPrice,
19180
19195
  productUrl: historyItem.productUrl ?? view.productUrl,
19181
19196
  result: historyItem,
19182
19197
  onDeleteResult: view.deleteResult,
@@ -19212,7 +19227,7 @@ function ResultScreen({ view }) {
19212
19227
  /*#__PURE__*/ jsx_runtime_jsx(Cart, {
19213
19228
  "data-icon": "inline-start"
19214
19229
  }),
19215
- t('resultTryAnother')
19230
+ addToCartLabel
19216
19231
  ]
19217
19232
  }),
19218
19233
  /*#__PURE__*/ jsxs("div", {
@@ -19258,9 +19273,13 @@ function ResultScreen({ view }) {
19258
19273
  ]
19259
19274
  });
19260
19275
  }
19261
- function ResultFitCard({ compact = false, onAddToCart, onDeleteResult, onOpenComparison, onSaveResult, onShareResult, productName, productUrl, result }) {
19276
+ function ResultFitCard({ compact = false, onAddToCart, onDeleteResult, onOpenComparison, onSaveResult, onShareResult, productName, productPrice, productUrl, result }) {
19262
19277
  const { t } = useTranslation();
19263
19278
  const productLabel = productName ?? t('resultProductLink');
19279
+ const normalizedProductPrice = try_on_screens_normalizeProductPrice(productPrice);
19280
+ const addToCartLabel = normalizedProductPrice ? t('resultTryAnotherWithPrice', {
19281
+ price: normalizedProductPrice
19282
+ }) : t('resultTryAnother');
19264
19283
  return /*#__PURE__*/ jsxs("div", {
19265
19284
  className: "flex flex-col gap-4",
19266
19285
  children: [
@@ -19286,7 +19305,7 @@ function ResultFitCard({ compact = false, onAddToCart, onDeleteResult, onOpenCom
19286
19305
  }),
19287
19306
  /*#__PURE__*/ jsx_runtime_jsx("span", {
19288
19307
  className: "truncate",
19289
- children: t('resultTryAnother')
19308
+ children: addToCartLabel
19290
19309
  })
19291
19310
  ]
19292
19311
  }),
@@ -19393,6 +19412,10 @@ function TermsCopy({ className }) {
19393
19412
  ]
19394
19413
  });
19395
19414
  }
19415
+ function try_on_screens_normalizeProductPrice(value) {
19416
+ const normalized = value?.trim();
19417
+ return normalized || void 0;
19418
+ }
19396
19419
  const REQUIRED_UPLOAD_COUNT = 2;
19397
19420
  function createNanoBananaAiTryOnProcessor({ createObjectUrl = defaultCreateObjectUrl, fetch: fetchImpl, productImageSrc, productType, tryOnClient, apiKey }) {
19398
19421
  assertProductType(productType);
@@ -19728,6 +19751,7 @@ async function toStoredResult(result) {
19728
19751
  id: result.id,
19729
19752
  productImageSrc: result.productImageSrc,
19730
19753
  productName: result.productName,
19754
+ productPrice: result.productPrice,
19731
19755
  productUrl: result.productUrl
19732
19756
  };
19733
19757
  }
@@ -19817,7 +19841,7 @@ class AiTryOnSession {
19817
19841
  createObjectUrl;
19818
19842
  tipStore;
19819
19843
  state;
19820
- constructor({ createObjectUrl, productImageSrc, productName, productType, productUrl, tipStore }){
19844
+ constructor({ createObjectUrl, productImageSrc, productName, productPrice, productType, productUrl, tipStore }){
19821
19845
  this.createObjectUrl = createObjectUrl;
19822
19846
  this.tipStore = tipStore;
19823
19847
  this.state = {
@@ -19830,6 +19854,7 @@ class AiTryOnSession {
19830
19854
  processingProgress: 0,
19831
19855
  productImageSrc,
19832
19856
  productName,
19857
+ productPrice: ai_try_on_session_normalizeProductPrice(productPrice),
19833
19858
  productType,
19834
19859
  productUrl,
19835
19860
  result: null,
@@ -19865,6 +19890,7 @@ class AiTryOnSession {
19865
19890
  canOpenMyFits: this.state.history.length > 0,
19866
19891
  myFitsOpen: this.state.myFitsOpen,
19867
19892
  productName: this.state.result?.productName ?? this.state.productName,
19893
+ productPrice: this.state.result ? ai_try_on_session_normalizeProductPrice(this.state.result.productPrice) : this.state.productPrice,
19868
19894
  productUrl: this.state.result?.productUrl ?? this.state.productUrl,
19869
19895
  result: this.state.result,
19870
19896
  resultHistory: getResultHistory(this.state.result, this.state.history),
@@ -19887,6 +19913,7 @@ class AiTryOnSession {
19887
19913
  return {
19888
19914
  open: this.state.comparisonOpen && null !== result,
19889
19915
  productName: result?.productName ?? this.state.productName,
19916
+ productPrice: result ? ai_try_on_session_normalizeProductPrice(result.productPrice) : this.state.productPrice,
19890
19917
  productUrl: result?.productUrl ?? this.state.productUrl,
19891
19918
  result
19892
19919
  };
@@ -19897,11 +19924,12 @@ class AiTryOnSession {
19897
19924
  get history() {
19898
19925
  return this.state.history;
19899
19926
  }
19900
- updateProduct({ productImageSrc, productName, productType, productUrl }) {
19927
+ updateProduct({ productImageSrc, productName, productPrice, productType, productUrl }) {
19901
19928
  this.state = {
19902
19929
  ...this.state,
19903
19930
  productImageSrc,
19904
19931
  productName,
19932
+ productPrice: ai_try_on_session_normalizeProductPrice(productPrice),
19905
19933
  productType,
19906
19934
  productUrl
19907
19935
  };
@@ -20202,6 +20230,7 @@ class AiTryOnSession {
20202
20230
  return {
20203
20231
  productImageSrc: this.state.productImageSrc,
20204
20232
  productName: this.state.productName,
20233
+ productPrice: this.state.productPrice,
20205
20234
  productUrl: this.state.productUrl
20206
20235
  };
20207
20236
  }
@@ -20220,10 +20249,15 @@ function createAiTryOnHistoryItem(result, metadata, createdAt = Date.now()) {
20220
20249
  return {
20221
20250
  ...result,
20222
20251
  ...metadata,
20252
+ productPrice: ai_try_on_session_normalizeProductPrice(metadata.productPrice),
20223
20253
  createdAt,
20224
20254
  id: `${result.before.id}-result-${createdAt}`
20225
20255
  };
20226
20256
  }
20257
+ function ai_try_on_session_normalizeProductPrice(value) {
20258
+ const normalized = value?.trim();
20259
+ return normalized || void 0;
20260
+ }
20227
20261
  function getResultHistory(result, history) {
20228
20262
  if (!result) return [];
20229
20263
  const results = [
@@ -20335,6 +20369,7 @@ function reviveStoredResult(result, createObjectUrl) {
20335
20369
  id: result.id,
20336
20370
  productImageSrc: result.productImageSrc,
20337
20371
  productName: result.productName,
20372
+ productPrice: result.productPrice,
20338
20373
  productUrl: result.productUrl
20339
20374
  };
20340
20375
  }
@@ -20389,7 +20424,7 @@ function collectPhotoObjectUrl(photo) {
20389
20424
  photo.src
20390
20425
  ] : null;
20391
20426
  }
20392
- function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, objectUrls = browserAiTryOnObjectUrls, onRequestClose, onRequestFileInput, processPhoto, productImageSrc, productName, productType, productUrl, tryOnClient, resultActions = browserAiTryOnResultActions, tipStore = browserAiTryOnTipStore }) {
20427
+ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, objectUrls = browserAiTryOnObjectUrls, onRequestClose, onRequestFileInput, processPhoto, productImageSrc, productName, productPrice, productType, productUrl, tryOnClient, resultActions = browserAiTryOnResultActions, tipStore = browserAiTryOnTipStore }) {
20393
20428
  const [, rerender] = (0, __rspack_external_react.useReducer)((value)=>value + 1, 0);
20394
20429
  const trackedObjectUrls = (0, __rspack_external_react.useRef)(new Set());
20395
20430
  const createTrackedObjectUrl = (0, __rspack_external_react.useCallback)((blob)=>{
@@ -20404,6 +20439,7 @@ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, object
20404
20439
  createObjectUrl: createTrackedObjectUrl,
20405
20440
  productImageSrc,
20406
20441
  productName,
20442
+ productPrice,
20407
20443
  productType,
20408
20444
  productUrl,
20409
20445
  tipStore
@@ -20412,6 +20448,7 @@ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, object
20412
20448
  session.updateProduct({
20413
20449
  productImageSrc,
20414
20450
  productName,
20451
+ productPrice,
20415
20452
  productType,
20416
20453
  productUrl
20417
20454
  });
@@ -20603,7 +20640,7 @@ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, object
20603
20640
  function waitForRemainingProcessingDuration(startedAt) {
20604
20641
  return waitForProcessingDuration(getRemainingProcessingDuration(startedAt));
20605
20642
  }
20606
- function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, productImageSrc, productName, productType, productUrl, tryOnClient: providedTryOnClient, apiKey, showDialogCloseButton = false }) {
20643
+ function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, productImageSrc, productName, productPrice, productType, productUrl, tryOnClient: providedTryOnClient, apiKey, showDialogCloseButton = false }) {
20607
20644
  assertProductType(productType);
20608
20645
  const { i18n, t } = useTranslation();
20609
20646
  const fileInputRef = (0, __rspack_external_react.useRef)(null);
@@ -20626,6 +20663,7 @@ function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, p
20626
20663
  processPhoto,
20627
20664
  productImageSrc,
20628
20665
  productName,
20666
+ productPrice,
20629
20667
  productType,
20630
20668
  productUrl,
20631
20669
  tryOnClient
@@ -20703,6 +20741,7 @@ function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, p
20703
20741
  }, stage),
20704
20742
  session.comparison.open && /*#__PURE__*/ jsx_runtime_jsx(ComparisonDialog, {
20705
20743
  productName: session.comparison.productName,
20744
+ productPrice: session.comparison.productPrice,
20706
20745
  productUrl: session.comparison.productUrl,
20707
20746
  portalContainer: dialogPortalContainer ?? void 0,
20708
20747
  result: session.comparison.result,
@@ -20746,7 +20785,7 @@ function getBadgeTone(stage) {
20746
20785
  configureNodeApiClient({
20747
20786
  baseURL: "https://api.neurodyn.ai/"
20748
20787
  });
20749
- function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, productImageSrc, productName, productType, productUrl, apiKey, ...props }) {
20788
+ function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, productImageSrc, productName, productPrice, productType, productUrl, apiKey, ...props }) {
20750
20789
  assertProductType(productType);
20751
20790
  const i18n = (0, __rspack_external_react.useMemo)(()=>createAiTryOnI18n(language), [
20752
20791
  language
@@ -20807,6 +20846,7 @@ function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, prod
20807
20846
  portalContainer: themeRoot,
20808
20847
  productImageSrc: productImageSrc,
20809
20848
  productName: productName,
20849
+ productPrice: productPrice,
20810
20850
  productType: productType,
20811
20851
  productUrl: productUrl,
20812
20852
  tryOnClient: tryOnClient,
@@ -20821,7 +20861,7 @@ function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, prod
20821
20861
  ]
20822
20862
  });
20823
20863
  }
20824
- function AiTryOnDialogContent({ language, onRequestClose, portalContainer, productImageSrc, productName, productType, productUrl, tryOnClient, ...props }) {
20864
+ function AiTryOnDialogContent({ language, onRequestClose, portalContainer, productImageSrc, productName, productPrice, productType, productUrl, tryOnClient, ...props }) {
20825
20865
  const { t } = useTranslation();
20826
20866
  return /*#__PURE__*/ jsx_runtime_jsx(Dialog, {
20827
20867
  ...props,
@@ -20850,6 +20890,7 @@ function AiTryOnDialogContent({ language, onRequestClose, portalContainer, produ
20850
20890
  language: language,
20851
20891
  productImageSrc: productImageSrc,
20852
20892
  productName: productName,
20893
+ productPrice: productPrice,
20853
20894
  productType: productType,
20854
20895
  productUrl: productUrl,
20855
20896
  tryOnClient: tryOnClient,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neurodyn/react-ai-try-on",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },