@tapcart/mobile-components 0.7.91 → 0.7.93
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/components/hooks/use-nosto-recommendation.d.ts +1 -1
- package/dist/components/hooks/use-nosto-recommendation.d.ts.map +1 -1
- package/dist/components/hooks/use-nosto-recommendation.js +2 -1
- package/dist/components/hooks/use-nosto-recommendation.test.js +23 -12
- package/dist/components/hooks/use-products.d.ts +1 -0
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-products.js +2 -1
- package/dist/components/ui/swipeable-list-item.d.ts +17 -0
- package/dist/components/ui/swipeable-list-item.d.ts.map +1 -0
- package/dist/components/ui/swipeable-list-item.js +80 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/styles.css +6 -0
- package/package.json +4 -3
|
@@ -7,7 +7,7 @@ export declare enum NostoRecommendationsType {
|
|
|
7
7
|
BEST_SELLERS = "BEST_SELLERS",
|
|
8
8
|
VIEWED_CATEGORY = "VIEWED_CATEGORY"
|
|
9
9
|
}
|
|
10
|
-
export declare function useNostoRecommendations(integrations: Integrations, baseURL: string, slotId?: string, recommendationsType?: NostoRecommendationsType | "", productIds?: string[], skip?: boolean, mockFallback?: boolean, mockFallbackAppId?: string): {
|
|
10
|
+
export declare function useNostoRecommendations(integrations: Integrations, baseURL: string, slotId?: string, country?: string, recommendationsType?: NostoRecommendationsType | "", productIds?: string[], skip?: boolean, mockFallback?: boolean, mockFallbackAppId?: string): {
|
|
11
11
|
recommendations: import("app-studio-types").Product[];
|
|
12
12
|
isLoading: boolean;
|
|
13
13
|
error: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-nosto-recommendation.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-nosto-recommendation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAe/C,oBAAY,wBAAwB;IAClC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;CACpC;AAyRD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,MAAM,SAAK,EACX,mBAAmB,CAAC,EAAE,wBAAwB,GAAG,EAAE,EACnD,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,IAAI,CAAC,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,OAAO,EACtB,iBAAiB,CAAC,EAAE,MAAM;;;;;
|
|
1
|
+
{"version":3,"file":"use-nosto-recommendation.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-nosto-recommendation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAe/C,oBAAY,wBAAwB;IAClC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;CACpC;AAyRD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,MAAM,SAAK,EACX,OAAO,SAAO,EACd,mBAAmB,CAAC,EAAE,wBAAwB,GAAG,EAAE,EACnD,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,IAAI,CAAC,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,OAAO,EACtB,iBAAiB,CAAC,EAAE,MAAM;;;;;EA6C3B"}
|
|
@@ -169,7 +169,7 @@ function useNostoRecommendationsProductIds(nostoKey, slotId = "", recommendation
|
|
|
169
169
|
error,
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
|
-
export function useNostoRecommendations(integrations, baseURL, slotId = "", recommendationsType, productIds, skip, mockFallback, mockFallbackAppId) {
|
|
172
|
+
export function useNostoRecommendations(integrations, baseURL, slotId = "", country = "US", recommendationsType, productIds, skip, mockFallback, mockFallbackAppId) {
|
|
173
173
|
var _a;
|
|
174
174
|
if (recommendationsType === "") {
|
|
175
175
|
recommendationsType = NostoRecommendationsType.BOUGHT_TOGETHER;
|
|
@@ -184,6 +184,7 @@ export function useNostoRecommendations(integrations, baseURL, slotId = "", reco
|
|
|
184
184
|
productHandles: [],
|
|
185
185
|
queryVariables: {
|
|
186
186
|
appId,
|
|
187
|
+
country: country,
|
|
187
188
|
},
|
|
188
189
|
mock: shouldMock,
|
|
189
190
|
});
|
|
@@ -112,7 +112,7 @@ describe("useNostoRecommendations", () => {
|
|
|
112
112
|
});
|
|
113
113
|
it("should return front page recommendations if productIds is empty and slotId is provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
114
|
const slotId = "mockSlotId";
|
|
115
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, undefined, undefined, undefined));
|
|
115
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", undefined, undefined, undefined));
|
|
116
116
|
// Initial state check
|
|
117
117
|
expect(result.current.isLoading).toBe(true);
|
|
118
118
|
// Wait for all promises with act
|
|
@@ -128,13 +128,14 @@ describe("useNostoRecommendations", () => {
|
|
|
128
128
|
productHandles: [],
|
|
129
129
|
queryVariables: {
|
|
130
130
|
appId: undefined,
|
|
131
|
+
country: "US",
|
|
131
132
|
},
|
|
132
133
|
mock: false,
|
|
133
134
|
});
|
|
134
135
|
}));
|
|
135
136
|
it("should return best sellers recommendations if productIds is empty and slotId is not provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
137
|
const slotId = "";
|
|
137
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, undefined, undefined));
|
|
138
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", undefined, undefined));
|
|
138
139
|
// Initial state check
|
|
139
140
|
expect(result.current.isLoading).toBe(true);
|
|
140
141
|
// Wait for all promises with act
|
|
@@ -150,6 +151,7 @@ describe("useNostoRecommendations", () => {
|
|
|
150
151
|
productHandles: [],
|
|
151
152
|
queryVariables: {
|
|
152
153
|
appId: undefined,
|
|
154
|
+
country: "US",
|
|
153
155
|
},
|
|
154
156
|
mock: false,
|
|
155
157
|
});
|
|
@@ -157,7 +159,7 @@ describe("useNostoRecommendations", () => {
|
|
|
157
159
|
it("should return best sellers recommendations if productIds is not empty, Best Sellers is the recommendation type and slotId is not provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
160
|
const slotId = "";
|
|
159
161
|
const productIds = ["mockProductId"];
|
|
160
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, NostoRecommendationsType.BEST_SELLERS, productIds));
|
|
162
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", NostoRecommendationsType.BEST_SELLERS, productIds));
|
|
161
163
|
// Initial state check
|
|
162
164
|
expect(result.current.isLoading).toBe(true);
|
|
163
165
|
// Wait for all promises with act
|
|
@@ -173,13 +175,14 @@ describe("useNostoRecommendations", () => {
|
|
|
173
175
|
productHandles: [],
|
|
174
176
|
queryVariables: {
|
|
175
177
|
appId: undefined,
|
|
178
|
+
country: "US",
|
|
176
179
|
},
|
|
177
180
|
mock: false,
|
|
178
181
|
});
|
|
179
182
|
}));
|
|
180
183
|
it("should return default front page recommendations if slotId is provided but layoutType is not", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
184
|
const slotId = "mockSlotId";
|
|
182
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId));
|
|
185
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US"));
|
|
183
186
|
// Initial state check
|
|
184
187
|
expect(result.current.isLoading).toBe(true);
|
|
185
188
|
// Wait for all promises with act
|
|
@@ -195,12 +198,13 @@ describe("useNostoRecommendations", () => {
|
|
|
195
198
|
productHandles: [],
|
|
196
199
|
queryVariables: {
|
|
197
200
|
appId: undefined,
|
|
201
|
+
country: "US",
|
|
198
202
|
},
|
|
199
203
|
mock: false,
|
|
200
204
|
});
|
|
201
205
|
}));
|
|
202
206
|
it("should return the correct recommendations for best sellers", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
203
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.BEST_SELLERS, undefined, undefined));
|
|
207
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.BEST_SELLERS, undefined, undefined));
|
|
204
208
|
// Initial state check
|
|
205
209
|
expect(result.current.isLoading).toBe(true);
|
|
206
210
|
// Wait for all promises with act
|
|
@@ -216,13 +220,14 @@ describe("useNostoRecommendations", () => {
|
|
|
216
220
|
productHandles: [],
|
|
217
221
|
queryVariables: {
|
|
218
222
|
appId: undefined,
|
|
223
|
+
country: "US",
|
|
219
224
|
},
|
|
220
225
|
mock: false,
|
|
221
226
|
});
|
|
222
227
|
}));
|
|
223
228
|
it("should return the related recommendations when only productIds and a recommendation type are provided on a non-home layout", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
224
229
|
const productIds = ["mockProductId"];
|
|
225
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
230
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
226
231
|
// Initial state check
|
|
227
232
|
expect(result.current.isLoading).toBe(true);
|
|
228
233
|
// Wait for all promises with act
|
|
@@ -238,6 +243,7 @@ describe("useNostoRecommendations", () => {
|
|
|
238
243
|
productHandles: [],
|
|
239
244
|
queryVariables: {
|
|
240
245
|
appId: undefined,
|
|
246
|
+
country: "US",
|
|
241
247
|
},
|
|
242
248
|
mock: false,
|
|
243
249
|
});
|
|
@@ -245,7 +251,7 @@ describe("useNostoRecommendations", () => {
|
|
|
245
251
|
it("should return the correct recommendations when productIds and slotIds are provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
246
252
|
const slotId = "mockSlotId";
|
|
247
253
|
const productIds = ["mockProductId"];
|
|
248
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
254
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
249
255
|
// Initial state check
|
|
250
256
|
expect(result.current.isLoading).toBe(true);
|
|
251
257
|
// Wait for all promises with act
|
|
@@ -261,13 +267,14 @@ describe("useNostoRecommendations", () => {
|
|
|
261
267
|
productHandles: [],
|
|
262
268
|
queryVariables: {
|
|
263
269
|
appId: undefined,
|
|
270
|
+
country: "US",
|
|
264
271
|
},
|
|
265
272
|
mock: false,
|
|
266
273
|
});
|
|
267
274
|
}));
|
|
268
275
|
it("should return the related products fallback recommendations when productIds are provided and no slotId and a type other than viewed_category and best_sellers is provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
269
276
|
const productIds = ["mockProductId"];
|
|
270
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
277
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
271
278
|
// Initial state check
|
|
272
279
|
expect(result.current.isLoading).toBe(true);
|
|
273
280
|
// Wait for all promises with act
|
|
@@ -283,13 +290,14 @@ describe("useNostoRecommendations", () => {
|
|
|
283
290
|
productHandles: [],
|
|
284
291
|
queryVariables: {
|
|
285
292
|
appId: undefined,
|
|
293
|
+
country: "US",
|
|
286
294
|
},
|
|
287
295
|
mock: false,
|
|
288
296
|
});
|
|
289
297
|
}));
|
|
290
298
|
it("should return the category fallback recommendations when no slotId, productIds are provided and a recommendation type of viewed_category is provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
291
299
|
const productIds = ["mockProductId"];
|
|
292
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_CATEGORY, productIds, undefined));
|
|
300
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_CATEGORY, productIds, undefined));
|
|
293
301
|
// Initial state check
|
|
294
302
|
expect(result.current.isLoading).toBe(true);
|
|
295
303
|
// Wait for all promises with act
|
|
@@ -305,12 +313,13 @@ describe("useNostoRecommendations", () => {
|
|
|
305
313
|
productHandles: [],
|
|
306
314
|
queryVariables: {
|
|
307
315
|
appId: undefined,
|
|
316
|
+
country: "US",
|
|
308
317
|
},
|
|
309
318
|
mock: false,
|
|
310
319
|
});
|
|
311
320
|
}));
|
|
312
321
|
it("should handle loading state", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
313
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, ""));
|
|
322
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US"));
|
|
314
323
|
// Check initial loading state
|
|
315
324
|
expect(result.current.isLoading).toBe(true);
|
|
316
325
|
// Wait for all state updates to complete
|
|
@@ -342,7 +351,7 @@ describe("useNostoRecommendations", () => {
|
|
|
342
351
|
}));
|
|
343
352
|
it("should default to best sellers if productIds are empty but a recommendation type other than Best Sellers is used", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
344
353
|
const productIds = [];
|
|
345
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
354
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
|
|
346
355
|
// Initial state check
|
|
347
356
|
expect(result.current.isLoading).toBe(true);
|
|
348
357
|
// Wait for all promises with act
|
|
@@ -358,12 +367,13 @@ describe("useNostoRecommendations", () => {
|
|
|
358
367
|
productHandles: [],
|
|
359
368
|
queryVariables: {
|
|
360
369
|
appId: undefined,
|
|
370
|
+
country: "US",
|
|
361
371
|
},
|
|
362
372
|
mock: false,
|
|
363
373
|
});
|
|
364
374
|
}));
|
|
365
375
|
it("should return an empty array if skip is true", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
366
|
-
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.BEST_SELLERS, undefined, true));
|
|
376
|
+
const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.BEST_SELLERS, undefined, true));
|
|
367
377
|
// Initial state check
|
|
368
378
|
expect(result.current.isLoading).toBe(true);
|
|
369
379
|
// Wait for all promises with act
|
|
@@ -378,6 +388,7 @@ describe("useNostoRecommendations", () => {
|
|
|
378
388
|
productHandles: [],
|
|
379
389
|
queryVariables: {
|
|
380
390
|
appId: undefined,
|
|
391
|
+
country: "US",
|
|
381
392
|
},
|
|
382
393
|
mock: false,
|
|
383
394
|
});
|
|
@@ -12,6 +12,7 @@ type UseProductsProps = {
|
|
|
12
12
|
queryVariables?: Record<string, any>;
|
|
13
13
|
fetcher?: (url: string, body?: Record<string, any> | null) => Promise<any>;
|
|
14
14
|
metafields?: MetafieldInput[];
|
|
15
|
+
mediaLimit?: number;
|
|
15
16
|
mock?: boolean;
|
|
16
17
|
onlyAvailableProducts?: boolean;
|
|
17
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AACD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AA8BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AACD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AA8BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CA2F7E"}
|
|
@@ -19,7 +19,7 @@ const formatProductData = ({ data, onlyAvailableProducts = false, }) => {
|
|
|
19
19
|
: products;
|
|
20
20
|
};
|
|
21
21
|
export function useProducts(props) {
|
|
22
|
-
var _a, _b, _c;
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
23
|
let url = null;
|
|
24
24
|
let body = null;
|
|
25
25
|
const shouldMockProducts = Boolean(props === null || props === void 0 ? void 0 : props.mock);
|
|
@@ -60,6 +60,7 @@ export function useProducts(props) {
|
|
|
60
60
|
if (queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.language) {
|
|
61
61
|
queryParams.set("language", queryVariables.language);
|
|
62
62
|
}
|
|
63
|
+
queryParams.set("mediaLimit", (_d = queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.mediaLimit) !== null && _d !== void 0 ? _d : 10);
|
|
63
64
|
url = `${baseURL}/products/by-ids?${queryParams.toString()}`;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export interface SwipeAction {
|
|
3
|
+
icon?: ReactNode;
|
|
4
|
+
color?: string;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
closeOnAction?: boolean;
|
|
7
|
+
key?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SwipeableListItemProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
actions: SwipeAction[];
|
|
12
|
+
actionWidth?: number;
|
|
13
|
+
threshold?: number;
|
|
14
|
+
}
|
|
15
|
+
declare const SwipeableListItem: React.FC<SwipeableListItemProps>;
|
|
16
|
+
export { SwipeableListItem };
|
|
17
|
+
//# sourceMappingURL=swipeable-list-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipeable-list-item.d.ts","sourceRoot":"","sources":["../../../components/ui/swipeable-list-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA+B,SAAS,EAAE,MAAM,OAAO,CAAA;AAGrE,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAA;IACnB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAwHvD,CAAA;AAID,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
|
+
import { useSwipeable } from "react-swipeable";
|
|
5
|
+
const SwipeableListItem = ({ children, actions = [], actionWidth = 52, threshold = 0.3, }) => {
|
|
6
|
+
const [offset, setOffset] = useState(0);
|
|
7
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
8
|
+
const totalActionsWidth = actionWidth * actions.length;
|
|
9
|
+
const thresholdPixels = totalActionsWidth * threshold;
|
|
10
|
+
const itemRef = useRef(null);
|
|
11
|
+
const closeItem = () => {
|
|
12
|
+
setIsOpen(false);
|
|
13
|
+
setOffset(0);
|
|
14
|
+
};
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const handleClickOutside = (event) => {
|
|
17
|
+
if (itemRef.current && !itemRef.current.contains(event.target)) {
|
|
18
|
+
closeItem();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
if (isOpen) {
|
|
22
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
23
|
+
}
|
|
24
|
+
return () => {
|
|
25
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
26
|
+
};
|
|
27
|
+
}, [isOpen]);
|
|
28
|
+
const handlers = useSwipeable({
|
|
29
|
+
onSwiping: (event) => {
|
|
30
|
+
let newOffset = 0;
|
|
31
|
+
if (event.dir === "Left") {
|
|
32
|
+
newOffset = Math.min(event.absX, totalActionsWidth);
|
|
33
|
+
}
|
|
34
|
+
else if (event.dir === "Right" && isOpen) {
|
|
35
|
+
newOffset = Math.max(totalActionsWidth - event.absX, 0);
|
|
36
|
+
}
|
|
37
|
+
setOffset(newOffset);
|
|
38
|
+
},
|
|
39
|
+
onSwipedLeft: () => {
|
|
40
|
+
if (offset > thresholdPixels) {
|
|
41
|
+
setIsOpen(true);
|
|
42
|
+
setOffset(totalActionsWidth);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
closeItem();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
onSwipedRight: () => closeItem(),
|
|
49
|
+
trackMouse: true,
|
|
50
|
+
trackTouch: true,
|
|
51
|
+
delta: 10,
|
|
52
|
+
preventScrollOnSwipe: true,
|
|
53
|
+
rotationAngle: 0,
|
|
54
|
+
});
|
|
55
|
+
return (_jsxs("div", Object.assign({ ref: itemRef, className: "relative overflow-hidden" }, { children: [_jsx("div", Object.assign({}, handlers, { className: "w-full transition-transform duration-200 ease-out", style: {
|
|
56
|
+
transform: `translateX(-${offset}px)`,
|
|
57
|
+
transition: offset === 0 || offset === totalActionsWidth
|
|
58
|
+
? "transform 0.2s ease-out"
|
|
59
|
+
: "none",
|
|
60
|
+
}, role: "button", "aria-expanded": isOpen }, { children: children })), _jsx("div", Object.assign({ className: "absolute right-0 top-0 h-full flex", "aria-label": "Action buttons", style: { visibility: offset > 0 ? "visible" : "hidden" } }, { children: actions.map((action, index) => {
|
|
61
|
+
const actionStartPosition = index * actionWidth;
|
|
62
|
+
const isActionVisible = offset > actionStartPosition;
|
|
63
|
+
return (_jsx("div", Object.assign({ className: "h-full flex items-center justify-center overflow-hidden", style: {
|
|
64
|
+
width: `${actionWidth}px`,
|
|
65
|
+
backgroundColor: action.color || "#e5e5e5",
|
|
66
|
+
maxWidth: isActionVisible
|
|
67
|
+
? `${Math.min(offset - actionStartPosition, actionWidth)}px`
|
|
68
|
+
: "0px",
|
|
69
|
+
opacity: isActionVisible ? 1 : 0,
|
|
70
|
+
transition: "max-width 0.1s ease-out, opacity 0.1s ease-out",
|
|
71
|
+
} }, { children: _jsx("button", Object.assign({ onClick: () => {
|
|
72
|
+
action.onPress();
|
|
73
|
+
if (action.closeOnAction !== false) {
|
|
74
|
+
closeItem();
|
|
75
|
+
}
|
|
76
|
+
}, className: "w-full h-full flex items-center justify-center", style: { minWidth: `${actionWidth}px` } }, { children: action.icon && _jsx(_Fragment, { children: action.icon }) })) }), action.key || index));
|
|
77
|
+
}) }))] })));
|
|
78
|
+
};
|
|
79
|
+
SwipeableListItem.displayName = "SwipeableListItem";
|
|
80
|
+
export { SwipeableListItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -72,4 +72,5 @@ export * from "./components/hooks/use-nosto-recommendation";
|
|
|
72
72
|
export * from "./components/libs/sort-filter/search-integration";
|
|
73
73
|
export * from "./components/ui/tap";
|
|
74
74
|
export * from "./components/ui/circular-progress";
|
|
75
|
+
export * from "./components/ui/swipeable-list-item";
|
|
75
76
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,eAAe,EACf,cAAc,EACd,SAAS,EACT,4BAA4B,GAC7B,MAAM,aAAa,CAAA;AACpB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,2CAA2C,CAAA;AACzD,cAAc,mCAAmC,CAAA;AACjD,cAAc,wCAAwC,CAAA;AACtD,cAAc,wCAAwC,CAAA;AACtD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sCAAsC,CAAA;AACpD,cAAc,yCAAyC,CAAA;AACvD,cAAc,oCAAoC,CAAA;AAClD,cAAc,wCAAwC,CAAA;AACtD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,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zC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA;AACnC,cAAc,mCAAmC,CAAA;AACjD,cAAc,qCAAqC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -73,3 +73,4 @@ export * from "./components/hooks/use-nosto-recommendation";
|
|
|
73
73
|
export * from "./components/libs/sort-filter/search-integration";
|
|
74
74
|
export * from "./components/ui/tap";
|
|
75
75
|
export * from "./components/ui/circular-progress";
|
|
76
|
+
export * from "./components/ui/swipeable-list-item";
|
package/dist/styles.css
CHANGED
|
@@ -2218,6 +2218,9 @@ video {
|
|
|
2218
2218
|
.ease-in-out {
|
|
2219
2219
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
2220
2220
|
}
|
|
2221
|
+
.ease-out {
|
|
2222
|
+
transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
|
2223
|
+
}
|
|
2221
2224
|
@keyframes enter {
|
|
2222
2225
|
|
|
2223
2226
|
from {
|
|
@@ -2250,6 +2253,9 @@ video {
|
|
|
2250
2253
|
.ease-in-out {
|
|
2251
2254
|
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
2252
2255
|
}
|
|
2256
|
+
.ease-out {
|
|
2257
|
+
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
|
2258
|
+
}
|
|
2253
2259
|
.paused {
|
|
2254
2260
|
animation-play-state: paused;
|
|
2255
2261
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.93",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -77,17 +77,18 @@
|
|
|
77
77
|
"clsx": "^1.2.1",
|
|
78
78
|
"dayjs": "^1.11.13",
|
|
79
79
|
"dompurify": "^3.2.2",
|
|
80
|
-
"embla-carousel-react": "^8.3.0",
|
|
81
80
|
"embla-carousel-autoplay": "8.5.2",
|
|
82
81
|
"embla-carousel-fade": "8.5.2",
|
|
82
|
+
"embla-carousel-react": "^8.3.0",
|
|
83
83
|
"lucide-react": "^0.248.0",
|
|
84
84
|
"next": "^14.2.5",
|
|
85
|
-
"react-circular-progressbar": "2.2.0",
|
|
86
85
|
"next-themes": "^0.2.1",
|
|
87
86
|
"pluralize": "^8.0.0",
|
|
88
87
|
"postcss-cli": "^11.0.0",
|
|
88
|
+
"react-circular-progressbar": "2.2.0",
|
|
89
89
|
"react-intersection-observer": "^9.10.2",
|
|
90
90
|
"react-svg": "^16.1.34",
|
|
91
|
+
"react-swipeable": "^7.0.2",
|
|
91
92
|
"react-virtual": "^2.10.4",
|
|
92
93
|
"swr": "^2.2.5",
|
|
93
94
|
"tailwind-merge": "^1.13.2",
|