@rjsf/core
Version:
A simple React component capable of building HTML forms out of a JSON schema.
13 lines (12 loc) • 1.64 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { buttonId, } from '@rjsf/utils';
/** The `ArrayFieldTemplateItemButtons` component is the template used to render the buttons associate3d with items of
* an array.
*
* @param props - The `ArrayFieldItemButtonsTemplateProps` props for the component
*/
export default function ArrayFieldItemButtonsTemplate(props) {
const { disabled, hasCopy, hasMoveDown, hasMoveUp, hasRemove, fieldPathId, onCopyItem, onRemoveItem, onMoveDownItem, onMoveUpItem, readonly, registry, uiSchema, } = props;
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
return (_jsxs(_Fragment, { children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { id: buttonId(fieldPathId, 'moveUp'), className: 'rjsf-array-item-move-up', disabled: disabled || readonly || !hasMoveUp, onClick: onMoveUpItem, uiSchema: uiSchema, registry: registry })), (hasMoveUp || hasMoveDown) && (_jsx(MoveDownButton, { id: buttonId(fieldPathId, 'moveDown'), className: 'rjsf-array-item-move-down', disabled: disabled || readonly || !hasMoveDown, onClick: onMoveDownItem, uiSchema: uiSchema, registry: registry })), hasCopy && (_jsx(CopyButton, { id: buttonId(fieldPathId, 'copy'), className: 'rjsf-array-item-copy', disabled: disabled || readonly, onClick: onCopyItem, uiSchema: uiSchema, registry: registry })), hasRemove && (_jsx(RemoveButton, { id: buttonId(fieldPathId, 'remove'), className: 'rjsf-array-item-remove', disabled: disabled || readonly, onClick: onRemoveItem, uiSchema: uiSchema, registry: registry }))] }));
}