UNPKG

@fremtind/jkl-feedback-react

Version:
35 lines (34 loc) 753 B
import React from "react"; import { CheckboxQuestion, RadioQuestion, TextQuestion, SmileyQuestion } from "./questions"; function getChildrenOfType(...allowedTypes) { return (children) => React.Children.map(children, (child) => { if (React.isValidElement(child) && allowedTypes.includes(child.type)) { return child; } return void 0; }); } const getQuestionFromType = (type) => { switch (type) { case "radio": return RadioQuestion; case "checkbox": return CheckboxQuestion; case "text": return TextQuestion; case "smiley": return SmileyQuestion; default: return RadioQuestion; } }; export { getChildrenOfType, getQuestionFromType }; //# sourceMappingURL=utils.js.map