@nexusui/components
Version:
These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.
2 lines (1 loc) • 1.26 kB
JavaScript
import{jsx as e}from"react/jsx-runtime";import{useMemo as o}from"react";import r from"@mui/material/Stack";import{FormCheckbox as t}from"../common/FormCheckbox/FormCheckbox.js";import{FormToggle as m}from"../common/FormToggle/FormToggle.js";import{FormSelect as l}from"../common/FormSelect/FormSelect.js";import{FormRadio as a}from"../common/FormRadio/FormRadio.js";import{FormInput as i}from"../common/FormInput/FormInput.js";const n=({type:o,id:r,label:n,name:s,rules:c,options:u=[],properties:p})=>{switch(o){case"text":return e(i,{label:n,name:s,rules:c,id:r,...p},`text-${s}`);case"radio":return e(a,{controllerProps:{defaultValue:p?.defaultValue||""},options:u,name:s,rules:c,id:r,...p},`radio-${s}`);case"select":return e(l,{label:n,name:s,rules:c,options:u,id:r,...p},`select-${s}`);case"switch":return e(m,{label:n,name:s,rules:c,controllerProps:{defaultValue:p?.defaultValue||""},id:r,...p},`switch-${s}`);case"checkbox":return e(t,{label:n,name:s,rules:c,...p},`checkbox-${s}`);default:return null}},s=t=>{const{fields:m,visible:l=!0,...a}=t,i=o((()=>m.map((o=>e(n,{...o},o.id)))),[m]);return o((()=>"function"!=typeof l?l:l()),[l])?e(r,{className:"NexusConditionalForm-root",spacing:4,...a,children:i}):null};export{s as ConditionalFormComponent};