UNPKG

@rjsf/material-ui

Version:

Material UI 4 theme, fields and widgets for react-jsonschema-form

21 lines 1.98 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import Box from '@material-ui/core/Box'; import Grid from '@material-ui/core/Grid'; import Paper from '@material-ui/core/Paper'; /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array. * * @param props - The `ArrayFieldTemplateItemType` props for the component */ export default function ArrayFieldItemTemplate(props) { const { children, disabled, hasToolbar, hasCopy, hasMoveDown, hasMoveUp, hasRemove, index, onCopyIndexClick, onDropIndexClick, onReorderClick, readonly, uiSchema, registry, } = props; const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates; const btnStyle = { flex: 1, paddingLeft: 6, paddingRight: 6, fontWeight: 'bold', minWidth: 0, }; return (_jsxs(Grid, { container: true, alignItems: 'center', children: [_jsx(Grid, { item: true, xs: true, style: { overflow: 'auto' }, children: _jsx(Box, { mb: 2, children: _jsx(Paper, { elevation: 2, children: _jsx(Box, { p: 2, children: children }) }) }) }), hasToolbar && (_jsxs(Grid, { item: true, children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { style: btnStyle, disabled: disabled || readonly || !hasMoveUp, onClick: onReorderClick(index, index - 1), uiSchema: uiSchema, registry: registry })), (hasMoveUp || hasMoveDown) && (_jsx(MoveDownButton, { style: btnStyle, disabled: disabled || readonly || !hasMoveDown, onClick: onReorderClick(index, index + 1), uiSchema: uiSchema, registry: registry })), hasCopy && (_jsx(CopyButton, { style: btnStyle, disabled: disabled || readonly, onClick: onCopyIndexClick(index), uiSchema: uiSchema, registry: registry })), hasRemove && (_jsx(RemoveButton, { style: btnStyle, disabled: disabled || readonly, onClick: onDropIndexClick(index), uiSchema: uiSchema, registry: registry }))] }))] })); } //# sourceMappingURL=ArrayFieldItemTemplate.js.map