@start-base/react-form-elements
Version:
Simplify form elements and form management. Selection of user friendly inputs and wide customization abilities to match your design and functionality.
1 lines • 3.76 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),l=require("clsx"),t=require("react-select"),a=require("react-select/animated");function o(e){return e&&e.__esModule?e:{default:e}}var r=o(e),n=o(l),u=o(t),c=o(a),s=Object.defineProperty,d=Object.defineProperties,i=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,l,t)=>l in e?s(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,b=(e,l)=>{for(var t in l||(l={}))S.call(l,t)&&f(e,t,l[t]);if(m)for(var t of m(l))p.call(l,t)&&f(e,t,l[t]);return e},I="SUI-Select-module-root--Ti5s",U="SUI-Select-module-inputRoot-si5Tv",v="SUI-Select-module-label-UcKX8",C="SUI-Select-module-disableShrink-J-WRb",h="SUI-Select-module-disabledLabel-lEiU-",y="SUI-Select-module-labelPlaceholder-z-dST",O="SUI-Select-module-labelFocused-q50V-",N="SUI-Select-module-input-HAhy-",g="SUI-Select-module-focus-YF8bV",E="SUI-Select-module-inputError-o-svT",P="SUI-Select-module-errorLabel-tJ7RS",j="SUI-Select-module-disabled--iG97",F="SUI-Select-module-innerInput-PeI5U",x="SUI-Select-module-control-ehUuP",V="SUI-Select-module-menu-axmUL",k="SUI-Select-module-option-EdP-F",w="SUI-Select-module-optionFocused-2jC7x",R="SUI-Select-module-singleValue--cc8w",q="SUI-Select-module-placeholder-OAeGA",M="SUI-Select-module-indicatorSeparator-eEfnQ",T="SUI-Select-module-indicatorsContainer-2xCsm",X="SUI-Select-module-clearIndicator-O6EuX",_="SUI-Select-module-multiValueRemove-34fTi",A="SUI-Select-module-multiValue-9XkYX",B="SUI-Select-module-valueContainer-MGkpr",D=c.default(),G=e.forwardRef((l,t)=>{var a=l,{name:o,onChange:c,error:s=null,label:f=null,options:G=[],placeholder:L=null,value:J=null,inputClassName:Y=null,labelClassName:z=null,errorClassName:H=null,disableShrink:K=!1,disabled:Q=!1,classNames:W=null,components:Z=null,onFocus:$=()=>({}),onBlur:ee=()=>({})}=a,le=((e,l)=>{var t={};for(var a in e)S.call(e,a)&&l.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&m)for(var a of m(e))l.indexOf(a)<0&&p.call(e,a)&&(t[a]=e[a]);return t})(a,["name","onChange","error","label","options","placeholder","value","inputClassName","labelClassName","errorClassName","disableShrink","disabled","classNames","components","onFocus","onBlur"]);const[te,ae]=e.useState(!1),oe=e.useCallback(e=>{c({target:{name:o,value:e}})},[t,o,c]),re=e.useMemo(()=>r.default.createElement("label",{htmlFor:o,className:n.default(v,{[C]:K,[h]:Q,[y]:f&&L&&!K,[O]:f&&te&&!K||f&&J&&!K,[z]:z})},f),[Q,o,K,f,L,te,J,z,t]),ne=e.useMemo(()=>s&&"string"==typeof s?s:s&&"object"==typeof s&&s.message?s.message:null,[s]);return r.default.createElement("div",{className:n.default(I)},r.default.createElement("div",{className:n.default(U)},f&&K?re:null,r.default.createElement(u.default,b({value:J,ref:t,options:G,instanceId:e.useId(),onChange:oe,classNames:(ue=b({input:()=>F,menu:()=>V,option:e=>e.isFocused||e.isSelected?w:k,singleValue:()=>R,placeholder:()=>q,indicatorSeparator:()=>M,indicatorsContainer:()=>T,clearIndicator:()=>X,multiValue:()=>A,valueContainer:()=>f&&!K?B:null,multiValueRemove:()=>_},W),ce={control:e=>{var l,t;return n.default(N,{[x]:!K&&f,[g]:e.isFocused,[E]:"boolean"==typeof s&&s,[j]:e.isDisabled,[Y]:Y,[null==(l=null==W?void 0:W.control)?void 0:l.call(W,e)]:null==(t=null==W?void 0:W.control)?void 0:t.call(W,e)})}},d(ue,i(ce))),placeholder:L,name:o,isDisabled:Q,onFocus:e=>{$(e),ae(!0)},onBlur:e=>{ee(e),ae(!1)},components:b(b({},D),Z)},le)),f&&!K?re:null),ne&&r.default.createElement("span",{className:n.default(P,b({},H?{[H]:!0}:{}))},ne));var ue,ce});G.displayName="Select";var L=G;Object.defineProperty(exports,"SelectComponents",{enumerable:!0,get:function(){return t.components}}),exports.default=L;