UNPKG

@novin-dev/formalite

Version:

Generate MUI form with few line of code

27 lines (24 loc) 1.26 kB
import { __assign } from 'tslib'; import React from 'react'; import { Grid, Skeleton } from '@mui/material'; import { baseMemo } from '../Bases/functions/memo.js'; import { getData } from '../../config/utils.js'; var ComponentView = function (props) { var allData = props.allData, name = props.name, formik = props.formik, loading = props.loading; var value = getData({ source: formik.values, key: name }); var onChange = function (newValue) { return formik.setFieldValue(String(name), newValue); }; var error = getData({ source: formik.errors, key: name }); var isTouched = getData({ source: formik.touched, key: name }); if (loading) { return (React.createElement(Grid, __assign({ item: true }, allData.layoutProps), React.createElement(Skeleton, { variant: "rectangular", animation: "wave", height: 55 }))); } return (React.createElement(Grid, __assign({ item: true }, allData.layoutProps), allData.render(String(name), value, onChange, error, isTouched))); }; var ComponentView$1 = React.memo(ComponentView, function (prevProps, nextProps) { return baseMemo(prevProps, nextProps); }); export { ComponentView$1 as default }; //# sourceMappingURL=ComponentView.js.map