@bikdotai/bik-component-library 0.0.517-beta.drop.7 → 0.0.517-beta.drop.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.
- package/dist/cjs/components/dropdown/Dropdown.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.d.ts +5 -2
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.d.ts +1 -0
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js +1 -1
- package/dist/cjs/components/dropdown/type.d.ts +1 -0
- package/dist/esm/components/dropdown/Dropdown.js +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.d.ts +5 -2
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.d.ts +1 -0
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js +1 -1
- package/dist/esm/components/dropdown/type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),n=require("../../constants/Theme.js"),o=require("../../assets/icons/chevronDown.svg.js"),i=require("../input/Input.js"),s=require("../input/context/InputStyleProvider.js"),l=require("./DropdownPopover/index.js"),a=require("./OpenedDropdown/utils/iterationOnOptions.js");function u(){}const d=d=>{var p,c,h,{placeHolder:v,size:g,onSelect:j,defaultOptions:f,disabled:x,noErrorHint:b,placeHolderHeight:O}=d,w=e.__rest(d,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight"]);const[H,S]=r.useState(!1),m=null!=g?g:"default",q=r.useRef(),[y,D]=r.useState(null!=f?f:[]);r.useEffect((()=>{var e;const t=[];null===(e=null==w?void 0:w.options)||void 0===e||e.forEach((e=>{e.options?e.options.forEach((e=>{e.selected&&t.push(Object.assign(Object.assign({},e),{label:e.label}))})):e.selected&&t.push(e)})),D([...t])}),[w.options]),r.useEffect((()=>{f&&D([...f])}),[f]);const E=a.getSelectedOptionsAsText(y);return t.jsx(s.InputStyleContext.Provider,Object.assign({value:{InputWrapper:{height:O||("small"===m?32:48),width:null!==(c=null!==(p=w.buttonWidth)&&void 0!==p?p:w.width)&&void 0!==c?c:"100%",zIndex:1,cursor:"pointer",padding:"6px 8px"},input:{minHeight:"100%"}}},{children:t.jsx(l.DropdownPopover,Object.assign({ref:q,onSelect:function(e){Array.isArray(e)?D([...e]):D([e]),null==j||j(e)},disabled:x,onDropdownVisbilityChange:e=>S(e)},w,{children:t.jsx(i.Input,{version:w.version,noErrorHint:b,state:x?"disabled":"none",value:null!=E?E:"",errorMessage:w.error,variant:m,placeholder:null!=v?v:"Select an option",width:null!==(h=w.width)&&void 0!==h?h:"100%",onChangeText:u,rightIcon:{icon:()=>t.jsx(o.default,{style:{transform:H?"rotate(180deg)":"rotate(0deg)"},onClick:u,width:"small"===m?20:24,height:"small"===m?20:24,color:n.COLORS.content.primary})},truncateText:!0})}))}))};d.displayName="Dropdown",exports.Dropdown=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),
|
|
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:w,allowFreeForm:v,height:b,onClose:m,onSelect:y,onSearch:M,version:O,skipSorting:q,headerRef:C,hideSelectAll:D,primaryButtonText:L,onInfiniteScroll:F,onMultiSelectClear:k,onDropdownItemClick:A}=j;const{dropdownOptions:B,search:I,searchedString:H,searchedOptions:Z,onApplyHandler:R,selectAllHandler:T,onMultiSelectClear:P,onFreeFormSelect:_,onMultiSelectApply:z,latestDropdownOptionsRef:E,getSelectedOptions:K}=o.useDropdown(O,f,y,q,g,M),[N,W]=t.useState(null!=w?w:S),[G,J]=t.useState(null),Q=t.useRef(null);r.useOutside(Q,(()=>{if(J(null),g&&"2.0"===O){const e=K(E.current);null==m||m(e)}else null==m||m(B)}),[C]);const U=null!=b?b:h,V="number"==typeof U?x&&g?U-96:x&&!g||!x&&g?U-48:U:U;t.useEffect((()=>{const e=null!=w?w:S;if(null===G)W(e);else if("number"==typeof e)W(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));W(t)}}),[G]);const X=[],Y=(H&&M?Z:B).map((e=>{var t,n;if(H&&!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(H.toLowerCase()))&&(X.push(!H||e.label===H),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(H.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(H.toLowerCase()))?(X.push(!H||e.label===H),e):null}return e})).filter((e=>null!==e)),$=!!x&&H&&0===Y.length;return e.jsxs(a.OpennedDropdownContainer,Object.assign({version:O,ref:Q,style:{width:N}},{children:[e.jsxs("div",Object.assign({style:{width:G?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!x&&e.jsx(d.SearchBox,{onSearch:I,version:O}),Y.length||H?e.jsxs(a.MenuListContainer,Object.assign({minHeight:U,maxHeight:V},{children:[!!g&&!$&&!D&&e.jsx(u.SelectAllMenu,{version:O,options:H&&M?Z:B,onSelect:T}),!v&&$&&e.jsx(p.SearchZeroState,{height:V,searchedString:H}),v&&($||!!X.length&&X.every((e=>!1===e)))&&e.jsx(i.FreeFormMenu,{version:O,isMultiSelect:g,onSelect:_,searchedString:H}),e.jsx(l.MenuList,{onInfiniteScroll:F,onDropdownItemClick:A,version:O,onSelect:R,showDescription:function(e,t){J(e&&t?{title:e,description:t}:null)},isMultiSelect:g,options:Y})]})):e.jsx("div",Object.assign({style:{height:U,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&&!(!Y.length&&!H)&&"2.0"!==O&&e.jsx(c.default,{onClear:()=>{P(),null==k||k()},onApply:z,list:H&&M?Z:B,buttonText:L})]})),!!G&&e.jsx(s.Description,{title:G.title,description:G.description,version:O})]}))};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MultiSelectOption, SingleOption } from '../../../type';
|
|
3
|
-
|
|
3
|
+
interface MenuItemProps {
|
|
4
4
|
option: SingleOption | MultiSelectOption;
|
|
5
5
|
isMultiSelect?: boolean;
|
|
6
6
|
showDescription: (title?: string, description?: string) => void;
|
|
7
7
|
onSelect: (option: SingleOption) => void;
|
|
8
|
+
onDropdownItemClick?: (option: SingleOption) => void;
|
|
8
9
|
last?: boolean;
|
|
9
10
|
version?: '1.0' | '2.0';
|
|
10
|
-
}
|
|
11
|
+
}
|
|
12
|
+
export declare const MenuItem: React.FC<MenuItemProps>;
|
|
13
|
+
export {};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
padding: ${e=>"2.0"===e.version?"8px 12px":"14px 16px"} !important;
|
|
3
3
|
cursor: pointer;
|
|
4
4
|
margin-top: ${e=>"2.0"===e.version?"2px":"0"};
|
|
5
|
-
`;exports.MenuItem=t=>{let{option:i,isMultiSelect:l,showDescription:a,onSelect:d,last:u,version:p}=t;var x;function g(e){i.disabled||d(Object.assign(Object.assign({},i),{selected:e}))}return e.jsx(c,{version:p,style:u?{borderBottom:0}:{},onClick:e=>{e.preventDefault(),g(!i.selected)},onMouseOver:function(){i.description?a(i.label,i.description):a()},listItem:{value:i.value,label:i.label},subText:i.subText,leadingIcon:l?e.jsxs("div",Object.assign({style:{display:"flex",alignContent:"center",justifyContent:"center",gap:8}},{children:[e.jsx(n.CheckBox,{size:"2.0"===p?"SMALL":"DEFAULT",isDisabled:null!==(x=i.disabled)&&void 0!==x&&x,isChecked:!!i.selected,onValueChange:g}),e.jsx("div",Object.assign({style:{marginRight:"-4px"}},{children:i.leadingIcon}))]})):i.leadingIcon?e.jsx(e.Fragment,{children:i.leadingIcon}):e.jsx(e.Fragment,{}),customComponent:i.customComponent,trailingIcon:i.isFreeForm?e.jsx(o.FreeFormContainer,{children:e.jsx(s.BodyCaption,Object.assign({style:{color:r.COLORS.content.secondary}},{children:"Freeform"}))}):i.trailingIcon?e.jsx(e.Fragment,{children:i.trailingIcon}):e.jsx(e.Fragment,{}),variant:i.disabled?"inactive":i.selected?"selected":"default"})};
|
|
5
|
+
`;exports.MenuItem=t=>{let{option:i,isMultiSelect:l,showDescription:a,onSelect:d,last:u,version:p,onDropdownItemClick:m}=t;var x;function g(e){i.disabled||d(Object.assign(Object.assign({},i),{selected:e}))}return e.jsx(c,{version:p,style:u?{borderBottom:0}:{},onClick:e=>{e.preventDefault(),g(!i.selected),null==m||m(i)},onMouseOver:function(){i.description?a(i.label,i.description):a()},listItem:{value:i.value,label:i.label},subText:i.subText,leadingIcon:l?e.jsxs("div",Object.assign({style:{display:"flex",alignContent:"center",justifyContent:"center",gap:8}},{children:[e.jsx(n.CheckBox,{size:"2.0"===p?"SMALL":"DEFAULT",isDisabled:null!==(x=i.disabled)&&void 0!==x&&x,isChecked:!!i.selected,onValueChange:g}),e.jsx("div",Object.assign({style:{marginRight:"-4px"}},{children:i.leadingIcon}))]})):i.leadingIcon?e.jsx(e.Fragment,{children:i.leadingIcon}):e.jsx(e.Fragment,{}),customComponent:i.customComponent,trailingIcon:i.isFreeForm?e.jsx(o.FreeFormContainer,{children:e.jsx(s.BodyCaption,Object.assign({style:{color:r.COLORS.content.secondary}},{children:"Freeform"}))}):i.trailingIcon?e.jsx(e.Fragment,{children:i.trailingIcon}):e.jsx(e.Fragment,{}),variant:i.disabled?"inactive":i.selected?"selected":"default"})};
|
|
@@ -7,6 +7,7 @@ interface MenuListProps {
|
|
|
7
7
|
onSelect: (optionSelect: SingleOption) => void;
|
|
8
8
|
version?: '1.0' | '2.0';
|
|
9
9
|
onInfiniteScroll?: () => void;
|
|
10
|
+
onDropdownItemClick?: (option: DropdownOption) => void;
|
|
10
11
|
}
|
|
11
12
|
export declare const MenuList: React.FC<MenuListProps>;
|
|
12
13
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),t=require("./MenuItem.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),t=require("./MenuItem.js"),r=require("./MenuList.styled.js");exports.MenuList=s=>{let{options:i,isMultiSelect:o,showDescription:c,onSelect:l,version:u,onInfiniteScroll:a,onDropdownItemClick:p}=s;const d=n.useRef(null),j=n.useRef(null),g=n.useCallback((()=>{d.current&&d.current.disconnect(),d.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==a||a())})),j.current&&d.current.observe(j.current)}),[a]);return n.useEffect((()=>(g(),()=>{d.current&&d.current.disconnect()})),[g,i]),e.jsx(e.Fragment,{children:i.map(((n,s)=>{const a=s===i.length-1;if(n.options){const i=n;return e.jsxs("div",Object.assign({style:{marginTop:"2.0"===u?2:0}},{children:[e.jsxs(r.StyledGroupedLabel,Object.assign({version:u},{children:[i.leadingIcon?e.jsx("span",Object.assign({style:{marginRight:8}},{children:i.leadingIcon})):e.jsx(e.Fragment,{}),i.label]})),i.options.map(((n,r)=>e.jsx(t.MenuItem,{version:u,last:r===i.options.length-1,onSelect:l,showDescription:c,onDropdownItemClick:p,isMultiSelect:o,option:n},`${s}-${r}`)))]}),s)}return e.jsxs("div",{children:[e.jsx(t.MenuItem,{version:u,last:a,onSelect:l,showDescription:c,onDropdownItemClick:p,isMultiSelect:o,option:n},s),a?e.jsx("span",{ref:j}):null]},s)}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o}from"../../_virtual/_tslib.js";import{jsx as
|
|
1
|
+
import{__rest as o}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{useState as e,useRef as n,useEffect as r}from"react";import{COLORS as i}from"../../constants/Theme.js";import l from"../../assets/icons/chevronDown.svg.js";import{Input as s}from"../input/Input.js";import{InputStyleContext as a}from"../input/context/InputStyleProvider.js";import{DropdownPopover as d}from"./DropdownPopover/index.js";import{getSelectedOptionsAsText as p}from"./OpenedDropdown/utils/iterationOnOptions.js";function c(){}const u=u=>{var m,h,f,{placeHolder:v,size:g,onSelect:b,defaultOptions:j,disabled:w,noErrorHint:H,placeHolderHeight:x}=u,O=o(u,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight"]);const[y,D]=e(!1),E=null!=g?g:"default",I=n(),[S,z]=e(null!=j?j:[]);r((()=>{var o;const t=[];null===(o=null==O?void 0:O.options)||void 0===o||o.forEach((o=>{o.options?o.options.forEach((o=>{o.selected&&t.push(Object.assign(Object.assign({},o),{label:o.label}))})):o.selected&&t.push(o)})),z([...t])}),[O.options]),r((()=>{j&&z([...j])}),[j]);const C=p(S);return t(a.Provider,Object.assign({value:{InputWrapper:{height:x||("small"===E?32:48),width:null!==(h=null!==(m=O.buttonWidth)&&void 0!==m?m:O.width)&&void 0!==h?h:"100%",zIndex:1,cursor:"pointer",padding:"6px 8px"},input:{minHeight:"100%"}}},{children:t(d,Object.assign({ref:I,onSelect:function(o){Array.isArray(o)?z([...o]):z([o]),null==b||b(o)},disabled:w,onDropdownVisbilityChange:o=>D(o)},O,{children:t(s,{version:O.version,noErrorHint:H,state:w?"disabled":"none",value:null!=C?C:"",errorMessage:O.error,variant:E,placeholder:null!=v?v:"Select an option",width:null!==(f=O.width)&&void 0!==f?f:"100%",onChangeText:c,rightIcon:{icon:()=>t(l,{style:{transform:y?"rotate(180deg)":"rotate(0deg)"},onClick:c,width:"small"===E?20:24,height:"small"===E?20:24,color:i.content.primary})},truncateText:!0})}))}))};u.displayName="Dropdown";export{u as Dropdown};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as n,useEffect as r}from"react";import{ZeroState as l}from"../../../zeroState/ZeroState.js";import{useOutside as i}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
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as n,useEffect as r}from"react";import{ZeroState as l}from"../../../zeroState/ZeroState.js";import{useOutside as i}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 m,MenuListContainer as h}from"./OpennedDropdown.styled.js";import{SearchBox as f}from"./searchbox/SearchBox.js";import{SearchZeroState as S}from"./searchbox/SearchZeroState.js";const g=304,w=290,b=b=>{let{options:v,isSearchable:j,isMultiSelect:y,width:x,allowFreeForm:C,height:O,onClose:M,onSelect:D,onSearch:k,version:L,skipSorting:A,headerRef:F,hideSelectAll:I,primaryButtonText:B,onInfiniteScroll:H,onMultiSelectClear:T,onDropdownItemClick:R}=b;const{dropdownOptions:Z,search:q,searchedString:z,searchedOptions:K,onApplyHandler:N,selectAllHandler:P,onMultiSelectClear:W,onFreeFormSelect:E,onMultiSelectApply:G,latestDropdownOptionsRef:J,getSelectedOptions:Q}=s(L,v,D,A,y,k),[U,V]=o(null!=x?x:w),[X,Y]=o(null),$=n(null);i($,(()=>{if(Y(null),y&&"2.0"===L){const e=Q(J.current);null==M||M(e)}else null==M||M(Z)}),[F]);const _=null!=O?O:g,ee="number"==typeof _?j&&y?_-96:j&&!y||!j&&y?_-48:_:_;r((()=>{const e=null!=x?x:w;if(null===X)V(e);else if("number"==typeof e)V(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));V(t)}}),[X]);const te=[],oe=(z&&k?K:Z).map((e=>{var t,o;if(z&&!k){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(z.toLowerCase()))&&(te.push(!z||e.label===z),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(z.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(z.toLowerCase()))?(te.push(!z||e.label===z),e):null}return e})).filter((e=>null!==e)),ne=!!j&&z&&0===oe.length;return e(m,Object.assign({version:L,ref:$,style:{width:U}},{children:[e("div",Object.assign({style:{width:X?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!j&&t(f,{onSearch:q,version:L}),oe.length||z?e(h,Object.assign({minHeight:_,maxHeight:ee},{children:[!!y&&!ne&&!I&&t(u,{version:L,options:z&&k?K:Z,onSelect:P}),!C&&ne&&t(S,{height:ee,searchedString:z}),C&&(ne||!!te.length&&te.every((e=>!1===e)))&&t(a,{version:L,isMultiSelect:y,onSelect:E,searchedString:z}),t(p,{onInfiniteScroll:H,onDropdownItemClick:R,version:L,onSelect:N,showDescription:function(e,t){Y(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:oe})]})):t("div",Object.assign({style:{height:_,display:"flex"}},{children:t(l,{title:"No results found",subTitle:"Please try again later or contact us at support@bik.ai if you require further assistance."})})),!!y&&!(!oe.length&&!z)&&"2.0"!==L&&t(d,{onClear:()=>{W(),null==T||T()},onApply:G,list:z&&k?K:Z,buttonText:B})]})),!!X&&t(c,{title:X.title,description:X.description,version:L})]}))};export{b as OpenedDropdown};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MultiSelectOption, SingleOption } from '../../../type';
|
|
3
|
-
|
|
3
|
+
interface MenuItemProps {
|
|
4
4
|
option: SingleOption | MultiSelectOption;
|
|
5
5
|
isMultiSelect?: boolean;
|
|
6
6
|
showDescription: (title?: string, description?: string) => void;
|
|
7
7
|
onSelect: (option: SingleOption) => void;
|
|
8
|
+
onDropdownItemClick?: (option: SingleOption) => void;
|
|
8
9
|
last?: boolean;
|
|
9
10
|
version?: '1.0' | '2.0';
|
|
10
|
-
}
|
|
11
|
+
}
|
|
12
|
+
export declare const MenuItem: React.FC<MenuItemProps>;
|
|
13
|
+
export {};
|
|
@@ -2,4 +2,4 @@ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import i from"st
|
|
|
2
2
|
padding: ${e=>"2.0"===e.version?"8px 12px":"14px 16px"} !important;
|
|
3
3
|
cursor: pointer;
|
|
4
4
|
margin-top: ${e=>"2.0"===e.version?"2px":"0"};
|
|
5
|
-
`,d=i=>{let{option:s,isMultiSelect:d,showDescription:m,onSelect:p,last:g,version:u}=i;var
|
|
5
|
+
`,d=i=>{let{option:s,isMultiSelect:d,showDescription:m,onSelect:p,last:g,version:u,onDropdownItemClick:b}=i;var f;function h(e){s.disabled||p(Object.assign(Object.assign({},s),{selected:e}))}return e(a,{version:u,style:g?{borderBottom:0}:{},onClick:e=>{e.preventDefault(),h(!s.selected),null==b||b(s)},onMouseOver:function(){s.description?m(s.label,s.description):m()},listItem:{value:s.value,label:s.label},subText:s.subText,leadingIcon:d?t("div",Object.assign({style:{display:"flex",alignContent:"center",justifyContent:"center",gap:8}},{children:[e(o,{size:"2.0"===u?"SMALL":"DEFAULT",isDisabled:null!==(f=s.disabled)&&void 0!==f&&f,isChecked:!!s.selected,onValueChange:h}),e("div",Object.assign({style:{marginRight:"-4px"}},{children:s.leadingIcon}))]})):s.leadingIcon?e(n,{children:s.leadingIcon}):e(n,{}),customComponent:s.customComponent,trailingIcon:s.isFreeForm?e(c,{children:e(r,Object.assign({style:{color:l.content.secondary}},{children:"Freeform"}))}):s.trailingIcon?e(n,{children:s.trailingIcon}):e(n,{}),variant:s.disabled?"inactive":s.selected?"selected":"default"})};export{d as MenuItem};
|
|
@@ -7,6 +7,7 @@ interface MenuListProps {
|
|
|
7
7
|
onSelect: (optionSelect: SingleOption) => void;
|
|
8
8
|
version?: '1.0' | '2.0';
|
|
9
9
|
onInfiniteScroll?: () => void;
|
|
10
|
+
onDropdownItemClick?: (option: DropdownOption) => void;
|
|
10
11
|
}
|
|
11
12
|
export declare const MenuList: React.FC<MenuListProps>;
|
|
12
13
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n,Fragment as e,jsxs as t}from"react/jsx-runtime";import{useRef as r,useCallback as
|
|
1
|
+
import{jsx as n,Fragment as e,jsxs as t}from"react/jsx-runtime";import{useRef as r,useCallback as o,useEffect as i}from"react";import{MenuItem as s}from"./MenuItem.js";import{StyledGroupedLabel as c}from"./MenuList.styled.js";const l=l=>{let{options:p,isMultiSelect:u,showDescription:m,onSelect:a,version:d,onInfiniteScroll:g,onDropdownItemClick:h}=l;const I=r(null),v=r(null),f=o((()=>{I.current&&I.current.disconnect(),I.current=new IntersectionObserver((n=>{n[0].isIntersecting&&(null==g||g())})),v.current&&I.current.observe(v.current)}),[g]);return i((()=>(f(),()=>{I.current&&I.current.disconnect()})),[f,p]),n(e,{children:p.map(((r,o)=>{const i=o===p.length-1;if(r.options){const i=r;return t("div",Object.assign({style:{marginTop:"2.0"===d?2:0}},{children:[t(c,Object.assign({version:d},{children:[i.leadingIcon?n("span",Object.assign({style:{marginRight:8}},{children:i.leadingIcon})):n(e,{}),i.label]})),i.options.map(((e,t)=>n(s,{version:d,last:t===i.options.length-1,onSelect:a,showDescription:m,onDropdownItemClick:h,isMultiSelect:u,option:e},`${o}-${t}`)))]}),o)}return t("div",{children:[n(s,{version:d,last:i,onSelect:a,showDescription:m,onDropdownItemClick:h,isMultiSelect:u,option:r},o),i?n("span",{ref:v}):null]},o)}))})};export{l as MenuList};
|