@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,FormHelperText as u,Typography as d,TextField as c,InputAdornment as m,Chip as f}from"@material-ui/core";import{forwardRef as b,useState as y,useEffect as g,useMemo as h}from"react";import O from"@babel/runtime/helpers/objectWithoutProperties";import v from"prop-types";import{Search as x}from"@material-ui/icons";import T from"../TruncatedText/index.js";import{PER_PAGE as I,SCROLL_THRESHOLD as P}from"./constants.js";import{useAssetAutoCompleteSelectData as C}from"./effects/index.js";import{Autocomplete as j}from"@material-ui/lab";function A(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 S(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?A(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var M="DC_SingleAssetEditorAutocomplete",q={paddingLeft:"16px",height:36,listStyleType:"none",display:"flex",alignItems:"center"},w=function(e){var t=e.text;return i("li",{style:q,children:i(d,{variant:"body2",color:"textSecondary",children:void 0===t?"Loading...":t})},"loading")},L=b((function(e,t){var r=e.children,n=e.loading,a=e.hasMore,s=O(e,["children","loading","hasMore"]);return o(l,S(S({},s),{},{ref:t,role:"listbox",children:[r,(a||n)&&i(w,{})]}))})),D=function(e){var a=e["data-testid"],l=e.appKey,d=e.assetType,b=e.classes,O=e.companyId,v=e.currentValue,A=e.disabled,q=e.disableClearable,D=e.errorText,N=e.isMultiple,R=e.isNullable,V=e.label,E=e.onChange,K=e.parentAssetId,_=e.parentAssetType,k=e.queryParams,z=y(N?[]:null),H=n(z,2),B=H[0],W=H[1],F=y(""),G=n(F,2),J=G[0],Q=G[1],U=y(""),X=n(U,2),Y=X[0],Z=X[1],$=y(!1),ee=n($,2),te=ee[0],re=ee[1],ne=y(1),oe=n(ne,2),ie=oe[0],ae=oe[1],le=y(!0),se=n(le,2),pe=se[0],ue=se[1];g((function(){W(N?[]:null),ae(1),re(!1)}),[d]);var de=C({appKey:l,assetType:d,companyId:O,currentValue:v,isMultiple:N,parentAssetId:K,parentAssetType:_,scrollPage:ie,searchText:J,setCurrentOption:W,queryParams:k}),ce=de.assets,me=de.loading;g((function(){var e=ce.length>=I*ie;ue(e)}),[ce,ie]);var fe=h((function(){return t((function(e){ae(1),Q(e)}),200)}),[]),be=h((function(){return t((function(){return ae((function(e){return e+1}))}),250)}),[]),ye={endAdornment:b.endAdornment,inputRoot:b.inputRoot,listbox:b.listbox,noOptions:b.noOptions,option:b.option,popupIndicator:b.popupIndicator,root:b.root};return o(s,{disabled:A,error:!!D,className:b.formControl,children:[!R&&i(p,{shrink:!0,children:V}),i(j,S({disabled:A,blurOnSelect:!0,classes:ye,clearOnBlur:!0,clearOnEscape:!0,"data-testid":a,disableClearable:q,filterOptions:r,getOptionLabel:function(e){return null==e?void 0:e.name},getOptionSelected:function(e,t){return e&&t&&e.id===t.id},inputValue:te?Y:(null==B?void 0:B.name)||"",ListboxComponent:L,ListboxProps:{onScroll:function(e){if(pe&&!me){var t=e.currentTarget;t.scrollTop+t.clientHeight>t.scrollHeight-P&&be()}},loading:me,hasMore:pe},options:ce,onChange:function(e,t){var r;W(t),E(N?t.map((function(e){return e.id})):null!==(r=null==t?void 0:t.id)&&void 0!==r?r:null,t)},onClose:function(){Z(""),Q(""),re(!1),ae(1)},onInputChange:function(e,t,r){"input"===r?(Z(t),re(!0),fe(t)):Q("")},noOptionsText:i(w,{text:me?"Loading...":"No options"}),renderInput:function(e){return i(c,S(S({},e),{},{variant:"standard",placeholder:"Search for asset..."},!N&&{InputProps:S(S({},e.InputProps),{},{startAdornment:i(m,{children:i(x,{className:b.searchIcon})})})}))},renderOption:function(e){var t=e.id,r=e.name;return i(T,{"data-testid":"".concat(M,"_option_").concat(r,"MenuItem"),children:N&&v.includes(t)?"".concat(r," (already selected)"):r},t)},value:B,multiple:N},N&&{renderTags:function(e,t){return e.map((function(e,r){return i(f,S({label:null==e?void 0:e.name},t({index:r})),e.id)}))},getOptionDisabled:function(e){return v.includes(e.id)}})),i(u,{children:D})]})};D.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(M,"_autoComplete"),disabled:!1,isMultiple:!1,appKey:null,queryParams:{}},D.propTypes={label:v.string,currentValue:v.oneOfType([v.number,v.arrayOf(v.number)]),isNullable:v.bool,onChange:v.func.isRequired,classes:v.shape({}).isRequired,disableClearable:v.bool,parentAssetId:v.number,parentAssetType:v.string,companyId:v.number,assetType:v.string.isRequired,errorText:v.string,"data-testid":v.string,disabled:v.bool,isMultiple:v.bool,appKey:v.string,queryParams:v.shape({})};var N=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"}}}))(D);export default N;
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 s}from"react/jsx-runtime";import{withStyles as l,IconButton as n,makeStyles as a,Modal as c,Tooltip as m}from"@material-ui/core";import p from"@babel/runtime/helpers/objectWithoutProperties";import d 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 N(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 g="filters",v="settings",O=(e(h={},g,"Filters"),e(h,v,"Settings"),h),T=l({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}}})(n),j=l((function(e){return{root:{color:e.palette.primary.text6,"&:hover":{color:"white",cursor:"pointer"}}}}))(b),M=a({closeTooltip:{marginTop:8},closeButton:{padding:"4px 6px"}});function k(o){var t,i,l=o.title,a=o.children,d=o.actions,b=o.open,h=o.isCloseIconHidden,y=o.onClose,v=o.isNative,k=o.isMobile,F=o.stickyFooter,P=o.contentContainerClassName,w=o.contentClassName,x=o.stickyFooterClassName,S=o.size,z=o.type,D=o.rootClassName,E=p(o,["title","children","actions","open","isCloseIconHidden","onClose","isNative","isMobile","stickyFooter","contentContainerClassName","contentClassName","stickyFooterClassName","size","type","rootClassName"]),I=v||k,H=M();return r(c,N(N({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:s("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&&s("div",{className:u(f.modalMobileTitle,z===g&&f.filtersTitle),children:[r(T,{onClick:y,children:r(C,{})}),r("div",{className:f.modalMobileTitleText,children:l||O[z]})]}),!I&&l&&s("div",{className:u(f.modalTitle,!h&&f.modalTitleWithClose),children:[r("div",{className:f.modalTitleText,children:l}),!h&&r(m,{title:"Close",classes:{tooltip:H.closeTooltip},placement:"bottom",children:r(n,{onClick:y,classes:{root:H.closeButton},children:r(j,{})})})]}),a&&r("div",{className:u(!I&&f.modalContent,I&&f.modalMobileContent,w),children:a}),d&&r("div",{className:u(I&&f.modalMobileActions,!F&&f.modalActions,F&&f.modalActionsSticky,F&&x),children:d})]})}))}k.propTypes={title:d.oneOfType([d.string,d.node]),children:d.oneOfType([d.string,d.node]),actions:d.oneOfType([d.string,d.node,d.array]),stickyFooter:d.bool,open:d.bool.isRequired,onClose:d.func,isNative:d.bool,isMobile:d.bool,isCloseIconHidden:d.bool,contentClassName:d.string,contentContainerClassName:d.string,stickyFooterClassName:d.string,rootClassName:d.string,size:d.string,type:d.string},k.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 k;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/ui",
3
- "version": "0.31.0-5",
3
+ "version": "0.31.0-6",
4
4
  "description": "Shared components/utils for Corva ui projects",
5
5
  "keywords": [
6
6
  "corva-ui"