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

46 lines 2.57 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx } from "react/jsx-runtime"; import { MenuToggle, Select, SelectList, } from "@patternfly/react-core"; import { Children, useRef, useState } from "react"; import { propertyToString } from "../../ui-shared/select/KeycloakSelect"; export const SingleSelect = (_a) => { var { toggleId, onToggle, onSelect, selections, isOpen, menuAppendTo, direction, width, maxHeight, toggleIcon, className, children } = _a, props = __rest(_a, ["toggleId", "onToggle", "onSelect", "selections", "isOpen", "menuAppendTo", "direction", "width", "maxHeight", "toggleIcon", "className", "children"]); const [open, setOpen] = useState(false); const ref = useRef(); const toggle = () => { setOpen(!open); onToggle(!open); }; const append = () => { var _a; if (menuAppendTo === "parent") { return ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.parentElement) || "inline"; } return "inline"; }; const childArray = Children.toArray(children); return (_jsx(Select, Object.assign({ ref: ref, maxMenuHeight: propertyToString(maxHeight), isScrollable: true, popperProps: { appendTo: append(), direction, width: propertyToString(width), } }, props, { onClick: toggle, onOpenChange: () => setOpen(false), selected: selections, onSelect: (_, value) => { onSelect === null || onSelect === void 0 ? void 0 : onSelect(value || ""); toggle(); }, toggle: (ref) => { var _a; return (_jsx(MenuToggle, { id: toggleId, ref: ref, className: className, onClick: toggle, isExpanded: isOpen, "aria-label": props["aria-label"], icon: toggleIcon, isFullWidth: true, children: ((_a = childArray.find((c) => c.props.value === selections)) === null || _a === void 0 ? void 0 : _a.props.children) || selections || props["aria-label"] })); }, isOpen: isOpen, children: _jsx(SelectList, { children: children }) }))); }; //# sourceMappingURL=SingleSelect.js.map