Download react-page/packages/editor/src/ui/uniform-mui/AutoFields.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 927 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/packages/editor/src/ui/uniform-mui/AutoFields.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-page/packages/editor/src/ui/uniform-mui/AutoFields.tsx
-
curl -L -o AutoFields.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/packages/editor/src/ui/uniform-mui/AutoFields.tsx
927 Bytes
| import type { ComponentType } from 'react'; | |
| import { createElement } from 'react'; | |
| import { useForm } from 'uniforms'; | |
| import AutoField from './AutoField'; | |
| export type AutoFieldsProps = { | |
| autoField?: ComponentType<{ name: string }>; | |
| element?: ComponentType | string; | |
| fields?: string[]; | |
| omitFields?: string[]; | |
| showInlineError?: boolean; | |
| }; | |
| export default function AutoFields({ | |
| autoField = AutoField, | |
| element = 'div', | |
| fields, | |
| omitFields = [], | |
| showInlineError, | |
| ...props | |
| }: AutoFieldsProps) { | |
| const { schema } = useForm(); | |
| return createElement( | |
| element, | |
| props, | |
| (fields ?? schema.getSubfields()) | |
| .filter((field) => !omitFields.includes(field)) | |
| .map((field) => | |
| createElement( | |
| autoField, | |
| Object.assign( | |
| { key: field, name: field }, | |
| showInlineError === undefined ? null : { showInlineError } | |
| ) | |
| ) | |
| ) | |
| ); | |
| } | |