35 lines
974 B
TypeScript
35 lines
974 B
TypeScript
import type { Props } from './types';
|
|
import { mapFieldTypeElement } from '@/config/elements';
|
|
import { ElementContainer } from 'ui';
|
|
|
|
export function Elements({ data, metaData }: Props) {
|
|
return (
|
|
<div className="mt-2 grid auto-rows-auto grid-cols-1 gap-2 gap-x-4 md:grid-cols-2 lg:grid-cols-3">
|
|
{Object.keys(metaData).map((name) => {
|
|
const { fieldType, label, max, min = 0, visible, ...props } = metaData[name];
|
|
|
|
if (!visible) return false;
|
|
|
|
const Element = mapFieldTypeElement[fieldType];
|
|
|
|
return (
|
|
<ElementContainer
|
|
key={name}
|
|
id={name}
|
|
title={fieldType === 'CHECKBOX' ? '' : metaData[name].label}
|
|
>
|
|
<Element
|
|
id={name}
|
|
defaultValue={data[name]}
|
|
title={label}
|
|
min={min}
|
|
max={max}
|
|
{...props}
|
|
/>
|
|
</ElementContainer>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|