@nosto/nosto-react 2.1.0 → 2.2.1

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