@bikdotai/bik-component-library 0.0.726-beta.4 → 0.0.726-beta.5

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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),t=require("react"),s=require("../../../zeroState/ZeroState.js"),n=require("../../../../hooks/useOutside.js"),o=require("../../hooks/useDropdown.js"),r=require("./description/Description.js"),i=require("./menu/FreeFormMenu.js"),l=require("./menu/MenuList.js"),u=require("./menu/SelectAllMenu.js"),c=require("./multiSelect/MultiSelectDropdownBottomBar.js"),a=require("./OpennedDropdown.styled.js"),d=require("./searchbox/SearchBox.js"),p=require("./searchbox/SearchZeroState.js");const h=304,f=290;exports.OpenedDropdown=x=>{let{options:j,isSearchable:S,isMultiSelect:b,maxSelections:g,width:m,allowFreeForm:v,height:O,onClose:w,onSelect:y,onSearch:D,version:E,skipSorting:C,headerRef:R,hideSelectAll:q,primaryButtonText:M,onInfiniteScroll:k,onMultiSelectClear:L,onDropdownItemClick:A,buttonOptions:F,isSearchLoading:I,disableSearchOptions:B,disableSearchedOptionExcept:H,useDefaultCursor:T,containerStyle:Z={},zeroState:_}=x;const{dropdownOptions:z,search:K,searchedString:P,searchedOptions:W,onApplyHandler:N,selectAllHandler:U,onMultiSelectClear:V,onFreeFormSelect:$,onMultiSelectApply:G,latestDropdownOptionsRef:J,getSelectedOptions:Q,getCurrentSelectionCount:X}=o.useDropdown(E,j,y,C,b,D,B,H,g),[Y,ee]=t.useState(null!=m?m:f),[te,se]=t.useState(null),[ne,oe]=t.useState(-1),re=t.useRef(null),ie=t.useRef([]),le=t.useRef(null);n.useOutside(re,(()=>{if(se(null),b&&"2.0"===E){const e=Q(J.current);null==w||w(e)}else null==w||w(z)}),[R,ie]),t.useEffect((()=>{var e;if(null==ne)return;const t=null===(e=le.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${ne}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),[ne]);t.useEffect((()=>{oe(-1)}),[P,W,z]);t.useEffect((()=>{le.current&&le.current.focus()}),[]);const ue=null!=O?O:h,ce="number"==typeof ue?S&&b?ue-96:S&&!b||!S&&b?ue-48:ue:ue;t.useEffect((()=>{const e=null!=m?m:f;if(null===te)ee(e);else if("number"==typeof e)ee(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ee(t)}}),[te]);const ae=[],de=(e=>{if(!b||!g&&0!==g)return e;const t=X(e)>=g;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const s=e;return Object.assign(Object.assign({},s),{disabled:s.disabled||!s.selected&&t})}})):e})((P&&D?W:z).map((e=>{var t,s;if(P&&!D){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))&&(ae.push(!P||e.label===P),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))||(null===(s=e.searchKey)||void 0===s?void 0:s.toLowerCase().includes(P.toLowerCase()))?(ae.push(!P||e.label===P),e):null}return e})).filter((e=>null!==e))),pe=!!S&&P&&0===de.length;return e.jsxRuntimeExports.jsxs(a.OpennedDropdownContainer,Object.assign({version:E,ref:re,style:Object.assign({width:Y},Z)},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{width:te?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!S&&e.jsxRuntimeExports.jsx(d.SearchBox,{onSearch:K,version:E}),de.length||P?e.jsxRuntimeExports.jsxs(a.MenuListContainer,Object.assign({minHeight:ue,maxHeight:ce,ref:le,tabIndex:0,onKeyDown:e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const s=e;s.disabled||t.push(s)}})),t})(P&&D?W:z);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),oe((e=>e<t.length-1?e+1:0));else if("ArrowUp"===e.key)e.preventDefault(),oe((e=>e>0?e-1:t.length-1));else if("Enter"===e.key&&ne>=0){e.preventDefault();const s=t[ne];s&&N(Object.assign(Object.assign({},s),{selected:!s.selected}))}else"Escape"===e.key&&(e.preventDefault(),null==w||w())}},{children:[!!b&&!pe&&!q&&e.jsxRuntimeExports.jsx(u.SelectAllMenu,{version:E,options:P&&D?W:z,onSelect:U}),!v&&pe&&e.jsxRuntimeExports.jsx(p.SearchZeroState,{isLoading:I,height:ce,searchedString:P,containerWidth:m}),v&&(pe||!!ae.length&&ae.every((e=>!1===e)))&&e.jsxRuntimeExports.jsx(i.FreeFormMenu,{version:E,isMultiSelect:b,onSelect:$,searchedString:P}),e.jsxRuntimeExports.jsx(l.MenuList,{onInfiniteScroll:k,onDropdownItemClick:A,version:E,onSelect:N,showDescription:function(e,t){se(e&&t?{title:e,description:t}:null)},isMultiSelect:b,options:de,useDefaultCursor:T,ref:ie,focusedIndex:ne})]})):e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:ue,display:"flex"}},{children:e.jsxRuntimeExports.jsx(s.ZeroState,Object.assign({},_,{title:(null==_?void 0:_.title)||"No results found",subTitle:(null==_?void 0:_.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!b&&!(!de.length&&!P)&&"2.0"!==E&&e.jsxRuntimeExports.jsx(c.default,{onClear:()=>{V(),null==L||L()},onApply:G,list:P&&D?W:z,buttonText:M,buttonOptions:F})]})),!!te&&e.jsxRuntimeExports.jsx(r.Description,{title:te.title,description:te.description,version:E})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),t=require("react"),s=require("../../../zeroState/ZeroState.js"),n=require("../../../../hooks/useOutside.js"),o=require("../../hooks/useDropdown.js"),r=require("./description/Description.js"),i=require("./menu/FreeFormMenu.js"),l=require("./menu/MenuList.js"),u=require("./menu/SelectAllMenu.js"),c=require("./multiSelect/MultiSelectDropdownBottomBar.js"),a=require("./OpennedDropdown.styled.js"),d=require("./searchbox/SearchBox.js"),p=require("./searchbox/SearchZeroState.js");const h=304,x=290;exports.OpenedDropdown=j=>{let{options:f,isSearchable:S,isMultiSelect:b,maxSelections:m,width:g,allowFreeForm:v,height:w,onClose:O,onSelect:y,onSearch:E,version:D,skipSorting:C,headerRef:R,hideSelectAll:q,primaryButtonText:M,onInfiniteScroll:k,onMultiSelectClear:L,onDropdownItemClick:A,buttonOptions:F,isSearchLoading:I,disableSearchOptions:T,disableSearchedOptionExcept:B,useDefaultCursor:H,containerStyle:Z={},zeroState:_}=j;const{dropdownOptions:z,search:P,searchedString:V,searchedOptions:W,onApplyHandler:$,selectAllHandler:K,onMultiSelectClear:N,onFreeFormSelect:U,onMultiSelectApply:G,latestDropdownOptionsRef:J,getSelectedOptions:Q,getCurrentSelectionCount:X}=o.useDropdown(D,f,y,C,b,E,T,B,m),[Y,ee]=t.useState(null!=g?g:x),[te,se]=t.useState(null),[ne,oe]=t.useState(-1),re=t.useRef(null),ie=t.useRef([]),le=t.useRef(null);n.useOutside(re,(()=>{if(se(null),b&&"2.0"===D){const e=Q(J.current);null==O||O(e)}else null==O||O(z)}),[R,ie]);t.useEffect((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const s=e;s.disabled||t.push(s)}})),t})(V&&E?W:z);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),oe((e=>{const s=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=le.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${s}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),s}));else if("ArrowUp"===e.key)e.preventDefault(),oe((e=>{const s=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=le.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${s}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),s}));else if("Enter"===e.key&&ne>=0){e.preventDefault();const s=t[ne];s&&$(Object.assign(Object.assign({},s),{selected:!s.selected}))}};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}}),[ne,V,W,z,E,$]);const ue=null!=w?w:h,ce="number"==typeof ue?S&&b?ue-96:S&&!b||!S&&b?ue-48:ue:ue;t.useEffect((()=>{const e=null!=g?g:x;if(null===te)ee(e);else if("number"==typeof e)ee(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ee(t)}}),[te]);const ae=[],de=(e=>{if(!b||!m&&0!==m)return e;const t=X(e)>=m;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const s=e;return Object.assign(Object.assign({},s),{disabled:s.disabled||!s.selected&&t})}})):e})((V&&E?W:z).map((e=>{var t,s;if(V&&!E){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))&&(ae.push(!V||e.label===V),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))||(null===(s=e.searchKey)||void 0===s?void 0:s.toLowerCase().includes(V.toLowerCase()))?(ae.push(!V||e.label===V),e):null}return e})).filter((e=>null!==e))),pe=!!S&&V&&0===de.length;return e.jsxRuntimeExports.jsxs(a.OpennedDropdownContainer,Object.assign({version:D,ref:re,style:Object.assign({width:Y},Z)},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{width:te?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!S&&e.jsxRuntimeExports.jsx(d.SearchBox,{onSearch:P,version:D}),de.length||V?e.jsxRuntimeExports.jsxs(a.MenuListContainer,Object.assign({minHeight:ue,maxHeight:ce,ref:le},{children:[!!b&&!pe&&!q&&e.jsxRuntimeExports.jsx(u.SelectAllMenu,{version:D,options:V&&E?W:z,onSelect:K}),!v&&pe&&e.jsxRuntimeExports.jsx(p.SearchZeroState,{isLoading:I,height:ce,searchedString:V,containerWidth:g}),v&&(pe||!!ae.length&&ae.every((e=>!1===e)))&&e.jsxRuntimeExports.jsx(i.FreeFormMenu,{version:D,isMultiSelect:b,onSelect:U,searchedString:V}),e.jsxRuntimeExports.jsx(l.MenuList,{onInfiniteScroll:k,onDropdownItemClick:A,version:D,onSelect:$,showDescription:function(e,t){se(e&&t?{title:e,description:t}:null)},isMultiSelect:b,options:de,useDefaultCursor:H,ref:ie,focusedIndex:ne})]})):e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:ue,display:"flex"}},{children:e.jsxRuntimeExports.jsx(s.ZeroState,Object.assign({},_,{title:(null==_?void 0:_.title)||"No results found",subTitle:(null==_?void 0:_.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!b&&!(!de.length&&!V)&&"2.0"!==D&&e.jsxRuntimeExports.jsx(c.default,{onClear:()=>{N(),null==L||L()},onApply:G,list:V&&E?W:z,buttonText:M,buttonOptions:F})]})),!!te&&e.jsxRuntimeExports.jsx(r.Description,{title:te.title,description:te.description,version:D})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../node_modules/react/jsx-runtime.js"),t=require("react"),s=require("./MenuItem.js"),n=require("./MenuList.styled.js");const r=t.forwardRef(((r,o)=>{let{options:i,isMultiSelect:u,showDescription:c,onSelect:l,version:d,onInfiniteScroll:x,onDropdownItemClick:a,useDefaultCursor:p,focusedIndex:j=-1}=r;const m=t.useRef(null),f=t.useRef(null),b=t.useCallback((()=>{m.current&&m.current.disconnect(),m.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==x||x())})),f.current&&m.current.observe(f.current)}),[x]);t.useEffect((()=>(b(),()=>{m.current&&m.current.disconnect()})),[b,i]);let I=-1;const R=e=>(e.disabled||(I+=1),I);return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:i.map(((t,r)=>{const x=r===i.length-1;if(t.options){const i=t;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginTop:"2.0"===d?2:0}},{children:[e.jsxRuntimeExports.jsxs(n.StyledGroupedLabel,Object.assign({version:d},{children:[i.leadingIcon?e.jsxRuntimeExports.jsx("span",Object.assign({style:{marginRight:8}},{children:i.leadingIcon})):null,i.label]})),i.options.map(((t,n)=>{const x=R(t),m=x===j&&!t.disabled;return e.jsxRuntimeExports.jsx(s.MenuItem,{version:d,last:n===i.options.length-1,onSelect:l,showDescription:c,onDropdownItemClick:a,isMultiSelect:u,option:t,useDefaultCursor:p,isFocused:m,dataIndex:x,ref:e=>{o&&"object"==typeof o&&o.current&&e&&e&&e&&e&&(o.current[r]=e)}},`${r}-${n}`)})),x?e.jsxRuntimeExports.jsx("span",{ref:f}):null]}),r)}const m=t,b=R(m),I=b===j&&!m.disabled;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(s.MenuItem,{version:d,last:x,onSelect:l,showDescription:c,onDropdownItemClick:a,isMultiSelect:u,option:m,useDefaultCursor:p,isFocused:I,dataIndex:b,ref:e=>{o&&"object"==typeof o&&o.current&&e&&(o.current[r]=e)}},r),x?e.jsxRuntimeExports.jsx("span",{ref:f}):null]},r)}))})}));exports.MenuList=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../node_modules/react/jsx-runtime.js"),t=require("react"),s=require("./MenuItem.js"),n=require("./MenuList.styled.js");const r=t.forwardRef(((r,o)=>{let{options:i,isMultiSelect:u,showDescription:c,onSelect:l,version:a,onInfiniteScroll:d,onDropdownItemClick:p,useDefaultCursor:x,focusedIndex:j=-1}=r;const m=t.useRef(null),f=t.useRef(null),b=t.useCallback((()=>{m.current&&m.current.disconnect(),m.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==d||d())})),f.current&&m.current.observe(f.current)}),[d]);t.useEffect((()=>(b(),()=>{m.current&&m.current.disconnect()})),[b,i]);const g=new Map;let I=-1;return i.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||(I++,g.set(e,I))}));else{const t=e;t.disabled||(I++,g.set(t,I))}})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:i.map(((t,r)=>{const d=r===i.length-1;if(t.options){const i=t;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginTop:"2.0"===a?2:0}},{children:[e.jsxRuntimeExports.jsxs(n.StyledGroupedLabel,Object.assign({version:a},{children:[i.leadingIcon?e.jsxRuntimeExports.jsx("span",Object.assign({style:{marginRight:8}},{children:i.leadingIcon})):null,i.label]})),i.options.map(((t,n)=>{const d=g.get(t),m=d===j&&!t.disabled;return e.jsxRuntimeExports.jsx(s.MenuItem,{version:a,last:n===i.options.length-1,onSelect:l,showDescription:c,onDropdownItemClick:p,isMultiSelect:u,option:t,useDefaultCursor:x,isFocused:m,dataIndex:d,ref:e=>{o&&"object"==typeof o&&o.current&&e&&e&&e&&e&&(o.current[r]=e)}},`${r}-${n}`)})),d?e.jsxRuntimeExports.jsx("span",{ref:f}):null]}),r)}const m=t,b=g.get(m),I=b===j&&!m.disabled;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(s.MenuItem,{version:a,last:d,onSelect:l,showDescription:c,onDropdownItemClick:p,isMultiSelect:u,option:m,useDefaultCursor:x,isFocused:I,dataIndex:b,ref:e=>{o&&"object"==typeof o&&o.current&&e&&(o.current[r]=e)}},r),d?e.jsxRuntimeExports.jsx("span",{ref:f}):null]},r)}))})}));exports.MenuList=r;
@@ -1 +1 @@
1
- import{j as e}from"../../../../node_modules/react/jsx-runtime.js";import{useState as t,useRef as o,useEffect as n}from"react";import{ZeroState as s}from"../../../zeroState/ZeroState.js";import{useOutside as i}from"../../../../hooks/useOutside.js";import{useDropdown as r}from"../../hooks/useDropdown.js";import{Description as l}from"./description/Description.js";import{FreeFormMenu as c}from"./menu/FreeFormMenu.js";import{MenuList as a}from"./menu/MenuList.js";import{SelectAllMenu as u}from"./menu/SelectAllMenu.js";import p from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as d,MenuListContainer as f}from"./OpennedDropdown.styled.js";import{SearchBox as h}from"./searchbox/SearchBox.js";import{SearchZeroState as m}from"./searchbox/SearchZeroState.js";const b=304,j=290,g=g=>{let{options:S,isSearchable:x,isMultiSelect:v,maxSelections:O,width:w,allowFreeForm:y,height:D,onClose:C,onSelect:k,onSearch:M,version:L,skipSorting:A,headerRef:I,hideSelectAll:F,primaryButtonText:E,onInfiniteScroll:B,onMultiSelectClear:H,onDropdownItemClick:T,buttonOptions:q,isSearchLoading:z,disableSearchOptions:K,disableSearchedOptionExcept:R,useDefaultCursor:W,containerStyle:Z={},zeroState:N}=g;const{dropdownOptions:P,search:U,searchedString:V,searchedOptions:$,onApplyHandler:_,selectAllHandler:G,onMultiSelectClear:J,onFreeFormSelect:Q,onMultiSelectApply:X,latestDropdownOptionsRef:Y,getSelectedOptions:ee,getCurrentSelectionCount:te}=r(L,S,k,A,v,M,K,R,O),[oe,ne]=t(null!=w?w:j),[se,ie]=t(null),[re,le]=t(-1),ce=o(null),ae=o([]),ue=o(null);i(ce,(()=>{if(ie(null),v&&"2.0"===L){const e=ee(Y.current);null==C||C(e)}else null==C||C(P)}),[I,ae]),n((()=>{var e;if(null==re)return;const t=null===(e=ue.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${re}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),[re]);n((()=>{le(-1)}),[V,$,P]);n((()=>{ue.current&&ue.current.focus()}),[]);const pe=null!=D?D:b,de="number"==typeof pe?x&&v?pe-96:x&&!v||!x&&v?pe-48:pe:pe;n((()=>{const e=null!=w?w:j;if(null===se)ne(e);else if("number"==typeof e)ne(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ne(t)}}),[se]);const fe=[],he=(e=>{if(!v||!O&&0!==O)return e;const t=te(e)>=O;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const o=e;return Object.assign(Object.assign({},o),{disabled:o.disabled||!o.selected&&t})}})):e})((V&&M?$:P).map((e=>{var t,o;if(V&&!M){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))&&(fe.push(!V||e.label===V),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(V.toLowerCase()))?(fe.push(!V||e.label===V),e):null}return e})).filter((e=>null!==e))),me=!!x&&V&&0===he.length;return e.jsxs(d,Object.assign({version:L,ref:ce,style:Object.assign({width:oe},Z)},{children:[e.jsxs("div",Object.assign({style:{width:se?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!x&&e.jsx(h,{onSearch:U,version:L}),he.length||V?e.jsxs(f,Object.assign({minHeight:pe,maxHeight:de,ref:ue,tabIndex:0,onKeyDown:e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const o=e;o.disabled||t.push(o)}})),t})(V&&M?$:P);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),le((e=>e<t.length-1?e+1:0));else if("ArrowUp"===e.key)e.preventDefault(),le((e=>e>0?e-1:t.length-1));else if("Enter"===e.key&&re>=0){e.preventDefault();const o=t[re];o&&_(Object.assign(Object.assign({},o),{selected:!o.selected}))}else"Escape"===e.key&&(e.preventDefault(),null==C||C())}},{children:[!!v&&!me&&!F&&e.jsx(u,{version:L,options:V&&M?$:P,onSelect:G}),!y&&me&&e.jsx(m,{isLoading:z,height:de,searchedString:V,containerWidth:w}),y&&(me||!!fe.length&&fe.every((e=>!1===e)))&&e.jsx(c,{version:L,isMultiSelect:v,onSelect:Q,searchedString:V}),e.jsx(a,{onInfiniteScroll:B,onDropdownItemClick:T,version:L,onSelect:_,showDescription:function(e,t){ie(e&&t?{title:e,description:t}:null)},isMultiSelect:v,options:he,useDefaultCursor:W,ref:ae,focusedIndex:re})]})):e.jsx("div",Object.assign({style:{height:pe,display:"flex"}},{children:e.jsx(s,Object.assign({},N,{title:(null==N?void 0:N.title)||"No results found",subTitle:(null==N?void 0:N.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!v&&!(!he.length&&!V)&&"2.0"!==L&&e.jsx(p,{onClear:()=>{J(),null==H||H()},onApply:X,list:V&&M?$:P,buttonText:E,buttonOptions:q})]})),!!se&&e.jsx(l,{title:se.title,description:se.description,version:L})]}))};export{g as OpenedDropdown};
1
+ import{j as e}from"../../../../node_modules/react/jsx-runtime.js";import{useState as t,useRef as o,useEffect as n}from"react";import{ZeroState as s}from"../../../zeroState/ZeroState.js";import{useOutside as i}from"../../../../hooks/useOutside.js";import{useDropdown as r}from"../../hooks/useDropdown.js";import{Description as l}from"./description/Description.js";import{FreeFormMenu as c}from"./menu/FreeFormMenu.js";import{MenuList as a}from"./menu/MenuList.js";import{SelectAllMenu as u}from"./menu/SelectAllMenu.js";import d from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as p,MenuListContainer as h}from"./OpennedDropdown.styled.js";import{SearchBox as m}from"./searchbox/SearchBox.js";import{SearchZeroState as f}from"./searchbox/SearchZeroState.js";const b=304,j=290,g=g=>{let{options:S,isSearchable:v,isMultiSelect:x,maxSelections:w,width:y,allowFreeForm:O,height:C,onClose:D,onSelect:k,onSearch:L,version:M,skipSorting:A,headerRef:I,hideSelectAll:E,primaryButtonText:F,onInfiniteScroll:T,onMultiSelectClear:B,onDropdownItemClick:H,buttonOptions:q,isSearchLoading:z,disableSearchOptions:R,disableSearchedOptionExcept:V,useDefaultCursor:W,containerStyle:Z={},zeroState:$}=g;const{dropdownOptions:K,search:N,searchedString:P,searchedOptions:U,onApplyHandler:_,selectAllHandler:G,onMultiSelectClear:J,onFreeFormSelect:Q,onMultiSelectApply:X,latestDropdownOptionsRef:Y,getSelectedOptions:ee,getCurrentSelectionCount:te}=r(M,S,k,A,x,L,R,V,w),[oe,ne]=t(null!=y?y:j),[se,ie]=t(null),[re,le]=t(-1),ce=o(null),ae=o([]),ue=o(null);i(ce,(()=>{if(ie(null),x&&"2.0"===M){const e=ee(Y.current);null==D||D(e)}else null==D||D(K)}),[I,ae]);n((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const o=e;o.disabled||t.push(o)}})),t})(P&&L?U:K);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),le((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=ue.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("ArrowUp"===e.key)e.preventDefault(),le((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=ue.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("Enter"===e.key&&re>=0){e.preventDefault();const o=t[re];o&&_(Object.assign(Object.assign({},o),{selected:!o.selected}))}};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}}),[re,P,U,K,L,_]);const de=null!=C?C:b,pe="number"==typeof de?v&&x?de-96:v&&!x||!v&&x?de-48:de:de;n((()=>{const e=null!=y?y:j;if(null===se)ne(e);else if("number"==typeof e)ne(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ne(t)}}),[se]);const he=[],me=(e=>{if(!x||!w&&0!==w)return e;const t=te(e)>=w;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const o=e;return Object.assign(Object.assign({},o),{disabled:o.disabled||!o.selected&&t})}})):e})((P&&L?U:K).map((e=>{var t,o;if(P&&!L){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))&&(he.push(!P||e.label===P),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(P.toLowerCase()))?(he.push(!P||e.label===P),e):null}return e})).filter((e=>null!==e))),fe=!!v&&P&&0===me.length;return e.jsxs(p,Object.assign({version:M,ref:ce,style:Object.assign({width:oe},Z)},{children:[e.jsxs("div",Object.assign({style:{width:se?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!v&&e.jsx(m,{onSearch:N,version:M}),me.length||P?e.jsxs(h,Object.assign({minHeight:de,maxHeight:pe,ref:ue},{children:[!!x&&!fe&&!E&&e.jsx(u,{version:M,options:P&&L?U:K,onSelect:G}),!O&&fe&&e.jsx(f,{isLoading:z,height:pe,searchedString:P,containerWidth:y}),O&&(fe||!!he.length&&he.every((e=>!1===e)))&&e.jsx(c,{version:M,isMultiSelect:x,onSelect:Q,searchedString:P}),e.jsx(a,{onInfiniteScroll:T,onDropdownItemClick:H,version:M,onSelect:_,showDescription:function(e,t){ie(e&&t?{title:e,description:t}:null)},isMultiSelect:x,options:me,useDefaultCursor:W,ref:ae,focusedIndex:re})]})):e.jsx("div",Object.assign({style:{height:de,display:"flex"}},{children:e.jsx(s,Object.assign({},$,{title:(null==$?void 0:$.title)||"No results found",subTitle:(null==$?void 0:$.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!x&&!(!me.length&&!P)&&"2.0"!==M&&e.jsx(d,{onClear:()=>{J(),null==B||B()},onApply:X,list:P&&L?U:K,buttonText:F,buttonOptions:q})]})),!!se&&e.jsx(l,{title:se.title,description:se.description,version:M})]}))};export{g as OpenedDropdown};
@@ -1 +1 @@
1
- import{j as e}from"../../../../../node_modules/react/jsx-runtime.js";import{forwardRef as n,useRef as t,useCallback as r,useEffect as s}from"react";import{MenuItem as o}from"./MenuItem.js";import{StyledGroupedLabel as i}from"./MenuList.styled.js";const c=n(((n,c)=>{let{options:l,isMultiSelect:u,showDescription:d,onSelect:a,version:p,onInfiniteScroll:j,onDropdownItemClick:m,useDefaultCursor:f,focusedIndex:x=-1}=n;const g=t(null),I=t(null),b=r((()=>{g.current&&g.current.disconnect(),g.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==j||j())})),I.current&&g.current.observe(I.current)}),[j]);s((()=>(b(),()=>{g.current&&g.current.disconnect()})),[b,l]);let h=-1;const D=e=>(e.disabled||(h+=1),h);return e.jsx(e.Fragment,{children:l.map(((n,t)=>{const r=t===l.length-1;if(n.options){const s=n;return e.jsxs("div",Object.assign({style:{marginTop:"2.0"===p?2:0}},{children:[e.jsxs(i,Object.assign({version:p},{children:[s.leadingIcon?e.jsx("span",Object.assign({style:{marginRight:8}},{children:s.leadingIcon})):null,s.label]})),s.options.map(((n,r)=>{const i=D(n),l=i===x&&!n.disabled;return e.jsx(o,{version:p,last:r===s.options.length-1,onSelect:a,showDescription:d,onDropdownItemClick:m,isMultiSelect:u,option:n,useDefaultCursor:f,isFocused:l,dataIndex:i,ref:e=>{c&&"object"==typeof c&&c.current&&e&&e&&e&&e&&(c.current[t]=e)}},`${t}-${r}`)})),r?e.jsx("span",{ref:I}):null]}),t)}const s=n,j=D(s),g=j===x&&!s.disabled;return e.jsxs("div",{children:[e.jsx(o,{version:p,last:r,onSelect:a,showDescription:d,onDropdownItemClick:m,isMultiSelect:u,option:s,useDefaultCursor:f,isFocused:g,dataIndex:j,ref:e=>{c&&"object"==typeof c&&c.current&&e&&(c.current[t]=e)}},t),r?e.jsx("span",{ref:I}):null]},t)}))})}));export{c as MenuList};
1
+ import{j as e}from"../../../../../node_modules/react/jsx-runtime.js";import{forwardRef as n,useRef as t,useCallback as s,useEffect as r}from"react";import{MenuItem as o}from"./MenuItem.js";import{StyledGroupedLabel as i}from"./MenuList.styled.js";const c=n(((n,c)=>{let{options:l,isMultiSelect:u,showDescription:a,onSelect:d,version:p,onInfiniteScroll:f,onDropdownItemClick:j,useDefaultCursor:m,focusedIndex:g=-1}=n;const x=t(null),h=t(null),b=s((()=>{x.current&&x.current.disconnect(),x.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==f||f())})),h.current&&x.current.observe(h.current)}),[f]);r((()=>(b(),()=>{x.current&&x.current.disconnect()})),[b,l]);const I=new Map;let D=-1;return l.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||(D++,I.set(e,D))}));else{const n=e;n.disabled||(D++,I.set(n,D))}})),e.jsx(e.Fragment,{children:l.map(((n,t)=>{const s=t===l.length-1;if(n.options){const r=n;return e.jsxs("div",Object.assign({style:{marginTop:"2.0"===p?2:0}},{children:[e.jsxs(i,Object.assign({version:p},{children:[r.leadingIcon?e.jsx("span",Object.assign({style:{marginRight:8}},{children:r.leadingIcon})):null,r.label]})),r.options.map(((n,s)=>{const i=I.get(n),l=i===g&&!n.disabled;return e.jsx(o,{version:p,last:s===r.options.length-1,onSelect:d,showDescription:a,onDropdownItemClick:j,isMultiSelect:u,option:n,useDefaultCursor:m,isFocused:l,dataIndex:i,ref:e=>{c&&"object"==typeof c&&c.current&&e&&e&&e&&e&&(c.current[t]=e)}},`${t}-${s}`)})),s?e.jsx("span",{ref:h}):null]}),t)}const r=n,f=I.get(r),x=f===g&&!r.disabled;return e.jsxs("div",{children:[e.jsx(o,{version:p,last:s,onSelect:d,showDescription:a,onDropdownItemClick:j,isMultiSelect:u,option:r,useDefaultCursor:m,isFocused:x,dataIndex:f,ref:e=>{c&&"object"==typeof c&&c.current&&e&&(c.current[t]=e)}},t),s?e.jsx("span",{ref:h}):null]},t)}))})}));export{c as MenuList};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.726-beta.4",
3
+ "version": "0.0.726-beta.5",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",