@liquidcommercedev/rmn-sdk 1.4.6-beta.2 → 1.4.6-beta.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- export type CarouselNavPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'middle-left' | 'middle-right' | 'middle-sides';
2
- export interface ICarouselDotOptions {
3
- position: CarouselNavPosition;
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
- export declare const CAROUSEL_COMPONENT_STYLE = "\n :host {\n position: relative;\n display: inline-block;\n margin: 0;\n overflow: hidden;\n height: 100%;\n width: 100%;\n }\n\n .carousel-slides {\n position: relative;\n height: 100%;\n width: 100%;\n }\n\n .carousel-slide {\n display: none;\n\n justify-content: center;\n align-items: center;\n height: 100%;\n width: 100%;\n }\n\n .carousel-slide.active {\n display: flex;\n }\n\n .carousel-dots {\n position: absolute;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .carousel-dots .dot {\n width: 12px;\n height: 12px;\n border-radius: 50%;\n cursor: pointer;\n transition: all 0.3s ease;\n }\n\n .carousel-dots.top-left,\n .carousel-dots.bottom-left {\n left: 10px;\n }\n\n .carousel-dots.top-center,\n .carousel-dots.bottom-center {\n left: 50%;\n transform: translateX(-50%);\n }\n\n .carousel-dots.top-right,\n .carousel-dots.bottom-right {\n right: 10px;\n }\n\n .carousel-dots.top-left,\n .carousel-dots.top-center,\n .carousel-dots.top-right {\n top: 10px;\n }\n\n .carousel-dots.bottom-left,\n .carousel-dots.bottom-center,\n .carousel-dots.bottom-right {\n bottom: 10px;\n }\n\n .carousel-dots.middle-left {\n left: 10px;\n top: 50%;\n transform: translateY(-50%);\n flex-direction: column;\n }\n\n .carousel-dots.middle-right {\n right: 10px;\n top: 50%;\n transform: translateY(-50%);\n flex-direction: column;\n }\n\n .carousel-buttons button {\n background-color: #00000080;\n color: #fff;\n border: none;\n padding: 10px;\n cursor: pointer;\n transition: background-color 0.3s ease;\n }\n\n .carousel-buttons button:hover {\n background-color: #000000b3;\n }\n\n .carousel-buttons.buttons-separate button {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n }\n\n .carousel-buttons.buttons-separate .prev-button {\n left: 10px;\n }\n\n .carousel-buttons.buttons-separate .next-button {\n right: 10px;\n }\n\n .carousel-buttons.buttons-together {\n position: absolute;\n display: flex;\n gap: 10px;\n }\n\n .carousel-buttons.buttons-together.top-left,\n .carousel-buttons.buttons-together.bottom-left {\n left: 10px;\n }\n\n .carousel-buttons.buttons-together.top-center,\n .carousel-buttons.buttons-together.bottom-center {\n left: 50%;\n transform: translateX(-50%);\n }\n\n .carousel-buttons.buttons-together.top-right,\n .carousel-buttons.buttons-together.bottom-right {\n right: 10px;\n }\n\n .carousel-buttons.buttons-together.top-left,\n .carousel-buttons.buttons-together.top-center,\n .carousel-buttons.buttons-together.top-right {\n top: 10px;\n }\n\n .carousel-buttons.buttons-together.bottom-left,\n .carousel-buttons.buttons-together.bottom-center,\n .carousel-buttons.buttons-together.bottom-right {\n bottom: 10px;\n }\n\n .carousel-buttons.buttons-together.middle-left,\n .carousel-buttons.buttons-together.middle-right {\n top: 50%;\n transform: translateY(-50%);\n flex-direction: column;\n }\n\n .carousel-buttons.buttons-together.middle-left {\n left: 10px;\n }\n\n .carousel-buttons.buttons-together.middle-right {\n right: 10px;\n }\n\n @media (max-width: 768px) {\n .carousel-buttons button {\n padding: 8px 12px;\n font-size: 14px;\n }\n\n .carousel-dots .dot {\n width: 8px;\n height: 8px;\n }\n }\n";
1
+ import type { ICustomCarouselElementData } from './carousel.interface';
2
+ export declare const CAROUSEL_COMPONENT_STYLE: ({ width, height, fluid }: ICustomCarouselElementData) => string;
@@ -1,2 +1,3 @@
1
1
  export * from './carousel.component';
2
+ export * from './carousel.interface';
2
3
  export * from './carousel.style';
@@ -0,0 +1,2 @@
1
+ export * from './spot.component';
2
+ export * from './spot.interface';
@@ -0,0 +1,3 @@
1
+ import type { ICustomSpotElement } from './spot.interface';
2
+ declare let SpotElement: new () => ICustomSpotElement;
3
+ export { SpotElement };
@@ -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 ELEMENT_TAG = "spot-element";
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,6 @@
1
1
  import type { RMN_SPOT_TYPE } from 'enums';
2
- import type { ICarouselOptions } from './component/carousel';
2
+ import type { ICarouselOptions, ICreateCarouselElementParams } from './component/carousel';
3
+ import type { ICreateSpotElementParams } from './component/spot';
3
4
  export interface ISpotColors {
4
5
  textColor?: string;
5
6
  backgroundColor?: string;
@@ -10,34 +11,31 @@ export interface ISpotOverlay {
10
11
  color: string;
11
12
  colorStop: string;
12
13
  }
13
- export interface ISpotBaseConfig {
14
- colors?: ISpotColors;
15
- minScale?: number;
16
- overlay?: ISpotOverlay[];
17
- }
18
14
  export interface IInjectSpotElement {
19
15
  placementId: string;
20
16
  spotType: RMN_SPOT_TYPE | string;
21
17
  count?: number;
22
18
  }
23
- export interface IInjectSpotsConfig extends ISpotBaseConfig {
19
+ export interface IInjectSpotElementConfig {
20
+ url?: string;
21
+ colors?: ISpotColors;
22
+ minScale?: number;
23
+ overlay?: ISpotOverlay[];
24
24
  carousel?: ICarouselOptions;
25
25
  }
26
- export interface ICreateFinalElementConfig {
26
+ export interface ICreateElementConfig {
27
27
  width: number;
28
28
  height: number;
29
29
  fluid?: boolean;
30
- minScale?: number;
31
- }
32
- export interface ICreateFinalElementParams {
33
- content: HTMLElement | string;
34
- config: ICreateFinalElementConfig;
30
+ minScale: number;
35
31
  }
36
32
  export interface IElementService {
37
- createFinalElement(data: ICreateFinalElementParams): HTMLElement | null;
33
+ createSpotElement(data: ICreateSpotElementParams): HTMLElement | null;
34
+ createCarouselElement(data: ICreateCarouselElementParams): HTMLElement | null;
38
35
  }
39
- export type ICustomSpotElementData = ICreateFinalElementConfig;
40
- export interface ICustomSpotElement extends HTMLElement {
41
- data: ICustomSpotElementData;
42
- content: HTMLElement | string;
36
+ export interface IRmnCreateSpotElementConfig {
37
+ fluid?: boolean;
38
+ colors?: ISpotColors;
39
+ overlay?: ISpotOverlay[];
40
+ minScale?: number;
43
41
  }
@@ -1,5 +1,7 @@
1
1
  import type { ISpot } from 'modules/selection';
2
- import type { ICreateFinalElementParams, IElementService, ISpotColors } from './element.interface';
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 {ICreateFinalElementParams} params - The parameters to create the final element.
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
- createFinalElement({ content, config }: ICreateFinalElementParams): HTMLElement | null;
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
  *
@@ -1,3 +1,3 @@
1
1
  export * from './element.constant';
2
2
  export * from './element.interface';
3
- export * from './spot.element.service';
3
+ export * from './element.service';
@@ -1,2 +1,3 @@
1
1
  import type { ISpotOverlay } from '../element.interface';
2
2
  export declare function linearGradientColorStop(overlay: ISpotOverlay[], fallback: string): string;
3
+ export declare function spotHtmlStringToElement(htmlString: string): HTMLElement;
@@ -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 GET_SPOT_TEMPLATE_HTML_STRING: (spot: ISpot, config?: ISpotTemplateConfig) => string;
10
+ export declare const SPOT_TEMPLATE_HTML_ELEMENT: (spot: ISpot, config?: ISpotTemplateConfig) => HTMLElement | null;
@@ -5,7 +5,7 @@ export interface IResizeSize {
5
5
  export interface IResizeOptions {
6
6
  element: HTMLElement;
7
7
  maxSize: IResizeSize;
8
- minScale?: number;
8
+ minScale: number;
9
9
  }
10
10
  export interface ISizeChangedEvent extends CustomEvent {
11
11
  detail: {
@@ -1,6 +1,6 @@
1
1
  import type { IAuthCredentials } from 'modules/auth';
2
- import type { IInjectSpotElement, IInjectSpotsConfig } from 'modules/element';
3
- import type { ISpots, ISpotSelectionParams } from 'modules/selection';
2
+ import type { IInjectSpotElement, IInjectSpotElementConfig, 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;
@@ -19,18 +19,18 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
19
19
  /**
20
20
  * Injects the spot elements into their provided placement.
21
21
  *
22
- * @param {IInjectSpotElement[]} data - The spot elements data.
23
- * @param {IInjectSpotsConfig} config - The configuration object.
22
+ * @param {IInjectSpotElement[]} data - The spot element's data.
23
+ * @param {IInjectSpotElementConfig} config - The configuration object.
24
24
  *
25
25
  * @return {Promise<void>} - A promise that resolves when the spot elements are injected.
26
26
  */
27
- injectSpotElement(data: IInjectSpotElement[], config?: IInjectSpotsConfig): Promise<void>;
27
+ injectSpotElement(data: IInjectSpotElement[], config?: IInjectSpotElementConfig): Promise<void>;
28
28
  /**
29
29
  * Injects a carousel element with the provided spots into the placement.
30
30
  *
31
31
  * @param {HTMLElement} placement - The placement element.
32
32
  * @param {ISpot[]} spots - The spot data.
33
- * @param {IInjectSpotsConfig} config - The configuration object.
33
+ * @param {IInjectSpotElementConfig} config - The configuration object.
34
34
  *
35
35
  * @return {void}
36
36
  */
@@ -41,7 +41,7 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
41
41
  * @param {IInjectSpotElement} injectItem - The inject item data.
42
42
  * @param {HTMLElement} placement - The placement element.
43
43
  * @param {ISpot} spot - The spot data.
44
- * @param {IInjectSpotsConfig} config - The configuration object.
44
+ * @param {IInjectSpotElementConfig} config - The configuration object.
45
45
  *
46
46
  * @return {void}
47
47
  */
@@ -64,4 +64,17 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
64
64
  * @return {Promise<IRmnClient>} - The RmnClient instance.
65
65
  */
66
66
  declare function RmnClient(apiKey: string, config: IRmnConfig): Promise<IRmnClient>;
67
- export { RmnClient };
67
+ /**
68
+ * Creates the spot html element based on the provided data using shadow dom.
69
+ *
70
+ * This method is useful when you are initializing the client in a non-browser environment.
71
+ * When you request a spot selection, you will receive the spot data in server-side and return them to the client.
72
+ * Then you can use this function to create the spot html element based on the provided data without the need of the RmnClient instance.
73
+ *
74
+ * @param {ISpot} spot - The spot data.
75
+ * @param {IRmnCreateSpotElementConfig} config - The configuration object.
76
+ *
77
+ * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
78
+ */
79
+ declare function RmnCreateSpotElement(spot: ISpot, config?: IRmnCreateSpotElementConfig): HTMLElement | null;
80
+ export { RmnClient, RmnCreateSpotElement };
@@ -0,0 +1,3 @@
1
+ import type { ISpotEvent, ISpots } from 'types';
2
+ export declare const SPOT_EVENTS_EXAMPLE: ISpotEvent[];
3
+ export declare const RB_SPOTS_SELECTION_EXAMPLE: Partial<ISpots>;
@@ -1,12 +1,12 @@
1
- export type { IInjectSpotsConfig } from 'modules/element';
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 { IInjectSpotElement, IInjectSpotsConfig } from 'modules/element';
5
+ import type { IInjectSpotElement, IInjectSpotElementConfig } from 'modules/element';
6
6
  import type { ISpots, ISpotSelectionParams } from 'modules/selection';
7
7
  export interface IRmnClient {
8
8
  spotSelection(data: ISpotSelectionParams): Promise<ISpots>;
9
- injectSpotElement(spots: IInjectSpotElement[], config?: IInjectSpotsConfig): Promise<void>;
9
+ injectSpotElement(spots: IInjectSpotElement[], config?: IInjectSpotElementConfig): 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.2",
5
+ "version": "1.4.6-beta.3",
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\" --fix",
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"