Build 594031stable
Module 580722
1,323 characters · in 25868.bd058c114912c1de.jsDependencies
Source Raw
function(e,t,r){"use strict";r.d(t,{R:()=>a});var n=r(353428),i=r(992533),o=r(582128);function a(e){let{selectionMode:t="none",disallowEmptySelection:r=!1,allowDuplicateSelectionEvents:a,selectionBehavior:l="toggle",disabledBehavior:u="all"}=e,c=(0,o.useRef)(!1),[,d]=(0,o.useState)(!1),f=(0,o.useRef)(null),p=(0,o.useRef)(null),[,h]=(0,o.useState)(null),m=(0,o.useMemo)(()=>s(e.selectedKeys),[e.selectedKeys]),g=(0,o.useMemo)(()=>s(e.defaultSelectedKeys,new(0,n.L)),[e.defaultSelectedKeys]),[v,y]=(0,i.P)(m,g,e.onSelectionChange),b=(0,o.useMemo)(()=>e.disabledKeys?new Set(e.disabledKeys):new Set,[e.disabledKeys]),[_,w]=(0,o.useState)(l);"replace"===l&&"toggle"===_&&"object"==typeof v&&0===v.size&&w("replace");let x=(0,o.useRef)(l);return(0,o.useEffect)(()=>{l!==x.current&&(w(l),x.current=l)},[l]),{selectionMode:t,disallowEmptySelection:r,selectionBehavior:_,setSelectionBehavior:w,get isFocused(){return c.current},setFocused(e){c.current=e,d(e)},get focusedKey(){return f.current},get childFocusStrategy(){return p.current},setFocusedKey(e,t="first"){f.current=e,p.current=t,h(e)},selectedKeys:v,setSelectedKeys(e){(a||!function(e,t){if(e.size!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;return!0}(e,v))&&y(e)},disabledKeys:b,disabledBehavior:u}}function s(e,t){return e?"all"===e?"all":new(0,n.L)(e):t}}