@aplazame/browser
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -13,2 +13,5 @@ import { EventEmitter, DetailsEvent } from './EventEmitter.js'; | ||
iframe?: HTMLIFrameElement; | ||
currentStyles: { | ||
[key: string]: string; | ||
}; | ||
constructor({ url, searchParams, requestTimeout, allowFilter, sendData }?: { | ||
@@ -31,3 +34,7 @@ url?: string | null; | ||
mount(el: HTMLElement): this; | ||
setStyles(styles: string | { | ||
[key: string]: string; | ||
}): this; | ||
resetStyles(): this; | ||
unmount(): void; | ||
} |
@@ -18,2 +18,21 @@ "use strict"; | ||
exports.AplazameEvent = AplazameEvent; | ||
const iframeStylesPresets = { | ||
fullscreen: { | ||
position: 'fixed', | ||
top: '0', | ||
left: '0', | ||
width: '100%', | ||
height: '100%', | ||
border: 'none', | ||
zIndex: '9999' | ||
}, | ||
fill_absolute: { | ||
position: 'absolute', | ||
top: '0', | ||
left: '0', | ||
width: '100%', | ||
height: '100%', | ||
border: 'none', | ||
}, | ||
}; | ||
class AplazameIFrame extends EventEmitter_js_1.EventEmitter { | ||
@@ -25,2 +44,3 @@ constructor({ url = null, searchParams = null, requestTimeout = null, allowFilter = null, sendData = null } = {}) { | ||
this.requestTimeout = 60000; | ||
this.currentStyles = {}; | ||
if (!url) | ||
@@ -75,2 +95,3 @@ throw new Error('url is required'); | ||
this.iframe.src = this.url.toString(); | ||
Object.assign(this.iframe.style, this.currentStyles); | ||
el.appendChild(this.iframe); | ||
@@ -83,2 +104,22 @@ // listening messages | ||
} | ||
setStyles(styles) { | ||
var _a; | ||
const newSytles = typeof styles === 'string' | ||
? ((_a = iframeStylesPresets[styles]) !== null && _a !== void 0 ? _a : {}) | ||
: styles; | ||
this.currentStyles = Object.assign(Object.assign({}, this.currentStyles), newSytles); | ||
if (this.iframe) { | ||
Object.assign(this.iframe.style, this.currentStyles); | ||
} | ||
return this; | ||
} | ||
resetStyles() { | ||
var _a; | ||
this.currentStyles = {}; | ||
const style = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.style; | ||
if (style === null || style === void 0 ? void 0 : style.length) { | ||
Array.from(style).forEach(key => style.removeProperty(key)); | ||
} | ||
return this; | ||
} | ||
unmount() { | ||
@@ -85,0 +126,0 @@ var _a; |
{ | ||
"name": "@aplazame/browser", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Aplazame SDK for browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16018
369