@reservoir0x/relay-kit-ui
Version:
Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.
42 lines • 1.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const index_js_1 = require("../primitives/index.js");
const AmountInput = ({ value, setValue, prefixSymbol, ...inputProps }) => {
return ((0, jsx_runtime_1.jsx)(index_js_1.Input, { ...inputProps, type: "text", inputMode: "decimal", autoComplete: "off", autoCorrect: "off", pattern: "^[0-9]+(\\.[0-9]*)?$", ellipsify: true, size: "large", className: "ph-no-capture", css: {
width: '100%',
background: 'none',
backgroundColor: 'transparent',
fontWeight: '600',
fontSize: 32,
px: '0 !important',
py: '1',
_focus: {
boxShadow: 'none',
outline: 'none'
},
_placeholder: {
color: 'gray12'
},
...inputProps.css
}, placeholder: inputProps.placeholder ?? '0', value: prefixSymbol ? `${prefixSymbol}${value}` : value, onChange: inputProps.onChange
? inputProps.onChange
: (e) => {
let newNumericValue = e.target.value;
if (prefixSymbol) {
if (newNumericValue.startsWith(prefixSymbol)) {
newNumericValue = newNumericValue.substring(prefixSymbol.length);
}
}
const regex = /^[0-9]+(\.[0-9]*)?$/;
if (newNumericValue === '.' || newNumericValue.includes(',')) {
setValue('0.');
}
else if (regex.test(newNumericValue) ||
newNumericValue === '') {
setValue(newNumericValue);
}
} }));
};
exports.default = AmountInput;
//# sourceMappingURL=AmountInput.js.map