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

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. */
@@ -50,6 +52,7 @@ declare const resources: {
50
52
  readonly download: "Download";
51
53
  readonly errorBadge: "Little error";
52
54
  readonly errorDifferentPhoto: "Change photo";
55
+ readonly errorFileTooLarge: "File is too large. Maximum file size is 10 MB";
53
56
  readonly errorGuidance: "Try again with a different photo. Make sure it shows your full body.";
54
57
  readonly errorRetry: "Try again";
55
58
  readonly errorSubtitle: "It happens — let's try again";
@@ -115,7 +118,8 @@ declare const resources: {
115
118
  readonly resultReset: "Save";
116
119
  readonly resultShare: "Share";
117
120
  readonly resultTitle: "Here's how it looks on you";
118
- readonly resultTryAnother: "Add To Cart – $430";
121
+ readonly resultTryAnother: "Add To Cart";
122
+ readonly resultTryAnotherWithPrice: "Add To Cart – {{price}}";
119
123
  readonly share: "Share";
120
124
  readonly startHistory: "View previous results";
121
125
  readonly startTitle: "Want to see it on you?";
@@ -161,6 +165,7 @@ declare const resources: {
161
165
  readonly download: "Скачать";
162
166
  readonly errorBadge: "Небольшая ошибка";
163
167
  readonly errorDifferentPhoto: "Изменить фото";
168
+ readonly errorFileTooLarge: "Файл слишком большой. Максимальный размер файла — 10 МБ";
164
169
  readonly errorGuidance: "Попробуйте другое фото. Убедитесь, что вы видны в полный рост.";
165
170
  readonly errorRetry: "Попробовать снова";
166
171
  readonly errorSubtitle: "Так бывает — попробуем еще раз";
@@ -226,7 +231,8 @@ declare const resources: {
226
231
  readonly resultReset: "Сохранить";
227
232
  readonly resultShare: "Поделиться";
228
233
  readonly resultTitle: "Вот как это выглядит на вас";
229
- readonly resultTryAnother: "Add To Cart – $430";
234
+ readonly resultTryAnother: "Add To Cart";
235
+ readonly resultTryAnotherWithPrice: "Add To Cart – {{price}}";
230
236
  readonly share: "Поделиться";
231
237
  readonly startHistory: "Смотреть прошлые результаты";
232
238
  readonly startTitle: "Хотите увидеть это на себе?";
package/dist/index.js CHANGED
@@ -10161,6 +10161,7 @@ const ns1 = {
10161
10161
  download: 'Download',
10162
10162
  errorBadge: 'Little error',
10163
10163
  errorDifferentPhoto: 'Change photo',
10164
+ errorFileTooLarge: 'File is too large. Maximum file size is 10 MB',
10164
10165
  errorGuidance: 'Try again with a different photo. Make sure it shows your full body.',
10165
10166
  errorRetry: 'Try again',
10166
10167
  errorSubtitle: 'It happens — let\'s try again',
@@ -10226,7 +10227,8 @@ const ns1 = {
10226
10227
  resultReset: 'Save',
10227
10228
  resultShare: 'Share',
10228
10229
  resultTitle: 'Here\'s how it looks on you',
10229
- resultTryAnother: 'Add To Cart – $430',
10230
+ resultTryAnother: 'Add To Cart',
10231
+ resultTryAnotherWithPrice: 'Add To Cart – {{price}}',
10230
10232
  share: 'Share',
10231
10233
  startHistory: 'View previous results',
10232
10234
  startTitle: 'Want to see it on you?',
@@ -10270,6 +10272,7 @@ const ru_ns1 = {
10270
10272
  download: 'Скачать',
10271
10273
  errorBadge: 'Небольшая ошибка',
10272
10274
  errorDifferentPhoto: 'Изменить фото',
10275
+ errorFileTooLarge: 'Файл слишком большой. Максимальный размер файла — 10 МБ',
10273
10276
  errorGuidance: 'Попробуйте другое фото. Убедитесь, что вы видны в полный рост.',
10274
10277
  errorRetry: 'Попробовать снова',
10275
10278
  errorSubtitle: 'Так бывает — попробуем еще раз',
@@ -10335,7 +10338,8 @@ const ru_ns1 = {
10335
10338
  resultReset: 'Сохранить',
10336
10339
  resultShare: 'Поделиться',
10337
10340
  resultTitle: 'Вот как это выглядит на вас',
10338
- resultTryAnother: 'Add To Cart – $430',
10341
+ resultTryAnother: 'Add To Cart',
10342
+ resultTryAnotherWithPrice: 'Add To Cart – {{price}}',
10339
10343
  share: 'Поделиться',
10340
10344
  startHistory: 'Смотреть прошлые результаты',
10341
10345
  startTitle: 'Хотите увидеть это на себе?',
@@ -18179,9 +18183,13 @@ function ResultImagePanel({ className, onOpenComparison, productLabel, productUr
18179
18183
  });
18180
18184
  }
18181
18185
  const COMPARISON_DIALOG_BACKGROUND_CLASS_NAME = 'bg-[#212124E5]';
18182
- function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult, onShareResult, portalContainer, productName, productUrl, result }) {
18186
+ function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult, onShareResult, portalContainer, productName, productPrice, productUrl, result }) {
18183
18187
  const { t } = useTranslation();
18184
18188
  const productLabel = productName ?? t('resultProductLink');
18189
+ const normalizedProductPrice = normalizeProductPrice(productPrice);
18190
+ const addToCartLabel = normalizedProductPrice ? t('resultTryAnotherWithPrice', {
18191
+ price: normalizedProductPrice
18192
+ }) : t('resultTryAnother');
18185
18193
  function handleDelete() {
18186
18194
  onDeleteResult();
18187
18195
  }
@@ -18306,7 +18314,7 @@ function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult,
18306
18314
  }),
18307
18315
  /*#__PURE__*/ jsx_runtime_jsx("span", {
18308
18316
  className: "truncate",
18309
- children: t('resultTryAnother')
18317
+ children: addToCartLabel
18310
18318
  })
18311
18319
  ]
18312
18320
  }),
