@bikdotai/bik-component-library 0.0.763-beta.2 → 0.0.763-beta.20

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