@aplazame/browser
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -10,2 +10,3 @@ import { EventEmitter, DetailsEvent } from './EventEmitter.js'; | ||
requestTimeout: number; | ||
iframeStylesPresets: any; | ||
url: URL; | ||
@@ -34,2 +35,5 @@ mount_el?: HTMLElement; | ||
mount(el: HTMLElement): this; | ||
addStylesPreset(name: string, styles: { | ||
[key: string]: string; | ||
}): this; | ||
setStyles(styles: string | { | ||
@@ -36,0 +40,0 @@ [key: string]: string; |
@@ -18,3 +18,3 @@ "use strict"; | ||
exports.AplazameEvent = AplazameEvent; | ||
const iframeStylesPresets = { | ||
const defaulsIframeStylesPresets = { | ||
fill_fixed: { | ||
@@ -43,2 +43,3 @@ position: 'fixed', | ||
this.requestTimeout = 60000; | ||
this.iframeStylesPresets = copyObject(defaulsIframeStylesPresets); | ||
this.currentStyles = {}; | ||
@@ -102,6 +103,10 @@ if (!url) | ||
} | ||
addStylesPreset(name, styles) { | ||
this.iframeStylesPresets[name] = styles; | ||
return this; | ||
} | ||
setStyles(styles) { | ||
var _a; | ||
const newSytles = typeof styles === 'string' | ||
? ((_a = iframeStylesPresets[styles]) !== null && _a !== void 0 ? _a : {}) | ||
? ((_a = this.iframeStylesPresets[styles]) !== null && _a !== void 0 ? _a : {}) | ||
: styles; | ||
@@ -108,0 +113,0 @@ this.currentStyles = Object.assign(Object.assign({}, this.currentStyles), newSytles); |
import { EventEmitter, DetailsEvent } from './EventEmitter'; | ||
import { AplazameIFrame } from './AplazameIFrame'; | ||
export { DetailsEvent, EventEmitter, AplazameIFrame, }; | ||
import { PostMessageHandler } from './PostMessageHandler'; | ||
export { DetailsEvent, EventEmitter, AplazameIFrame, PostMessageHandler, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AplazameIFrame = exports.EventEmitter = exports.DetailsEvent = void 0; | ||
exports.PostMessageHandler = exports.AplazameIFrame = exports.EventEmitter = exports.DetailsEvent = void 0; | ||
const EventEmitter_1 = require("./EventEmitter"); | ||
@@ -9,1 +9,3 @@ Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return EventEmitter_1.EventEmitter; } }); | ||
Object.defineProperty(exports, "AplazameIFrame", { enumerable: true, get: function () { return AplazameIFrame_1.AplazameIFrame; } }); | ||
const PostMessageHandler_1 = require("./PostMessageHandler"); | ||
Object.defineProperty(exports, "PostMessageHandler", { enumerable: true, get: function () { return PostMessageHandler_1.PostMessageHandler; } }); |
{ | ||
"name": "@aplazame/browser", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Aplazame SDK for browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -29,2 +29,63 @@ # browser-sdk | ||
} | ||
``` | ||
### AplazameIFrame object | ||
> constructor | ||
``` js | ||
const apzIframe = new AplazameIFrame({ | ||
url, | ||
searchParams, | ||
}) | ||
``` | ||
> methods | ||
``` ts | ||
apzIframe.send(event: string, payload: unknown) | ||
// received by the iframe as MessageEvent<{ data: { event, payload } }> | ||
apzIframe.request(request: string, payload: unknown) | ||
// received by the iframe as MessageEvent<{ data: { request, payload } }> | ||
apzIframe.mount(el: HTMLElement) | ||
// iframe is created and attached to el when calling this method | ||
apzIframe.setStyles(styles: string | { [key: string]: string }) | ||
// applies styles to iframe DOM Element | ||
// when styles is a string, it refers to a preset | ||
// otherwise applies styles key by key | ||
apzIframe.addStylesPreset(name: string, styles: { [key: string]: string }) | ||
// Adds a new preset to presets | ||
apzIframe.resetStyles() | ||
// clears all styles applied to the iframe | ||
apzIframe.unmount() | ||
// removes iframe from DOM tree and emits 'unmount' event | ||
``` | ||
> default styles presets | ||
``` js | ||
const defaulsIframeStylesPresets: { | ||
fill_fixed: { | ||
position: 'fixed', | ||
top: '0', | ||
left: '0', | ||
width: '100%', | ||
height: '100%', | ||
border: 'none', | ||
}, | ||
fill_absolute: { | ||
position: 'absolute', | ||
top: '0', | ||
left: '0', | ||
width: '100%', | ||
height: '100%', | ||
border: 'none', | ||
}, | ||
} | ||
``` |
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
21390
12
466
90