UNPKG

@xgovformbuilder/govuk-react-jsx

Version:

> This package is no longer maintained and will not receive updates bringing it beyond govuk-frontend 4.0.1. If you are using this in your project the simplest way forward is to copy and paste the components from here into your project allowing you to kee

49 lines (45 loc) 1.97 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["className", "errorMessage", "formGroup", "hint", "label", "aria-describedby", "id"]; import React from 'react'; import { ErrorMessage, Hint, Label } from '../..'; var FileUpload = /*#__PURE__*/React.forwardRef(function (props, ref) { var className = props.className, errorMessage = props.errorMessage, formGroup = props.formGroup, hint = props.hint, label = props.label, describedBy = props['aria-describedby'], id = props.id, attributes = _objectWithoutProperties(props, _excluded); var hintComponent; var errorMessageComponent; var describedByValue = describedBy || ''; if (hint) { var hintId = "".concat(props.id, "-hint"); describedByValue += " ".concat(hintId); hintComponent = /*#__PURE__*/React.createElement(Hint, _extends({}, props.hint, { id: hintId })); } if (errorMessage) { var errorId = "".concat(id, "-error"); describedByValue += " ".concat(errorId); errorMessageComponent = /*#__PURE__*/React.createElement(ErrorMessage, _extends({}, errorMessage, { id: errorId })); } return /*#__PURE__*/React.createElement("div", { className: "govuk-form-group".concat(errorMessage ? ' govuk-form-group--error' : '', " ").concat((formGroup === null || formGroup === void 0 ? void 0 : formGroup.className) || '') }, /*#__PURE__*/React.createElement(Label, _extends({}, label, { htmlFor: id })), hintComponent, errorMessageComponent, /*#__PURE__*/React.createElement("input", _extends({}, attributes, { id: id, ref: ref, className: "govuk-file-upload ".concat(className || '').concat(errorMessage ? ' govuk-file-upload--error' : ''), type: "file", "aria-describedby": describedByValue || null }))); }); FileUpload.displayName = 'FileUpload'; export { FileUpload };