smart-webcomponents
Version:
Web Components & Custom Elements for Professional Web Applications
2 lines • 9.27 kB
JavaScript
/*! For license information please see smart.ui.listitem.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 alternationIndex(){return this.nativeElement?this.nativeElement.alternationIndex:void 0}set alternationIndex(t){if(this.nativeElement){this.nativeElement.alternationIndex=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("alternation-index");this.nativeElement.hasAttribute("alternation-index")?this.setAttribute("alternation-index",e):this.removeAttribute("alternation-index"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get color(){return this.nativeElement?this.nativeElement.color:void 0}set color(t){if(this.nativeElement){this.nativeElement.color=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("color");this.nativeElement.hasAttribute("color")?this.setAttribute("color",e):this.removeAttribute("color"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get displayMode(){return this.nativeElement?this.nativeElement.displayMode:void 0}set displayMode(t){if(this.nativeElement){this.nativeElement.displayMode=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("display-mode");this.nativeElement.hasAttribute("display-mode")?this.setAttribute("display-mode",e):this.removeAttribute("display-mode"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get grouped(){return this.nativeElement?this.nativeElement.grouped:void 0}set grouped(t){if(this.nativeElement){this.nativeElement.grouped=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("grouped");this.nativeElement.hasAttribute("grouped")?this.setAttribute("grouped",e):this.removeAttribute("grouped"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get selected(){return this.nativeElement?this.nativeElement.selected:void 0}set selected(t){if(this.nativeElement){this.nativeElement.selected=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("selected");this.nativeElement.hasAttribute("selected")?this.setAttribute("selected",e):this.removeAttribute("selected"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get value(){return this.nativeElement?this.nativeElement.value:void 0}set value(t){if(this.nativeElement){this.nativeElement.value=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("value");this.nativeElement.hasAttribute("value")?this.setAttribute("value",e):this.removeAttribute("value"),this._isUpdatingAttribute=!1}}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 details(){return this.nativeElement?this.nativeElement.details:void 0}set details(t){if(this.nativeElement){this.nativeElement.details=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("details");this.nativeElement.hasAttribute("details")?this.setAttribute("details",e):this.removeAttribute("details"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get group(){return this.nativeElement?this.nativeElement.group:void 0}set group(t){if(this.nativeElement){this.nativeElement.group=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("group");this.nativeElement.hasAttribute("group")?this.setAttribute("group",e):this.removeAttribute("group"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get hidden(){return this.nativeElement?this.nativeElement.hidden:void 0}set hidden(t){if(this.nativeElement){this.nativeElement.hidden=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("hidden");this.nativeElement.hasAttribute("hidden")?this.setAttribute("hidden",e):this.removeAttribute("hidden"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get readonly(){return this.nativeElement?this.nativeElement.readonly:void 0}set readonly(t){if(this.nativeElement){this.nativeElement.readonly=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("readonly");this.nativeElement.hasAttribute("readonly")?this.setAttribute("readonly",e):this.removeAttribute("readonly"),this._isUpdatingAttribute=!1}}static get observedAttributes(){return["style","class","alternation-index","color","display-mode","grouped","selected","value","label","details","group","hidden","readonly"]}get properties(){return["alternationIndex","color","displayMode","grouped","selected","value","label","details","group","hidden","readonly"]}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-list-item");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-list-item")||window.customElements.define("smart-ui-list-item",t)})();