@@ -18347,6 +18355,10 @@ function ComparisonDialog({ onAddToCart, onClose, onDeleteResult, onSaveResult,
18347
18355
  })
18348
18356
  });
18349
18357
  }
18358
+ function normalizeProductPrice(value) {
18359
+ const normalized = value?.trim();
18360
+ return normalized || void 0;
18361
+ }
18350
18362
  const badgeVariants = cva('inline-flex w-fit items-center justify-center overflow-hidden rounded-full whitespace-nowrap', {
18351
18363
  variants: {
18352
18364
  variant: {
@@ -19081,11 +19093,12 @@ function ProcessingScreen({ view }) {
19081
19093
  }
19082
19094
  function ErrorScreen({ view }) {
19083
19095
  const { t } = useTranslation();
19096
+ const isFileTooLarge = 'upload-validation' === view.error.kind && 'file-too-large' === view.error.code;
19084
19097
  return /*#__PURE__*/ jsxs(ScreenLayout, {
19085
- title: t('errorTitle'),
19086
- subtitle: t('errorSubtitle'),
19098
+ title: t(isFileTooLarge ? 'errorFileTooLarge' : 'errorTitle'),
19099
+ subtitle: isFileTooLarge ? void 0 : t('errorSubtitle'),
19087
19100
  children: [
19088
- /*#__PURE__*/ jsxs(TryOnImagePanel, {
19101
+ !isFileTooLarge && /*#__PURE__*/ jsxs(TryOnImagePanel, {
19089
19102
  className: "mt-3",
19090
19103
  children: [
19091
19104
  /*#__PURE__*/ jsx_runtime_jsx(BlurredPhotoBackdrop, {
@@ -19169,6 +19182,10 @@ function ErrorScreen({ view }) {
19169
19182
  }
19170
19183
  function ResultScreen({ view }) {
19171
19184
  const { t } = useTranslation();
19185
+ const normalizedProductPrice = try_on_screens_normalizeProductPrice(view.productPrice);
19186
+ const addToCartLabel = normalizedProductPrice ? t('resultTryAnotherWithPrice', {
19187
+ price: normalizedProductPrice
19188
+ }) : t('resultTryAnother');
19172
19189
  if (view.myFitsOpen) return /*#__PURE__*/ jsx_runtime_jsx("div", {
19173
19190
  className: "min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain pb-4",
19174
19191
  children: /*#__PURE__*/ jsx_runtime_jsx("div", {
@@ -19177,6 +19194,7 @@ function ResultScreen({ view }) {
19177
19194
  compact: index > 0,
19178
19195
  onAddToCart: view.addToCart,
19179
19196
  productName: historyItem.productName ?? view.productName,
19197
+ productPrice: historyItem.productPrice,
19180
19198
  productUrl: historyItem.productUrl ?? view.productUrl,
19181
19199
  result: historyItem,
19182
19200
  onDeleteResult: view.deleteResult,
@@ -19212,7 +19230,7 @@ function ResultScreen({ view }) {
19212
19230
  /*#__PURE__*/ jsx_runtime_jsx(Cart, {
19213
19231
  "data-icon": "inline-start"
19214
19232
  }),
19215
- t('resultTryAnother')
19233
+ addToCartLabel
19216
19234
  ]
19217
19235
  }),
19218
19236
  /*#__PURE__*/ jsxs("div", {
@@ -19258,9 +19276,13 @@ function ResultScreen({ view }) {
19258
19276
  ]
19259
19277
  });
19260
19278
  }
19261
- function ResultFitCard({ compact = false, onAddToCart, onDeleteResult, onOpenComparison, onSaveResult, onShareResult, productName, productUrl, result }) {
19279
+ function ResultFitCard({ compact = false, onAddToCart, onDeleteResult, onOpenComparison, onSaveResult, onShareResult, productName, productPrice, productUrl, result }) {
19262
19280
  const { t } = useTranslation();
19263
19281
  const productLabel = productName ?? t('resultProductLink');
19282
+ const normalizedProductPrice = try_on_screens_normalizeProductPrice(productPrice);
19283
+ const addToCartLabel = normalizedProductPrice ? t('resultTryAnotherWithPrice', {
19284
+ price: normalizedProductPrice
19285
+ }) : t('resultTryAnother');
19264
19286
  return /*#__PURE__*/ jsxs("div", {
19265
19287
  className: "flex flex-col gap-4",
19266
19288
  children: [
@@ -19286,7 +19308,7 @@ function ResultFitCard({ compact = false, onAddToCart, onDeleteResult, onOpenCom
19286
19308
  }),
19287
19309
  /*#__PURE__*/ jsx_runtime_jsx("span", {
19288
19310
  className: "truncate",
19289
- children: t('resultTryAnother')
19311
+ children: addToCartLabel
19290
19312
  })
19291
19313
  ]
19292
19314
  }),
@@ -19393,6 +19415,10 @@ function TermsCopy({ className }) {
19393
19415
  ]
19394
19416
  });
19395
19417
  }
19418
+ function try_on_screens_normalizeProductPrice(value) {
19419
+ const normalized = value?.trim();
19420
+ return normalized || void 0;
19421
+ }
19396
19422
  const REQUIRED_UPLOAD_COUNT = 2;
19397
19423
  function createNanoBananaAiTryOnProcessor({ createObjectUrl = defaultCreateObjectUrl, fetch: fetchImpl, productImageSrc, productType, tryOnClient, apiKey }) {
19398
19424
  assertProductType(productType);
@@ -19728,6 +19754,7 @@ async function toStoredResult(result) {
19728
19754
  id: result.id,
19729
19755
  productImageSrc: result.productImageSrc,
19730
19756
  productName: result.productName,
19757
+ productPrice: result.productPrice,
19731
19758
  productUrl: result.productUrl
19732
19759
  };
19733
19760
  }
@@ -19817,7 +19844,7 @@ class AiTryOnSession {
19817
19844
  createObjectUrl;
19818
19845
  tipStore;
19819
19846
  state;
19820
- constructor({ createObjectUrl, productImageSrc, productName, productType, productUrl, tipStore }){
19847
+ constructor({ createObjectUrl, productImageSrc, productName, productPrice, productType, productUrl, tipStore }){
19821
19848
  this.createObjectUrl = createObjectUrl;
19822
19849
  this.tipStore = tipStore;
19823
19850
  this.state = {
@@ -19830,6 +19857,7 @@ class AiTryOnSession {
19830
19857
  processingProgress: 0,
19831
19858
  productImageSrc,
19832
19859
  productName,
19860
+ productPrice: ai_try_on_session_normalizeProductPrice(productPrice),
19833
19861
  productType,
19834
19862
  productUrl,
19835
19863
  result: null,
@@ -19865,6 +19893,7 @@ class AiTryOnSession {
19865
19893
  canOpenMyFits: this.state.history.length > 0,
19866
19894
  myFitsOpen: this.state.myFitsOpen,
19867
19895
  productName: this.state.result?.productName ?? this.state.productName,
19896
+ productPrice: this.state.result ? ai_try_on_session_normalizeProductPrice(this.state.result.productPrice) : this.state.productPrice,
19868
19897
  productUrl: this.state.result?.productUrl ?? this.state.productUrl,
19869
19898
  result: this.state.result,
19870
19899
  resultHistory: getResultHistory(this.state.result, this.state.history),
@@ -19887,6 +19916,7 @@ class AiTryOnSession {
19887
19916
  return {
19888
19917
  open: this.state.comparisonOpen && null !== result,
19889
19918
  productName: result?.productName ?? this.state.productName,
19919
+ productPrice: result ? ai_try_on_session_normalizeProductPrice(result.productPrice) : this.state.productPrice,
19890
19920
  productUrl: result?.productUrl ?? this.state.productUrl,
19891
19921
  result
19892
19922
  };
@@ -19897,11 +19927,12 @@ class AiTryOnSession {
19897
19927
  get history() {
19898
19928
  return this.state.history;
19899
19929
  }
19900
- updateProduct({ productImageSrc, productName, productType, productUrl }) {
19930
+ updateProduct({ productImageSrc, productName, productPrice, productType, productUrl }) {
19901
19931
  this.state = {
19902
19932
  ...this.state,
19903
19933
  productImageSrc,
19904
19934
  productName,
19935
+ productPrice: ai_try_on_session_normalizeProductPrice(productPrice),
19905
19936
  productType,
19906
19937
  productUrl
19907
19938
  };
@@ -20202,6 +20233,7 @@ class AiTryOnSession {
20202
20233
  return {
20203
20234
  productImageSrc: this.state.productImageSrc,
20204
20235
  productName: this.state.productName,
20236
+ productPrice: this.state.productPrice,
20205
20237
  productUrl: this.state.productUrl
20206
20238
  };
20207
20239
  }
@@ -20220,10 +20252,15 @@ function createAiTryOnHistoryItem(result, metadata, createdAt = Date.now()) {
20220
20252
  return {
20221
20253
  ...result,
20222
20254
  ...metadata,
20255
+ productPrice: ai_try_on_session_normalizeProductPrice(metadata.productPrice),
20223
20256
  createdAt,
20224
20257
  id: `${result.before.id}-result-${createdAt}`
20225
20258
  };
20226
20259
  }
20260
+ function ai_try_on_session_normalizeProductPrice(value) {
20261
+ const normalized = value?.trim();
20262
+ return normalized || void 0;
20263
+ }
20227
20264
  function getResultHistory(result, history) {
20228
20265
  if (!result) return [];
20229
20266
  const results = [
@@ -20335,6 +20372,7 @@ function reviveStoredResult(result, createObjectUrl) {
20335
20372
  id: result.id,
20336
20373
  productImageSrc: result.productImageSrc,
20337
20374
  productName: result.productName,
20375
+ productPrice: result.productPrice,
20338
20376
  productUrl: result.productUrl
20339
20377
  };
20340
20378
  }
@@ -20389,7 +20427,7 @@ function collectPhotoObjectUrl(photo) {
20389
20427
  photo.src
20390
20428
  ] : null;
20391
20429
  }
20392
- function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, objectUrls = browserAiTryOnObjectUrls, onRequestClose, onRequestFileInput, processPhoto, productImageSrc, productName, productType, productUrl, tryOnClient, resultActions = browserAiTryOnResultActions, tipStore = browserAiTryOnTipStore }) {
20430
+ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, objectUrls = browserAiTryOnObjectUrls, onRequestClose, onRequestFileInput, processPhoto, productImageSrc, productName, productPrice, productType, productUrl, tryOnClient, resultActions = browserAiTryOnResultActions, tipStore = browserAiTryOnTipStore }) {
20393
20431
  const [, rerender] = (0, __rspack_external_react.useReducer)((value)=>value + 1, 0);
20394
20432
  const trackedObjectUrls = (0, __rspack_external_react.useRef)(new Set());
20395
20433
  const createTrackedObjectUrl = (0, __rspack_external_react.useCallback)((blob)=>{
@@ -20404,6 +20442,7 @@ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, object
20404
20442
  createObjectUrl: createTrackedObjectUrl,
20405
20443
  productImageSrc,
20406
20444
  productName,
20445
+ productPrice,
20407
20446
  productType,
20408
20447
  productUrl,
20409
20448
  tipStore
@@ -20412,6 +20451,7 @@ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, object
20412
20451
  session.updateProduct({
20413
20452
  productImageSrc,
20414
20453
  productName,
20454
+ productPrice,
20415
20455
  productType,
20416
20456
  productUrl
20417
20457
  });
@@ -20603,7 +20643,7 @@ function useAiTryOnSession({ historyStore = indexedDbAiTryOnHistoryStore, object
20603
20643
  function waitForRemainingProcessingDuration(startedAt) {
20604
20644
  return waitForProcessingDuration(getRemainingProcessingDuration(startedAt));
20605
20645
  }
20606
- function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, productImageSrc, productName, productType, productUrl, tryOnClient: providedTryOnClient, apiKey, showDialogCloseButton = false }) {
20646
+ function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, productImageSrc, productName, productPrice, productType, productUrl, tryOnClient: providedTryOnClient, apiKey, showDialogCloseButton = false }) {
20607
20647
  assertProductType(productType);
20608
20648
  const { i18n, t } = useTranslation();
20609
20649
  const fileInputRef = (0, __rspack_external_react.useRef)(null);
@@ -20626,6 +20666,7 @@ function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, p
20626
20666
  processPhoto,
20627
20667
  productImageSrc,
20628
20668
  productName,
20669
+ productPrice,
20629
20670
  productType,
20630
20671
  productUrl,
20631
20672
  tryOnClient
@@ -20703,6 +20744,7 @@ function AiTryOnRoot({ dialogPortalContainer, language, onClose, processPhoto, p
20703
20744
  }, stage),
20704
20745
  session.comparison.open && /*#__PURE__*/ jsx_runtime_jsx(ComparisonDialog, {
20705
20746
  productName: session.comparison.productName,
20747
+ productPrice: session.comparison.productPrice,
20706
20748
  productUrl: session.comparison.productUrl,
20707
20749
  portalContainer: dialogPortalContainer ?? void 0,
20708
20750
  result: session.comparison.result,
@@ -20746,7 +20788,7 @@ function getBadgeTone(stage) {
20746
20788
  configureNodeApiClient({
20747
20789
  baseURL: "https://api.neurodyn.ai/"
20748
20790
  });
20749
- function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, productImageSrc, productName, productType, productUrl, apiKey, ...props }) {
20791
+ function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, productImageSrc, productName, productPrice, productType, productUrl, apiKey, ...props }) {
20750
20792
  assertProductType(productType);
20751
20793
  const i18n = (0, __rspack_external_react.useMemo)(()=>createAiTryOnI18n(language), [
20752
20794
  language
@@ -20807,6 +20849,7 @@ function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, prod
20807
20849
  portalContainer: themeRoot,
20808
20850
  productImageSrc: productImageSrc,
20809
20851
  productName: productName,
20852
+ productPrice: productPrice,
20810
20853
  productType: productType,
20811
20854
  productUrl: productUrl,
20812
20855
  tryOnClient: tryOnClient,
@@ -20821,7 +20864,7 @@ function AiTryOnDialog({ defaultOpen = false, language, onOpenChange, open, prod
20821
20864
  ]
20822
20865
  });
20823
20866
  }
20824
- function AiTryOnDialogContent({ language, onRequestClose, portalContainer, productImageSrc, productName, productType, productUrl, tryOnClient, ...props }) {
20867
+ function AiTryOnDialogContent({ language, onRequestClose, portalContainer, productImageSrc, productName, productPrice, productType, productUrl, tryOnClient, ...props }) {
20825
20868
  const { t } = useTranslation();
20826
20869
  return /*#__PURE__*/ jsx_runtime_jsx(Dialog, {
20827
20870
  ...props,
@@ -20850,6 +20893,7 @@ function AiTryOnDialogContent({ language, onRequestClose, portalContainer, produ
20850
20893
  language: language,
20851
20894
  productImageSrc: productImageSrc,
20852
20895
  productName: productName,
20896
+ productPrice: productPrice,
20853
20897
  productType: productType,
20854
20898
  productUrl: productUrl,
20855
20899
  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.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },