{"version":3,"file":"tablePagination.mjs","names":[],"sources":["../../../../src/components/table/src/tablePagination.tsx"],"sourcesContent":["import { computed, defineComponent, inject } from \"vue\";\nimport { ElNotification, ElPagination } from \"element-plus\";\nimport { definePropType, useRender } from \"../../../utils\";\nimport { tableStateKey } from \"./useTable\";\n\nexport default defineComponent({\n\tname: \"FaTablePagination\",\n\tprops: {\n\t\t/** 页码 */\n\t\tpageSizes: {\n\t\t\ttype: definePropType<number[]>(Array),\n\t\t\tdefault: [20, 30, 50, 100],\n\t\t},\n\t},\n\temits: {\n\t\t/** 页码改变 */\n\t\tsizeChange: (pageSize: number) => typeof pageSize === \"number\" || pageSize === null,\n\t\t/** 当前页数改变 */\n\t\tcurrentChange: (currentPage: number) => typeof currentPage === \"number\" || currentPage === null,\n\t},\n\tsetup(props, { emit }) {\n\t\tconst tableState = inject(tableStateKey);\n\t\tif (tableState === undefined) {\n\t\t\tthrow new Error(\"FaTablePagination 必须在 FaTable 内部渲染。\");\n\t\t}\n\n\t\tconst handleSizeChange = (pageSize: number) => {\n\t\t\tif (pageSize > 100) {\n\t\t\t\tElNotification({\n\t\t\t\t\ttitle: \"欢迎\",\n\t\t\t\t\tmessage: \"当前页码已经超过100条/页，可能会造成页面卡顿。\",\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tduration: 2000,\n\t\t\t\t});\n\t\t\t}\n\t\t\temit(\"sizeChange\", pageSize);\n\t\t};\n\t\tconst currentPageModel = computed({\n\t\t\tget: () => tableState.tablePagination.pageIndex,\n\t\t\tset: (currentPage: number) => emit(\"currentChange\", currentPage),\n\t\t});\n\t\tconst pageSizeModel = computed({\n\t\t\tget: () => tableState.tablePagination.pageSize,\n\t\t\tset: handleSizeChange,\n\t\t});\n\n\t\tuseRender(() => (\n\t\t\t<ElPagination\n\t\t\t\tclass=\"fa-table-pagination\"\n\t\t\t\tsize=\"small\"\n\t\t\t\tvModel:currentPage={currentPageModel.value}\n\t\t\t\tvModel:pageSize={pageSizeModel.value}\n\t\t\t\tpageSizes={props.pageSizes}\n\t\t\t\tbackground\n\t\t\t\tlayout=\"jumper, prev, pager, next, sizes, total\"\n\t\t\t\ttotal={tableState.tablePagination.totalRows}\n\t\t\t/>\n\t\t));\n\t},\n});\n"],"mappings":";;;;;;AAKA,IAAA,0BAAe,gBAAgB;CAC9B,MAAM;CACN,OAAO;;AAEN,WAAW;EACV,MAAM,eAAyB,KAAK;EACpC,SAAS;GAAC;GAAI;GAAI;GAAI;EAAG;CAC1B,EACD;CACA,OAAO;;EAEN,aAAa,aAAqB,OAAO,aAAa,YAAY,aAAa;;EAE/E,gBAAgB,gBAAwB,OAAO,gBAAgB,YAAY,gBAAgB;CAC5F;CACA,MAAM,OAAO,EAAE,QAAQ;EACtB,MAAM,aAAa,OAAO,aAAa;EACvC,IAAI,eAAe,KAAA,GAClB,MAAM,IAAI,MAAM,qCAAqC;EAGtD,MAAM,oBAAoB,aAAqB;GAC9C,IAAI,WAAW,KACd,eAAe;IACd,OAAO;IACP,SAAS;IACT,MAAM;IACN,UAAU;GACX,CAAC;GAEF,KAAK,cAAc,QAAQ;EAC5B;EACA,MAAM,mBAAmB,SAAS;GACjC,WAAW,WAAW,gBAAgB;GACtC,MAAM,gBAAwB,KAAK,iBAAiB,WAAW;EAChE,CAAC;EACD,MAAM,gBAAgB,SAAS;GAC9B,WAAW,WAAW,gBAAgB;GACtC,KAAK;EACN,CAAC;EAED,gBAAU,YAAA,cAAA;GAAA,SAAA;GAAA,QAAA;GAAA,eAIY,iBAAiB;GAAK,yBAAA,WAAtB,iBAAiB,QAAK;GAAA,YACzB,cAAc;GAAK,sBAAA,WAAnB,cAAc,QAAK;GAAA,aACzB,MAAM;GAAS,cAAA;GAAA,UAAA;GAAA,SAGnB,WAAW,gBAAgB;EAAS,GAAA,IAAA,CAE5C;CACF;AACD,CAAC"}