@bikdotai/bik-component-library 0.0.763-beta.57 → 0.0.763-beta.58

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"),r=require("../../hooks/useDropdown.js"),o=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 f=304,h=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:E,onInfiniteScroll:L,onMultiSelectClear:R,onDropdownItemClick:A,buttonOptions:I,isSearchLoading:F,disableSearchOptions:T,disableSearchedOptionExcept:B,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))),N=t.useRef(_),U=t.useRef(!1),G=t.useRef(V);t.useEffect((()=>{K($(S))}),[S,$]),t.useEffect((()=>{N.current=_}),[_]),t.useEffect((()=>{G.current=V}),[V]),t.useEffect((()=>()=>{U.current&&G.current&&G.current(N.current)}),[]);const J=t.useCallback((e=>{const t=$(e);K(t),"2.0"===D?null==V||V(t):U.current=!0}),[V,$,D]),Q=P?_:S,{dropdownOptions:X,search:Y,searchedString:ee,searchedOptions:te,onApplyHandler:ne,selectAllHandler:se,onMultiSelectClear:re,onFreeFormSelect:oe,onMultiSelectApply:ie,latestDropdownOptionsRef:le,getSelectedOptions:ue,getCurrentSelectionCount:ce}=r.useDropdown(D,Q,y,k||P,j,C,T,B,v),[ae,de]=t.useState(null!=x?x:h),[pe,fe]=t.useState(null),[he,be]=t.useState(-1),Se=t.useRef(null),ge=t.useRef([]),je=t.useRef(null);s.useOutside(Se,(()=>{if(fe(null),j&&"2.0"===D){const e=ue(le.current);null==w||w(e)}else null==w||w(X)}),[q,ge]),t.useEffect((()=>{const e=setTimeout((()=>{Se.current&&Se.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})(ee&&C?te:X);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),be((e=>{const n=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="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("ArrowUp"===e.key)e.preventDefault(),be((e=>{const n=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="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("Enter"===e.key&&he>=0){e.preventDefault();const n=t[he];n&&(ne(Object.assign(Object.assign({},n),{selected:!n.selected})),A&&A(n))}},t=Se.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[he,ee,te,X,C,ne,A]);const ve=null!=m?m:f,xe="number"==typeof ve?g&&j?ve-96:g&&!j||!g&&j?ve-48:ve:ve;t.useEffect((()=>{const e=null!=x?x:h;if(null===pe)de(e);else if("number"==typeof e)de(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));de(t)}}),[pe]);const Oe=[],me=(e=>{if(!j||!v&&0!==v)return e;const t=ce(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})((ee&&C?te:X).map((e=>{var t,n;if(ee&&!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(ee.toLowerCase()))&&(Oe.push(!ee||e.label===ee),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(ee.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(ee.toLowerCase()))?(Oe.push(!ee||e.label===ee),e):null}return e})).filter((e=>null!==e))),we=!!g&&ee&&0===me.length;return e.jsxs(a.OpennedDropdownContainer,Object.assign({version:D,ref:Se,tabIndex:-1,style:Object.assign(Object.assign({width:ae},Z),{outline:"none"})},{children:[e.jsxs("div",Object.assign({style:{width:pe?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!g&&e.jsx(d.SearchBox,{onSearch:Y,version:D}),me.length||ee?e.jsxs(a.MenuListContainer,Object.assign({minHeight:ve,maxHeight:xe,ref:je},{children:[!!j&&!we&&!M&&e.jsx(u.SelectAllMenu,{version:D,options:ee&&C?te:X,onSelect:se}),!O&&we&&e.jsx(p.SearchZeroState,{isLoading:F,height:xe,searchedString:ee,containerWidth:x}),O&&(we||!!Oe.length&&Oe.every((e=>!1===e)))&&e.jsx(i.FreeFormMenu,{version:D,isMultiSelect:j,onSelect:oe,searchedString:ee}),e.jsx(l.MenuList,{onInfiniteScroll:L,onDropdownItemClick:A,version:D,onSelect:ne,showDescription:function(e,t){fe(e&&t?{title:e,description:t}:null)},isMultiSelect:j,options:me,useDefaultCursor:H,ref:ge,focusedIndex:he,isDraggable:P,onOptionsReorder:J})]})):e.jsx("div",Object.assign({style:{height:ve,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&&!(!me.length&&!ee)&&"2.0"!==D&&e.jsx(c.default,{onClear:()=>{re(),null==R||R()},onApply:ie,list:ee&&C?te:X,buttonText:E,buttonOptions:I,hideClearButton:W})]})),!!pe&&e.jsx(o.Description,{title:pe.title,description:pe.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"),r=require("../../hooks/useDropdown.js"),o=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 f=304,h=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:E,onInfiniteScroll:L,onMultiSelectClear:R,onDropdownItemClick:A,buttonOptions:I,isSearchLoading:F,disableSearchOptions:T,disableSearchedOptionExcept:B,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))),N=t.useRef(_),U=t.useRef(!1),G=t.useRef(V);t.useEffect((()=>{K($(S))}),[S,$]),t.useEffect((()=>{N.current=_}),[_]),t.useEffect((()=>{G.current=V}),[V]),t.useEffect((()=>()=>{U.current&&G.current&&G.current(N.current)}),[]);const J=t.useCallback((e=>{K(e),"2.0"===D?null==V||V(e):U.current=!0}),[V,D]),Q=P?_:S,{dropdownOptions:X,search:Y,searchedString:ee,searchedOptions:te,onApplyHandler:ne,selectAllHandler:se,onMultiSelectClear:re,onFreeFormSelect:oe,onMultiSelectApply:ie,latestDropdownOptionsRef:le,getSelectedOptions:ue,getCurrentSelectionCount:ce}=r.useDropdown(D,Q,y,k||P,j,C,T,B,v),[ae,de]=t.useState(null!=x?x:h),[pe,fe]=t.useState(null),[he,be]=t.useState(-1),Se=t.useRef(null),ge=t.useRef([]),je=t.useRef(null);s.useOutside(Se,(()=>{if(fe(null),j&&"2.0"===D){const e=ue(le.current);null==w||w(e)}else null==w||w(X)}),[q,ge]),t.useEffect((()=>{const e=setTimeout((()=>{Se.current&&Se.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})(ee&&C?te:X);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),be((e=>{const n=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="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("ArrowUp"===e.key)e.preventDefault(),be((e=>{const n=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="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("Enter"===e.key&&he>=0){e.preventDefault();const n=t[he];n&&(ne(Object.assign(Object.assign({},n),{selected:!n.selected})),A&&A(n))}},t=Se.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[he,ee,te,X,C,ne,A]);const ve=null!=m?m:f,xe="number"==typeof ve?g&&j?ve-96:g&&!j||!g&&j?ve-48:ve:ve;t.useEffect((()=>{const e=null!=x?x:h;if(null===pe)de(e);else if("number"==typeof e)de(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));de(t)}}),[pe]);const Oe=[],me=(e=>{if(!j||!v&&0!==v)return e;const t=ce(X)>=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})((ee&&C?te:X).map((e=>{var t,n;if(ee&&!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(ee.toLowerCase()))&&(Oe.push(!ee||e.label===ee),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(ee.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(ee.toLowerCase()))?(Oe.push(!ee||e.label===ee),e):null}return e})).filter((e=>null!==e))),we=!!g&&ee&&0===me.length;return e.jsxs(a.OpennedDropdownContainer,Object.assign({version:D,ref:Se,tabIndex:-1,style:Object.assign(Object.assign({width:ae},Z),{outline:"none"})},{children:[e.jsxs("div",Object.assign({style:{width:pe?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!g&&e.jsx(d.SearchBox,{onSearch:Y,version:D}),me.length||ee?e.jsxs(a.MenuListContainer,Object.assign({minHeight:ve,maxHeight:xe,ref:je},{children:[!!j&&!we&&!M&&e.jsx(u.SelectAllMenu,{version:D,options:ee&&C?te:X,onSelect:se}),!O&&we&&e.jsx(p.SearchZeroState,{isLoading:F,height:xe,searchedString:ee,containerWidth:x}),O&&(we||!!Oe.length&&Oe.every((e=>!1===e)))&&e.jsx(i.FreeFormMenu,{version:D,isMultiSelect:j,onSelect:oe,searchedString:ee}),e.jsx(l.MenuList,{onInfiniteScroll:L,onDropdownItemClick:A,version:D,onSelect:ne,showDescription:function(e,t){fe(e&&t?{title:e,description:t}:null)},isMultiSelect:j,options:me,useDefaultCursor:H,ref:ge,focusedIndex:he,isDraggable:P,onOptionsReorder:J})]})):e.jsx("div",Object.assign({style:{height:ve,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&&!(!me.length&&!ee)&&"2.0"!==D&&e.jsx(c.default,{onClear:()=>{re(),null==R||R()},onApply:ie,list:ee&&C?te:X,buttonText:E,buttonOptions:I,hideClearButton:W})]})),!!pe&&e.jsx(o.Description,{title:pe.title,description:pe.description,version:D})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),t=require("./MenuItem.js"),s=require("./MenuList.styled.js");const r=n.forwardRef(((r,l)=>{let{options:o,isMultiSelect:i,showDescription:c,onSelect:u,version:a,onInfiniteScroll:d,onDropdownItemClick:p,useDefaultCursor:f,focusedIndex:g=-1,isDraggable:b=!1,onOptionsReorder:D}=r;const j=n.useRef(null),v=n.useRef(null),[x,m]=n.useState(null),[I,h]=n.useState(null),C=n.useCallback((()=>{j.current&&j.current.disconnect(),j.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==d||d())})),v.current&&j.current.observe(v.current)}),[d]);n.useEffect((()=>(C(),()=>{j.current&&j.current.disconnect()})),[C,o]);const S=n.useCallback((e=>n=>{b&&(m(e),n.dataTransfer.effectAllowed="move")}),[b]),w=n.useCallback((e=>n=>{b&&(n.preventDefault(),n.dataTransfer.dropEffect="move",h(e))}),[b]),M=n.useCallback((e=>n=>{if(b&&null!==x){if(n.preventDefault(),x!==e){const n=[...o],t=n[x],s=n[e];if(t.selected===s.selected){const[t]=n.splice(x,1);n.splice(e,0,t),null==D||D(n)}}m(null),h(null)}}),[b,x,o,D]),k=n.useCallback((()=>{m(null),h(null)}),[]),O=new Map;let y=-1;return o.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||(y++,O.set(e,y))}));else{const n=e;n.disabled||(y++,O.set(n,y))}})),e.jsx(e.Fragment,{children:o.map(((n,r)=>{const d=r===o.length-1;if(n.options){const o=n;return e.jsxs("div",Object.assign({style:{marginTop:"2.0"===a?2:0}},{children:[e.jsxs(s.StyledGroupedLabel,Object.assign({version:a},{children:[o.leadingIcon?e.jsx("span",Object.assign({style:{marginRight:8}},{children:o.leadingIcon})):null,o.label]})),o.options.map(((n,s)=>{const d=O.get(n),b=d===g&&!n.disabled;return e.jsx(t.MenuItem,{version:a,last:s===o.options.length-1,onSelect:u,showDescription:c,onDropdownItemClick:p,isMultiSelect:i,option:n,useDefaultCursor:f,isFocused:b,dataIndex:d,isDraggable:!1,ref:e=>{l&&"object"==typeof l&&l.current&&e&&e&&e&&e&&(l.current[r]=e)}},`${r}-${s}`)})),d?e.jsx("span",{ref:v}):null]}),r)}const D=n,j=O.get(D),x=j===g&&!D.disabled;return e.jsxs("div",{children:[e.jsx(t.MenuItem,{version:a,last:d,onSelect:u,showDescription:c,onDropdownItemClick:p,isMultiSelect:i,option:D,useDefaultCursor:f,isFocused:x,dataIndex:j,isDraggable:b,onDragStart:S(r),onDragOver:w(r),onDrop:M(r),onDragEnd:k,isDraggedOver:I===r,ref:e=>{l&&"object"==typeof l&&l.current&&e&&(l.current[r]=e)}},D.value),d?e.jsx("span",{ref:v}):null]},r)}))})}));exports.MenuList=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),t=require("./MenuItem.js"),r=require("./MenuList.styled.js");const s=n.forwardRef(((s,l)=>{let{options:o,isMultiSelect:i,showDescription:u,onSelect:c,version:a,onInfiniteScroll:d,onDropdownItemClick:p,useDefaultCursor:f,focusedIndex:g=-1,isDraggable:b=!1,onOptionsReorder:D}=s;const j=n.useRef(null),v=n.useRef(null),[x,m]=n.useState(null),[I,h]=n.useState(null),C=n.useCallback((()=>{j.current&&j.current.disconnect(),j.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==d||d())})),v.current&&j.current.observe(v.current)}),[d]);n.useEffect((()=>(C(),()=>{j.current&&j.current.disconnect()})),[C,o]);const S=n.useCallback((e=>n=>{b&&(m(e),n.dataTransfer.effectAllowed="move")}),[b]),w=n.useCallback((e=>n=>{b&&(n.preventDefault(),n.dataTransfer.dropEffect="move",h(e))}),[b]),M=n.useCallback((e=>n=>{if(b&&null!==x){if(n.preventDefault(),x!==e){const n=[...o],[t]=n.splice(x,1);n.splice(e,0,t),null==D||D(n)}m(null),h(null)}}),[b,x,o,D]),k=n.useCallback((()=>{m(null),h(null)}),[]),O=new Map;let y=-1;return o.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||(y++,O.set(e,y))}));else{const n=e;n.disabled||(y++,O.set(n,y))}})),e.jsx(e.Fragment,{children:o.map(((n,s)=>{const d=s===o.length-1;if(n.options){const o=n;return e.jsxs("div",Object.assign({style:{marginTop:"2.0"===a?2:0}},{children:[e.jsxs(r.StyledGroupedLabel,Object.assign({version:a},{children:[o.leadingIcon?e.jsx("span",Object.assign({style:{marginRight:8}},{children:o.leadingIcon})):null,o.label]})),o.options.map(((n,r)=>{const d=O.get(n),b=d===g&&!n.disabled;return e.jsx(t.MenuItem,{version:a,last:r===o.options.length-1,onSelect:c,showDescription:u,onDropdownItemClick:p,isMultiSelect:i,option:n,useDefaultCursor:f,isFocused:b,dataIndex:d,isDraggable:!1,ref:e=>{l&&"object"==typeof l&&l.current&&e&&e&&e&&e&&(l.current[s]=e)}},`${s}-${r}`)})),d?e.jsx("span",{ref:v}):null]}),s)}const D=n,j=O.get(D),x=j===g&&!D.disabled;return e.jsxs("div",{children:[e.jsx(t.MenuItem,{version:a,last:d,onSelect:c,showDescription:u,onDropdownItemClick:p,isMultiSelect:i,option:D,useDefaultCursor:f,isFocused:x,dataIndex:j,isDraggable:b,onDragStart:S(s),onDragOver:w(s),onDrop:M(s),onDragEnd:k,isDraggedOver:I===s,ref:e=>{l&&"object"==typeof l&&l.current&&e&&(l.current[s]=e)}},D.value),d?e.jsx("span",{ref:v}):null]},s)}))})}));exports.MenuList=s;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useCallback as o,useState as n,useRef as r,useEffect 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 u}from"./description/Description.js";import{FreeFormMenu as a}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))),Y=r(Q),_=r(!1),ee=r(U);i((()=>{X(J(O))}),[O,J]),i((()=>{Y.current=Q}),[Q]),i((()=>{ee.current=U}),[U]),i((()=>()=>{_.current&&ee.current&&ee.current(Y.current)}),[]);const te=o((e=>{const t=J(e);X(t),"2.0"===A?null==U||U(t):_.current=!0}),[U,J,A]),oe=P?Q:O,{dropdownOptions:ne,search:re,searchedString:ie,searchedOptions:se,onApplyHandler:le,selectAllHandler:ce,onMultiSelectClear:ue,onFreeFormSelect:ae,onMultiSelectApply:de,latestDropdownOptionsRef:pe,getSelectedOptions:he,getCurrentSelectionCount:fe}=c(A,oe,M,T||P,y,I,W,Z,x),[me,be]=n(null!=C?C:v),[ge,Se]=n(null),[ve,je]=n(-1),Oe=r(null),we=r([]),ye=r(null);l(Oe,(()=>{if(Se(null),y&&"2.0"===A){const e=he(pe.current);null==L||L(e)}else null==L||L(ne)}),[E,we]),i((()=>{const e=setTimeout((()=>{Oe.current&&Oe.current.focus({preventScroll:!0})}),0);return()=>clearTimeout(e)}),[]);i((()=>{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})(ie&&I?se:ne);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),je((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=ye.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(),je((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=ye.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&&ve>=0){e.preventDefault();const o=t[ve];o&&(le(Object.assign(Object.assign({},o),{selected:!o.selected})),q&&q(o))}},t=Oe.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[ve,ie,se,ne,I,le,q]);const xe=null!=k?k:S,Ce="number"==typeof xe?w&&y?xe-96:w&&!y||!w&&y?xe-48:xe:xe;i((()=>{const e=null!=C?C:v;if(null===ge)be(e);else if("number"==typeof e)be(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));be(t)}}),[ge]);const De=[],ke=(e=>{if(!y||!x&&0!==x)return e;const t=fe(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})((ie&&I?se:ne).map((e=>{var t,o;if(ie&&!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(ie.toLowerCase()))&&(De.push(!ie||e.label===ie),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(ie.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(ie.toLowerCase()))?(De.push(!ie||e.label===ie),e):null}return e})).filter((e=>null!==e))),Le=!!w&&ie&&0===ke.length;return e(f,Object.assign({version:A,ref:Oe,tabIndex:-1,style:Object.assign(Object.assign({width:me},K),{outline:"none"})},{children:[e("div",Object.assign({style:{width:ge?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!w&&t(b,{onSearch:re,version:A}),ke.length||ie?e(m,Object.assign({minHeight:xe,maxHeight:Ce,ref:ye},{children:[!!y&&!Le&&!B&&t(p,{version:A,options:ie&&I?se:ne,onSelect:ce}),!D&&Le&&t(g,{isLoading:V,height:Ce,searchedString:ie,containerWidth:C}),D&&(Le||!!De.length&&De.every((e=>!1===e)))&&t(a,{version:A,isMultiSelect:y,onSelect:ae,searchedString:ie}),t(d,{onInfiniteScroll:H,onDropdownItemClick:q,version:A,onSelect:le,showDescription:function(e,t){Se(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:ke,useDefaultCursor:$,ref:we,focusedIndex:ve,isDraggable:P,onOptionsReorder:te})]})):t("div",Object.assign({style:{height:xe,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&&!(!ke.length&&!ie)&&"2.0"!==A&&t(h,{onClear:()=>{ue(),null==R||R()},onApply:de,list:ie&&I?se:ne,buttonText:F,buttonOptions:z,hideClearButton:G})]})),!!ge&&t(u,{title:ge.title,description:ge.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,useRef as r,useEffect 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 u}from"./description/Description.js";import{FreeFormMenu as a}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))),Y=r(Q),_=r(!1),ee=r(U);i((()=>{X(J(O))}),[O,J]),i((()=>{Y.current=Q}),[Q]),i((()=>{ee.current=U}),[U]),i((()=>()=>{_.current&&ee.current&&ee.current(Y.current)}),[]);const te=o((e=>{X(e),"2.0"===A?null==U||U(e):_.current=!0}),[U,A]),oe=P?Q:O,{dropdownOptions:ne,search:re,searchedString:ie,searchedOptions:se,onApplyHandler:le,selectAllHandler:ce,onMultiSelectClear:ue,onFreeFormSelect:ae,onMultiSelectApply:de,latestDropdownOptionsRef:pe,getSelectedOptions:he,getCurrentSelectionCount:fe}=c(A,oe,M,T||P,y,I,W,Z,x),[me,be]=n(null!=C?C:v),[ge,Se]=n(null),[ve,je]=n(-1),Oe=r(null),we=r([]),ye=r(null);l(Oe,(()=>{if(Se(null),y&&"2.0"===A){const e=he(pe.current);null==L||L(e)}else null==L||L(ne)}),[E,we]),i((()=>{const e=setTimeout((()=>{Oe.current&&Oe.current.focus({preventScroll:!0})}),0);return()=>clearTimeout(e)}),[]);i((()=>{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})(ie&&I?se:ne);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),je((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=ye.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(),je((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=ye.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&&ve>=0){e.preventDefault();const o=t[ve];o&&(le(Object.assign(Object.assign({},o),{selected:!o.selected})),q&&q(o))}},t=Oe.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[ve,ie,se,ne,I,le,q]);const xe=null!=k?k:S,Ce="number"==typeof xe?w&&y?xe-96:w&&!y||!w&&y?xe-48:xe:xe;i((()=>{const e=null!=C?C:v;if(null===ge)be(e);else if("number"==typeof e)be(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));be(t)}}),[ge]);const De=[],ke=(e=>{if(!y||!x&&0!==x)return e;const t=fe(ne)>=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})((ie&&I?se:ne).map((e=>{var t,o;if(ie&&!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(ie.toLowerCase()))&&(De.push(!ie||e.label===ie),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(ie.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(ie.toLowerCase()))?(De.push(!ie||e.label===ie),e):null}return e})).filter((e=>null!==e))),Le=!!w&&ie&&0===ke.length;return e(f,Object.assign({version:A,ref:Oe,tabIndex:-1,style:Object.assign(Object.assign({width:me},K),{outline:"none"})},{children:[e("div",Object.assign({style:{width:ge?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!w&&t(b,{onSearch:re,version:A}),ke.length||ie?e(m,Object.assign({minHeight:xe,maxHeight:Ce,ref:ye},{children:[!!y&&!Le&&!B&&t(p,{version:A,options:ie&&I?se:ne,onSelect:ce}),!D&&Le&&t(g,{isLoading:V,height:Ce,searchedString:ie,containerWidth:C}),D&&(Le||!!De.length&&De.every((e=>!1===e)))&&t(a,{version:A,isMultiSelect:y,onSelect:ae,searchedString:ie}),t(d,{onInfiniteScroll:H,onDropdownItemClick:q,version:A,onSelect:le,showDescription:function(e,t){Se(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:ke,useDefaultCursor:$,ref:we,focusedIndex:ve,isDraggable:P,onOptionsReorder:te})]})):t("div",Object.assign({style:{height:xe,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&&!(!ke.length&&!ie)&&"2.0"!==A&&t(h,{onClear:()=>{ue(),null==R||R()},onApply:de,list:ie&&I?se:ne,buttonText:F,buttonOptions:z,hideClearButton:G})]})),!!ge&&t(u,{title:ge.title,description:ge.description,version:A})]}))};export{j as OpenedDropdown};
@@ -1 +1 @@
1
- import{jsx as e,Fragment as n,jsxs as t}from"react/jsx-runtime";import{forwardRef as r,useRef as o,useState as s,useCallback as l,useEffect as i}from"react";import{MenuItem as c}from"./MenuItem.js";import{StyledGroupedLabel as a}from"./MenuList.styled.js";const u=r(((r,u)=>{let{options:d,isMultiSelect:p,showDescription:f,onSelect:g,version:m,onInfiniteScroll:D,onDropdownItemClick:b,useDefaultCursor:v,focusedIndex:h=-1,isDraggable:I=!1,onOptionsReorder:w}=r;const j=o(null),S=o(null),[O,C]=s(null),[M,x]=s(null),y=l((()=>{j.current&&j.current.disconnect(),j.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==D||D())})),S.current&&j.current.observe(S.current)}),[D]);i((()=>(y(),()=>{j.current&&j.current.disconnect()})),[y,d]);const E=l((e=>n=>{I&&(C(e),n.dataTransfer.effectAllowed="move")}),[I]),k=l((e=>n=>{I&&(n.preventDefault(),n.dataTransfer.dropEffect="move",x(e))}),[I]),T=l((e=>n=>{if(I&&null!==O){if(n.preventDefault(),O!==e){const n=[...d],t=n[O],r=n[e];if(t.selected===r.selected){const[t]=n.splice(O,1);n.splice(e,0,t),null==w||w(n)}}C(null),x(null)}}),[I,O,d,w]),F=l((()=>{C(null),x(null)}),[]),R=new Map;let $=-1;return d.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||($++,R.set(e,$))}));else{const n=e;n.disabled||($++,R.set(n,$))}})),e(n,{children:d.map(((n,r)=>{const o=r===d.length-1;if(n.options){const s=n;return t("div",Object.assign({style:{marginTop:"2.0"===m?2:0}},{children:[t(a,Object.assign({version:m},{children:[s.leadingIcon?e("span",Object.assign({style:{marginRight:8}},{children:s.leadingIcon})):null,s.label]})),s.options.map(((n,t)=>{const o=R.get(n),l=o===h&&!n.disabled;return e(c,{version:m,last:t===s.options.length-1,onSelect:g,showDescription:f,onDropdownItemClick:b,isMultiSelect:p,option:n,useDefaultCursor:v,isFocused:l,dataIndex:o,isDraggable:!1,ref:e=>{u&&"object"==typeof u&&u.current&&e&&e&&e&&e&&(u.current[r]=e)}},`${r}-${t}`)})),o?e("span",{ref:S}):null]}),r)}const s=n,l=R.get(s),i=l===h&&!s.disabled;return t("div",{children:[e(c,{version:m,last:o,onSelect:g,showDescription:f,onDropdownItemClick:b,isMultiSelect:p,option:s,useDefaultCursor:v,isFocused:i,dataIndex:l,isDraggable:I,onDragStart:E(r),onDragOver:k(r),onDrop:T(r),onDragEnd:F,isDraggedOver:M===r,ref:e=>{u&&"object"==typeof u&&u.current&&e&&(u.current[r]=e)}},s.value),o?e("span",{ref:S}):null]},r)}))})}));export{u as MenuList};
1
+ import{jsx as e,Fragment as n,jsxs as t}from"react/jsx-runtime";import{forwardRef as r,useRef as o,useState as s,useCallback as l,useEffect as i}from"react";import{MenuItem as c}from"./MenuItem.js";import{StyledGroupedLabel as a}from"./MenuList.styled.js";const u=r(((r,u)=>{let{options:d,isMultiSelect:p,showDescription:f,onSelect:g,version:m,onInfiniteScroll:D,onDropdownItemClick:b,useDefaultCursor:v,focusedIndex:h=-1,isDraggable:I=!1,onOptionsReorder:w}=r;const j=o(null),S=o(null),[O,C]=s(null),[M,x]=s(null),y=l((()=>{j.current&&j.current.disconnect(),j.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==D||D())})),S.current&&j.current.observe(S.current)}),[D]);i((()=>(y(),()=>{j.current&&j.current.disconnect()})),[y,d]);const E=l((e=>n=>{I&&(C(e),n.dataTransfer.effectAllowed="move")}),[I]),k=l((e=>n=>{I&&(n.preventDefault(),n.dataTransfer.dropEffect="move",x(e))}),[I]),T=l((e=>n=>{if(I&&null!==O){if(n.preventDefault(),O!==e){const n=[...d],[t]=n.splice(O,1);n.splice(e,0,t),null==w||w(n)}C(null),x(null)}}),[I,O,d,w]),F=l((()=>{C(null),x(null)}),[]),R=new Map;let $=-1;return d.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||($++,R.set(e,$))}));else{const n=e;n.disabled||($++,R.set(n,$))}})),e(n,{children:d.map(((n,r)=>{const o=r===d.length-1;if(n.options){const s=n;return t("div",Object.assign({style:{marginTop:"2.0"===m?2:0}},{children:[t(a,Object.assign({version:m},{children:[s.leadingIcon?e("span",Object.assign({style:{marginRight:8}},{children:s.leadingIcon})):null,s.label]})),s.options.map(((n,t)=>{const o=R.get(n),l=o===h&&!n.disabled;return e(c,{version:m,last:t===s.options.length-1,onSelect:g,showDescription:f,onDropdownItemClick:b,isMultiSelect:p,option:n,useDefaultCursor:v,isFocused:l,dataIndex:o,isDraggable:!1,ref:e=>{u&&"object"==typeof u&&u.current&&e&&e&&e&&e&&(u.current[r]=e)}},`${r}-${t}`)})),o?e("span",{ref:S}):null]}),r)}const s=n,l=R.get(s),i=l===h&&!s.disabled;return t("div",{children:[e(c,{version:m,last:o,onSelect:g,showDescription:f,onDropdownItemClick:b,isMultiSelect:p,option:s,useDefaultCursor:v,isFocused:i,dataIndex:l,isDraggable:I,onDragStart:E(r),onDragOver:k(r),onDrop:T(r),onDragEnd:F,isDraggedOver:M===r,ref:e=>{u&&"object"==typeof u&&u.current&&e&&(u.current[r]=e)}},s.value),o?e("span",{ref:S}):null]},r)}))})}));export{u as MenuList};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.763-beta.57",
3
+ "version": "0.0.763-beta.58",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",