UNPKG

@indec/form-builder

Version:

Form builder

53 lines (52 loc) 2.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _hasFormikErrorsAndWarnings = _interopRequireDefault(require("../../utils/hasFormikErrorsAndWarnings")); var _Icons = require("../Icons"); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } function InputLabel(_ref) { var label = _ref.label, form = _ref.form, field = _ref.field, disabled = _ref.disabled, _ref$warnings = _ref.warnings, warnings = _ref$warnings === void 0 ? {} : _ref$warnings; var _hasFormikErrorsAndWa = (0, _hasFormikErrorsAndWarnings["default"])({ form: form, field: field, warnings: warnings }), hasWarning = _hasFormikErrorsAndWa.hasWarning, hasError = _hasFormikErrorsAndWa.hasError; var labelNumber = label.number ? "".concat(label.number, " - ") : ''; return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { className: "fb:flex fb:flex-row fb:gap-4", "data-testid": "input-label", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: "fb:flex fb:flex-row fb:mb-2 fb:items-center ".concat(!disabled ? 'fb:opacity-100' : 'fb:opacity-30'), children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", { className: "fb:font-bold fb:text-[17px]", children: ["".concat(labelNumber).concat(label.text), " ", hasError && '*'] }) }), hasError && !disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.ErrorIcon, { className: "fb:w-6 fb:h-6 fb:text-red-600", "data-testid": "error-icon" }) }), hasWarning && !disabled && !hasError && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.ExclamationIcon, { className: "fb:w-6 fb:h-6 fb:text-yellow-600", "data-testid": "warning-icon" }) })] }), label.introduction && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", { className: "fb:text-gray-500 fb:font-bold", children: label.introduction })] }); } var _default = exports["default"] = InputLabel;