@thefittingroom/shop-ui 0.0.13 → 0.0.15
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/esm/components/index.d.ts +2 -2
- package/dist/esm/components/slider.d.ts +1 -2
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +64 -53
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +3 -3
- package/index.html +1 -1
- package/package.json +2 -2
|
@@ -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 {
|
|
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;
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v0.0.
|
|
2
|
+
* thefittingroom v0.0.15 (2023-07-31T23:30:09.543Z)
|
|
3
3
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/*!
|
|
6
|
-
* thefittingroom v0.0.
|
|
6
|
+
* thefittingroom v0.0.10 (2023-07-31T23:26:47.153Z)
|
|
7
7
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
@@ -22828,8 +22828,8 @@ class FirebaseUser {
|
|
|
22828
22828
|
const q = sl(Ta(this.firestore, 'users'), rl(Eh(), '==', this.id));
|
|
22829
22829
|
const cancel = setTimeout(() => unsub(), timeout);
|
|
22830
22830
|
return new Promise((resolve) => {
|
|
22831
|
-
unsub = jl(q, (snapshot) => {
|
|
22832
|
-
if (!predicate(snapshot))
|
|
22831
|
+
unsub = jl(q, async (snapshot) => {
|
|
22832
|
+
if (!(await predicate(snapshot)))
|
|
22833
22833
|
return;
|
|
22834
22834
|
clearTimeout(cancel);
|
|
22835
22835
|
unsub();
|
|
@@ -22945,7 +22945,7 @@ class Fetcher {
|
|
|
22945
22945
|
}
|
|
22946
22946
|
}
|
|
22947
22947
|
|
|
22948
|
-
const
|
|
22948
|
+
const testImage = (url) => {
|
|
22949
22949
|
const img = new Image();
|
|
22950
22950
|
img.src = url;
|
|
22951
22951
|
return new Promise((resolve) => {
|
|
@@ -23045,7 +23045,13 @@ class TfrShop {
|
|
|
23045
23045
|
var _a, _b, _c, _d;
|
|
23046
23046
|
if (!this.isLoggedIn)
|
|
23047
23047
|
throw new UserNotLoggedInError();
|
|
23048
|
-
const predicate = (data) => {
|
|
23048
|
+
const predicate = async (data) => {
|
|
23049
|
+
var _a, _b, _c, _d;
|
|
23050
|
+
const frames = (_d = (_c = (_b = (_a = data.docs[0].data()) === null || _a === void 0 ? void 0 : _a.vto) === null || _b === void 0 ? void 0 : _b[this.brandId]) === null || _c === void 0 ? void 0 : _c[colorwaySizeAssetSKU]) === null || _d === void 0 ? void 0 : _d.frames;
|
|
23051
|
+
if (!(frames === null || frames === void 0 ? void 0 : frames.length))
|
|
23052
|
+
return false;
|
|
23053
|
+
return testImage(frames[0]);
|
|
23054
|
+
};
|
|
23049
23055
|
const userProfile = (await this.user.watchUserProfileForChanges(predicate, TfrShop.vtoTimeout));
|
|
23050
23056
|
if (!((_d = (_c = (_b = (_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.vto) === null || _a === void 0 ? void 0 : _a[this.brandId]) === null || _b === void 0 ? void 0 : _b[colorwaySizeAssetSKU]) === null || _c === void 0 ? void 0 : _c.frames) === null || _d === void 0 ? void 0 : _d.length))
|
|
23051
23057
|
throw new NoFramesFoundError();
|
|
@@ -23114,7 +23120,7 @@ class TfrShop {
|
|
|
23114
23120
|
const frames = ((_c = (_b = (_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.vto) === null || _a === void 0 ? void 0 : _a[this.brandId]) === null || _b === void 0 ? void 0 : _b[colorwaySizeAssetSKU]) === null || _c === void 0 ? void 0 : _c.frames) || [];
|
|
23115
23121
|
if (!frames.length)
|
|
23116
23122
|
throw new NoFramesFoundError();
|
|
23117
|
-
const testedImage = await
|
|
23123
|
+
const testedImage = await testImage(frames[0]);
|
|
23118
23124
|
if (!testedImage)
|
|
23119
23125
|
throw new NoFramesFoundError();
|
|
23120
23126
|
return frames;
|
|
@@ -23138,6 +23144,50 @@ var AvatarState$1;
|
|
|
23138
23144
|
|
|
23139
23145
|
const VTO_TIMEOUT_MS = TfrShop.vtoTimeout;
|
|
23140
23146
|
|
|
23147
|
+
function loadImageRecursive(imageURL, imageURLs) {
|
|
23148
|
+
let next = function () {
|
|
23149
|
+
if (imageURLs.length === 0) {
|
|
23150
|
+
return;
|
|
23151
|
+
}
|
|
23152
|
+
loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
|
|
23153
|
+
};
|
|
23154
|
+
var img = new Image();
|
|
23155
|
+
img.onload = next;
|
|
23156
|
+
img.onerror = next;
|
|
23157
|
+
img.src = imageURL;
|
|
23158
|
+
}
|
|
23159
|
+
function loadImages(imageURLs) {
|
|
23160
|
+
loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
|
|
23161
|
+
}
|
|
23162
|
+
const InitImageSlider = (sliderID, onChange) => {
|
|
23163
|
+
const slider = document.getElementById(sliderID);
|
|
23164
|
+
if (!slider) {
|
|
23165
|
+
throw new Error(`Slider with id ${sliderID} not found`);
|
|
23166
|
+
}
|
|
23167
|
+
return {
|
|
23168
|
+
Load(imageURLs) {
|
|
23169
|
+
if (!Array.isArray(imageURLs) || !imageURLs.length) {
|
|
23170
|
+
console.debug('slider has no images to load');
|
|
23171
|
+
return new Error('slider has no images to load');
|
|
23172
|
+
}
|
|
23173
|
+
loadImages(imageURLs);
|
|
23174
|
+
const defaultScrollValue = (imageURLs === null || imageURLs === void 0 ? void 0 : imageURLs.length) - 2;
|
|
23175
|
+
slider.value = defaultScrollValue.toString();
|
|
23176
|
+
slider.max = (imageURLs.length - 1).toString();
|
|
23177
|
+
const handleSliderChange = () => {
|
|
23178
|
+
const currentValue = parseInt(slider.value);
|
|
23179
|
+
onChange(slider, imageURLs[currentValue]);
|
|
23180
|
+
};
|
|
23181
|
+
onChange(slider, imageURLs[defaultScrollValue]);
|
|
23182
|
+
slider.removeEventListener('input', handleSliderChange);
|
|
23183
|
+
slider.addEventListener('input', handleSliderChange);
|
|
23184
|
+
return () => {
|
|
23185
|
+
slider.removeEventListener('input', handleSliderChange);
|
|
23186
|
+
};
|
|
23187
|
+
},
|
|
23188
|
+
};
|
|
23189
|
+
};
|
|
23190
|
+
|
|
23141
23191
|
var L = {
|
|
23142
23192
|
AssociatedEmail: 'If there is an account associated with that email, We have sent a link to reset your password.',
|
|
23143
23193
|
BackToSignIn: 'Back to sign in',
|
|
@@ -36021,50 +36071,6 @@ const SizeErrorModal = (props) => {
|
|
|
36021
36071
|
};
|
|
36022
36072
|
};
|
|
36023
36073
|
|
|
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
36074
|
const TryOnModal = (props) => {
|
|
36069
36075
|
let close = () => void 0;
|
|
36070
36076
|
const onNavBack = () => {
|
|
@@ -36302,6 +36308,8 @@ class FittingRoom {
|
|
|
36302
36308
|
return `${trySizes}. ${L.WeRecommendSize} ${recommendedSizeLabel}.`;
|
|
36303
36309
|
}
|
|
36304
36310
|
async tryOn() {
|
|
36311
|
+
if (!this.shop.isLoggedIn)
|
|
36312
|
+
return this.nav.toScan();
|
|
36305
36313
|
try {
|
|
36306
36314
|
if (this.hooks.onLoading)
|
|
36307
36315
|
this.hooks.onLoading();
|
|
@@ -36315,8 +36323,11 @@ class FittingRoom {
|
|
|
36315
36323
|
return this.nav.onError(L.DontHaveAvatar);
|
|
36316
36324
|
if (error instanceof errors.RecommendedAvailableSizesError)
|
|
36317
36325
|
return this.nav.onSizeError(error.recommended_size, error.available_sizes);
|
|
36318
|
-
if (error instanceof errors.UserNotLoggedInError)
|
|
36326
|
+
if (error instanceof errors.UserNotLoggedInError) {
|
|
36327
|
+
if (this.hooks.onLoadingComplete)
|
|
36328
|
+
this.hooks.onLoadingComplete();
|
|
36319
36329
|
return this.nav.toScan();
|
|
36330
|
+
}
|
|
36320
36331
|
console.error(error.message);
|
|
36321
36332
|
this.nav.onError(L.SomethingWentWrong);
|
|
36322
36333
|
}
|
|
@@ -36333,5 +36344,5 @@ const initFittingRoom = async (shopId, modalDivId, hooks, env = 'dev') => {
|
|
|
36333
36344
|
return tfr;
|
|
36334
36345
|
};
|
|
36335
36346
|
|
|
36336
|
-
export { VTO_TIMEOUT_MS, initFittingRoom };
|
|
36347
|
+
export { InitImageSlider, VTO_TIMEOUT_MS, initFittingRoom };
|
|
36337
36348
|
//# sourceMappingURL=index.js.map
|