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

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.
@@ -36,7 +36,7 @@ export declare class MetaCustomProcessor {
36
36
  value: {
37
37
  operator: string;
38
38
  dataType: import("../types").QueryBuilderConnectorType;
39
- value?: string | number | string[] | Date | Date[] | number[] | undefined;
39
+ value?: string | number | string[] | number[] | Date | Date[] | undefined;
40
40
  };
41
41
  key: string;
42
42
  refresh?: boolean | undefined;
@@ -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:D,version:C,skipSorting:k,headerRef:q,hideSelectAll:M,primaryButtonText:L,onInfiniteScroll:E,onMultiSelectClear:A,onDropdownItemClick:I,buttonOptions:F,isSearchLoading:T,disableSearchOptions:R,disableSearchedOptionExcept:B,useDefaultCursor:H,containerStyle:Z={},zeroState:z,isDraggable:P=!1,onOptionsReorder:V}=b;const W=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]),[$,_]=t.useState((()=>W(S)));t.useEffect((()=>{_(W(S))}),[S,W]);const K=t.useCallback((e=>{const t=W(e);_(t),null==V||V(t)}),[V,W]),N=P?$:S,{dropdownOptions:U,search:G,searchedString:J,searchedOptions:Q,onApplyHandler:X,selectAllHandler:Y,onMultiSelectClear:ee,onFreeFormSelect:te,onMultiSelectApply:ne,latestDropdownOptionsRef:se,getSelectedOptions:oe,getCurrentSelectionCount:re}=o.useDropdown(C,N,y,k||P,j,D,R,B,v),[ie,le]=t.useState(null!=x?x:f),[ue,ce]=t.useState(null),[ae,de]=t.useState(-1),pe=t.useRef(null),he=t.useRef([]),fe=t.useRef(null);s.useOutside(pe,(()=>{if(ce(null),j&&"2.0"===C){const e=oe(se.current);null==w||w(e)}else null==w||w(U)}),[q,he]),t.useEffect((()=>{const e=setTimeout((()=>{pe.current&&pe.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})(J&&D?Q:U);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),de((e=>{const n=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=fe.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(),de((e=>{const n=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=fe.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&&ae>=0){e.preventDefault();const n=t[ae];n&&(X(Object.assign(Object.assign({},n),{selected:!n.selected})),I&&I(n))}},t=pe.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[ae,J,Q,U,D,X,I]);const be=null!=m?m:h,Se="number"==typeof be?g&&j?be-96:g&&!j||!g&&j?be-48:be:be;t.useEffect((()=>{const e=null!=x?x:f;if(null===ue)le(e);else if("number"==typeof e)le(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));le(t)}}),[ue]);const ge=[],je=(e=>{if(!j||!v&&0!==v)return e;const t=re(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})((J&&D?Q:U).map((e=>{var t,n;if(J&&!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(J.toLowerCase()))&&(ge.push(!J||e.label===J),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(J.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(J.toLowerCase()))?(ge.push(!J||e.label===J),e):null}return e})).filter((e=>null!==e))),ve=!!g&&J&&0===je.length;return e.jsxs(a.OpennedDropdownContainer,Object.assign({version:C,ref:pe,tabIndex:-1,style:Object.assign(Object.assign({width:ie},Z),{outline:"none"})},{children:[e.jsxs("div",Object.assign({style:{width:ue?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!g&&e.jsx(d.SearchBox,{onSearch:G,version:C}),je.length||J?e.jsxs(a.MenuListContainer,Object.assign({minHeight:be,maxHeight:Se,ref:fe},{children:[!!j&&!ve&&!M&&e.jsx(u.SelectAllMenu,{version:C,options:J&&D?Q:U,onSelect:Y}),!O&&ve&&e.jsx(p.SearchZeroState,{isLoading:T,height:Se,searchedString:J,containerWidth:x}),O&&(ve||!!ge.length&&ge.every((e=>!1===e)))&&e.jsx(i.FreeFormMenu,{version:C,isMultiSelect:j,onSelect:te,searchedString:J}),e.jsx(l.MenuList,{onInfiniteScroll:E,onDropdownItemClick:I,version:C,onSelect:X,showDescription:function(e,t){ce(e&&t?{title:e,description:t}:null)},isMultiSelect:j,options:je,useDefaultCursor:H,ref:he,focusedIndex:ae,isDraggable:P,onOptionsReorder:K})]})):e.jsx("div",Object.assign({style:{height:be,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&&!(!je.length&&!J)&&"2.0"!==C&&e.jsx(c.default,{onClear:()=>{ee(),null==A||A()},onApply:ne,list:J&&D?Q:U,buttonText:L,buttonOptions:F})]})),!!ue&&e.jsx(r.Description,{title:ue.title,description:ue.description,version:C})]}))};
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})]}))};
@@ -6,6 +6,7 @@ interface MultiSelectDropdownBottomBarProps {
6
6
  list: DropdownOption[];
7
7
  buttonText?: string;
8
8
  buttonOptions?: ButtonOptions;
9
+ hideClearButton?: boolean;
9
10
  }
10
11
  declare const MultiSelectDropdownBottomBar: React.FC<MultiSelectDropdownBottomBarProps>;
11
12
  export default MultiSelectDropdownBottomBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../button/Button.js"),r=require("../../../../TypographyStyle.js"),n=require("../../../../../constants/Theme.js"),o=require("./MultiSelectDropdownBottomBar.styled.js");exports.default=s=>{const{onClear:i,onApply:l,list:u,buttonText:a,buttonOptions:c}=s,{primaryButtonText:p,primaryButtonType:y,secondaryButtonText:d,secondaryButtonType:x}=null!=c?c:{},j=u.reduce(((e,t)=>{if(t.options){return e+t.options.filter((e=>!0===e.selected)).length}return t.selected?e+1:e}),0);return e.jsxs(o.BottomBarContainer,Object.assign({style:{justifyContent:"space-between"}},{children:[e.jsx(r.BodySecondary,Object.assign({style:{flex:1,color:n.COLORS.content.primary}},{children:j?`${j} selected`:""})),e.jsxs("div",Object.assign({style:{flexDirection:"row",display:"flex",gap:12}},{children:[e.jsx(t.Button,{size:"small",buttonType:x||"primary",buttonText:d||"Clear",onClick:i}),e.jsx(t.Button,{size:"small",buttonText:p||a||"Apply",buttonType:y||"primary",onClick:()=>{l()}})]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../button/Button.js"),r=require("../../../../TypographyStyle.js"),n=require("../../../../../constants/Theme.js"),o=require("./MultiSelectDropdownBottomBar.styled.js");exports.default=s=>{const{onClear:i,onApply:l,list:u,buttonText:a,buttonOptions:c,hideClearButton:p}=s,{primaryButtonText:y,primaryButtonType:d,secondaryButtonText:x,secondaryButtonType:j}=null!=c?c:{},B=u.reduce(((e,t)=>{if(t.options){return e+t.options.filter((e=>!0===e.selected)).length}return t.selected?e+1:e}),0);return e.jsxs(o.BottomBarContainer,Object.assign({style:{justifyContent:"space-between"}},{children:[e.jsx(r.BodySecondary,Object.assign({style:{flex:1,color:n.COLORS.content.primary}},{children:B?`${B} selected`:""})),e.jsxs("div",Object.assign({style:{flexDirection:"row",display:"flex",gap:12}},{children:[!p&&e.jsx(t.Button,{size:"small",buttonType:j||"primary",buttonText:x||"Clear",onClick:i}),e.jsx(t.Button,{size:"small",buttonText:y||a||"Apply",buttonType:d||"primary",onClick:()=>{l()}})]}))]}))};
