!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")},1929:e=>{e.exports=require("react-select")}},t={};function r(a){var l=t[a];if(void 0!==l)return l.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.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 a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{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 a={};return(()=>{r.r(a),r.d(a,{default:()=>v});var e=r(8213),t=r.n(e),l=r(8779),o=r.n(l),n=r(3838),s=r.n(n),u=r(6689),i=r.n(u),p=r(1929),c=r.n(p);const b=["error","label","value","onChange","id","multi","isMulti","className","isDisabled","isClearable","options","selectStyles","customStyle"];function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const y=e=>{let{error:r,label:a,value:l,onChange:o,id:n,multi:p,isMulti:d,className:y,isDisabled:v,isClearable:m,options:g,selectStyles:O,customStyle:h}=e,j=s()(e,b);const[w,S]=(0,u.useState)(l?Array.isArray(l)?{value:"between",label:"Between"}:g.find((e=>e.value===l.replace(/\d/g,""))):{value:null,label:""}),[x,P]=(0,u.useState)(l?Array.isArray(l)?l[0]:l.replace(/\D/g,""):""),[E,C]=(0,u.useState)(Array.isArray(l)?l[1]:""),[D,q]=(0,u.useState)(f({control:(e,t)=>f(f({},e),{},{width:175})},O)),[A,N]=(0,u.useState)(r);(0,u.useEffect)((()=>{N(r)}),[r]);const M=e=>{const t=e.target.value.replace(/\D/g,"");if("between"===w.value){"operator-input"===e.target.id?P(t):C(t);let r={target:{id:n,value:"operator-input"===e.target.id?[t,E]:[x,t],type:"operatorinput",operator:w.value}};o(r)}else{P(t);let e={target:{id:n,value:t,type:"operatorinput",operator:w.value}};o(e)}};let k=y;return i().createElement("div",{className:y,style:h||{display:"flex",justifyContent:"space-between",alignItems:"baseline"}},i().createElement("label",null,a),i().createElement(c(),t()({className:k,value:w,options:g,onChange:e=>{C(""),S({value:e.value,label:e.label});let t={target:{id:n,value:"between"===e.value?[x,E]:x,type:"operatorinput",operator:e.value}};o(t)},isClearable:m,isDisabled:v,styles:D},j)),i().createElement("input",t()({id:"operator-input",value:x,onChange:M,className:"form-control",disabled:v,style:{width:"auto"}},j)),"between"===w.value&&i().createElement(i().Fragment,null,i().createElement("span",null,"And"),i().createElement("input",t()({id:"operator-input-between",value:E,onChange:M,className:"form-control",disabled:v,style:{width:"auto"}},j))),A&&i().createElement("p",{className:"error-label"},r))},v=y;y.defaultProps={options:[{value:">",label:"Greater than"},{value:"<",label:"Less than"},{value:">=",label:"Greater or Equal"},{value:"<=",label:"Less or Equal"},{value:"==",label:"Equal"},{value:"between",label:"Between"}]}})(),a})()));
//# sourceMappingURL=operator-input.js.map