@bikdotai/bik-component-library 0.0.726-beta.0 → 0.0.726-beta.10
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/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.d.ts +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +2 -2
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.d.ts +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +2 -2
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),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"),a=require("./multiSelect/MultiSelectDropdownBottomBar.js"),c=require("./OpennedDropdown.styled.js"),d=require("./searchbox/SearchBox.js"),p=require("./searchbox/SearchZeroState.js");const h=304,x=290;exports.OpenedDropdown=j=>{let{options:f,isSearchable:S,isMultiSelect:m,maxSelections:b,width:g,allowFreeForm:w,height:v,onClose:O,onSelect:y,onSearch:E,version:D,skipSorting:C,headerRef:q,hideSelectAll:M,primaryButtonText:R,onInfiniteScroll:k,onMultiSelectClear:L,onDropdownItemClick:A,buttonOptions:F,isSearchLoading:I,disableSearchOptions:T,disableSearchedOptionExcept:B,useDefaultCursor:P,containerStyle:H={},zeroState:Z}=j;const{dropdownOptions:_,search:z,searchedString:V,searchedOptions:W,onApplyHandler:$,selectAllHandler:K,onMultiSelectClear:N,onFreeFormSelect:U,onMultiSelectApply:G,latestDropdownOptionsRef:J,getSelectedOptions:Q,getCurrentSelectionCount:X}=o.useDropdown(D,f,y,C,m,E,T,B,b),[Y,ee]=t.useState(null!=g?g:x),[te,ne]=t.useState(null),[se,oe]=t.useState(-1),re=t.useRef(null),ie=t.useRef([]);s.useOutside(re,(()=>{if(ne(null),m&&"2.0"===D){const e=Q(J.current);null==O||O(e)}else null==O||O(_)}),[q,ie]);const le=null!=v?v:h,ue="number"==typeof le?S&&m?le-96:S&&!m||!S&&m?le-48:le:le;t.useEffect((()=>{const e=null!=g?g:x;if(null===te)ee(e);else if("number"==typeof e)ee(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ee(t)}}),[te]);const ae=[],ce=(e=>{if(!m||!b&&0!==b)return e;const t=X(e)>=b;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})((V&&E?W:_).map((e=>{var t,n;if(V&&!E){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(V.toLowerCase()))&&(ae.push(!V||e.label===V),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(V.toLowerCase()))?(ae.push(!V||e.label===V),e):null}return e})).filter((e=>null!==e))),de=!!S&&V&&0===ce.length;return 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})(ce);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),e.stopPropagation(),oe((e=>{const n=-1===e?0:Math.min(e+1,t.length-1);return setTimeout((()=>{const e=document.querySelector(`[data-dropdown-index="${n}"]`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("ArrowUp"===e.key)e.preventDefault(),e.stopPropagation(),oe((e=>{const t=e<=0?0:e-1;return setTimeout((()=>{const e=document.querySelector(`[data-dropdown-index="${t}"]`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),t}));else if("Enter"===e.key&&se>=0&&se<t.length){e.preventDefault(),e.stopPropagation();const n=t[se];n&&!n.disabled&&$(n)}};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}}),[se,ce,$]),t.useEffect((()=>{oe(-1)}),[V]),e.jsxRuntimeExports.jsxs(c.OpennedDropdownContainer,Object.assign({version:D,ref:re,style:Object.assign({width:Y},H)},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{width:te?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!S&&e.jsxRuntimeExports.jsx(d.SearchBox,{onSearch:z,version:D}),ce.length||V?e.jsxRuntimeExports.jsxs(c.MenuListContainer,Object.assign({minHeight:le,maxHeight:ue},{children:[!!m&&!de&&!M&&e.jsxRuntimeExports.jsx(u.SelectAllMenu,{version:D,options:V&&E?W:_,onSelect:K}),!w&&de&&e.jsxRuntimeExports.jsx(p.SearchZeroState,{isLoading:I,height:ue,searchedString:V,containerWidth:g}),w&&(de||!!ae.length&&ae.every((e=>!1===e)))&&e.jsxRuntimeExports.jsx(i.FreeFormMenu,{version:D,isMultiSelect:m,onSelect:U,searchedString:V}),e.jsxRuntimeExports.jsx(l.MenuList,{onInfiniteScroll:k,onDropdownItemClick:A,version:D,onSelect:$,showDescription:function(e,t){ne(e&&t?{title:e,description:t}:null)},isMultiSelect:m,options:ce,useDefaultCursor:P,focusedIndex:se,ref:ie})]})):e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:le,display:"flex"}},{children:e.jsxRuntimeExports.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."}))})),!!m&&!(!ce.length&&!V)&&"2.0"!==D&&e.jsxRuntimeExports.jsx(a.default,{onClear:()=>{N(),null==L||L()},onApply:G,list:V&&E?W:_,buttonText:R,buttonOptions:F})]})),!!te&&e.jsxRuntimeExports.jsx(r.Description,{title:te.title,description:te.description,version:D})]}))};
|
|
@@ -10,7 +10,7 @@ interface MenuItemProps {
|
|
|
10
10
|
version?: '1.0' | '2.0';
|
|
11
11
|
useDefaultCursor?: boolean;
|
|
12
12
|
isFocused?: boolean;
|
|
13
|
-
|
|
13
|
+
flatIndex?: number;
|
|
14
14
|
}
|
|
15
15
|
export declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
16
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../node_modules/react/jsx-runtime.js"),t=require("../../../../../assets/icons/chevronRight.svg.js"),s=require("react"),n=require("styled-components"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../node_modules/react/jsx-runtime.js"),t=require("../../../../../assets/icons/chevronRight.svg.js"),s=require("react"),n=require("styled-components"),r=require("../../../../checkBox/CheckBox.js"),i=require("../../../../list-item/ListItem.js"),o=require("../../../../tooltips/Tooltip.js"),l=require("../../../../TypographyStyle.js"),a=require("../../../../../constants/Theme.js"),d=require("./FreeFormMenu.styled.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(n);const x=u.default(i.ListItem)`
|
|
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"};
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
border: ${e=>{let{version:t}=e;return"1.0"===t?`1px solid ${a.DEFAULT_THEME.colorsV2.stroke.primary}`:"none"}};
|
|
11
11
|
max-height: 248px;
|
|
12
12
|
overflow-y: auto;
|
|
13
|
-
`,j=s.forwardRef(((n,
|
|
13
|
+
`,j=s.forwardRef(((n,i)=>{let{option:c,isMultiSelect:u,showDescription:j,onSelect:m,last:g,version:v,onDropdownItemClick:b,useDefaultCursor:h,isFocused:E=!1,flatIndex:f=-1}=n;var R;const[C,F]=s.useState(c.selected),y=(e,t)=>{if(!e.children){I(!e.selected);const s=t?Object.assign(Object.assign({},e),{parent:t}):e;null==b||b(s)}},I=e=>{c.disabled||m(Object.assign(Object.assign({},c),{selected:e}))},O=h?{cursor:"default"}:{};return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(o.Tooltip,Object.assign({body:"",tooltipContent:c.children?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:a.DEFAULT_THEME.colorsV2.surface.standard},ref:i,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1)},{children:e.jsxRuntimeExports.jsx(p,Object.assign({version:null!=v?v:"2.0"},{children:c.children.map((t=>{var s;return e.jsxRuntimeExports.jsx(x,{version:v,style:"1.0"!==v&&(null!==(s=null==c?void 0:c.children)&&void 0!==s?s:[]).length-1?{borderBottom:0}:{},onClick:e=>{e.preventDefault(),y(t,c)},listItem:{value:t.value,label:t.label},subText:t.subText,leadingIcon:t.leadingIcon||void 0,customComponent:t.customComponent,trailingIcon:t.trailingIcon||void 0,variant:c.disabled?"inactive":t.selected?"selected":"default"},t.value)}))}))})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),placement:"right-start",hideArrow:!0},{children:e.jsxRuntimeExports.jsx(x,{version:v,style:g?Object.assign(Object.assign({borderBottom:0},O),E?{backgroundColor:"#F5F5F5"}:{}):Object.assign(Object.assign({},O),E?{backgroundColor:"#F5F5F5"}:{}),"data-dropdown-index":f,onClick:e=>{e.preventDefault(),y(c)},onMouseOver:()=>{c.description?j(c.label,c.description):j()},listItem:{value:c.value,label:c.label},subText:c.subText,leadingIcon:u?e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignContent:"center",justifyContent:"center",gap:8}},{children:[e.jsxRuntimeExports.jsx(r.CheckBox,{size:"2.0"===v?"SMALL":"DEFAULT",isDisabled:null!==(R=c.disabled)&&void 0!==R&&R,isChecked:!!c.selected,onValueChange:I}),e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginRight:"-4px"}},{children:c.leadingIcon}))]})):c.leadingIcon?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:c.leadingIcon}):void 0,customComponent:c.customComponent,trailingIcon:c.isFreeForm?e.jsxRuntimeExports.jsx(d.FreeFormContainer,{children:e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:{color:a.COLORS.content.secondary}},{children:"Freeform"}))}):c.children?e.jsxRuntimeExports.jsx(t.default,{width:12,height:12}):c.trailingIcon?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:c.trailingIcon}):void 0,variant:c.disabled?"inactive":c.selected||!u&&C?"selected":"default"})}))})}));exports.MenuItem=j;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../node_modules/react/jsx-runtime.js"),t=require("react"),s=require("./MenuItem.js"),n=require("./MenuList.styled.js");const r=t.forwardRef(((r,o)=>{let{options:i,isMultiSelect:u,showDescription:c,onSelect:l,version:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../node_modules/react/jsx-runtime.js"),t=require("react"),s=require("./MenuItem.js"),n=require("./MenuList.styled.js");const r=t.forwardRef(((r,o)=>{let{options:i,isMultiSelect:u,showDescription:c,onSelect:l,version:x,onInfiniteScroll:d,onDropdownItemClick:p,useDefaultCursor:a,focusedIndex:j=-1}=r;const m=t.useRef(null),f=t.useRef(null),b=t.useCallback((()=>{m.current&&m.current.disconnect(),m.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==d||d())})),f.current&&m.current.observe(f.current)}),[d]);t.useEffect((()=>(b(),()=>{m.current&&m.current.disconnect()})),[b,i]);let I=-1;const R=e=>(e.disabled||I++,I);return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:i.map(((t,r)=>{const d=r===i.length-1;if(t.options){const i=t;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginTop:"2.0"===x?2:0}},{children:[e.jsxRuntimeExports.jsxs(n.StyledGroupedLabel,Object.assign({version:x},{children:[i.leadingIcon?e.jsxRuntimeExports.jsx("span",Object.assign({style:{marginRight:8}},{children:i.leadingIcon})):null,i.label]})),i.options.map(((t,n)=>{const d=t.disabled?-1:R(t);return e.jsxRuntimeExports.jsx(s.MenuItem,{version:x,last:n===i.options.length-1,onSelect:l,showDescription:c,onDropdownItemClick:p,isMultiSelect:u,option:t,useDefaultCursor:a,isFocused:d===j,flatIndex:d,ref:e=>{o&&"object"==typeof o&&o.current&&e&&e&&e&&e&&(o.current[r]=e)}},`${r}-${n}`)})),d?e.jsxRuntimeExports.jsx("span",{ref:f}):null]}),r)}const m=t.disabled?-1:R(t);return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(s.MenuItem,{version:x,last:d,onSelect:l,showDescription:c,onDropdownItemClick:p,isMultiSelect:u,option:t,useDefaultCursor:a,isFocused:m===j,flatIndex:m,ref:e=>{o&&"object"==typeof o&&o.current&&e&&(o.current[r]=e)}},r),d?e.jsxRuntimeExports.jsx("span",{ref:f}):null]},r)}))})}));exports.MenuList=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"../../../../node_modules/react/jsx-runtime.js";import{useState as t,useRef as o,useEffect as n}from"react";import{ZeroState as s}from"../../../zeroState/ZeroState.js";import{useOutside as i}from"../../../../hooks/useOutside.js";import{useDropdown as r}from"../../hooks/useDropdown.js";import{Description as l}from"./description/Description.js";import{FreeFormMenu as
|
|
1
|
+
import{j as e}from"../../../../node_modules/react/jsx-runtime.js";import{useState as t,useRef as o,useEffect as n}from"react";import{ZeroState as s}from"../../../zeroState/ZeroState.js";import{useOutside as i}from"../../../../hooks/useOutside.js";import{useDropdown as r}from"../../hooks/useDropdown.js";import{Description as l}from"./description/Description.js";import{FreeFormMenu as a}from"./menu/FreeFormMenu.js";import{MenuList as c}from"./menu/MenuList.js";import{SelectAllMenu as u}from"./menu/SelectAllMenu.js";import d from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as p,MenuListContainer as h}from"./OpennedDropdown.styled.js";import{SearchBox as m}from"./searchbox/SearchBox.js";import{SearchZeroState as f}from"./searchbox/SearchZeroState.js";const b=304,g=290,j=j=>{let{options:S,isSearchable:x,isMultiSelect:v,maxSelections:w,width:y,allowFreeForm:O,height:C,onClose:D,onSelect:k,onSearch:L,version:M,skipSorting:A,headerRef:I,hideSelectAll:E,primaryButtonText:F,onInfiniteScroll:T,onMultiSelectClear:B,onDropdownItemClick:H,buttonOptions:P,isSearchLoading:q,disableSearchOptions:z,disableSearchedOptionExcept:R,useDefaultCursor:V,containerStyle:W={},zeroState:Z}=j;const{dropdownOptions:$,search:K,searchedString:N,searchedOptions:U,onApplyHandler:_,selectAllHandler:G,onMultiSelectClear:J,onFreeFormSelect:Q,onMultiSelectApply:X,latestDropdownOptionsRef:Y,getSelectedOptions:ee,getCurrentSelectionCount:te}=r(M,S,k,A,v,L,z,R,w),[oe,ne]=t(null!=y?y:g),[se,ie]=t(null),[re,le]=t(-1),ae=o(null),ce=o([]);i(ae,(()=>{if(ie(null),v&&"2.0"===M){const e=ee(Y.current);null==D||D(e)}else null==D||D($)}),[I,ce]);const ue=null!=C?C:b,de="number"==typeof ue?x&&v?ue-96:x&&!v||!x&&v?ue-48:ue:ue;n((()=>{const e=null!=y?y:g;if(null===se)ne(e);else if("number"==typeof e)ne(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ne(t)}}),[se]);const pe=[],he=(e=>{if(!v||!w&&0!==w)return e;const t=te(e)>=w;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})((N&&L?U:$).map((e=>{var t,o;if(N&&!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(N.toLowerCase()))&&(pe.push(!N||e.label===N),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(N.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(N.toLowerCase()))?(pe.push(!N||e.label===N),e):null}return e})).filter((e=>null!==e))),me=!!x&&N&&0===he.length;return n((()=>{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})(he);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),e.stopPropagation(),le((e=>{const o=-1===e?0:Math.min(e+1,t.length-1);return setTimeout((()=>{const e=document.querySelector(`[data-dropdown-index="${o}"]`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("ArrowUp"===e.key)e.preventDefault(),e.stopPropagation(),le((e=>{const t=e<=0?0:e-1;return setTimeout((()=>{const e=document.querySelector(`[data-dropdown-index="${t}"]`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),t}));else if("Enter"===e.key&&re>=0&&re<t.length){e.preventDefault(),e.stopPropagation();const o=t[re];o&&!o.disabled&&_(o)}};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}}),[re,he,_]),n((()=>{le(-1)}),[N]),e.jsxs(p,Object.assign({version:M,ref:ae,style:Object.assign({width:oe},W)},{children:[e.jsxs("div",Object.assign({style:{width:se?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!x&&e.jsx(m,{onSearch:K,version:M}),he.length||N?e.jsxs(h,Object.assign({minHeight:ue,maxHeight:de},{children:[!!v&&!me&&!E&&e.jsx(u,{version:M,options:N&&L?U:$,onSelect:G}),!O&&me&&e.jsx(f,{isLoading:q,height:de,searchedString:N,containerWidth:y}),O&&(me||!!pe.length&&pe.every((e=>!1===e)))&&e.jsx(a,{version:M,isMultiSelect:v,onSelect:Q,searchedString:N}),e.jsx(c,{onInfiniteScroll:T,onDropdownItemClick:H,version:M,onSelect:_,showDescription:function(e,t){ie(e&&t?{title:e,description:t}:null)},isMultiSelect:v,options:he,useDefaultCursor:V,focusedIndex:re,ref:ce})]})):e.jsx("div",Object.assign({style:{height:ue,display:"flex"}},{children:e.jsx(s,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."}))})),!!v&&!(!he.length&&!N)&&"2.0"!==M&&e.jsx(d,{onClear:()=>{J(),null==B||B()},onApply:X,list:N&&L?U:$,buttonText:F,buttonOptions:P})]})),!!se&&e.jsx(l,{title:se.title,description:se.description,version:M})]}))};export{j as OpenedDropdown};
|
|
@@ -10,7 +10,7 @@ interface MenuItemProps {
|
|
|
10
10
|
version?: '1.0' | '2.0';
|
|
11
11
|
useDefaultCursor?: boolean;
|
|
12
12
|
isFocused?: boolean;
|
|
13
|
-
|
|
13
|
+
flatIndex?: number;
|
|
14
14
|
}
|
|
15
15
|
export declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
16
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"../../../../../node_modules/react/jsx-runtime.js";import t from"../../../../../assets/icons/chevronRight.svg.js";import{forwardRef as
|
|
1
|
+
import{j as e}from"../../../../../node_modules/react/jsx-runtime.js";import t from"../../../../../assets/icons/chevronRight.svg.js";import{forwardRef as o,useState as n}from"react";import s from"styled-components";import{CheckBox as i}from"../../../../checkBox/CheckBox.js";import{ListItem as r}from"../../../../list-item/ListItem.js";import{Tooltip as l}from"../../../../tooltips/Tooltip.js";import{BodyCaption as a}from"../../../../TypographyStyle.js";import{DEFAULT_THEME as c,COLORS as d}from"../../../../../constants/Theme.js";import{FreeFormContainer as p}from"./FreeFormMenu.styled.js";const m=s(r)`
|
|
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"};
|
|
@@ -10,4 +10,4 @@ import{j as e}from"../../../../../node_modules/react/jsx-runtime.js";import t fr
|
|
|
10
10
|
border: ${e=>{let{version:t}=e;return"1.0"===t?`1px solid ${c.colorsV2.stroke.primary}`:"none"}};
|
|
11
11
|
max-height: 248px;
|
|
12
12
|
overflow-y: auto;
|
|
13
|
-
`,g=
|
|
13
|
+
`,g=o(((o,s)=>{let{option:r,isMultiSelect:g,showDescription:x,onSelect:j,last:b,version:v,onDropdownItemClick:h,useDefaultCursor:f,isFocused:y=!1,flatIndex:C=-1}=o;var F;const[I,O]=n(r.selected),k=(e,t)=>{if(!e.children){w(!e.selected);const o=t?Object.assign(Object.assign({},e),{parent:t}):e;null==h||h(o)}},w=e=>{r.disabled||j(Object.assign(Object.assign({},r),{selected:e}))},T=f?{cursor:"default"}:{};return e.jsx(e.Fragment,{children:e.jsx(l,Object.assign({body:"",tooltipContent:r.children?e.jsx("div",Object.assign({style:{backgroundColor:c.colorsV2.surface.standard},ref:s,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1)},{children:e.jsx(u,Object.assign({version:null!=v?v:"2.0"},{children:r.children.map((t=>{var o;return e.jsx(m,{version:v,style:"1.0"!==v&&(null!==(o=null==r?void 0:r.children)&&void 0!==o?o:[]).length-1?{borderBottom:0}:{},onClick:e=>{e.preventDefault(),k(t,r)},listItem:{value:t.value,label:t.label},subText:t.subText,leadingIcon:t.leadingIcon||void 0,customComponent:t.customComponent,trailingIcon:t.trailingIcon||void 0,variant:r.disabled?"inactive":t.selected?"selected":"default"},t.value)}))}))})):e.jsx(e.Fragment,{}),placement:"right-start",hideArrow:!0},{children:e.jsx(m,{version:v,style:b?Object.assign(Object.assign({borderBottom:0},T),y?{backgroundColor:"#F5F5F5"}:{}):Object.assign(Object.assign({},T),y?{backgroundColor:"#F5F5F5"}:{}),"data-dropdown-index":C,onClick:e=>{e.preventDefault(),k(r)},onMouseOver:()=>{r.description?x(r.label,r.description):x()},listItem:{value:r.value,label:r.label},subText:r.subText,leadingIcon:g?e.jsxs("div",Object.assign({style:{display:"flex",alignContent:"center",justifyContent:"center",gap:8}},{children:[e.jsx(i,{size:"2.0"===v?"SMALL":"DEFAULT",isDisabled:null!==(F=r.disabled)&&void 0!==F&&F,isChecked:!!r.selected,onValueChange:w}),e.jsx("div",Object.assign({style:{marginRight:"-4px"}},{children:r.leadingIcon}))]})):r.leadingIcon?e.jsx(e.Fragment,{children:r.leadingIcon}):void 0,customComponent:r.customComponent,trailingIcon:r.isFreeForm?e.jsx(p,{children:e.jsx(a,Object.assign({style:{color:d.content.secondary}},{children:"Freeform"}))}):r.children?e.jsx(t,{width:12,height:12}):r.trailingIcon?e.jsx(e.Fragment,{children:r.trailingIcon}):void 0,variant:r.disabled?"inactive":r.selected||!g&&I?"selected":"default"})}))})}));export{g as MenuItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"../../../../../node_modules/react/jsx-runtime.js";import{forwardRef as n,useRef as t,useCallback as r,useEffect as s}from"react";import{MenuItem as o}from"./MenuItem.js";import{StyledGroupedLabel as i}from"./MenuList.styled.js";const c=n(((n,c)=>{let{options:l,isMultiSelect:u,showDescription:d,onSelect:a,version:p,onInfiniteScroll:j,onDropdownItemClick:m,useDefaultCursor:f,focusedIndex:x=-1}=n;const g=t(null),I=t(null),b=r((()=>{g.current&&g.current.disconnect(),g.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==j||j())})),I.current&&g.current.observe(I.current)}),[j]);s((()=>(b(),()=>{g.current&&g.current.disconnect()})),[b,l]);let h=-1;const D=e=>(e.disabled||
|
|
1
|
+
import{j as e}from"../../../../../node_modules/react/jsx-runtime.js";import{forwardRef as n,useRef as t,useCallback as r,useEffect as s}from"react";import{MenuItem as o}from"./MenuItem.js";import{StyledGroupedLabel as i}from"./MenuList.styled.js";const c=n(((n,c)=>{let{options:l,isMultiSelect:u,showDescription:d,onSelect:a,version:p,onInfiniteScroll:j,onDropdownItemClick:m,useDefaultCursor:f,focusedIndex:x=-1}=n;const g=t(null),I=t(null),b=r((()=>{g.current&&g.current.disconnect(),g.current=new IntersectionObserver((e=>{e[0].isIntersecting&&(null==j||j())})),I.current&&g.current.observe(I.current)}),[j]);s((()=>(b(),()=>{g.current&&g.current.disconnect()})),[b,l]);let h=-1;const D=e=>(e.disabled||h++,h);return e.jsx(e.Fragment,{children:l.map(((n,t)=>{const r=t===l.length-1;if(n.options){const s=n;return e.jsxs("div",Object.assign({style:{marginTop:"2.0"===p?2:0}},{children:[e.jsxs(i,Object.assign({version:p},{children:[s.leadingIcon?e.jsx("span",Object.assign({style:{marginRight:8}},{children:s.leadingIcon})):null,s.label]})),s.options.map(((n,r)=>{const i=n.disabled?-1:D(n);return e.jsx(o,{version:p,last:r===s.options.length-1,onSelect:a,showDescription:d,onDropdownItemClick:m,isMultiSelect:u,option:n,useDefaultCursor:f,isFocused:i===x,flatIndex:i,ref:e=>{c&&"object"==typeof c&&c.current&&e&&e&&e&&e&&(c.current[t]=e)}},`${t}-${r}`)})),r?e.jsx("span",{ref:I}):null]}),t)}const s=n.disabled?-1:D(n);return e.jsxs("div",{children:[e.jsx(o,{version:p,last:r,onSelect:a,showDescription:d,onDropdownItemClick:m,isMultiSelect:u,option:n,useDefaultCursor:f,isFocused:s===x,flatIndex:s,ref:e=>{c&&"object"==typeof c&&c.current&&e&&(c.current[t]=e)}},t),r?e.jsx("span",{ref:I}):null]},t)}))})}));export{c as MenuList};
|