@nosto/nosto-react 2.2.1 → 2.3.0
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/LICENSE +1 -1
- package/dist/index.d.ts +23 -192
- package/dist/index.es.js +249 -221
- package/dist/index.umd.js +1 -1
- package/package.json +20 -17
- package/src/components/Nosto404.tsx +2 -25
- package/src/components/NostoCategory.tsx +2 -30
- package/src/components/NostoCheckout.tsx +2 -25
- package/src/components/NostoHome.tsx +2 -26
- package/src/components/NostoOrder.tsx +2 -33
- package/src/components/NostoOther.tsx +2 -25
- package/src/components/NostoPlacement.tsx +1 -1
- package/src/components/NostoProduct.tsx +2 -32
- package/src/components/NostoProvider.tsx +5 -9
- package/src/components/NostoSearch.tsx +2 -30
- package/src/components/NostoSession.tsx +2 -42
- package/src/context.ts +2 -2
- package/src/hooks/scriptLoader.ts +4 -4
- package/src/hooks/useDeepCompareEffect.ts +1 -4
- package/src/hooks/useLoadClientScript.ts +26 -17
- package/src/hooks/useNosto404.tsx +25 -0
- package/src/hooks/useNostoApi.ts +4 -7
- package/src/hooks/useNostoCategory.tsx +31 -0
- package/src/hooks/useNostoCheckout.tsx +25 -0
- package/src/hooks/useNostoContext.ts +2 -3
- package/src/hooks/useNostoHome.tsx +25 -0
- package/src/hooks/useNostoOrder.tsx +35 -0
- package/src/hooks/useNostoOther.tsx +25 -0
- package/src/hooks/useNostoProduct.tsx +43 -0
- package/src/hooks/useNostoSearch.tsx +31 -0
- package/src/hooks/useNostoSession.tsx +34 -0
- package/src/hooks/useRenderCampaigns.tsx +12 -9
- package/src/index.ts +23 -3
- package/src/types.ts +1 -923
- package/src/utils/types.ts +5 -3
- package/src/components/helpers.ts +0 -3
- package/src/components/index.ts +0 -11
- package/src/hooks/index.ts +0 -5
package/LICENSE
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,61 +1,19 @@
|
|
|
1
|
+
import { Cart } from '@nosto/nosto-js/client';
|
|
1
2
|
import { Context } from 'react';
|
|
3
|
+
import { PushedCustomer as Customer } from '@nosto/nosto-js/client';
|
|
2
4
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
5
|
+
import { WebsiteOrder as Order } from '@nosto/nosto-js/client';
|
|
6
|
+
import { Product } from '@nosto/nosto-js/client';
|
|
7
|
+
import { PushedProduct } from '@nosto/nosto-js/client';
|
|
3
8
|
import { ReactElement } from 'react';
|
|
4
9
|
import { ReactNode } from 'react';
|
|
10
|
+
import { RenderMode } from '@nosto/nosto-js/client';
|
|
5
11
|
|
|
6
12
|
declare type AnyFunction = (...args: unknown[]) => unknown;
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
* @group Types
|
|
10
|
-
*/
|
|
11
|
-
export declare interface Cart {
|
|
12
|
-
hcid?: string;
|
|
13
|
-
items: CartItem[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare type Cart_2 = Cart | ToCamelCase<Cart>;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @group Types
|
|
20
|
-
*/
|
|
21
|
-
declare interface CartItem {
|
|
22
|
-
name: string;
|
|
23
|
-
price_currency_code: string;
|
|
24
|
-
product_id: string;
|
|
25
|
-
quantity: number;
|
|
26
|
-
sku_id?: string;
|
|
27
|
-
unit_price: number;
|
|
28
|
-
}
|
|
14
|
+
export { Cart }
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
* @group Types
|
|
32
|
-
*/
|
|
33
|
-
declare interface ConversionItem {
|
|
34
|
-
name: string;
|
|
35
|
-
price_currency_code: string;
|
|
36
|
-
product_id: string;
|
|
37
|
-
quantity?: number;
|
|
38
|
-
sku_id?: string;
|
|
39
|
-
unit_price?: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @group Types
|
|
44
|
-
*/
|
|
45
|
-
export declare interface Customer {
|
|
46
|
-
customer_reference?: string;
|
|
47
|
-
email: string;
|
|
48
|
-
first_name: string;
|
|
49
|
-
hcid?: string;
|
|
50
|
-
last_name: string;
|
|
51
|
-
newsletter?: boolean;
|
|
52
|
-
order_number?: string;
|
|
53
|
-
source?: string;
|
|
54
|
-
source_id?: string;
|
|
55
|
-
type?: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
declare type Customer_2 = Customer | ToCamelCase<Customer>;
|
|
16
|
+
export { Customer }
|
|
59
17
|
|
|
60
18
|
/**
|
|
61
19
|
* You can personalise your cart and checkout pages by using the `Nosto404` component.
|
|
@@ -80,7 +38,7 @@ declare type Customer_2 = Customer | ToCamelCase<Customer>;
|
|
|
80
38
|
export declare function Nosto404(props: Nosto404Props): null;
|
|
81
39
|
|
|
82
40
|
/**
|
|
83
|
-
* @group
|
|
41
|
+
* @group Hooks
|
|
84
42
|
*/
|
|
85
43
|
export declare type Nosto404Props = {
|
|
86
44
|
placements?: string[];
|
|
@@ -111,7 +69,7 @@ export declare type Nosto404Props = {
|
|
|
111
69
|
export declare function NostoCategory(props: NostoCategoryProps): null;
|
|
112
70
|
|
|
113
71
|
/**
|
|
114
|
-
* @group
|
|
72
|
+
* @group Hooks
|
|
115
73
|
*/
|
|
116
74
|
export declare type NostoCategoryProps = {
|
|
117
75
|
category: string;
|
|
@@ -140,7 +98,7 @@ export declare type NostoCategoryProps = {
|
|
|
140
98
|
export declare function NostoCheckout(props: NostoCheckoutProps): null;
|
|
141
99
|
|
|
142
100
|
/**
|
|
143
|
-
* @group
|
|
101
|
+
* @group Hooks
|
|
144
102
|
*/
|
|
145
103
|
export declare type NostoCheckoutProps = {
|
|
146
104
|
placements?: string[];
|
|
@@ -189,7 +147,7 @@ export declare interface NostoContextType {
|
|
|
189
147
|
export declare function NostoHome(props: NostoHomeProps): null;
|
|
190
148
|
|
|
191
149
|
/**
|
|
192
|
-
* @group
|
|
150
|
+
* @group Hooks
|
|
193
151
|
*/
|
|
194
152
|
export declare type NostoHomeProps = {
|
|
195
153
|
placements?: string[];
|
|
@@ -217,10 +175,10 @@ export declare type NostoHomeProps = {
|
|
|
217
175
|
export declare function NostoOrder(props: NostoOrderProps): null;
|
|
218
176
|
|
|
219
177
|
/**
|
|
220
|
-
* @group
|
|
178
|
+
* @group Hooks
|
|
221
179
|
*/
|
|
222
180
|
export declare type NostoOrderProps = {
|
|
223
|
-
order: Order
|
|
181
|
+
order: Order | ToCamelCase<Order>;
|
|
224
182
|
placements?: string[];
|
|
225
183
|
};
|
|
226
184
|
|
|
@@ -246,7 +204,7 @@ export declare type NostoOrderProps = {
|
|
|
246
204
|
export declare function NostoOther(props: NostoOtherProps): null;
|
|
247
205
|
|
|
248
206
|
/**
|
|
249
|
-
* @group
|
|
207
|
+
* @group Hooks
|
|
250
208
|
*/
|
|
251
209
|
export declare type NostoOtherProps = {
|
|
252
210
|
placements?: string[];
|
|
@@ -302,10 +260,11 @@ export declare type NostoPlacementProps = {
|
|
|
302
260
|
export declare function NostoProduct(props: NostoProductProps): null;
|
|
303
261
|
|
|
304
262
|
/**
|
|
305
|
-
* @group
|
|
263
|
+
* @group Hooks
|
|
306
264
|
*/
|
|
307
265
|
export declare type NostoProductProps = {
|
|
308
266
|
product: string;
|
|
267
|
+
reference?: string;
|
|
309
268
|
tagging?: Product;
|
|
310
269
|
placements?: string[];
|
|
311
270
|
};
|
|
@@ -424,112 +383,16 @@ export declare type NostoSearchProps = {
|
|
|
424
383
|
export declare function NostoSession(props?: NostoSessionProps): null;
|
|
425
384
|
|
|
426
385
|
/**
|
|
427
|
-
* @group
|
|
386
|
+
* @group Hooks
|
|
428
387
|
*/
|
|
429
388
|
export declare type NostoSessionProps = {
|
|
430
|
-
cart?:
|
|
431
|
-
customer?:
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
declare interface NostoSku extends Sku {
|
|
435
|
-
inventory_level?: number;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
declare interface NostoVariant {
|
|
439
|
-
availability: string;
|
|
440
|
-
available: boolean;
|
|
441
|
-
discounted: boolean;
|
|
442
|
-
list_price?: number;
|
|
443
|
-
price: number;
|
|
444
|
-
price_currency_code: string;
|
|
445
|
-
price_text?: string;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* @group Types
|
|
450
|
-
*/
|
|
451
|
-
export declare interface Order {
|
|
452
|
-
created_at?: Date;
|
|
453
|
-
external_order_ref: string;
|
|
454
|
-
info?: OrderCustomer;
|
|
455
|
-
items: ConversionItem[];
|
|
456
|
-
order_status?: string;
|
|
457
|
-
order_status_label?: string;
|
|
458
|
-
payment_provider: string;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* @group Types
|
|
463
|
-
*/
|
|
464
|
-
declare interface OrderCustomer {
|
|
465
|
-
country: string;
|
|
466
|
-
email?: string;
|
|
467
|
-
first_name?: string;
|
|
468
|
-
last_name?: string;
|
|
469
|
-
newsletter: string;
|
|
470
|
-
order_number: string;
|
|
471
|
-
phone: string;
|
|
472
|
-
post_code: string;
|
|
473
|
-
type: string;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* @group Types
|
|
478
|
-
*/
|
|
479
|
-
export declare type Product = {
|
|
480
|
-
product_id: string;
|
|
481
|
-
selected_sku_id?: string;
|
|
389
|
+
cart?: Cart | ToCamelCase<Cart>;
|
|
390
|
+
customer?: Customer | ToCamelCase<Customer>;
|
|
482
391
|
};
|
|
483
392
|
|
|
484
|
-
|
|
485
|
-
age_group?: string;
|
|
486
|
-
alternate_image_urls: string[];
|
|
487
|
-
availability: string;
|
|
488
|
-
brand?: string;
|
|
489
|
-
category: string[];
|
|
490
|
-
category_id: string[];
|
|
491
|
-
condition?: string;
|
|
492
|
-
custom_fields: {
|
|
493
|
-
[index: string]: string;
|
|
494
|
-
};
|
|
495
|
-
date_published?: Date;
|
|
496
|
-
description?: string;
|
|
497
|
-
gender?: string;
|
|
498
|
-
google_category?: string;
|
|
499
|
-
gtin?: string;
|
|
500
|
-
image_url?: string;
|
|
501
|
-
inventory_level?: number;
|
|
502
|
-
list_price?: number;
|
|
503
|
-
name: string;
|
|
504
|
-
parent_category_id: string[];
|
|
505
|
-
price: number;
|
|
506
|
-
price_currency_code: string;
|
|
507
|
-
product_id: string;
|
|
508
|
-
rating_value?: number;
|
|
509
|
-
review_count?: number;
|
|
510
|
-
skus: PushedProductSKU[];
|
|
511
|
-
source_updated?: Date;
|
|
512
|
-
supplier_cost?: number;
|
|
513
|
-
tags1: string[];
|
|
514
|
-
tags2: string[];
|
|
515
|
-
tags3: string[];
|
|
516
|
-
thumb_url?: string;
|
|
517
|
-
unit_pricing_base_measure?: number;
|
|
518
|
-
unit_pricing_measure?: number;
|
|
519
|
-
unit_pricing_unit?: string;
|
|
520
|
-
update_received?: Date;
|
|
521
|
-
url: string;
|
|
522
|
-
variation_id?: string;
|
|
523
|
-
variations: {
|
|
524
|
-
[index: string]: PushedVariation;
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
declare interface PushedProductSKU extends NostoSku {
|
|
529
|
-
}
|
|
393
|
+
export { Order }
|
|
530
394
|
|
|
531
|
-
|
|
532
|
-
}
|
|
395
|
+
export { Product }
|
|
533
396
|
|
|
534
397
|
/**
|
|
535
398
|
* @group Types
|
|
@@ -548,11 +411,6 @@ declare type RecommendationComponent = ReactElement<{
|
|
|
548
411
|
nostoRecommendation: Recommendation;
|
|
549
412
|
}>;
|
|
550
413
|
|
|
551
|
-
/**
|
|
552
|
-
* @group Types
|
|
553
|
-
*/
|
|
554
|
-
declare type RenderMode = "HTML" | "SIMPLE" | "JSON_170x170" | "JSON_100_X_100" | "JSON_90x70" | "JSON_50x50" | "JSON_30x30" | "JSON_100x140" | "JSON_200x200" | "JSON_400x400" | "JSON_750x750" | "JSON_10_MAX_SQUARE" | "JSON_200x200_SQUARE" | "JSON_400x400_SQUARE" | "JSON_750x750_SQUARE" | "JSON_ORIGINAL" | "VERSION_SOURCE";
|
|
555
|
-
|
|
556
414
|
/**
|
|
557
415
|
* @group Types
|
|
558
416
|
*/
|
|
@@ -567,20 +425,6 @@ export declare type ScriptLoadOptions = {
|
|
|
567
425
|
attributes?: Record<string, string>;
|
|
568
426
|
};
|
|
569
427
|
|
|
570
|
-
declare interface Sku {
|
|
571
|
-
availability: string;
|
|
572
|
-
custom_fields: {
|
|
573
|
-
[index: string]: string;
|
|
574
|
-
};
|
|
575
|
-
gtin?: string;
|
|
576
|
-
id: string;
|
|
577
|
-
image_url?: string;
|
|
578
|
-
list_price?: number;
|
|
579
|
-
name: string;
|
|
580
|
-
price: number;
|
|
581
|
-
url?: string;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
428
|
declare type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
|
|
585
429
|
|
|
586
430
|
declare type ToCamelCase<T> = T extends (infer U)[] ? ToCamelCase<U>[] : T extends Date ? T : T extends object ? {
|
|
@@ -641,7 +485,7 @@ export declare function useNostoOther(props?: NostoOtherProps): void;
|
|
|
641
485
|
*
|
|
642
486
|
* @group Hooks
|
|
643
487
|
*/
|
|
644
|
-
export declare function useNostoProduct({ product, tagging, placements }: NostoProductProps): void;
|
|
488
|
+
export declare function useNostoProduct({ product, tagging, placements, reference }: NostoProductProps): void;
|
|
645
489
|
|
|
646
490
|
/**
|
|
647
491
|
* You can personalise your search pages by using the useNostoSearch hook.
|
|
@@ -658,16 +502,3 @@ export declare function useNostoSearch({ query, placements }: NostoSearchProps):
|
|
|
658
502
|
export declare function useNostoSession({ cart, customer }?: NostoSessionProps): void;
|
|
659
503
|
|
|
660
504
|
export { }
|
|
661
|
-
|
|
662
|
-
declare global {
|
|
663
|
-
interface Window {
|
|
664
|
-
nosto?: {
|
|
665
|
-
reload(settings: unknown): void;
|
|
666
|
-
};
|
|
667
|
-
nostojs: {
|
|
668
|
-
(callback: (api: NostoClient) => void): void;
|
|
669
|
-
q?: unknown[];
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|