@foxford/ui 2.79.0 → 2.80.0-beta-d262988-20250924
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/components/Dropdown/Dropdown.js +1 -1
- package/components/Dropdown/Dropdown.js.map +1 -1
- package/components/Dropdown/Dropdown.mjs +1 -1
- package/components/Dropdown/Dropdown.mjs.map +1 -1
- package/components/Dropdown/DropdownMenu.js +1 -1
- package/components/Dropdown/DropdownMenu.js.map +1 -1
- package/components/Dropdown/DropdownMenu.mjs +1 -1
- package/components/Dropdown/DropdownMenu.mjs.map +1 -1
- package/components/Dropdown/constants.js +1 -1
- package/components/Dropdown/constants.js.map +1 -1
- package/components/Dropdown/constants.mjs +1 -1
- package/components/Dropdown/constants.mjs.map +1 -1
- package/components/Dropdown/sizes.js +2 -0
- package/components/Dropdown/sizes.js.map +1 -0
- package/components/Dropdown/sizes.mjs +2 -0
- package/components/Dropdown/sizes.mjs.map +1 -0
- package/components/Dropdown/style.js.map +1 -1
- package/components/Dropdown/style.mjs.map +1 -1
- package/dts/index.d.ts +448 -237
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var React=require('react');var nanoid=require('nanoid');var withMergedProps=require('../../hocs/withMergedProps.js');var useScrollMonitor=require('../../hooks/useScrollMonitor.js');var dom=require('../../shared/utils/dom.js');var misc=require('../../shared/utils/misc.js');var constants$1=require('../../shared/constants.js');var DropdownMenu=require('./DropdownMenu.js');var hooks=require('./hooks.js');var constants=require('./constants.js');var utils=require('./utils.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var FormInputLabel=require('../FormInputLabel/FormInputLabel.js');var FormInput=require('../FormInput/FormInput.js');var Chip=require('../Chip/Chip.js');var IconButton=require('../IconButton/IconButton.js');var MenuList=require('../MenuList/MenuList.js');var ListItem=require('../ListItem/ListItem.js');var InputCheckbox=require('../InputCheckbox/InputCheckbox.js');var MenuDivider=require('../MenuDivider/MenuDivider.js');const Dropdown=withMergedProps.withMergedProps(React.forwardRef(((e,o)=>{const{size:t="m",name:n="fox-dropdown",labelPosition:r="dynamic",searchable:s=!0,primary:a=!0,optionsMultiToggle:i=!0,iconProps:l={},menuProps:c={},loadingIconProps:u={},optionsEmptyIconProps:d={},loading:p,autoFocus:b,disableAutoScrollToSelectedOption:m,closeMenuOnScroll:g,scrollMonitorTarget:v,contrast:x,selectedOption:f,defaultSelectedOption:k,icon:C,inputMode:h,loadingMessage:I,loadingIcon:R,maxLength:j,multiple:y,clearable:w,onChangeInput:D,onCloseMenu:M,onOpenMenu:S,onSelectOption:P,options:L,loadOptions:E,groupSelectedOptions:B,optionsMultiToggleCaption:T,optionsEmptyMessage:F,optionsEmptyIcon:q,palette:z,placeholder:O,readOnly:K,required:X,status:$,sizeXXS:H,sizeXS:N,sizeS:Z,sizeM:_,sizeL:A,sizeXL:U,form:G,...J}=e;const Q={size:t,sizeXXS:H,sizeXS:N,sizeS:Z,sizeM:_,sizeL:A,sizeXL:U};const V={sizes:constants.SIZES_ICON,color:J.disabled?'content-disabled':'content-onmain-tertiary'};const W=React.useMemo((()=>J.id??`${n}-${nanoid.nanoid()}`),[n,J.id]);const Y=React.useMemo((()=>nanoid.nanoid()),[]);const ee=React.useMemo((()=>nanoid.nanoid()),[]);const[oe,te]=hooks.useFilteredOptions({options:L});const[ne,re,se]=hooks.useLoadedOptions({loadOptions:E,options:L});const[ae,ie]=React.useState((()=>utils.getDropdownSelectedOption(f!==void 0?f:k,y)));const[le,ce]=React.useState((()=>utils.getDropdownInputText(ae,y)));const[ue,de]=React.useState(!1);const[pe,be]=React.useState(!1);const me=E?ne:oe;const ge=E?p??re:p;const ve=React.useMemo((()=>y?utils.groupDropdownOptions(me,ae):[[],[]]),[y,me,ae]);const xe=pe&&!J.disabled;const fe=X&&ae.length===0;const ke=Boolean(xe||le||ue);const Ce=ve[0].length>0&&ve[1].length===0;const he=ve[0].length>0&&ve[1].length>0;const Ie=React.useRef(null);const[Re,je]=React.useState(null);const ye=React.useRef(null);const we=React.useRef(null);const De=React.useRef(xe);const Me=React.useCallback((e=>{ce(e),D&&D(e)}),[D]);const Se=React.useCallback((e=>{E?se(e):te(e)}),[E,se,te]);const Pe=React.useMemo((()=>misc.createDebouncedCallback(Se,150)),[Se]);const preventBlur=e=>{e.target!==Ie.current&&e.target instanceof Node&&(e.currentTarget.contains(e.target)||c.renderInPortal&&xe&&Re&&Re.contains(e.target))&&e.preventDefault()};return useScrollMonitor.useScrollMonitor({target:v,onScrollStart:()=>{g&&xe&&(Ie.current?.focus(),be(!1))}}),React.useLayoutEffect((()=>{f!==void 0&&(y||xe||Me(utils.getDropdownInputText(f)),ie(utils.getDropdownSelectedOption(f,y)))}),[y,f,xe,Me]),React.useEffect((()=>{xe!==De.current&&(xe&&S&&S(),!xe&&M&&M(),De.current=xe)}),[xe,M,S]),React.useEffect((()=>{if(!y&&!m&&xe&&!ge&&le.length===0&&Re&&we.current){const e=Re.getBoundingClientRect();const o=we.current.getBoundingClientRect();(o.top<e.top||o.bottom>e.bottom)&&setTimeout((()=>{Re&&we.current&&Re.scrollTo(0,we.current.offsetTop)}),0)}}),[y,m,xe,ge,le,Re]),jsxRuntime.jsx(FormInputLabel.FormInputLabel,{...J,...Q,ref:o,id:W,labelId:Y,labelPosition:r,active:ke,onColored:x,primary:a,error:$==='error',success:$==='success',focus:ue,icon:[C,jsxRuntime.jsx(style.ChevronIcon,{up:xe},'chevron')],iconProps:{...Q,...V,...l},palette:{color:J.disabled?z.labelColorDisabled:z.labelColor,backgroundColor:J.disabled?z.backgroundColorDisabled:z.backgroundColor,backgroundColorHover:J.disabled?z.backgroundColorDisabled:z.backgroundColorHover,borderColor:J.disabled?z.borderColorDisabled:z.borderColor},onClick:e=>{J.onClick&&J.onClick(e),J.disabled||(Ie.current?.focus(),xe?Re&&e.target instanceof Node&&!Re.contains(e.target)&&(be(!1),Me(utils.getDropdownInputText(ae,y))):(be(!0),Se(''),s&&Me('')))},onPointerDown:e=>{J.onPointerDown&&J.onPointerDown(e),preventBlur(e)},onMouseDown:e=>{J.onMouseDown&&J.onMouseDown(e),window.PointerEvent||preventBlur(e)},onFocus:e=>{J.onFocus&&J.onFocus(e),de(!0),Ie.current&&e.target===Ie.current&&s&&!y&&!xe&&Me('')},onBlur:e=>{J.onBlur&&J.onBlur(e),e.currentTarget.contains(e.relatedTarget)||c.renderInPortal&&xe&&Re&&Re.contains(e.relatedTarget)||(de(!1),Me(utils.getDropdownInputText(ae,y)),be(!1))},input:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!fe||s||K?null:jsxRuntime.jsx(style.InputMimic,{required:!0,type:"text",inputMode:"none",form:G,tabIndex:-1,onFocus:()=>{Ie.current?.focus()}}),jsxRuntime.jsx(FormInput.FormInput,{ref:Ie,role:"combobox","aria-controls":ee,"aria-expanded":xe,"aria-labelledby":J.label?Y:void 0,type:"text",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",form:G,autoFocus:b,inputMode:s?h:'none',maxLength:j,placeholder:O,readOnly:K||!s,required:fe,disabled:J.disabled,value:le,palette:{color:z.color,colorDisabled:z.colorDisabled,placeholderColor:z.placeholderColor,placeholderColorDisabled:z.placeholderColorDisabled},onClick:e=>{xe&&e.currentTarget.selectionStart!==e.currentTarget.selectionEnd&&e.stopPropagation()},onChange:e=>{const o=e.currentTarget.value;Me(o),Pe(o),be(!0)},onKeyDown:e=>{if(constants$1.keyboardKeys.Enter.validate(e.key)&&(Me(utils.getDropdownInputText(ae,y)),be(!1)),!constants$1.keyboardKeys.Space.validate(e.key)||xe&&e.currentTarget.selectionStart!==0||(e.preventDefault(),xe||(Se(''),s&&Me('')),be((e=>!e))),constants$1.keyboardKeys.Esc.validate(e.key)&&be(!1),constants$1.keyboardKeys.Tab.validate(e.key)&&xe&&(e.preventDefault(),be(!1)),constants$1.keyboardKeys.ArrowDown.validate(e.key)&&xe&&ye.current)if(e.preventDefault(),!y&&we.current){const e=[...ye.current.children];const o=e.findIndex((e=>e.contains(we.current)));const t=e[o+1]??e[0];t instanceof HTMLElement&&dom.focusFirstFocusable(t)}else dom.focusFirstFocusable(ye.current);if(constants$1.keyboardKeys.ArrowUp.validate(e.key)&&xe&&ye.current)if(e.preventDefault(),!y&&we.current){const e=[...ye.current.children];const o=e.findIndex((e=>e.contains(we.current)));const t=e[o-1]??e[e.length-1];t instanceof HTMLElement&&dom.focusFirstFocusable(t)}else dom.focusLastFocusable(ye.current)}}),ae.map((e=>jsxRuntime.jsx("input",{type:"hidden",name:n,value:e.value,form:G,disabled:J.disabled},e.value)))]}),addon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[y&&ae.length>0?jsxRuntime.jsx(Chip.Chip,{size:"xs",active:!0,black:!0,marginLeft:12,disabled:J.disabled,cursor:J.disabled?'not-allowed':void 0,text:ae.length,textProps:{appearance:'caption',size:'xs'},palette:J.disabled?{color:'content-disabled',colorHover:'content-disabled',backgroundColor:'bg-disabled-small',backgroundColorHover:'bg-disabled-small'}:void 0,onPointerDown:e=>{e.preventDefault()},onMouseDown:e=>{window.PointerEvent||e.preventDefault()},discardButtonProps:{square:!0,contrast:!J.disabled,onClick:e=>{e.stopPropagation(),K||(f===void 0&&ie([]),P&&P([]),Ie.current?.focus(),Me(''),Se(''),be(!0))}}}):null,!y&&w&&ae.length>0?jsxRuntime.jsx(IconButton.IconButton,{icon:"close",size:"l",square:!0,marginLeft:12,disabled:J.disabled,onClick:e=>{e.stopPropagation(),K||(f===void 0&&ie([]),P&&P(null),Ie.current?.focus(),Me(''),Se(''),be(!0))}}):null]}),dropdown:jsxRuntime.jsx(DropdownMenu.DropdownMenu,{...c,setRef:je,open:xe,popperReferenceId:W,secondary:!x,elevated:x,disableAutoFocus:!0,palette:{backgroundColor:z.menuBackgroundColor,borderColor:z.menuBorderColor},empty:me.length===0,loading:ge,loadingMessage:I,loadingIcon:R,loadingIconProps:{...Q,...V,...u},emptyMessage:F,emptyIcon:q,emptyIconProps:{...Q,...V,...d},onKeyDown:e=>{constants$1.keyboardKeys.Tab.validate(e.key)&&(e.preventDefault(),Ie.current?.focus(),be(!1)),constants$1.keyboardKeys.Enter.validate(e.key)&&(Ie.current?.focus(),Me(utils.getDropdownInputText(ae,y)),be(!1)),constants$1.keyboardKeys.Esc.validate(e.key)&&(Ie.current?.focus(),be(!1)),constants$1.keyboardKeys.Backspace.validate(e.key)&&!K&&(y||!y&&w)&&(f===void 0&&ie([]),P&&P(y?[]:null),Me(''),Se(''))},children:jsxRuntime.jsx(MenuList.MenuList,y?{ref:ye,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,"aria-multiselectable":!0,children:le.length===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i?jsxRuntime.jsx(ListItem.ListItem,{...Q,text:T,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:constants.SIZES_CHECKBOX,form:"none",name:n,checked:Ce,indeterminate:he,error:Boolean((Ce||he)&&$==='error'),success:Boolean((Ce||he)&&$==='success'),onChange:()=>{if(!K){const e=Ce||he?[]:[...me];f===void 0&&ie(e),P&&P(e)}}})}):null,i?jsxRuntime.jsx(MenuDivider.MenuDivider,{}):null,B?ve[0].map((e=>{const o=e.status??$;const t=o==='error';const r=o==='success';return React.createElement(ListItem.ListItem,{...Q,key:e.value,active:!0,text:e.text,danger:t,success:r,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),Ie.current?.focus()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:constants.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!0,name:n,value:e.value,checked:!0,error:t,success:r,onChange:e=>{if(!K){const o=ae.filter((o=>o.value!==e.currentTarget.value));f===void 0&&ie(o),P&&P(o)}}})})})):null,B&&ve[0].length>0&&ve[1].length>0?jsxRuntime.jsx(MenuDivider.MenuDivider,{}):null,B?ve[1].map((e=>React.createElement(ListItem.ListItem,{...Q,key:e.value,text:e.text,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),Ie.current?.focus()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:constants.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!1,name:n,value:e.value,checked:!1,onChange:()=>{if(!K){const o=[...ae,e];f===void 0&&ie(o),P&&P(o)}}})}))):null,!B&&me.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??$;const r=o&&t==='error';const s=o&&t==='success';return React.createElement(ListItem.ListItem,{...Q,key:e.value,text:e.text,danger:r,success:s,disabled:J.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:constants.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:n,value:e.value,checked:o,error:r,success:s,onChange:t=>{if(!K){const n=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];f===void 0&&ie(n),P&&P(n)}}})})}))]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:me.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??$;const r=o&&t==='error';const s=o&&t==='success';return React.createElement(ListItem.ListItem,{...Q,key:e.value,text:e.text,danger:r,success:s,disabled:J.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:constants.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:n,value:e.value,checked:o,error:r,success:s,onChange:t=>{if(!K){const n=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];f===void 0&&ie(n),P&&P(n)}}})})}))})}:{ref:ye,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,children:me.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;return React.createElement(ListItem.ListItem,{...Q,role:"option","aria-selected":o,ref:o?we:void 0,key:e.value,text:e.text,active:o,danger:Boolean(o&&$==='error'),success:Boolean(o&&$==='success'),disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:o=>{if(o.stopPropagation(),!K){const o={...e};f===void 0&&(Me(utils.getDropdownInputText(o)),ie(utils.getDropdownSelectedOption(o))),P&&P(o),Ie.current?.focus(),be(!1)}}})}))})})})})),{sizes:constants.SIZES,displayName:"Dropdown"});exports.COMPONENT_NAME="Dropdown",exports.Dropdown=Dropdown;
|
|
1
|
+
'use strict';var React=require('react');var nanoid=require('nanoid');var withMergedProps=require('../../hocs/withMergedProps.js');var useScrollMonitor=require('../../hooks/useScrollMonitor.js');var dom=require('../../shared/utils/dom.js');var misc=require('../../shared/utils/misc.js');var constants=require('../../shared/constants.js');var DropdownMenu=require('./DropdownMenu.js');var hooks=require('./hooks.js');var sizes=require('./sizes.js');var utils=require('./utils.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var FormInputLabel=require('../FormInputLabel/FormInputLabel.js');var FormInput=require('../FormInput/FormInput.js');var Chip=require('../Chip/Chip.js');var IconButton=require('../IconButton/IconButton.js');var MenuList=require('../MenuList/MenuList.js');var ListItem=require('../ListItem/ListItem.js');var InputCheckbox=require('../InputCheckbox/InputCheckbox.js');var MenuDivider=require('../MenuDivider/MenuDivider.js');const Dropdown=withMergedProps.withMergedProps(React.forwardRef(((e,o)=>{const{size:t="m",name:n="fox-dropdown",labelPosition:s="dynamic",searchable:r=!0,primary:a=!0,optionsMultiToggle:i=!0,iconProps:l={},menuProps:c={},loadingIconProps:u={},optionsEmptyIconProps:d={},loading:p,autoFocus:b,disableAutoScrollToSelectedOption:m,closeMenuOnScroll:g,scrollMonitorTarget:v,contrast:x,selectedOption:f,defaultSelectedOption:k,icon:C,inputMode:h,loadingMessage:I,loadingIcon:R,maxLength:j,multiple:y,clearable:w,onChangeInput:D,onCloseMenu:M,onOpenMenu:S,onSelectOption:P,options:L,loadOptions:z,groupSelectedOptions:E,optionsMultiToggleCaption:B,optionsEmptyMessage:T,optionsEmptyIcon:F,palette:q,placeholder:O,readOnly:K,required:X,status:H,sizeXXS:N,sizeXS:Z,sizeS:_,sizeM:A,sizeL:$,sizeXL:U,form:G,...J}=e;const Q={size:t,sizeXXS:N,sizeXS:Z,sizeS:_,sizeM:A,sizeL:$,sizeXL:U};const V={sizes:sizes.SIZES_ICON,color:J.disabled?'content-disabled':'content-onmain-tertiary'};const W=React.useMemo((()=>J.id??`${n}-${nanoid.nanoid()}`),[n,J.id]);const Y=React.useMemo((()=>nanoid.nanoid()),[]);const ee=React.useMemo((()=>nanoid.nanoid()),[]);const[oe,te]=hooks.useFilteredOptions({options:L});const[ne,se,re]=hooks.useLoadedOptions({loadOptions:z,options:L});const[ae,ie]=React.useState((()=>utils.getDropdownSelectedOption(f!==void 0?f:k,y)));const[le,ce]=React.useState((()=>utils.getDropdownInputText(ae,y)));const[ue,de]=React.useState(!1);const[pe,be]=React.useState(!1);const me=z?ne:oe;const ge=z?p??se:p;const ve=React.useMemo((()=>y?utils.groupDropdownOptions(me,ae):[[],[]]),[y,me,ae]);const xe=pe&&!J.disabled;const fe=X&&ae.length===0;const ke=Boolean(xe||le||ue);const Ce=ve[0].length>0&&ve[1].length===0;const he=ve[0].length>0&&ve[1].length>0;const Ie=React.useRef(null);const[Re,je]=React.useState(null);const ye=React.useRef(null);const we=React.useRef(null);const De=React.useRef(xe);const Me=React.useCallback((e=>{ce(e),D&&D(e)}),[D]);const Se=React.useCallback((e=>{z?re(e):te(e)}),[z,re,te]);const Pe=React.useMemo((()=>misc.createDebouncedCallback(Se,150)),[Se]);const preventBlur=e=>{e.target!==Ie.current&&e.target instanceof Node&&(e.currentTarget.contains(e.target)||c.renderInPortal&&xe&&Re&&Re.contains(e.target))&&e.preventDefault()};return useScrollMonitor.useScrollMonitor({target:v,onScrollStart:()=>{g&&xe&&(Ie.current?.focus(),be(!1))}}),React.useLayoutEffect((()=>{f!==void 0&&(y||xe||Me(utils.getDropdownInputText(f)),ie(utils.getDropdownSelectedOption(f,y)))}),[y,f,xe,Me]),React.useEffect((()=>{xe!==De.current&&(xe&&S&&S(),!xe&&M&&M(),De.current=xe)}),[xe,M,S]),React.useEffect((()=>{if(!y&&!m&&xe&&!ge&&le.length===0&&Re&&we.current){const e=Re.getBoundingClientRect();const o=we.current.getBoundingClientRect();(o.top<e.top||o.bottom>e.bottom)&&setTimeout((()=>{Re&&we.current&&Re.scrollTo(0,we.current.offsetTop)}),0)}}),[y,m,xe,ge,le,Re]),jsxRuntime.jsx(FormInputLabel.FormInputLabel,{...J,...Q,ref:o,id:W,labelId:Y,labelPosition:s,active:ke,onColored:x,primary:a,error:H==='error',success:H==='success',focus:ue,icon:[C,jsxRuntime.jsx(style.ChevronIcon,{up:xe},'chevron')],iconProps:{...Q,...V,...l},palette:{color:J.disabled?q.labelColorDisabled:q.labelColor,backgroundColor:J.disabled?q.backgroundColorDisabled:q.backgroundColor,backgroundColorHover:J.disabled?q.backgroundColorDisabled:q.backgroundColorHover,borderColor:J.disabled?q.borderColorDisabled:q.borderColor},onClick:e=>{J.onClick&&J.onClick(e),J.disabled||(Ie.current?.focus(),xe?Re&&e.target instanceof Node&&!Re.contains(e.target)&&(be(!1),Me(utils.getDropdownInputText(ae,y))):(be(!0),Se(''),r&&Me('')))},onPointerDown:e=>{J.onPointerDown&&J.onPointerDown(e),preventBlur(e)},onMouseDown:e=>{J.onMouseDown&&J.onMouseDown(e),window.PointerEvent||preventBlur(e)},onFocus:e=>{J.onFocus&&J.onFocus(e),de(!0),Ie.current&&e.target===Ie.current&&r&&!y&&!xe&&Me('')},onBlur:e=>{J.onBlur&&J.onBlur(e),e.currentTarget.contains(e.relatedTarget)||c.renderInPortal&&xe&&Re&&Re.contains(e.relatedTarget)||(de(!1),Me(utils.getDropdownInputText(ae,y)),be(!1))},input:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!fe||r||K?null:jsxRuntime.jsx(style.InputMimic,{required:!0,type:"text",inputMode:"none",form:G,tabIndex:-1,onFocus:()=>{Ie.current?.focus()}}),jsxRuntime.jsx(FormInput.FormInput,{ref:Ie,role:"combobox","aria-controls":ee,"aria-expanded":xe,"aria-labelledby":J.label?Y:void 0,type:"text",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",form:G,autoFocus:b,inputMode:r?h:'none',maxLength:j,placeholder:O,readOnly:K||!r,required:fe,disabled:J.disabled,value:le,palette:{color:q.color,colorDisabled:q.colorDisabled,placeholderColor:q.placeholderColor,placeholderColorDisabled:q.placeholderColorDisabled},onClick:e=>{xe&&e.currentTarget.selectionStart!==e.currentTarget.selectionEnd&&e.stopPropagation()},onChange:e=>{const o=e.currentTarget.value;Me(o),Pe(o),be(!0)},onKeyDown:e=>{if(constants.keyboardKeys.Enter.validate(e.key)&&(Me(utils.getDropdownInputText(ae,y)),be(!1)),!constants.keyboardKeys.Space.validate(e.key)||xe&&e.currentTarget.selectionStart!==0||(e.preventDefault(),xe||(Se(''),r&&Me('')),be((e=>!e))),constants.keyboardKeys.Esc.validate(e.key)&&be(!1),constants.keyboardKeys.Tab.validate(e.key)&&xe&&(e.preventDefault(),be(!1)),constants.keyboardKeys.ArrowDown.validate(e.key)&&xe&&ye.current)if(e.preventDefault(),!y&&we.current){const e=[...ye.current.children];const o=e.findIndex((e=>e.contains(we.current)));const t=e[o+1]??e[0];t instanceof HTMLElement&&dom.focusFirstFocusable(t)}else dom.focusFirstFocusable(ye.current);if(constants.keyboardKeys.ArrowUp.validate(e.key)&&xe&&ye.current)if(e.preventDefault(),!y&&we.current){const e=[...ye.current.children];const o=e.findIndex((e=>e.contains(we.current)));const t=e[o-1]??e[e.length-1];t instanceof HTMLElement&&dom.focusFirstFocusable(t)}else dom.focusLastFocusable(ye.current)}}),ae.map((e=>jsxRuntime.jsx("input",{type:"hidden",name:n,value:e.value,form:G,disabled:J.disabled||e.disabled},e.value)))]}),addon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[y&&ae.length>0?jsxRuntime.jsx(Chip.Chip,{size:"xs",active:!0,black:!0,marginLeft:12,disabled:J.disabled,cursor:J.disabled?'not-allowed':void 0,text:ae.length,textProps:{appearance:'caption',size:'xs'},palette:J.disabled?{color:'content-disabled',colorHover:'content-disabled',backgroundColor:'bg-disabled-small',backgroundColorHover:'bg-disabled-small'}:void 0,onPointerDown:e=>{e.preventDefault()},onMouseDown:e=>{window.PointerEvent||e.preventDefault()},discardButtonProps:{square:!0,contrast:!J.disabled,onClick:e=>{e.stopPropagation(),K||(f===void 0&&ie([]),P&&P([]),Ie.current?.focus(),Me(''),Se(''),be(!0))}}}):null,!y&&w&&ae.length>0?jsxRuntime.jsx(IconButton.IconButton,{icon:"close",size:"l",square:!0,marginLeft:12,disabled:J.disabled,onClick:e=>{e.stopPropagation(),K||(f===void 0&&ie([]),P&&P(null),Ie.current?.focus(),Me(''),Se(''),be(!0))}}):null]}),dropdown:jsxRuntime.jsx(DropdownMenu.DropdownMenu,{...c,setRef:je,open:xe,popperReferenceId:W,secondary:!x,elevated:x,disableAutoFocus:!0,palette:{backgroundColor:q.menuBackgroundColor,borderColor:q.menuBorderColor},empty:me.length===0,loading:ge,loadingMessage:I,loadingIcon:R,loadingIconProps:{...Q,...V,...u},emptyMessage:T,emptyIcon:F,emptyIconProps:{...Q,...V,...d},onKeyDown:e=>{constants.keyboardKeys.Tab.validate(e.key)&&(e.preventDefault(),Ie.current?.focus(),be(!1)),constants.keyboardKeys.Enter.validate(e.key)&&(Ie.current?.focus(),Me(utils.getDropdownInputText(ae,y)),be(!1)),constants.keyboardKeys.Esc.validate(e.key)&&(Ie.current?.focus(),be(!1)),constants.keyboardKeys.Backspace.validate(e.key)&&!K&&(y||!y&&w)&&(f===void 0&&ie([]),P&&P(y?[]:null),Me(''),Se(''))},children:jsxRuntime.jsx(MenuList.MenuList,y?{ref:ye,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,"aria-multiselectable":!0,children:le.length===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i?jsxRuntime.jsx(ListItem.ListItem,{...Q,text:B,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:sizes.SIZES_CHECKBOX,form:"none",name:n,checked:Ce,indeterminate:he,error:Boolean((Ce||he)&&H==='error'),success:Boolean((Ce||he)&&H==='success'),onChange:()=>{if(!K){const e=Ce||he?ae.filter((e=>e.disabled)):me.filter((e=>!e.disabled));f===void 0&&ie(e),P&&P(e)}}})}):null,i?jsxRuntime.jsx(MenuDivider.MenuDivider,{}):null,E?ve[0].map((e=>{const o=e.status??H;const t=o==='error';const s=o==='success';return React.createElement(ListItem.ListItem,{...Q,key:e.value,active:!0,text:e.text,danger:t,success:s,disabled:J.disabled||e.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),Ie.current?.focus()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:sizes.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!0,name:n,value:e.value,checked:!0,error:t,success:s,onChange:e=>{if(!K){const o=ae.filter((o=>o.value!==e.currentTarget.value));f===void 0&&ie(o),P&&P(o)}}})})})):null,E&&ve[0].length>0&&ve[1].length>0?jsxRuntime.jsx(MenuDivider.MenuDivider,{}):null,E?ve[1].map((e=>React.createElement(ListItem.ListItem,{...Q,key:e.value,text:e.text,disabled:J.disabled||e.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),Ie.current?.focus()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:sizes.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!1,name:n,value:e.value,checked:!1,onChange:()=>{if(!K){const o=[...ae,e];f===void 0&&ie(o),P&&P(o)}}})}))):null,!E&&me.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??H;const s=o&&t==='error';const r=o&&t==='success';return React.createElement(ListItem.ListItem,{...Q,key:e.value,text:e.text,danger:s,success:r,disabled:J.disabled||e.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:sizes.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:n,value:e.value,checked:o,error:s,success:r,onChange:t=>{if(!K){const n=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];f===void 0&&ie(n),P&&P(n)}}})})}))]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:me.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??H;const s=o&&t==='error';const r=o&&t==='success';return React.createElement(ListItem.ListItem,{...Q,key:e.value,text:e.text,danger:s,success:r,disabled:J.disabled||e.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsxRuntime.jsx(InputCheckbox.InputCheckbox,{sizes:sizes.SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:n,value:e.value,checked:o,error:s,success:r,onChange:t=>{if(!K){const n=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];f===void 0&&ie(n),P&&P(n)}}})})}))})}:{ref:ye,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,children:me.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;return React.createElement(ListItem.ListItem,{...Q,role:"option","aria-selected":o,ref:o?we:void 0,key:e.value,text:e.text,active:o,danger:Boolean(o&&H==='error'),success:Boolean(o&&H==='success'),disabled:J.disabled||e.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:o=>{if(o.stopPropagation(),!K){const o={...e};f===void 0&&(Me(utils.getDropdownInputText(o)),ie(utils.getDropdownSelectedOption(o))),P&&P(o),Ie.current?.focus(),be(!1)}}})}))})})})})),{sizes:sizes.SIZES,displayName:"Dropdown"});exports.COMPONENT_NAME="Dropdown",exports.Dropdown=Dropdown;
|
|
2
2
|
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from 'react'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { focusFirstFocusable, focusLastFocusable } from 'shared/utils/dom'\nimport { createDebouncedCallback } from 'shared/utils/misc'\nimport { keyboardKeys } from 'shared/constants'\nimport type { Nullable } from 'shared/types'\nimport { FormInput } from 'components/FormInput'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { MenuList } from 'components/MenuList'\nimport { MenuDivider } from 'components/MenuDivider'\nimport { ListItem } from 'components/ListItem'\nimport { InputCheckbox } from 'components/InputCheckbox'\nimport { Chip } from 'components/Chip'\nimport { IconButton } from 'components/IconButton'\nimport type { IconProps } from 'components/Icon'\nimport { DropdownMenu } from './DropdownMenu'\nimport { useFilteredOptions, useLoadedOptions } from './hooks'\nimport { SIZES, SIZES_CHECKBOX, SIZES_ICON } from './constants'\nimport { getDropdownInputText, getDropdownSelectedOption, groupDropdownOptions } from './utils'\nimport * as Styled from './style'\nimport type { DropdownProps, DropdownOption } from './types'\n\nconst COMPONENT_NAME = 'Dropdown'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Dropdown/types.ts).\n */\nconst Dropdown: React.ForwardRefExoticComponent<DropdownProps> = withMergedProps<DropdownProps, HTMLDivElement>(\n forwardRef<HTMLDivElement, MergedProps<DropdownProps>>((props, ref) => {\n const {\n size = 'm',\n name = 'fox-dropdown',\n labelPosition = 'dynamic',\n searchable = true,\n primary = true,\n optionsMultiToggle = true,\n iconProps = {},\n menuProps = {},\n loadingIconProps = {},\n optionsEmptyIconProps = {},\n loading,\n autoFocus,\n disableAutoScrollToSelectedOption,\n closeMenuOnScroll,\n scrollMonitorTarget,\n contrast,\n selectedOption,\n defaultSelectedOption,\n icon,\n inputMode,\n loadingMessage,\n loadingIcon,\n maxLength,\n multiple,\n clearable,\n onChangeInput,\n onCloseMenu,\n onOpenMenu,\n onSelectOption,\n options,\n loadOptions,\n groupSelectedOptions,\n optionsMultiToggleCaption,\n optionsEmptyMessage,\n optionsEmptyIcon,\n palette,\n placeholder,\n readOnly,\n required,\n status,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n form,\n ...rootProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const iconBaseProps: IconProps = {\n sizes: SIZES_ICON,\n color: rootProps.disabled ? 'content-disabled' : 'content-onmain-tertiary',\n }\n\n const formInputLabelId = useMemo(() => rootProps.id ?? `${name}-${nanoid()}`, [name, rootProps.id])\n const inputLabelId = useMemo(() => nanoid(), [])\n const menuListId = useMemo(() => nanoid(), [])\n\n const [filteredOptions, getFilteredOptions] = useFilteredOptions({\n options,\n })\n\n const [loadedOptions, optionsLoading, getLoadedOptions] = useLoadedOptions({\n loadOptions,\n options,\n })\n\n const [dropdownSelectedOption, setDropdownSelectedOption] = useState<DropdownOption[]>(() =>\n getDropdownSelectedOption(selectedOption !== undefined ? selectedOption : defaultSelectedOption, multiple)\n )\n\n const [inputText, setInputText] = useState<string>(() => getDropdownInputText(dropdownSelectedOption, multiple))\n\n const [focusWithin, setFocusWithin] = useState<boolean>(false)\n\n const [menuOpenRequest, setMenuOpenRequest] = useState<boolean>(false)\n\n const menuOptions: DropdownOption[] = loadOptions ? loadedOptions : filteredOptions\n const menuOptionsLoading = loadOptions ? (loading ?? optionsLoading) : loading\n\n const menuOptionsGroups: ReturnType<typeof groupDropdownOptions> = useMemo(\n () => (multiple ? groupDropdownOptions(menuOptions, dropdownSelectedOption) : [[], []]),\n [multiple, menuOptions, dropdownSelectedOption]\n )\n\n const menuOpen = menuOpenRequest && !rootProps.disabled\n\n const inputRequired = required && dropdownSelectedOption.length === 0\n const inputActive = Boolean(menuOpen || inputText || focusWithin)\n\n const multiToggleChecked = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length === 0\n const multiToggleIndeterminate = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0\n\n const inputRef = useRef<HTMLInputElement>(null)\n const [menuRef, setMenuRef] = useState<Nullable<HTMLElement>>(null)\n const menuListRef = useRef<HTMLUListElement>(null)\n const selectedOptionRef = useRef<HTMLElement>(null)\n const menuOpenPrevRef = useRef<boolean>(menuOpen)\n\n const updateInputText = useCallback(\n (inputTextValue: string) => {\n setInputText(inputTextValue)\n\n if (onChangeInput) {\n onChangeInput(inputTextValue)\n }\n },\n [onChangeInput]\n )\n\n const updateOptions = useCallback(\n (inputTextValue: string) => {\n if (loadOptions) {\n getLoadedOptions(inputTextValue)\n } else {\n getFilteredOptions(inputTextValue)\n }\n },\n [loadOptions, getLoadedOptions, getFilteredOptions]\n )\n\n const updateOptionsDebounced = useMemo(() => {\n return createDebouncedCallback(updateOptions, 150)\n }, [updateOptions])\n\n const preventBlur = (evt: React.PointerEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (\n evt.target !== inputRef.current &&\n evt.target instanceof Node &&\n (evt.currentTarget.contains(evt.target) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.target)))\n ) {\n evt.preventDefault()\n }\n }\n\n useScrollMonitor({\n target: scrollMonitorTarget,\n onScrollStart: () => {\n if (closeMenuOnScroll && menuOpen) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n },\n })\n\n useLayoutEffect(() => {\n if (selectedOption === undefined) return\n\n if (!multiple && !menuOpen) {\n updateInputText(getDropdownInputText(selectedOption))\n }\n setDropdownSelectedOption(getDropdownSelectedOption(selectedOption, multiple))\n }, [multiple, selectedOption, menuOpen, updateInputText])\n\n useEffect(() => {\n if (menuOpen === menuOpenPrevRef.current) return\n\n if (menuOpen && onOpenMenu) onOpenMenu()\n if (!menuOpen && onCloseMenu) onCloseMenu()\n\n menuOpenPrevRef.current = menuOpen\n }, [menuOpen, onCloseMenu, onOpenMenu])\n\n useEffect(() => {\n if (\n !multiple &&\n !disableAutoScrollToSelectedOption &&\n menuOpen &&\n !menuOptionsLoading &&\n inputText.length === 0 &&\n menuRef &&\n selectedOptionRef.current\n ) {\n const menuRect = menuRef.getBoundingClientRect()\n const selectedOptionRect = selectedOptionRef.current.getBoundingClientRect()\n\n if (selectedOptionRect.top < menuRect.top || selectedOptionRect.bottom > menuRect.bottom) {\n setTimeout(() => {\n if (menuRef && selectedOptionRef.current) {\n menuRef.scrollTo(0, selectedOptionRef.current.offsetTop)\n }\n }, 0)\n }\n }\n }, [multiple, disableAutoScrollToSelectedOption, menuOpen, menuOptionsLoading, inputText, menuRef])\n\n return (\n <FormInputLabel\n {...rootProps}\n {...sizeProps}\n ref={ref}\n id={formInputLabelId}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n active={inputActive}\n onColored={contrast}\n primary={primary}\n error={status === 'error'}\n success={status === 'success'}\n focus={focusWithin}\n icon={[icon, <Styled.ChevronIcon key='chevron' up={menuOpen} />]}\n iconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...iconProps,\n }}\n palette={{\n color: rootProps.disabled ? palette.labelColorDisabled : palette.labelColor,\n backgroundColor: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: rootProps.disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={(evt) => {\n if (rootProps.onClick) rootProps.onClick(evt)\n\n if (rootProps.disabled) return\n\n inputRef.current?.focus()\n\n if (!menuOpen) {\n setMenuOpenRequest(true)\n\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n } else if (menuRef && evt.target instanceof Node && !menuRef.contains(evt.target)) {\n setMenuOpenRequest(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n }\n }}\n onPointerDown={(evt) => {\n if (rootProps.onPointerDown) rootProps.onPointerDown(evt)\n\n preventBlur(evt)\n }}\n onMouseDown={(evt) => {\n if (rootProps.onMouseDown) rootProps.onMouseDown(evt)\n\n if (!window.PointerEvent) preventBlur(evt)\n }}\n onFocus={(evt) => {\n if (rootProps.onFocus) rootProps.onFocus(evt)\n\n setFocusWithin(true)\n\n if (inputRef.current && evt.target === inputRef.current && searchable && !multiple && !menuOpen) {\n updateInputText('')\n }\n }}\n onBlur={(evt) => {\n if (rootProps.onBlur) rootProps.onBlur(evt)\n\n if (\n evt.currentTarget.contains(evt.relatedTarget) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.relatedTarget))\n ) {\n return\n }\n\n setFocusWithin(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }}\n input={\n <>\n {inputRequired && !searchable && !readOnly ? (\n <Styled.InputMimic\n required\n type='text'\n inputMode='none'\n form={form}\n tabIndex={-1}\n onFocus={() => {\n inputRef.current?.focus()\n }}\n />\n ) : null}\n <FormInput\n ref={inputRef}\n role='combobox'\n aria-controls={menuListId}\n aria-expanded={menuOpen}\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n type='text'\n autoComplete='off'\n autoCapitalize='off'\n autoCorrect='off'\n spellCheck='false'\n form={form}\n autoFocus={autoFocus}\n inputMode={searchable ? inputMode : 'none'}\n maxLength={maxLength}\n placeholder={placeholder}\n readOnly={readOnly || !searchable}\n required={inputRequired}\n disabled={rootProps.disabled}\n value={inputText}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n onClick={(evt) => {\n if (menuOpen && evt.currentTarget.selectionStart !== evt.currentTarget.selectionEnd) {\n evt.stopPropagation()\n }\n }}\n onChange={(evt) => {\n const inputValue = evt.currentTarget.value\n\n updateInputText(inputValue)\n updateOptionsDebounced(inputValue)\n setMenuOpenRequest(true)\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Enter.validate(evt.key)) {\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Space.validate(evt.key) && (!menuOpen || evt.currentTarget.selectionStart === 0)) {\n evt.preventDefault()\n\n if (!menuOpen) {\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n }\n\n setMenuOpenRequest((prev) => !prev)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Tab.validate(evt.key) && menuOpen) {\n evt.preventDefault()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.ArrowDown.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx + 1] ?? menuItems[0]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusFirstFocusable(menuListRef.current)\n }\n }\n\n if (keyboardKeys.ArrowUp.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx - 1] ?? menuItems[menuItems.length - 1]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusLastFocusable(menuListRef.current)\n }\n }\n }}\n />\n {dropdownSelectedOption.map((item) => (\n <input\n key={item.value}\n type='hidden'\n name={name}\n value={item.value}\n form={form}\n disabled={rootProps.disabled}\n />\n ))}\n </>\n }\n addon={\n <>\n {multiple && dropdownSelectedOption.length > 0 ? (\n <Chip\n size='xs'\n active\n black\n marginLeft={12}\n disabled={rootProps.disabled}\n cursor={rootProps.disabled ? 'not-allowed' : undefined}\n text={dropdownSelectedOption.length}\n textProps={{\n appearance: 'caption',\n size: 'xs',\n }}\n palette={\n rootProps.disabled\n ? {\n color: 'content-disabled',\n colorHover: 'content-disabled',\n backgroundColor: 'bg-disabled-small',\n backgroundColorHover: 'bg-disabled-small',\n }\n : undefined\n }\n onPointerDown={(evt) => {\n evt.preventDefault()\n }}\n onMouseDown={(evt) => {\n if (!window.PointerEvent) evt.preventDefault()\n }}\n discardButtonProps={{\n square: true,\n contrast: !rootProps.disabled,\n onClick: (evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption([])\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n },\n }}\n />\n ) : null}\n {!multiple && clearable && dropdownSelectedOption.length > 0 ? (\n <IconButton\n icon='close'\n size='l'\n square\n marginLeft={12}\n disabled={rootProps.disabled}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(null)\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n }}\n />\n ) : null}\n </>\n }\n dropdown={\n <DropdownMenu\n {...menuProps}\n setRef={setMenuRef}\n open={menuOpen}\n popperReferenceId={formInputLabelId}\n secondary={!contrast}\n elevated={contrast}\n disableAutoFocus\n palette={{\n backgroundColor: palette.menuBackgroundColor,\n borderColor: palette.menuBorderColor,\n }}\n empty={menuOptions.length === 0}\n loading={menuOptionsLoading}\n loadingMessage={loadingMessage}\n loadingIcon={loadingIcon}\n loadingIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...loadingIconProps,\n }}\n emptyMessage={optionsEmptyMessage}\n emptyIcon={optionsEmptyIcon}\n emptyIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...optionsEmptyIconProps,\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Tab.validate(evt.key)) {\n evt.preventDefault()\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Enter.validate(evt.key)) {\n inputRef.current?.focus()\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Backspace.validate(evt.key) && !readOnly && (multiple || (!multiple && clearable))) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(multiple ? [] : null)\n\n updateInputText('')\n updateOptions('')\n }\n }}\n >\n {multiple ? (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n aria-multiselectable\n >\n {inputText.length === 0 ? (\n <>\n {optionsMultiToggle ? (\n <ListItem\n {...sizeProps}\n text={optionsMultiToggleCaption}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n name={name}\n checked={multiToggleChecked}\n indeterminate={multiToggleIndeterminate}\n error={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'error')}\n success={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'success')}\n onChange={() => {\n if (!readOnly) {\n const update = multiToggleChecked || multiToggleIndeterminate ? [] : [...menuOptions]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ) : null}\n {optionsMultiToggle ? <MenuDivider /> : null}\n {groupSelectedOptions\n ? menuOptionsGroups[0].map((option) => {\n const optionStatus = option.status ?? status\n const optionErrorStatus = optionStatus === 'error'\n const optionSuccessStatus = optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n active\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected\n name={name}\n value={option.value}\n checked\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = dropdownSelectedOption.filter(\n (item) => item.value !== evt.currentTarget.value\n )\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })\n : null}\n {groupSelectedOptions && menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0 ? (\n <MenuDivider />\n ) : null}\n {groupSelectedOptions\n ? menuOptionsGroups[1].map((option) => (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={false}\n name={name}\n value={option.value}\n checked={false}\n onChange={() => {\n if (!readOnly) {\n const update = [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ))\n : null}\n {!groupSelectedOptions &&\n menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n ) : (\n <>\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n )}\n </MenuList>\n ) : (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n >\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n return (\n <ListItem\n {...sizeProps}\n role='option'\n aria-selected={selected}\n ref={selected ? selectedOptionRef : undefined}\n key={option.value}\n text={option.text}\n active={selected}\n danger={Boolean(selected && status === 'error')}\n success={Boolean(selected && status === 'success')}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n const update = { ...option }\n\n if (selectedOption === undefined) {\n updateInputText(getDropdownInputText(update))\n setDropdownSelectedOption(getDropdownSelectedOption(update))\n }\n\n if (onSelectOption) onSelectOption(update)\n\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n }}\n />\n )\n })}\n </MenuList>\n )}\n </DropdownMenu>\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { Dropdown, COMPONENT_NAME }\n"],"names":["Dropdown","withMergedProps","forwardRef","props","ref","size","name","labelPosition","searchable","primary","optionsMultiToggle","iconProps","menuProps","loadingIconProps","optionsEmptyIconProps","loading","autoFocus","disableAutoScrollToSelectedOption","closeMenuOnScroll","scrollMonitorTarget","contrast","selectedOption","defaultSelectedOption","icon","inputMode","loadingMessage","loadingIcon","maxLength","multiple","clearable","onChangeInput","onCloseMenu","onOpenMenu","onSelectOption","options","loadOptions","groupSelectedOptions","optionsMultiToggleCaption","optionsEmptyMessage","optionsEmptyIcon","palette","placeholder","readOnly","required","status","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","form","rootProps","sizeProps","iconBaseProps","sizes","SIZES_ICON","color","disabled","formInputLabelId","useMemo","id","nanoid","inputLabelId","menuListId","filteredOptions","getFilteredOptions","useFilteredOptions","loadedOptions","optionsLoading","getLoadedOptions","useLoadedOptions","dropdownSelectedOption","setDropdownSelectedOption","useState","getDropdownSelectedOption","undefined","inputText","setInputText","getDropdownInputText","focusWithin","setFocusWithin","menuOpenRequest","setMenuOpenRequest","menuOptions","menuOptionsLoading","menuOptionsGroups","groupDropdownOptions","menuOpen","inputRequired","length","inputActive","Boolean","multiToggleChecked","multiToggleIndeterminate","inputRef","useRef","menuRef","setMenuRef","menuListRef","selectedOptionRef","menuOpenPrevRef","updateInputText","useCallback","inputTextValue","updateOptions","updateOptionsDebounced","createDebouncedCallback","preventBlur","evt","target","current","Node","currentTarget","contains","renderInPortal","preventDefault","useScrollMonitor","onScrollStart","focus","useLayoutEffect","useEffect","menuRect","getBoundingClientRect","selectedOptionRect","top","bottom","setTimeout","scrollTo","offsetTop","_jsx","FormInputLabel","labelId","active","onColored","error","success","jsx","Styled","up","labelColorDisabled","labelColor","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","onPointerDown","onMouseDown","window","PointerEvent","onFocus","onBlur","relatedTarget","input","_jsxs","jsxs","_Fragment","children","type","tabIndex","FormInput","role","label","autoComplete","autoCapitalize","autoCorrect","spellCheck","value","colorDisabled","placeholderColor","placeholderColorDisabled","selectionStart","selectionEnd","stopPropagation","onChange","inputValue","onKeyDown","keyboardKeys","Enter","validate","key","Space","prev","Esc","Tab","ArrowDown","menuItems","idx","findIndex","item","focusTarget","HTMLElement","focusFirstFocusable","ArrowUp","focusLastFocusable","map","addon","Chip","black","marginLeft","cursor","text","textProps","appearance","colorHover","discardButtonProps","square","IconButton","dropdown","DropdownMenu","setRef","open","popperReferenceId","secondary","elevated","disableAutoFocus","menuBackgroundColor","menuBorderColor","empty","emptyMessage","emptyIcon","emptyIconProps","Backspace","MenuList","ListItem","borderRadius","ellipsis","wordBreak","control","InputCheckbox","SIZES_CHECKBOX","checked","indeterminate","update","MenuDivider","option","optionStatus","optionErrorStatus","optionSuccessStatus","_createElement","danger","filter","selected","SIZES","displayName"],"mappings":"49BAqCMA,MAAAA,SAA2DC,gBAAAA,gBAC/DC,MAAAA,YAAuD,CAACC,EAAOC,KAC7D,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,eAAcC,cACrBA,EAAgB,UAASC,WACzBA,GAAa,EAAIC,QACjBA,GAAU,EAAIC,mBACdA,GAAqB,EAAIC,UACzBA,EAAY,CAAE,EAAAC,UACdA,EAAY,CAAE,EAAAC,iBACdA,EAAmB,CAAE,EAAAC,sBACrBA,EAAwB,CAAE,EAAAC,QAC1BA,EAAOC,UACPA,EAASC,kCACTA,EAAiCC,kBACjCA,EAAiBC,oBACjBA,EAAmBC,SACnBA,EAAQC,eACRA,EAAcC,sBACdA,EAAqBC,KACrBA,EAAIC,UACJA,EAASC,eACTA,EAAcC,YACdA,EAAWC,UACXA,EAASC,SACTA,EAAQC,UACRA,EAASC,cACTA,EAAaC,YACbA,EAAWC,WACXA,EAAUC,eACVA,EAAcC,QACdA,EAAOC,YACPA,EAAWC,qBACXA,EAAoBC,0BACpBA,EAAyBC,oBACzBA,EAAmBC,iBACnBA,EAAgBC,QAChBA,EAAOC,YACPA,EAAWC,SACXA,EAAQC,SACRA,EAAQC,OACRA,EAAMC,QACNA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,KACNA,KACGC,GACDj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,IAAIjG,GAAwBqK,GAE5BxN,SAAmBuD,GACrBH,GAA0BkK,GAGxB1M,GAAgBA,EAAe0M,EACrC,MAIN,OAOH,CACPvO,IAAK+F,GACLtC,GAAIG,GACJmG,KAAK,UACL,kBAAiB/G,EAAUgH,MAAQrG,OAAea,EAAUmF,SAE3D3E,GAAYiH,KAAKwC,IAChB,MAAMO,EAAW5K,GAAuBsH,WAAWC,GAASA,EAAKtB,QAAUoE,EAAOpE,WAAY,EAE9F,OACEwE,MAAAA,cAACf,SAAAA,SAAQ,IACH7K,EACJ8G,KAAK,SACL,gBAAeiF,EACfhP,IAAKgP,EAAWhJ,QAAoBxB,EACpC0G,IAAKuD,EAAOpE,MACZkC,KAAMkC,EAAOlC,KACbtE,OAAQ+G,EACRF,OAAQtJ,QAAQwJ,GAAYxM,IAAW,SACvC4F,QAAS5C,QAAQwJ,GAAYxM,IAAW,WACxCc,SAAUN,EAAUM,SACpByK,aAAc,EACdC,UAAU,EACVxB,UAAW,CAAEyB,UAAW,cACxBlF,QAAUtC,IAGR,GAFAA,EAAIkE,mBAECrI,EAAU,CACb,MAAMiM,EAAS,IAAKE,GAEhBxN,SAAmBuD,IACrB0B,GAAgBvB,MAAAA,qBAAqB4J,IACrClK,GAA0BE,MAAAA,0BAA0BgK,KAGlD1M,GAAgBA,EAAe0M,GAEnC5I,GAASgB,SAASQ,QAClBpC,IAAmB,EACrB,IAEF,SAOd,IAGN,CACE5B,MAAO8L,UAAKA,MACZC,YA91BmB,oCAAA"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from 'react'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { focusFirstFocusable, focusLastFocusable } from 'shared/utils/dom'\nimport { createDebouncedCallback } from 'shared/utils/misc'\nimport { keyboardKeys } from 'shared/constants'\nimport type { Nullable } from 'shared/types'\nimport { FormInput } from 'components/FormInput'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { MenuList } from 'components/MenuList'\nimport { MenuDivider } from 'components/MenuDivider'\nimport { ListItem } from 'components/ListItem'\nimport { InputCheckbox } from 'components/InputCheckbox'\nimport { Chip } from 'components/Chip'\nimport { IconButton } from 'components/IconButton'\nimport type { IconProps } from 'components/Icon'\nimport { DropdownMenu } from './DropdownMenu'\nimport { useFilteredOptions, useLoadedOptions } from './hooks'\nimport { SIZES, SIZES_CHECKBOX, SIZES_ICON } from './sizes'\nimport { getDropdownInputText, getDropdownSelectedOption, groupDropdownOptions } from './utils'\nimport * as Styled from './style'\nimport type { DropdownProps, DropdownOption } from './types'\n\nconst COMPONENT_NAME = 'Dropdown'\n\n/**\n *\n * Компонент для выбора одной или нескольких опций из числа доступных.\n *\n * Поддерживается \"ref\" и все нативные атрибуты \\<div\\> элемента.\n */\nconst Dropdown: React.ForwardRefExoticComponent<DropdownProps> = withMergedProps<DropdownProps, HTMLDivElement>(\n forwardRef<HTMLDivElement, MergedProps<DropdownProps>>((props, ref) => {\n const {\n size = 'm',\n name = 'fox-dropdown',\n labelPosition = 'dynamic',\n searchable = true,\n primary = true,\n optionsMultiToggle = true,\n iconProps = {},\n menuProps = {},\n loadingIconProps = {},\n optionsEmptyIconProps = {},\n loading,\n autoFocus,\n disableAutoScrollToSelectedOption,\n closeMenuOnScroll,\n scrollMonitorTarget,\n contrast,\n selectedOption,\n defaultSelectedOption,\n icon,\n inputMode,\n loadingMessage,\n loadingIcon,\n maxLength,\n multiple,\n clearable,\n onChangeInput,\n onCloseMenu,\n onOpenMenu,\n onSelectOption,\n options,\n loadOptions,\n groupSelectedOptions,\n optionsMultiToggleCaption,\n optionsEmptyMessage,\n optionsEmptyIcon,\n palette,\n placeholder,\n readOnly,\n required,\n status,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n form,\n ...rootProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const iconBaseProps: IconProps = {\n sizes: SIZES_ICON,\n color: rootProps.disabled ? 'content-disabled' : 'content-onmain-tertiary',\n }\n\n const formInputLabelId = useMemo(() => rootProps.id ?? `${name}-${nanoid()}`, [name, rootProps.id])\n const inputLabelId = useMemo(() => nanoid(), [])\n const menuListId = useMemo(() => nanoid(), [])\n\n const [filteredOptions, getFilteredOptions] = useFilteredOptions({\n options,\n })\n\n const [loadedOptions, optionsLoading, getLoadedOptions] = useLoadedOptions({\n loadOptions,\n options,\n })\n\n const [dropdownSelectedOption, setDropdownSelectedOption] = useState<DropdownOption[]>(() =>\n getDropdownSelectedOption(selectedOption !== undefined ? selectedOption : defaultSelectedOption, multiple)\n )\n\n const [inputText, setInputText] = useState<string>(() => getDropdownInputText(dropdownSelectedOption, multiple))\n\n const [focusWithin, setFocusWithin] = useState<boolean>(false)\n\n const [menuOpenRequest, setMenuOpenRequest] = useState<boolean>(false)\n\n const menuOptions: DropdownOption[] = loadOptions ? loadedOptions : filteredOptions\n const menuOptionsLoading = loadOptions ? (loading ?? optionsLoading) : loading\n\n const menuOptionsGroups: ReturnType<typeof groupDropdownOptions> = useMemo(\n () => (multiple ? groupDropdownOptions(menuOptions, dropdownSelectedOption) : [[], []]),\n [multiple, menuOptions, dropdownSelectedOption]\n )\n\n const menuOpen = menuOpenRequest && !rootProps.disabled\n\n const inputRequired = required && dropdownSelectedOption.length === 0\n const inputActive = Boolean(menuOpen || inputText || focusWithin)\n\n const multiToggleChecked = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length === 0\n const multiToggleIndeterminate = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0\n\n const inputRef = useRef<HTMLInputElement>(null)\n const [menuRef, setMenuRef] = useState<Nullable<HTMLElement>>(null)\n const menuListRef = useRef<HTMLUListElement>(null)\n const selectedOptionRef = useRef<HTMLElement>(null)\n const menuOpenPrevRef = useRef<boolean>(menuOpen)\n\n const updateInputText = useCallback(\n (inputTextValue: string) => {\n setInputText(inputTextValue)\n\n if (onChangeInput) {\n onChangeInput(inputTextValue)\n }\n },\n [onChangeInput]\n )\n\n const updateOptions = useCallback(\n (inputTextValue: string) => {\n if (loadOptions) {\n getLoadedOptions(inputTextValue)\n } else {\n getFilteredOptions(inputTextValue)\n }\n },\n [loadOptions, getLoadedOptions, getFilteredOptions]\n )\n\n const updateOptionsDebounced = useMemo(() => {\n return createDebouncedCallback(updateOptions, 150)\n }, [updateOptions])\n\n const preventBlur = (evt: React.PointerEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (\n evt.target !== inputRef.current &&\n evt.target instanceof Node &&\n (evt.currentTarget.contains(evt.target) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.target)))\n ) {\n evt.preventDefault()\n }\n }\n\n useScrollMonitor({\n target: scrollMonitorTarget,\n onScrollStart: () => {\n if (closeMenuOnScroll && menuOpen) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n },\n })\n\n useLayoutEffect(() => {\n if (selectedOption === undefined) return\n\n if (!multiple && !menuOpen) {\n updateInputText(getDropdownInputText(selectedOption))\n }\n setDropdownSelectedOption(getDropdownSelectedOption(selectedOption, multiple))\n }, [multiple, selectedOption, menuOpen, updateInputText])\n\n useEffect(() => {\n if (menuOpen === menuOpenPrevRef.current) return\n\n if (menuOpen && onOpenMenu) onOpenMenu()\n if (!menuOpen && onCloseMenu) onCloseMenu()\n\n menuOpenPrevRef.current = menuOpen\n }, [menuOpen, onCloseMenu, onOpenMenu])\n\n useEffect(() => {\n if (\n !multiple &&\n !disableAutoScrollToSelectedOption &&\n menuOpen &&\n !menuOptionsLoading &&\n inputText.length === 0 &&\n menuRef &&\n selectedOptionRef.current\n ) {\n const menuRect = menuRef.getBoundingClientRect()\n const selectedOptionRect = selectedOptionRef.current.getBoundingClientRect()\n\n if (selectedOptionRect.top < menuRect.top || selectedOptionRect.bottom > menuRect.bottom) {\n setTimeout(() => {\n if (menuRef && selectedOptionRef.current) {\n menuRef.scrollTo(0, selectedOptionRef.current.offsetTop)\n }\n }, 0)\n }\n }\n }, [multiple, disableAutoScrollToSelectedOption, menuOpen, menuOptionsLoading, inputText, menuRef])\n\n return (\n <FormInputLabel\n {...rootProps}\n {...sizeProps}\n ref={ref}\n id={formInputLabelId}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n active={inputActive}\n onColored={contrast}\n primary={primary}\n error={status === 'error'}\n success={status === 'success'}\n focus={focusWithin}\n icon={[icon, <Styled.ChevronIcon key='chevron' up={menuOpen} />]}\n iconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...iconProps,\n }}\n palette={{\n color: rootProps.disabled ? palette.labelColorDisabled : palette.labelColor,\n backgroundColor: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: rootProps.disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={(evt) => {\n if (rootProps.onClick) rootProps.onClick(evt)\n\n if (rootProps.disabled) return\n\n inputRef.current?.focus()\n\n if (!menuOpen) {\n setMenuOpenRequest(true)\n\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n } else if (menuRef && evt.target instanceof Node && !menuRef.contains(evt.target)) {\n setMenuOpenRequest(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n }\n }}\n onPointerDown={(evt) => {\n if (rootProps.onPointerDown) rootProps.onPointerDown(evt)\n\n preventBlur(evt)\n }}\n onMouseDown={(evt) => {\n if (rootProps.onMouseDown) rootProps.onMouseDown(evt)\n\n if (!window.PointerEvent) preventBlur(evt)\n }}\n onFocus={(evt) => {\n if (rootProps.onFocus) rootProps.onFocus(evt)\n\n setFocusWithin(true)\n\n if (inputRef.current && evt.target === inputRef.current && searchable && !multiple && !menuOpen) {\n updateInputText('')\n }\n }}\n onBlur={(evt) => {\n if (rootProps.onBlur) rootProps.onBlur(evt)\n\n if (\n evt.currentTarget.contains(evt.relatedTarget) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.relatedTarget))\n ) {\n return\n }\n\n setFocusWithin(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }}\n input={\n <>\n {inputRequired && !searchable && !readOnly ? (\n <Styled.InputMimic\n required\n type='text'\n inputMode='none'\n form={form}\n tabIndex={-1}\n onFocus={() => {\n inputRef.current?.focus()\n }}\n />\n ) : null}\n <FormInput\n ref={inputRef}\n role='combobox'\n aria-controls={menuListId}\n aria-expanded={menuOpen}\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n type='text'\n autoComplete='off'\n autoCapitalize='off'\n autoCorrect='off'\n spellCheck='false'\n form={form}\n autoFocus={autoFocus}\n inputMode={searchable ? inputMode : 'none'}\n maxLength={maxLength}\n placeholder={placeholder}\n readOnly={readOnly || !searchable}\n required={inputRequired}\n disabled={rootProps.disabled}\n value={inputText}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n onClick={(evt) => {\n if (menuOpen && evt.currentTarget.selectionStart !== evt.currentTarget.selectionEnd) {\n evt.stopPropagation()\n }\n }}\n onChange={(evt) => {\n const inputValue = evt.currentTarget.value\n\n updateInputText(inputValue)\n updateOptionsDebounced(inputValue)\n setMenuOpenRequest(true)\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Enter.validate(evt.key)) {\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Space.validate(evt.key) && (!menuOpen || evt.currentTarget.selectionStart === 0)) {\n evt.preventDefault()\n\n if (!menuOpen) {\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n }\n\n setMenuOpenRequest((prev) => !prev)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Tab.validate(evt.key) && menuOpen) {\n evt.preventDefault()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.ArrowDown.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx + 1] ?? menuItems[0]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusFirstFocusable(menuListRef.current)\n }\n }\n\n if (keyboardKeys.ArrowUp.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx - 1] ?? menuItems[menuItems.length - 1]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusLastFocusable(menuListRef.current)\n }\n }\n }}\n />\n {dropdownSelectedOption.map((option) => (\n <input\n key={option.value}\n type='hidden'\n name={name}\n value={option.value}\n form={form}\n disabled={rootProps.disabled || option.disabled}\n />\n ))}\n </>\n }\n addon={\n <>\n {multiple && dropdownSelectedOption.length > 0 ? (\n <Chip\n size='xs'\n active\n black\n marginLeft={12}\n disabled={rootProps.disabled}\n cursor={rootProps.disabled ? 'not-allowed' : undefined}\n text={dropdownSelectedOption.length}\n textProps={{\n appearance: 'caption',\n size: 'xs',\n }}\n palette={\n rootProps.disabled\n ? {\n color: 'content-disabled',\n colorHover: 'content-disabled',\n backgroundColor: 'bg-disabled-small',\n backgroundColorHover: 'bg-disabled-small',\n }\n : undefined\n }\n onPointerDown={(evt) => {\n evt.preventDefault()\n }}\n onMouseDown={(evt) => {\n if (!window.PointerEvent) evt.preventDefault()\n }}\n discardButtonProps={{\n square: true,\n contrast: !rootProps.disabled,\n onClick: (evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption([])\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n },\n }}\n />\n ) : null}\n {!multiple && clearable && dropdownSelectedOption.length > 0 ? (\n <IconButton\n icon='close'\n size='l'\n square\n marginLeft={12}\n disabled={rootProps.disabled}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(null)\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n }}\n />\n ) : null}\n </>\n }\n dropdown={\n <DropdownMenu\n {...menuProps}\n setRef={setMenuRef}\n open={menuOpen}\n popperReferenceId={formInputLabelId}\n secondary={!contrast}\n elevated={contrast}\n disableAutoFocus\n palette={{\n backgroundColor: palette.menuBackgroundColor,\n borderColor: palette.menuBorderColor,\n }}\n empty={menuOptions.length === 0}\n loading={menuOptionsLoading}\n loadingMessage={loadingMessage}\n loadingIcon={loadingIcon}\n loadingIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...loadingIconProps,\n }}\n emptyMessage={optionsEmptyMessage}\n emptyIcon={optionsEmptyIcon}\n emptyIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...optionsEmptyIconProps,\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Tab.validate(evt.key)) {\n evt.preventDefault()\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Enter.validate(evt.key)) {\n inputRef.current?.focus()\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Backspace.validate(evt.key) && !readOnly && (multiple || (!multiple && clearable))) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(multiple ? [] : null)\n\n updateInputText('')\n updateOptions('')\n }\n }}\n >\n {multiple ? (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n aria-multiselectable\n >\n {inputText.length === 0 ? (\n <>\n {optionsMultiToggle ? (\n <ListItem\n {...sizeProps}\n text={optionsMultiToggleCaption}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n name={name}\n checked={multiToggleChecked}\n indeterminate={multiToggleIndeterminate}\n error={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'error')}\n success={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'success')}\n onChange={() => {\n if (!readOnly) {\n const update =\n multiToggleChecked || multiToggleIndeterminate\n ? dropdownSelectedOption.filter((option) => option.disabled)\n : menuOptions.filter((option) => !option.disabled)\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ) : null}\n {optionsMultiToggle ? <MenuDivider /> : null}\n {groupSelectedOptions\n ? menuOptionsGroups[0].map((option) => {\n const optionStatus = option.status ?? status\n const optionErrorStatus = optionStatus === 'error'\n const optionSuccessStatus = optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n active\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled || option.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected\n name={name}\n value={option.value}\n checked\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = dropdownSelectedOption.filter(\n (item) => item.value !== evt.currentTarget.value\n )\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })\n : null}\n {groupSelectedOptions && menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0 ? (\n <MenuDivider />\n ) : null}\n {groupSelectedOptions\n ? menuOptionsGroups[1].map((option) => (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n disabled={rootProps.disabled || option.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={false}\n name={name}\n value={option.value}\n checked={false}\n onChange={() => {\n if (!readOnly) {\n const update = [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ))\n : null}\n {!groupSelectedOptions &&\n menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled || option.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n ) : (\n <>\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled || option.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n )}\n </MenuList>\n ) : (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n >\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n return (\n <ListItem\n {...sizeProps}\n role='option'\n aria-selected={selected}\n ref={selected ? selectedOptionRef : undefined}\n key={option.value}\n text={option.text}\n active={selected}\n danger={Boolean(selected && status === 'error')}\n success={Boolean(selected && status === 'success')}\n disabled={rootProps.disabled || option.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n const update = { ...option }\n\n if (selectedOption === undefined) {\n updateInputText(getDropdownInputText(update))\n setDropdownSelectedOption(getDropdownSelectedOption(update))\n }\n\n if (onSelectOption) onSelectOption(update)\n\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n }}\n />\n )\n })}\n </MenuList>\n )}\n </DropdownMenu>\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { Dropdown, COMPONENT_NAME }\n"],"names":["Dropdown","withMergedProps","forwardRef","props","ref","size","name","labelPosition","searchable","primary","optionsMultiToggle","iconProps","menuProps","loadingIconProps","optionsEmptyIconProps","loading","autoFocus","disableAutoScrollToSelectedOption","closeMenuOnScroll","scrollMonitorTarget","contrast","selectedOption","defaultSelectedOption","icon","inputMode","loadingMessage","loadingIcon","maxLength","multiple","clearable","onChangeInput","onCloseMenu","onOpenMenu","onSelectOption","options","loadOptions","groupSelectedOptions","optionsMultiToggleCaption","optionsEmptyMessage","optionsEmptyIcon","palette","placeholder","readOnly","required","status","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","form","rootProps","sizeProps","iconBaseProps","sizes","SIZES_ICON","color","disabled","formInputLabelId","useMemo","id","nanoid","inputLabelId","menuListId","filteredOptions","getFilteredOptions","useFilteredOptions","loadedOptions","optionsLoading","getLoadedOptions","useLoadedOptions","dropdownSelectedOption","setDropdownSelectedOption","useState","getDropdownSelectedOption","undefined","inputText","setInputText","getDropdownInputText","focusWithin","setFocusWithin","menuOpenRequest","setMenuOpenRequest","menuOptions","menuOptionsLoading","menuOptionsGroups","groupDropdownOptions","menuOpen","inputRequired","length","inputActive","Boolean","multiToggleChecked","multiToggleIndeterminate","inputRef","useRef","menuRef","setMenuRef","menuListRef","selectedOptionRef","menuOpenPrevRef","updateInputText","useCallback","inputTextValue","updateOptions","updateOptionsDebounced","createDebouncedCallback","preventBlur","evt","target","current","Node","currentTarget","contains","renderInPortal","preventDefault","useScrollMonitor","onScrollStart","focus","useLayoutEffect","useEffect","menuRect","getBoundingClientRect","selectedOptionRect","top","bottom","setTimeout","scrollTo","offsetTop","_jsx","FormInputLabel","labelId","active","onColored","error","success","jsx","Styled","up","labelColorDisabled","labelColor","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","onPointerDown","onMouseDown","window","PointerEvent","onFocus","onBlur","relatedTarget","input","_jsxs","jsxs","_Fragment","children","type","tabIndex","FormInput","role","label","autoComplete","autoCapitalize","autoCorrect","spellCheck","value","colorDisabled","placeholderColor","placeholderColorDisabled","selectionStart","selectionEnd","stopPropagation","onChange","inputValue","onKeyDown","keyboardKeys","Enter","validate","key","Space","prev","Esc","Tab","ArrowDown","menuItems","idx","findIndex","item","focusTarget","HTMLElement","focusFirstFocusable","ArrowUp","focusLastFocusable","map","option","addon","Chip","black","marginLeft","cursor","text","textProps","appearance","colorHover","discardButtonProps","square","IconButton","dropdown","DropdownMenu","setRef","open","popperReferenceId","secondary","elevated","disableAutoFocus","menuBackgroundColor","menuBorderColor","empty","emptyMessage","emptyIcon","emptyIconProps","Backspace","MenuList","ListItem","borderRadius","ellipsis","wordBreak","control","InputCheckbox","SIZES_CHECKBOX","checked","indeterminate","update","filter","MenuDivider","optionStatus","optionErrorStatus","optionSuccessStatus","_createElement","danger","selected","SIZES","displayName"],"mappings":"k9BAiCMA,MAAAA,SAA2DC,gBAAAA,gBAC/DC,MAAAA,YAAuD,CAACC,EAAOC,KAC7D,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,eAAcC,cACrBA,EAAgB,UAASC,WACzBA,GAAa,EAAIC,QACjBA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B,EAAO7B,MACZmC,KAAMN,EAAOM,KACbvE,OAAQ+G,EACRD,OAAQvJ,QAAQwJ,GAAYxM,IAAW,SACvC4F,QAAS5C,QAAQwJ,GAAYxM,IAAW,WACxCc,SAAUN,EAAUM,UAAY4I,EAAO5I,SACvC0K,aAAc,EACdC,UAAU,EACVxB,UAAW,CAAEyB,UAAW,cACxBnF,QAAUtC,IAGR,GAFAA,EAAIkE,mBAECrI,EAAU,CACb,MAAMkM,EAAS,IAAKtC,GAEhBjL,SAAmBuD,IACrB0B,GAAgBvB,MAAAA,qBAAqB6J,IACrCnK,GAA0BE,MAAAA,0BAA0BiK,KAGlD3M,GAAgBA,EAAe2M,GAEnC7I,GAASgB,SAASQ,QAClBpC,IAAmB,EACrB,IAEF,SAOd,IAGN,CACE5B,MAAO8L,MAAKA,MACZC,YA71BmB,oCAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{forwardRef,useMemo,useState,useRef,useCallback,useLayoutEffect,useEffect,createElement}from'react';import{nanoid}from'nanoid';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useScrollMonitor}from'../../hooks/useScrollMonitor.mjs';import{focusFirstFocusable,focusLastFocusable}from'../../shared/utils/dom.mjs';import{createDebouncedCallback}from'../../shared/utils/misc.mjs';import{keyboardKeys}from'../../shared/constants.mjs';import{DropdownMenu}from'./DropdownMenu.mjs';import{useFilteredOptions,useLoadedOptions}from'./hooks.mjs';import{SIZES,SIZES_ICON,SIZES_CHECKBOX}from'./constants.mjs';import{getDropdownSelectedOption,getDropdownInputText,groupDropdownOptions}from'./utils.mjs';import{ChevronIcon,InputMimic}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{FormInputLabel}from'../FormInputLabel/FormInputLabel.mjs';import{FormInput}from'../FormInput/FormInput.mjs';import{Chip}from'../Chip/Chip.mjs';import{IconButton}from'../IconButton/IconButton.mjs';import{MenuList}from'../MenuList/MenuList.mjs';import{ListItem}from'../ListItem/ListItem.mjs';import{InputCheckbox}from'../InputCheckbox/InputCheckbox.mjs';import{MenuDivider}from'../MenuDivider/MenuDivider.mjs';const COMPONENT_NAME='Dropdown';const Dropdown=withMergedProps(forwardRef(((e,o)=>{const{size:t="m",name:n="fox-dropdown",labelPosition:r="dynamic",searchable:s=!0,primary:a=!0,optionsMultiToggle:l=!0,iconProps:i={},menuProps:c={},loadingIconProps:d={},optionsEmptyIconProps:u={},loading:p,autoFocus:m,disableAutoScrollToSelectedOption:b,closeMenuOnScroll:f,scrollMonitorTarget:g,contrast:v,selectedOption:C,defaultSelectedOption:k,icon:x,inputMode:I,loadingMessage:h,loadingIcon:y,maxLength:w,multiple:D,clearable:M,onChangeInput:S,onCloseMenu:E,onOpenMenu:j,onSelectOption:P,options:L,loadOptions:O,groupSelectedOptions:F,optionsMultiToggleCaption:T,optionsEmptyMessage:B,optionsEmptyIcon:z,palette:K,placeholder:R,readOnly:X,required:H,status:N,sizeXXS:Z,sizeXS:_,sizeS:A,sizeM:q,sizeL:$,sizeXL:U,form:G,...J}=e;const Q={size:t,sizeXXS:Z,sizeXS:_,sizeS:A,sizeM:q,sizeL:$,sizeXL:U};const V={sizes:SIZES_ICON,color:J.disabled?'content-disabled':'content-onmain-tertiary'};const W=useMemo((()=>J.id??`${n}-${nanoid()}`),[n,J.id]);const Y=useMemo((()=>nanoid()),[]);const ee=useMemo((()=>nanoid()),[]);const[oe,te]=useFilteredOptions({options:L});const[ne,re,se]=useLoadedOptions({loadOptions:O,options:L});const[ae,le]=useState((()=>getDropdownSelectedOption(C!==void 0?C:k,D)));const[ie,ce]=useState((()=>getDropdownInputText(ae,D)));const[de,ue]=useState(!1);const[pe,me]=useState(!1);const be=O?ne:oe;const fe=O?p??re:p;const ge=useMemo((()=>D?groupDropdownOptions(be,ae):[[],[]]),[D,be,ae]);const ve=pe&&!J.disabled;const Ce=H&&ae.length===0;const ke=Boolean(ve||ie||de);const xe=ge[0].length>0&&ge[1].length===0;const Ie=ge[0].length>0&&ge[1].length>0;const he=useRef(null);const[ye,we]=useState(null);const De=useRef(null);const Me=useRef(null);const Se=useRef(ve);const Ee=useCallback((e=>{ce(e),S&&S(e)}),[S]);const je=useCallback((e=>{O?se(e):te(e)}),[O,se,te]);const Pe=useMemo((()=>createDebouncedCallback(je,150)),[je]);const preventBlur=e=>{e.target!==he.current&&e.target instanceof Node&&(e.currentTarget.contains(e.target)||c.renderInPortal&&ve&&ye&&ye.contains(e.target))&&e.preventDefault()};return useScrollMonitor({target:g,onScrollStart:()=>{f&&ve&&(he.current?.focus(),me(!1))}}),useLayoutEffect((()=>{C!==void 0&&(D||ve||Ee(getDropdownInputText(C)),le(getDropdownSelectedOption(C,D)))}),[D,C,ve,Ee]),useEffect((()=>{ve!==Se.current&&(ve&&j&&j(),!ve&&E&&E(),Se.current=ve)}),[ve,E,j]),useEffect((()=>{if(!D&&!b&&ve&&!fe&&ie.length===0&&ye&&Me.current){const e=ye.getBoundingClientRect();const o=Me.current.getBoundingClientRect();(o.top<e.top||o.bottom>e.bottom)&&setTimeout((()=>{ye&&Me.current&&ye.scrollTo(0,Me.current.offsetTop)}),0)}}),[D,b,ve,fe,ie,ye]),jsx(FormInputLabel,{...J,...Q,ref:o,id:W,labelId:Y,labelPosition:r,active:ke,onColored:v,primary:a,error:N==='error',success:N==='success',focus:de,icon:[x,jsx(ChevronIcon,{up:ve},'chevron')],iconProps:{...Q,...V,...i},palette:{color:J.disabled?K.labelColorDisabled:K.labelColor,backgroundColor:J.disabled?K.backgroundColorDisabled:K.backgroundColor,backgroundColorHover:J.disabled?K.backgroundColorDisabled:K.backgroundColorHover,borderColor:J.disabled?K.borderColorDisabled:K.borderColor},onClick:e=>{J.onClick&&J.onClick(e),J.disabled||(he.current?.focus(),ve?ye&&e.target instanceof Node&&!ye.contains(e.target)&&(me(!1),Ee(getDropdownInputText(ae,D))):(me(!0),je(''),s&&Ee('')))},onPointerDown:e=>{J.onPointerDown&&J.onPointerDown(e),preventBlur(e)},onMouseDown:e=>{J.onMouseDown&&J.onMouseDown(e),window.PointerEvent||preventBlur(e)},onFocus:e=>{J.onFocus&&J.onFocus(e),ue(!0),he.current&&e.target===he.current&&s&&!D&&!ve&&Ee('')},onBlur:e=>{J.onBlur&&J.onBlur(e),e.currentTarget.contains(e.relatedTarget)||c.renderInPortal&&ve&&ye&&ye.contains(e.relatedTarget)||(ue(!1),Ee(getDropdownInputText(ae,D)),me(!1))},input:jsxs(Fragment,{children:[!Ce||s||X?null:jsx(InputMimic,{required:!0,type:"text",inputMode:"none",form:G,tabIndex:-1,onFocus:()=>{he.current?.focus()}}),jsx(FormInput,{ref:he,role:"combobox","aria-controls":ee,"aria-expanded":ve,"aria-labelledby":J.label?Y:void 0,type:"text",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",form:G,autoFocus:m,inputMode:s?I:'none',maxLength:w,placeholder:R,readOnly:X||!s,required:Ce,disabled:J.disabled,value:ie,palette:{color:K.color,colorDisabled:K.colorDisabled,placeholderColor:K.placeholderColor,placeholderColorDisabled:K.placeholderColorDisabled},onClick:e=>{ve&&e.currentTarget.selectionStart!==e.currentTarget.selectionEnd&&e.stopPropagation()},onChange:e=>{const o=e.currentTarget.value;Ee(o),Pe(o),me(!0)},onKeyDown:e=>{if(keyboardKeys.Enter.validate(e.key)&&(Ee(getDropdownInputText(ae,D)),me(!1)),!keyboardKeys.Space.validate(e.key)||ve&&e.currentTarget.selectionStart!==0||(e.preventDefault(),ve||(je(''),s&&Ee('')),me((e=>!e))),keyboardKeys.Esc.validate(e.key)&&me(!1),keyboardKeys.Tab.validate(e.key)&&ve&&(e.preventDefault(),me(!1)),keyboardKeys.ArrowDown.validate(e.key)&&ve&&De.current)if(e.preventDefault(),!D&&Me.current){const e=[...De.current.children];const o=e.findIndex((e=>e.contains(Me.current)));const t=e[o+1]??e[0];t instanceof HTMLElement&&focusFirstFocusable(t)}else focusFirstFocusable(De.current);if(keyboardKeys.ArrowUp.validate(e.key)&&ve&&De.current)if(e.preventDefault(),!D&&Me.current){const e=[...De.current.children];const o=e.findIndex((e=>e.contains(Me.current)));const t=e[o-1]??e[e.length-1];t instanceof HTMLElement&&focusFirstFocusable(t)}else focusLastFocusable(De.current)}}),ae.map((e=>jsx("input",{type:"hidden",name:n,value:e.value,form:G,disabled:J.disabled},e.value)))]}),addon:jsxs(Fragment,{children:[D&&ae.length>0?jsx(Chip,{size:"xs",active:!0,black:!0,marginLeft:12,disabled:J.disabled,cursor:J.disabled?'not-allowed':void 0,text:ae.length,textProps:{appearance:'caption',size:'xs'},palette:J.disabled?{color:'content-disabled',colorHover:'content-disabled',backgroundColor:'bg-disabled-small',backgroundColorHover:'bg-disabled-small'}:void 0,onPointerDown:e=>{e.preventDefault()},onMouseDown:e=>{window.PointerEvent||e.preventDefault()},discardButtonProps:{square:!0,contrast:!J.disabled,onClick:e=>{e.stopPropagation(),X||(C===void 0&&le([]),P&&P([]),he.current?.focus(),Ee(''),je(''),me(!0))}}}):null,!D&&M&&ae.length>0?jsx(IconButton,{icon:"close",size:"l",square:!0,marginLeft:12,disabled:J.disabled,onClick:e=>{e.stopPropagation(),X||(C===void 0&&le([]),P&&P(null),he.current?.focus(),Ee(''),je(''),me(!0))}}):null]}),dropdown:jsx(DropdownMenu,{...c,setRef:we,open:ve,popperReferenceId:W,secondary:!v,elevated:v,disableAutoFocus:!0,palette:{backgroundColor:K.menuBackgroundColor,borderColor:K.menuBorderColor},empty:be.length===0,loading:fe,loadingMessage:h,loadingIcon:y,loadingIconProps:{...Q,...V,...d},emptyMessage:B,emptyIcon:z,emptyIconProps:{...Q,...V,...u},onKeyDown:e=>{keyboardKeys.Tab.validate(e.key)&&(e.preventDefault(),he.current?.focus(),me(!1)),keyboardKeys.Enter.validate(e.key)&&(he.current?.focus(),Ee(getDropdownInputText(ae,D)),me(!1)),keyboardKeys.Esc.validate(e.key)&&(he.current?.focus(),me(!1)),keyboardKeys.Backspace.validate(e.key)&&!X&&(D||!D&&M)&&(C===void 0&&le([]),P&&P(D?[]:null),Ee(''),je(''))},children:jsx(MenuList,D?{ref:De,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,"aria-multiselectable":!0,children:ie.length===0?jsxs(Fragment,{children:[l?jsx(ListItem,{...Q,text:T,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",name:n,checked:xe,indeterminate:Ie,error:Boolean((xe||Ie)&&N==='error'),success:Boolean((xe||Ie)&&N==='success'),onChange:()=>{if(!X){const e=xe||Ie?[]:[...be];C===void 0&&le(e),P&&P(e)}}})}):null,l?jsx(MenuDivider,{}):null,F?ge[0].map((e=>{const o=e.status??N;const t=o==='error';const r=o==='success';return createElement(ListItem,{...Q,key:e.value,active:!0,text:e.text,danger:t,success:r,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),he.current?.focus()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!0,name:n,value:e.value,checked:!0,error:t,success:r,onChange:e=>{if(!X){const o=ae.filter((o=>o.value!==e.currentTarget.value));C===void 0&&le(o),P&&P(o)}}})})})):null,F&&ge[0].length>0&&ge[1].length>0?jsx(MenuDivider,{}):null,F?ge[1].map((e=>createElement(ListItem,{...Q,key:e.value,text:e.text,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),he.current?.focus()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!1,name:n,value:e.value,checked:!1,onChange:()=>{if(!X){const o=[...ae,e];C===void 0&&le(o),P&&P(o)}}})}))):null,!F&&be.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??N;const r=o&&t==='error';const s=o&&t==='success';return createElement(ListItem,{...Q,key:e.value,text:e.text,danger:r,success:s,disabled:J.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:n,value:e.value,checked:o,error:r,success:s,onChange:t=>{if(!X){const n=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];C===void 0&&le(n),P&&P(n)}}})})}))]}):jsx(Fragment,{children:be.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??N;const r=o&&t==='error';const s=o&&t==='success';return createElement(ListItem,{...Q,key:e.value,text:e.text,danger:r,success:s,disabled:J.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:n,value:e.value,checked:o,error:r,success:s,onChange:t=>{if(!X){const n=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];C===void 0&&le(n),P&&P(n)}}})})}))})}:{ref:De,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,children:be.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;return createElement(ListItem,{...Q,role:"option","aria-selected":o,ref:o?Me:void 0,key:e.value,text:e.text,active:o,danger:Boolean(o&&N==='error'),success:Boolean(o&&N==='success'),disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:o=>{if(o.stopPropagation(),!X){const o={...e};C===void 0&&(Ee(getDropdownInputText(o)),le(getDropdownSelectedOption(o))),P&&P(o),he.current?.focus(),me(!1)}}})}))})})})})),{sizes:SIZES,displayName:"Dropdown"});export{COMPONENT_NAME,Dropdown};
|
|
1
|
+
import{forwardRef,useMemo,useState,useRef,useCallback,useLayoutEffect,useEffect,createElement}from'react';import{nanoid}from'nanoid';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useScrollMonitor}from'../../hooks/useScrollMonitor.mjs';import{focusFirstFocusable,focusLastFocusable}from'../../shared/utils/dom.mjs';import{createDebouncedCallback}from'../../shared/utils/misc.mjs';import{keyboardKeys}from'../../shared/constants.mjs';import{DropdownMenu}from'./DropdownMenu.mjs';import{useFilteredOptions,useLoadedOptions}from'./hooks.mjs';import{SIZES,SIZES_ICON,SIZES_CHECKBOX}from'./sizes.mjs';import{getDropdownSelectedOption,getDropdownInputText,groupDropdownOptions}from'./utils.mjs';import{ChevronIcon,InputMimic}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{FormInputLabel}from'../FormInputLabel/FormInputLabel.mjs';import{FormInput}from'../FormInput/FormInput.mjs';import{Chip}from'../Chip/Chip.mjs';import{IconButton}from'../IconButton/IconButton.mjs';import{MenuList}from'../MenuList/MenuList.mjs';import{ListItem}from'../ListItem/ListItem.mjs';import{InputCheckbox}from'../InputCheckbox/InputCheckbox.mjs';import{MenuDivider}from'../MenuDivider/MenuDivider.mjs';const COMPONENT_NAME='Dropdown';const Dropdown=withMergedProps(forwardRef(((e,o)=>{const{size:t="m",name:r="fox-dropdown",labelPosition:n="dynamic",searchable:s=!0,primary:a=!0,optionsMultiToggle:l=!0,iconProps:i={},menuProps:c={},loadingIconProps:d={},optionsEmptyIconProps:u={},loading:p,autoFocus:m,disableAutoScrollToSelectedOption:b,closeMenuOnScroll:f,scrollMonitorTarget:g,contrast:v,selectedOption:C,defaultSelectedOption:k,icon:x,inputMode:I,loadingMessage:h,loadingIcon:y,maxLength:w,multiple:D,clearable:M,onChangeInput:S,onCloseMenu:E,onOpenMenu:j,onSelectOption:P,options:L,loadOptions:O,groupSelectedOptions:F,optionsMultiToggleCaption:T,optionsEmptyMessage:B,optionsEmptyIcon:z,palette:K,placeholder:R,readOnly:X,required:H,status:N,sizeXXS:Z,sizeXS:_,sizeS:A,sizeM:q,sizeL:$,sizeXL:U,form:G,...J}=e;const Q={size:t,sizeXXS:Z,sizeXS:_,sizeS:A,sizeM:q,sizeL:$,sizeXL:U};const V={sizes:SIZES_ICON,color:J.disabled?'content-disabled':'content-onmain-tertiary'};const W=useMemo((()=>J.id??`${r}-${nanoid()}`),[r,J.id]);const Y=useMemo((()=>nanoid()),[]);const ee=useMemo((()=>nanoid()),[]);const[oe,te]=useFilteredOptions({options:L});const[re,ne,se]=useLoadedOptions({loadOptions:O,options:L});const[ae,le]=useState((()=>getDropdownSelectedOption(C!==void 0?C:k,D)));const[ie,ce]=useState((()=>getDropdownInputText(ae,D)));const[de,ue]=useState(!1);const[pe,me]=useState(!1);const be=O?re:oe;const fe=O?p??ne:p;const ge=useMemo((()=>D?groupDropdownOptions(be,ae):[[],[]]),[D,be,ae]);const ve=pe&&!J.disabled;const Ce=H&&ae.length===0;const ke=Boolean(ve||ie||de);const xe=ge[0].length>0&&ge[1].length===0;const Ie=ge[0].length>0&&ge[1].length>0;const he=useRef(null);const[ye,we]=useState(null);const De=useRef(null);const Me=useRef(null);const Se=useRef(ve);const Ee=useCallback((e=>{ce(e),S&&S(e)}),[S]);const je=useCallback((e=>{O?se(e):te(e)}),[O,se,te]);const Pe=useMemo((()=>createDebouncedCallback(je,150)),[je]);const preventBlur=e=>{e.target!==he.current&&e.target instanceof Node&&(e.currentTarget.contains(e.target)||c.renderInPortal&&ve&&ye&&ye.contains(e.target))&&e.preventDefault()};return useScrollMonitor({target:g,onScrollStart:()=>{f&&ve&&(he.current?.focus(),me(!1))}}),useLayoutEffect((()=>{C!==void 0&&(D||ve||Ee(getDropdownInputText(C)),le(getDropdownSelectedOption(C,D)))}),[D,C,ve,Ee]),useEffect((()=>{ve!==Se.current&&(ve&&j&&j(),!ve&&E&&E(),Se.current=ve)}),[ve,E,j]),useEffect((()=>{if(!D&&!b&&ve&&!fe&&ie.length===0&&ye&&Me.current){const e=ye.getBoundingClientRect();const o=Me.current.getBoundingClientRect();(o.top<e.top||o.bottom>e.bottom)&&setTimeout((()=>{ye&&Me.current&&ye.scrollTo(0,Me.current.offsetTop)}),0)}}),[D,b,ve,fe,ie,ye]),jsx(FormInputLabel,{...J,...Q,ref:o,id:W,labelId:Y,labelPosition:n,active:ke,onColored:v,primary:a,error:N==='error',success:N==='success',focus:de,icon:[x,jsx(ChevronIcon,{up:ve},'chevron')],iconProps:{...Q,...V,...i},palette:{color:J.disabled?K.labelColorDisabled:K.labelColor,backgroundColor:J.disabled?K.backgroundColorDisabled:K.backgroundColor,backgroundColorHover:J.disabled?K.backgroundColorDisabled:K.backgroundColorHover,borderColor:J.disabled?K.borderColorDisabled:K.borderColor},onClick:e=>{J.onClick&&J.onClick(e),J.disabled||(he.current?.focus(),ve?ye&&e.target instanceof Node&&!ye.contains(e.target)&&(me(!1),Ee(getDropdownInputText(ae,D))):(me(!0),je(''),s&&Ee('')))},onPointerDown:e=>{J.onPointerDown&&J.onPointerDown(e),preventBlur(e)},onMouseDown:e=>{J.onMouseDown&&J.onMouseDown(e),window.PointerEvent||preventBlur(e)},onFocus:e=>{J.onFocus&&J.onFocus(e),ue(!0),he.current&&e.target===he.current&&s&&!D&&!ve&&Ee('')},onBlur:e=>{J.onBlur&&J.onBlur(e),e.currentTarget.contains(e.relatedTarget)||c.renderInPortal&&ve&&ye&&ye.contains(e.relatedTarget)||(ue(!1),Ee(getDropdownInputText(ae,D)),me(!1))},input:jsxs(Fragment,{children:[!Ce||s||X?null:jsx(InputMimic,{required:!0,type:"text",inputMode:"none",form:G,tabIndex:-1,onFocus:()=>{he.current?.focus()}}),jsx(FormInput,{ref:he,role:"combobox","aria-controls":ee,"aria-expanded":ve,"aria-labelledby":J.label?Y:void 0,type:"text",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",form:G,autoFocus:m,inputMode:s?I:'none',maxLength:w,placeholder:R,readOnly:X||!s,required:Ce,disabled:J.disabled,value:ie,palette:{color:K.color,colorDisabled:K.colorDisabled,placeholderColor:K.placeholderColor,placeholderColorDisabled:K.placeholderColorDisabled},onClick:e=>{ve&&e.currentTarget.selectionStart!==e.currentTarget.selectionEnd&&e.stopPropagation()},onChange:e=>{const o=e.currentTarget.value;Ee(o),Pe(o),me(!0)},onKeyDown:e=>{if(keyboardKeys.Enter.validate(e.key)&&(Ee(getDropdownInputText(ae,D)),me(!1)),!keyboardKeys.Space.validate(e.key)||ve&&e.currentTarget.selectionStart!==0||(e.preventDefault(),ve||(je(''),s&&Ee('')),me((e=>!e))),keyboardKeys.Esc.validate(e.key)&&me(!1),keyboardKeys.Tab.validate(e.key)&&ve&&(e.preventDefault(),me(!1)),keyboardKeys.ArrowDown.validate(e.key)&&ve&&De.current)if(e.preventDefault(),!D&&Me.current){const e=[...De.current.children];const o=e.findIndex((e=>e.contains(Me.current)));const t=e[o+1]??e[0];t instanceof HTMLElement&&focusFirstFocusable(t)}else focusFirstFocusable(De.current);if(keyboardKeys.ArrowUp.validate(e.key)&&ve&&De.current)if(e.preventDefault(),!D&&Me.current){const e=[...De.current.children];const o=e.findIndex((e=>e.contains(Me.current)));const t=e[o-1]??e[e.length-1];t instanceof HTMLElement&&focusFirstFocusable(t)}else focusLastFocusable(De.current)}}),ae.map((e=>jsx("input",{type:"hidden",name:r,value:e.value,form:G,disabled:J.disabled||e.disabled},e.value)))]}),addon:jsxs(Fragment,{children:[D&&ae.length>0?jsx(Chip,{size:"xs",active:!0,black:!0,marginLeft:12,disabled:J.disabled,cursor:J.disabled?'not-allowed':void 0,text:ae.length,textProps:{appearance:'caption',size:'xs'},palette:J.disabled?{color:'content-disabled',colorHover:'content-disabled',backgroundColor:'bg-disabled-small',backgroundColorHover:'bg-disabled-small'}:void 0,onPointerDown:e=>{e.preventDefault()},onMouseDown:e=>{window.PointerEvent||e.preventDefault()},discardButtonProps:{square:!0,contrast:!J.disabled,onClick:e=>{e.stopPropagation(),X||(C===void 0&&le([]),P&&P([]),he.current?.focus(),Ee(''),je(''),me(!0))}}}):null,!D&&M&&ae.length>0?jsx(IconButton,{icon:"close",size:"l",square:!0,marginLeft:12,disabled:J.disabled,onClick:e=>{e.stopPropagation(),X||(C===void 0&&le([]),P&&P(null),he.current?.focus(),Ee(''),je(''),me(!0))}}):null]}),dropdown:jsx(DropdownMenu,{...c,setRef:we,open:ve,popperReferenceId:W,secondary:!v,elevated:v,disableAutoFocus:!0,palette:{backgroundColor:K.menuBackgroundColor,borderColor:K.menuBorderColor},empty:be.length===0,loading:fe,loadingMessage:h,loadingIcon:y,loadingIconProps:{...Q,...V,...d},emptyMessage:B,emptyIcon:z,emptyIconProps:{...Q,...V,...u},onKeyDown:e=>{keyboardKeys.Tab.validate(e.key)&&(e.preventDefault(),he.current?.focus(),me(!1)),keyboardKeys.Enter.validate(e.key)&&(he.current?.focus(),Ee(getDropdownInputText(ae,D)),me(!1)),keyboardKeys.Esc.validate(e.key)&&(he.current?.focus(),me(!1)),keyboardKeys.Backspace.validate(e.key)&&!X&&(D||!D&&M)&&(C===void 0&&le([]),P&&P(D?[]:null),Ee(''),je(''))},children:jsx(MenuList,D?{ref:De,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,"aria-multiselectable":!0,children:ie.length===0?jsxs(Fragment,{children:[l?jsx(ListItem,{...Q,text:T,disabled:J.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",name:r,checked:xe,indeterminate:Ie,error:Boolean((xe||Ie)&&N==='error'),success:Boolean((xe||Ie)&&N==='success'),onChange:()=>{if(!X){const e=xe||Ie?ae.filter((e=>e.disabled)):be.filter((e=>!e.disabled));C===void 0&&le(e),P&&P(e)}}})}):null,l?jsx(MenuDivider,{}):null,F?ge[0].map((e=>{const o=e.status??N;const t=o==='error';const n=o==='success';return createElement(ListItem,{...Q,key:e.value,active:!0,text:e.text,danger:t,success:n,disabled:J.disabled||e.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),he.current?.focus()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!0,name:r,value:e.value,checked:!0,error:t,success:n,onChange:e=>{if(!X){const o=ae.filter((o=>o.value!==e.currentTarget.value));C===void 0&&le(o),P&&P(o)}}})})})):null,F&&ge[0].length>0&&ge[1].length>0?jsx(MenuDivider,{}):null,F?ge[1].map((e=>createElement(ListItem,{...Q,key:e.value,text:e.text,disabled:J.disabled||e.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation(),he.current?.focus()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":!1,name:r,value:e.value,checked:!1,onChange:()=>{if(!X){const o=[...ae,e];C===void 0&&le(o),P&&P(o)}}})}))):null,!F&&be.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??N;const n=o&&t==='error';const s=o&&t==='success';return createElement(ListItem,{...Q,key:e.value,text:e.text,danger:n,success:s,disabled:J.disabled||e.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:r,value:e.value,checked:o,error:n,success:s,onChange:t=>{if(!X){const r=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];C===void 0&&le(r),P&&P(r)}}})})}))]}):jsx(Fragment,{children:be.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;const t=e.status??N;const n=o&&t==='error';const s=o&&t==='success';return createElement(ListItem,{...Q,key:e.value,text:e.text,danger:n,success:s,disabled:J.disabled||e.disabled,active:o,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:e=>{e.stopPropagation()},control:jsx(InputCheckbox,{sizes:SIZES_CHECKBOX,form:"none",role:"option","aria-selected":o,name:r,value:e.value,checked:o,error:n,success:s,onChange:t=>{if(!X){const r=o?ae.filter((e=>e.value!==t.currentTarget.value)):[...ae,e];C===void 0&&le(r),P&&P(r)}}})})}))})}:{ref:De,id:ee,role:"listbox","aria-labelledby":J.label?Y:void 0,children:be.map((e=>{const o=ae.findIndex((o=>o.value===e.value))!==-1;return createElement(ListItem,{...Q,role:"option","aria-selected":o,ref:o?Me:void 0,key:e.value,text:e.text,active:o,danger:Boolean(o&&N==='error'),success:Boolean(o&&N==='success'),disabled:J.disabled||e.disabled,borderRadius:8,ellipsis:!1,textProps:{wordBreak:'break-word'},onClick:o=>{if(o.stopPropagation(),!X){const o={...e};C===void 0&&(Ee(getDropdownInputText(o)),le(getDropdownSelectedOption(o))),P&&P(o),he.current?.focus(),me(!1)}}})}))})})})})),{sizes:SIZES,displayName:"Dropdown"});export{COMPONENT_NAME,Dropdown};
|
|
2
2
|
//# sourceMappingURL=Dropdown.mjs.map
|