@corva/ui 0.31.0-5 → 0.31.0-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import{debounce as t,identity as r}from"lodash";import n from"@babel/runtime/helpers/slicedToArray";import{jsxs as o,jsx as i}from"react/jsx-runtime";import{withStyles as a,List as l,FormControl as s,InputLabel as p,
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import{debounce as t,identity as r}from"lodash";import n from"@babel/runtime/helpers/slicedToArray";import{jsxs as o,jsx as i}from"react/jsx-runtime";import{withStyles as a,List as l,FormControl as s,InputLabel as p,Tooltip as u,FormHelperText as d,Typography as c,TextField as m,InputAdornment as f,Chip as b}from"@material-ui/core";import{forwardRef as y,useState as g,useEffect as h,useMemo as O}from"react";import v from"@babel/runtime/helpers/objectWithoutProperties";import x from"prop-types";import{Search as T}from"@material-ui/icons";import I from"../TruncatedText/index.js";import{PER_PAGE as P,SCROLL_THRESHOLD as C}from"./constants.js";import{useAssetAutoCompleteSelectData as j}from"./effects/index.js";import{Autocomplete as A}from"@material-ui/lab";function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function M(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?S(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var q="DC_SingleAssetEditorAutocomplete",w={paddingLeft:"16px",height:36,listStyleType:"none",display:"flex",alignItems:"center"},L=function(e){var t=e.text;return i("li",{style:w,children:i(c,{variant:"body2",color:"textSecondary",children:void 0===t?"Loading...":t})},"loading")},D=y((function(e,t){var r=e.children,n=e.loading,a=e.hasMore,s=v(e,["children","loading","hasMore"]);return o(l,M(M({},s),{},{ref:t,role:"listbox",children:[r,(a||n)&&i(L,{})]}))})),N=function(e){var a,l=e["data-testid"],c=e.appKey,y=e.assetType,v=e.classes,x=e.companyId,S=e.currentValue,w=e.disabled,N=e.disableClearable,R=e.errorText,V=e.isMultiple,E=e.isNullable,K=e.label,_=e.onChange,k=e.parentAssetId,z=e.parentAssetType,H=e.queryParams,B=g(V?[]:null),W=n(B,2),F=W[0],G=W[1],J=g(""),Q=n(J,2),U=Q[0],X=Q[1],Y=g(""),Z=n(Y,2),$=Z[0],ee=Z[1],te=g(!1),re=n(te,2),ne=re[0],oe=re[1],ie=g(1),ae=n(ie,2),le=ae[0],se=ae[1],pe=g(!0),ue=n(pe,2),de=ue[0],ce=ue[1];h((function(){G(V?[]:null),se(1),oe(!1)}),[y]);var me=j({appKey:c,assetType:y,companyId:x,currentValue:S,isMultiple:V,parentAssetId:k,parentAssetType:z,scrollPage:le,searchText:U,setCurrentOption:G,queryParams:H}),fe=me.assets,be=me.loading;h((function(){var e=fe.length>=P*le;ce(e)}),[fe,le]);var ye=O((function(){return t((function(e){se(1),X(e)}),200)}),[]),ge=O((function(){return t((function(){return se((function(e){return e+1}))}),250)}),[]),he={endAdornment:v.endAdornment,inputRoot:v.inputRoot,listbox:v.listbox,noOptions:v.noOptions,option:v.option,popupIndicator:v.popupIndicator,root:v.root};return o(s,{disabled:w,error:!!R,className:v.formControl,children:[!E&&i(p,{shrink:!0,children:K}),i(u,{title:null!==(a=null==F?void 0:F.name)&&void 0!==a?a:"",children:i(A,M({disabled:w,blurOnSelect:!0,classes:he,clearOnBlur:!0,clearOnEscape:!0,"data-testid":l,disableClearable:N,filterOptions:r,getOptionLabel:function(e){return null==e?void 0:e.name},getOptionSelected:function(e,t){return e&&t&&e.id===t.id},inputValue:ne?$:(null==F?void 0:F.name)||"",ListboxComponent:D,ListboxProps:{onScroll:function(e){if(de&&!be){var t=e.currentTarget;t.scrollTop+t.clientHeight>t.scrollHeight-C&&ge()}},loading:be,hasMore:de},options:fe,onChange:function(e,t){var r;G(t),_(V?t.map((function(e){return e.id})):null!==(r=null==t?void 0:t.id)&&void 0!==r?r:null,t)},onClose:function(){ee(""),X(""),oe(!1),se(1)},onInputChange:function(e,t,r){"input"===r?(ee(t),oe(!0),ye(t)):X("")},noOptionsText:i(L,{text:be?"Loading...":"No options"}),renderInput:function(e){return i(m,M(M({},e),{},{variant:"standard",placeholder:"Search for asset..."},!V&&{InputProps:M(M({},e.InputProps),{},{startAdornment:i(f,{children:i(T,{className:v.searchIcon})})})}))},renderOption:function(e){var t=e.id,r=e.name;return i(I,{"data-testid":"".concat(q,"_option_").concat(r,"MenuItem"),children:V&&S.includes(t)?"".concat(r," (already selected)"):r},t)},value:F,multiple:V},V&&{renderTags:function(e,t){return e.map((function(e,r){return i(b,M({label:null==e?void 0:e.name},t({index:r})),e.id)}))},getOptionDisabled:function(e){return S.includes(e.id)}}))}),i(d,{children:R})]})};N.defaultProps={label:"Choose An Asset",currentValue:void 0,disableClearable:!0,isNullable:!1,parentAssetId:void 0,parentAssetType:void 0,companyId:void 0,errorText:"","data-testid":"".concat(q,"_autoComplete"),disabled:!1,isMultiple:!1,appKey:null,queryParams:{}},N.propTypes={label:x.string,currentValue:x.oneOfType([x.number,x.arrayOf(x.number)]),isNullable:x.bool,onChange:x.func.isRequired,classes:x.shape({}).isRequired,disableClearable:x.bool,parentAssetId:x.number,parentAssetType:x.string,companyId:x.number,assetType:x.string.isRequired,errorText:x.string,"data-testid":x.string,disabled:x.bool,isMultiple:x.bool,appKey:x.string,queryParams:x.shape({})};var R=a((function(e){return{formControl:{},listbox:{maxHeight:350},root:{fontSize:16},inputRoot:{paddingTop:16,padding:"8px 0",paddingBottom:0,width:350,fontSize:16},popupIndicator:{display:"none"},option:{paddingLeft:"16px !important",height:36,"&[aria-disabled=true]":{color:e.palette.primary.text9,opacity:1,backgroundColor:"unset"}},noOptions:{padding:0},searchIcon:{fontSize:"20px !important"}}}))(N);export default R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import{noop as o}from"lodash";import{isNativeDetected as t,isMobileDetected as i}from"../../utils/mobileDetect.js";import{jsx as r,jsxs as
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import{noop as o}from"lodash";import{isNativeDetected as t,isMobileDetected as i}from"../../utils/mobileDetect.js";import{jsx as r,jsxs as n}from"react/jsx-runtime";import{withStyles as s,IconButton as l,makeStyles as a,Modal as c,Tooltip as m}from"@material-ui/core";import d from"@babel/runtime/helpers/objectWithoutProperties";import p from"prop-types";import u from"classnames";import{Close as b,CloseRounded as C}from"@material-ui/icons";import f from"./Modal.css.js";var h;function y(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);o&&(i=i.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,i)}return t}function g(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?y(Object(i),!0).forEach((function(t){e(o,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):y(Object(i)).forEach((function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}))}return o}var N="filters",v="settings",O=(e(h={},N,"Filters"),e(h,v,"Settings"),h),T=s({root:{position:"absolute",right:28,top:24,color:"#9E9E9E",fontSize:"14px",paddingTop:8,width:14,height:14,"&.MuiIconButton-root":{padding:0},"& svg":{transform:"scale(1.8)",width:14,height:14}}})(l),j=s((function(e){return{root:{color:e.palette.primary.text6,"&:hover":{color:"white",cursor:"pointer"}}}}))(b),k=a((function(e){return{closeTooltip:{marginTop:8},closeButton:{padding:"4px 6px","&:hover":{backgroundColor:e.palette.background.b7}}}}));function M(o){var t,i,s=o.title,a=o.children,p=o.actions,b=o.open,h=o.isCloseIconHidden,y=o.onClose,v=o.isNative,M=o.isMobile,F=o.stickyFooter,P=o.contentContainerClassName,w=o.contentClassName,x=o.stickyFooterClassName,S=o.size,z=o.type,D=o.rootClassName,E=d(o,["title","children","actions","open","isCloseIconHidden","onClose","isNative","isMobile","stickyFooter","contentContainerClassName","contentClassName","stickyFooterClassName","size","type","rootClassName"]),I=v||M,H=k();return r(c,g(g({open:b,onClose:y,className:u((t={"c-modal":!I},e(t,f.modalWrapper,!0),e(t,D,!0),e(t,f[z],I&&z),t))},E),{},{children:n("div",{className:u((i={},e(i,f[S],!I),e(i,f.modalContainer,!I),e(i,f.modalStaticFooter,!I&&F),e(i,P,!0),e(i,f.modalMobileContainer,I),e(i,f.modalMobileStaticFooter,I),i)),children:[I&&n("div",{className:u(f.modalMobileTitle,z===N&&f.filtersTitle),children:[r(T,{onClick:y,children:r(C,{})}),r("div",{className:f.modalMobileTitleText,children:s||O[z]})]}),!I&&s&&n("div",{className:u(f.modalTitle,!h&&f.modalTitleWithClose),children:[r("div",{className:f.modalTitleText,children:s}),!h&&r(m,{title:"Close",classes:{tooltip:H.closeTooltip},placement:"bottom",children:r(l,{onClick:y,classes:{root:H.closeButton},children:r(j,{})})})]}),a&&r("div",{className:u(!I&&f.modalContent,I&&f.modalMobileContent,w),children:a}),p&&r("div",{className:u(I&&f.modalMobileActions,!F&&f.modalActions,F&&f.modalActionsSticky,F&&x),children:p})]})}))}M.propTypes={title:p.oneOfType([p.string,p.node]),children:p.oneOfType([p.string,p.node]),actions:p.oneOfType([p.string,p.node,p.array]),stickyFooter:p.bool,open:p.bool.isRequired,onClose:p.func,isNative:p.bool,isMobile:p.bool,isCloseIconHidden:p.bool,contentClassName:p.string,contentContainerClassName:p.string,stickyFooterClassName:p.string,rootClassName:p.string,size:p.string,type:p.string},M.defaultProps={title:"",children:null,actions:"",stickyFooter:!1,onClose:o,isNative:t,isMobile:i,isCloseIconHidden:!1,contentClassName:null,contentContainerClassName:null,stickyFooterClassName:null,size:null,type:"",rootClassName:null};export default M;
|