UNPKG

@navinc/base-react-components

Version:
23 lines 2.26 kB
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 { Err, Errors, Field, FieldWrapper, Helper, Label, PercentInput } from '../../form-elements/shared.js'; import { Copy } from '../../copy.js'; import { deprecationWarning } from '@navinc/utils'; const _PercentInputField = (_a) => { var { className, label, value, required, type, hasSpaceForErrors, helperText, isInvalid, errors = [], lede = '' } = _a, props = __rest(_a, ["className", "label", "value", "required", "type", "hasSpaceForErrors", "helperText", "isInvalid", "errors", "lede"]); deprecationWarning(true, `PercentInput has been deprecated and will be removed in a future version. Please refactor all uses to use vanilla-masker's \`toPattern\` function instead.`); return (_jsxs(FieldWrapper, { className: className, children: [lede && _jsx(Copy, { bold: true, children: lede }), _jsxs(Field, { isInvalid: isInvalid, isVisited: true, value: value, required: required, type: type, children: [_jsx(PercentInput, Object.assign({ isInvalid: isInvalid, value: value != null ? value : undefined, thousandSeparator: ",", decimalScale: 0, allowNegative: false, suffix: "%", format: "###%", required: required, placeholder: "%" }, props)), _jsx(Label, { required: required, value: value, children: label })] }), helperText && _jsx(Helper, { hasSpaceForHelper: hasSpaceForErrors, helperText: helperText }), _jsx(Errors, { hasSpaceForErrors: hasSpaceForErrors, children: !!errors.length && errors.map((err, i) => _jsx(Err, { children: err }, `err-${i}`)) })] })); }; export const PercentInputField = styled(_PercentInputField).withConfig({ displayName: "brc-sc-PercentInputField", componentId: "brc-sc-piytgx" }) ``; //# sourceMappingURL=index.js.map