PromoCursed/node_modules/.cache/babel-loader/e86257d7dccf2f70108e2d6aa81d0e5e3b4924faac902f1e72d0ec399b23b77d.json

1 line
9.3 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"var __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport { useState } from 'react';\nimport extendsObject from '../../_util/extendsObject';\nexport const DEFAULT_PAGE_SIZE = 10;\nexport function getPaginationParam(mergedPagination, pagination) {\n const param = {\n current: mergedPagination.current,\n pageSize: mergedPagination.pageSize\n };\n const paginationObj = pagination && typeof pagination === 'object' ? pagination : {};\n Object.keys(paginationObj).forEach(pageProp => {\n const value = mergedPagination[pageProp];\n if (typeof value !== 'function') {\n param[pageProp] = value;\n }\n });\n return param;\n}\nfunction usePagination(total, onChange, pagination) {\n const _a = pagination && typeof pagination === 'object' ? pagination : {},\n {\n total: paginationTotal = 0\n } = _a,\n paginationObj = __rest(_a, [\"total\"]);\n const [innerPagination, setInnerPagination] = useState(() => ({\n current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,\n pageSize: 'defaultPageSize' in paginationObj ? paginationObj.defaultPageSize : DEFAULT_PAGE_SIZE\n }));\n // ============ Basic Pagination Config ============\n const mergedPagination = extendsObject(innerPagination, paginationObj, {\n total: paginationTotal > 0 ? paginationTotal : total\n });\n // Reset `current` if data length or pageSize changed\n const maxPage = Math.ceil((paginationTotal || total) / mergedPagination.pageSize);\n if (mergedPagination.current > maxPage) {\n // Prevent a maximum page count of 0\n mergedPagination.current = maxPage || 1;\n }\n const refreshPagination = (current, pageSize) => {\n setInnerPagination({\n current: current !== null && current !== void 0 ? current : 1,\n pageSize: pageSize || mergedPagination.pageSize\n });\n };\n const onInternalChange = (current, pageSize) => {\n var _a;\n if (pagination) {\n (_a = pagination.onChange) === null || _a === void 0 ? void 0 : _a.call(pagination, current, pageSize);\n }\n refreshPagination(current, pageSize);\n onChange(current, pageSize || (mergedPagination === null || mergedPagination === void 0 ? void 0 : mergedPagination.pageSize));\n };\n if (pagination === false) {\n return [{}, () => {}];\n }\n return [Object.assign(Object.assign({}, mergedPagination), {\n onChange: onInternalChange\n }), refreshPagination];\n}\nexport default usePagination;","map":{"version":3,"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","useState","extendsObject","DEFAULT_PAGE_SIZE","getPaginationParam","mergedPagination","pagination","param","current","pageSize","paginationObj","keys","forEach","pageProp","value","usePagination","total","onChange","_a","paginationTotal","innerPagination","setInnerPagination","defaultCurrent","defaultPageSize","maxPage","Math","ceil","refreshPagination","onInternalChange","assign"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/table/hooks/usePagination.js"],"sourcesContent":["var __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport { useState } from 'react';\nimport extendsObject from '../../_util/extendsObject';\nexport const DEFAUL