UNPKG

@navinc/base-react-components

Version:
31 lines 2.9 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CurrencyInputField = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const styled_components_1 = __importDefault(require("styled-components")); const shared_js_1 = require("../../form-elements/shared.js"); const copy_1 = __importDefault(require("../../copy")); const CurrencyInputField = (_a) => { var { className, errors = [], hasSpaceForErrors, isInvalid, isStatic, label, lede = '', placeholder, required, touched, type, value } = _a, props = __rest(_a, ["className", "errors", "hasSpaceForErrors", "isInvalid", "isStatic", "label", "lede", "placeholder", "required", "touched", "type", "value"]); console.warn(`[Deprecation]: CurrencyInput has been deprecated and will be removed in a future version. Please refactor all uses to use vanilla-masker's \`toMoney\` function instead.'`); /* isStatic to be used to overcome auto-populated fields that do not read as values or placeholders */ const isVisited = touched || value || placeholder || isStatic; return ((0, jsx_runtime_1.jsxs)(shared_js_1.FieldWrapper, Object.assign({ className: className }, { children: [lede && (0, jsx_runtime_1.jsx)(copy_1.default, Object.assign({ bold: true }, { children: lede }), void 0), (0, jsx_runtime_1.jsxs)(shared_js_1.Field, Object.assign({ isVisited: isVisited, isInvalid: isInvalid, value: value, required: required, type: type }, { children: [(0, jsx_runtime_1.jsx)(shared_js_1.CurrencyInput, Object.assign({ isInvalid: isInvalid, value: value != null ? value : undefined, thousandSeparator: ",", decimalScale: 0, prefix: "$", required: required, onValueChange: props.onChange, placeholder: "$" }, props), void 0), (0, jsx_runtime_1.jsx)(shared_js_1.Label, Object.assign({ required: required, value: value }, { children: label }), void 0)] }), void 0), (0, jsx_runtime_1.jsx)(shared_js_1.Errors, Object.assign({ hasSpaceForErrors: hasSpaceForErrors }, { children: !!errors.length && errors.map((err, i) => (0, jsx_runtime_1.jsx)(shared_js_1.Err, { children: err }, `err-${i}`)) }), void 0)] }), void 0)); }; exports.CurrencyInputField = CurrencyInputField; exports.default = (0, styled_components_1.default)(CurrencyInputField) ``; //# sourceMappingURL=index.js.map