@liquidcommercedev/rmn-sdk 1.5.0-beta.12 → 1.5.0-beta.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ export * from './skeleton.component';
2
+ export * from './skeleton.interface';
@@ -0,0 +1,3 @@
1
+ import type { ICustomSkeletonElement } from './skeleton.interface';
2
+ declare let SkeletonElement: new () => ICustomSkeletonElement;
3
+ export { SkeletonElement };
@@ -0,0 +1,13 @@
1
+ import type { RMN_SPOT_TYPE } from 'enums';
2
+ export interface ICustomSkeletonElementData {
3
+ fluid: boolean;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export interface ICustomSkeletonElement extends HTMLElement {
8
+ data: ICustomSkeletonElementData;
9
+ }
10
+ export interface ICreateSkeletonElementParams {
11
+ fluid: boolean;
12
+ spotType: RMN_SPOT_TYPE;
13
+ }
@@ -0,0 +1,2 @@
1
+ import type { ICustomSkeletonElementData } from './skeleton.interface';
2
+ export declare function SkeletonTemplate({ fluid, width, height }: ICustomSkeletonElementData): string;
@@ -1,5 +1,8 @@
1
+ import type { SpotDimensionsType } from 'modules/selection';
1
2
  export declare const SPOT_ELEMENT_TAG = "spot-element";
2
3
  export declare const CAROUSEL_ELEMENT_TAG = "spot-carousel-element";
4
+ export declare const SKELETON_ELEMENT_TAG = "spot-skeleton-element";
3
5
  export declare const GFONT_PRECONNECT = "\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n";
4
6
  export declare const GFONT_SOURCE_SANS_3 = "\n <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap\">\n";
5
7
  export declare const GFONT_CORMORANT = "\n <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap\">\n";
8
+ export declare const SPOT_DIMENSIONS: SpotDimensionsType;
@@ -1,5 +1,6 @@
1
1
  import type { ISpot } from 'modules/selection';
2
2
  import type { ICreateCarouselElementParams } from './component/carousel';
3
+ import type { ICreateSkeletonElementParams } from './component/skeleton';
3
4
  import type { ICreateSpotElementParams } from './component/spot';
4
5
  import type { IElementService, ISpotColors } from './element.interface';
5
6
  export declare class ElementService implements IElementService {
@@ -24,6 +25,16 @@ export declare class ElementService implements IElementService {
24
25
  * @return {HTMLElement | null} - The html element or null if the browser environment is not available.
25
26
  */
26
27
  createCarouselElement({ slides, config, }: ICreateCarouselElementParams): HTMLElement | null;
28
+ /**
29
+ * Creates the skeleton html element based on the provided data using shadow dom.
30
+ *
31
+ * This method is only available in browser environments.
32
+ *
33
+ * @param {ICreateSkeletonElementParams} params - The parameters to create the final element.
34
+ *
35
+ * @return {HTMLElement | null} - The html element or null if the browser environment is not available.
36
+ */
37
+ createSkeletonElement(params: ICreateSkeletonElementParams): HTMLElement | null;
27
38
  /**
28
39
  * Overrides the spot colors with the provided colors.
29
40
  *
@@ -1,4 +1,8 @@
1
1
  import type { RMN_SPOT_EVENT } from 'enums';
2
+ export interface IDataLayerEvent {
3
+ event: string;
4
+ [key: string]: any;
5
+ }
2
6
  export interface INormalizedEventData {
3
7
  event: RMN_SPOT_EVENT;
4
8
  productIds: Array<string | number>;
@@ -6,6 +6,7 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
6
6
  private readonly selectionService;
7
7
  private readonly elementService;
8
8
  private readonly eventService;
9
+ private intersectionObserver;
9
10
  constructor(auth: IAuthCredentials);
10
11
  /**
11
12
  * Makes a selection request on our server based on the provided data.
@@ -27,14 +28,7 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
27
28
  * @return {Promise<void>} - A promise that resolves when the spot elements are injected.
28
29
  */
29
30
  injectSpotElement(params: IInjectSpotElementParams): Promise<void>;
30
- /**
31
- * Makes a selection request on our server based on the provided data.
32
- *
33
- * @param {IInjectSpotElementParams} params - Parameters for injecting spot elements.
34
- *
35
- * @return {Promise<ISpots | {error: string}>} - The spots response object.
36
- */
37
- private spotSelectionRequest;
31
+ /** ========================= HELPER METHODS ========================= **/
38
32
  /**
39
33
  * Injects a carousel element with the provided spots into the placement.
40
34
  *
@@ -56,6 +50,22 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
56
50
  * @return {void}
57
51
  */
58
52
  private injectOneSpotElement;
53
+ /**
54
+ * Clears the placement element by removing all its children.
55
+ *
56
+ * @param {string} placementId - The placement id.
57
+ *
58
+ * @return {void}
59
+ */
60
+ private clearPlacement;
61
+ /**
62
+ * Makes a selection request on our server based on the provided data.
63
+ *
64
+ * @param {IInjectSpotElementParams} params - Parameters for injecting spot elements.
65
+ *
66
+ * @return {Promise<ISpots | {error: string}>} - The spots response object.
67
+ */
68
+ private spotSelectionRequest;
59
69
  /**
60
70
  * Prevents duplicate placement ids in the inject data.
61
71
  *
@@ -66,8 +76,13 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
66
76
  * @return {void}
67
77
  */
68
78
  private preventDuplicateSpotPlacementIds;
79
+ /**
80
+ * Prevents non-existent spot types in the inject data.
81
+ *
82
+ * @param {IInjectSpotElement[]} inject - The inject data.
83
+ * @return {IInjectSpotElement[]} - The filtered inject data.
84
+ */
69
85
  private preventNonExistentSpotTypes;
70
- private updateSpotsState;
71
86
  private useSpotSelectionExample;
72
87
  }
73
88
  /**
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@liquidcommercedev/rmn-sdk",
3
3
  "description": "LiquidCommerce RMN SDK",
4
4
  "author": "LiquidCommerce Tech",
5
- "version": "1.5.0-beta.12",
5
+ "version": "1.5.0-beta.14",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",