@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
22 lines • 1.67 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { KeycloakSelect } from "../../../ui-shared";
import { FormGroup, SelectOption } from "@patternfly/react-core";
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { useServerInfo } from "../../../context/server-info/ServerInfoProvider";
import useToggle from "../../../utils/useToggle";
export const ValidatorSelect = ({ selectedValidators, onChange, }) => {
var _a;
const { t } = useTranslation();
const allValidator = ((_a = useServerInfo().componentTypes) === null || _a === void 0 ? void 0 : _a["org.keycloak.validate.Validator"]) || [];
const validators = useMemo(() => allValidator.filter(({ id }) => !selectedValidators.includes(id)), [selectedValidators]);
const [open, toggle] = useToggle();
const [value, setValue] = useState();
return (_jsx(FormGroup, { label: t("validatorType"), fieldId: "validator", children: _jsx(KeycloakSelect, { toggleId: "validator", onToggle: toggle, onSelect: (value) => {
const option = value;
onChange(option);
setValue(option);
toggle();
}, selections: value === null || value === void 0 ? void 0 : value.id, variant: "single", "aria-label": t("selectOne"), isOpen: open, placeholderText: t("choose"), menuAppendTo: "parent", maxHeight: 300, children: validators.map((option) => (_jsx(SelectOption, { selected: (value === null || value === void 0 ? void 0 : value.id) === option.id, value: option, description: option.helpText, children: option.id }, option.id))) }) }));
};
//# sourceMappingURL=ValidatorSelect.js.map