@liquidcommercedev/rmn-sdk 1.4.6-beta.2 → 1.4.6-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +611 -504
- package/dist/index.esm.js +611 -505
- package/dist/types/enums.d.ts +1 -0
- package/dist/types/index.umd.d.ts +2 -2
- package/dist/types/modules/element/component/carousel/carousel.component.d.ts +3 -58
- package/dist/types/modules/element/component/carousel/carousel.interface.d.ts +31 -0
- package/dist/types/modules/element/component/carousel/carousel.style.d.ts +2 -1
- package/dist/types/modules/element/component/carousel/index.d.ts +1 -0
- package/dist/types/modules/element/component/spot/index.d.ts +2 -0
- package/dist/types/modules/element/component/spot/spot.component.d.ts +3 -0
- package/dist/types/modules/element/component/spot/spot.interface.d.ts +10 -0
- package/dist/types/modules/element/element.constant.d.ts +2 -1
- package/dist/types/modules/element/element.interface.d.ts +21 -15
- package/dist/types/modules/element/{spot.element.service.d.ts → element.service.d.ts} +15 -3
- package/dist/types/modules/element/index.d.ts +1 -1
- package/dist/types/modules/element/template/helper.d.ts +1 -0
- package/dist/types/modules/element/template/template.service.d.ts +1 -1
- package/dist/types/modules/event/helpers/resize.service.d.ts +1 -1
- package/dist/types/modules/selection/selection.interface.d.ts +2 -2
- package/dist/types/modules/selection/selection.type.d.ts +3 -2
- package/dist/types/rmn-client.d.ts +36 -14
- package/dist/types/static.constant.d.ts +3 -0
- package/dist/types/types.d.ts +4 -4
- package/package.json +2 -2
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
- package/dist/types/modules/element/spot.element.d.ts +0 -2
package/dist/types/enums.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import { RmnClient } from './index';
|
2
|
-
export { RmnClient };
|
1
|
+
import { RmnClient, RmnCreateSpotElement } from './index';
|
2
|
+
export { RmnClient, RmnCreateSpotElement };
|
@@ -1,58 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
color: string;
|
5
|
-
activeColor: string;
|
6
|
-
}
|
7
|
-
export interface ICarouselButtonOptions {
|
8
|
-
position: CarouselNavPosition;
|
9
|
-
together: boolean;
|
10
|
-
textColor: string;
|
11
|
-
backgroundColor: string;
|
12
|
-
borderRadius: string;
|
13
|
-
prev: string;
|
14
|
-
next: string;
|
15
|
-
}
|
16
|
-
export interface ICarouselOptions {
|
17
|
-
autoplay?: boolean;
|
18
|
-
interval?: number;
|
19
|
-
useDots?: ICarouselDotOptions | false;
|
20
|
-
useButtons?: ICarouselButtonOptions | false;
|
21
|
-
}
|
22
|
-
export declare class CarouselComponent {
|
23
|
-
private readonly carousel;
|
24
|
-
private readonly shadowRoot;
|
25
|
-
private readonly slidesContainer;
|
26
|
-
private readonly slides;
|
27
|
-
private readonly autoplay;
|
28
|
-
private readonly interval;
|
29
|
-
private readonly dotsOptions;
|
30
|
-
private readonly buttonsOptions;
|
31
|
-
private currentSlide;
|
32
|
-
private dotElements;
|
33
|
-
private prevButton;
|
34
|
-
private nextButton;
|
35
|
-
private autoplayInterval;
|
36
|
-
constructor(slides: Array<HTMLElement | string>, options?: ICarouselOptions);
|
37
|
-
getElement(): HTMLElement;
|
38
|
-
private render;
|
39
|
-
private setupCarousel;
|
40
|
-
private renderSlides;
|
41
|
-
private renderDots;
|
42
|
-
private renderButtons;
|
43
|
-
private setupDots;
|
44
|
-
private setupButtons;
|
45
|
-
private nextSlide;
|
46
|
-
private prevSlide;
|
47
|
-
private goToSlide;
|
48
|
-
private updateCarousel;
|
49
|
-
private updateDots;
|
50
|
-
private startAutoplay;
|
51
|
-
private stopAutoplay;
|
52
|
-
private resetAutoplay;
|
53
|
-
private initializeDotOptions;
|
54
|
-
private initializeButtonOptions;
|
55
|
-
private validateOptions;
|
56
|
-
private validateDotsPosition;
|
57
|
-
private validateButtonsPosition;
|
58
|
-
}
|
1
|
+
import type { ICustomCarouselElement } from './carousel.interface';
|
2
|
+
declare let CarouselElement: new () => ICustomCarouselElement;
|
3
|
+
export { CarouselElement };
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import type { ICreateElementConfig } from 'modules/element';
|
2
|
+
export type CarouselNavPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'middle-left' | 'middle-right' | 'middle-sides';
|
3
|
+
export interface ICarouselDotOptions {
|
4
|
+
position: CarouselNavPosition;
|
5
|
+
color: string;
|
6
|
+
activeColor: string;
|
7
|
+
}
|
8
|
+
export interface ICarouselButtonOptions {
|
9
|
+
position: CarouselNavPosition;
|
10
|
+
together: boolean;
|
11
|
+
textColor: string;
|
12
|
+
backgroundColor: string;
|
13
|
+
borderRadius: string;
|
14
|
+
prev: string;
|
15
|
+
next: string;
|
16
|
+
}
|
17
|
+
export interface ICarouselOptions {
|
18
|
+
autoplay?: boolean;
|
19
|
+
interval?: number;
|
20
|
+
useDots?: ICarouselDotOptions | boolean;
|
21
|
+
useButtons?: ICarouselButtonOptions | boolean;
|
22
|
+
}
|
23
|
+
export type ICustomCarouselElementData = ICreateElementConfig & ICarouselOptions;
|
24
|
+
export interface ICustomCarouselElement extends HTMLElement {
|
25
|
+
data: ICustomCarouselElementData;
|
26
|
+
slides: HTMLElement[];
|
27
|
+
}
|
28
|
+
export interface ICreateCarouselElementParams {
|
29
|
+
slides: HTMLElement[];
|
30
|
+
config: ICreateElementConfig;
|
31
|
+
}
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import type { ICustomCarouselElementData } from './carousel.interface';
|
2
|
+
export declare const CAROUSEL_COMPONENT_STYLE: ({ width, height, fluid }: ICustomCarouselElementData) => string;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { ICreateElementConfig } from 'modules/element';
|
2
|
+
export type ICustomSpotElementData = ICreateElementConfig;
|
3
|
+
export interface ICustomSpotElement extends HTMLElement {
|
4
|
+
data: ICustomSpotElementData;
|
5
|
+
content: HTMLElement;
|
6
|
+
}
|
7
|
+
export interface ICreateSpotElementParams {
|
8
|
+
content: HTMLElement;
|
9
|
+
config: ICreateElementConfig;
|
10
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
export declare const
|
1
|
+
export declare const SPOT_ELEMENT_TAG = "spot-element";
|
2
|
+
export declare const CAROUSEL_ELEMENT_TAG = "spot-carousel-element";
|
2
3
|
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";
|
3
4
|
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";
|
4
5
|
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";
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import type { RMN_SPOT_TYPE } from 'enums';
|
2
|
-
import type { ICarouselOptions } from '
|
2
|
+
import type { ICarouselOptions, ICreateCarouselElementParams } from 'modules/element/component/carousel';
|
3
|
+
import type { ICreateSpotElementParams } from 'modules/element/component/spot';
|
4
|
+
import type { RmnFilterType } from 'modules/selection';
|
3
5
|
export interface ISpotColors {
|
4
6
|
textColor?: string;
|
5
7
|
backgroundColor?: string;
|
@@ -10,34 +12,38 @@ export interface ISpotOverlay {
|
|
10
12
|
color: string;
|
11
13
|
colorStop: string;
|
12
14
|
}
|
13
|
-
export interface
|
15
|
+
export interface IInjectSpotElementConfig {
|
16
|
+
url?: string;
|
14
17
|
colors?: ISpotColors;
|
15
18
|
minScale?: number;
|
16
19
|
overlay?: ISpotOverlay[];
|
20
|
+
carousel?: ICarouselOptions;
|
17
21
|
}
|
18
22
|
export interface IInjectSpotElement {
|
19
23
|
placementId: string;
|
20
24
|
spotType: RMN_SPOT_TYPE | string;
|
21
25
|
count?: number;
|
26
|
+
config?: Omit<IInjectSpotElementConfig, 'url'>;
|
27
|
+
filter?: Partial<RmnFilterType>;
|
22
28
|
}
|
23
|
-
export interface
|
24
|
-
carousel?: ICarouselOptions;
|
25
|
-
}
|
26
|
-
export interface ICreateFinalElementConfig {
|
29
|
+
export interface ICreateElementConfig {
|
27
30
|
width: number;
|
28
31
|
height: number;
|
29
32
|
fluid?: boolean;
|
30
|
-
minScale
|
33
|
+
minScale: number;
|
31
34
|
}
|
32
|
-
export interface
|
33
|
-
|
34
|
-
config
|
35
|
+
export interface IInjectSpotElementParams {
|
36
|
+
inject: IInjectSpotElement[];
|
37
|
+
config?: IInjectSpotElementConfig;
|
38
|
+
filter?: Partial<RmnFilterType>;
|
35
39
|
}
|
36
40
|
export interface IElementService {
|
37
|
-
|
41
|
+
createSpotElement(params: ICreateSpotElementParams): HTMLElement | null;
|
42
|
+
createCarouselElement(params: ICreateCarouselElementParams): HTMLElement | null;
|
38
43
|
}
|
39
|
-
export
|
40
|
-
|
41
|
-
|
42
|
-
|
44
|
+
export interface IRmnCreateSpotElementConfig {
|
45
|
+
fluid?: boolean;
|
46
|
+
colors?: ISpotColors;
|
47
|
+
overlay?: ISpotOverlay[];
|
48
|
+
minScale?: number;
|
43
49
|
}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import type { ISpot } from 'modules/selection';
|
2
|
-
import type {
|
2
|
+
import type { ICreateCarouselElementParams } from './component/carousel';
|
3
|
+
import type { ICreateSpotElementParams } from './component/spot';
|
4
|
+
import type { IElementService, ISpotColors } from './element.interface';
|
3
5
|
export declare class ElementService implements IElementService {
|
4
6
|
static getInstance(): ElementService;
|
5
7
|
/**
|
@@ -7,11 +9,21 @@ export declare class ElementService implements IElementService {
|
|
7
9
|
*
|
8
10
|
* This method is only available in browser environments.
|
9
11
|
*
|
10
|
-
* @param {
|
12
|
+
* @param {ICreateSpotElementParams} params - The parameters to create the final element.
|
11
13
|
*
|
12
14
|
* @return {HTMLElement | null} - The html element or null if the browser environment is not available.
|
13
15
|
*/
|
14
|
-
|
16
|
+
createSpotElement({ content, config }: ICreateSpotElementParams): HTMLElement | null;
|
17
|
+
/**
|
18
|
+
* Creates the carousel html element based on the provided slides and configs using shadow dom.
|
19
|
+
*
|
20
|
+
* This method is only available in browser environments.
|
21
|
+
*
|
22
|
+
* @param {ICreateCarouselElementParams} params - The parameters to create the final element.
|
23
|
+
*
|
24
|
+
* @return {HTMLElement | null} - The html element or null if the browser environment is not available.
|
25
|
+
*/
|
26
|
+
createCarouselElement({ slides, config, }: ICreateCarouselElementParams): HTMLElement | null;
|
15
27
|
/**
|
16
28
|
* Overrides the spot colors with the provided colors.
|
17
29
|
*
|
@@ -7,4 +7,4 @@ import type { ISpotTemplateConfig } from './template.type';
|
|
7
7
|
*
|
8
8
|
* @return {string} - The spot html string.
|
9
9
|
*/
|
10
|
-
export declare const
|
10
|
+
export declare const SPOT_TEMPLATE_HTML_ELEMENT: (spot: ISpot, config?: ISpotTemplateConfig) => HTMLElement | null;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { RMN_SPOT_EVENT, RMN_SPOT_TYPE } from 'enums';
|
2
|
-
import type {
|
2
|
+
import type { PlacementIdType, SpotVariantType } from 'modules/selection';
|
3
3
|
import type { RmnFilterType, RmnSpotType } from 'types';
|
4
4
|
export interface ISpotSelectionParams {
|
5
5
|
url?: string;
|
@@ -30,7 +30,7 @@ export interface ISpot {
|
|
30
30
|
mobileSecondaryImage?: string;
|
31
31
|
productUpcs?: string[];
|
32
32
|
}
|
33
|
-
export type ISpots = Record<
|
33
|
+
export type ISpots = Record<PlacementIdType, ISpot[]>;
|
34
34
|
export interface ISelectionService {
|
35
35
|
spotSelection(data: ISpotSelectionParams): Promise<ISpots>;
|
36
36
|
}
|
@@ -2,12 +2,13 @@ import type { RMN_FILTER_PROPERTIES, RMN_SPOT_TYPE } from 'enums';
|
|
2
2
|
export type RmnFilterType = {
|
3
3
|
[key in RMN_FILTER_PROPERTIES]?: string[];
|
4
4
|
};
|
5
|
+
export type PlacementIdType = RMN_SPOT_TYPE | `${RMN_SPOT_TYPE}${number}` | string;
|
5
6
|
export type SpotFilterType = {
|
7
|
+
placementId?: PlacementIdType;
|
6
8
|
spot: RMN_SPOT_TYPE | string;
|
7
|
-
count
|
9
|
+
count?: number;
|
8
10
|
exactMatch?: string;
|
9
11
|
} & Omit<RmnFilterType, RMN_FILTER_PROPERTIES.KEYWORDS>;
|
10
|
-
export type SpotIdentifierType = RMN_SPOT_TYPE | `${RMN_SPOT_TYPE}${number}`;
|
11
12
|
export type RmnSpotType = RMN_SPOT_TYPE | string | SpotFilterType;
|
12
13
|
type RBSpotTypeKeys = keyof {
|
13
14
|
[K in keyof typeof RMN_SPOT_TYPE as K extends `RB_${string}` ? K : never]: (typeof RMN_SPOT_TYPE)[K];
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IAuthCredentials } from 'modules/auth';
|
2
|
-
import type {
|
3
|
-
import type { ISpots, ISpotSelectionParams } from 'modules/selection';
|
2
|
+
import type { IInjectSpotElementParams, IRmnCreateSpotElementConfig } from 'modules/element';
|
3
|
+
import type { ISpot, ISpots, ISpotSelectionParams } from 'modules/selection';
|
4
4
|
import type { IRmnClient, IRmnConfig } from 'types';
|
5
5
|
export declare class LiquidCommerceRmnClient implements IRmnClient {
|
6
6
|
private readonly selectionService;
|
@@ -11,26 +11,33 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
|
|
11
11
|
*
|
12
12
|
* To create a spot html element, use the RmnCreateSpotElement function.
|
13
13
|
*
|
14
|
-
* @param {ISpotSelectionParams}
|
14
|
+
* @param {ISpotSelectionParams} params - Spots selection parameters.
|
15
15
|
*
|
16
16
|
* @return {Promise<ISpots>} - The spots response object.
|
17
17
|
*/
|
18
|
-
spotSelection(
|
18
|
+
spotSelection(params: ISpotSelectionParams): Promise<ISpots>;
|
19
19
|
/**
|
20
20
|
* Injects the spot elements into their provided placement.
|
21
21
|
*
|
22
|
-
* @param {
|
23
|
-
* @param {IInjectSpotsConfig} config - The configuration object.
|
22
|
+
* @param {IInjectSpotElementParams} params - Parameters for injecting spot elements.
|
24
23
|
*
|
25
24
|
* @return {Promise<void>} - A promise that resolves when the spot elements are injected.
|
26
25
|
*/
|
27
|
-
injectSpotElement(
|
26
|
+
injectSpotElement(params: IInjectSpotElementParams): Promise<void>;
|
27
|
+
/**
|
28
|
+
* Makes a selection request on our server based on the provided data.
|
29
|
+
*
|
30
|
+
* @param {IInjectSpotElementParams} params - Parameters for injecting spot elements.
|
31
|
+
*
|
32
|
+
* @return {Promise<ISpots>} - The spots response object.
|
33
|
+
*/
|
34
|
+
private spotSelectionRequest;
|
28
35
|
/**
|
29
36
|
* Injects a carousel element with the provided spots into the placement.
|
30
37
|
*
|
31
38
|
* @param {HTMLElement} placement - The placement element.
|
32
39
|
* @param {ISpot[]} spots - The spot data.
|
33
|
-
* @param {
|
40
|
+
* @param {IInjectSpotElementConfig} config - The configuration object.
|
34
41
|
*
|
35
42
|
* @return {void}
|
36
43
|
*/
|
@@ -41,19 +48,21 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
|
|
41
48
|
* @param {IInjectSpotElement} injectItem - The inject item data.
|
42
49
|
* @param {HTMLElement} placement - The placement element.
|
43
50
|
* @param {ISpot} spot - The spot data.
|
44
|
-
* @param {
|
51
|
+
* @param {IInjectSpotElementConfig} config - The configuration object.
|
45
52
|
*
|
46
53
|
* @return {void}
|
47
54
|
*/
|
48
55
|
private injectOneSpotElement;
|
49
56
|
/**
|
50
|
-
*
|
57
|
+
* Prevents duplicate placement ids in the inject data.
|
58
|
+
*
|
59
|
+
* @param {IInjectSpotElement[]} inject - The inject data.
|
51
60
|
*
|
52
|
-
* @
|
61
|
+
* @throws {Error} - If a duplicate placement id is found.
|
53
62
|
*
|
54
|
-
* @return {
|
63
|
+
* @return {void}
|
55
64
|
*/
|
56
|
-
private
|
65
|
+
private preventDuplicateSpotPlacementIds;
|
57
66
|
}
|
58
67
|
/**
|
59
68
|
* Creates a new instance of the RmnClient.
|
@@ -64,4 +73,17 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
|
|
64
73
|
* @return {Promise<IRmnClient>} - The RmnClient instance.
|
65
74
|
*/
|
66
75
|
declare function RmnClient(apiKey: string, config: IRmnConfig): Promise<IRmnClient>;
|
67
|
-
|
76
|
+
/**
|
77
|
+
* Creates the spot html element based on the provided data using shadow dom.
|
78
|
+
*
|
79
|
+
* This method is useful when you are initializing the client in a non-browser environment.
|
80
|
+
* When you request a spot selection, you will receive the spot data in server-side and return them to the client.
|
81
|
+
* Then you can use this function to create the spot html element based on the provided data without the need of the RmnClient instance.
|
82
|
+
*
|
83
|
+
* @param {ISpot} spot - The spot data.
|
84
|
+
* @param {IRmnCreateSpotElementConfig} config - The configuration object.
|
85
|
+
*
|
86
|
+
* @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
|
87
|
+
*/
|
88
|
+
declare function RmnCreateSpotElement(spot: ISpot, config?: IRmnCreateSpotElementConfig): HTMLElement | null;
|
89
|
+
export { RmnClient, RmnCreateSpotElement };
|
package/dist/types/types.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
export type {
|
1
|
+
export type { IInjectSpotElement, IInjectSpotElementConfig, IRmnCreateSpotElementConfig, } from 'modules/element';
|
2
2
|
export type { ISpots, RmnFilterType, RmnSpotType } from 'modules/selection';
|
3
3
|
export { ISpot, ISpotEvent, ISpotSelectionParams } from 'modules/selection';
|
4
4
|
import type { RMN_ENV } from 'enums';
|
5
|
-
import type {
|
5
|
+
import type { IInjectSpotElementParams } from 'modules/element';
|
6
6
|
import type { ISpots, ISpotSelectionParams } from 'modules/selection';
|
7
7
|
export interface IRmnClient {
|
8
|
-
spotSelection(
|
9
|
-
injectSpotElement(
|
8
|
+
spotSelection(params: ISpotSelectionParams): Promise<ISpots>;
|
9
|
+
injectSpotElement(params: IInjectSpotElementParams): Promise<void>;
|
10
10
|
}
|
11
11
|
export interface IRmnConfig {
|
12
12
|
env: RMN_ENV;
|
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.4.6-beta.
|
5
|
+
"version": "1.4.6-beta.4",
|
6
6
|
"homepage": "https://docs.liquidcommerce.co/rmn-sdk",
|
7
7
|
"main": "./dist/index.cjs",
|
8
8
|
"module": "./dist/index.esm.js",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"test": "vitest run",
|
43
43
|
"test:watch": "vitest",
|
44
44
|
"test:coverage": "vitest run --coverage",
|
45
|
-
"lint": "eslint \"src/**/*.ts\"
|
45
|
+
"lint": "eslint \"src/**/*.ts\"",
|
46
46
|
"format": "prettier --write \"src/**/*.ts\"",
|
47
47
|
"docs": "typedoc --out docs src",
|
48
48
|
"prepublishOnly": "pnpm run build"
|