intelicoreact 1.8.62 → 1.8.64
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
|
-
function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,l=Array(n);t<n;t++)l[t]=e[t];return l}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}Object.defineProperty(exports,"__esModule",{value:!0});var l=exports,o={MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH:function(){return w},default:function(){return b}};for(var r in o)Object.defineProperty(l,r,{enumerable:!0,get:o[r]});var i=require("react/jsx-runtime"),u=h(require("classnames")),c=function(e,n){if(e&&e.__esModule)return e;if(null===e||(void 0===e?"undefined":t(e))!=="object"&&"function"!=typeof e)return{default:e};var l=g(n);if(l&&l.has(e))return l.get(e);var o={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var u=r?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(o,i,u):o[i]=e[i]}return o.default=e,l&&l.set(e,o),o}(require("react")),a=require("react-dom"),s=require("react-feather"),d=require("../../../Functions/fieldValueFormatters"),v=h(require("../Input/Input")),f=h(require("../RadioInput/RadioInput")),p=h(require("./components/DropdownLoader")),m=h(require("./useDropdown"));function h(e){return e&&e.__esModule?e:{default:e}}function g(e){if("function"!=typeof WeakMap)return null;var n=new WeakMap,t=new WeakMap;return(g=function(e){return e?t:n})(e)}require("./Dropdown.scss");var _="dropdown",w=10,b=function(l){var o,r,h,g,b,y,j,x,C,L,O=l.label,S=l.options,E=l.value,N=l.error,I=l.disabled,k=l.onChange,M=l.placeholder,H=l.className,P=l.isSearchable,A=l.entity,R=l.scrollReactionObj,T=l.isListTop,D=l.isNotValidateASCII,B=void 0!==D&&D,F=l.testId,q=void 0===F?"dropdown":F,W=l.sortAlphabetical,K=l.fieldKey,V=l.id,U=l.noOptionsText,z=void 0===U?"No options available":U,X=l.isDoNotPullOutListOfMainContainer,G=l.withMobileLogic,$=l.withActions,J=l.minItemsForShowMobileSearch,Q=l.customTrigger,Y=l.tabIndex,Z=l.onActionConfirmClick,ee=l.onActionCancelClick,en=l.isDefaultOpened,et=l.isDefaultOpenedMobile,el=l.footerContent,eo=l.closeOnSelect,er=void 0===eo||eo,ei=l.closeOnSelectMobile,eu=void 0===ei||ei,ec=l.withApplyLogic,ea=void 0!==ec&&ec,es=l.cancelButtonRef,ed=l.applyButtonRef,ev=(0,m.default)({id:V,fieldKey:K,value:E,sortAlphabetical:void 0===W||W,withMobileLogic:G,options:S,isSearchable:P,minItemsForShowMobileSearch:void 0===J?w:J,isDoNotPullOutListOfMainContainer:X}),ef=ev.dropdownId,ep=ev.isMobile,em=ev.isOpen,eh=ev.setIsOpen,eg=ev.searchValue,e_=ev.setSearchValue,ew=ev.initListHeight,eb=ev.setInitListHeight,ey=ev.isSearchChanged,ej=ev.setIsSearchChanged,ex=ev.isSearchInputFocused,eC=ev.setIsSearchInputFocused,eL=ev.isScrollableList,eO=ev.setIsScrollableList,eS=ev.isFixedMaxHeight,eE=ev.setIsFixedMaxHeight,eN=ev.scrollTop,eI=ev.setScrollTop,ek=ev.scrollHeight,eM=ev.setScrollHeight,eH=ev.maxListContainerHeight,eP=ev.setMaxListContainerHeight,eA=ev.getListContainer,eR=ev.getListContainerWrapper,eT=ev.getParentNode,eD=ev.getPreparedOptionLabel,eB=ev.getSortedOptions,eF=ev.filteredGroups,eq=ev.filteredItems,eW=ev.filteredOptions,eK=ev.selectedLabel,eV=ev.postfixText,eU=ev.dropdownRef,ez=ev.dropdownListRef,eX=ev.dropdownListWrapperRef,eG=ev.dropdownFooterRef,e$=ev.searchInputRef,eJ=ev.wrapperRef,eQ=ev.isSearchable,eY=ev.valueToApply,eZ=ev.valueToApplyRef,e0=ev.setValueToApply,e1=function(){eh(!1),null==e0||e0(null),null==ee||ee()},e3=function(){(null==eZ?void 0:eZ.current)!==null&&(null==eZ?void 0:eZ.current)!==void 0&&(null==k||k(eZ.current),setTimeout(function(){return null==Z?void 0:Z()},1)),null==e1||e1()},e2=function(e){(ep?eu:er)&&e1(),ea&&(null==ed?void 0:ed.current)?null==e0||e0(e.value):null==k||k(e.value)},e6=function(e){return!![9,13].includes(e.keyCode)&&(e1(),!0)},e8=function(e){return!![9,13].includes(e.keyCode)&&(eh(!0),!0)},e9=function(e){var n=e;B||(n=(0,d.formatToOnlyASCIICodeText)(n)),ej(!0),e_(n)},e4=function(e){e.target===(null==eJ?void 0:eJ.current)&&(e.stopPropagation(),e.preventDefault(),e1())},e5=function(e){e9(e)},e7=function(e){var n;(null==(n=eA())?void 0:n.contains(null==e?void 0:e.target))||(null==eU?void 0:eU.current)===null||(null==eU?void 0:eU.current.contains(null==e?void 0:e.target))||e1()},ne=(0,c.useCallback)(function(e){var n=R||{},t=n.callback,l=n.isWithAnyScrolling,o=n.scrollingInaccuracy,r=null==e?void 0:e.target;t&&"function"==typeof t&&(l?t(e):Math.round(r.clientHeight+r.scrollTop+(void 0===o?0:o))>=r.scrollHeight&&t(e))},[eW]),nn=function(){var e=document.createElement("div");e.setAttribute("id",ef),e.classList.add("dropdown__container"),ep&&e.addEventListener("click",function(e){(null==e?void 0:e.target).id===ef&&e1()});try{null==(n=eA())||n.remove()}finally{if(ep){try{null==(o=document.getElementById("mlw-".concat(ef)))||o.remove()}catch(e){}var n,t,l,o,r=document.createElement("div");r.classList.add("dropdown-mobile"),r.setAttribute("id","mlw-".concat(ef)),null==r||r.append(e),null==(l=eT())||l.append(r)}else null==(t=eT())||t.append(e)}},nt=function(){var e,n,t,l,o,r,i,u,c,a,s,d,v,f,p,m,h,g,_,w=eA();if(!w||!em)return!1;var b=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,y=null!=(p=null==eU||null==(e=eU.current)?void 0:e.getBoundingClientRect())?p:{},j=y.width,x=y.height,C=void 0===x?0:x,L=y.left,O=y.top,S=void 0===O?0:O,E=w.getElementsByClassName("dropdown__list")[0],N=null==eX||null==(n=eX.current)?void 0:n.getElementsByClassName("dropdown__list-header")[0],I=Number.parseInt(null!=(m=null==(l=getComputedStyle(null==eX?void 0:eX.current))||null==(t=l.marginTop)?void 0:t.replace("px",""))?m:"0",10),k=null!=ew?ew:Number.parseInt(null!=(h=null==(r=getComputedStyle(E))||null==(o=r.maxHeight)?void 0:o.replace("px",""))?h:"0",10);null===ew&&eb(k);var M=S-I,H=b-S-C-2*I,P=null==E||null==(i=E.getBoundingClientRect())?void 0:i.height,A=(ep?(null==eX||null==(c=eX.current)||null==(u=c.getBoundingClientRect())?void 0:u.height)-(null==N||null==(a=N.getBoundingClientRect())?void 0:a.height):M>=k||H>=k?k-3*I:M>H?M-3*I:H-4*I)-(null!=(g=null==eG||null==(d=eG.current)||null==(s=d.getBoundingClientRect())?void 0:s.height)?g:0);return w.style.minWidth="".concat(j,"px"),w.style.left="".concat(L,"px"),w.style.top="".concat("bottom"==(M<H||H>=P?"bottom":"top")?S+C:S-3*I-Number.parseInt(null!=(_=null==(f=getComputedStyle(null==eX?void 0:eX.current))||null==(v=f.height)?void 0:v.replace("px",""))?_:"0",10),"px"),eH===A||ep||eP(A),E.style.maxHeight="".concat(A,"px"),!0},nl=em?e7:function(){},no=function(n){var t,l=function(e){"open_modal"===e.value?null==k||k("open_modal"):e2(e)},o=[{label:"New ".concat(A),value:"open_modal",className:"dropdown__list-item--modal"}].concat(function(n){if(Array.isArray(n))return e(n)}(t=null!=eW?eW:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(n,t){if(n){if("string"==typeof n)return e(n,void 0);var l=Object.prototype.toString.call(n).slice(8,-1);if("Object"===l&&n.constructor&&(l=n.constructor.name),"Map"===l||"Set"===l)return Array.from(l);if("Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return e(n,t)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());return{onChange:function(e){return n?l(e):e2(e)},options:n?o:S}},nr=(0,c.useMemo)(function(){return A&&""!==A&&"string"==typeof A},[A]),ni=(0,c.useMemo)(function(){return no(nr)},[nr,eW]),nu=function(e,t,l){var o,r,c,a;return(0,i.jsxs)("button",{type:"button","data-testid":"".concat(q,"-").concat(l,"-option"),onMouseDown:function(){return ni.onChange(e)},className:(0,u.default)("".concat(_,"__list-item"),(n(a={},"".concat(_,"__list-item_active"),e.value===(null!=eY?eY:E)),n(a,"".concat(_,"__list-item_disabled"),e.disabled),a),e.className),value:null==e?void 0:e.value,children:[!ep&&(0,i.jsx)("span",{className:(0,u.default)("".concat(_,"__active-icon"),n({},"".concat(_,"__active-icon_active"),e.value===E)),children:(0,i.jsx)(s.Check,{})}),(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-item-label"),e.labelClassName||""),dangerouslySetInnerHTML:{__html:eD(e.label,e.postfix,e.description)}}),(null==e?void 0:e.icon)||"",ep?null!=(c=null==e?void 0:e.customMobileIcon)?c:(0,i.jsx)(f.default,{value:e.value,checked:null!=eY?eY:E}):""]},null==(r=e.value)||null==(o=r.toString())?void 0:o.replace(/ /g,"_"))},nc=function(e){var n,t,l,o,r,c;return(null!=(c=null==(n=e.items)?void 0:n.length)?c:0)>0?(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"-group"),e.className),children:[(0,i.jsx)("div",{className:"".concat(_,"-group__name"),children:e.label}),null==(t=e.items)?void 0:t.map(function(e,n){var t;return nu(e,n,null==(t=(null==e?void 0:e.testId)||n)?void 0:t.toString())})]},null==(r=e.label)||null==(o=r.toString())?void 0:o.replace(/ /g,"_").concat(null==(l=Date.now())?void 0:l.toString())):null};if((0,c.useEffect)(function(){return document.addEventListener("click",e7,!0),function(){var e,n;null==(e=eA())||e.remove(),null==(n=eR())||n.remove(),document.removeEventListener("click",e7,!0)}},[]),(0,c.useEffect)(function(){(!X||eU.current)&&(nn(),(en&&!ep||et)&&eh(!0))},[X,eU.current]),(0,c.useLayoutEffect)(function(){var e;return ep?(window.removeEventListener("resize",nt),window.removeEventListener("mousewheel",nl),window.removeEventListener("scroll",nl),window.removeEventListener("touchmove",nl)):(window.addEventListener("resize",nt),window.addEventListener("mousewheel",nl),window.addEventListener("scroll",nl),window.addEventListener("touchmove",nl)),null==(e=eA())||e.addEventListener("click",nl),function(){var e;window.removeEventListener("resize",nt),window.removeEventListener("mousewheel",nl),window.removeEventListener("scroll",nl),window.removeEventListener("touchmove",nl),null==(e=eA())||e.removeEventListener("click",nl)}},[eA]),(0,c.useLayoutEffect)(function(){nt()},[eH,em,eg,ep,eS,S]),(0,c.useEffect)(function(){var e,n,l=em?"addEventListener":"removeEventListener";return null==es||null==(e=es.current)||e[l]("click",e1,!0),null==ed||null==(n=ed.current)||n[l]("click",e3,!0),!em&&(ej(!1),ep||eP(0)),R&&(void 0===R?"undefined":t(R))==="object"&&em&&ez&&ez.current&&ez.current.addEventListener("scroll",ne),function(){R&&(void 0===R?"undefined":t(R))==="object"&&removeEventListener("scroll",ne)}},[em,ez]),(0,c.useEffect)(function(){var e;return eg||!ex||ep||(e_(eK),e=setTimeout(function(){return e$.current.select()},1)),ex||em||e_(null),function(){clearTimeout(e)}},[ex]),(0,c.useEffect)(function(){if(em&&!ex&&(null==e$?void 0:e$.current)&&!ep&&(null==(e=e$.current)||e.focus()),em?null==(n=eA())||n.classList.add("dropdown__container--opened"):(null==(t=e$.current)||t.blur(),null==(l=eA())||l.classList.remove("dropdown__container--opened")),em&&ep){var e,n,t,l,o,r,i,u,c=null==ez||null==(o=ez.current)?void 0:o.querySelector("button[value='".concat(null!=eY?eY:E,"']"));c&&(null==ez||null==(u=ez.current)||u.scrollTo(0,(null==c||null==(r=c.getBoundingClientRect())?void 0:r.y)-(null==ez||null==(i=ez.current)?void 0:i.getBoundingClientRect().y)-16))}!em&&ep&&e_(null)},[em]),(0,c.useEffect)(function(){if(em&&ep&&(null==ez?void 0:ez.current)&&!eg){var e,n,t,l;eO((null==ez||null==(e=ez.current)?void 0:e.scrollHeight)>(null==ez||null==(n=ez.current)?void 0:n.clientHeight)),eE(eL||(null==ez||null==(t=ez.current)?void 0:t.scrollHeight)>(null==ez||null==(l=ez.current)?void 0:l.clientHeight))}},[em,ep,eL,null==ez?void 0:ez.current,null==ez||null==(j=ez.current)?void 0:j.scrollHeight,null==ez||null==(x=ez.current)?void 0:x.clientHeight]),(0,c.useEffect)(function(){var e,n=function(e){var n,t;eI(Number.parseInt(null==e||null==(t=e.target)||null==(n=t.scrollTop)?void 0:n.toString(),10))};return em&&ep&&(null==ez?void 0:ez.current)&&(null==ez||null==(e=ez.current)||e.addEventListener("scroll",n)),function(){if((null==ez?void 0:ez.current)!==null){var e;null==ez||null==(e=ez.current)||e.removeEventListener("scroll",n)}}},[em,ep,null==ez?void 0:ez.current]),(0,c.useEffect)(function(){if(null==ez?void 0:ez.current){var e,n;eM(Number.parseInt(((null==ez||null==(e=ez.current)?void 0:e.scrollHeight)-(null==ez||null==(n=ez.current)?void 0:n.clientHeight)).toString(),10))}},[eN,null==ez?void 0:ez.current]),!S)return null;return(0,i.jsxs)("div",{className:(0,u.default)(_,H,(n(C={disabled:I},"".concat(_,"-mobile"),ep),n(C,"".concat(_,"--focused"),em&&!ep),n(C,"".concat(_,"--with-custom-trigger"),!!Q),C)),ref:eU,onKeyDown:e6,onKeyUp:e8,children:[(0,i.jsx)("button",{type:"button","data-testid":q,className:(0,u.default)("".concat(_,"__trigger"),"input__wrap",(n(L={},"".concat(_,"__trigger--with-actions"),$),n(L,"placeholder",null==E||""===E),n(L,"error",N),L)),onClick:function(){return eh(!0)},onKeyDown:e6,onKeyUp:e8,tabIndex:Y,children:Q||(0,i.jsxs)(i.Fragment,{children:[eQ&&!ep?(0,i.jsx)("input",{ref:e$,className:"".concat(_,"__input"),value:String(em?null!=eg?eg:"":null!=eK?eK:""),onChange:function(e){return e5(e.target.value)},placeholder:M,onFocus:function(){return eC(!0)},onBlur:function(){return eC(!1)}}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text",children:eK||M||""}),eV&&(0,i.jsx)("span",{className:"dropdown__list-item-postfix",children:eV})]}),(0,i.jsx)("span",{className:(0,u.default)("".concat(_,"__arrow"),n({},"".concat(_,"__arrow_active"),em)),onClick:function(e){null==e||e.stopPropagation(),eh(function(e){return!e})},children:ep?(0,i.jsx)(s.Code,{className:"mobile-icon"}):em?(0,i.jsx)(s.ChevronUp,{}):(0,i.jsx)(s.ChevronDown,{})})]})}),$&&(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__actions")),children:[(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__actions-item")),onClick:Z,children:(0,i.jsx)(s.Check,{})}),(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__actions-item")),onClick:ee,children:(0,i.jsx)(s.X,{})})]}),em&&((y=eA())?(0,a.createPortal)((0,i.jsx)("div",{"data-testid":"".concat(q,"-container-wrapper"),className:(0,u.default)("".concat(_,"__container-wrapper")),ref:eJ,onClick:ep?e4:function(){},children:(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list-wrapper"),(n(r={},"".concat(_,"__list-wrapper--fixed-height"),eS),n(r,"".concat(_,"__list-wrapper--with-bottom-shadow"),eL&&ep&&!el),n(r,"".concat(_,"__list-wrapper--with-bottom-shadow-hidden"),eN===ek&&!el),r)),ref:eX,children:[ep&&(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list-header"),(n(h={},"".concat(_,"__list-header-with-shadow"),eL&&ep),n(h,"".concat(_,"__list-header-with-shadow-hidden"),0===eN),h)),children:[(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list-header-row")),children:[(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-label")),children:O}),(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-close-icon")),onClick:e1,children:(0,i.jsx)(s.X,{onClick:e1})})]}),eQ&&(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-header-row")),children:(0,i.jsx)(v.default,{ref:e$,className:"".concat(_,"__input"),value:eg||"",onChange:e5,placeholder:M||"Search",withDelete:!0,onFocus:function(){return eC(!0)},onBlur:function(){return eC(!1)}})})]}),(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list"),(n(g={},"".concat(_,"__list-top"),T),n(g,"".concat(_,"__list--with-footer"),el),g)),ref:ez,children:[ni.options&&(null==(o=eB(ni.options))?void 0:o.map(function(e,t){if(null==e||null==(i=e.items)?void 0:i.length)if(!eQ||!ey)return nc(e);else{var l,o,r,i,u,c,a=null==(c=e.items)?void 0:c.slice().filter(function(e){var n;return(null==e||null==(n=e.label)?void 0:n.toLowerCase().includes((null==eg?void 0:eg.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)===""});if(null==a?void 0:a.length)return nc((l=function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{},o=Object.keys(l);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(l).filter(function(e){return Object.getOwnPropertyDescriptor(l,e).enumerable}))),o.forEach(function(t){n(e,t,l[t])})}return e}({},e),o=o={items:a},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):(function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t.push.apply(t,l)}return t})(Object(o)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(o,e))}),l))}else if(!eQ||!ey||(null==e||null==(u=e.label)?void 0:u.toLowerCase().includes((null==eg?void 0:eg.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)==="")return nu(e,t,null==(r=(null==e?void 0:e.testId)||t)?void 0:r.toString());return null})),!(null==eq?void 0:eq.length)&&!(null==eF?void 0:eF.length)&&(0,i.jsx)("div",{className:"".concat(_,"__list-item ").concat(_,"__list-item--no-options"),children:z}),I&&em&&(0,i.jsx)(p.default,{})]}),el&&(0,i.jsx)("div",{ref:eG,className:(0,u.default)("".concat(_,"__footer"),(n(b={},"".concat(_,"__footer-with-shadow"),ep&&eL),n(b,"".concat(_,"__footer-with-shadow-hidden"),eN===ek),b)),children:el})]})}),y):null)]})};
|
|
1
|
+
function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,l=Array(n);t<n;t++)l[t]=e[t];return l}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}Object.defineProperty(exports,"__esModule",{value:!0});var l=exports,o={MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH:function(){return w},default:function(){return b}};for(var r in o)Object.defineProperty(l,r,{enumerable:!0,get:o[r]});var i=require("react/jsx-runtime"),u=h(require("classnames")),c=function(e,n){if(e&&e.__esModule)return e;if(null===e||(void 0===e?"undefined":t(e))!=="object"&&"function"!=typeof e)return{default:e};var l=g(n);if(l&&l.has(e))return l.get(e);var o={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var u=r?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(o,i,u):o[i]=e[i]}return o.default=e,l&&l.set(e,o),o}(require("react")),a=require("react-dom"),s=require("react-feather"),d=require("../../../Functions/fieldValueFormatters"),v=h(require("../Input/Input")),f=h(require("../RadioInput/RadioInput")),p=h(require("./components/DropdownLoader")),m=h(require("./useDropdown"));function h(e){return e&&e.__esModule?e:{default:e}}function g(e){if("function"!=typeof WeakMap)return null;var n=new WeakMap,t=new WeakMap;return(g=function(e){return e?t:n})(e)}require("./Dropdown.scss");var _="dropdown",w=10,b=function(l){var o,r,h,g,b,y,j,x,L,C,O=l.label,E=l.options,S=l.value,N=l.error,I=l.disabled,k=l.onChange,H=l.placeholder,M=l.className,P=l.isSearchable,A=l.entity,T=l.scrollReactionObj,D=l.isListTop,R=l.isNotValidateASCII,B=void 0!==R&&R,F=l.testId,q=void 0===F?"dropdown":F,W=l.sortAlphabetical,K=l.fieldKey,V=l.id,U=l.noOptionsText,z=void 0===U?"No options available":U,X=l.isDoNotPullOutListOfMainContainer,Y=l.withMobileLogic,G=l.withActions,$=l.minItemsForShowMobileSearch,J=l.customTrigger,Q=l.tabIndex,Z=l.onActionConfirmClick,ee=l.onActionCancelClick,en=l.isDefaultOpened,et=l.isDefaultOpenedMobile,el=l.footerContent,eo=l.closeOnSelect,er=void 0===eo||eo,ei=l.closeOnSelectMobile,eu=void 0===ei||ei,ec=l.withApplyLogic,ea=void 0!==ec&&ec,es=l.cancelButtonRef,ed=l.applyButtonRef,ev=(0,m.default)({id:V,fieldKey:K,value:S,sortAlphabetical:void 0===W||W,withMobileLogic:Y,options:E,isSearchable:P,minItemsForShowMobileSearch:void 0===$?w:$,isDoNotPullOutListOfMainContainer:X}),ef=ev.dropdownId,ep=ev.isMobile,em=ev.isOpen,eh=ev.setIsOpen,eg=ev.searchValue,e_=ev.setSearchValue,ew=ev.initListHeight,eb=ev.setInitListHeight,ey=ev.isSearchChanged,ej=ev.setIsSearchChanged,ex=ev.isSearchInputFocused,eL=ev.setIsSearchInputFocused,eC=ev.isScrollableList,eO=ev.setIsScrollableList,eE=ev.isFixedMaxHeight,eS=ev.setIsFixedMaxHeight,eN=ev.scrollTop,eI=ev.setScrollTop,ek=ev.scrollHeight,eH=ev.setScrollHeight,eM=ev.maxListContainerHeight,eP=ev.setMaxListContainerHeight,eA=ev.getListContainer,eT=ev.getListContainerWrapper,eD=ev.getParentNode,eR=ev.getPreparedOptionLabel,eB=ev.getSortedOptions,eF=ev.filteredGroups,eq=ev.filteredItems,eW=ev.filteredOptions,eK=ev.selectedLabel,eV=ev.postfixText,eU=ev.dropdownRef,ez=ev.dropdownListRef,eX=ev.dropdownListWrapperRef,eY=ev.dropdownFooterRef,eG=ev.searchInputRef,e$=ev.wrapperRef,eJ=ev.isSearchable,eQ=ev.valueToApply,eZ=ev.valueToApplyRef,e0=ev.setValueToApply,e1=function(){eh(!1),null==e0||e0(null),null==ee||ee()},e3=function(){(null==eZ?void 0:eZ.current)!==null&&(null==eZ?void 0:eZ.current)!==void 0&&(null==k||k(eZ.current),setTimeout(function(){return null==Z?void 0:Z()},1)),null==e1||e1()},e2=function(e){(ep?eu:er)&&e1(),ea&&(null==ed?void 0:ed.current)?null==e0||e0(e.value):null==k||k(e.value)},e6=function(e){return!![9,13].includes(e.keyCode)&&(e1(),!0)},e8=function(e){return!![9,13].includes(e.keyCode)&&(eh(!0),!0)},e9=function(e){var n=e;B||(n=(0,d.formatToOnlyASCIICodeText)(n)),ej(!0),e_(n)},e4=function(e){e.target===(null==e$?void 0:e$.current)&&(e.stopPropagation(),e.preventDefault(),e1())},e5=function(e){e9(e)},e7=function(e){var n;(null==(n=eA())?void 0:n.contains(null==e?void 0:e.target))||(null==eU?void 0:eU.current)===null||(null==eU?void 0:eU.current.contains(null==e?void 0:e.target))||e1()},ne=(0,c.useCallback)(function(e){var n=T||{},t=n.callback,l=n.isWithAnyScrolling,o=n.scrollingInaccuracy,r=null==e?void 0:e.target;t&&"function"==typeof t&&(l?t(e):Math.round(r.clientHeight+r.scrollTop+(void 0===o?0:o))>=r.scrollHeight&&t(e))},[eW]),nn=function(){var e=document.createElement("div");e.setAttribute("id",ef),e.classList.add("dropdown__container"),ep&&e.addEventListener("click",function(e){(null==e?void 0:e.target).id===ef&&e1()});try{null==(n=eA())||n.remove()}finally{if(ep){try{null==(o=document.getElementById("mlw-".concat(ef)))||o.remove()}catch(e){}var n,t,l,o,r=document.createElement("div");r.classList.add("dropdown-mobile"),r.setAttribute("id","mlw-".concat(ef)),null==r||r.append(e),null==(l=eD())||l.append(r)}else null==(t=eD())||t.append(e)}},nt=function(){var e,n,t,l,o,r,i,u,c,a,s,d,v,f,p,m,h,g,_,w=eA();if(!w||!em)return!1;var b=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,y=null!=(p=null==eU||null==(e=eU.current)?void 0:e.getBoundingClientRect())?p:{},j=y.width,x=y.height,L=void 0===x?0:x,C=y.left,O=y.top,E=void 0===O?0:O,S=w.getElementsByClassName("dropdown__list")[0],N=null==eX||null==(n=eX.current)?void 0:n.getElementsByClassName("dropdown__list-header")[0],I=Number.parseInt(null!=(m=null==(l=getComputedStyle(null==eX?void 0:eX.current))||null==(t=l.marginTop)?void 0:t.replace("px",""))?m:"0",10),k=null!=ew?ew:Number.parseInt(null!=(h=null==(r=getComputedStyle(S))||null==(o=r.maxHeight)?void 0:o.replace("px",""))?h:"0",10);null===ew&&eb(k);var H=E-I,M=b-E-L-2*I,P=null==S||null==(i=S.getBoundingClientRect())?void 0:i.height,A=(ep?(null==eX||null==(c=eX.current)||null==(u=c.getBoundingClientRect())?void 0:u.height)-(null==N||null==(a=N.getBoundingClientRect())?void 0:a.height):H>=k||M>=k?k-3*I:H>M?H-3*I:M-4*I)-(null!=(g=null==eY||null==(d=eY.current)||null==(s=d.getBoundingClientRect())?void 0:s.height)?g:0);return w.style.minWidth="".concat(j,"px"),w.style.left="".concat(C,"px"),w.style.top="".concat("bottom"==(H<M||M>=P?"bottom":"top")?E+L:E-3*I-Number.parseInt(null!=(_=null==(f=getComputedStyle(null==eX?void 0:eX.current))||null==(v=f.height)?void 0:v.replace("px",""))?_:"0",10),"px"),eM===A||ep||eP(A),S.style.maxHeight="".concat(A,"px"),!0},nl=em?e7:function(){},no=function(n){var t,l=function(e){"open_modal"===e.value?null==k||k("open_modal"):e2(e)},o=[{label:"New ".concat(A),value:"open_modal",className:"dropdown__list-item--modal"}].concat(function(n){if(Array.isArray(n))return e(n)}(t=null!=eW?eW:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(n,t){if(n){if("string"==typeof n)return e(n,void 0);var l=Object.prototype.toString.call(n).slice(8,-1);if("Object"===l&&n.constructor&&(l=n.constructor.name),"Map"===l||"Set"===l)return Array.from(l);if("Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return e(n,t)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());return{onChange:function(e){return n?l(e):e2(e)},options:n?o:E}},nr=(0,c.useMemo)(function(){return A&&""!==A&&"string"==typeof A},[A]),ni=(0,c.useMemo)(function(){return no(nr)},[nr,eW]),nu=function(e,t,l){var o,r,c,a;return(0,i.jsxs)("button",{type:"button","data-testid":"".concat(q,"-").concat(l,"-option"),onMouseDown:function(){return ni.onChange(e)},className:(0,u.default)("".concat(_,"__list-item"),(n(a={},"".concat(_,"__list-item_active"),e.value===(null!=eQ?eQ:S)),n(a,"".concat(_,"__list-item_disabled"),e.disabled),a),e.className),value:null==e?void 0:e.value,children:[!ep&&(0,i.jsx)("span",{className:(0,u.default)("".concat(_,"__active-icon"),n({},"".concat(_,"__active-icon_active"),e.value===S)),children:(0,i.jsx)(s.Check,{})}),(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-item-label"),e.labelClassName||""),dangerouslySetInnerHTML:{__html:eR(e.label,e.postfix,e.description)}}),(null==e?void 0:e.icon)||"",ep?null!=(c=null==e?void 0:e.customMobileIcon)?c:(0,i.jsx)(f.default,{value:e.value,checked:null!=eQ?eQ:S}):""]},null==(r=e.value)||null==(o=r.toString())?void 0:o.replace(/ /g,"_"))},nc=function(e){var n,t,l,o,r,c;return(null!=(c=null==(n=e.items)?void 0:n.length)?c:0)>0?(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"-group"),e.className),children:[(0,i.jsx)("div",{className:"".concat(_,"-group__name"),children:e.label}),null==(t=e.items)?void 0:t.map(function(e,n){var t;return nu(e,n,null==(t=(null==e?void 0:e.testId)||n)?void 0:t.toString())})]},null==(r=e.label)||null==(o=r.toString())?void 0:o.replace(/ /g,"_").concat(null==(l=Date.now())?void 0:l.toString())):null};if((0,c.useEffect)(function(){return document.addEventListener("click",e7,!0),function(){var e,n;null==(e=eA())||e.remove(),null==(n=eT())||n.remove(),document.removeEventListener("click",e7,!0)}},[]),(0,c.useEffect)(function(){(!X||eU.current)&&(nn(),(en&&!ep||et)&&eh(!0))},[X,eU.current]),(0,c.useLayoutEffect)(function(){var e;return ep?(window.removeEventListener("resize",nt),window.removeEventListener("mousewheel",nl),window.removeEventListener("scroll",nl),window.removeEventListener("touchmove",nl)):(window.addEventListener("resize",nt),window.addEventListener("mousewheel",nl),window.addEventListener("scroll",nl),window.addEventListener("touchmove",nl)),null==(e=eA())||e.addEventListener("click",nl),function(){var e;window.removeEventListener("resize",nt),window.removeEventListener("mousewheel",nl),window.removeEventListener("scroll",nl),window.removeEventListener("touchmove",nl),null==(e=eA())||e.removeEventListener("click",nl)}},[eA]),(0,c.useLayoutEffect)(function(){nt()},[eM,em,eg,ep,eE,E]),(0,c.useEffect)(function(){var e,n,l=em?"addEventListener":"removeEventListener";return null==es||null==(e=es.current)||e[l]("click",e1,!0),null==ed||null==(n=ed.current)||n[l]("click",e3,!0),!em&&(ej(!1),ep||eP(0)),T&&(void 0===T?"undefined":t(T))==="object"&&em&&ez&&ez.current&&ez.current.addEventListener("scroll",ne),function(){T&&(void 0===T?"undefined":t(T))==="object"&&removeEventListener("scroll",ne)}},[em,ez]),(0,c.useEffect)(function(){var e;return eg||!ex||ep||(e_(eK),e=setTimeout(function(){return eG.current.select()},1)),ex||em||e_(null),function(){clearTimeout(e)}},[ex]),(0,c.useEffect)(function(){if(em&&!ex&&(null==eG?void 0:eG.current)&&!ep&&(null==(e=eG.current)||e.focus()),em?null==(n=eA())||n.classList.add("dropdown__container--opened"):(null==(t=eG.current)||t.blur(),null==(l=eA())||l.classList.remove("dropdown__container--opened")),em&&ep){var e,n,t,l,o,r,i,u,c=null==ez||null==(o=ez.current)?void 0:o.querySelector("button[value='".concat(null!=eQ?eQ:S,"']"));c&&(null==ez||null==(u=ez.current)||u.scrollTo(0,(null==c||null==(r=c.getBoundingClientRect())?void 0:r.y)-(null==ez||null==(i=ez.current)?void 0:i.getBoundingClientRect().y)-16))}!em&&ep&&e_(null)},[em]),(0,c.useEffect)(function(){if(!ep){var e,n=null==(e=eA())?void 0:e.getElementsByClassName("dropdown__list")[0],t=function(e){var t=n.scrollTop,l=n.scrollHeight,o=n.clientHeight,r=e.deltaY<0,i=e.deltaY>0;(r&&t<=0||i&&t+o>=l-1)&&e.preventDefault()};return em?null==n||n.addEventListener("wheel",t,{passive:!1}):null==n||n.removeEventListener("wheel",t),function(){null==n||n.removeEventListener("wheel",t)}}return function(){}},[em,ep]),(0,c.useEffect)(function(){if(em&&ep&&(null==ez?void 0:ez.current)&&!eg){var e,n,t,l;eO((null==ez||null==(e=ez.current)?void 0:e.scrollHeight)>(null==ez||null==(n=ez.current)?void 0:n.clientHeight)),eS(eC||(null==ez||null==(t=ez.current)?void 0:t.scrollHeight)>(null==ez||null==(l=ez.current)?void 0:l.clientHeight))}},[em,ep,eC,null==ez?void 0:ez.current,null==ez||null==(j=ez.current)?void 0:j.scrollHeight,null==ez||null==(x=ez.current)?void 0:x.clientHeight]),(0,c.useEffect)(function(){var e,n=function(e){var n,t;eI(Number.parseInt(null==e||null==(t=e.target)||null==(n=t.scrollTop)?void 0:n.toString(),10))};return em&&ep&&(null==ez?void 0:ez.current)&&(null==ez||null==(e=ez.current)||e.addEventListener("scroll",n)),function(){if((null==ez?void 0:ez.current)!==null){var e;null==ez||null==(e=ez.current)||e.removeEventListener("scroll",n)}}},[em,ep,null==ez?void 0:ez.current]),(0,c.useEffect)(function(){if(null==ez?void 0:ez.current){var e,n;eH(Number.parseInt(((null==ez||null==(e=ez.current)?void 0:e.scrollHeight)-(null==ez||null==(n=ez.current)?void 0:n.clientHeight)).toString(),10))}},[eN,null==ez?void 0:ez.current]),!E)return null;return(0,i.jsxs)("div",{className:(0,u.default)(_,M,(n(L={disabled:I},"".concat(_,"-mobile"),ep),n(L,"".concat(_,"--focused"),em&&!ep),n(L,"".concat(_,"--with-custom-trigger"),!!J),L)),ref:eU,onKeyDown:e6,onKeyUp:e8,children:[(0,i.jsx)("button",{type:"button","data-testid":q,className:(0,u.default)("".concat(_,"__trigger"),"input__wrap",(n(C={},"".concat(_,"__trigger--with-actions"),G),n(C,"placeholder",null==S||""===S),n(C,"error",N),C)),onClick:function(){return eh(!0)},onKeyDown:e6,onKeyUp:e8,tabIndex:Q,children:J||(0,i.jsxs)(i.Fragment,{children:[eJ&&!ep?(0,i.jsx)("input",{ref:eG,className:"".concat(_,"__input"),value:String(em?null!=eg?eg:"":null!=eK?eK:""),onChange:function(e){return e5(e.target.value)},placeholder:H,onFocus:function(){return eL(!0)},onBlur:function(){return eL(!1)}}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text",children:eK||H||""}),eV&&(0,i.jsx)("span",{className:"dropdown__list-item-postfix",children:eV})]}),(0,i.jsx)("span",{className:(0,u.default)("".concat(_,"__arrow"),n({},"".concat(_,"__arrow_active"),em)),onClick:function(e){null==e||e.stopPropagation(),eh(function(e){return!e})},children:ep?(0,i.jsx)(s.Code,{className:"mobile-icon"}):em?(0,i.jsx)(s.ChevronUp,{}):(0,i.jsx)(s.ChevronDown,{})})]})}),G&&(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__actions")),children:[(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__actions-item")),onClick:Z,children:(0,i.jsx)(s.Check,{})}),(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__actions-item")),onClick:ee,children:(0,i.jsx)(s.X,{})})]}),em&&((y=eA())?(0,a.createPortal)((0,i.jsx)("div",{"data-testid":"".concat(q,"-container-wrapper"),className:(0,u.default)("".concat(_,"__container-wrapper")),ref:e$,onClick:ep?e4:function(){},children:(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list-wrapper"),(n(r={},"".concat(_,"__list-wrapper--fixed-height"),eE),n(r,"".concat(_,"__list-wrapper--with-bottom-shadow"),eC&&ep&&!el),n(r,"".concat(_,"__list-wrapper--with-bottom-shadow-hidden"),eN===ek&&!el),r)),ref:eX,children:[ep&&(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list-header"),(n(h={},"".concat(_,"__list-header-with-shadow"),eC&&ep),n(h,"".concat(_,"__list-header-with-shadow-hidden"),0===eN),h)),children:[(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list-header-row")),children:[(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-label")),children:O}),(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-close-icon")),onClick:e1,children:(0,i.jsx)(s.X,{onClick:e1})})]}),eJ&&(0,i.jsx)("div",{className:(0,u.default)("".concat(_,"__list-header-row")),children:(0,i.jsx)(v.default,{ref:eG,className:"".concat(_,"__input"),value:eg||"",onChange:e5,placeholder:H||"Search",withDelete:!0,onFocus:function(){return eL(!0)},onBlur:function(){return eL(!1)}})})]}),(0,i.jsxs)("div",{className:(0,u.default)("".concat(_,"__list"),(n(g={},"".concat(_,"__list-top"),D),n(g,"".concat(_,"__list--with-footer"),el),g)),ref:ez,children:[ni.options&&(null==(o=eB(ni.options))?void 0:o.map(function(e,t){if(null==e||null==(i=e.items)?void 0:i.length)if(!eJ||!ey)return nc(e);else{var l,o,r,i,u,c,a=null==(c=e.items)?void 0:c.slice().filter(function(e){var n;return(null==e||null==(n=e.label)?void 0:n.toLowerCase().includes((null==eg?void 0:eg.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)===""});if(null==a?void 0:a.length)return nc((l=function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{},o=Object.keys(l);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(l).filter(function(e){return Object.getOwnPropertyDescriptor(l,e).enumerable}))),o.forEach(function(t){n(e,t,l[t])})}return e}({},e),o=o={items:a},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):(function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t.push.apply(t,l)}return t})(Object(o)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(o,e))}),l))}else if(!eJ||!ey||(null==e||null==(u=e.label)?void 0:u.toLowerCase().includes((null==eg?void 0:eg.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)==="")return nu(e,t,null==(r=(null==e?void 0:e.testId)||t)?void 0:r.toString());return null})),!(null==eq?void 0:eq.length)&&!(null==eF?void 0:eF.length)&&(0,i.jsx)("div",{className:"".concat(_,"__list-item ").concat(_,"__list-item--no-options"),children:z}),I&&em&&(0,i.jsx)(p.default,{})]}),el&&(0,i.jsx)("div",{ref:eY,className:(0,u.default)("".concat(_,"__footer"),(n(b={},"".concat(_,"__footer-with-shadow"),ep&&eC),n(b,"".concat(_,"__footer-with-shadow-hidden"),eN===ek),b)),children:el})]})}),y):null)]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,
|
|
1
|
+
function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return r}});var e=require("react"),r=function(){var r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.isWithoutWidthCheck,o=function(){var t=navigator.userAgent||navigator.vendor||window.opera,e=/Macintosh/.test(t),r=navigator.maxTouchPoints&&navigator.maxTouchPoints>2;return e&&!!r},a=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||o()},u=(r=(0,e.useState)(a()),function(t){if(Array.isArray(t))return t}(r)||function(t,e){var r,n,i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var o=[],a=!0,u=!1;try{for(i=i.call(t);!(a=(r=i.next()).done)&&(o.push(r.value),o.length!==e);a=!0);}catch(t){u=!0,n=t}finally{try{a||null==i.return||i.return()}finally{if(u)throw n}}return o}}(r,2)||function(e,r){if(e){if("string"==typeof e)return t(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}}(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=u[0],l=u[1];return(0,e.useEffect)(function(){a()&&l(!0)},[navigator.userAgent]),{isMobile:c&&(void 0!==i&&i||window.screen.width<=768||window.screen.width<=1024&&window.matchMedia("(orientation: landscape)").matches),isMobilePortrait:c&&window.screen.width<=768&&window.matchMedia("(orientation: portait)").matches,isMobileLandscape:c&&window.screen.width<=1024&&window.matchMedia("(orientation: landscape)").matches}};
|