forked from bombastictranz/awesome
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
3885-a6d7d86272722c3f.js.download
2 lines (2 loc) · 13.9 KB
/
3885-a6d7d86272722c3f.js.download
1
2
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3885],{79775:function(e,n,t){t.d(n,{p:function(){return D},V:function(){return B}});var i=t(70865),r=t(96670),o=t(52903),a=t(28165),l=t(62413),u=t(2784),d=t(3e3),c=t(70776),s=t(15504),m=t(60943),p=function(e){var n=e.children;return(0,o.tZ)("div",{css:(0,a.iv)("position:absolute;","FloatingMenu.tsx--EmptyList"),children:n})},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return(0,a.iv)("max-height:",40*((e||0)+.5)+10,"px;overflow:auto;padding:10px;","FloatingMenu.tsx--listStyle")},_=(0,a.iv)("align-items:flex-end;height:60px;","FloatingMenu.tsx--loadMoreStyle"),b=(0,a.iv)(d.ZT.paragraph3Medium," align-items:center;border-radius:3px;color:",c.w.neutral700,";cursor:pointer;display:flex;height:",40,"px;padding:0 10px;& svg{/* \n I do not like using !important here but we have to\n in order to override the icon colors\n */\n fill:",c.w.neutral600," !important;}","FloatingMenu.tsx--menuItem"),g=(0,a.iv)(d.ZT.paragraph3Medium," color:",c.w.neutral500,";","FloatingMenu.tsx--menuItemDisabled"),v=(0,a.iv)(d.ZT.paragraph3Medium," background-color:",c.w.blue10,";color:",c.w.blue,";font-weight:500;& svg{/* \n I do not like using !important here but we have to\n in order to override the icon colors\n */\n fill:",c.w.blue," !important;}","FloatingMenu.tsx--menuItemHighlighted"),f=(0,a.iv)("display:flex;align-items:center;justify-content:center;margin-right:10px;","FloatingMenu.tsx--menuItemIcon"),I=(0,a.iv)("flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;","FloatingMenu.tsx--menuItemText");function M(e){var n=(0,i.Z)({align:"stretch",visibleItems:4},e),t=n.align,a=n.ariaLabel,l=n.getItemProps,d=n.itemKey,c=n.itemLabel,M=n.getMenuProps,Z=n.highlightedIndex,y=n.isLoadingMore,C=n.isOpen,w=n.items,E=n.maxWidth,L=n.minWidth,S=n.onLoadMore,x=n.showLoadMore,B=void 0!==x&&x,k=C&&w.length>0,A=(0,r.Z)((0,i.Z)({},l({disabled:!1,index:w.length,item:null})),{onClick:void 0});return k?(0,o.tZ)(s.f,{align:t,maxWidth:E,minWidth:L,children:(0,o.BX)("ul",(0,r.Z)((0,i.Z)({"aria-hidden":!C,css:[h(n.visibleItems)]},M({"aria-label":a})),{"aria-labelledby":void 0,children:[(k?w:[]).map((function(e,t){var a=(0,i.Z)({},l({disabled:e.disabled,index:t,item:e}));return(0,u.createElement)("li",(0,r.Z)((0,i.Z)({},a),{key:e[d]||t}),(0,o.BX)("span",{css:[b,e.disabled&&g,Z===t&&v],children:[n.renderIcon&&(0,o.tZ)("span",{css:f,children:n.renderIcon({item:e})}),(0,o.tZ)("span",{css:I,children:e[c]})]}))})),k&&(y||B)&&(0,u.createElement)("li",(0,r.Z)((0,i.Z)({},A),{key:"Load more"}),(0,o.tZ)("span",{css:[b,_],children:(0,o.tZ)(m.W,{isLoading:Boolean(y),onClick:S,size:"small",children:"Load more"})}))]}))}):(0,o.tZ)(p,{children:(0,o.tZ)("ul",(0,r.Z)((0,i.Z)({"aria-hidden":!C,css:[h(n.visibleItems)]},M({"aria-label":a})),{"aria-labelledby":void 0}))})}var Z=t(26297),y=t(61854),C=t(42126),w=t(22211),E=(0,t(39479).B)("TypeaheadInput",{clearSelectionButton:{alignItems:"center",background:"transparent",border:"none",cursor:"pointer",display:"flex",height:"100%",justifyContent:"center",outline:"none",width:"100%"}}),L=function(e){var n=e.clearSelection;return(0,o.tZ)("button",{css:E.clearSelectionButton,onClick:n,title:"Clear Selection",type:"button",children:(0,o.tZ)(y.J,{canAcceptPointerEvents:!1,name:"x",size:20})})},S=function(e){return e.renderIcon?e.renderIcon({item:e.selectedItem}):(0,o.tZ)(y.J,{name:"magnifyingGlass",size:e.iconSize})},x=function(e){var n,t=null!==(n=e.showClearSelectionButton)&&void 0!==n?n:e.selectedItem&&!e.isDisabled,a=e.getInputProps({"aria-labelledby":e.ariaLabelledBy,autoComplete:e.autoComplete,onFocus:e.onFocus}),l=a.ref,u=(0,Z.Z)(a,["ref"]);return(0,o.BX)(o.HY,{children:[(0,o.tZ)("div",{ref:l}),(0,o.tZ)(C.o,(0,r.Z)((0,i.Z)({},u),{ariaLabel:e.ariaLabel,autoComplete:"off",canClickIconAfter:Boolean(e.renderIconAfter)||t,disabledText:e.disabledText,isDisabled:e.isDisabled,isErrored:e.isErrored,placeholder:e.placeholder,renderIconAfter:function(n){var i=n.iconSize,r=n.isFocused,a=n.isHovered;return e.renderIconAfter?e.renderIconAfter():t?(0,o.tZ)(L,{clearSelection:function(n){n.currentTarget&&n.currentTarget.blur(),e.clearSelection()},isFocused:r,isHovered:a}):e.iconEndName&&(0,o.tZ)(y.J,{name:e.iconEndName,size:i})},renderIconBefore:function(n){var t=n.iconSize,a=n.isFocused;return e.isBusy?(0,o.tZ)("span",{style:{width:t},children:(0,o.tZ)(w.$,{})}):e.isOpen?null:(0,o.tZ)(S,(0,r.Z)((0,i.Z)({},e),{iconSize:t,isFocused:a}))},size:e.size}))]})};x.defaultProps={size:"small"};var B,k=t(76635),A=(0,a.iv)("position:relative;","Typeahead.tsx--rootStyles");function D(e){var n=e.id,t=e.onChange,a=e.items,d=e.inputId,c=e.itemLabel,s=e.onFocus,m=e.keepInputValueOnBlur,p=(0,u.useCallback)((0,k.debounce)(e.onInputValueChange,500),[]),h=(0,u.useCallback)((function(n){if(n){var t=n[c];return e.inputValue!==t?e.inputValue||"":t}return e.inputValue||""}),[e,c]),_=(0,u.useCallback)((function(e,n){var t=n.type,o=n.changes;switch(t){case l.Kb.stateChangeTypes.ItemClick:return(0,r.Z)((0,i.Z)({},o),{isOpen:!1});case l.Kb.stateChangeTypes.InputBlur:if(m){var a,u=null===(a=e.selectedItem)||void 0===a?void 0:a.label;return(0,r.Z)((0,i.Z)({},o),{inputValue:u})}return o;default:return o}}),[m]),b=(0,u.useCallback)((function(e){t(e.selectedItem)}),[t]),g=(0,l.Kb)({inputValue:e.inputValue,inputId:d,items:a,itemToString:h,id:n,onSelectedItemChange:b,onInputValueChange:p,selectedItem:e.selectedItem,stateReducer:_,onStateChange:function(n){var t;null===(t=e.onInputValueChange)||void 0===t||t.call(e,n)}}),v=g.getInputProps,f=g.getItemProps,I=g.getMenuProps,Z=g.getComboboxProps,y=g.highlightedIndex,C=g.isOpen,w=g.openMenu,E=g.selectedItem,L=g.inputValue,S=g.reset,B=e.showErrorOnNoResults&&E&&0===a.length||e.isErrored,D=e.labelId||void 0;return(0,o.BX)("div",(0,r.Z)((0,i.Z)({css:A},Z()),{children:[(0,o.tZ)(x,{ariaLabel:e.ariaLabel,ariaLabelledBy:D,autoComplete:e.autoComplete,clearSelection:S,disabledText:e.disabledText,getInputProps:v,itemLabel:e.itemLabel,iconEndName:e.iconEndName,inputValue:L,isBusy:e.isBusy,isOpen:C,isDisabled:e.isDisabled,isErrored:!!B,onFocus:function(n){null===s||void 0===s||s(n),e.openOnFocus&&w()},placeholder:e.placeholder,renderIcon:e.inputIcon,renderIconAfter:e.renderIconAfter,selectedItem:E,size:e.size,showClearSelectionButton:e.showClearSelectionButton}),function(n){var t;return(null===(t=e.renderFloatingMenu)||void 0===t?void 0:t.call(e,n))||(0,o.tZ)(M,(0,i.Z)({},n))}((0,r.Z)((0,i.Z)({},e.floatingMenuProps),{ariaLabel:e.menuAriaLabel,getItemProps:f,itemKey:e.itemKey,itemLabel:e.itemLabel,getMenuProps:I,highlightedIndex:y,isLoadingMore:e.isLoadingMore,isOpen:C,items:a,onLoadMore:e.onLoadMore,renderIcon:e.renderIcon,showLoadMore:e.showLoadMore}))]}))}!function(e){e.InputKeyDownArrowDown="__input_keydown_arrow_down__",e.InputKeyDownArrowUp="__input_keydown_arrow_up__",e.InputKeyDownEscape="__input_keydown_escape__",e.InputKeyDownHome="__input_keydown_home__",e.InputKeyDownEnd="__input_keydown_end__",e.InputKeyDownEnter="__input_keydown_enter__",e.InputChange="__input_change__",e.InputBlur="__input_blur__",e.MenuMouseLeave="__menu_mouse_leave__",e.ItemMouseMove="__item_mouse_move__",e.ItemClick="__item_click__",e.ToggleButtonClick="__togglebutton_click__",e.FunctionToggleMenu="__function_toggle_menu__",e.FunctionOpenMenu="__function_open_menu__",e.FunctionCloseMenu="__function_close_menu__",e.FunctionSetHighlightedIndex="__function_set_highlighted_index__",e.FunctionSelectItem="__function_select_item__",e.FunctionSetInputValue="__function_set_input_value__",e.FunctionReset="__function_reset__",e.ControlledPropUpdatedSelectedItem="__controlled_prop_updated_selected_item__"}(B||(B={})),D.defaultProps={isDisabled:!1,openOnFocus:!1,renderFloatingMenu:function(e){return(0,o.tZ)(M,(0,i.Z)({},e))},showEmptyList:!1,showErrorOnNoResults:!1,itemLabel:"label",itemKey:"id"}},33885:function(e,n,t){t.r(n),t.d(n,{MemberSearch:function(){return h},OwnerSearch:function(){return b}});var i=t(70865),r=t(96670),o=t(52903),a=t(17688),l=t(61854),u=t(41273),d=t(79775),c=t(38716),s=t(54110),m=t(16181),p=t(47497);function h(){var e=(0,c.X8)(),n=(0,m.gn)(),t=n.userId,i=n.email,r=n.fullName,a=n.photoUrl,l=(0,p.Z)().memberId;if(!t||!e)return null;var u={id:t,email:i||"",fullName:r||"",photoUrl:a||""};return(0,o.tZ)(_,{currentUser:u,accountId:e,memberId:l})}function _(e){var n=e.currentUser,t=e.accountId,i=e.memberId,r=(0,s.LR)({accountId:t,currentUser:n,defaultSelectedMemberId:i||n.id}),l=r.members,u=r.onSearch,d=r.selectedItem,c=r.search,m=r.isLoading,p=r.handleMemberChange,h=r.onLoadMore,_=r.isLoadingMore,g=r.defaultMemberHasBeenSet;return(0,o.tZ)("div",{"data-testid":"membersearch",children:(0,o.tZ)(a.g,{label:"Owned by",renderInput:function(){return(0,o.tZ)(b,{currentUser:n,inputValue:c||"",isBusy:m,isDisabled:!g,isLoadingMore:_,members:l,onChange:p,onInputValueChange:u,onLoadMore:h,selectedItem:d,showLoadMore:Boolean(h)})}})})}var b=function(e){var n=e.currentUser,t=e.inputValue,a=e.isBusy,l=e.isDisabled,u=e.isLoadingMore,c=e.members,m=e.onChange,p=e.onInputValueChange,h=e.onLoadMore,_=e.selectedItem,b=null===c||void 0===c?void 0:c.map((function(e){return(0,r.Z)((0,i.Z)({},e),{label:(0,s.n6)(e)})})),v=_?(0,r.Z)((0,i.Z)({},_),{label:(0,s.n6)(_)}):null,f=String(null===_||void 0===_?void 0:_.id)!==String(null===n||void 0===n?void 0:n.id)&&!!_;return(0,o.tZ)(d.p,{showClearSelectionButton:f,id:"MemberSearchTypeahead",itemLabel:"label",itemKey:"id",isBusy:a,isDisabled:l,ariaLabel:"Owned by",selectedItem:v||null,items:b,inputValue:t,menuAriaLabel:"menuAriaLabel",placeholder:"",onInputValueChange:p,onChange:m,isLoadingMore:u,onLoadMore:h,showLoadMore:Boolean(h),openOnFocus:!0,renderIcon:g,inputIcon:g,keepInputValueOnBlur:!0})},g=function(e){var n=e.item;return n?(0,o.tZ)(u.q,{ariaHidden:!0,name:String(n.name),size:24,url:n.imageUrl}):(0,o.tZ)(l.J,{name:"personOne",size:24})};n.default=h},54110:function(e,n,t){t.d(n,{n6:function(){return y},LR:function(){return M}});var i=t(70865),r=t(96670),o=t(92228),a=t(50930),l=t(2784),u=t(79775),d=t(60138),c=t(40794),s=t(64368),m=t(5632),p=t(14725);function h(e,n){switch(n.type){case"UPDATE_SEARCH":return(0,r.Z)((0,i.Z)({},e),{search:n.search});case"UPDATE_SELECTED_MEMBER_ID":return(0,r.Z)((0,i.Z)({},e),{selectedMemberId:n.selectedMemberId});case"UPDATE_MEMBER_AND_SEARCH":return(0,r.Z)((0,i.Z)({},e),{selectedMemberId:n.selectedMemberId,search:n.search});default:return e}}var _=t(57037),b=t(35591);function g(){var e=(0,o.Z)(["\n fragment UserFilter on Member {\n email\n id\n imageUrl\n name\n }\n"]);return g=function(){return e},e}function v(){var e=(0,o.Z)(["\n ","\n query MemberFilter(\n $accountId: Int!\n $memberId: ID\n $limit: Int\n $offset: Int\n $search: String\n ) {\n account(id: $accountId) {\n id\n member(id: $memberId) {\n ...UserFilter\n }\n members(limit: $limit, offset: $offset, search: $search) {\n edges {\n ...UserFilter\n }\n totalCount\n }\n }\n }\n"]);return v=function(){return e},e}var f=(0,d.Ps)(g()),I=(0,d.Ps)(v(),f);function M(e){var n,t,o,d,p,g=e.accountId,v=e.currentUser,f=e.defaultSelectedMemberId,M=e.ownedBySearch,y=(0,m.useRouter)(),w={selectedMemberId:f||v.id,search:f===v.id?"".concat(v.fullName," (you)"):void 0};M&&(w={selectedMemberId:f||"",search:void 0});var E=(0,l.useState)(!1),L=E[0],S=E[1],x=(0,l.useReducer)(h,w),B=x[0],k=B.search,A=B.selectedMemberId,D=x[1],F=(0,_.Z)(k,300),T=(0,c.a)(I,{notifyOnNetworkStatusChange:!0,onCompleted:function(e){var n,t;!L&&(null===e||void 0===e||null===(n=e.account)||void 0===n||null===(t=n.member)||void 0===t?void 0:t.id)&&(D({type:"UPDATE_SEARCH",search:Z(e.account.member,v)}),S(!0))},onError:function(e){(0,b.Z)("MemberFilter",e)},variables:{accountId:g,memberId:A,limit:10,offset:0,search:F}}),P=T.data,V=T.error,U=T.loading,R=T.fetchMore,N=T.networkStatus,O=(null===P||void 0===P?void 0:P.account.members.edges.map((function(e){return e.id===v.id?(0,r.Z)((0,i.Z)({},e),{name:"".concat(e.name," (you)")}):e})))||[],z=(null===P||void 0===P||null===(n=P.account)||void 0===n||null===(t=n.member)||void 0===t?void 0:t.id)?null===P||void 0===P||null===(o=P.account)||void 0===o?void 0:o.member:null,H=(0,l.useCallback)((function(e){(e.type===u.V.InputChange||e.type===u.V.FunctionOpenMenu||e.type===u.V.InputBlur||[6,7,13].includes(e.type))&&D({type:"UPDATE_SEARCH",search:e.inputValue})}),[D]),K=(0,l.useCallback)((function(e){null===e||void 0===e?(y.push("/app/zaps",void 0,{shallow:!0}),D({type:"UPDATE_MEMBER_AND_SEARCH",selectedMemberId:v.id,search:"".concat(v.fullName," (you)")}),C(g,v.fullName)):(y.push("/app/zaps?memberId=".concat(e.id),void 0,{shallow:!0}),D({type:"UPDATE_MEMBER_AND_SEARCH",selectedMemberId:e.id,search:Z(e,v)}),C(g,e.name))}),[D,g,v,y]),$=(0,l.useCallback)((function(e){D(null===e||void 0===e?{type:"UPDATE_MEMBER_AND_SEARCH",selectedMemberId:"",search:""}:{type:"UPDATE_MEMBER_AND_SEARCH",selectedMemberId:e.id,search:Z(e,v)})}),[D,v]);return{error:V,isLoading:U,isLoadingMore:N===s.I.fetchMore,members:O,onLoadMore:O.length<((null===P||void 0===P||null===(d=P.account)||void 0===d||null===(p=d.members)||void 0===p?void 0:p.totalCount)||0)?function(){R({updateQuery:function(e,n){var t,o,l,u,d,c=n.fetchMoreResult;return c?(0,r.Z)((0,i.Z)({},c),{account:(0,r.Z)((0,i.Z)({},c.account),{members:(0,r.Z)((0,i.Z)({},null===(t=c.account)||void 0===t?void 0:t.members),{edges:(0,a.Z)((null===(o=e.account)||void 0===o||null===(l=o.members)||void 0===l?void 0:l.edges)||[]).concat((0,a.Z)((null===(u=c.account)||void 0===u||null===(d=u.members)||void 0===d?void 0:d.edges)||[]))})})}):e},variables:{accountId:g,limit:10,offset:O.length,search:k}})}:void 0,onSearch:H,search:k,selectedItem:z,handleMemberChange:M?$:K,defaultMemberHasBeenSet:L}}var Z=function(e,n){return(null===e||void 0===e?void 0:e.id)!==n.id||e.name.endsWith("(you)")?y(e):"".concat(y(e)," (you)")},y=function(e){var n=e.name;return"string"===typeof n&&""!==n.trim()?n:e.email||""},C=function(e,n){(0,p.Z)({accountId:e,eventAction:"select",interactionName:n,systemName:"zap-management.MemberSearch"})}}}]);
//# sourceMappingURL=3885-a6d7d86272722c3f.js.map