UNPKG

@astarte-platform/react-bootstrap

Version:

React Bootstrap theme, fields and widgets for react-jsonschema-form, powered by react-bootstrap, this is a package from a fork of official project

19 lines 1.67 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { ADDITIONAL_PROPERTY_FLAG, 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, onDropPropertyClick, onKeyChange, 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; if (!additional) { return (_jsx("div", { className: classNames, style: style, children: children })); } const handleBlur = ({ target }) => onKeyChange(target.value); const keyId = `${id}-key`; return (_jsxs(Row, { className: classNames, style: style, children: [_jsx(Col, { xs: 5, children: _jsxs(Form.Group, { children: [_jsx(Form.Label, { htmlFor: keyId, children: keyLabel }), _jsx(Form.Control, { required: required, defaultValue: label, disabled: disabled || readonly, id: keyId, name: keyId, onBlur: !readonly ? handleBlur : undefined, type: 'text' })] }) }), _jsx(Col, { xs: 5, children: children }), _jsx(Col, { xs: 2, className: 'py-4 d-grid gap-2', children: _jsx(RemoveButton, { className: 'w-100', disabled: disabled || readonly, onClick: onDropPropertyClick(label), uiSchema: uiSchema, registry: registry }) })] }, keyId)); } //# sourceMappingURL=WrapIfAdditionalTemplate.js.map