ray-template/js/hooks-selection-CbihARrh.js

1 line
2.2 KiB
JavaScript

import{T as e,d as t,v as n,y as r}from"./runtime-core.esm-bundler-BvnVMcQz.js";import{A as i,T as a}from"./isSymbol-DERoyzaf.js";import{Ln as o,Z as s,mn as c,tr as l}from"./directives-QatNmAyh.js";import{t as u}from"./useTablePro-Ceczz0Qe.js";import{t as d}from"./DemoPage-DXXea1cu.js";import{t as f}from"./DemoResult-CvFDt4Kp.js";import{n as p}from"./person-Bb7V4tGh.js";import{t as m}from"./usePeopleData-CiyV__rQ.js";function h(t){return typeof t==`function`||Object.prototype.toString.call(t)===`[object Object]`&&!e(t)}var g=r({name:`TableDemoHooksSelection`,setup(){let{t:e}=c(),[r,{isReady:g,getCurrentPageData:_,getTableInstance:v}]=u(),{data:y,loading:b}=m(),x=a([]),S=i(new Set),C=t(()=>[{type:`selection`,width:44},...p(t=>e(`table.${t}`)).slice(0,4).map(e=>`key`in e&&e.key===`age`?{...e,sorter:(e,t)=>e.age-t.age}:e),{title:e(`tableHooks.markColumn`),key:`marked`,width:110,render:({id:t})=>e(S.value.has(t)?`tableHooks.marked`:`tableHooks.unmarked`)}]),w=()=>_().map(e=>e.id).filter(e=>typeof e==`string`),T=()=>{x.value=[...new Set([...x.value,...w()])]},E=()=>{let e=new Set(w());x.value=x.value.filter(t=>!e.has(t))},D=()=>{S.value=new Set([...S.value,...x.value]),x.value=[]};return()=>{let t,i,a,c,u,p;return n(d,{title:e(`menu.TableHooksSelection`),description:e(`tableHooks.selectionDescription`)},{default:()=>[n(o,null,{default:()=>[n(l,{type:`primary`,disabled:!g.value,onClick:T},h(t=e(`tableHooks.selectPage`))?t:{default:()=>[t]}),n(l,{disabled:!g.value||!x.value.length,onClick:E},h(i=e(`tableHooks.unselectPage`))?i:{default:()=>[i]}),n(l,{disabled:!x.value.length,onClick:()=>{x.value=[]}},h(a=e(`tableHooks.clearAll`))?a:{default:()=>[a]}),n(l,{disabled:!x.value.length,onClick:D},h(c=e(`tableHooks.markSelected`))?c:{default:()=>[c]}),n(l,{disabled:!g.value,onClick:()=>v()?.clearSorter()},h(u=e(`tableHooks.clearSort`))?u:{default:()=>[u]})]}),n(f,{label:e(`tableHooks.selectionResult`)},h(p=e(`tableHooks.selectionDetails`,{selected:x.value.length,marked:S.value.size}))?p:{default:()=>[p]}),n(s,{onRegister:r,title:e(`table.directory`),columns:C.value,data:y.value,loading:b.value,checkedRowKeys:x.value,"onUpdate:checkedRowKeys":e=>x.value=e,search:[{key:`name`,label:e(`table.name`),placeholder:e(`table.nameHint`)}],scrollX:716},null)]})}}});export{g as default};