@@ -41,6 +41,7 @@ export interface OpenDropdownProps {
41
41
  };
42
42
  /** Enable drag-and-drop reordering of options */
43
43
  isDraggable?: boolean;
44
+ hideClearButton?: boolean;
44
45
  /** Callback when options are reordered via drag-and-drop */
45
46
  onOptionsReorder?: (reorderedOptions: DropdownOption[]) => void;
46
47
  }
@@ -36,7 +36,7 @@ export declare class MetaCustomProcessor {
36
36
  value: {
37
37
  operator: string;
38
38
  dataType: import("../types").QueryBuilderConnectorType;
39
- value?: string | number | string[] | Date | Date[] | number[] | undefined;
39
+ value?: string | number | string[] | number[] | Date | Date[] | undefined;
40
40
  };
41
41
  key: string;
42
42
  refresh?: boolean | undefined;
@@ -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:D,allowFreeForm:C,height:k,onClose:L,onSelect:M,onSearch:I,version:A,skipSorting:T,headerRef:E,hideSelectAll:F,primaryButtonText:B,onInfiniteScroll:H,onMultiSelectClear:R,onDropdownItemClick:q,buttonOptions:z,isSearchLoading:V,disableSearchOptions:W,disableSearchedOptionExcept:Z,useDefaultCursor:$,containerStyle:K={},zeroState:N,isDraggable:P=!1,onOptionsReorder:U}=j;const G=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]),[J,Q]=n((()=>G(O)));r((()=>{Q(G(O))}),[O,G]);const X=o((e=>{const t=G(e);Q(t),null==U||U(t)}),[U,G]),Y=P?J:O,{dropdownOptions:_,search:ee,searchedString:te,searchedOptions:oe,onApplyHandler:ne,selectAllHandler:re,onMultiSelectClear:ie,onFreeFormSelect:se,onMultiSelectApply:le,latestDropdownOptionsRef:ce,getSelectedOptions:ae,getCurrentSelectionCount:ue}=c(A,Y,M,T||P,y,I,W,Z,x),[de,pe]=n(null!=D?D:v),[he,fe]=n(null),[me,be]=n(-1),ge=i(null),Se=i([]),ve=i(null);l(ge,(()=>{if(fe(null),y&&"2.0"===A){const e=ae(ce.current);null==L||L(e)}else null==L||L(_)}),[E,Se]),r((()=>{const e=setTimeout((()=>{ge.current&&ge.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})(te&&I?oe:_);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),be((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=ve.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(),be((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=ve.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&&me>=0){e.preventDefault();const o=t[me];o&&(ne(Object.assign(Object.assign({},o),{selected:!o.selected})),q&&q(o))}},t=ge.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[me,te,oe,_,I,ne,q]);const je=null!=k?k:S,Oe="number"==typeof je?w&&y?je-96:w&&!y||!w&&y?je-48:je:je;r((()=>{const e=null!=D?D:v;if(null===he)pe(e);else if("number"==typeof e)pe(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));pe(t)}}),[he]);const we=[],ye=(e=>{if(!y||!x&&0!==x)return e;const t=ue(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})((te&&I?oe:_).map((e=>{var t,o;if(te&&!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(te.toLowerCase()))&&(we.push(!te||e.label===te),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(te.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(te.toLowerCase()))?(we.push(!te||e.label===te),e):null}return e})).filter((e=>null!==e))),xe=!!w&&te&&0===ye.length;return e(f,Object.assign({version:A,ref:ge,tabIndex:-1,style:Object.assign(Object.assign({width:de},K),{outline:"none"})},{children:[e("div",Object.assign({style:{width:he?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!w&&t(b,{onSearch:ee,version:A}),ye.length||te?e(m,Object.assign({minHeight:je,maxHeight:Oe,ref:ve},{children:[!!y&&!xe&&!F&&t(p,{version:A,options:te&&I?oe:_,onSelect:re}),!C&&xe&&t(g,{isLoading:V,height:Oe,searchedString:te,containerWidth:D}),C&&(xe||!!we.length&&we.every((e=>!1===e)))&&t(u,{version:A,isMultiSelect:y,onSelect:se,searchedString:te}),t(d,{onInfiniteScroll:H,onDropdownItemClick:q,version:A,onSelect:ne,showDescription:function(e,t){fe(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:ye,useDefaultCursor:$,ref:Se,focusedIndex:me,isDraggable:P,onOptionsReorder:X})]})):t("div",Object.assign({style:{height:je,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&&!(!ye.length&&!te)&&"2.0"!==A&&t(h,{onClear:()=>{ie(),null==R||R()},onApply:le,list:te&&I?oe:_,buttonText:B,buttonOptions:z})]})),!!he&&t(a,{title:he.title,description:he.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),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};
@@ -6,6 +6,7 @@ interface MultiSelectDropdownBottomBarProps {
6
6
  list: DropdownOption[];
7
7
  buttonText?: string;
8
8
  buttonOptions?: ButtonOptions;
9
+ hideClearButton?: boolean;
9
10
  }
10
11
  declare const MultiSelectDropdownBottomBar: React.FC<MultiSelectDropdownBottomBarProps>;
11
12
  export default MultiSelectDropdownBottomBar;
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import{Button as o}from"../../../../button/Button.js";import{BodySecondary as n}from"../../../../TypographyStyle.js";import{COLORS as r}from"../../../../../constants/Theme.js";import{BottomBarContainer as s}from"./MultiSelectDropdownBottomBar.styled.js";const l=l=>{const{onClear:i,onApply:p,list:a,buttonText:c,buttonOptions:y}=l,{primaryButtonText:u,primaryButtonType:m,secondaryButtonText:d,secondaryButtonType:f}=null!=y?y:{},b=a.reduce(((t,e)=>{if(e.options){return t+e.options.filter((t=>!0===t.selected)).length}return e.selected?t+1:t}),0);return t(s,Object.assign({style:{justifyContent:"space-between"}},{children:[e(n,Object.assign({style:{flex:1,color:r.content.primary}},{children:b?`${b} selected`:""})),t("div",Object.assign({style:{flexDirection:"row",display:"flex",gap:12}},{children:[e(o,{size:"small",buttonType:f||"primary",buttonText:d||"Clear",onClick:i}),e(o,{size:"small",buttonText:u||c||"Apply",buttonType:m||"primary",onClick:()=>{p()}})]}))]}))};export{l as default};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import{Button as o}from"../../../../button/Button.js";import{BodySecondary as n}from"../../../../TypographyStyle.js";import{COLORS as r}from"../../../../../constants/Theme.js";import{BottomBarContainer as s}from"./MultiSelectDropdownBottomBar.styled.js";const l=l=>{const{onClear:i,onApply:p,list:a,buttonText:c,buttonOptions:u,hideClearButton:y}=l,{primaryButtonText:m,primaryButtonType:d,secondaryButtonText:f,secondaryButtonType:b}=null!=u?u:{},T=a.reduce(((t,e)=>{if(e.options){return t+e.options.filter((t=>!0===t.selected)).length}return e.selected?t+1:t}),0);return t(s,Object.assign({style:{justifyContent:"space-between"}},{children:[e(n,Object.assign({style:{flex:1,color:r.content.primary}},{children:T?`${T} selected`:""})),t("div",Object.assign({style:{flexDirection:"row",display:"flex",gap:12}},{children:[!y&&e(o,{size:"small",buttonType:b||"primary",buttonText:f||"Clear",onClick:i}),e(o,{size:"small",buttonText:m||c||"Apply",buttonType:d||"primary",onClick:()=>{p()}})]}))]}))};export{l as default};
@@ -41,6 +41,7 @@ export interface OpenDropdownProps {
41
41
  };
42
42
  /** Enable drag-and-drop reordering of options */
43
43
  isDraggable?: boolean;
44
+ hideClearButton?: boolean;
44
45
  /** Callback when options are reordered via drag-and-drop */
45
46
  onOptionsReorder?: (reorderedOptions: DropdownOption[]) => void;
46
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.763-beta.1",
3
+ "version": "0.0.763-beta.2",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",