@bikdotai/bik-component-library 0.0.569-am.9 → 0.0.569-beta.0
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/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/cjs/components/dropdown/hooks/useDropdown.d.ts +1 -1
- package/dist/cjs/components/dropdown/hooks/useDropdown.js +1 -1
- package/dist/cjs/components/dropdown/type.d.ts +0 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/esm/components/dropdown/hooks/useDropdown.d.ts +1 -1
- package/dist/esm/components/dropdown/hooks/useDropdown.js +1 -1
- package/dist/esm/components/dropdown/type.d.ts +0 -1
- package/package.json +1 -1
|
@@ -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"),r=require("../../../../hooks/useOutside.js"),o=require("../../hooks/useDropdown.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("../../../zeroState/ZeroState.js"),r=require("../../../../hooks/useOutside.js"),o=require("../../hooks/useDropdown.js"),s=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,S=290;exports.OpenedDropdown=j=>{let{options:f,isSearchable:x,isMultiSelect:g,width:b,allowFreeForm:w,height:v,onClose:m,onSelect:O,onSearch:y,version:M,skipSorting:q,headerRef:C,hideSelectAll:D,primaryButtonText:L,onInfiniteScroll:F,onMultiSelectClear:k,onDropdownItemClick:A,buttonOptions:B,isSearchLoading:I,disableOtherOptions:H}=j;const{dropdownOptions:Z,search:R,searchedString:T,searchedOptions:P,onApplyHandler:_,selectAllHandler:z,onMultiSelectClear:E,onFreeFormSelect:K,onMultiSelectApply:N,latestDropdownOptionsRef:W,getSelectedOptions:G}=o.useDropdown(M,f,O,q,g,y,H),[J,Q]=t.useState(null!=b?b:S),[U,V]=t.useState(null),X=t.useRef(null);r.useOutside(X,(()=>{if(V(null),g&&"2.0"===M){const e=G(W.current);null==m||m(e)}else null==m||m(Z)}),[C]);const Y=null!=v?v:h,$="number"==typeof Y?x&&g?Y-96:x&&!g||!x&&g?Y-48:Y:Y;t.useEffect((()=>{const e=null!=b?b:S;if(null===U)Q(e);else if("number"==typeof e)Q(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));Q(t)}}),[U]);const ee=[],te=(T&&y?P:Z).map((e=>{var t,n;if(T&&!y){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(T.toLowerCase()))&&(ee.push(!T||e.label===T),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(T.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(T.toLowerCase()))?(ee.push(!T||e.label===T),e):null}return e})).filter((e=>null!==e)),ne=!!x&&T&&0===te.length;return e.jsxs(a.OpennedDropdownContainer,Object.assign({version:M,ref:X,style:{width:J}},{children:[e.jsxs("div",Object.assign({style:{width:U?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!x&&e.jsx(d.SearchBox,{onSearch:R,version:M}),te.length||T?e.jsxs(a.MenuListContainer,Object.assign({minHeight:Y,maxHeight:$},{children:[!!g&&!ne&&!D&&e.jsx(u.SelectAllMenu,{version:M,options:T&&y?P:Z,onSelect:z}),!w&&ne&&e.jsx(p.SearchZeroState,{isLoading:I,height:$,searchedString:T}),w&&(ne||!!ee.length&&ee.every((e=>!1===e)))&&e.jsx(i.FreeFormMenu,{version:M,isMultiSelect:g,onSelect:K,searchedString:T}),e.jsx(l.MenuList,{onInfiniteScroll:F,onDropdownItemClick:A,version:M,onSelect:_,showDescription:function(e,t){V(e&&t?{title:e,description:t}:null)},isMultiSelect:g,options:te})]})):e.jsx("div",Object.assign({style:{height:Y,display:"flex"}},{children:e.jsx(n.ZeroState,{title:"No results found",subTitle:"Please try again later or contact us at support@bik.ai if you require further assistance."})})),!!g&&!(!te.length&&!T)&&"2.0"!==M&&e.jsx(c.default,{onClear:()=>{E(),null==k||k()},onApply:N,list:T&&y?P:Z,buttonText:L,buttonOptions:B})]})),!!U&&e.jsx(s.Description,{title:U.title,description:U.description,version:M})]}))};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SelectAllCheckboxState } from '../OpenedDropdown/components/menu/SelectAllMenu';
|
|
3
3
|
import { DropdownOption, SingleOption } from '../type';
|
|
4
|
-
export declare const useDropdown: (version: string | undefined, options: DropdownOption[], onSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined, skipSorting?: boolean, isMultiSelect?: boolean, onSearch?: ((searchKey: string) => Promise<DropdownOption[]>) | undefined,
|
|
4
|
+
export declare const useDropdown: (version: string | undefined, options: DropdownOption[], onSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined, skipSorting?: boolean, isMultiSelect?: boolean, onSearch?: ((searchKey: string) => Promise<DropdownOption[]>) | undefined, disableOtherOptions?: boolean) => {
|
|
5
5
|
latestDropdownOptionsRef: import("react").MutableRefObject<DropdownOption[]>;
|
|
6
6
|
dropdownOptions: DropdownOption[];
|
|
7
7
|
search: (searchKey: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../OpenedDropdown/utils/iterationOnOptions.js");exports.useDropdown=function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../OpenedDropdown/utils/iterationOnOptions.js");exports.useDropdown=function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",l=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0;const[u,d]=e.useState(null!=l?l:[]),[r,p]=e.useState([]),[O,v]=e.useState(""),f=e.useRef(u);e.useEffect((()=>{if(f.current=u,r.length&&O&&c){let e=[...r];const t=u.map((e=>{if(e.options)return e.options.map((e=>({value:e.value,selected:e.selected,disabled:!e.selected&&a})));const t=e;return{value:t.value,selected:t.selected,disabled:!t.selected&&a}})).flat();console.log("dropdownOptionFlat",t),e=e.map((e=>{const s=t.find((t=>e.value===t.value));return console.log("selectedDropdownOption",s),s?Object.assign(Object.assign({},e),{selected:s.selected,disabled:!s.selected&&a}):e})),console.log("searchedOptionsClone",e),p([...e])}}),[u]),e.useEffect((()=>{if(l){const e=[...l];d(i&&!o?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[l]);const g=e=>{const t=[];return e.forEach((e=>{if(e.options){const s=e.options.filter((e=>!0===e.selected));t.push(Object.assign(Object.assign({},e),{options:[...s]}))}else e.selected&&t.push(Object.assign({},e))})),t};function b(e,l){if(i)if(r.length&&O&&c)if(e.selected){let n=!1;const o=t.iterateOnOptions(u,{selected:e.selected},(t=>t.value===e.value&&(n=!0,!0)));if(n||o.push(e),l)return[...o];d([...o]),"2.0"===s&&h(o)}else{let n=!1,o=t.iterateOnOptions(u,{selected:e.selected},(t=>t.value===e.value&&(n=!0,!0)));if(n&&(o=o.filter((t=>t.value!==e.value))),l)return[...o];d([...o]),"2.0"===s&&h(o)}else{const n=t.iterateOnOptions(u,{selected:e.selected},(t=>t.value===e.value));if(l)return[...n];d([...n]),"2.0"===s&&h(n)}else null==n||n(e)}function h(e){const t=g(null!=e?e:f.current);null==n||n([...t])}return{latestDropdownOptionsRef:f,dropdownOptions:u,search:function(e){if(v(e),p([]),e&&c){const s=[];t.iterateOnOptionsRaw(u,(e=>{e.selected&&!s.includes(e.value)&&s.push(e.value)})),c(e).then((e=>{if(e){const t=e.map((e=>{if(e.options){const t=e;return Object.assign(Object.assign({},t),{options:t.options.map((e=>Object.assign(Object.assign({},e),{selected:s.includes(e.value)})))})}return Object.assign(Object.assign({},e),{selected:s.includes(e.value)})}));p([...t])}}))}},searchedString:O,searchedOptions:r,onApplyHandler:b,selectAllHandler:function(e){if(r.length&&O&&c)!function(e){let t=[...u];e?r.forEach((e=>{let s=!1;t=t.map((t=>{const l=e;return void 0!==l.value&&l.value===t.value?(s=!0,Object.assign(Object.assign({},t),{selected:!0})):t})),s||t.push(Object.assign(Object.assign({},e),{selected:!0}))})):r.forEach((e=>{t=t.map((t=>{const s=e;return void 0!==s.value&&s.value===t.value?Object.assign(Object.assign({},t),{selected:!1}):t}))})),d([...t]),"2.0"===s&&h(t)}("selectAll"===e);else if("selectAll"===e){const e=t.iterateOnOptions(u,{selected:!0},(e=>{var t;return O?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(O.toLowerCase()))&&!e.disabled:!e.disabled}));d([...e]),"2.0"===s&&h(e)}else if("notSelected"===e){const e=t.iterateOnOptions(u,{selected:!1},(e=>!e.disabled));d([...e]),"2.0"===s&&h(e)}},onMultiSelectClear:function(){const e=t.iterateOnOptions(u,{selected:!1});d([...e]),"2.0"===s&&h(e)},onFreeFormSelect:function(e){if(!i)return void b({label:O,value:O,isFreeForm:!0,selected:!0});const t=u.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===O&&t.value===O?e:t.selected})));e&&(t.some((e=>e.label===O&&e.value===O))||t.unshift({label:O,value:O,isFreeForm:!0,selected:!0})),d([...t]),"2.0"===s&&h(t)},onMultiSelectApply:h,getSelectedOptions:g}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as n,useEffect as i}from"react";import{ZeroState as r}from"../../../zeroState/ZeroState.js";import{useOutside as l}from"../../../../hooks/useOutside.js";import{useDropdown as s}from"../../hooks/useDropdown.js";import{Description as c}from"./description/Description.js";import{FreeFormMenu as a}from"./menu/FreeFormMenu.js";import{MenuList as p}from"./menu/MenuList.js";import{SelectAllMenu as u}from"./menu/SelectAllMenu.js";import d from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as h,MenuListContainer as m}from"./OpennedDropdown.styled.js";import{SearchBox as f}from"./searchbox/SearchBox.js";import{SearchZeroState as S}from"./searchbox/SearchZeroState.js";const g=304,b=290,w=w=>{let{options:v,isSearchable:j,isMultiSelect:y,width:O,allowFreeForm:x,height:C,onClose:M,onSelect:D,onSearch:L,version:k,skipSorting:A,headerRef:F,hideSelectAll:I,primaryButtonText:B,onInfiniteScroll:H,onMultiSelectClear:T,onDropdownItemClick:R,buttonOptions:Z,isSearchLoading:q,disableOtherOptions:z
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as n,useEffect as i}from"react";import{ZeroState as r}from"../../../zeroState/ZeroState.js";import{useOutside as l}from"../../../../hooks/useOutside.js";import{useDropdown as s}from"../../hooks/useDropdown.js";import{Description as c}from"./description/Description.js";import{FreeFormMenu as a}from"./menu/FreeFormMenu.js";import{MenuList as p}from"./menu/MenuList.js";import{SelectAllMenu as u}from"./menu/SelectAllMenu.js";import d from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as h,MenuListContainer as m}from"./OpennedDropdown.styled.js";import{SearchBox as f}from"./searchbox/SearchBox.js";import{SearchZeroState as S}from"./searchbox/SearchZeroState.js";const g=304,b=290,w=w=>{let{options:v,isSearchable:j,isMultiSelect:y,width:O,allowFreeForm:x,height:C,onClose:M,onSelect:D,onSearch:L,version:k,skipSorting:A,headerRef:F,hideSelectAll:I,primaryButtonText:B,onInfiniteScroll:H,onMultiSelectClear:T,onDropdownItemClick:R,buttonOptions:Z,isSearchLoading:q,disableOtherOptions:z}=w;const{dropdownOptions:K,search:N,searchedString:P,searchedOptions:W,onApplyHandler:E,selectAllHandler:G,onMultiSelectClear:J,onFreeFormSelect:Q,onMultiSelectApply:U,latestDropdownOptionsRef:V,getSelectedOptions:X}=s(k,v,D,A,y,L,z),[Y,$]=o(null!=O?O:b),[_,ee]=o(null),te=n(null);l(te,(()=>{if(ee(null),y&&"2.0"===k){const e=X(V.current);null==M||M(e)}else null==M||M(K)}),[F]);const oe=null!=C?C:g,ne="number"==typeof oe?j&&y?oe-96:j&&!y||!j&&y?oe-48:oe:oe;i((()=>{const e=null!=O?O:b;if(null===_)$(e);else if("number"==typeof e)$(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));$(t)}}),[_]);const ie=[],re=(P&&L?W: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()))&&(ie.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()))?(ie.push(!P||e.label===P),e):null}return e})).filter((e=>null!==e)),le=!!j&&P&&0===re.length;return e(h,Object.assign({version:k,ref:te,style:{width:Y}},{children:[e("div",Object.assign({style:{width:_?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!j&&t(f,{onSearch:N,version:k}),re.length||P?e(m,Object.assign({minHeight:oe,maxHeight:ne},{children:[!!y&&!le&&!I&&t(u,{version:k,options:P&&L?W:K,onSelect:G}),!x&&le&&t(S,{isLoading:q,height:ne,searchedString:P}),x&&(le||!!ie.length&&ie.every((e=>!1===e)))&&t(a,{version:k,isMultiSelect:y,onSelect:Q,searchedString:P}),t(p,{onInfiniteScroll:H,onDropdownItemClick:R,version:k,onSelect:E,showDescription:function(e,t){ee(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:re})]})):t("div",Object.assign({style:{height:oe,display:"flex"}},{children:t(r,{title:"No results found",subTitle:"Please try again later or contact us at support@bik.ai if you require further assistance."})})),!!y&&!(!re.length&&!P)&&"2.0"!==k&&t(d,{onClear:()=>{J(),null==T||T()},onApply:U,list:P&&L?W:K,buttonText:B,buttonOptions:Z})]})),!!_&&t(c,{title:_.title,description:_.description,version:k})]}))};export{w as OpenedDropdown};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SelectAllCheckboxState } from '../OpenedDropdown/components/menu/SelectAllMenu';
|
|
3
3
|
import { DropdownOption, SingleOption } from '../type';
|
|
4
|
-
export declare const useDropdown: (version: string | undefined, options: DropdownOption[], onSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined, skipSorting?: boolean, isMultiSelect?: boolean, onSearch?: ((searchKey: string) => Promise<DropdownOption[]>) | undefined,
|
|
4
|
+
export declare const useDropdown: (version: string | undefined, options: DropdownOption[], onSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined, skipSorting?: boolean, isMultiSelect?: boolean, onSearch?: ((searchKey: string) => Promise<DropdownOption[]>) | undefined, disableOtherOptions?: boolean) => {
|
|
5
5
|
latestDropdownOptionsRef: import("react").MutableRefObject<DropdownOption[]>;
|
|
6
6
|
dropdownOptions: DropdownOption[];
|
|
7
7
|
search: (searchKey: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e,useRef as t,useEffect as s}from"react";import{iterateOnOptionsRaw as l,iterateOnOptions as n}from"../OpenedDropdown/utils/iterationOnOptions.js";const
|
|
1
|
+
import{useState as e,useRef as t,useEffect as s}from"react";import{iterateOnOptionsRaw as l,iterateOnOptions as n}from"../OpenedDropdown/utils/iterationOnOptions.js";const o=function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",c=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,d=arguments.length>4?arguments[4]:void 0,u=arguments.length>5?arguments[5]:void 0,r=arguments.length>6?arguments[6]:void 0;const[p,v]=e(null!=c?c:[]),[f,g]=e([]),[b,O]=e(""),h=t(p);s((()=>{if(h.current=p,f.length&&b&&u){let e=[...f];const t=p.map((e=>{if(e.options)return e.options.map((e=>({value:e.value,selected:e.selected,disabled:!e.selected&&r})));const t=e;return{value:t.value,selected:t.selected,disabled:!t.selected&&r}})).flat();console.log("dropdownOptionFlat",t),e=e.map((e=>{const s=t.find((t=>e.value===t.value));return console.log("selectedDropdownOption",s),s?Object.assign(Object.assign({},e),{selected:s.selected,disabled:!s.selected&&r}):e})),console.log("searchedOptionsClone",e),g([...e])}}),[p]),s((()=>{if(c){const e=[...c];v(d&&!a?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[c]);const j=e=>{const t=[];return e.forEach((e=>{if(e.options){const s=e.options.filter((e=>!0===e.selected));t.push(Object.assign(Object.assign({},e),{options:[...s]}))}else e.selected&&t.push(Object.assign({},e))})),t};function m(e,t){if(d)if(f.length&&b&&u)if(e.selected){let s=!1;const l=n(p,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s||l.push(e),t)return[...l];v([...l]),"2.0"===o&&w(l)}else{let s=!1,l=n(p,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s&&(l=l.filter((t=>t.value!==e.value))),t)return[...l];v([...l]),"2.0"===o&&w(l)}else{const s=n(p,{selected:e.selected},(t=>t.value===e.value));if(t)return[...s];v([...s]),"2.0"===o&&w(s)}else null==i||i(e)}function w(e){const t=j(null!=e?e:h.current);null==i||i([...t])}return{latestDropdownOptionsRef:h,dropdownOptions:p,search:function(e){if(O(e),g([]),e&&u){const t=[];l(p,(e=>{e.selected&&!t.includes(e.value)&&t.push(e.value)})),u(e).then((e=>{if(e){const s=e.map((e=>{if(e.options){const s=e;return Object.assign(Object.assign({},s),{options:s.options.map((e=>Object.assign(Object.assign({},e),{selected:t.includes(e.value)})))})}return Object.assign(Object.assign({},e),{selected:t.includes(e.value)})}));g([...s])}}))}},searchedString:b,searchedOptions:f,onApplyHandler:m,selectAllHandler:function(e){if(f.length&&b&&u)!function(e){let t=[...p];e?f.forEach((e=>{let s=!1;t=t.map((t=>{const l=e;return void 0!==l.value&&l.value===t.value?(s=!0,Object.assign(Object.assign({},t),{selected:!0})):t})),s||t.push(Object.assign(Object.assign({},e),{selected:!0}))})):f.forEach((e=>{t=t.map((t=>{const s=e;return void 0!==s.value&&s.value===t.value?Object.assign(Object.assign({},t),{selected:!1}):t}))})),v([...t]),"2.0"===o&&w(t)}("selectAll"===e);else if("selectAll"===e){const e=n(p,{selected:!0},(e=>{var t;return b?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(b.toLowerCase()))&&!e.disabled:!e.disabled}));v([...e]),"2.0"===o&&w(e)}else if("notSelected"===e){const e=n(p,{selected:!1},(e=>!e.disabled));v([...e]),"2.0"===o&&w(e)}},onMultiSelectClear:function(){const e=n(p,{selected:!1});v([...e]),"2.0"===o&&w(e)},onFreeFormSelect:function(e){if(!d)return void m({label:b,value:b,isFreeForm:!0,selected:!0});const t=p.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===b&&t.value===b?e:t.selected})));e&&(t.some((e=>e.label===b&&e.value===b))||t.unshift({label:b,value:b,isFreeForm:!0,selected:!0})),v([...t]),"2.0"===o&&w(t)},onMultiSelectApply:w,getSelectedOptions:j}};export{o as useDropdown};
|