!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={8779:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},8213:e=>{e.exports=require("@babel/runtime/helpers/extends")},3838:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},6689:e=>{e.exports=require("react")},9231:e=>{e.exports=require("react-rte")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var o={};return(()=>{r.r(o),r.d(o,{default:()=>h});var e=r(8213),t=r.n(e),n=r(3838),i=r.n(n),a=r(8779),s=r.n(a),u=r(6689),l=r.n(u);const p=["onChange","value","error","className","id"];function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){s()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class h extends l().Component{constructor(e){var t;super(e),this.RichTextEditor=null,"undefined"!=typeof window&&(this.RichTextEditor=r(9231).default),this.state={editorValue:null===(t=this.RichTextEditor)||void 0===t?void 0:t.createEmptyValue(),currentValue:null},this.handleChange=this.handleChange.bind(this)}static getDerivedStateFromProps(e,t){const{value:r}=e,{editorValue:o,currentValue:n}=t;return null!=n&&r===n?t:d(d({},t),{},{editorValue:o.setContentFromString(r,"html"),currentValue:r})}handleChange(e){let t=this.state.editorValue;if(this.setState({editorValue:e}),(t?t.getEditorState().getCurrentContent():null)!==e.getEditorState().getCurrentContent()){let t=e.toString("html");if(t="<p><br></p>"===t?"":t,this.setState({currentValue:t}),t!==this.props.value){let e={target:{id:this.props.id,value:t,type:"texteditor"}};this.props.onChange(e)}}}render(){let e=this.props,{onChange:r,value:o,error:n,className:a,id:s}=e,u=i()(e,p),c=this.props.hasOwnProperty("error")&&""!==n;return l().createElement("div",null,this.RichTextEditor&&l().createElement(this.RichTextEditor,t()({id:s,className:a+" "+(c?"error":""),value:this.state.editorValue,onChange:this.handleChange},u)),c&&l().createElement("p",{className:"error-label"},n))}}})(),o})()));
//# sourceMappingURL=editor-input.js.map