UNPKG

@rjsf/react-bootstrap

Version:

React Bootstrap theme, fields and widgets for react-jsonschema-form, powered by react-bootstrap

22 lines 1.3 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { BsPlus } from '@react-icons/all-files/bs/BsPlus'; import IconButton, { RemoveButton } from '../IconButton'; /** The OptionalDataControlsTemplate renders one of three different states. If * there is an `onAddClick()` function, it renders the "Add" button. If there is * an `onRemoveClick()` function, it renders the "Remove" button. Otherwise it * renders the "No data found" section. All of them use the `label` as either * the `title` of buttons or simply outputting it. * * @param props - The `OptionalDataControlsTemplateProps` for the template */ export default function OptionalDataControlsTemplate(props) { const { id, registry, label, onAddClick, onRemoveClick } = props; if (onAddClick) { return (_jsx(IconButton, { id: id, registry: registry, className: 'rjsf-add-optional-data', icon: _jsx(BsPlus, {}), onClick: onAddClick, title: label, size: 'sm', variant: 'secondary' })); } else if (onRemoveClick) { return (_jsx(RemoveButton, { id: id, registry: registry, className: 'rjsf-remove-optional-data', onClick: onRemoveClick, title: label, size: 'sm', variant: 'secondary' })); } return _jsx("em", { id: id, children: label }); } //# sourceMappingURL=OptionalDataControlsTemplate.js.map