@jobber/components 8.26.1 → 8.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,26 +3,53 @@
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
5
5
|
`InputNumberExperimental` collects a single numeric value in a form. Reach for
|
|
6
|
-
it when the value benefits from being nudged up or down
|
|
7
|
-
durations, or counts.
|
|
6
|
+
it when the value benefits from being nudged up or down, such as quantities,
|
|
7
|
+
prices, durations, or counts.
|
|
8
8
|
|
|
9
|
-
Most fields need
|
|
10
|
-
can
|
|
9
|
+
Most fields only need the props shown below. For rare layouts the props can't
|
|
10
|
+
handle, you can build the same field from smaller pieces. See the **Implement**
|
|
11
11
|
tab.
|
|
12
12
|
|
|
13
13
|
### When to use
|
|
14
14
|
|
|
15
|
-
* The value is a number the user increments or decrements
|
|
16
|
-
|
|
17
|
-
* A stepper, min/max bounds, or number formatting would help the user
|
|
15
|
+
* The value is a number the user increments or decrements, like a quantity,
|
|
16
|
+
price, day count, or number of repetitions
|
|
17
|
+
* A stepper, min/max bounds, or number formatting would help the user
|
|
18
18
|
|
|
19
19
|
### When not to use
|
|
20
20
|
|
|
21
|
-
* The value is a sequence of digits that is never calculated with
|
|
21
|
+
* The value is a sequence of digits that is never calculated with, such as phone
|
|
22
22
|
numbers, credit-card numbers, or postal codes. A stepper adds no value there;
|
|
23
23
|
use [InputText](../InputText/InputText.md) instead.
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## Anatomy
|
|
26
|
+
|
|
27
|
+
`InputNumberExperimental` typically includes:
|
|
28
|
+
|
|
29
|
+
* Label (required): names the value the field collects
|
|
30
|
+
* Value field (required): the number the user types or steps through
|
|
31
|
+
* Stepper (optional): increment and decrement controls that change the value by
|
|
32
|
+
`step`
|
|
33
|
+
* Prefix or suffix (optional): a unit or symbol shown alongside the value, like
|
|
34
|
+
$ or kg
|
|
35
|
+
* Loading indicator (optional): replaces the stepper while background work runs
|
|
36
|
+
|
|
37
|
+
## Behavior
|
|
38
|
+
|
|
39
|
+
* The field is controlled through `value`, where a number sets the value and
|
|
40
|
+
`null` leaves it empty.
|
|
41
|
+
* `onValueCommitted` fires when the user commits a value: on blur, on Enter, or
|
|
42
|
+
when they use the stepper or arrow keys. Use `onValueChange` for per-keystroke
|
|
43
|
+
updates.
|
|
44
|
+
* The stepper buttons and the Up and Down arrow keys change the value by `step`
|
|
45
|
+
(default 1).
|
|
46
|
+
* `min` and `max` bound the value, and the stepper stops at each limit.
|
|
47
|
+
* `loading` hides the stepper and shows an indicator in its place. The field
|
|
48
|
+
stays editable, so use `readOnly` or `disabled` to lock it.
|
|
49
|
+
|
|
50
|
+
## Options
|
|
51
|
+
|
|
52
|
+
### Basic
|
|
26
53
|
|
|
27
54
|
Pass `label`, a controlled `value`, and `onValueCommitted`. Bounds (`min` /
|
|
28
55
|
`max`) and `step` are optional.
|
|
@@ -50,11 +77,9 @@ export function InputNumberExperimentalBasicExample(
|
|
|
50
77
|
}
|
|
51
78
|
```
|
|
52
79
|
|
|
53
|
-
## Options
|
|
54
|
-
|
|
55
80
|
### Prefixes and suffixes
|
|
56
81
|
|
|
57
|
-
Use `prefix`
|
|
82
|
+
Use `prefix` or `suffix` to add a unit or symbol. A suffix can be a label, an
|
|
58
83
|
icon, or a clickable icon that runs an action (give it an `ariaLabel`).
|
|
59
84
|
|
|
60
85
|
```tsx
|
|
@@ -101,7 +126,7 @@ export function InputNumberExperimentalAffixesExample() {
|
|
|
101
126
|
|
|
102
127
|
### Sizes
|
|
103
128
|
|
|
104
|
-
|
|
129
|
+
3 sizes are available. `default` fits almost every form; use `small` only in
|
|
105
130
|
tight spaces and `large` only in especially spacious layouts.
|
|
106
131
|
|
|
107
132
|
```tsx
|
|
@@ -189,8 +214,8 @@ export function InputNumberExperimentalFormattingExample() {
|
|
|
189
214
|
### Loading
|
|
190
215
|
|
|
191
216
|
`loading` shows a non-blocking indicator in the stepper's slot for background
|
|
192
|
-
work
|
|
193
|
-
|
|
217
|
+
work, like saving. The field stays editable and the stepper is hidden while
|
|
218
|
+
loading.
|
|
194
219
|
|
|
195
220
|
```tsx
|
|
196
221
|
import React, { useState } from "react";
|
|
@@ -222,25 +247,59 @@ Put the unit in the label or an affix, not both.
|
|
|
222
247
|
| Label "Weight", suffix "kg" | Label "Weight (kg)", suffix "kg" |
|
|
223
248
|
| Label "Duration", suffix "days" | Label "Duration in days", suffix "days" |
|
|
224
249
|
|
|
225
|
-
### Keep labels short and sentence
|
|
250
|
+
### Keep labels short and sentence case
|
|
226
251
|
|
|
227
252
|
| ✅ Do | ❌ Don't |
|
|
228
253
|
| -------- | ----------------------- |
|
|
229
254
|
| Quantity | Enter the quantity here |
|
|
230
255
|
| Discount | DISCOUNT % |
|
|
231
256
|
|
|
257
|
+
### Put the symbol where it's read
|
|
258
|
+
|
|
259
|
+
Use a prefix for a leading symbol and a suffix for a trailing unit, matching how
|
|
260
|
+
the value is spoken.
|
|
261
|
+
|
|
262
|
+
| ✅ Do | ❌ Don't |
|
|
263
|
+
| -------------------- | -------------------- |
|
|
264
|
+
| Prefix "$", value 40 | Suffix "$", value 40 |
|
|
265
|
+
| Suffix "%", value 15 | Prefix "%", value 15 |
|
|
266
|
+
|
|
267
|
+
### Keep validation errors helpful
|
|
268
|
+
|
|
269
|
+
When a value breaks `min` or `max`, provide helpful guidance on what values will
|
|
270
|
+
be accepted as opposed to just providing a generic error.
|
|
271
|
+
|
|
272
|
+
| ✅ Do | ❌ Don't |
|
|
273
|
+
| ------------------------------ | ------------- |
|
|
274
|
+
| Enter a value between 1 and 99 | Invalid input |
|
|
275
|
+
| Quantity can't be more than 50 | Error |
|
|
276
|
+
|
|
277
|
+
### Use numbers as opposed to spelling them
|
|
278
|
+
|
|
279
|
+
Use numerals in labels, helper text, affixes, and bounds.
|
|
280
|
+
|
|
281
|
+
| ✅ Do | ❌ Don't |
|
|
282
|
+
| ----------- | --------------- |
|
|
283
|
+
| Max 3 items | Max three items |
|
|
284
|
+
|
|
232
285
|
## Do's and Don'ts
|
|
233
286
|
|
|
287
|
+
#### Do:
|
|
288
|
+
|
|
234
289
|
* ✅ Use for values the user increments or decrements
|
|
235
|
-
* ✅ Set `min`
|
|
290
|
+
* ✅ Set `min` and `max` when the value has real bounds
|
|
236
291
|
* ✅ Use `format` for currency, percent, and decimals rather than formatting the
|
|
237
292
|
value yourself
|
|
238
|
-
*
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
293
|
+
* ✅ Use `loading` for background work so the field stays usable
|
|
294
|
+
|
|
295
|
+
#### Don't:
|
|
296
|
+
|
|
297
|
+
* ❌ Use it for digit sequences that are never calculated with, like phone or
|
|
298
|
+
credit card numbers
|
|
299
|
+
* ❌ Disable the field to communicate an error; show an `error` message instead
|
|
300
|
+
* ❌ Repeat the unit in both the label and an affix
|
|
242
301
|
|
|
243
|
-
## Accessibility
|
|
302
|
+
## Accessibility notes
|
|
244
303
|
|
|
245
304
|
The field is a native number input, so it is reachable and operable by keyboard
|
|
246
305
|
and assistive technology.
|
|
@@ -252,13 +311,13 @@ and assistive technology.
|
|
|
252
311
|
| Enter | Commits the current value |
|
|
253
312
|
| Type | Replaces the value |
|
|
254
313
|
|
|
255
|
-
Give a clickable affix a clear `ariaLabel` describing its action
|
|
256
|
-
|
|
314
|
+
Give a clickable affix a clear `ariaLabel` describing its action, like "Clear
|
|
315
|
+
value".
|
|
257
316
|
|
|
258
317
|
## Related components
|
|
259
318
|
|
|
260
|
-
* For digit sequences that are not calculated with
|
|
261
|
-
[InputText](../InputText/InputText.md).
|
|
319
|
+
* For digit sequences that are not calculated with, like phone or credit card
|
|
320
|
+
numbers, use [InputText](../InputText/InputText.md).
|
|
262
321
|
* For dates, use [InputDate](../InputDate/InputDate.md).
|
|
263
322
|
|
|
264
323
|
|
package/dist/styles.css
CHANGED
|
@@ -4176,6 +4176,11 @@ a._7BLGtYNuJOU-.zgRx3ehZ2z8-:hover {
|
|
|
4176
4176
|
line-height: 0;
|
|
4177
4177
|
}
|
|
4178
4178
|
|
|
4179
|
+
.yL7--3ni8BM- p {
|
|
4180
|
+
margin-top: 1px;
|
|
4181
|
+
margin-top: var(--space-minuscule);
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4179
4184
|
.qWsLxPjCBI8- {
|
|
4180
4185
|
display: inline-block;
|
|
4181
4186
|
margin-bottom: 4px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "8.26.
|
|
3
|
+
"version": "8.26.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -540,5 +540,5 @@
|
|
|
540
540
|
"> 1%",
|
|
541
541
|
"IE 10"
|
|
542
542
|
],
|
|
543
|
-
"gitHead": "
|
|
543
|
+
"gitHead": "7d6fff8d16519d467ff260b676141d4e15d865ee"
|
|
544
544
|
}
|