@bikdotai/bik-component-library 0.0.620-mldn.8 → 0.0.620-mldn.9
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"),r=require("../../constants/Theme.js"),s=require("../dropdown/OpenedDropdown/components/searchbox/SearchBox.js"),o=require("../floater/floater.js"),i=require("./MenuList.js"),l=require("./MultiLevelDropdown.styled.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(t);exports.MultiLevelDropdown=u=>{let{options:d,width:a,isSearchable:p,onDropdownItemClick:f=(()=>{}),refElement:h,topOffset:j,leftOffset:O,isDropdownOpen:w,onDropdownOutsideClick:x}=u;const b=c.default.useRef(null),[g,m]=t.useState(d),v=e=>{b.current&&!b.current.contains(e.target)?x&&x(!0):x&&x(!1)};return t.useEffect((()=>(document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)})),[]),e.jsx(o.Floater,Object.assign({refElement:h,topOffset:j,leftOffset:O},{children:w&&e.jsx("div",Object.assign({ref:b,style:{backgroundColor:r.COLORS.surface.standard,zIndex:99999}},{children:e.jsxs(l.DropdownContainer,Object.assign({width:a},{children:[p&&e.jsx("div",Object.assign({style:{padding:"4px",width:null!=a?a:"200px"}},{children:e.jsx(s.SearchBox,{onSearch:e=>{const t=[...d],n=[];for(;t.length>0;){const r=t.shift();r&&r.label.toLowerCase().includes(e.toLowerCase())&&n.push(r),r&&"children"in r&&r.children?t.push(...r.children):r&&"options"in r&&r.options&&t.push(...r.options)}const r=e=>e.map((e=>{if(n.includes(e))return e;if("children"in e&&e.children){const t=r(e.children);if(t.length>0)return Object.assign(Object.assign({},e),{children:t})}if("options"in e&&e.options){const t=r(e.options);if(t.length>0)return Object.assign(Object.assign({},e),{options:t})}return null})).filter((e=>null!==e));m(r(d))},version:"2.0"})})),e.jsx(l.OptionsContainer,Object.assign({width:a},{children:(null!=g?g:[]).length>0&&e.jsx(i.MenuList,{width:null!=a?a:"200px",onDropdownItemClick:f,options:g,parents:[]})})),0===(null!=g?g:[]).length&&e.jsx(l.NoResultsContainer,Object.assign({style:{width:null!=a?a:"200px"}},{children:e.jsx(n.ZeroState,{title:"No results found!",subTitle:"Sorry, we are unable to find any results for your search."})}))]}))}))}))};
|
|
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("../../constants/Theme.js"),s=require("../dropdown/OpenedDropdown/components/searchbox/SearchBox.js"),o=require("../floater/floater.js"),i=require("./MenuList.js"),l=require("./MultiLevelDropdown.styled.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(t);exports.MultiLevelDropdown=u=>{let{options:d,width:a,isSearchable:p,onDropdownItemClick:f=(()=>{}),refElement:h,topOffset:j,leftOffset:O,isDropdownOpen:w,onDropdownOutsideClick:x}=u;const b=c.default.useRef(null),[g,m]=t.useState(d),v=e=>{b.current&&!b.current.contains(e.target)?x&&x(!0):x&&x(!1)};return t.useEffect((()=>(document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)})),[]),e.jsx(o.Floater,Object.assign({refElement:h,topOffset:j,leftOffset:O},{children:w&&e.jsx("div",Object.assign({ref:b,style:{backgroundColor:r.COLORS.surface.standard,zIndex:99999}},{children:e.jsxs(l.DropdownContainer,Object.assign({width:a},{children:[p&&e.jsx("div",Object.assign({style:{padding:"4px",width:null!=a?a:"200px"}},{children:e.jsx(s.SearchBox,{onSearch:e=>{const t=Array.isArray(d)?[...d]:[],n=[];for(;t.length>0;){const r=t.shift();r&&r.label.toLowerCase().includes(e.toLowerCase())&&n.push(r),r&&"children"in r&&r.children?t.push(...r.children):r&&"options"in r&&r.options&&t.push(...r.options)}const r=e=>e.map((e=>{if(n.includes(e))return e;if("children"in e&&e.children){const t=r(e.children);if(t.length>0)return Object.assign(Object.assign({},e),{children:t})}if("options"in e&&e.options){const t=r(e.options);if(t.length>0)return Object.assign(Object.assign({},e),{options:t})}return null})).filter((e=>null!==e));m(r(d))},version:"2.0"})})),e.jsx(l.OptionsContainer,Object.assign({width:a},{children:(null!=g?g:[]).length>0&&e.jsx(i.MenuList,{width:null!=a?a:"200px",onDropdownItemClick:f,options:g,parents:[]})})),0===(null!=g?g:[]).length&&e.jsx(l.NoResultsContainer,Object.assign({style:{width:null!=a?a:"200px"}},{children:e.jsx(n.ZeroState,{title:"No results found!",subTitle:"Sorry, we are unable to find any results for your search."})}))]}))}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import t,{useState as o,useEffect as r}from"react";import{ZeroState as s}from"../zeroState/ZeroState.js";import{COLORS as i}from"../../constants/Theme.js";import{SearchBox as l}from"../dropdown/OpenedDropdown/components/searchbox/SearchBox.js";import{Floater as c}from"../floater/floater.js";import{MenuList as d}from"./MenuList.js";import{DropdownContainer as
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import t,{useState as o,useEffect as r}from"react";import{ZeroState as s}from"../zeroState/ZeroState.js";import{COLORS as i}from"../../constants/Theme.js";import{SearchBox as l}from"../dropdown/OpenedDropdown/components/searchbox/SearchBox.js";import{Floater as c}from"../floater/floater.js";import{MenuList as d}from"./MenuList.js";import{DropdownContainer as a,OptionsContainer as p,NoResultsContainer as u}from"./MultiLevelDropdown.styled.js";const f=f=>{let{options:h,width:m,isSearchable:g,onDropdownItemClick:w=(()=>{}),refElement:j,topOffset:O,leftOffset:b,isDropdownOpen:x,onDropdownOutsideClick:y}=f;const v=t.useRef(null),[C,D]=o(h),L=e=>{v.current&&!v.current.contains(e.target)?y&&y(!0):y&&y(!1)};return r((()=>(document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)})),[]),e(c,Object.assign({refElement:j,topOffset:O,leftOffset:b},{children:x&&e("div",Object.assign({ref:v,style:{backgroundColor:i.surface.standard,zIndex:99999}},{children:n(a,Object.assign({width:m},{children:[g&&e("div",Object.assign({style:{padding:"4px",width:null!=m?m:"200px"}},{children:e(l,{onSearch:e=>{const n=Array.isArray(h)?[...h]:[],t=[];for(;n.length>0;){const o=n.shift();o&&o.label.toLowerCase().includes(e.toLowerCase())&&t.push(o),o&&"children"in o&&o.children?n.push(...o.children):o&&"options"in o&&o.options&&n.push(...o.options)}const o=e=>e.map((e=>{if(t.includes(e))return e;if("children"in e&&e.children){const n=o(e.children);if(n.length>0)return Object.assign(Object.assign({},e),{children:n})}if("options"in e&&e.options){const n=o(e.options);if(n.length>0)return Object.assign(Object.assign({},e),{options:n})}return null})).filter((e=>null!==e));D(o(h))},version:"2.0"})})),e(p,Object.assign({width:m},{children:(null!=C?C:[]).length>0&&e(d,{width:null!=m?m:"200px",onDropdownItemClick:w,options:C,parents:[]})})),0===(null!=C?C:[]).length&&e(u,Object.assign({style:{width:null!=m?m:"200px"}},{children:e(s,{title:"No results found!",subTitle:"Sorry, we are unable to find any results for your search."})}))]}))}))}))};export{f as MultiLevelDropdown};
|