@thefittingroom/shop-ui 0.0.12 → 0.0.14

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.
@@ -10,5 +10,5 @@ import ScanCodeModal from './Modals/ScanCodeModal';
10
10
  import SignInModal from './Modals/SignInModal';
11
11
  import SizeErrorModal from './Modals/SizeErrorModal';
12
12
  import TryOnModal from './Modals/TryOnModal';
13
- import InitImageSlider from './slider';
14
- export { SignInModal, ForgotPasswordModal, ScanCodeModal, ErrorModal, LoadingAvatarModal, InitModalManager, ModalManager, NoAvatarModal, LoggedOutModal, SizeErrorModal, ResetLinkModal, InitImageSlider, TryOnModal, };
13
+ import { InitImageSlider } from './slider';
14
+ export { ErrorModal, ForgotPasswordModal, InitImageSlider, InitModalManager, LoadingAvatarModal, LoggedOutModal, ModalManager, NoAvatarModal, ResetLinkModal, ScanCodeModal, SignInModal, SizeErrorModal, TryOnModal, };
@@ -1,4 +1,3 @@
1
- declare const InitImageSlider: (sliderID: string, onChange: (slider: HTMLInputElement, imageUrl: string) => void) => {
1
+ export declare const InitImageSlider: (sliderID: string, onChange: (slider: HTMLInputElement, imageUrl: string) => void) => {
2
2
  Load(imageURLs: string[]): Error | (() => void);
3
3
  };
4
- export default InitImageSlider;
@@ -1,3 +1,4 @@
1
1
  export { VTO_TIMEOUT_MS } from '@thefittingroom/sdk';
2
+ export { InitImageSlider } from './components/slider';
2
3
  export { initFittingRoom } from './init';
3
4
  export type { FittingRoom } from './tfr';
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v0.0.12 (2023-07-26T23:25:57.440Z)
2
+ * thefittingroom v0.0.14 (2023-07-31T17:58:33.095Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  /*!
@@ -23138,6 +23138,50 @@ var AvatarState$1;
23138
23138
 
23139
23139
  const VTO_TIMEOUT_MS = TfrShop.vtoTimeout;
23140
23140
 
23141
+ function loadImageRecursive(imageURL, imageURLs) {
23142
+ let next = function () {
23143
+ if (imageURLs.length === 0) {
23144
+ return;
23145
+ }
23146
+ loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
23147
+ };
23148
+ var img = new Image();
23149
+ img.onload = next;
23150
+ img.onerror = next;
23151
+ img.src = imageURL;
23152
+ }
23153
+ function loadImages(imageURLs) {
23154
+ loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
23155
+ }
23156
+ const InitImageSlider = (sliderID, onChange) => {
23157
+ const slider = document.getElementById(sliderID);
23158
+ if (!slider) {
23159
+ throw new Error(`Slider with id ${sliderID} not found`);
23160
+ }
23161
+ return {
23162
+ Load(imageURLs) {
23163
+ if (!Array.isArray(imageURLs) || !imageURLs.length) {
23164
+ console.debug('slider has no images to load');
23165
+ return new Error('slider has no images to load');
23166
+ }
23167
+ loadImages(imageURLs);
23168
+ const defaultScrollValue = (imageURLs === null || imageURLs === void 0 ? void 0 : imageURLs.length) - 2;
23169
+ slider.value = defaultScrollValue.toString();
23170
+ slider.max = (imageURLs.length - 1).toString();
23171
+ const handleSliderChange = () => {
23172
+ const currentValue = parseInt(slider.value);
23173
+ onChange(slider, imageURLs[currentValue]);
23174
+ };
23175
+ onChange(slider, imageURLs[defaultScrollValue]);
23176
+ slider.removeEventListener('input', handleSliderChange);
23177
+ slider.addEventListener('input', handleSliderChange);
23178
+ return () => {
23179
+ slider.removeEventListener('input', handleSliderChange);
23180
+ };
23181
+ },
23182
+ };
23183
+ };
23184
+
23141
23185
  var L = {
23142
23186
  AssociatedEmail: 'If there is an account associated with that email, We have sent a link to reset your password.',
23143
23187
  BackToSignIn: 'Back to sign in',
@@ -36021,50 +36065,6 @@ const SizeErrorModal = (props) => {
36021
36065
  };
36022
36066
  };
36023
36067
 
36024
- function loadImageRecursive(imageURL, imageURLs) {
36025
- let next = function () {
36026
- if (imageURLs.length === 0) {
36027
- return;
36028
- }
36029
- loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
36030
- };
36031
- var img = new Image();
36032
- img.onload = next;
36033
- img.onerror = next;
36034
- img.src = imageURL;
36035
- }
36036
- function loadImages(imageURLs) {
36037
- loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
36038
- }
36039
- const InitImageSlider = (sliderID, onChange) => {
36040
- const slider = document.getElementById(sliderID);
36041
- if (!slider) {
36042
- throw new Error(`Slider with id ${sliderID} not found`);
36043
- }
36044
- return {
36045
- Load(imageURLs) {
36046
- if (!Array.isArray(imageURLs) || !imageURLs.length) {
36047
- console.debug('slider has no images to load');
36048
- return new Error('slider has no images to load');
36049
- }
36050
- loadImages(imageURLs);
36051
- const defaultScrollValue = (imageURLs === null || imageURLs === void 0 ? void 0 : imageURLs.length) - 2;
36052
- slider.value = defaultScrollValue.toString();
36053
- slider.max = (imageURLs.length - 1).toString();
36054
- const handleSliderChange = () => {
36055
- const currentValue = parseInt(slider.value);
36056
- onChange(slider, imageURLs[currentValue]);
36057
- };
36058
- onChange(slider, imageURLs[defaultScrollValue]);
36059
- slider.removeEventListener('input', handleSliderChange);
36060
- slider.addEventListener('input', handleSliderChange);
36061
- return () => {
36062
- slider.removeEventListener('input', handleSliderChange);
36063
- };
36064
- },
36065
- };
36066
- };
36067
-
36068
36068
  const TryOnModal = (props) => {
36069
36069
  let close = () => void 0;
36070
36070
  const onNavBack = () => {
@@ -36199,11 +36199,17 @@ var AvatarState;
36199
36199
  })(AvatarState || (AvatarState = {}));
36200
36200
 
36201
36201
  class FittingRoom {
36202
- constructor(shopId, modalDivId, hooks = {}) {
36202
+ constructor(shopId, modalDivId, hooks = {}, _env) {
36203
36203
  this.shopId = shopId;
36204
36204
  this.hooks = hooks;
36205
+ // prettier-ignore
36206
+ const env = _env
36207
+ ? _env
36208
+ : typeof process !== 'undefined'
36209
+ ? process.env.NODE_ENV
36210
+ : 'dev';
36205
36211
  this.nav = new FittingRoomNav(modalDivId, this.signIn.bind(this), this.forgotPassword.bind(this), this.submitTel.bind(this));
36206
- this.tfrShop = initShop(Number(this.shopId), process.env.NODE_ENV);
36212
+ this.tfrShop = initShop(Number(this.shopId), env);
36207
36213
  }
36208
36214
  get sku() {
36209
36215
  return this.nav.sku;
@@ -36321,11 +36327,11 @@ class FittingRoom {
36321
36327
  }
36322
36328
  }
36323
36329
 
36324
- const initFittingRoom = async (shopId, modalDivId, hooks) => {
36325
- const tfr = new FittingRoom(shopId, modalDivId, hooks);
36330
+ const initFittingRoom = async (shopId, modalDivId, hooks, env = 'dev') => {
36331
+ const tfr = new FittingRoom(shopId, modalDivId, hooks, env);
36326
36332
  await tfr.onInit();
36327
36333
  return tfr;
36328
36334
  };
36329
36335
 
36330
- export { VTO_TIMEOUT_MS, initFittingRoom };
36336
+ export { InitImageSlider, VTO_TIMEOUT_MS, initFittingRoom };
36331
36337
  //# sourceMappingURL=index.js.map