@navinc/base-react-components
Version:
Nav's Pattern Library
25 lines • 2.39 kB
JavaScript
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;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import styled from 'styled-components';
import { CurrencyInput, Label, FieldWrapper, Field, Errors, Err } from '../../form-elements/shared.js';
import Copy from '../../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 (_jsxs(FieldWrapper, Object.assign({ className: className }, { children: [lede && _jsx(Copy, Object.assign({ bold: true }, { children: lede }), void 0), _jsxs(Field, Object.assign({ isVisited: isVisited, isInvalid: isInvalid, value: value, required: required, type: type }, { children: [_jsx(CurrencyInput, Object.assign({ isInvalid: isInvalid, value: value != null ? value : undefined, thousandSeparator: ",", decimalScale: 0, prefix: "$", required: required, onValueChange: props.onChange, placeholder: "$" }, props), void 0), _jsx(Label, Object.assign({ required: required, value: value }, { children: label }), void 0)] }), void 0), _jsx(Errors, Object.assign({ hasSpaceForErrors: hasSpaceForErrors }, { children: !!errors.length && errors.map((err, i) => _jsx(Err, { children: err }, `err-${i}`)) }), void 0)] }), void 0));
};
export default styled(CurrencyInputField) ``;
export { CurrencyInputField };
//# sourceMappingURL=index.js.map