Currency
Reference
- The
Currencycomponent provides a specialized input field for entering currency values. - It ensures that only numeric input is allowed and optionally supports decimal values.
Props
The Currency component accepts the following props:
-
allowDecimal(optional, default:true):- A boolean that determines whether decimal values are allowed in the input.
- If
true, users can enter decimal numbers (e.g.,123.45). - If
false, only whole numbers are allowed (e.g.,123).
-
value(optional):- The current value of the input field.
- This is a controlled prop, meaning the parent component manages the state of the input value.
-
onEdit(optional):- A callback function triggered whenever the input value changes.
- It receives the updated value as an argument.
-
onFocusOut(optional):- A callback function triggered when the input loses focus (blur event).
- Useful for validating or formatting the value after the user finishes editing.
-
placeholder(optional):- A string that specifies placeholder text to display when the input is empty.
-
style(optional):- An object containing custom styles to apply to the
TextBoxcomponent.
- An object containing custom styles to apply to the
-
disabled(optional):- A boolean that determines whether the input field is disabled.
- If
true, the input is read-only and cannot be interacted with.
Usage Example
function Example(pageContext) {
const { protrakComponents } = React.useContext(customWidgetContext);
const { Currency } = protrakComponents;
const [value, setValue] = useState('');
const handleEdit = (newValue) => {
setValue(newValue);
};
return (
<Currency
value={value}
onEdit={handleEdit}
placeholder="Enter amount"
/>
);
};