@bikdotai/bik-component-library 0.0.517-beta.drop.7 → 0.0.517-beta.drop.8
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"),s=require("../../hooks/useDropdown.js"),o=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:A,onDropdownItemClick:k}=j;const{dropdownOptions:B,search:H,searchedString:I,searchedOptions:Z,onApplyHandler:R,selectAllHandler:T,onMultiSelectClear:P,onFreeFormSelect:_,onMultiSelectApply:z,latestDropdownOptionsRef:E,getSelectedOptions:K}=s.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=(I&&M?Z:B).map((e=>{var t,n;if(I&&!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(I.toLowerCase()))&&(X.push(!I||e.label===I),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(I.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(I.toLowerCase()))?(X.push(!I||e.label===I),e):null}return e})).filter((e=>null!==e)),$=!!x&&I&&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:H,version:O}),Y.length||I?e.jsxs(a.MenuListContainer,Object.assign({minHeight:U,maxHeight:V},{children:[!!g&&!$&&!D&&e.jsx(u.SelectAllMenu,{version:O,options:I&&M?Z:B,onSelect:T}),!v&&$&&e.jsx(p.SearchZeroState,{height:V,searchedString:I}),v&&($||!!X.length&&X.every((e=>!1===e)))&&e.jsx(i.FreeFormMenu,{version:O,isMultiSelect:g,onSelect:_,searchedString:I}),e.jsx(l.MenuList,{onInfiniteScroll:F,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&&!I)&&"2.0"!==O&&e.jsx(c.default,{onClear:()=>{P(),null==A||A()},onApply:z,list:I&&M?Z:B,buttonText:L})]})),!!G&&e.jsx(o.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"),s=require("./MenuList.styled.js");exports.MenuList=r=>{let{options:i,isMultiSelect:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),t=require("./MenuItem.js"),s=require("./MenuList.styled.js");exports.MenuList=r=>{let{options:i,isMultiSelect:o,showDescription:c,onSelect:l,version:u,onInfiniteScroll:a,onDropdownItemClick:p}=r;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,r)=>{const a=r===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(s.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,s)=>e.jsx(t.MenuItem,{version:u,last:s===i.options.length-1,onSelect:l,showDescription:c,isMultiSelect:o,option:n},`${r}-${s}`)))]}),r)}return e.jsxs("div",{children:[e.jsx(t.MenuItem,{version:u,last:a,onSelect:l,showDescription:c,isMultiSelect:o,option:n},r),a?e.jsx("span",{ref:j}):null]},r)}))})};
|
|
@@ -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 u}from"./menu/MenuList.js";import{SelectAllMenu as p}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,v=v=>{let{options:
|
|
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 u}from"./menu/MenuList.js";import{SelectAllMenu as p}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,v=v=>{let{options:w,isSearchable:j,isMultiSelect:y,width:x,allowFreeForm:C,height:O,onClose:M,onSelect:D,onSearch:L,version:k,skipSorting:A,headerRef:F,hideSelectAll:B,primaryButtonText:H,onInfiniteScroll:I,onMultiSelectClear:T,onDropdownItemClick:R}=v;const{dropdownOptions:Z,search:q,searchedString:z,searchedOptions:K,onApplyHandler:N,selectAllHandler:P,onMultiSelectClear:W,onFreeFormSelect:E,onMultiSelectApply:G,latestDropdownOptionsRef:J,getSelectedOptions:Q}=s(k,w,D,A,y,L),[U,V]=o(null!=x?x:b),[X,Y]=o(null),$=n(null);i($,(()=>{if(Y(null),y&&"2.0"===k){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:b;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&&L?K:Z).map((e=>{var t,o;if(z&&!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(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(h,Object.assign({version:k,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:k}),oe.length||z?e(m,Object.assign({minHeight:_,maxHeight:ee},{children:[!!y&&!ne&&!B&&t(p,{version:k,options:z&&L?K:Z,onSelect:P}),!C&&ne&&t(S,{height:ee,searchedString:z}),C&&(ne||!!te.length&&te.every((e=>!1===e)))&&t(a,{version:k,isMultiSelect:y,onSelect:E,searchedString:z}),t(u,{onInfiniteScroll:I,version:k,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"!==k&&t(d,{onClear:()=>{W(),null==T||T()},onApply:G,list:z&&L?K:Z,buttonText:H})]})),!!X&&t(c,{title:X.title,description:X.description,version:k})]}))};export{v 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 i,useEffect as o}from"react";import{MenuItem as s}from"./MenuItem.js";import{StyledGroupedLabel as c}from"./MenuList.styled.js";const l=l=>{let{options:u,isMultiSelect:p,showDescription:a,onSelect:m,version:d,onInfiniteScroll:g}=l;const
|
|
1
|
+
import{jsx as n,Fragment as e,jsxs as t}from"react/jsx-runtime";import{useRef as r,useCallback as i,useEffect as o}from"react";import{MenuItem as s}from"./MenuItem.js";import{StyledGroupedLabel as c}from"./MenuList.styled.js";const l=l=>{let{options:u,isMultiSelect:p,showDescription:a,onSelect:m,version:d,onInfiniteScroll:g,onDropdownItemClick:h}=l;const v=r(null),f=r(null),I=i((()=>{v.current&&v.current.disconnect(),v.current=new IntersectionObserver((n=>{n[0].isIntersecting&&(null==g||g())})),f.current&&v.current.observe(f.current)}),[g]);return o((()=>(I(),()=>{v.current&&v.current.disconnect()})),[I,u]),n(e,{children:u.map(((r,i)=>{const o=i===u.length-1;if(r.options){const o=r;return t("div",Object.assign({style:{marginTop:"2.0"===d?2:0}},{children:[t(c,Object.assign({version:d},{children:[o.leadingIcon?n("span",Object.assign({style:{marginRight:8}},{children:o.leadingIcon})):n(e,{}),o.label]})),o.options.map(((e,t)=>n(s,{version:d,last:t===o.options.length-1,onSelect:m,showDescription:a,isMultiSelect:p,option:e},`${i}-${t}`)))]}),i)}return t("div",{children:[n(s,{version:d,last:o,onSelect:m,showDescription:a,isMultiSelect:p,option:r},i),o?n("span",{ref:f}):null]},i)}))})};export{l as MenuList};
|