Build 589089stable
Module 128131
1,925 characters · in 38a9a83007e303b9.jsDependencies
Source Raw
function(e,t,s){s.d(t,{$:()=>n,O:()=>c});var i=s(868086),l=s(421114),r=s(576024),o=s(201092),a=s(582128),d=s(59344);function n(e,t,s){let{isDisabled:i}=e,{toolbarProps:n}=function(e,t){let{"aria-label":s,"aria-labelledby":i,orientation:n="horizontal"}=e,[c,u]=(0,a.useState)(!1);(0,r.N)(()=>{var e;u(!!(t.current&&(null==(e=t.current.parentElement)?void 0:e.closest('[role="toolbar"]'))))});let{direction:v}=(0,d.Y)(),b="rtl"===v&&"horizontal"===n,f=(0,l.C7)(t),p=(0,a.useRef)(null);return{toolbarProps:{...(0,o.$)(e,{labelable:!0}),role:c?"group":"toolbar","aria-orientation":n,"aria-label":s,"aria-labelledby":null==s?i:void 0,onKeyDownCapture:c?void 0:e=>{if(e.currentTarget.contains(e.target)){if("horizontal"===n&&"ArrowRight"===e.key||"vertical"===n&&"ArrowDown"===e.key)b?f.focusPrevious():f.focusNext();else if("horizontal"===n&&"ArrowLeft"===e.key||"vertical"===n&&"ArrowUp"===e.key)b?f.focusNext():f.focusPrevious();else{if("Tab"!==e.key)return;e.stopPropagation(),p.current=document.activeElement,e.shiftKey?f.focusFirst():f.focusLast();return}e.stopPropagation(),e.preventDefault()}},onFocusCapture:c?void 0:e=>{var s,i;p.current&&!e.currentTarget.contains(e.relatedTarget)&&(null==(s=t.current)?void 0:s.contains(e.target))&&(null==(i=p.current)||i.focus(),p.current=null)},onBlurCapture:c?void 0:e=>{e.currentTarget.contains(e.relatedTarget)||p.current||(p.current=e.target)}}}}(e,s);return{groupProps:{...n,role:"single"===t.selectionMode?"radiogroup":n.role,"aria-disabled":i}}}function c(e,t,s){let l={isSelected:t.selectedKeys.has(e.id),defaultSelected:!1,setSelected(s){t.setSelected(e.id,s)},toggle(){t.toggleKey(e.id)}},{isPressed:r,isSelected:o,isDisabled:a,buttonProps:d}=(0,i.q)({...e,id:void 0,isDisabled:e.isDisabled||t.isDisabled},l,s);return"single"===t.selectionMode&&(d.role="radio",d["aria-checked"]=l.isSelected,delete d["aria-pressed"]),{isPressed:r,isSelected:o,isDisabled:a,buttonProps:d}}}