import {apply as json_logic_apply} from "json-logic-js"; import {componentsList} from "./components/components"; import {true_type_of} from "./utils"; export function ProcessOptions({options, data, target, id}) { let options_t = true_type_of(options); if (options_t === "array") { return Array.from( options.map((option_item, i) => ProcessOptions({ options: option_item, data: data, target: target, id: id + i })) ); } else if (options_t === "object") { if ( true_type_of(options.type) === "string" && (true_type_of(options.args) === "object" || true_type_of(options.items) === "array") ) { if (options.type in componentsList) { return componentsList[options.type](target, id + options.type, data, options.args); } else if (options.type === "Group") { return (
{ProcessOptions({ options: json_logic_apply(options.items, data), data: data, target: target, id: id })}
); } else { return componentsList["Default"](options.type, id + "missing"); } } else { return ProcessOptions({options: json_logic_apply(options, data), data: data, target: target, id: id}); } } }