UNPKG

phx-react

Version:

PHX REACT

45 lines 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const react_1 = tslib_1.__importStar(require("react")); const Dropdown_1 = require("../../Dropdown"); const utils_1 = require("../utils"); const direct_link_1 = require("../../../hooks/direct-link"); const optionNumber = [150, 125, 100, 75, 50, 25, 10]; function PaginationSelected({ rowQuantity, setCurrentPage, setRowQuantity, paginationChange, setOffset, configUrlApply, tableKey, }) { const directLink = (0, direct_link_1.PHXUseDirectLink)(); (0, react_1.useEffect)(() => { if (configUrlApply) { const { searchParams } = configUrlApply; const rowQuery = utils_1.applyUrlQuery.get(searchParams, `row-${tableKey}`); if (rowQuery) { setRowQuantity === null || setRowQuantity === void 0 ? void 0 : setRowQuantity(Number(rowQuery)); } } }, []); const options = optionNumber.map((item) => ({ content: item + '', active: rowQuantity === item, onClick: () => { var _a; setRowQuantity === null || setRowQuantity === void 0 ? void 0 : setRowQuantity(item); setCurrentPage(1); setOffset(0); if (paginationChange) { paginationChange(1); } if (configUrlApply) { utils_1.applyUrlQuery.set(((_a = configUrlApply === null || configUrlApply === void 0 ? void 0 : configUrlApply.router) === null || _a === void 0 ? void 0 : _a.push) || directLink, configUrlApply.searchParams, [ { key: `row-${tableKey}`, value: item + '' }, { key: `pagi-${tableKey}`, value: '1' }, ]); } }, })); return (react_1.default.createElement("div", { className: 'relative' }, react_1.default.createElement("div", { className: 'absolute bottom-0 top-0 flex items-center gap-x-1' }, react_1.default.createElement(Dropdown_1.PHXDropdown, { buttonContent: `${rowQuantity}`, options: options, origin: 'top-left', type: 'default' }), react_1.default.createElement("div", { className: 'w-24 text-xs' }, "b\u1EA3n ghi/trang")))); } exports.default = PaginationSelected; //# sourceMappingURL=PaginaitonSelected.js.map