@aplazame/browser
Advanced tools
Comparing version 0.1.16 to 0.1.17
import { EventEmitter, DetailsEvent } from './EventEmitter.js'; | ||
import { type ApzStyles, type ApzAttributes } from './types.js'; | ||
export declare class AplazameEvent extends DetailsEvent { | ||
@@ -14,9 +15,4 @@ } | ||
iframe?: HTMLIFrameElement; | ||
currentStyles: { | ||
[key: string]: unknown; | ||
important?: Record<string, string>; | ||
}; | ||
currentAttributes: { | ||
[key: string]: string; | ||
}; | ||
currentStyles: ApzStyles; | ||
currentAttributes: ApzAttributes; | ||
constructor({ url, searchParams, requestTimeout, allowFilter, sendData }?: { | ||
@@ -39,19 +35,5 @@ url?: string | null; | ||
mount(el: HTMLElement): this; | ||
addStylesPreset(name: string, styles: { | ||
[key: string]: string; | ||
}): this; | ||
setStyles(styles?: { | ||
[key: string]: unknown; | ||
important?: Record<string, string>; | ||
} | string): this; | ||
applyStyles(styles?: { | ||
[key: string]: unknown; | ||
important?: Record<string, string> | undefined; | ||
}): this; | ||
setAttributes(attributes: { | ||
[key: string]: string; | ||
}): this; | ||
applyAttributes(attributes?: { | ||
[key: string]: string; | ||
}): this; | ||
addStylesPreset(name: string, styles: ApzStyles): this; | ||
setStyles(styles?: ApzStyles | string): this; | ||
setAttributes(attributes: ApzAttributes): this; | ||
resetStyles(): this; | ||
@@ -58,0 +40,0 @@ resetAttributes(): void; |
@@ -14,2 +14,3 @@ "use strict"; | ||
const EventEmitter_js_1 = require("./EventEmitter.js"); | ||
const dom_helpers_1 = require("./helpers/dom.helpers"); | ||
const copyObject = (obj) => JSON.parse(JSON.stringify(obj)); | ||
@@ -95,4 +96,4 @@ class AplazameEvent extends EventEmitter_js_1.DetailsEvent { | ||
this.iframe.src = this.url.toString(); | ||
this.applyStyles(); | ||
this.applyAttributes(); | ||
(0, dom_helpers_1.applyStylesToEl)(this.iframe, this.currentStyles); | ||
(0, dom_helpers_1.applyAttributesToEl)(this.iframe, this.currentAttributes); | ||
el.appendChild(this.iframe); | ||
@@ -115,40 +116,12 @@ // listening messages | ||
this.currentStyles = Object.assign(Object.assign(Object.assign({}, this.currentStyles), newSytles), { important: Object.assign(Object.assign({}, this.currentStyles.important), newSytles.important) }); | ||
this.applyStyles(); | ||
if (this.iframe) | ||
(0, dom_helpers_1.applyStylesToEl)(this.iframe, this.currentStyles); | ||
return this; | ||
} | ||
applyStyles(styles = this.currentStyles) { | ||
const iframe = this.iframe; | ||
if (iframe) { | ||
Object.keys(styles).forEach(key => { | ||
if (key === 'important') { | ||
for (const key in styles.important) { | ||
iframe.style.setProperty(key, String(styles.important[key]), 'important'); | ||
} | ||
return; | ||
} | ||
if (styles[key] === null) | ||
iframe.style.removeProperty(key); | ||
else | ||
iframe.style.setProperty(key, String(styles[key])); | ||
}); | ||
} | ||
return this; | ||
} | ||
setAttributes(attributes) { | ||
this.currentAttributes = Object.assign(Object.assign({}, this.currentAttributes), attributes); | ||
this.applyAttributes(); | ||
if (this.iframe) | ||
(0, dom_helpers_1.applyAttributesToEl)(this.iframe, this.currentAttributes); | ||
return this; | ||
} | ||
applyAttributes(attributes = this.currentAttributes) { | ||
const iframe = this.iframe; | ||
if (iframe) { | ||
for (const key in attributes) { | ||
if (attributes[key] === null) | ||
iframe.removeAttribute(key); | ||
else | ||
iframe.setAttribute(key, attributes[key]); | ||
} | ||
} | ||
return this; | ||
} | ||
resetStyles() { | ||
@@ -155,0 +128,0 @@ var _a; |
import { EventEmitter, DetailsEvent } from './EventEmitter'; | ||
import { AplazameIFrame } from './AplazameIFrame'; | ||
import { PostMessageHandler } from './PostMessageHandler'; | ||
export { DetailsEvent, EventEmitter, AplazameIFrame, PostMessageHandler, }; | ||
import { type ApzStyles, type ApzAttributes } from './types.js'; | ||
export { DetailsEvent, EventEmitter, AplazameIFrame, PostMessageHandler, ApzStyles, ApzAttributes, }; |
{ | ||
"name": "@aplazame/browser", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"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
24108
18
527