@etsoo/materialui
Version:
TypeScript Material-UI Implementation
29 lines (28 loc) • 1.23 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { InputField } from "./InputField";
import { NumberUtils } from "@etsoo/shared";
import InputAdornment from "@mui/material/InputAdornment";
/**
* Number input field, for controlled only components, please see IntInputField and MoneyInputField
* @param props Props
* @returns Component
*/
export function NumberInputField(props) {
const { currency, inputStyle, min = 0, step = 1, symbol = currency
? `${currency} ${NumberUtils.getCurrencySymbol(currency)}`
: undefined, endSymbol, max = 9999999, slotProps = {}, ...rest } = props;
return (_jsx(InputField, { type: "number", slotProps: Object.assign(slotProps, {
input: {
startAdornment: symbol ? (_jsx(React.Fragment, { children: _jsx(InputAdornment, { position: "start", children: symbol }) })) : undefined,
endAdornment: endSymbol ? (_jsx(InputAdornment, { position: "end", children: endSymbol })) : undefined
},
htmlInput: {
min,
step,
max,
style: inputStyle,
inputMode: "numeric"
}
}), ...rest }));
}