smart-webcomponents
Version:
Web Components & Custom Elements for Professional Web Applications
2 lines • 19.6 kB
JavaScript
/*! For license information please see smart.ui.formcontrol.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 action(){return this.nativeElement?this.nativeElement.action:void 0}set action(t){if(this.nativeElement){this.nativeElement.action=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("action");this.nativeElement.hasAttribute("action")?this.setAttribute("action",e):this.removeAttribute("action"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get align(){return this.nativeElement?this.nativeElement.align:void 0}set align(t){if(this.nativeElement){this.nativeElement.align=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("align");this.nativeElement.hasAttribute("align")?this.setAttribute("align",e):this.removeAttribute("align"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get appendHTML(){return this.nativeElement?this.nativeElement.appendHTML:void 0}set appendHTML(t){if(this.nativeElement){this.nativeElement.appendHTML=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("append-h-t-m-l");this.nativeElement.hasAttribute("append-h-t-m-l")?this.setAttribute("append-h-t-m-l",e):this.removeAttribute("append-h-t-m-l"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get controlOptions(){return this.nativeElement?this.nativeElement.controlOptions:void 0}set controlOptions(t){if(this.nativeElement){this.nativeElement.controlOptions=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("control-options");this.nativeElement.hasAttribute("control-options")?this.setAttribute("control-options",e):this.removeAttribute("control-options"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get controlType(){return this.nativeElement?this.nativeElement.controlType:void 0}set controlType(t){if(this.nativeElement){this.nativeElement.controlType=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("control-type");this.nativeElement.hasAttribute("control-type")?this.setAttribute("control-type",e):this.removeAttribute("control-type"),this._isUpdatingAttribute=!1}}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 columnSpan(){return this.nativeElement?this.nativeElement.columnSpan:void 0}set columnSpan(t){if(this.nativeElement){this.nativeElement.columnSpan=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("column-span");this.nativeElement.hasAttribute("column-span")?this.setAttribute("column-span",e):this.removeAttribute("column-span"),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 disabled(){return this.nativeElement?this.nativeElement.disabled:void 0}set disabled(t){if(this.nativeElement){this.nativeElement.disabled=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("disabled");this.nativeElement.hasAttribute("disabled")?this.setAttribute("disabled",e):this.removeAttribute("disabled"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get dirty(){return this.nativeElement?this.nativeElement.dirty:void 0}set dirty(t){if(this.nativeElement){this.nativeElement.dirty=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("dirty");this.nativeElement.hasAttribute("dirty")?this.setAttribute("dirty",e):this.removeAttribute("dirty"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get info(){return this.nativeElement?this.nativeElement.info:void 0}set info(t){if(this.nativeElement){this.nativeElement.info=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("info");this.nativeElement.hasAttribute("info")?this.setAttribute("info",e):this.removeAttribute("info"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get invalid(){return this.nativeElement?this.nativeElement.invalid:void 0}set invalid(t){if(this.nativeElement){this.nativeElement.invalid=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("invalid");this.nativeElement.hasAttribute("invalid")?this.setAttribute("invalid",e):this.removeAttribute("invalid"),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 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 labelOffset(){return this.nativeElement?this.nativeElement.labelOffset:void 0}set labelOffset(t){if(this.nativeElement){this.nativeElement.labelOffset=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("label-offset");this.nativeElement.hasAttribute("label-offset")?this.setAttribute("label-offset",e):this.removeAttribute("label-offset"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get labelAlign(){return this.nativeElement?this.nativeElement.labelAlign:void 0}set labelAlign(t){if(this.nativeElement){this.nativeElement.labelAlign=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("label-align");this.nativeElement.hasAttribute("label-align")?this.setAttribute("label-align",e):this.removeAttribute("label-align"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get nextButtonLabel(){return this.nativeElement?this.nativeElement.nextButtonLabel:void 0}set nextButtonLabel(t){if(this.nativeElement){this.nativeElement.nextButtonLabel=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("next-button-label");this.nativeElement.hasAttribute("next-button-label")?this.setAttribute("next-button-label",e):this.removeAttribute("next-button-label"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get backButtonLabel(){return this.nativeElement?this.nativeElement.backButtonLabel:void 0}set backButtonLabel(t){if(this.nativeElement){this.nativeElement.backButtonLabel=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("back-button-label");this.nativeElement.hasAttribute("back-button-label")?this.setAttribute("back-button-label",e):this.removeAttribute("back-button-label"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get placeholder(){return this.nativeElement?this.nativeElement.placeholder:void 0}set placeholder(t){if(this.nativeElement){this.nativeElement.placeholder=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("placeholder");this.nativeElement.hasAttribute("placeholder")?this.setAttribute("placeholder",e):this.removeAttribute("placeholder"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get prependHTML(){return this.nativeElement?this.nativeElement.prependHTML:void 0}set prependHTML(t){if(this.nativeElement){this.nativeElement.prependHTML=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("prepend-h-t-m-l");this.nativeElement.hasAttribute("prepend-h-t-m-l")?this.setAttribute("prepend-h-t-m-l",e):this.removeAttribute("prepend-h-t-m-l"),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 required(){return this.nativeElement?this.nativeElement.required:void 0}set required(t){if(this.nativeElement){this.nativeElement.required=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("required");this.nativeElement.hasAttribute("required")?this.setAttribute("required",e):this.removeAttribute("required"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get untouched(){return this.nativeElement?this.nativeElement.untouched:void 0}set untouched(t){if(this.nativeElement){this.nativeElement.untouched=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("untouched");this.nativeElement.hasAttribute("untouched")?this.setAttribute("untouched",e):this.removeAttribute("untouched"),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 showButtons(){return this.nativeElement?this.nativeElement.showButtons:void 0}set showButtons(t){if(this.nativeElement){this.nativeElement.showButtons=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("show-buttons");this.nativeElement.hasAttribute("show-buttons")?this.setAttribute("show-buttons",e):this.removeAttribute("show-buttons"),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 valid(){return this.nativeElement?this.nativeElement.valid:void 0}set valid(t){if(this.nativeElement){this.nativeElement.valid=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("valid");this.nativeElement.hasAttribute("valid")?this.setAttribute("valid",e):this.removeAttribute("valid"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get validationRules(){return this.nativeElement?this.nativeElement.validationRules:void 0}set validationRules(t){if(this.nativeElement){this.nativeElement.validationRules=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("validation-rules");this.nativeElement.hasAttribute("validation-rules")?this.setAttribute("validation-rules",e):this.removeAttribute("validation-rules"),this._isUpdatingAttribute=!1}}get _isUpdating(){return this.nativeElement?this.nativeElement._isUpdating:void 0}set _isUpdating(t){this.nativeElement&&(this.nativeElement._isUpdating=t)}get viewMode(){return this.nativeElement?this.nativeElement.viewMode:void 0}set viewMode(t){if(this.nativeElement){this.nativeElement.viewMode=t,this._isUpdatingAttribute=!0;const e=this.nativeElement.getAttribute("view-mode");this.nativeElement.hasAttribute("view-mode")?this.setAttribute("view-mode",e):this.removeAttribute("view-mode"),this._isUpdatingAttribute=!1}}static get observedAttributes(){return["style","class","action","align","append-h-t-m-l","control-options","control-type","columns","column-span","data-field","disabled","dirty","info","invalid","label","label-position","label-offset","label-align","next-button-label","back-button-label","placeholder","prepend-h-t-m-l","readonly","required","untouched","show-colon-after-label","show-buttons","value","valid","validation-rules","view-mode"]}get properties(){return["action","align","appendHTML","controlOptions","controlType","columns","columnSpan","dataField","disabled","dirty","info","invalid","label","labelPosition","labelOffset","labelAlign","nextButtonLabel","backButtonLabel","placeholder","prependHTML","readonly","required","untouched","showColonAfterLabel","showButtons","value","valid","validationRules","viewMode"]}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-form-control");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-control")||window.customElements.define("smart-ui-form-control",t)})();