@bikdotai/bik-component-library 0.0.726-beta.0 → 0.0.726-beta.1
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.
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/package.json +1 -1
|
@@ -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,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]);
|
|
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]);const ue=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};t.useEffect((()=>{ue(V&&E?W:z).length>0&&-1===ne&&oe(0)}),[z,W,V,E,ne]),t.useEffect((()=>{const e=e=>{const t=ue(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 ce=null!=w?w:h,ae="number"==typeof ce?S&&b?ce-96:S&&!b||!S&&b?ce-48:ce:ce;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 de=[],pe=(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()))&&(de.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()))?(de.push(!V||e.label===V),e):null}return e})).filter((e=>null!==e))),he=!!S&&V&&0===pe.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}),pe.length||V?e.jsxRuntimeExports.jsxs(a.MenuListContainer,Object.assign({minHeight:ce,maxHeight:ae,ref:le},{children:[!!b&&!he&&!q&&e.jsxRuntimeExports.jsx(u.SelectAllMenu,{version:D,options:V&&E?W:z,onSelect:K}),!v&&he&&e.jsxRuntimeExports.jsx(p.SearchZeroState,{isLoading:I,height:ae,searchedString:V,containerWidth:g}),v&&(he||!!de.length&&de.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:pe,useDefaultCursor:H,ref:ie,focusedIndex:ne})]})):e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:ce,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&&!(!pe.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
|
-
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]);
|
|
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]);const de=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};n((()=>{de(P&&L?U:K).length>0&&-1===re&&le(0)}),[K,U,P,L,re]),n((()=>{const e=e=>{const t=de(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 pe=null!=C?C:b,he="number"==typeof pe?v&&x?pe-96:v&&!x||!v&&x?pe-48:pe:pe;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 me=[],fe=(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()))&&(me.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()))?(me.push(!P||e.label===P),e):null}return e})).filter((e=>null!==e))),be=!!v&&P&&0===fe.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}),fe.length||P?e.jsxs(h,Object.assign({minHeight:pe,maxHeight:he,ref:ue},{children:[!!x&&!be&&!E&&e.jsx(u,{version:M,options:P&&L?U:K,onSelect:G}),!O&&be&&e.jsx(f,{isLoading:z,height:he,searchedString:P,containerWidth:y}),O&&(be||!!me.length&&me.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:fe,useDefaultCursor:W,ref:ae,focusedIndex:re})]})):e.jsx("div",Object.assign({style:{height:pe,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&&!(!fe.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};
|