UNPKG

@keycloakify/keycloak-account-ui

Version:

<p align="center"> <img src="https://github.com/user-attachments/assets/e31c4910-7205-441c-9a35-e134b806b3a8"> </p> <p align="center"> <i>Repackaged Keycloak Account UI</i> <br> <br> <a href="https://github.com/keycloakify/keycloak-a

24 lines 1.9 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Pagination, SearchInput, Toolbar, ToolbarContent, ToolbarItem, } from "@patternfly/react-core"; export const ResourceToolbar = ({ count, first, max, onNextClick, onPreviousClick, onPerPageSelect, onFilter, hasNext, }) => { const { t } = useTranslation(); const [nameFilter, setNameFilter] = useState(""); const page = Math.round(first / max) + 1; return (_jsx(Toolbar, { children: _jsxs(ToolbarContent, { children: [_jsx(ToolbarItem, { children: _jsx(SearchInput, { placeholder: t("filterByName"), "aria-label": t("filterByName"), value: nameFilter, onChange: (_, value) => { setNameFilter(value); }, onSearch: () => onFilter(nameFilter), onKeyDown: (e) => { if (e.key === "Enter") { onFilter(nameFilter); } }, onClear: () => { setNameFilter(""); onFilter(""); } }) }), _jsx(ToolbarItem, { variant: "pagination", children: _jsx(Pagination, { isCompact: true, perPageOptions: [ { title: "5", value: 5 }, { title: "10", value: 10 }, { title: "20", value: 20 }, ], toggleTemplate: ({ firstIndex, lastIndex, }) => (_jsxs("b", { children: [firstIndex, " - ", lastIndex] })), itemCount: count + (page - 1) * max + (hasNext ? 1 : 0), page: page, perPage: max, onNextClick: (_, p) => onNextClick((p - 1) * max), onPreviousClick: (_, p) => onPreviousClick((p - 1) * max), onPerPageSelect: (_, m, f) => onPerPageSelect(f - 1, m) }) })] }) })); }; //# sourceMappingURL=ResourceToolbar.js.map