Skip to main content

Number Input

Overview

The Number Input component is a custom Perspective component that provides an enhanced interface for entering and editing numeric values. It fixes a number of issues with the default Perspective Numeric Input component and includes additional features to improve the user experience.

Props

The Number Input component has the following props:

Prop NameTypeDescriptionInput/Output
valuenumberThe current value.Both
allowNegativebooleanIf true, allows negative values.Input
allowLeadingZerosbooleanIf true, allows leading zeros.Input
decimalScalenumberThe number of decimal places to allow. If set to 0, only integers are allowed.Input
fixedDecimalScalebooleanIf true, always shows the number of decimal places specified by decimalScale, even while editing.Input
thousandSeparatorbooleanIf true, shows a thousands separator.Input
prefixstringA string to prefix the value with.Input
suffixstringA string to suffix the value with.Input
placeholderstringThe placeholder text to show when the input is empty.Input
enabledbooleanIf false, the input is disabled and cannot be interacted with.Input
readonlybooleanIf true, the input is read-only and cannot be edited.Input
alignstringThe alignment of the text in the input. Can be "left", "center", or "right". Default is "left".Input
inputBoundsobjectAn object specifying the minimum and maximum values allowed. E.g. { min: 0, max: 100 }.Input
isOutOfBoundsbooleanIndicates whether the current value is out of the specified bounds.Output
allowOutOfBoundsbooleanIf true, allows values outside of the specified bounds.Input

Notes

  • The Number Input is designed to be used in conjunction with the TamakiMES/_components/NumberInput Perspective View, which provides a complete interface for editing numbers, including a label, description, and error messages.
  • List of known bugs with the default Perspective Numeric Input component that are fixed by this component:
    • Does not have "inputmode" attribute set to "numeric", which results in incorrect virtual keyboards on mobile devices/tablets
    • Implements unconventional method to grab focus, causing an incompatibility with the Expression Editor and any other component that tracks its focus state internally
    • Does not handle integers correctly. If you set the format to Integer ('0,0'), then type in a float (e.g. '1.23') and press enter it will change the display to show just '1' but the actual value will still be '1.23'
      • Display value rounds instead of truncates, a value of '2.9' in Integer format will result in a display value of '3'
      • It allows you to type in a decimal when in Integer mode
    • Captures scroll input on certain browsers/OSes even when the component does not have focus, causing the value to change unexpectedly
    • No way to have a fixed number of decimal places, e.g. always show 2 decimal places even while editing
    • No way to have a prefix or suffix on the number, e.g. a currency symbol