@nosto/nosto-react 2.1.0 → 2.2.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/README.md +13 -0
- package/dist/index.d.ts +146 -23
- package/dist/index.es.js +428 -393
- package/dist/index.umd.js +9 -9
- package/package.json +1 -1
- package/src/components/Nosto404.tsx +17 -3
- package/src/components/NostoCategory.tsx +19 -3
- package/src/components/NostoCheckout.tsx +17 -3
- package/src/components/NostoHome.tsx +17 -3
- package/src/components/NostoOrder.tsx +19 -6
- package/src/components/NostoOther.tsx +17 -3
- package/src/components/NostoPlacement.tsx +6 -2
- package/src/components/NostoProduct.tsx +21 -8
- package/src/components/NostoSearch.tsx +19 -3
- package/src/components/NostoSession.tsx +26 -6
- package/src/components/index.ts +10 -10
- package/src/utils/snakeize.ts +5 -1
- package/src/utils/types.ts +29 -0
package/README.md
CHANGED
|
@@ -264,6 +264,19 @@ import {
|
|
|
264
264
|
</div>;
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
+
### Hook alternatives
|
|
268
|
+
|
|
269
|
+
For all the page type specific components hooks are also provided with the same props
|
|
270
|
+
|
|
271
|
+
- useNosto404
|
|
272
|
+
- useNostoOther
|
|
273
|
+
- useNostoCheckout
|
|
274
|
+
- useNostoProduct
|
|
275
|
+
- useNostoCategory
|
|
276
|
+
- useNostoSearch
|
|
277
|
+
- useNostOrder
|
|
278
|
+
- useNostoHome
|
|
279
|
+
|
|
267
280
|
### Detailed technical documentation
|
|
268
281
|
Find our latest technical specs and documentation hosted [here](https://nosto.github.io/nosto-react).
|
|
269
282
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare interface Cart {
|
|
|
12
12
|
items: CartItem[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
declare type Cart_2 = Cart | ToCamelCase<Cart>;
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* @group Types
|
|
17
19
|
*/
|
|
@@ -52,6 +54,8 @@ export declare interface Customer {
|
|
|
52
54
|
type?: string;
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
declare type Customer_2 = Customer | ToCamelCase<Customer>;
|
|
58
|
+
|
|
55
59
|
/**
|
|
56
60
|
* You can personalise your cart and checkout pages by using the `Nosto404` component.
|
|
57
61
|
* The component does not require any props.
|
|
@@ -72,9 +76,14 @@ export declare interface Customer {
|
|
|
72
76
|
*
|
|
73
77
|
* @group Components
|
|
74
78
|
*/
|
|
75
|
-
export declare function Nosto404(props:
|
|
79
|
+
export declare function Nosto404(props: Nosto404Props): null;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @group Components
|
|
83
|
+
*/
|
|
84
|
+
export declare type Nosto404Props = {
|
|
76
85
|
placements?: string[];
|
|
77
|
-
}
|
|
86
|
+
};
|
|
78
87
|
|
|
79
88
|
/**
|
|
80
89
|
* You can personalise your category and collection pages by using the NostoCategory component.
|
|
@@ -98,10 +107,15 @@ export declare function Nosto404(props: {
|
|
|
98
107
|
*
|
|
99
108
|
* @group Components
|
|
100
109
|
*/
|
|
101
|
-
export declare function NostoCategory(props:
|
|
110
|
+
export declare function NostoCategory(props: NostoCategoryProps): null;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @group Components
|
|
114
|
+
*/
|
|
115
|
+
export declare type NostoCategoryProps = {
|
|
102
116
|
category: string;
|
|
103
117
|
placements?: string[];
|
|
104
|
-
}
|
|
118
|
+
};
|
|
105
119
|
|
|
106
120
|
/**
|
|
107
121
|
* You can personalise your cart and checkout pages by using the NostoCheckout component.
|
|
@@ -122,9 +136,14 @@ export declare function NostoCategory(props: {
|
|
|
122
136
|
*
|
|
123
137
|
* @group Components
|
|
124
138
|
*/
|
|
125
|
-
export declare function NostoCheckout(props:
|
|
139
|
+
export declare function NostoCheckout(props: NostoCheckoutProps): null;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @group Components
|
|
143
|
+
*/
|
|
144
|
+
export declare type NostoCheckoutProps = {
|
|
126
145
|
placements?: string[];
|
|
127
|
-
}
|
|
146
|
+
};
|
|
128
147
|
|
|
129
148
|
/**
|
|
130
149
|
* @group Essential Functions
|
|
@@ -166,9 +185,14 @@ export declare interface NostoContextType {
|
|
|
166
185
|
*
|
|
167
186
|
* @group Components
|
|
168
187
|
*/
|
|
169
|
-
export declare function NostoHome(props:
|
|
188
|
+
export declare function NostoHome(props: NostoHomeProps): null;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @group Components
|
|
192
|
+
*/
|
|
193
|
+
export declare type NostoHomeProps = {
|
|
170
194
|
placements?: string[];
|
|
171
|
-
}
|
|
195
|
+
};
|
|
172
196
|
|
|
173
197
|
/**
|
|
174
198
|
* You can personalise your order-confirmation/thank-you page by using the `NostoOrder` component.
|
|
@@ -189,10 +213,15 @@ export declare function NostoHome(props: {
|
|
|
189
213
|
*
|
|
190
214
|
* @group Components
|
|
191
215
|
*/
|
|
192
|
-
export declare function NostoOrder(props:
|
|
216
|
+
export declare function NostoOrder(props: NostoOrderProps): null;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @group Components
|
|
220
|
+
*/
|
|
221
|
+
export declare type NostoOrderProps = {
|
|
193
222
|
order: Order;
|
|
194
223
|
placements?: string[];
|
|
195
|
-
}
|
|
224
|
+
};
|
|
196
225
|
|
|
197
226
|
/**
|
|
198
227
|
* You can personalise your miscellaneous pages by using the NostoOther component.
|
|
@@ -213,9 +242,14 @@ export declare function NostoOrder(props: {
|
|
|
213
242
|
*
|
|
214
243
|
* @group Components
|
|
215
244
|
*/
|
|
216
|
-
export declare function NostoOther(props:
|
|
245
|
+
export declare function NostoOther(props: NostoOtherProps): null;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @group Components
|
|
249
|
+
*/
|
|
250
|
+
export declare type NostoOtherProps = {
|
|
217
251
|
placements?: string[];
|
|
218
|
-
}
|
|
252
|
+
};
|
|
219
253
|
|
|
220
254
|
/**
|
|
221
255
|
* Nosto React has a special component called NostoPlacement.
|
|
@@ -230,10 +264,15 @@ export declare function NostoOther(props: {
|
|
|
230
264
|
*
|
|
231
265
|
* @group Components
|
|
232
266
|
*/
|
|
233
|
-
export declare function NostoPlacement(
|
|
267
|
+
export declare function NostoPlacement({ id, pageType }: NostoPlacementProps): JSX_2.Element;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* @group Components
|
|
271
|
+
*/
|
|
272
|
+
export declare type NostoPlacementProps = {
|
|
234
273
|
id: string;
|
|
235
274
|
pageType?: string;
|
|
236
|
-
}
|
|
275
|
+
};
|
|
237
276
|
|
|
238
277
|
/**
|
|
239
278
|
* The NostoProduct component must be used to personalise the product page.
|
|
@@ -259,11 +298,16 @@ export declare function NostoPlacement(props: {
|
|
|
259
298
|
*
|
|
260
299
|
* @group Components
|
|
261
300
|
*/
|
|
262
|
-
export declare function NostoProduct(props:
|
|
301
|
+
export declare function NostoProduct(props: NostoProductProps): null;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @group Components
|
|
305
|
+
*/
|
|
306
|
+
export declare type NostoProductProps = {
|
|
263
307
|
product: string;
|
|
264
308
|
tagging?: Product;
|
|
265
309
|
placements?: string[];
|
|
266
|
-
}
|
|
310
|
+
};
|
|
267
311
|
|
|
268
312
|
/**
|
|
269
313
|
* This widget is what we call the Nosto root widget, which is responsible for adding the actual Nosto script and the JS API stub.
|
|
@@ -356,10 +400,15 @@ export declare interface NostoProviderProps {
|
|
|
356
400
|
*
|
|
357
401
|
* @group Components
|
|
358
402
|
*/
|
|
359
|
-
export declare function NostoSearch(props:
|
|
403
|
+
export declare function NostoSearch(props: NostoSearchProps): null;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* @group Components
|
|
407
|
+
*/
|
|
408
|
+
export declare type NostoSearchProps = {
|
|
360
409
|
query: string;
|
|
361
410
|
placements?: string[];
|
|
362
|
-
}
|
|
411
|
+
};
|
|
363
412
|
|
|
364
413
|
/**
|
|
365
414
|
* Nosto React requires that you pass it the details of current cart contents and the details of the currently logged-in customer, if any, on every route change.
|
|
@@ -369,12 +418,17 @@ export declare function NostoSearch(props: {
|
|
|
369
418
|
*
|
|
370
419
|
* The cart prop requires a value that adheres to the type `Cart`, while the customer prop requires a value that adheres to the type `Customer`.
|
|
371
420
|
*
|
|
372
|
-
* @group
|
|
421
|
+
* @group Components
|
|
422
|
+
*/
|
|
423
|
+
export declare function NostoSession(props?: NostoSessionProps): null;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* @group Components
|
|
373
427
|
*/
|
|
374
|
-
export declare
|
|
375
|
-
cart?:
|
|
376
|
-
customer?:
|
|
377
|
-
}
|
|
428
|
+
export declare type NostoSessionProps = {
|
|
429
|
+
cart?: Cart_2;
|
|
430
|
+
customer?: Customer_2;
|
|
431
|
+
};
|
|
378
432
|
|
|
379
433
|
declare interface NostoSku extends Sku {
|
|
380
434
|
inventory_level?: number;
|
|
@@ -526,6 +580,33 @@ declare interface Sku {
|
|
|
526
580
|
url?: string;
|
|
527
581
|
}
|
|
528
582
|
|
|
583
|
+
declare type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
|
|
584
|
+
|
|
585
|
+
declare type ToCamelCase<T> = T extends (infer U)[] ? ToCamelCase<U>[] : T extends Date ? T : T extends object ? {
|
|
586
|
+
[K in keyof T as SnakeToCamelCase<K & string>]: ToCamelCase<T[K]>;
|
|
587
|
+
} : T;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* You can personalise your cart and checkout pages by using the `useNosto404` hook.
|
|
591
|
+
*
|
|
592
|
+
* @group Hooks
|
|
593
|
+
*/
|
|
594
|
+
export declare function useNosto404(props?: Nosto404Props): void;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* You can personalise your category and collection pages by using the useNostoCategory hook.
|
|
598
|
+
*
|
|
599
|
+
* @group Hooks
|
|
600
|
+
*/
|
|
601
|
+
export declare function useNostoCategory({ category, placements }: NostoCategoryProps): void;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* You can personalise your cart and checkout pages by using the useNostoCheckout hook.
|
|
605
|
+
*
|
|
606
|
+
* @group Hooks
|
|
607
|
+
*/
|
|
608
|
+
export declare function useNostoCheckout(props?: NostoCheckoutProps): void;
|
|
609
|
+
|
|
529
610
|
/**
|
|
530
611
|
* A hook that allows you to access the NostoContext and retrieve Nosto-related data from it in React components.
|
|
531
612
|
*
|
|
@@ -533,6 +614,48 @@ declare interface Sku {
|
|
|
533
614
|
*/
|
|
534
615
|
export declare function useNostoContext(): NostoContextType;
|
|
535
616
|
|
|
617
|
+
/**
|
|
618
|
+
* You can personalise your home page by using the useNostoHome hook.
|
|
619
|
+
*
|
|
620
|
+
* @group Hooks
|
|
621
|
+
*/
|
|
622
|
+
export declare function useNostoHome(props?: NostoHomeProps): void;
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* You can personalise your order-confirmation/thank-you page by using the `useNostoOrder` hook.
|
|
626
|
+
*
|
|
627
|
+
* @group Hooks
|
|
628
|
+
*/
|
|
629
|
+
export declare function useNostoOrder({ order, placements }: NostoOrderProps): void;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* You can personalise your miscellaneous pages by using the useNostoOther hook.
|
|
633
|
+
*
|
|
634
|
+
* @group Hooks
|
|
635
|
+
*/
|
|
636
|
+
export declare function useNostoOther(props?: NostoOtherProps): void;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* You can personalise your product pages by using the useNostoProduct hook.
|
|
640
|
+
*
|
|
641
|
+
* @group Hooks
|
|
642
|
+
*/
|
|
643
|
+
export declare function useNostoProduct({ product, tagging, placements }: NostoProductProps): void;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* You can personalise your search pages by using the useNostoSearch hook.
|
|
647
|
+
*
|
|
648
|
+
* @group Hooks
|
|
649
|
+
*/
|
|
650
|
+
export declare function useNostoSearch({ query, placements }: NostoSearchProps): void;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Nosto React requires that you pass it the details of current cart contents and the details of the currently logged-in customer, if any, on every route change.
|
|
654
|
+
*
|
|
655
|
+
* @group Hooks
|
|
656
|
+
*/
|
|
657
|
+
export declare function useNostoSession({ cart, customer }?: NostoSessionProps): void;
|
|
658
|
+
|
|
536
659
|
export { }
|
|
537
660
|
|
|
538
661
|
declare global {
|