You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
1.6 KiB
2 lines
1.6 KiB
var B=Object.defineProperty;var g=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var h=(n,o,c)=>o in n?B(n,o,{enumerable:!0,configurable:!0,writable:!0,value:c}):n[o]=c,m=(n,o)=>{for(var c in o||(o={}))F.call(o,c)&&h(n,c,o[c]);if(g)for(var c of g(o))I.call(o,c)&&h(n,c,o[c]);return n};import{r as v,f as R,u as t,ar as J,O as C,J as T,aj as W,as as Y,K as x}from"./index-f4658ae7.js";import{ROW_KEY as _}from"./const-0405ffdf.js";function D(n,o,c){const l=v([]),u=v([]),y=R(()=>{const{rowSelection:e}=t(n);return e?m({selectedRowKeys:t(l),onChange:s=>{r(s)}},J(e,["onChange"])):null});C(()=>{var e;return(e=t(n).rowSelection)==null?void 0:e.selectedRowKeys},e=>{r(e)}),C(()=>t(l),()=>{T(()=>{const{rowSelection:e}=t(n);if(e){const{onChange:s}=e;s&&W(s)&&s(d(),w())}c("selection-change",{keys:d(),rows:w()})})},{deep:!0});const k=R(()=>t(n).autoCreateKey&&!t(n).rowKey),K=R(()=>{const{rowKey:e}=t(n);return t(k)?_:e});function r(e){var a;l.value=e;const s=Y(x(t(o)).concat(x(t(u))),f=>e.includes(f[t(K)]),{children:(a=n.value.childrenColumnName)!=null?a:"children"}),i=[];e.forEach(f=>{const S=s.find(j=>j[t(K)]===f);S&&i.push(S)}),u.value=i}function A(e){u.value=e}function E(){u.value=[],l.value=[]}function N(e){const i=t(l).findIndex(a=>a===e);i!==-1&&t(l).splice(i,1)}function d(){return t(l)}function w(){return t(u)}function O(){return t(y)}return{getRowSelection:O,getRowSelectionRef:y,getSelectRows:w,getSelectRowKeys:d,setSelectedRowKeys:r,clearSelectedRowKeys:E,deleteSelectRowByKey:N,setSelectedRows:A}}export{D as useRowSelection};
|