@placetopay/lightbox-sdk 2.1.1 → 2.1.2

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.
@@ -1,17 +1,20 @@
1
- export declare enum ElementIds {
2
- WRAPPER_ID = "placetopay_lightbox_wrapper",
3
- IFRAME_ID = "placetopay_lightbox",
4
- CLOSE_BUTTON_ID = "placetopay_close_button",
5
- STYLES_ID = "placetopay-lightbox"
6
- }
7
- export declare enum LightboxEvents {
8
- CLOSE = "close",
9
- UPDATE_STYLES = "updateStyles",
10
- HIDE_CLOSE_BUTTON = "hideCloseButton"
11
- }
12
- export declare enum Styles {
13
- BACKDROP_COLOR = "--placetopay-lightbox-backdrop-color",
14
- RADIUS = "--placetopay-lightbox-border-radius",
15
- MAX_HEIGHT = "--placetopay-lightbox-max-height",
16
- MAX_WIDTH = "--placetopay-lightbox-max-width"
17
- }
1
+ export declare enum ElementIds {
2
+ WRAPPER_ID = "placetopay_lightbox_wrapper",
3
+ IFRAME_ID = "placetopay_lightbox",
4
+ CLOSE_BUTTON_ID = "placetopay_close_button",
5
+ STYLES_ID = "placetopay-lightbox"
6
+ }
7
+ export declare enum LightboxEvents {
8
+ CLOSE = "close",
9
+ UPDATE_STYLES = "updateStyles",
10
+ HIDE_CLOSE_BUTTON = "hideCloseButton"
11
+ }
12
+ export declare enum Styles {
13
+ BACKDROP_COLOR = "--placetopay-lightbox-backdrop-color",
14
+ RADIUS = "--placetopay-lightbox-border-radius",
15
+ MAX_HEIGHT = "--placetopay-lightbox-max-height",
16
+ MAX_WIDTH = "--placetopay-lightbox-max-width",
17
+ POSITION = "--placetopay-lightbox-position",
18
+ WRAPPER_WIDTH = "--placetopay-lightbox-wrapper-width",
19
+ WRAPPER_HEIGHT = "--placetopay-lightbox-wrapper-height"
20
+ }
package/dist/constants.js CHANGED
@@ -1,20 +1,23 @@
1
- export var ElementIds;
2
- (function (ElementIds) {
3
- ElementIds["WRAPPER_ID"] = "placetopay_lightbox_wrapper";
4
- ElementIds["IFRAME_ID"] = "placetopay_lightbox";
5
- ElementIds["CLOSE_BUTTON_ID"] = "placetopay_close_button";
6
- ElementIds["STYLES_ID"] = "placetopay-lightbox";
7
- })(ElementIds || (ElementIds = {}));
8
- export var LightboxEvents;
9
- (function (LightboxEvents) {
10
- LightboxEvents["CLOSE"] = "close";
11
- LightboxEvents["UPDATE_STYLES"] = "updateStyles";
12
- LightboxEvents["HIDE_CLOSE_BUTTON"] = "hideCloseButton";
13
- })(LightboxEvents || (LightboxEvents = {}));
14
- export var Styles;
15
- (function (Styles) {
16
- Styles["BACKDROP_COLOR"] = "--placetopay-lightbox-backdrop-color";
17
- Styles["RADIUS"] = "--placetopay-lightbox-border-radius";
18
- Styles["MAX_HEIGHT"] = "--placetopay-lightbox-max-height";
19
- Styles["MAX_WIDTH"] = "--placetopay-lightbox-max-width";
20
- })(Styles || (Styles = {}));
1
+ export var ElementIds;
2
+ (function (ElementIds) {
3
+ ElementIds["WRAPPER_ID"] = "placetopay_lightbox_wrapper";
4
+ ElementIds["IFRAME_ID"] = "placetopay_lightbox";
5
+ ElementIds["CLOSE_BUTTON_ID"] = "placetopay_close_button";
6
+ ElementIds["STYLES_ID"] = "placetopay-lightbox";
7
+ })(ElementIds || (ElementIds = {}));
8
+ export var LightboxEvents;
9
+ (function (LightboxEvents) {
10
+ LightboxEvents["CLOSE"] = "close";
11
+ LightboxEvents["UPDATE_STYLES"] = "updateStyles";
12
+ LightboxEvents["HIDE_CLOSE_BUTTON"] = "hideCloseButton";
13
+ })(LightboxEvents || (LightboxEvents = {}));
14
+ export var Styles;
15
+ (function (Styles) {
16
+ Styles["BACKDROP_COLOR"] = "--placetopay-lightbox-backdrop-color";
17
+ Styles["RADIUS"] = "--placetopay-lightbox-border-radius";
18
+ Styles["MAX_HEIGHT"] = "--placetopay-lightbox-max-height";
19
+ Styles["MAX_WIDTH"] = "--placetopay-lightbox-max-width";
20
+ Styles["POSITION"] = "--placetopay-lightbox-position";
21
+ Styles["WRAPPER_WIDTH"] = "--placetopay-lightbox-wrapper-width";
22
+ Styles["WRAPPER_HEIGHT"] = "--placetopay-lightbox-wrapper-height";
23
+ })(Styles || (Styles = {}));
@@ -1,3 +1,3 @@
1
- import { MountLightboxOptions } from '../types';
2
- export declare const mountLightbox: ({ url, callbacks, styles, closeButtonEnabled, enforceStyles }: MountLightboxOptions) => void;
3
- export declare const unmountLightbox: (target: string) => void;
1
+ import { MountLightboxOptions } from '../types';
2
+ export declare const mountLightbox: ({ id, url, element, callbacks, styles, closeButtonEnabled, enforceStyles, }: MountLightboxOptions) => void;
3
+ export declare const unmountLightbox: (target: string) => void;
@@ -1,78 +1,87 @@
1
- import { Styles, ElementIds, LightboxEvents as LE } from '../constants';
2
- import { setStyle, unsetStyle } from '../helpers';
3
- let listener;
4
- export const mountLightbox = ({ url, callbacks, styles, closeButtonEnabled, enforceStyles }) => {
5
- const wrapper = document.createElement('div');
6
- wrapper.id = new URL(url).origin;
7
- wrapper.className = ElementIds.WRAPPER_ID;
8
- const iframe = document.createElement('iframe');
9
- iframe.src = url;
10
- iframe.id = ElementIds.IFRAME_ID;
11
- updateStyles(styles);
12
- document.body.appendChild(wrapper);
13
- wrapper.appendChild(iframe);
14
- let closeButton;
15
- if (closeButtonEnabled) {
16
- closeButton = document.createElement('button');
17
- closeButton.id = ElementIds.CLOSE_BUTTON_ID;
18
- closeButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#4b5563" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/></svg>`;
19
- closeButton.addEventListener('click', () => {
20
- unmountLightbox(new URL(url).origin);
21
- });
22
- wrapper.appendChild(closeButton);
23
- }
24
- mountListener({ callbacks, styles, closeButton, enforceStyles });
25
- };
26
- const mountListener = ({ callbacks, styles, closeButton, enforceStyles }) => {
27
- listener = (event) => {
28
- var _a;
29
- if (event.data.type === LE.CLOSE)
30
- unmountLightbox(event.origin);
31
- if (event.data.type === LE.UPDATE_STYLES) {
32
- const newStyles = enforceStyles
33
- ? Object.assign(Object.assign({}, event.data.payload), styles) : Object.assign(Object.assign({}, styles), event.data.payload);
34
- updateStyles(newStyles);
35
- }
36
- if (event.data.type === LE.HIDE_CLOSE_BUTTON)
37
- closeButton === null || closeButton === void 0 ? void 0 : closeButton.remove();
38
- (_a = callbacks[event.data.type]) === null || _a === void 0 ? void 0 : _a.call(callbacks, event.data.payload);
39
- };
40
- globalThis.addEventListener('message', listener);
41
- };
42
- export const unmountLightbox = (target) => {
43
- const element = document.getElementById(target);
44
- if (element) {
45
- element.remove();
46
- clearStyles();
47
- globalThis.removeEventListener('message', listener);
48
- }
49
- else
50
- throw new Error(`Frame from "${target}" not found`);
51
- };
52
- const clearStyles = () => {
53
- unsetStyle(Styles.BACKDROP_COLOR);
54
- unsetStyle(Styles.RADIUS);
55
- unsetStyle(Styles.MAX_HEIGHT);
56
- unsetStyle(Styles.MAX_WIDTH);
57
- };
58
- const updateStyles = (styles) => {
59
- var _a, _b, _c, _d, _e;
60
- setStyle(Styles.BACKDROP_COLOR, buildBackdrop((_a = styles.backdropColor) !== null && _a !== void 0 ? _a : '#000000', (_b = styles.backdropOpacity) !== null && _b !== void 0 ? _b : 0.7));
61
- setStyle(Styles.RADIUS, `${(_c = styles.radius) !== null && _c !== void 0 ? _c : 0}px`);
62
- setStyle(Styles.MAX_HEIGHT, buildDimension('height', (_d = styles.height) !== null && _d !== void 0 ? _d : 640));
63
- setStyle(Styles.MAX_WIDTH, buildDimension('width', (_e = styles.width) !== null && _e !== void 0 ? _e : 512));
64
- };
65
- const buildBackdrop = (color, opacity) => {
66
- var _a;
67
- const backdrop = (_a = color === null || color === void 0 ? void 0 : color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b).substring(1).match(/.{2}/g)) === null || _a === void 0 ? void 0 : _a.map((x) => parseInt(x, 16));
68
- backdrop.push(opacity);
69
- return `rgba(${backdrop.join(', ')})`;
70
- };
71
- const buildDimension = (type, value) => {
72
- const result = String(value);
73
- if (result.match(/^\d+%$/) || result.match(/^\d+px$/))
74
- return result;
75
- if (result.match(/^\d+$/))
76
- return `${result}px`;
77
- console.warn(`Invalid ${type}. Must be a number, a number followed by "px", or a number followed by "%".`);
78
- };
1
+ import { Styles, ElementIds, LightboxEvents as LE } from '../constants';
2
+ import { setStyle, unsetStyle } from '../helpers';
3
+ let listener;
4
+ export const mountLightbox = ({ id, url, element, callbacks, styles, closeButtonEnabled, enforceStyles, }) => {
5
+ const wrapper = document.createElement('div');
6
+ wrapper.id = id;
7
+ wrapper.className = ElementIds.WRAPPER_ID;
8
+ if (element !== document.body) {
9
+ wrapper.style.setProperty(Styles.POSITION, 'absolute');
10
+ wrapper.style.setProperty(Styles.WRAPPER_HEIGHT, '100%');
11
+ wrapper.style.setProperty(Styles.WRAPPER_WIDTH, '100%');
12
+ }
13
+ const iframe = document.createElement('iframe');
14
+ iframe.src = url;
15
+ iframe.id = ElementIds.IFRAME_ID;
16
+ updateStyles(styles);
17
+ console.log({ isBody: element === document.body });
18
+ element.appendChild(wrapper);
19
+ wrapper.appendChild(iframe);
20
+ let closeButton;
21
+ if (closeButtonEnabled) {
22
+ closeButton = document.createElement('button');
23
+ closeButton.id = ElementIds.CLOSE_BUTTON_ID;
24
+ closeButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#4b5563" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/></svg>`;
25
+ closeButton.addEventListener('click', () => {
26
+ unmountLightbox(id);
27
+ });
28
+ wrapper.appendChild(closeButton);
29
+ }
30
+ mountListener({ id, callbacks, styles, closeButton, enforceStyles });
31
+ };
32
+ const mountListener = ({ id, callbacks, styles, closeButton, enforceStyles }) => {
33
+ listener = (event) => {
34
+ var _a;
35
+ if (event.data.type === LE.CLOSE)
36
+ unmountLightbox(id);
37
+ if (event.data.type === LE.UPDATE_STYLES) {
38
+ const newStyles = enforceStyles
39
+ ? Object.assign(Object.assign({}, event.data.payload), styles) : Object.assign(Object.assign({}, styles), event.data.payload);
40
+ updateStyles(newStyles);
41
+ }
42
+ if (event.data.type === LE.HIDE_CLOSE_BUTTON)
43
+ closeButton === null || closeButton === void 0 ? void 0 : closeButton.remove();
44
+ (_a = callbacks[event.data.type]) === null || _a === void 0 ? void 0 : _a.call(callbacks, event.data.payload);
45
+ };
46
+ globalThis.addEventListener('message', listener);
47
+ };
48
+ export const unmountLightbox = (target) => {
49
+ const element = document.getElementById(target);
50
+ if (element) {
51
+ element.remove();
52
+ clearStyles();
53
+ globalThis.removeEventListener('message', listener);
54
+ }
55
+ else
56
+ throw new Error(`Frame from "${target}" not found`);
57
+ };
58
+ const clearStyles = () => {
59
+ unsetStyle(Styles.BACKDROP_COLOR);
60
+ unsetStyle(Styles.RADIUS);
61
+ unsetStyle(Styles.MAX_HEIGHT);
62
+ unsetStyle(Styles.MAX_WIDTH);
63
+ };
64
+ const updateStyles = (styles) => {
65
+ var _a, _b, _c, _d, _e, _f, _g, _h;
66
+ setStyle(Styles.BACKDROP_COLOR, buildBackdrop((_a = styles.backdropColor) !== null && _a !== void 0 ? _a : '#000000', (_b = styles.backdropOpacity) !== null && _b !== void 0 ? _b : 0.7));
67
+ setStyle(Styles.RADIUS, `${(_c = styles.radius) !== null && _c !== void 0 ? _c : 0}px`);
68
+ setStyle(Styles.MAX_HEIGHT, buildDimension('height', (_d = styles.height) !== null && _d !== void 0 ? _d : 640));
69
+ setStyle(Styles.MAX_WIDTH, buildDimension('width', (_e = styles.width) !== null && _e !== void 0 ? _e : 512));
70
+ setStyle(Styles.POSITION, (_f = styles.position) !== null && _f !== void 0 ? _f : 'fixed');
71
+ setStyle(Styles.WRAPPER_WIDTH, buildDimension('width', (_g = styles.wrapperWidth) !== null && _g !== void 0 ? _g : '100vw'));
72
+ setStyle(Styles.WRAPPER_HEIGHT, buildDimension('height', (_h = styles.wrapperHeight) !== null && _h !== void 0 ? _h : '100vh'));
73
+ };
74
+ const buildBackdrop = (color, opacity) => {
75
+ var _a;
76
+ const backdrop = (_a = color === null || color === void 0 ? void 0 : color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b).substring(1).match(/.{2}/g)) === null || _a === void 0 ? void 0 : _a.map((x) => parseInt(x, 16));
77
+ backdrop.push(opacity);
78
+ return `rgba(${backdrop.join(', ')})`;
79
+ };
80
+ const buildDimension = (type, value) => {
81
+ const result = String(value);
82
+ if (result.match(/^\d+(vh|vw|px|%)$/))
83
+ return result;
84
+ if (result.match(/^\d+$/))
85
+ return `${result}px`;
86
+ console.warn(`Invalid ${type}. Must be a number, a number followed by "px", or a number followed by "%".`);
87
+ };
@@ -1,7 +1,7 @@
1
- import { InitialOptions, LightboxInstance, ApiStructure, LightboxStyles } from '../types';
2
- export declare const isInside: () => boolean;
3
- export declare const updateStyles: (styles: LightboxStyles) => void;
4
- export declare const hideCloseButton: () => void;
5
- export declare const emitClose: (payload?: unknown, preventClose?: boolean) => void;
6
- export declare const emit: ({ type, payload, preventClose }: ApiStructure) => void;
7
- export declare const createLightbox: (url: string, options?: InitialOptions) => LightboxInstance;
1
+ import { InitialOptions, LightboxInstance, ApiStructure, LightboxStyles } from '../types';
2
+ export declare const isInside: () => boolean;
3
+ export declare const updateStyles: (styles: LightboxStyles) => void;
4
+ export declare const hideCloseButton: () => void;
5
+ export declare const emitClose: (payload?: unknown, preventClose?: boolean) => void;
6
+ export declare const emit: ({ type, payload, preventClose }: ApiStructure) => void;
7
+ export declare const createLightbox: (url: string, options?: InitialOptions) => LightboxInstance;
@@ -1,41 +1,45 @@
1
- import { LightboxEvents as LE } from '../constants';
2
- import { postMessage, redirectBasedOnDriver } from '../helpers';
3
- import { mountLightbox, unmountLightbox } from './assemblers';
4
- export const isInside = () => globalThis.location !== globalThis.parent.location;
5
- export const updateStyles = (styles) => postMessage(LE.UPDATE_STYLES, styles);
6
- export const hideCloseButton = () => postMessage(LE.HIDE_CLOSE_BUTTON);
7
- export const emitClose = (payload, preventClose) => {
8
- postMessage(LE.CLOSE, payload, preventClose);
9
- };
10
- export const emit = ({ type, payload, preventClose }) => postMessage(type, payload, preventClose);
11
- export const createLightbox = (url, options) => {
12
- var _a, _b, _c, _d;
13
- const lightbox = {
14
- allowRedirects: (_a = options === null || options === void 0 ? void 0 : options.allowRedirects) !== null && _a !== void 0 ? _a : true,
15
- callbacks: (_b = options === null || options === void 0 ? void 0 : options.callbacks) !== null && _b !== void 0 ? _b : {},
16
- closeButton: (_c = options === null || options === void 0 ? void 0 : options.closeButton) !== null && _c !== void 0 ? _c : true,
17
- styles: (_d = options === null || options === void 0 ? void 0 : options.styles) !== null && _d !== void 0 ? _d : {},
18
- url: url,
19
- close: () => unmountLightbox(url),
20
- updateStyles,
21
- hideCloseButton,
22
- on: (name, callback) => {
23
- lightbox.callbacks[name] = callback;
24
- },
25
- open: () => {
26
- var _a;
27
- if (lightbox.allowRedirects)
28
- redirectBasedOnDriver(url);
29
- mountLightbox({
30
- url,
31
- callbacks: lightbox.callbacks,
32
- styles: lightbox.styles,
33
- closeButtonEnabled: lightbox.closeButton,
34
- enforceStyles: (_a = options === null || options === void 0 ? void 0 : options.enforceStyles) !== null && _a !== void 0 ? _a : false,
35
- });
36
- },
37
- };
38
- if (options === null || options === void 0 ? void 0 : options.launch)
39
- lightbox.open();
40
- return lightbox;
41
- };
1
+ import { LightboxEvents as LE } from '../constants';
2
+ import { postMessage, redirectBasedOnDriver } from '../helpers';
3
+ import { mountLightbox, unmountLightbox } from './assemblers';
4
+ export const isInside = () => globalThis.location !== globalThis.parent.location;
5
+ export const updateStyles = (styles) => postMessage(LE.UPDATE_STYLES, styles);
6
+ export const hideCloseButton = () => postMessage(LE.HIDE_CLOSE_BUTTON);
7
+ export const emitClose = (payload, preventClose) => {
8
+ postMessage(LE.CLOSE, payload, preventClose);
9
+ };
10
+ export const emit = ({ type, payload, preventClose }) => postMessage(type, payload, preventClose);
11
+ export const createLightbox = (url, options) => {
12
+ var _a, _b, _c, _d, _e, _f;
13
+ const lightbox = {
14
+ id: (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : new URL(url).origin,
15
+ element: (_b = options === null || options === void 0 ? void 0 : options.element) !== null && _b !== void 0 ? _b : document.body,
16
+ allowRedirects: (_c = options === null || options === void 0 ? void 0 : options.allowRedirects) !== null && _c !== void 0 ? _c : true,
17
+ callbacks: (_d = options === null || options === void 0 ? void 0 : options.callbacks) !== null && _d !== void 0 ? _d : {},
18
+ closeButton: (_e = options === null || options === void 0 ? void 0 : options.closeButton) !== null && _e !== void 0 ? _e : true,
19
+ styles: (_f = options === null || options === void 0 ? void 0 : options.styles) !== null && _f !== void 0 ? _f : {},
20
+ url: url,
21
+ close: () => unmountLightbox(url),
22
+ updateStyles,
23
+ hideCloseButton,
24
+ on: (name, callback) => {
25
+ lightbox.callbacks[name] = callback;
26
+ },
27
+ open: () => {
28
+ var _a;
29
+ if (lightbox.allowRedirects)
30
+ redirectBasedOnDriver(url);
31
+ mountLightbox({
32
+ id: lightbox.id,
33
+ url,
34
+ element: lightbox.element,
35
+ callbacks: lightbox.callbacks,
36
+ styles: lightbox.styles,
37
+ closeButtonEnabled: lightbox.closeButton,
38
+ enforceStyles: (_a = options === null || options === void 0 ? void 0 : options.enforceStyles) !== null && _a !== void 0 ? _a : false,
39
+ });
40
+ },
41
+ };
42
+ if (options === null || options === void 0 ? void 0 : options.launch)
43
+ lightbox.open();
44
+ return lightbox;
45
+ };
package/dist/helpers.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const postMessage: (type: string, payload?: unknown, preventClose?: boolean) => void;
2
- export declare const setStyle: (name: string, value: string) => void;
3
- export declare const unsetStyle: (name: string) => void;
4
- export declare const redirectBasedOnDriver: (url: string) => void;
1
+ export declare const postMessage: (type: string, payload?: unknown, preventClose?: boolean) => void;
2
+ export declare const setStyle: (name: string, value: string) => void;
3
+ export declare const unsetStyle: (name: string) => void;
4
+ export declare const redirectBasedOnDriver: (url: string) => void;
package/dist/helpers.js CHANGED
@@ -1,19 +1,19 @@
1
- export const postMessage = (type, payload, preventClose) => {
2
- return globalThis.parent.postMessage({ type, preventClose, payload }, '*');
3
- };
4
- export const setStyle = (name, value) => {
5
- document.documentElement.style.setProperty(name, value);
6
- };
7
- export const unsetStyle = (name) => {
8
- document.documentElement.style.removeProperty(name);
9
- };
10
- export const redirectBasedOnDriver = (url) => {
11
- if (navigator.userAgent.match(/iPhone|iPad|iPod/i) ||
12
- /^((?!chrome|android).)*safari/i.test(navigator.userAgent) // regex from https://stackoverflow.com/a/23522755
13
- ) {
14
- if (window.self !== window.top) {
15
- window.parent.postMessage({ type: "placetopay-lightbox:redirect", url }, "*"); // dont change this, it would be a broken change
16
- }
17
- location.href = url;
18
- }
19
- };
1
+ export const postMessage = (type, payload, preventClose) => {
2
+ return globalThis.parent.postMessage({ type, preventClose, payload }, '*');
3
+ };
4
+ export const setStyle = (name, value) => {
5
+ document.documentElement.style.setProperty(name, value);
6
+ };
7
+ export const unsetStyle = (name) => {
8
+ document.documentElement.style.removeProperty(name);
9
+ };
10
+ export const redirectBasedOnDriver = (url) => {
11
+ if (navigator.userAgent.match(/iPhone|iPad|iPod/i) ||
12
+ /^((?!chrome|android).)*safari/i.test(navigator.userAgent) // regex from https://stackoverflow.com/a/23522755
13
+ ) {
14
+ if (window.self !== window.top) {
15
+ window.parent.postMessage({ type: "placetopay-lightbox:redirect", url }, "*"); // dont change this, it would be a broken change
16
+ }
17
+ location.href = url;
18
+ }
19
+ };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './core';
2
- export * from './types';
1
+ export * from './core';
2
+ export * from './types';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './core';
2
- export * from './types';
1
+ export * from './core';
2
+ export * from './types';
package/dist/styles.css CHANGED
@@ -1,13 +1,13 @@
1
1
  .placetopay_lightbox_wrapper {
2
2
  background: var(--placetopay-lightbox-backdrop-color);
3
- position: fixed;
3
+ position: var(--placetopay-lightbox-position);
4
4
  display: flex;
5
5
  justify-content: center;
6
6
  align-items: center;
7
7
  top: 0;
8
8
  left: 0;
9
- width: 100vw;
10
- height: 100vh;
9
+ width: var(--placetopay-lightbox-wrapper-width);
10
+ height: var(--placetopay-lightbox-wrapper-height);
11
11
  z-index: 999;
12
12
  user-select: none;
13
13
  }
package/dist/types.d.ts CHANGED
@@ -1,46 +1,54 @@
1
- export declare type ClientCallback = (payload?: unknown) => void;
2
- export declare type ClientCallbacks = Record<string, ClientCallback | undefined>;
3
- export declare type LightboxStyles = Partial<{
4
- backdropColor: string;
5
- backdropOpacity: number;
6
- height: string | number;
7
- width: string | number;
8
- radius: number;
9
- }>;
10
- export declare type ApiStructure = {
11
- type: string;
12
- payload?: unknown;
13
- preventClose?: boolean;
14
- };
15
- export declare type InternalOptions = Partial<{
16
- launch: boolean;
17
- enforceStyles: boolean;
18
- }>;
19
- export declare type ExposedOptions = Partial<{
20
- allowRedirects: boolean;
21
- callbacks: ClientCallbacks;
22
- closeButton: boolean;
23
- styles: LightboxStyles;
24
- }>;
25
- export declare type InitialOptions = ExposedOptions & InternalOptions;
26
- export declare type MountLightboxOptions = {
27
- url: string;
28
- callbacks: ClientCallbacks;
29
- styles: LightboxStyles;
30
- closeButtonEnabled: boolean;
31
- enforceStyles: boolean;
32
- };
33
- export declare type MountListenerOptions = {
34
- callbacks: ClientCallbacks;
35
- styles: LightboxStyles;
36
- closeButton: HTMLButtonElement;
37
- enforceStyles: boolean;
38
- };
39
- export declare type LightboxInstance = Required<ExposedOptions> & {
40
- url: string;
41
- on: (name: string, callback: ClientCallback) => void;
42
- open: () => void;
43
- close: (payload?: unknown) => void;
44
- updateStyles: (styles: LightboxStyles) => void;
45
- hideCloseButton: () => void;
46
- };
1
+ export type ClientCallback = (payload?: unknown) => void;
2
+ export type ClientCallbacks = Record<string, ClientCallback | undefined>;
3
+ export type LightboxStyles = Partial<{
4
+ backdropColor: string;
5
+ backdropOpacity: number;
6
+ height: string | number;
7
+ width: string | number;
8
+ radius: number;
9
+ position: 'absolute' | 'fixed';
10
+ wrapperWidth: string | number;
11
+ wrapperHeight: string | number;
12
+ }>;
13
+ export type ApiStructure = {
14
+ type: string;
15
+ payload?: unknown;
16
+ preventClose?: boolean;
17
+ };
18
+ export type InternalOptions = Partial<{
19
+ launch: boolean;
20
+ enforceStyles: boolean;
21
+ }>;
22
+ export type ExposedOptions = Partial<{
23
+ id: string;
24
+ element: HTMLElement;
25
+ allowRedirects: boolean;
26
+ callbacks: ClientCallbacks;
27
+ closeButton: boolean;
28
+ styles: LightboxStyles;
29
+ }>;
30
+ export type InitialOptions = ExposedOptions & InternalOptions;
31
+ export type MountLightboxOptions = {
32
+ id: string;
33
+ url: string;
34
+ element: HTMLElement;
35
+ callbacks: ClientCallbacks;
36
+ styles: LightboxStyles;
37
+ closeButtonEnabled: boolean;
38
+ enforceStyles: boolean;
39
+ };
40
+ export type MountListenerOptions = {
41
+ id: string;
42
+ callbacks: ClientCallbacks;
43
+ styles: LightboxStyles;
44
+ closeButton: HTMLButtonElement;
45
+ enforceStyles: boolean;
46
+ };
47
+ export type LightboxInstance = Required<ExposedOptions> & {
48
+ url: string;
49
+ on: (name: string, callback: ClientCallback) => void;
50
+ open: () => void;
51
+ close: (payload?: unknown) => void;
52
+ updateStyles: (styles: LightboxStyles) => void;
53
+ hideCloseButton: () => void;
54
+ };
package/dist/types.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@placetopay/lightbox-sdk",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Small javascript library to encapsulate websites in a lightbox with configurable styles and behaviors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",