smart-webcomponents
Version:
Web Components & Custom Elements for Professional Web Applications
2 lines • 7.2 kB
JavaScript
/*! For license information please see smart.ui.ribbongroup.js.LICENSE.txt */
(()=>{"use strict";class t extends HTMLElement{get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get label(){return this.nativeElement?this.nativeElement.label:void 0}set label(t){if(this.nativeElement){this.nativeElement.label=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("label");this.nativeElement.hasAttribute("label")?this.setAttribute("label",e):this.removeAttribute("label"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get icon(){return this.nativeElement?this.nativeElement.icon:void 0}set icon(t){if(this.nativeElement){this.nativeElement.icon=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("icon");this.nativeElement.hasAttribute("icon")?this.setAttribute("icon",e):this.removeAttribute("icon"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get cssClass(){return this.nativeElement?this.nativeElement.cssClass:void 0}set cssClass(t){if(this.nativeElement){this.nativeElement.cssClass=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("css-class");this.nativeElement.hasAttribute("css-class")?this.setAttribute("css-class",e):this.removeAttribute("css-class"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get ribbonItems(){return this.nativeElement?this.nativeElement.ribbonItems:void 0}set ribbonItems(t){if(this.nativeElement){this.nativeElement.ribbonItems=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("ribbon-items");this.nativeElement.hasAttribute("ribbon-items")?this.setAttribute("ribbon-items",e):this.removeAttribute("ribbon-items"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get direction(){return this.nativeElement?this.nativeElement.direction:void 0}set direction(t){if(this.nativeElement){this.nativeElement.direction=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("direction");this.nativeElement.hasAttribute("direction")?this.setAttribute("direction",e):this.removeAttribute("direction"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get dialogLauncher(){return this.nativeElement?this.nativeElement.dialogLauncher:void 0}set dialogLauncher(t){if(this.nativeElement){this.nativeElement.dialogLauncher=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("dialog-launcher");this.nativeElement.hasAttribute("dialog-launcher")?this.setAttribute("dialog-launcher",e):this.removeAttribute("dialog-launcher"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get wrapSize(){return this.nativeElement?this.nativeElement.wrapSize:void 0}set wrapSize(t){if(this.nativeElement){this.nativeElement.wrapSize=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("wrap-size");this.nativeElement.hasAttribute("wrap-size")?this.setAttribute("wrap-size",e):this.removeAttribute("wrap-size"),this._isUpdatingAttribute=!1}}static get observedAttributes(){return["style","class","label","icon","css-class","ribbon-items","direction","dialog-launcher","wrap-size"]}get properties(){return["label","icon","cssClass","ribbonItems","direction","dialogLauncher","wrapSize"]}constructor(){super()}get eventListeners(){return[]}componentDidRender(t){const e=this,i={},n={};let s=null;for(let t in e.props)"children"!==t&&("style"!==t?t.startsWith("on")&&-1===e.properties.indexOf(t)?n[t]=e.props[t]:i[t]=e.props[t]:s=e.props[t]);for(let t in e.attributes){const i=e.attributes[t].name;if(i)if("class"!==i)"style"===i&&e.nativeElement.setAttribute(i,e.getAttribute(i)),-1!==e.properties.indexOf(i.replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()})))&&e.nativeElement.setAttribute(i,e.getAttribute(i));else{const t=e.getAttribute(i).trim().split(" ");for(let i in t)e.nativeElement.classList.contains(t[i])||""===t[i]||e.nativeElement.classList.add(t[i])}}for(let t in i)if("class"!==t&&"className"!==t){if(i[t]!==e.nativeElement[t]){const n=t=>t.replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()}));"hover"!==t&&"active"!==t&&"focus"!==t&&"selected"!==t||e.nativeElement.setAttribute(t,"");const s=n(t);e.nativeElement[s]=i[t]}}else{const n=i[t].trim().split(" ");for(let t in n)e.nativeElement.classList.contains(n[t])||""===n[t]||e.nativeElement.classList.add(n[t])}for(let t in n)e[t]=n[t],e.nativeElement[t.toLowerCase()]=n[t];if(s)for(let t in s)e.nativeElement.style[t]=s[t]}componentDidMount(){this.componentDidRender(!0)}componentDidUpdate(){this.componentDidRender(!1)}componentWillUnmount(){const t=this;if(t.nativeElement){t.nativeElement.whenRenderedCallbacks=[];for(let e=0;e<t.eventListeners.length;e++){const i=t.eventListeners[e];t.nativeElement.removeEventListener(i.substring(2).toLowerCase(),t[i])}}}connectedCallback(){this.shadowRoot||this._render()}disconnectedCallback(){this.componentWillUnmount()}addStylesToElement(t,e){const i=document.createElement("style");i.type="text/css";for(let t=0;t<e.length;t++){let n=document.createTextNode(e[t]);n.textContent=n.textContent.replace(":root",":host"),i.appendChild(n)}if(document.adoptedStyleSheets){const e=new CSSStyleSheet;e.replaceSync(i.innerHTML),t.adoptedStyleSheets?t.adoptedStyleSheets=[...t.adoptedStyleSheets,e]:-1===document.adoptedStyleSheets.indexOf(e)&&(document.adoptedStyleSheets=[...document.adoptedStyleSheets,e])}else t.appendChild(i)}addStyle(t){const e=this.shadowRoot;if("string"==typeof t){const i=document.createElement("style");i.type="text/css";const n=document.createTextNode(t);i.appendChild(n),e.appendChild(i)}else e.appendChild(t)}attributeChangedCallback(t,e,i){const n=this;if(n.shadowRoot&&n.isReady&&!n._isUpdatingAttribute)if("class"!==t)n.nativeElement.setAttribute(t,i);else{const t=i.trim().split(" "),s=e.trim().split(" ");for(let t in s)""!==s[t]&&n.nativeElement.classList.remove(s[t]);for(let e in t)n.nativeElement.classList.contains(t[e])||""===t[e]||n.nativeElement.classList.add(t[e])}}_render(){const t=this;if(t.parentNode){const e=document.createElement("smart-ribbon-group");t.parentNode?t.parentNode.replaceChild(e,t):t.getRootNode().host.shadowRoot.replaceChild(e,t),t.nativeElement=e,t.componentDidMount(),t.isReady=!0,t.classList.add("smart-ui-component")}}}window.customElements.get("smart-ui-ribbon-group")||window.customElements.define("smart-ui-ribbon-group",t)})();