UNPKG

@rjsf/react-bootstrap

Version:

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

22 lines 1.99 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString, } from '@rjsf/utils'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import Form from 'react-bootstrap/Form'; export default function WrapIfAdditionalTemplate({ classNames, style, children, disabled, id, label, displayLabel, onRemoveProperty, onKeyRenameBlur, rawDescription, readonly, required, schema, uiSchema, registry, }) { const { templates, translateString } = registry; // Button templates are not overridden in the uiSchema const { RemoveButton } = templates.ButtonTemplates; const keyLabel = translateString(TranslatableString.KeyLabel, [label]); const additional = ADDITIONAL_PROPERTY_FLAG in schema; const descPadding = rawDescription ? 1 : 0; const descMargin = rawDescription ? -24 : 0; if (!additional) { return (_jsx("div", { className: classNames, style: style, children: children })); } const keyId = `${id}-key`; const margin = displayLabel ? 12 + descMargin : 0; const padding = displayLabel ? 4 + descPadding : 1; return (_jsxs(Row, { className: classNames, style: style, children: [_jsx(Col, { xs: 5, children: _jsxs(Form.Group, { children: [displayLabel && _jsx(Form.Label, { htmlFor: keyId, children: keyLabel }), _jsx(Form.Control, { required: required, defaultValue: label, disabled: disabled || readonly, id: keyId, name: keyId, onBlur: !readonly ? onKeyRenameBlur : undefined, type: 'text' })] }) }), _jsx(Col, { xs: 6, children: children }), _jsx(Col, { xs: 1, className: `py-${padding} d-grid gap-2`, style: { marginTop: `${margin}px`, maxHeight: `2.5rem` }, children: _jsx(RemoveButton, { id: buttonId(id, 'remove'), className: 'rjsf-object-property-remove w-100', disabled: disabled || readonly, onClick: onRemoveProperty, uiSchema: uiSchema, registry: registry }) })] }, keyId)); } //# sourceMappingURL=WrapIfAdditionalTemplate.js.map