Repository navigation
Number component? #2903
Unanswered
holmesshanea
asked this question in
Feature Requests
Replies: 1 comment
|
Example: |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
How about a Number component? A numeric input component with inline spin buttons and expression evaluation?
Example 1: A quantity field with inline spin buttons. In a shopping cart, a customer can type 3 or tap the − / + buttons to adjust the quantity one item at a time. The field stops at the available stock.
Example 2: A budget field with expression evaluation. In an expense form, a user enters 4 * 25 + 12.50 for four $25 items and $12.50 in shipping. When they press Enter, the field displays 112.50 and saves that amount. Less work for users. They can type 3 * 12 + 6 directly into the field, then use the inline − / + buttons or arrow keys to make a small adjustment. The calculation stays in the form. Typing 2 * (3 + 4) and pressing Enter displays 14. ↑ / ↓ and the inline buttons change it by 0.25. Escape restores the last committed value. If an expression is invalid, the field keeps the draft and shows an error so the user can correct it.
Component =, . Use a Flux input group for the text field and inline − / + buttons, and evaluate expressions locally. Livewire receives the committed number.
The parser allows decimal numbers, parentheses, unary signs, and +, -, *, and / with standard precedence. It evaluates only those arithmetic operations. Round committed values to decimals places, store an empty field as null, reject typed values outside the range, and stop stepping at the bounds.
All reactions