@navinc/base-react-components
Version:
Nav's Pattern Library
30 lines • 2.87 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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PercentInputField = 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_js_1 = __importDefault(require("../../copy.js"));
const utils_1 = require("@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"]);
(0, utils_1.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 ((0, jsx_runtime_1.jsxs)(shared_js_1.FieldWrapper, Object.assign({ className: className }, { children: [lede && (0, jsx_runtime_1.jsx)(copy_js_1.default, Object.assign({ bold: true }, { children: lede })), (0, jsx_runtime_1.jsxs)(shared_js_1.Field, Object.assign({ isInvalid: isInvalid, isVisited: true, value: value, required: required, type: type }, { children: [(0, jsx_runtime_1.jsx)(shared_js_1.PercentInput, Object.assign({ isInvalid: isInvalid, value: value != null ? value : undefined, thousandSeparator: ",", decimalScale: 0, allowNegative: false, suffix: "%", format: "###%", required: required, placeholder: "%" }, props)), (0, jsx_runtime_1.jsx)(shared_js_1.Label, Object.assign({ required: required, value: value }, { children: label }))] })), helperText && (0, jsx_runtime_1.jsx)(shared_js_1.Helper, { hasSpaceForHelper: hasSpaceForErrors, helperText: helperText }), (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}`)) }))] })));
};
exports.PercentInputField = PercentInputField;
exports.default = (0, styled_components_1.default)(PercentInputField).withConfig({ componentId: "brc-sc-1sxf7sg" }) ``;
//# sourceMappingURL=index.js.map