smart-webcomponents
Version:
Web Components & Custom Elements for Professional Web Applications
2 lines • 10.2 kB
JavaScript
/*! For license information please see smart.ui.formgroup.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 columns(){return this.nativeElement?this.nativeElement.columns:void 0}set columns(t){if(this.nativeElement){this.nativeElement.columns=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("columns");this.nativeElement.hasAttribute("columns")?this.setAttribute("columns",e):this.removeAttribute("columns"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get dataField(){return this.nativeElement?this.nativeElement.dataField:void 0}set dataField(t){if(this.nativeElement){this.nativeElement.dataField=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("data-field");this.nativeElement.hasAttribute("data-field")?this.setAttribute("data-field",e):this.removeAttribute("data-field"),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 controls(){return this.nativeElement?this.nativeElement.controls:void 0}set controls(t){if(this.nativeElement){this.nativeElement.controls=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("controls");this.nativeElement.hasAttribute("controls")?this.setAttribute("controls",e):this.removeAttribute("controls"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get onStatusChanges(){return this.nativeElement?this.nativeElement.onStatusChanges:void 0}set onStatusChanges(t){if(this.nativeElement){this.nativeElement.onStatusChanges=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("on-status-changes");this.nativeElement.hasAttribute("on-status-changes")?this.setAttribute("on-status-changes",e):this.removeAttribute("on-status-changes"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get onValueChanges(){return this.nativeElement?this.nativeElement.onValueChanges:void 0}set onValueChanges(t){if(this.nativeElement){this.nativeElement.onValueChanges=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("on-value-changes");this.nativeElement.hasAttribute("on-value-changes")?this.setAttribute("on-value-changes",e):this.removeAttribute("on-value-changes"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get labelPosition(){return this.nativeElement?this.nativeElement.labelPosition:void 0}set labelPosition(t){if(this.nativeElement){this.nativeElement.labelPosition=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("label-position");this.nativeElement.hasAttribute("label-position")?this.setAttribute("label-position",e):this.removeAttribute("label-position"),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}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get showColonAfterLabel(){return this.nativeElement?this.nativeElement.showColonAfterLabel:void 0}set showColonAfterLabel(t){if(this.nativeElement){this.nativeElement.showColonAfterLabel=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("show-colon-after-label");this.nativeElement.hasAttribute("show-colon-after-label")?this.setAttribute("show-colon-after-label",e):this.removeAttribute("show-colon-after-label"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get showSummary(){return this.nativeElement?this.nativeElement.showSummary:void 0}set showSummary(t){if(this.nativeElement){this.nativeElement.showSummary=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("show-summary");this.nativeElement.hasAttribute("show-summary")?this.setAttribute("show-summary",e):this.removeAttribute("show-summary"),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}}static get observedAttributes(){return["style","class","columns","data-field","label","controls","on-status-changes","on-value-changes","label-position","readonly","show-colon-after-label","show-summary","value"]}get properties(){return["columns","dataField","label","controls","onStatusChanges","onValueChanges","labelPosition","readonly","showColonAfterLabel","showSummary","value"]}constructor(){super()}get eventListeners(){return[]}addControl(t){this.nativeElement.isRendered?this.nativeElement.addControl(t):this.nativeElement.whenRendered((()=>{this.nativeElement.addControl(t)}))}async getControl(t){return await(()=>new Promise((e=>{this.nativeElement.whenRendered((()=>{const i=this.nativeElement.getControl(t);e(i)}))})))()}insertControl(t,e){this.nativeElement.isRendered?this.nativeElement.insertControl(t,e):this.nativeElement.whenRendered((()=>{this.nativeElement.insertControl(t,e)}))}removeControl(t){this.nativeElement.isRendered?this.nativeElement.removeControl(t):this.nativeElement.whenRendered((()=>{this.nativeElement.removeControl(t)}))}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-form-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-form-group")||window.customElements.define("smart-ui-form-group",t)})();