Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swrve/dropdowns

Package Overview
Dependencies
Maintainers
9
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swrve/dropdowns - npm Package Compare versions

Comparing version 3.28.10 to 3.28.11

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [3.28.11](https://github.com/Swrve/ui-component-lib/compare/@swrve/dropdowns@3.28.10...@swrve/dropdowns@3.28.11) (2022-08-03)
**Note:** Version bump only for package @swrve/dropdowns
## [3.28.10](https://github.com/Swrve/ui-component-lib/compare/@swrve/dropdowns@3.28.8...@swrve/dropdowns@3.28.10) (2022-07-22)

@@ -8,0 +16,0 @@

2

dist/index.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("classnames"),require("lodash"),require("@swrve/icons"),require("downshift"),require("@swrve/core"),require("@swrve/offscreen"),require("react-apollo")):"function"==typeof define&&define.amd?define(["react","prop-types","classnames","lodash","@swrve/icons","downshift","@swrve/core","@swrve/offscreen","react-apollo"],t):"object"==typeof exports?exports["@swrve/dropdowns"]=t(require("react"),require("prop-types"),require("classnames"),require("lodash"),require("@swrve/icons"),require("downshift"),require("@swrve/core"),require("@swrve/offscreen"),require("react-apollo")):e["@swrve/dropdowns"]=t(e.react,e["prop-types"],e.classnames,e.lodash,e["@swrve/icons"],e.downshift,e["@swrve/core"],e["@swrve/offscreen"],e["react-apollo"])}(window,(function(e,t,r,n,o,a,i,l,c){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=9)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=a},function(e,t){e.exports=i},function(e,t){e.exports=l},function(e,t){e.exports=c},function(e,t,r){"use strict";r.r(t),r.d(t,"ComponentDropdown",(function(){return p})),r.d(t,"Dropdown",(function(){return j})),r.d(t,"SearchableDropdown",(function(){return B})),r.d(t,"SearchableChipDropdown",(function(){return _})),r.d(t,"AsyncDropdown",(function(){return Y})),r.d(t,"AsyncChipDropdown",(function(){return ae}));var n=r(0),o=r.n(n),a=r(2),i=r.n(a),l=r(5),c=r.n(l),u=r(1),s=function(e){var t=e.alignRight,r=e.children,n=e.itemToString,a=e.onChange,l=e.options;return o.a.createElement(c.a,{itemToString:n,onChange:a},(function(e){var n=e.getToggleButtonProps,a=e.getItemProps,c=e.isOpen,u=e.highlightedIndex;return o.a.createElement("div",{className:"relative"},r({getToggleButtonProps:n,isOpen:c}),c&&o.a.createElement("div",{className:i()("sw-component-dropdown",{"right-0":t})},l.map((function(e,t){return o.a.createElement("div",a({item:e,key:e.label,disabled:e.disabled,onClick:function(e){return e.stopPropagation()},className:i()("sw-component-dropdown-item hover:bg-gauloiseBlue-10 hover:text-gauloiseBlue-100",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":u===t})}),e.label)}))))}))};s.displayName="ButtonDropdown",s.propTypes={children:u.func,alignRight:u.bool,itemToString:u.func,onChange:u.func,options:u.array},s.defaultProps={alignRight:!1};var p=s,d=r(3),f=r(7),m=r(6),h=r(4);function g(e,t){return void 0===t&&(t="label"),Object(d.isString)(e)?e:Object(d.get)(e,t)}function b(e,t,r){return("dropdown item"+(t?" "+t:"")+" "+(Object(d.isString)(e)?e:g(e,r))).replace(/ /gi,"-").toLowerCase()}function y(e){return("dropdown item "+e).replace(/ /gi,"-").toLowerCase()}function v(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 w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(){return(O=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var x=function(e){var t=e.ariaLabel,r=void 0===t?"open menu":t,n=e.arrow,a=e.loading,l=e.className,u=e.debug,s=e.defaultHighlightedIndex,p=e.disabled,x=e.error,j=e.extraItemProps,E=e.labelKey,P=e.lockInPosition,k=e.menuMaxHeight,I=e.placement,N=void 0===I?"bottom-start":I,S=e.onChange,C=e.options,B=e.placeholder,L=e.truncateOptions,T=e.value,D=e.fullWidth,q=e.icon,H=e["data-automation"],M=function(e,t){return void 0===t&&(t="label"),Object(d.isArray)(e)?e.reduce((function(e,r){return Object(d.isArray)(r.value)?r.value.reduce((function(e,t){return[].concat(e,[t])}),[].concat(e,[{category:r[t]}])):[].concat(e,[r])}),[]):e}(C,E),R=function(e,t){return void 0===t&&(t="label"),Object(d.isArray)(e)?e.reduce((function(e,r){return Object(d.isArray)(r.value)?r.value.reduce((function(e,n){return[].concat(e,[b(n,r[t],t)])}),[].concat(e,[y(r[t])])):Object(d.isObject)(r)?[].concat(e,[y(r[t])]):[].concat(e,[y(r)])}),[]):e}(C,E),z=H||"dropdown",_=i()(D?"block relative":"inline-block",l),G=function(){return o.a.createElement(h.Icon,{name:q,title:q,size:"medium",className:"mr-2 align-middle text-gauloiseBlue-100"})};return o.a.createElement(c.a,{onChange:function(e){return S(Object(d.get)(e,"value",e))},defaultHighlightedIndex:s,selectedItem:T,itemToString:function(e){return null==e?"":g(e,E)},render:function(e){var t=e.getItemProps,l=e.getToggleButtonProps,c=e.isOpen,s=e.selectedItem,b=e.highlightedIndex;return o.a.createElement("div",{className:_,"data-automation":z},o.a.createElement(f.Manager,null,o.a.createElement("div",null,o.a.createElement(f.Reference,null,(function(e){var t=e.ref;return o.a.createElement("button",O({"data-automation":"dropdown-button",ref:t},l({"aria-label":r,className:i()(["relative sw-dropdown bg-cloudWhite text-sm text-left rounded border border-porcelain hover:border-gauloiseBlue-100 py-2 px-4 pr-10 leading-button truncate",{"opacity-50 cursor-not-allowed":p,"border-radicalRed-100 hover:border-radicalRed-100":x,"cursor-wait":a},{"w-full":D}]),disabled:p})),g(s,E)?o.a.createElement("span",{className:"w-full text-pickledBlack"},q&&o.a.createElement(G,null),g(s,E)):o.a.createElement("span",{className:"w-full text-bombayGrey"},q&&o.a.createElement(G,null),B),a?o.a.createElement(m.Loader,{className:"absolute sw-dropdown-loader","data-automation":"sw-dropdown-loader",size:"4"}):o.a.createElement(h.Icon,{name:"arrow",size:"small",className:["absolute text-gauloiseBlue-100 sw-dropdown-arrow",{"sw-rotate-dropdown-arrow":c}]}))})),(c||u)&&o.a.createElement(f.Frame,{arrow:n,className:{"w-full":D},lockInPosition:P,maxWidth:500,minWidth:!0,placement:N},o.a.createElement("div",{className:"overflow-x-auto",style:{maxHeight:k?k+"px":"inherit"}},Object(d.isEmpty)(M)?o.a.createElement("div",{className:"px-4 py-1 text-sm text-left text-regentGrey"},"No matching options."):M.map((function(e,r){if(Object(d.get)(e,"category",void 0))return o.a.createElement("div",t({disabled:!0,"data-automation":R[r],item:e,key:r,className:"py-2 text-xs uppercase text-jungleBlack"}),e.category);var n=Object(d.get)(e,"subLabel"),a=!Object(d.isEmpty)(n);return o.a.createElement("div",t(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach((function(t){w(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({"data-automation":R[r],item:e,key:r,className:i()("cursor-pointer py-3 px-4 text-sm rounded break-words",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":b===r&&g(s,E)!==g(e,E),"bg-gauloiseBlue-20 text-gauloiseBlue-100 font-bold":g(s,E)===g(e,E),"text-regentGrey":!a,"text-pickledBlack":a,truncate:L})},j)),g(e,E),a&&o.a.createElement(o.a.Fragment,null," - ",o.a.createElement("span",{className:i()("font-normal text-regentGrey",{"text-gauloiseBlue-100":b===r||g(s,E)===g(e,E)})},n)))})))))))}})};x.displayName="Dropdown",x.propTypes={arrow:u.bool,icon:u.string,loading:u.bool,labelKey:u.string,disabled:u.bool,extraItemProps:u.object,error:u.bool,options:u.array,lockInPosition:u.bool,menuMaxHeight:u.number,fullWidth:u.bool,placeholder:u.string,placement:u.string,value:Object(u.oneOfType)([u.string,u.number,u.bool,u.object]),defaultHighlightedIndex:u.number,truncateOptions:u.bool,onChange:u.func.isRequired,selectByValue:u.bool,"data-automation":u.string},x.defaultProps={arrow:!1,loading:!1,placeholder:"select",labelKey:"label",defaultHighlightedIndex:0,disabled:!1,error:!1,extraItemProps:{},lockInPosition:!0,menuMaxHeight:310,fullWidth:!1,options:[],truncateOptions:!1,value:""};var j=x;var E=function(e){var t=e.items,r=e.inputValue,n=e.highlightedIndex,a=e.menuMaxHeight,l=e.selectedItem,c=e.getItemProps,u=e.truncateOptions,s=void 0!==u&&u,p=e.filterOptions,d=(void 0===p||p?t.filter((function(e){return!r||e.label.match(new RegExp((void 0===(t=r)&&(t=""),t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")),"i"));var t})):t).map((function(e,t){return o.a.createElement("div",c({item:e,index:t,key:e.key||e.label,className:i()("cursor-pointer py-3 px-4 text-sm text-regentGrey rounded flex items-center",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":n===t&&l.label!==e.label,"bg-gauloiseBlue-20 text-gauloiseBlue-100 font-bold":e.key?l.key===e.key:l.label===e.label,truncate:s}),onClick:function(e){return e.stopPropagation()}}),e.icon&&o.a.createElement(h.Icon,{className:"flex-shrink-0 mr-2",name:e.icon,size:"small"})," ",e.label)}));return o.a.createElement("div",{className:"absolute w-full p-2 mt-2 overflow-y-auto border rounded shadow border-porcelain bg-cloudWhite sw-searchable-options",style:{maxHeight:a?a+"px":"inherit"}},d.length>0?d:o.a.createElement("div",{className:"px-4 py-3 text-sm text-left rounded text-regentGrey"},"No matching options."))};E.propTypes={menuMaxHeight:u.number,truncateOptions:u.bool};var P=E;function k(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 I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?k(Object(r),!0).forEach((function(t){N(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function N(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function S(e,t){return(S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var C=function(e){var t,r;function n(t){var r;return(r=e.call(this,t)||this).standardizeOption=r.standardizeOption.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,S(t,r);var a=n.prototype;return a.standardizeOption=function(e){var t=this.props.labelKey;if(e!==Object(e))return{label:String(e),value:e};if(t){if(!e.hasOwnProperty(t))throw new Error('labelKey property "'+t+'" was not found on the following option: '+JSON.stringify(e,null,2));return I(I({label:String(e[t]),value:e},e.icon&&{icon:e.icon}),e.key&&{key:e.key})}if(e.label)return{label:String(e.label),value:e};throw new Error("The following option could not be processed by Dropdown: "+JSON.stringify(e,null,2))},a.render=function(){var e=this,t=this.props,r=t.disabled,n=t.error,a=t.menuMaxHeight,l=t.options,u=t.placeholder,s=t.value,p=t.truncateOptions,d=t.onChange,f=t["data-automation"]||"dropdown";return o.a.createElement(c.a,{onChange:function(e){d(null===e?"":e.value)},defaultHighlightedIndex:0,selectedItem:this.standardizeOption(s),itemToString:function(e){return null==e?"":e.label},render:function(t){var c=t.getInputProps,d=t.getItemProps,m=t.isOpen,g=t.inputValue,b=t.highlightedIndex,y=t.selectedItem,v=t.openMenu,w=t.toggleMenu,O=t.clearSelection;return o.a.createElement("div",{className:"relative "+(m?"z-5":"z-0"),"data-automation":f},o.a.createElement("div",{className:"relative rounded sw-searchable-dropdown bg-cloudWhite"},o.a.createElement("input",c({className:i()("relative z-20 w-full bg-transparent text-sm text-pickledBlack border border-porcelain rounded py-2 pl-4 pr-10 leading-button",{"opacity-50 cursor-not-allowed":r,"border-radicalRed-100 hover:border-radicalRed-100":n}),disabled:r,placeholder:u,onClick:function(){return!m&&w()},ref:function(t){return e.searchableInput=t}})),s?o.a.createElement("span",{className:"absolute z-50 p-2 cursor-pointer sw-searchable-dropdown-cancel",onClick:function(){O(),e.searchableInput.focus(),v()}},o.a.createElement(h.Icon,{name:"close",size:"small",className:"text-gauloiseBlue-100"})):o.a.createElement(h.Icon,{name:"arrow",size:"small",className:["text-gauloiseBlue-100 absolute z-0 cursor-pointer sw-searchable-dropdown-arrow",{"sw-rotate-searchable-dropdown-arrow":m}]})),m&&o.a.createElement(P,{items:l.map(e.standardizeOption),inputValue:g,highlightedIndex:b,menuMaxHeight:a,getItemProps:d,truncateOptions:p,selectedItem:y}))}})},n}(o.a.Component);C.displayName="SearchableDropdown",C.propTypes={labelKey:u.string,disabled:u.bool,error:u.bool,menuMaxHeight:u.number,options:u.array,placeholder:u.string,value:Object(u.oneOfType)([u.string,u.number,u.bool,u.object]),truncateOptions:u.bool,onChange:u.func.isRequired,"data-automation":u.string},C.defaultProps={disabled:!1,error:!1,menuMaxHeight:null,options:[],truncateOptions:!1,value:""};var B=C;var L=function(e){var t=e.items,r=e.inputValue,n=e.highlightedIndex,a=e.menuMaxHeight,l=e.selectedItems,c=e.getItemProps,u=e.truncateOptions,s=t.filter((function(e){return("ALL_CHECKBOX_KEY"!==e.key||!r)&&(!r||e.label.match(new RegExp((void 0===(t=r)&&(t=""),t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")),"i")));var t})).map((function(e,t){var r="ALL_CHECKBOX_KEY"===e.key?0===l.length:l.some((function(t){return e.key?t.key===e.key:t.name===e.label}));return o.a.createElement("div",c({item:e,index:t,key:e.key||e.label,className:i()("cursor-pointer text-sm text-regentGrey rounded flex items-center my-1",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":n===t&&!r,"bg-gauloiseBlue-20 text-gauloiseBlue-100":r,truncate:u}),onClick:function(e){return e.stopPropagation()}}),o.a.createElement(m.CheckboxListItem,{style:{margin:0},className:"w-full",labelPosition:"left",key:e.key,label:e.label,icon:e.icon,checked:r,"data-automation":(e.key||e.label)+"-data-automation",noBackground:!0}))}));return o.a.createElement("div",{className:"absolute w-full p-1 mt-2 overflow-y-auto border rounded shadow border-porcelain bg-cloudWhite",style:{maxHeight:a?a+"px":"inherit"}},s.length>0?s:o.a.createElement("div",{className:"px-4 py-3 text-sm text-left rounded text-regentGrey"},"No matching options."))};L.propTypes={getItemProps:u.func.isRequired,highlightedIndex:u.number.isRequired,inputValue:u.string,items:u.array.isRequired,menuMaxHeight:u.number,selectedItems:u.array.isRequired,truncateOptions:u.bool};var T=L,D=["autoFocus","disabled","error","labelKey","menuMaxHeight","onChange","onDelete","options","placeholder","values","truncateOptions","itemToString","stateReducer","delimiter","checkboxes"];function q(){return(q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function H(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(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var z=function(e){var t=e.autoFocus,r=void 0!==t&&t,a=e.disabled,l=void 0!==a&&a,u=(e.error,e.labelKey),s=void 0===u?"name":u,p=e.menuMaxHeight,d=void 0===p?null:p,f=e.onChange,g=e.onDelete,b=e.options,y=void 0===b?[]:b,v=e.placeholder,w=e.values,O=void 0===w?[]:w,x=e.truncateOptions,j=void 0!==x&&x,E=e.itemToString,k=void 0===E?function(e){return null===e?"":e.label}:E,I=e.stateReducer,N=e.delimiter,S=e.checkboxes,C=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,D),B=Object(n.useRef)(),L=Object(n.useCallback)((function(e,t,r){e.stopPropagation(),g(t,r,e),B.current.focus()}),[g]),H=function(e){if(e!==Object(e))return{label:String(e),value:e};if(s){if(!e.hasOwnProperty(s))throw new Error('labelKey property "'+s+'" was not found on the following option: '+JSON.stringify(e,null,2));return M(M({label:String(e[s]),value:e},e.icon&&{icon:e.icon}),e.key&&{key:e.key})}if(e.label)return{label:String(e.label),value:e};throw new Error("The following option could not be processed by Dropdown: "+JSON.stringify(e,null,2))},R=O.length>0,z=Object(n.useMemo)((function(){return i()("relative sw-searchable-dropdown hover:border-secondary-100 focus:border-secondary-100 bg-cloudWhite border border-porcelain rounded p-2 pl-4 pr-10",{"pb-1":R})}),[R]);return o.a.createElement(c.a,{defaultHighlightedIndex:0,onChange:function(e){return f(null===e?"":e.value)},selectedItem:H(""),itemToString:k,stateReducer:I,render:function(e){var t=e.getInputProps,n=e.getItemProps,a=e.isOpen,c=e.inputValue,u=e.highlightedIndex,s=e.selectedItem,p=e.openMenu,f=e.toggleMenu;return o.a.createElement("div",q({className:i()("relative",{"z-5":a,"z-0":!a,"cursor-not-allowed":l}),onClick:function(){B.current.focus(),!l&&p()}},C),o.a.createElement("div",{className:z},O.map((function(e,t){return o.a.createElement("span",{key:e.key||e.id},N&&t>=1&&o.a.createElement("span",{className:"mr-1 text-sm text-jungleBlack"},N),o.a.createElement(m.Chip,{onDelete:function(t,r){return L(t,r,e)},id:e.id,className:"mb-1 mr-1"},e.icon&&o.a.createElement(h.Icon,{className:"flex-shrink-0 mr-2",name:e.icon,size:"small"}),e.name))})),o.a.createElement("input",t({className:i()("z-20 bg-transparent text-sm text-pickledBlack leading-button inline-block",{"opacity-50 cursor-not-allowed":l,checkboxes:S}),style:{width:R?"50px":"150px"},disabled:l,autoFocus:r,placeholder:R?"":v,onClick:function(){return!a&&!l&&f()},ref:B})),o.a.createElement(h.Icon,{name:"arrow",size:"small",onClick:function(e){e.stopPropagation(),B.current.focus(),!l&&f()},className:i()("text-gauloiseBlue-100 absolute z-0 cursor-pointer sw-searchable-dropdown-arrow",{"sw-rotate-searchable-dropdown-arrow":a,"cursor-not-allowed":l})})),a&&(S?o.a.createElement(T,{items:y.map(H),inputValue:c,highlightedIndex:u,menuMaxHeight:d,getItemProps:n,truncateOptions:j,selectedItems:O,allCheckboxLabel:v}):o.a.createElement(P,{items:y.map(H),inputValue:c,highlightedIndex:u,menuMaxHeight:d,getItemProps:n,truncateOptions:j,selectedItem:s})))}})};z.propTypes={labelKey:u.string,disabled:u.bool,error:u.bool,menuMaxHeight:u.number,options:u.array,placeholder:u.string,values:Object(u.oneOfType)([u.string,u.array]),truncateOptions:u.bool,onChange:u.func.isRequired,itemToString:u.func,delimiter:u.string,checkboxes:u.bool};var _=z,G=r(8);function K(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 V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){F(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function F(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function W(e,t){return(W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var A=function(e){var t,r;function n(){return e.apply(this,arguments)||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,W(t,r),n.prototype.render=function(){var e=this.props,t=e["data-automation"],r=e.query,n=e.variables,a=e.labelKey,l=e.value,u=e.onChange,s=e.accessor,p=e.placeholder,d=e.disabled;return o.a.createElement(c.a,{key:l,stateReducer:function(e,t){switch(t.type){case c.a.stateChangeTypes.mouseUp:return V(V({},t),{},{inputValue:e.inputValue});default:return t}},defaultInputValue:l,itemToString:function(e){return null==e?"":g(e,a)},onChange:function(e){return u(e)}},(function(e){var l=e.isOpen,c=e.openMenu,u=e.inputValue,h=e.getInputProps,b=e.getItemProps,y=e.highlightedIndex;e.getToggleButtonProps;return o.a.createElement("div",{className:"z-50"},o.a.createElement(f.Manager,null,o.a.createElement("div",null,o.a.createElement(f.Reference,null,(function(e){var r=e.ref;return o.a.createElement("div",{ref:r},o.a.createElement(m.SearchInput,h({value:u,onFocus:c,"data-automation":t,className:"w-full",placeholder:p,disabled:d})))})),l&&o.a.createElement(f.Frame,{minWidth:!0,maxHeight:200,lockInPosition:!0,placement:"bottom-start",arrow:!1},o.a.createElement("div",{"data-automation":t+"-frame",className:"overflow-x-auto",style:{maxHeight:"160px"}},o.a.createElement(G.Query,{query:r,variables:V(V({},n),{},{filter:u})},(function(e){var r=e.loading,n=e.error,l=e.data;return r?o.a.createElement("div",{"data-automation":t+"-loading",className:"cursor-pointer py-3 px-4 text-regentGrey text-sm rounded text center"},"Searching..."):n?o.a.createElement("div",{className:"cursor-pointer py-3 px-4 text-regentGrey text-sm rounded text center"},"Network error"):0===s(l).length?o.a.createElement("div",{"data-automation":t+"-no-results",className:"cursor-pointer py-3 px-4 text-regentGrey text-sm rounded text center"},"No results"):o.a.createElement("div",null,s(l).map((function(e,r){return o.a.createElement("div",b({item:e,key:r,"data-automation":t+"-item-"+r,className:i()("text-regentGrey hover:text-gauloiseBlue-100 text-xs","py-3 px-4","hover:bg-gauloiseBlue-10 rounded","cursor-pointer",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":y===r})}),g(e,a))})))})))))))}))},n}(n.Component);A.defaultProps={placeholder:"Search",labelKey:"label",disabled:!1},A.propTypes={"data-automation":u.string,value:u.string,labelKey:u.string,placeholder:u.string,query:u.object.isRequired,accessor:u.func.isRequired,variables:u.object.isRequired,onChange:u.func.isRequired,disabled:u.bool};var Y=A,J=["autoFocus","disabled","labelKey","menuMaxHeight","onChange","onDelete","placeholder","values","truncateOptions","stateReducer","delimiter","query","selector","value","variables","filter","className","chipTheme"];function $(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */$=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=t&&t.prototype instanceof p?t:p,a=Object.create(o.prototype),i=new j(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return P()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var l=w(i,r);if(l){if(l===s)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===s)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,i),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var s={};function p(){}function d(){}function f(){}var m={};l(m,o,(function(){return this}));var h=Object.getPrototypeOf,g=h&&h(h(E([])));g&&g!==t&&r.call(g,o)&&(m=g);var b=f.prototype=p.prototype=Object.create(m);function y(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,l){var c=u(e[o],e,a);if("throw"!==c.type){var s=c.arg,p=s.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,i,l)}),(function(e){n("throw",e,i,l)})):t.resolve(p).then((function(e){s.value=e,i(s)}),(function(e){return n("throw",e,i,l)}))}l(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return s;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,s;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,s):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,s)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function E(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:P}}function P(){return{value:void 0,done:!0}}return d.prototype=f,l(b,"constructor",f),l(f,"constructor",d),d.displayName=l(f,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,i,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},y(v.prototype),l(v.prototype,a,(function(){return this})),e.AsyncIterator=v,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new v(c(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},y(b),l(b,i,"Generator"),l(b,o,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=E,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,s):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),s},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),s}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},e}function Q(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 X(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Z(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,o)}function ee(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){Z(a,n,o,i,l,"next",e)}function l(e){Z(a,n,o,i,l,"throw",e)}i(void 0)}))}}function te(){return(te=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var re=function(e,t){return e!==Object(e)?{label:String(e),value:e}:t?{label:String(e[t]),value:e}:e.label?{label:String(e.label),value:e}:void 0},ne=function(e){var t=e.autoFocus,r=void 0!==t&&t,a=e.disabled,l=void 0!==a&&a,u=e.labelKey,s=void 0===u?"name":u,p=e.menuMaxHeight,d=void 0===p?300:p,f=e.onChange,g=e.onDelete,b=e.placeholder,y=e.values,v=void 0===y?[]:y,w=e.truncateOptions,O=void 0!==w&&w,x=e.stateReducer,j=e.delimiter,E=e.query,P=e.selector,k=e.value,I=void 0===k?"":k,N=e.variables,S=void 0===N?{}:N,C=e.filter,B=void 0===C?function(e){return!v.map((function(e){return e.id})).includes(e.value.id)}:C,L=e.className,T=e.chipTheme,D=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,J),q=Object(n.useRef)(),H=Object(n.useCallback)((function(e,t,r){e.stopPropagation(),g(t,r,e),q.current.focus()}),[g]),M=v.length>0,R=Object(n.useMemo)((function(){return i()("relative sw-searchable-dropdown hover:border-secondary-100 focus:border-secondary-100 bg-cloudWhite border border-porcelain rounded p-2 pl-4 pr-10",{"pb-1":M})}),[M]);return o.a.createElement(c.a,{defaultHighlightedIndex:0,onChange:function(e){return f(null===e?"":e.value)},selectedItem:re(I),itemToString:function(e){return null===e?"":e.label},stateReducer:x,render:function(e){var t=e.getInputProps,n=e.getItemProps,a=e.isOpen,c=e.inputValue,u=e.highlightedIndex,p=e.selectedItem,f=e.openMenu,g=e.toggleMenu,y=e.clearSelection;return o.a.createElement("div",te({className:i()("relative "+(a?"z-5":"z-0"),L),onClick:function(){q.current.focus(),f()}},D),o.a.createElement("div",{className:R},v.map((function(e,t){return o.a.createElement("span",{key:e.key||e.id},j&&t>=1&&o.a.createElement("span",{className:"mr-1 text-sm text-jungleBlack"},j),o.a.createElement(m.Chip,{onDelete:function(t,r){return H(t,r,e)},id:e.id,theme:T,className:"mb-1 mr-1"},e.icon&&o.a.createElement(h.Icon,{className:"flex-shrink-0 mr-2",name:e.icon,size:"small"}),e.name))})),o.a.createElement("input",t({className:i()("z-20 bg-transparent text-sm text-pickledBlack leading-button inline-block",{"opacity-50 cursor-not-allowed":l}),style:{width:M?"50px":"150px"},disabled:l,autoFocus:r,placeholder:M?"":b,onClick:function(){return!a&&g()},ref:q})),I?o.a.createElement("span",{className:"absolute z-50 p-2 cursor-pointer sw-searchable-dropdown-cancel",onClick:function(e){e.stopPropagation(),y(),q.current.focus(),f()}},o.a.createElement(h.Icon,{name:"close",size:"small",className:"text-gauloiseBlue-100"})):o.a.createElement(h.Icon,{name:"arrow",size:"small",onClick:function(e){e.stopPropagation(),q.current.focus(),g()},className:["text-gauloiseBlue-100 absolute z-0 cursor-pointer sw-searchable-dropdown-arrow",{"sw-rotate-searchable-dropdown-arrow":a}]})),o.a.createElement(oe,{isOpen:a,inputValue:c,highlightedIndex:u,labelKey:s,menuMaxHeight:d,getItemProps:n,truncateOptions:O,selectedItem:p,query:E,selector:P,values:v,variables:S,filter:B}))}})},oe=function(e){var t=e.query,r=e.isOpen,a=e.inputValue,i=e.highlightedIndex,l=e.menuMaxHeight,c=e.getItemProps,u=e.labelKey,s=e.truncateOptions,p=e.selectedItem,f=e.selector,m=e.filter,h=e.variables,g=Object(G.useLazyQuery)(t),b=g[0],y=g[1],v=y.loading,w=y.data,O=Object(n.useState)(a),x=O[0],j=O[1],E=o.a.useCallback(Object(d.debounce)((function(e){return k.apply(this,arguments)}),200),[]);function k(){return(k=ee($().mark((function e(t){return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b(t);case 2:j(t.variables.filter);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}o.a.useEffect((function(){E({variables:X(X({},h),{},{filter:a})})}),[a,E,h]);var I=x!==a;if(r&&(v||I))return o.a.createElement("div",{className:"absolute w-full p-2 mt-2 overflow-y-auto border rounded shadow border-porcelain bg-cloudWhite",style:{maxHeight:l?l+"px":"inherit"}},Array.from({length:10}).map((function(e,t){return o.a.createElement("div",{key:t,className:"flex items-center px-4 py-3 text-sm rounded cursor-wait text-regentGrey"},o.a.createElement("div",{className:"w-full h-4 sw-loader-skeleton sw-loader-single"}))})));var N=(Object(d.isEmpty)(w)||v||I?[]:Object(d.get)(w,f,[]).map((function(e){return re(e,u)}))).filter(m);return r&&o.a.createElement(P,{items:N,inputValue:a,highlightedIndex:i,menuMaxHeight:l,getItemProps:c,truncateOptions:s,selectedItem:p,filterOptions:!1})};ne.propTypes={labelKey:u.string,disabled:u.bool,menuMaxHeight:u.number,options:u.array,placeholder:u.string,values:Object(u.oneOfType)([u.string,u.array]),truncateOptions:u.bool,onChange:u.func.isRequired,delimiter:u.string,filter:u.func,chipTheme:Object(u.oneOf)(["primary","secondary","warning","radicalRed","dodgerBlue","pictonBlue","javaGreen","limaGreen","frenchRoseRed","sunglowYellow","electricViolet","royalBlue","lazyLavender","orangePeel","cloudWhite"])},ne.displayName="AsyncChipDropdown";var ae=ne}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("classnames"),require("lodash"),require("@swrve/icons"),require("downshift"),require("@swrve/core"),require("@swrve/offscreen"),require("react-apollo")):"function"==typeof define&&define.amd?define(["react","prop-types","classnames","lodash","@swrve/icons","downshift","@swrve/core","@swrve/offscreen","react-apollo"],t):"object"==typeof exports?exports["@swrve/dropdowns"]=t(require("react"),require("prop-types"),require("classnames"),require("lodash"),require("@swrve/icons"),require("downshift"),require("@swrve/core"),require("@swrve/offscreen"),require("react-apollo")):e["@swrve/dropdowns"]=t(e.react,e["prop-types"],e.classnames,e.lodash,e["@swrve/icons"],e.downshift,e["@swrve/core"],e["@swrve/offscreen"],e["react-apollo"])}(window,(function(e,t,r,n,o,a,i,l,c){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=9)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=a},function(e,t){e.exports=i},function(e,t){e.exports=l},function(e,t){e.exports=c},function(e,t,r){"use strict";r.r(t),r.d(t,"ComponentDropdown",(function(){return p})),r.d(t,"Dropdown",(function(){return j})),r.d(t,"SearchableDropdown",(function(){return B})),r.d(t,"SearchableChipDropdown",(function(){return _})),r.d(t,"AsyncDropdown",(function(){return Y})),r.d(t,"AsyncChipDropdown",(function(){return ae}));var n=r(0),o=r.n(n),a=r(2),i=r.n(a),l=r(5),c=r.n(l),u=r(1),s=function(e){var t=e.alignRight,r=e.children,n=e.itemToString,a=e.onChange,l=e.options;return o.a.createElement(c.a,{itemToString:n,onChange:a},(function(e){var n=e.getToggleButtonProps,a=e.getItemProps,c=e.isOpen,u=e.highlightedIndex;return o.a.createElement("div",{className:"relative"},r({getToggleButtonProps:n,isOpen:c}),c&&o.a.createElement("div",{className:i()("sw-component-dropdown",{"right-0":t})},l.map((function(e,t){return o.a.createElement("div",a({item:e,key:e.label,disabled:e.disabled,onClick:function(e){return e.stopPropagation()},className:i()("sw-component-dropdown-item hover:bg-gauloiseBlue-10 hover:text-gauloiseBlue-100",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":u===t})}),e.label)}))))}))};s.displayName="ButtonDropdown",s.propTypes={children:u.func,alignRight:u.bool,itemToString:u.func,onChange:u.func,options:u.array},s.defaultProps={alignRight:!1};var p=s,d=r(3),f=r(7),m=r(6),h=r(4);function g(e,t){return void 0===t&&(t="label"),Object(d.isString)(e)?e:Object(d.get)(e,t)}function b(e,t,r){return("dropdown item"+(t?" "+t:"")+" "+(Object(d.isString)(e)?e:g(e,r))).replace(/ /gi,"-").toLowerCase()}function y(e){return("dropdown item "+e).replace(/ /gi,"-").toLowerCase()}function v(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 w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(){return(O=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var x=function(e){var t=e.ariaLabel,r=void 0===t?"open menu":t,n=e.arrow,a=e.loading,l=e.className,u=e.debug,s=e.defaultHighlightedIndex,p=e.disabled,x=e.error,j=e.extraItemProps,E=e.labelKey,P=e.lockInPosition,k=e.menuMaxHeight,I=e.placement,N=void 0===I?"bottom-start":I,S=e.onChange,C=e.options,B=e.placeholder,q=e.truncateOptions,L=e.value,T=e.fullWidth,D=e.icon,H=e["data-automation"],M=function(e,t){return void 0===t&&(t="label"),Object(d.isArray)(e)?e.reduce((function(e,r){return Object(d.isArray)(r.value)?r.value.reduce((function(e,t){return[].concat(e,[t])}),[].concat(e,[{category:r[t]}])):[].concat(e,[r])}),[]):e}(C,E),R=function(e,t){return void 0===t&&(t="label"),Object(d.isArray)(e)?e.reduce((function(e,r){return Object(d.isArray)(r.value)?r.value.reduce((function(e,n){return[].concat(e,[b(n,r[t],t)])}),[].concat(e,[y(r[t])])):Object(d.isObject)(r)?[].concat(e,[y(r[t])]):[].concat(e,[y(r)])}),[]):e}(C,E),z=H||"dropdown",_=i()(T?"block relative":"inline-block",l),G=function(){return o.a.createElement(h.Icon,{name:D,title:D,size:"medium",className:"mr-2 align-middle text-gauloiseBlue-100"})};return o.a.createElement(c.a,{onChange:function(e){return S(Object(d.get)(e,"value",e))},defaultHighlightedIndex:s,selectedItem:L,itemToString:function(e){return null==e?"":g(e,E)},render:function(e){var t=e.getItemProps,l=e.getToggleButtonProps,c=e.isOpen,s=e.selectedItem,b=e.highlightedIndex;return o.a.createElement("div",{className:_,"data-automation":z},o.a.createElement(f.Manager,null,o.a.createElement("div",null,o.a.createElement(f.Reference,null,(function(e){var t=e.ref;return o.a.createElement("button",O({"data-automation":"dropdown-button",ref:t},l({"aria-label":r,className:i()(["relative sw-dropdown bg-cloudWhite text-sm text-left rounded border border-porcelain hover:border-gauloiseBlue-100 py-2 px-4 pr-10 leading-button truncate",{"opacity-50 cursor-not-allowed":p,"border-radicalRed-100 hover:border-radicalRed-100":x,"cursor-wait":a},{"w-full":T}]),disabled:p})),g(s,E)?o.a.createElement("span",{className:"w-full text-pickledBlack"},D&&o.a.createElement(G,null),g(s,E)):o.a.createElement("span",{className:"w-full text-bombayGrey"},D&&o.a.createElement(G,null),B),a?o.a.createElement(m.Loader,{className:"absolute sw-dropdown-loader","data-automation":"sw-dropdown-loader",size:"4"}):o.a.createElement(h.Icon,{name:"arrow",size:"small",className:["absolute text-gauloiseBlue-100 sw-dropdown-arrow",{"sw-rotate-dropdown-arrow":c}]}))})),(c||u)&&o.a.createElement(f.Frame,{arrow:n,className:{"w-full":T},lockInPosition:P,maxWidth:500,minWidth:!0,placement:N},o.a.createElement("div",{className:"overflow-x-auto",style:{maxHeight:k?k+"px":"inherit"}},Object(d.isEmpty)(M)?o.a.createElement("div",{className:"px-4 py-1 text-sm text-left text-regentGrey"},"No matching options."):M.map((function(e,r){if(Object(d.get)(e,"category",void 0))return o.a.createElement("div",t({disabled:!0,"data-automation":R[r],item:e,key:r,className:"py-2 text-xs uppercase text-jungleBlack"}),e.category);var n=Object(d.get)(e,"subLabel"),a=!Object(d.isEmpty)(n);return o.a.createElement("div",t(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach((function(t){w(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({"data-automation":R[r],item:e,key:r,className:i()("cursor-pointer py-3 px-4 text-sm rounded break-words",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":b===r&&g(s,E)!==g(e,E),"bg-gauloiseBlue-20 text-gauloiseBlue-100 font-bold":g(s,E)===g(e,E),"text-regentGrey":!a,"text-pickledBlack":a,truncate:q})},j)),g(e,E),a&&o.a.createElement(o.a.Fragment,null," - ",o.a.createElement("span",{className:i()("font-normal text-regentGrey",{"text-gauloiseBlue-100":b===r||g(s,E)===g(e,E)})},n)))})))))))}})};x.displayName="Dropdown",x.propTypes={arrow:u.bool,icon:u.string,loading:u.bool,labelKey:u.string,disabled:u.bool,extraItemProps:u.object,error:u.bool,options:u.array,lockInPosition:u.bool,menuMaxHeight:u.number,fullWidth:u.bool,placeholder:u.string,placement:u.string,value:Object(u.oneOfType)([u.string,u.number,u.bool,u.object]),defaultHighlightedIndex:u.number,truncateOptions:u.bool,onChange:u.func.isRequired,selectByValue:u.bool,"data-automation":u.string},x.defaultProps={arrow:!1,loading:!1,placeholder:"select",labelKey:"label",defaultHighlightedIndex:0,disabled:!1,error:!1,extraItemProps:{},lockInPosition:!0,menuMaxHeight:310,fullWidth:!1,options:[],truncateOptions:!1,value:""};var j=x;var E=function(e){var t=e.items,r=e.inputValue,n=e.highlightedIndex,a=e.menuMaxHeight,l=e.selectedItem,c=e.getItemProps,u=e.truncateOptions,s=void 0!==u&&u,p=e.filterOptions,d=(void 0===p||p?t.filter((function(e){return!r||e.label.match(new RegExp((void 0===(t=r)&&(t=""),t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")),"i"));var t})):t).map((function(e,t){return o.a.createElement("div",c({item:e,index:t,key:e.key||e.label,className:i()("cursor-pointer py-3 px-4 text-sm text-regentGrey rounded flex items-center",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":n===t&&l.label!==e.label,"bg-gauloiseBlue-20 text-gauloiseBlue-100 font-bold":e.key?l.key===e.key:l.label===e.label,truncate:s}),onClick:function(e){return e.stopPropagation()}}),e.icon&&o.a.createElement(h.Icon,{className:"flex-shrink-0 mr-2",name:e.icon,size:"small"})," ",e.label)}));return o.a.createElement("div",{className:"absolute w-full p-2 mt-2 overflow-y-auto border rounded shadow border-porcelain bg-cloudWhite sw-searchable-options",style:{maxHeight:a?a+"px":"inherit"}},d.length>0?d:o.a.createElement("div",{className:"px-4 py-3 text-sm text-left rounded text-regentGrey"},"No matching options."))};E.propTypes={menuMaxHeight:u.number,truncateOptions:u.bool};var P=E;function k(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 I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?k(Object(r),!0).forEach((function(t){N(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function N(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function S(e,t){return(S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var C=function(e){var t,r;function n(t){var r;return(r=e.call(this,t)||this).standardizeOption=r.standardizeOption.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,S(t,r);var a=n.prototype;return a.standardizeOption=function(e){var t=this.props.labelKey;if(e!==Object(e))return{label:String(e),value:e};if(t){if(!e.hasOwnProperty(t))throw new Error('labelKey property "'+t+'" was not found on the following option: '+JSON.stringify(e,null,2));return I(I({label:String(e[t]),value:e},e.icon&&{icon:e.icon}),e.key&&{key:e.key})}if(e.label)return{label:String(e.label),value:e};throw new Error("The following option could not be processed by Dropdown: "+JSON.stringify(e,null,2))},a.render=function(){var e=this,t=this.props,r=t.disabled,n=t.error,a=t.menuMaxHeight,l=t.options,u=t.placeholder,s=t.value,p=t.truncateOptions,d=t.onChange,f=t["data-automation"]||"dropdown";return o.a.createElement(c.a,{onChange:function(e){d(null===e?"":e.value)},defaultHighlightedIndex:0,selectedItem:this.standardizeOption(s),itemToString:function(e){return null==e?"":e.label},render:function(t){var c=t.getInputProps,d=t.getItemProps,m=t.isOpen,g=t.inputValue,b=t.highlightedIndex,y=t.selectedItem,v=t.openMenu,w=t.toggleMenu,O=t.clearSelection;return o.a.createElement("div",{className:"relative "+(m?"z-5":"z-0"),"data-automation":f},o.a.createElement("div",{className:"relative rounded sw-searchable-dropdown bg-cloudWhite"},o.a.createElement("input",c({className:i()("relative z-20 w-full bg-transparent text-sm text-pickledBlack border border-porcelain rounded py-2 pl-4 pr-10 leading-button",{"opacity-50 cursor-not-allowed":r,"border-radicalRed-100 hover:border-radicalRed-100":n}),disabled:r,placeholder:u,onClick:function(){return!m&&w()},ref:function(t){return e.searchableInput=t}})),s?o.a.createElement("span",{className:"absolute z-50 p-2 cursor-pointer sw-searchable-dropdown-cancel",onClick:function(){O(),e.searchableInput.focus(),v()}},o.a.createElement(h.Icon,{name:"close",size:"small",className:"text-gauloiseBlue-100"})):o.a.createElement(h.Icon,{name:"arrow",size:"small",className:["text-gauloiseBlue-100 absolute z-0 cursor-pointer sw-searchable-dropdown-arrow",{"sw-rotate-searchable-dropdown-arrow":m}]})),m&&o.a.createElement(P,{items:l.map(e.standardizeOption),inputValue:g,highlightedIndex:b,menuMaxHeight:a,getItemProps:d,truncateOptions:p,selectedItem:y}))}})},n}(o.a.Component);C.displayName="SearchableDropdown",C.propTypes={labelKey:u.string,disabled:u.bool,error:u.bool,menuMaxHeight:u.number,options:u.array,placeholder:u.string,value:Object(u.oneOfType)([u.string,u.number,u.bool,u.object]),truncateOptions:u.bool,onChange:u.func.isRequired,"data-automation":u.string},C.defaultProps={disabled:!1,error:!1,menuMaxHeight:null,options:[],truncateOptions:!1,value:""};var B=C;var q=function(e){var t=e.items,r=e.inputValue,n=e.highlightedIndex,a=e.menuMaxHeight,l=e.selectedItems,c=e.getItemProps,u=e.truncateOptions,s=t.filter((function(e){return("ALL_CHECKBOX_KEY"!==e.key||!r)&&(!r||e.label.match(new RegExp((void 0===(t=r)&&(t=""),t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")),"i")));var t})).map((function(e,t){var r="ALL_CHECKBOX_KEY"===e.key?0===l.length:l.some((function(t){return e.key?t.key===e.key:t.name===e.label}));return o.a.createElement("div",c({item:e,index:t,key:e.key||e.label,className:i()("cursor-pointer text-sm text-regentGrey rounded flex items-center my-1",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":n===t&&!r,"bg-gauloiseBlue-20 text-gauloiseBlue-100":r,truncate:u}),onClick:function(e){return e.stopPropagation()}}),o.a.createElement(m.CheckboxListItem,{style:{margin:0},className:"w-full",labelPosition:"left",key:e.key,label:e.label,icon:e.icon,checked:r,"data-automation":(e.key||e.label)+"-data-automation",noBackground:!0}))}));return o.a.createElement("div",{className:"absolute w-full p-1 mt-2 overflow-y-auto border rounded shadow border-porcelain bg-cloudWhite",style:{maxHeight:a?a+"px":"inherit"}},s.length>0?s:o.a.createElement("div",{className:"px-4 py-3 text-sm text-left rounded text-regentGrey"},"No matching options."))};q.propTypes={getItemProps:u.func.isRequired,highlightedIndex:u.number.isRequired,inputValue:u.string,items:u.array.isRequired,menuMaxHeight:u.number,selectedItems:u.array.isRequired,truncateOptions:u.bool};var L=q,T=["autoFocus","disabled","error","labelKey","menuMaxHeight","onChange","onDelete","options","placeholder","values","truncateOptions","itemToString","stateReducer","delimiter","checkboxes"];function D(){return(D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function H(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(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var z=function(e){var t=e.autoFocus,r=void 0!==t&&t,a=e.disabled,l=void 0!==a&&a,u=(e.error,e.labelKey),s=void 0===u?"name":u,p=e.menuMaxHeight,d=void 0===p?null:p,f=e.onChange,g=e.onDelete,b=e.options,y=void 0===b?[]:b,v=e.placeholder,w=e.values,O=void 0===w?[]:w,x=e.truncateOptions,j=void 0!==x&&x,E=e.itemToString,k=void 0===E?function(e){return null===e?"":e.label}:E,I=e.stateReducer,N=e.delimiter,S=e.checkboxes,C=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,T),B=Object(n.useRef)(),q=Object(n.useCallback)((function(e,t,r){e.stopPropagation(),g(t,r,e),B.current.focus()}),[g]),H=function(e){if(e!==Object(e))return{label:String(e),value:e};if(s){if(!e.hasOwnProperty(s))throw new Error('labelKey property "'+s+'" was not found on the following option: '+JSON.stringify(e,null,2));return M(M({label:String(e[s]),value:e},e.icon&&{icon:e.icon}),e.key&&{key:e.key})}if(e.label)return{label:String(e.label),value:e};throw new Error("The following option could not be processed by Dropdown: "+JSON.stringify(e,null,2))},R=O.length>0,z=Object(n.useMemo)((function(){return i()("relative sw-searchable-dropdown hover:border-secondary-100 focus:border-secondary-100 bg-cloudWhite border border-porcelain rounded p-2 pl-4 pr-10",{"pb-1":R})}),[R]);return o.a.createElement(c.a,{defaultHighlightedIndex:0,onChange:function(e){return f(null===e?"":e.value)},selectedItem:H(""),itemToString:k,stateReducer:I,render:function(e){var t=e.getInputProps,n=e.getItemProps,a=e.isOpen,c=e.inputValue,u=e.highlightedIndex,s=e.selectedItem,p=e.openMenu,f=e.toggleMenu;return o.a.createElement("div",D({className:i()("relative",{"z-5":a,"z-0":!a,"cursor-not-allowed":l}),onClick:function(){B.current.focus(),!l&&p()}},C),o.a.createElement("div",{className:z},O.map((function(e,t){return o.a.createElement("span",{key:e.key||e.id},N&&t>=1&&o.a.createElement("span",{className:"mr-1 text-sm text-jungleBlack"},N),o.a.createElement(m.Chip,{onDelete:function(t,r){return q(t,r,e)},id:e.id,className:"mb-1 mr-1"},e.icon&&o.a.createElement(h.Icon,{className:"flex-shrink-0 mr-2",name:e.icon,size:"small"}),e.name))})),o.a.createElement("input",t({className:i()("z-20 bg-transparent text-sm text-pickledBlack leading-button inline-block",{"opacity-50 cursor-not-allowed":l,checkboxes:S}),style:{width:R?"50px":"150px"},disabled:l,autoFocus:r,placeholder:R?"":v,onClick:function(){return!a&&!l&&f()},ref:B})),o.a.createElement(h.Icon,{name:"arrow",size:"small",onClick:function(e){e.stopPropagation(),B.current.focus(),!l&&f()},className:i()("text-gauloiseBlue-100 absolute z-0 cursor-pointer sw-searchable-dropdown-arrow",{"sw-rotate-searchable-dropdown-arrow":a,"cursor-not-allowed":l})})),a&&(S?o.a.createElement(L,{items:y.map(H),inputValue:c,highlightedIndex:u,menuMaxHeight:d,getItemProps:n,truncateOptions:j,selectedItems:O,allCheckboxLabel:v}):o.a.createElement(P,{items:y.map(H),inputValue:c,highlightedIndex:u,menuMaxHeight:d,getItemProps:n,truncateOptions:j,selectedItem:s})))}})};z.propTypes={labelKey:u.string,disabled:u.bool,error:u.bool,menuMaxHeight:u.number,options:u.array,placeholder:u.string,values:Object(u.oneOfType)([u.string,u.array]),truncateOptions:u.bool,onChange:u.func.isRequired,itemToString:u.func,delimiter:u.string,checkboxes:u.bool};var _=z,G=r(8);function K(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 V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){F(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function F(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function W(e,t){return(W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var A=function(e){var t,r;function n(){return e.apply(this,arguments)||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,W(t,r),n.prototype.render=function(){var e=this.props,t=e["data-automation"],r=e.query,n=e.variables,a=e.labelKey,l=e.value,u=e.onChange,s=e.accessor,p=e.placeholder,d=e.disabled;return o.a.createElement(c.a,{key:l,stateReducer:function(e,t){switch(t.type){case c.a.stateChangeTypes.mouseUp:return V(V({},t),{},{inputValue:e.inputValue});default:return t}},defaultInputValue:l,itemToString:function(e){return null==e?"":g(e,a)},onChange:function(e){return u(e)}},(function(e){var l=e.isOpen,c=e.openMenu,u=e.inputValue,h=e.getInputProps,b=e.getItemProps,y=e.highlightedIndex;e.getToggleButtonProps;return o.a.createElement("div",{className:"z-50"},o.a.createElement(f.Manager,null,o.a.createElement("div",null,o.a.createElement(f.Reference,null,(function(e){var r=e.ref;return o.a.createElement("div",{ref:r},o.a.createElement(m.SearchInput,h({value:u,onFocus:c,"data-automation":t,className:"w-full",placeholder:p,disabled:d})))})),l&&o.a.createElement(f.Frame,{minWidth:!0,maxHeight:200,lockInPosition:!0,placement:"bottom-start",arrow:!1},o.a.createElement("div",{"data-automation":t+"-frame",className:"overflow-x-auto",style:{maxHeight:"160px"}},o.a.createElement(G.Query,{query:r,variables:V(V({},n),{},{filter:u})},(function(e){var r=e.loading,n=e.error,l=e.data;return r?o.a.createElement("div",{"data-automation":t+"-loading",className:"cursor-pointer py-3 px-4 text-regentGrey text-sm rounded text center"},"Searching..."):n?o.a.createElement("div",{className:"cursor-pointer py-3 px-4 text-regentGrey text-sm rounded text center"},"Network error"):0===s(l).length?o.a.createElement("div",{"data-automation":t+"-no-results",className:"cursor-pointer py-3 px-4 text-regentGrey text-sm rounded text center"},"No results"):o.a.createElement("div",null,s(l).map((function(e,r){return o.a.createElement("div",b({item:e,key:r,"data-automation":t+"-item-"+r,className:i()("text-regentGrey hover:text-gauloiseBlue-100 text-xs","py-3 px-4","hover:bg-gauloiseBlue-10 rounded","cursor-pointer",{"bg-gauloiseBlue-10 text-gauloiseBlue-100":y===r})}),g(e,a))})))})))))))}))},n}(n.Component);A.defaultProps={placeholder:"Search",labelKey:"label",disabled:!1},A.propTypes={"data-automation":u.string,value:u.string,labelKey:u.string,placeholder:u.string,query:u.object.isRequired,accessor:u.func.isRequired,variables:u.object.isRequired,onChange:u.func.isRequired,disabled:u.bool};var Y=A,J=["autoFocus","disabled","labelKey","menuMaxHeight","onChange","onDelete","placeholder","values","truncateOptions","stateReducer","delimiter","query","queryOptions","selector","value","variables","filter","className","chipTheme"];function $(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */$=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=t&&t.prototype instanceof p?t:p,a=Object.create(o.prototype),i=new j(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return P()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var l=w(i,r);if(l){if(l===s)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===s)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,i),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var s={};function p(){}function d(){}function f(){}var m={};l(m,o,(function(){return this}));var h=Object.getPrototypeOf,g=h&&h(h(E([])));g&&g!==t&&r.call(g,o)&&(m=g);var b=f.prototype=p.prototype=Object.create(m);function y(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,l){var c=u(e[o],e,a);if("throw"!==c.type){var s=c.arg,p=s.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,i,l)}),(function(e){n("throw",e,i,l)})):t.resolve(p).then((function(e){s.value=e,i(s)}),(function(e){return n("throw",e,i,l)}))}l(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return s;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,s;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,s):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,s)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function E(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:P}}function P(){return{value:void 0,done:!0}}return d.prototype=f,l(b,"constructor",f),l(f,"constructor",d),d.displayName=l(f,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,i,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},y(v.prototype),l(v.prototype,a,(function(){return this})),e.AsyncIterator=v,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new v(c(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},y(b),l(b,i,"Generator"),l(b,o,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=E,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,s):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),s},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),s}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},e}function Q(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 X(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Z(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,o)}function ee(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){Z(a,n,o,i,l,"next",e)}function l(e){Z(a,n,o,i,l,"throw",e)}i(void 0)}))}}function te(){return(te=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var re=function(e,t){return e!==Object(e)?{label:String(e),value:e}:t?{label:String(e[t]),value:e}:e.label?{label:String(e.label),value:e}:void 0},ne=function(e){var t=e.autoFocus,r=void 0!==t&&t,a=e.disabled,l=void 0!==a&&a,u=e.labelKey,s=void 0===u?"name":u,p=e.menuMaxHeight,d=void 0===p?300:p,f=e.onChange,g=e.onDelete,b=e.placeholder,y=e.values,v=void 0===y?[]:y,w=e.truncateOptions,O=void 0!==w&&w,x=e.stateReducer,j=e.delimiter,E=e.query,P=e.queryOptions,k=void 0===P?{}:P,I=e.selector,N=e.value,S=void 0===N?"":N,C=e.variables,B=void 0===C?{}:C,q=e.filter,L=void 0===q?function(e){return!v.map((function(e){return e.id})).includes(e.value.id)}:q,T=e.className,D=e.chipTheme,H=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,J),M=Object(n.useRef)(),R=Object(n.useCallback)((function(e,t,r){e.stopPropagation(),g(t,r,e),M.current.focus()}),[g]),z=v.length>0,_=Object(n.useMemo)((function(){return i()("relative sw-searchable-dropdown hover:border-secondary-100 focus:border-secondary-100 bg-cloudWhite border border-porcelain rounded p-2 pl-4 pr-10",{"pb-1":z})}),[z]);return o.a.createElement(c.a,{defaultHighlightedIndex:0,onChange:function(e){return f(null===e?"":e.value)},selectedItem:re(S),itemToString:function(e){return null===e?"":e.label},stateReducer:x,render:function(e){var t=e.getInputProps,n=e.getItemProps,a=e.isOpen,c=e.inputValue,u=e.highlightedIndex,p=e.selectedItem,f=e.openMenu,g=e.toggleMenu,y=e.clearSelection;return o.a.createElement("div",te({className:i()("relative "+(a?"z-5":"z-0"),T),onClick:function(){M.current.focus(),f()}},H),o.a.createElement("div",{className:_},v.map((function(e,t){return o.a.createElement("span",{key:e.key||e.id},j&&t>=1&&o.a.createElement("span",{className:"mr-1 text-sm text-jungleBlack"},j),o.a.createElement(m.Chip,{onDelete:function(t,r){return R(t,r,e)},id:e.id,theme:D,className:"mb-1 mr-1"},e.icon&&o.a.createElement(h.Icon,{className:"flex-shrink-0 mr-2",name:e.icon,size:"small"}),e.name))})),o.a.createElement("input",t({className:i()("z-20 bg-transparent text-sm text-pickledBlack leading-button inline-block",{"opacity-50 cursor-not-allowed":l}),style:{width:z?"50px":"150px"},disabled:l,autoFocus:r,placeholder:z?"":b,onClick:function(){return!a&&g()},ref:M})),S?o.a.createElement("span",{className:"absolute z-50 p-2 cursor-pointer sw-searchable-dropdown-cancel",onClick:function(e){e.stopPropagation(),y(),M.current.focus(),f()}},o.a.createElement(h.Icon,{name:"close",size:"small",className:"text-gauloiseBlue-100"})):o.a.createElement(h.Icon,{name:"arrow",size:"small",onClick:function(e){e.stopPropagation(),M.current.focus(),g()},className:["text-gauloiseBlue-100 absolute z-0 cursor-pointer sw-searchable-dropdown-arrow",{"sw-rotate-searchable-dropdown-arrow":a}]})),o.a.createElement(oe,{isOpen:a,inputValue:c,highlightedIndex:u,labelKey:s,menuMaxHeight:d,getItemProps:n,truncateOptions:O,selectedItem:p,query:E,queryOptions:k,selector:I,values:v,variables:B,filter:L}))}})},oe=function(e){var t=e.query,r=e.queryOptions,a=e.isOpen,i=e.inputValue,l=e.highlightedIndex,c=e.menuMaxHeight,u=e.getItemProps,s=e.labelKey,p=e.truncateOptions,f=e.selectedItem,m=e.selector,h=e.filter,g=e.variables,b=Object(G.useLazyQuery)(t,r),y=b[0],v=b[1],w=v.loading,O=v.data,x=Object(n.useState)(i),j=x[0],E=x[1],k=o.a.useCallback(Object(d.debounce)((function(e){return I.apply(this,arguments)}),200),[]);function I(){return(I=ee($().mark((function e(t){return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y(t);case 2:E(t.variables.filter);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}o.a.useEffect((function(){k({variables:X(X({},g),{},{filter:i})})}),[i,k,g]);var N=j!==i;if(a&&(w||N))return o.a.createElement("div",{className:"absolute w-full p-2 mt-2 overflow-y-auto border rounded shadow border-porcelain bg-cloudWhite",style:{maxHeight:c?c+"px":"inherit"}},Array.from({length:10}).map((function(e,t){return o.a.createElement("div",{key:t,className:"flex items-center px-4 py-3 text-sm rounded cursor-wait text-regentGrey"},o.a.createElement("div",{className:"w-full h-4 sw-loader-skeleton sw-loader-single"}))})));var S=(Object(d.isEmpty)(O)||w||N?[]:Object(d.get)(O,m,[]).map((function(e){return re(e,s)}))).filter(h);return a&&o.a.createElement(P,{items:S,inputValue:i,highlightedIndex:l,menuMaxHeight:c,getItemProps:u,truncateOptions:p,selectedItem:f,filterOptions:!1})};ne.propTypes={labelKey:u.string,disabled:u.bool,menuMaxHeight:u.number,options:u.array,placeholder:u.string,values:Object(u.oneOfType)([u.string,u.array]),truncateOptions:u.bool,onChange:u.func.isRequired,delimiter:u.string,filter:u.func,chipTheme:Object(u.oneOf)(["primary","secondary","warning","radicalRed","dodgerBlue","pictonBlue","javaGreen","limaGreen","frenchRoseRed","sunglowYellow","electricViolet","royalBlue","lazyLavender","orangePeel","cloudWhite"])},ne.displayName="AsyncChipDropdown";var ae=ne}])}));
//# sourceMappingURL=index.js.map
{
"name": "@swrve/dropdowns",
"sideEffects": false,
"version": "3.28.10",
"version": "3.28.11",
"description": "Assorted dropdown components.",

@@ -36,3 +36,3 @@ "main": "dist/index.js",

},
"gitHead": "4a774455d445967ddd435dcd7903e1a64444e22b"
"gitHead": "15112470a8291969b390242ec77def8836f251ec"
}

@@ -50,2 +50,3 @@ import React, { useCallback, useMemo, useRef, useState } from 'react'

query,
queryOptions = {},
selector,

@@ -181,2 +182,3 @@ value = '',

query={query}
queryOptions={queryOptions}
selector={selector}

@@ -195,2 +197,3 @@ values={values}

query,
queryOptions,
isOpen,

@@ -208,3 +211,3 @@ inputValue,

}) => {
const [fetchQuery, { loading, data }] = useLazyQuery(query)
const [fetchQuery, { loading, data }] = useLazyQuery(query, queryOptions)
const [searchTerm, setSearchTerm] = useState(inputValue)

@@ -211,0 +214,0 @@ const debouncedFetchQuery = React.useCallback(debounce(search, 200), [])

@@ -76,2 +76,3 @@ import React from 'react'

query={COUNTRY_QUERY}
queryOptions={{ fetchPolicy: 'network-only' }}
selector="characters.results"

@@ -78,0 +79,0 @@ {...args}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc