Module 364643

4,805 characters · in no known chunk
Dependencies
Required by (2)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{p:()=>m});var i=n(869795),r=n(132716),s=n(985620),a=n(2799),o=n(318473),l=n(260431),u=n(805447),c=n(775133),d=n(114099),_=n(297987),h=n(401705),f=n(807177),E=n(64700),p=n(862836);function m(e){let{id:t,selectionManager:n,key:m,ref:I,shouldSelectOnPressUp:T,shouldUseVirtualFocus:S,focus:N,isDisabled:C,onAction:y,allowsDifferentPressOrigin:O,linkBehavior:R="action"}=e,v=(0,r.rd)();t=(0,s.Bi)(t);let b=e=>{if("keyboard"===e.pointerType&&(0,i.N9)(e))n.toggleSelection(m);else{if("none"===n.selectionMode)return;if(n.isLink(m)){if("selection"===R&&I.current){let t=n.getItemProps(m);v.open(I.current,e,t.href,t.routerOptions),n.setSelectedKeys(n.selectedKeys);return}else if("override"===R||"none"===R)return}"single"===n.selectionMode?n.isSelected(m)&&!n.disallowEmptySelection?n.toggleSelection(m):n.replaceSelection(m):e&&e.shiftKey?n.extendSelection(m):"toggle"===n.selectionBehavior||e&&((0,a.B)(e)||"touch"===e.pointerType||"virtual"===e.pointerType)?n.toggleSelection(m):n.replaceSelection(m)}};(0,E.useEffect)(()=>{m===n.focusedKey&&n.isFocused&&(S?(0,p.vX)(I.current):N?N():document.activeElement!==I.current&&I.current&&(0,u.l)(I.current))},[I,m,n.focusedKey,n.childFocusStrategy,n.isFocused,S]),C=C||n.isDisabled(m);let L={};S||C?C&&(L.onMouseDown=e=>{e.preventDefault()}):L={tabIndex:m===n.focusedKey?0:-1,onFocus(e){e.target===I.current&&n.setFocusedKey(m)}};let D=n.isLink(m)&&"override"===R,w=y&&"action"===e.UNSTABLE_itemBehavior,P=n.isLink(m)&&"selection"!==R&&"none"!==R,M=!C&&n.canSelectItem(m)&&!D&&!w,x=(y||P)&&!C,U=x&&("replace"===n.selectionBehavior?!M:!M||n.isEmpty),k=x&&M&&"replace"===n.selectionBehavior,G=U||k,V=(0,E.useRef)(null),F=G&&M,B=(0,E.useRef)(!1),H=(0,E.useRef)(!1),j=n.getItemProps(m),W=e=>{if(y){var t;y(),null==(t=I.current)||t.dispatchEvent(new CustomEvent("react-aria-item-action",{bubbles:!0}))}P&&I.current&&v.open(I.current,e,j.href,j.routerOptions)},Y={ref:I};if(T?(Y.onPressStart=e=>{V.current=e.pointerType,B.current=F,"keyboard"===e.pointerType&&(!G||A())&&b(e)},O?(Y.onPressUp=U?void 0:e=>{"mouse"===e.pointerType&&M&&b(e)},Y.onPress=U?W:e=>{"keyboard"!==e.pointerType&&"mouse"!==e.pointerType&&M&&b(e)}):Y.onPress=e=>{U||k&&"mouse"!==e.pointerType?("keyboard"!==e.pointerType||g())&&W(e):"keyboard"!==e.pointerType&&M&&b(e)}):(Y.onPressStart=e=>{V.current=e.pointerType,B.current=F,H.current=U,M&&("mouse"===e.pointerType&&!U||"keyboard"===e.pointerType&&(!x||A()))&&b(e)},Y.onPress=e=>{("touch"===e.pointerType||"pen"===e.pointerType||"virtual"===e.pointerType||"keyboard"===e.pointerType&&G&&g()||"mouse"===e.pointerType&&H.current)&&(G?W(e):M&&b(e))}),L["data-collection"]=(0,i.EG)(n.collection),L["data-key"]=m,Y.preventFocusOnPress=S,S&&(Y=(0,o.v)(Y,{onPressStart(e){"touch"!==e.pointerType&&(n.setFocused(!0),n.setFocusedKey(m))},onPress(e){"touch"===e.pointerType&&(n.setFocused(!0),n.setFocusedKey(m))}})),j)for(let e of["onPressStart","onPressEnd","onPressChange","onPress","onPressUp","onClick"])j[e]&&(Y[e]=(0,l.c)(Y[e],j[e]));let{pressProps:K,isPressed:$}=(0,c.d)(Y),z=k?e=>{"mouse"===V.current&&(e.stopPropagation(),e.preventDefault(),W(e))}:void 0,{longPressProps:q}=function(e){let{isDisabled:t,onLongPressStart:n,onLongPressEnd:i,onLongPress:r,threshold:s=500,accessibilityDescription:a}=e,l=(0,E.useRef)(void 0),{addGlobalListener:u,removeGlobalListener:p}=(0,d.A)(),{pressProps:m}=(0,c.d)({isDisabled:t,onPressStart(e){if(e.continuePropagation(),("mouse"===e.pointerType||"touch"===e.pointerType)&&(n&&n({...e,type:"longpressstart"}),l.current=setTimeout(()=>{e.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),(0,_.TW)(e.target).activeElement!==e.target&&(0,h.e)(e.target),r&&r({...e,type:"longpress"}),l.current=void 0},s),"touch"===e.pointerType)){let t=e=>{e.preventDefault()};u(e.target,"contextmenu",t,{once:!0}),u(window,"pointerup",()=>{setTimeout(()=>{p(e.target,"contextmenu",t)},30)},{once:!0})}},onPressEnd(e){l.current&&clearTimeout(l.current),i&&("mouse"===e.pointerType||"touch"===e.pointerType)&&i({...e,type:"longpressend"})}}),g=(0,f.I)(r&&!t?a:void 0);return{longPressProps:(0,o.v)(m,g)}}({isDisabled:!F,onLongPress(e){"touch"===e.pointerType&&(b(e),n.setSelectionBehavior("toggle"))}}),Z="none"!==R&&n.isLink(m)?e=>{r.Fe.isOpening||e.preventDefault()}:void 0;return{itemProps:(0,o.v)(L,M||U||S&&!C?K:{},F?q:{},{onDoubleClick:z,onDragStartCapture:e=>{"touch"===V.current&&B.current&&e.preventDefault()},onClick:Z,id:t},S?{onMouseDown:e=>e.preventDefault()}:void 0),isPressed:$,isSelected:n.isSelected(m),isFocused:n.isFocused&&n.focusedKey===m,isDisabled:C,allowsSelection:M,hasAction:G}}function g(){let e=window.event;return(null==e?void 0:e.key)==="Enter"}function A(){let e=window.event;return(null==e?void 0:e.key)===" "||(null==e?void 0:e.code)==="Space"}}