UNPKG

activator-oce-exporter

Version:

Extract Activator binder and convert it to valid OCE mono pacakge

50 lines (43 loc) 1.43 kB
import { getValueObject } from '../utils'; export function EmailComponent(superClass) { return class extends superClass { static getStyle(top = 0, left = 0) { const styleRoot = super.getStyle(top, left); return ` ${styleRoot} :host { position: relative; box-sizing: border-box; }`; } static shouldWidthUpdate(width, value) { // @todo jQuery sortable sets null to width on drag const isValidValue = value && value !== 'null'; return width && isValidValue; } getParentWidth() { if (this.parentNode && this.parentNode.width) { return getValueObject(this.parentNode.width).num; } return 0; } updateWidth(value = this.width) { if (this.constructor.shouldWidthUpdate(this.constructor.properties.width, value)) { const { num, unit } = getValueObject(value); const parentWidth = this.getParentWidth(); const widthValue = Math.min(num, parentWidth); this.style.setProperty('--width', `${widthValue}${unit}`); } } firstUpdated(changedProperties) { super.firstUpdated(changedProperties); this.updateWidth(); } update(changedProperties) { super.update(changedProperties); if (changedProperties.has('width')) { this.updateWidth(this.width); } } }; }