"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("lodash-unified"),q=require("vue"),w=require("./useKeepAliveFlag.js");function G(u){const r=q.ref(null),{isShowRowSelection:d=!0,clearSelectionOnRequest:f=!0,transformSearchFormValues:o,api:s,tableRefresh:n=!0,virtual:v,clearDataOnDeactivated:p=!0,...S}=u||{};let i=null;const c=()=>{r.value?.rowSelection?.clearAll()},l=()=>{r.value?.submitWith(!0)},g=()=>{r.value?.reset()},{isDeactivated:h}=w.useKeepAliveFlag({afterActivated(){(a.isFunction(n)?n():n)&&l()},afterDeactivated:l}),m=async e=>{if(h()&&p)return{data:[],total:0};i=e.sort;const t=o?o(e):e;if(!s)throw new Error("api is not defined");const{records:A,total:F}=await s(t);return f&&c(),{data:A,total:F}};return[a.merge({scroll:{x:"100%",y:"100%"},columnResizable:!0,request:s?m:void 0,rowSelection:d?{fixed:"left",columnWidth:38}:void 0,ref(e){r.value=e},virtual:a.merge({oSize:20,y:20},v),card:!0},S),{reload:l,reset:g,getSearchFormValues:(e=!0)=>{const t=r.value?.getSearchFormValues(!!e)||{};return o?o(t):t},getApGridInstance:()=>r.value,getSearchFormValuesAndSorted:(e=!0)=>{const t=r.value?.getSearchFormValues(!!e)||{};return t.sort=i&&a.cloneDeep(i),o?o(t):t},clearSelection:c}]}exports.usePageListApGrid=G;
