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