@jobber/components-native 0.107.1 → 0.107.2-JOB-171968-266117e.31
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.
- package/dist/docs/AtlantisThemeContext/AtlantisThemeContext.md +40 -0
- package/dist/docs/Chip/Chip.md +2 -2
- package/dist/docs/ContentOverlay/ContentOverlay.md +4 -0
- package/dist/docs/Form/Form.md +5 -5
- package/dist/docs/Icon/Icon.md +61 -53
- package/dist/docs/InputNumber/InputNumber.md +400 -10
- package/dist/docs/InputTime/InputTime.md +8 -0
- package/dist/docs/ProgressBar/ProgressBar.md +9 -0
- package/dist/docs/empty-states/empty-states.md +29 -0
- package/dist/docs/index.md +0 -1
- package/dist/package.json +3 -3
- package/dist/src/ContentOverlay/ContentOverlay.js +15 -10
- package/dist/src/ContentOverlay/computeContentOverlayBehavior.js +7 -4
- package/dist/src/ContentOverlay/computeContentOverlayBehavior.test.js +31 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +1 -1
- package/dist/types/src/ContentOverlay/computeContentOverlayBehavior.d.ts +1 -0
- package/dist/types/src/ContentOverlay/types.d.ts +23 -0
- package/package.json +3 -3
- package/src/ContentOverlay/ContentOverlay.tsx +57 -33
- package/src/ContentOverlay/computeContentOverlayBehavior.test.ts +40 -0
- package/src/ContentOverlay/computeContentOverlayBehavior.ts +8 -4
- package/src/ContentOverlay/types.ts +28 -0
- package/dist/docs/Select/Select.md +0 -219
|
@@ -116,6 +116,46 @@ function ThemedComponent() {
|
|
|
116
116
|
}
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
+
### Cross-tab theme sync (Web Only)
|
|
120
|
+
|
|
121
|
+
The provider can keep the theme in sync across a user's open browser tabs. This
|
|
122
|
+
is opt-in: pass the `localStorage` key your app writes to as the `storageKey`
|
|
123
|
+
prop. The provider then listens for
|
|
124
|
+
[`storage` events](https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event)
|
|
125
|
+
on that key and applies theme changes from other tabs. The `storage` event fires
|
|
126
|
+
only in tabs *other* than the one that wrote the value, so there's no feedback
|
|
127
|
+
loop.
|
|
128
|
+
|
|
129
|
+
**Your app is responsible for writing to `localStorage`** when the theme changes
|
|
130
|
+
— Atlantis only handles the listen-and-react side.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
<AtlantisThemeContextProvider storageKey="my_app_theme">
|
|
134
|
+
<ThemedComponent />
|
|
135
|
+
</AtlantisThemeContextProvider>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
// Theme toggle — write to the same key after calling updateTheme
|
|
140
|
+
import { updateTheme } from "@jobber/components/AtlantisThemeContext";
|
|
141
|
+
|
|
142
|
+
function toggleTheme(newTheme: "light" | "dark") {
|
|
143
|
+
updateTheme(newTheme); // updates all providers in this tab immediately
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
localStorage.setItem("my_app_theme", newTheme); // signals other tabs
|
|
147
|
+
} catch {
|
|
148
|
+
// localStorage unavailable (e.g. private mode) — degrades gracefully
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Omit `storageKey` and no `storage` listener is added, keeping the previous
|
|
154
|
+
within-tab-only behavior. Multiple dynamic providers on the same page all share
|
|
155
|
+
the same internal store, so a single provider with a `storageKey` is enough — a
|
|
156
|
+
cross-tab signal updates every dynamic provider at once. Providers mounted with
|
|
157
|
+
`dangerouslyOverrideTheme` are unaffected.
|
|
158
|
+
|
|
119
159
|
### Forcing a theme for an AtlantisThemeContextProvider
|
|
120
160
|
|
|
121
161
|
In some scenarios you may want to force a theme for specific components
|
package/dist/docs/Chip/Chip.md
CHANGED
|
@@ -238,8 +238,8 @@ export function ChipInvalidExample(
|
|
|
238
238
|
single-select, multi-select, and add/dismiss functionality "out of the box"
|
|
239
239
|
* [FilterPicker](/components/FilterPicker) is most commonly triggered by a Chip,
|
|
240
240
|
but is a separate component
|
|
241
|
-
* [
|
|
242
|
-
presents as a form element and should be preferred in forms
|
|
241
|
+
* [LegacySelect](/components/LegacySelect) is a simpler single-select "dropdown"
|
|
242
|
+
that presents as a form element and should be preferred in forms
|
|
243
243
|
* [RadioGroup](/components/RadioGroup) should be used to allow the user to
|
|
244
244
|
select "one-of-many" items (single-select) and the labels for the items are
|
|
245
245
|
longer than 1 or 2 words.
|
|
@@ -50,6 +50,9 @@ where it will be a maximum width of 640px and be centered on the screen.
|
|
|
50
50
|
| `children` | `ReactNode` | Yes | — | Content to be passed into the overlay |
|
|
51
51
|
| `accessibilityLabel` | `string` | No | `"Close {title} modal"` | Optional accessibilityLabel describing the overlay. This will read out when the overlay is opened. |
|
|
52
52
|
| `adjustToContentHeight` | `boolean` | No | `false` | If true, automatically adjusts the overlay height to the content height. This will disable the ability to drag the ov... |
|
|
53
|
+
| `allowDragWithBeforeExit` | `boolean` | No | `false` | When `true`, `onBeforeExit` intercepts the dismiss button and back press but does not disable drag. Drag-to-dismiss b... |
|
|
54
|
+
| `enableContentPanningGesture` | `boolean` | No | — | Whether pan on the content area drags the sheet. Set `false` to let nested scrollables own the gesture. Defaults to t... |
|
|
55
|
+
| `enablePanDownToClose` | `boolean` | No | — | Whether panning down on the content area closes the sheet. Set false to prevent the sheet from being closed by pannin... |
|
|
53
56
|
| `fullScreen` | `boolean` | No | `false` | Force overlay height to fill the screen. Width not impacted. |
|
|
54
57
|
| `isDraggable` | `boolean` | No | `true` | If false, hides the handle and turns off dragging. |
|
|
55
58
|
| `keyboardShouldPersistTaps` | `boolean` | No | `false` | Allows taps to be registered behind keyboard if enabled |
|
|
@@ -61,4 +64,5 @@ where it will be a maximum width of 640px and be centered on the screen.
|
|
|
61
64
|
| `ref` | `Ref<{ open?: () => void; close?: () => void; }>` | No | — | Ref to the content overlay component. |
|
|
62
65
|
| `scrollEnabled` | `boolean` | No | `false` | Enables scrolling in the content body of overlay |
|
|
63
66
|
| `showDismiss` | `boolean` | No | `false` | Display the dismiss button in the header of the overlay. |
|
|
67
|
+
| `snapPoints` | `(string | number)[]` | No | — | Explicit snap points for the overlay (percentages or pixel values). When provided, `adjustToContentHeight` is ignored... |
|
|
64
68
|
| `title` | `string` | No | — | Title of overlay, appears in the header next to the close button. |
|
package/dist/docs/Form/Form.md
CHANGED
|
@@ -18,11 +18,11 @@ have a `value` and `onChange` prop.
|
|
|
18
18
|
### Inputs
|
|
19
19
|
|
|
20
20
|
Form can accept various inputs and selection elements such as (but not limited
|
|
21
|
-
to) [InputText](../InputText/InputText.md),
|
|
22
|
-
[
|
|
23
|
-
[Chips](/components/Chips). They should be
|
|
24
|
-
indicate grouping when relevant, and groups
|
|
25
|
-
using ContentSection.
|
|
21
|
+
to) [InputText](../InputText/InputText.md),
|
|
22
|
+
[LegacySelect](/components/LegacySelect), [Switch](../Switch/Switch.md),
|
|
23
|
+
[Checkbox](../Checkbox/Checkbox.md), and [Chips](/components/Chips). They should be
|
|
24
|
+
placed [Cards](../Card/Card.md) to indicate grouping when relevant, and groups
|
|
25
|
+
of Cards can be spaced appropriately using ContentSection.
|
|
26
26
|
|
|
27
27
|
### Save Button label
|
|
28
28
|
|
package/dist/docs/Icon/Icon.md
CHANGED
|
@@ -417,6 +417,7 @@ export function IconSizesExample() {
|
|
|
417
417
|
| | `future` |
|
|
418
418
|
| | `history` |
|
|
419
419
|
| | `import` |
|
|
420
|
+
| | `merge` |
|
|
420
421
|
| | `redo` |
|
|
421
422
|
| | `remove` |
|
|
422
423
|
| | `search` |
|
|
@@ -428,59 +429,66 @@ export function IconSizesExample() {
|
|
|
428
429
|
|
|
429
430
|
### Other
|
|
430
431
|
|
|
431
|
-
| Icon | `Name`
|
|
432
|
-
| :--- |
|
|
433
|
-
| | `apps`
|
|
434
|
-
| | `at`
|
|
435
|
-
| | `camera`
|
|
436
|
-
| | `checkmark`
|
|
437
|
-
| | `checkmarkCircle`
|
|
438
|
-
| | `circle`
|
|
439
|
-
| | `cog`
|
|
440
|
-
| | `dashboard`
|
|
441
|
-
| | `desktop`
|
|
442
|
-
| | `website`
|
|
443
|
-
| | `eye`
|
|
444
|
-
| | `eyeCrossed`
|
|
445
|
-
| | `flash`
|
|
446
|
-
| | `flashAuto`
|
|
447
|
-
| | `flashOff`
|
|
448
|
-
| | `gift`
|
|
449
|
-
| | `grid`
|
|
450
|
-
| | `happyFace`
|
|
451
|
-
| | `headset`
|
|
452
|
-
| | `home`
|
|
453
|
-
| | `link`
|
|
454
|
-
| | `loadingCheck`
|
|
455
|
-
| | `lock`
|
|
456
|
-
| | `logout`
|
|
457
|
-
| | `measurement`
|
|
458
|
-
| | `menu`
|
|
459
|
-
| | `microphone`
|
|
460
|
-
| | `microphoneMuted`
|
|
461
|
-
| | `mobile`
|
|
462
|
-
| | `more`
|
|
463
|
-
| | `number`
|
|
464
|
-
| | `
|
|
465
|
-
| | `
|
|
466
|
-
| | `
|
|
467
|
-
| | `
|
|
468
|
-
| | `
|
|
469
|
-
| | `
|
|
470
|
-
| | `
|
|
471
|
-
| | `
|
|
472
|
-
| | `
|
|
473
|
-
| | `
|
|
474
|
-
| | `
|
|
475
|
-
| | `
|
|
476
|
-
| | `
|
|
477
|
-
| | `
|
|
478
|
-
| | `
|
|
479
|
-
| | `
|
|
480
|
-
| | `
|
|
481
|
-
| | `
|
|
482
|
-
| | `
|
|
483
|
-
| | `
|
|
432
|
+
| Icon | `Name` |
|
|
433
|
+
| :--- | :------------------ |
|
|
434
|
+
| | `apps` |
|
|
435
|
+
| | `at` |
|
|
436
|
+
| | `camera` |
|
|
437
|
+
| | `checkmark` |
|
|
438
|
+
| | `checkmarkCircle` |
|
|
439
|
+
| | `circle` |
|
|
440
|
+
| | `cog` |
|
|
441
|
+
| | `dashboard` |
|
|
442
|
+
| | `desktop` |
|
|
443
|
+
| | `website` |
|
|
444
|
+
| | `eye` |
|
|
445
|
+
| | `eyeCrossed` |
|
|
446
|
+
| | `flash` |
|
|
447
|
+
| | `flashAuto` |
|
|
448
|
+
| | `flashOff` |
|
|
449
|
+
| | `gift` |
|
|
450
|
+
| | `grid` |
|
|
451
|
+
| | `happyFace` |
|
|
452
|
+
| | `headset` |
|
|
453
|
+
| | `home` |
|
|
454
|
+
| | `link` |
|
|
455
|
+
| | `loadingCheck` |
|
|
456
|
+
| | `lock` |
|
|
457
|
+
| | `logout` |
|
|
458
|
+
| | `measurement` |
|
|
459
|
+
| | `menu` |
|
|
460
|
+
| | `microphone` |
|
|
461
|
+
| | `microphoneMuted` |
|
|
462
|
+
| | `mobile` |
|
|
463
|
+
| | `more` |
|
|
464
|
+
| | `number` |
|
|
465
|
+
| | `numpad` |
|
|
466
|
+
| | `offline` |
|
|
467
|
+
| | `phone` |
|
|
468
|
+
| | `phoneCall` |
|
|
469
|
+
| | `phoneDisconnected` |
|
|
470
|
+
| | `phoneEnd` |
|
|
471
|
+
| | `phoneIncoming` |
|
|
472
|
+
| | `phoneOutgoing` |
|
|
473
|
+
| | `pinned` |
|
|
474
|
+
| | `presentation` |
|
|
475
|
+
| | `priceTag` |
|
|
476
|
+
| | `quickbooks` |
|
|
477
|
+
| | `reports` |
|
|
478
|
+
| | `shape` |
|
|
479
|
+
| | `sidebar` |
|
|
480
|
+
| | `signature` |
|
|
481
|
+
| | `sneaker` |
|
|
482
|
+
| | `sparkles` |
|
|
483
|
+
| | `speaker` |
|
|
484
|
+
| | `sprout` |
|
|
485
|
+
| | `starburst` |
|
|
486
|
+
| | `sun` |
|
|
487
|
+
| | `tableColumns` |
|
|
488
|
+
| | `thumbsDown` |
|
|
489
|
+
| | `thumbsUp` |
|
|
490
|
+
| | `unPinned` |
|
|
491
|
+
| | `xero` |
|
|
484
492
|
|
|
485
493
|
### Legacy
|
|
486
494
|
|
|
@@ -1,20 +1,410 @@
|
|
|
1
1
|
# InputNumber
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Summary
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`InputNumber` collects a single numeric value in a form. Reach for it when the
|
|
6
|
+
value benefits from being nudged up or down, such as quantities, prices,
|
|
7
|
+
durations, or counts.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
tab.
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
using a number input. For example, phone numbers and credit card numbers provide
|
|
12
|
-
no value to the user by offering an incrementer.
|
|
13
|
+
### When to use
|
|
13
14
|
|
|
14
|
-
|
|
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
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
* The value is a sequence of digits that is never calculated with, such as phone
|
|
22
|
+
numbers, credit-card numbers, or postal codes. A stepper adds no value there;
|
|
23
|
+
use [InputText](../InputText/InputText.md) instead.
|
|
24
|
+
|
|
25
|
+
## Anatomy
|
|
26
|
+
|
|
27
|
+
`InputNumber` 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
|
|
53
|
+
|
|
54
|
+
Pass `label`, a controlled `value`, and `onValueCommitted`. Bounds (`min` /
|
|
55
|
+
`max`) and `step` are optional.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import React, { useState } from "react";
|
|
59
|
+
import type { InputNumberProps } from "@jobber/components";
|
|
60
|
+
import { InputNumber } from "@jobber/components";
|
|
61
|
+
|
|
62
|
+
export function InputNumberBasicExample(props: Partial<InputNumberProps>) {
|
|
63
|
+
const [value, setValue] = useState<number | null>(3);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<InputNumber
|
|
67
|
+
label="Quantity"
|
|
68
|
+
min={0}
|
|
69
|
+
max={100}
|
|
70
|
+
{...props}
|
|
71
|
+
value={value}
|
|
72
|
+
onValueCommitted={setValue}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Prefixes and suffixes
|
|
79
|
+
|
|
80
|
+
Use `prefix` or `suffix` to add a unit or symbol. A suffix can be a label, an
|
|
81
|
+
icon, or a clickable icon that runs an action (give it an `ariaLabel`).
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import React, { useState } from "react";
|
|
85
|
+
import { InputNumber } from "@jobber/components";
|
|
86
|
+
import { Content } from "@jobber/components/Content";
|
|
87
|
+
|
|
88
|
+
export function InputNumberAffixesExample() {
|
|
89
|
+
const [price, setPrice] = useState<number | null>(42);
|
|
90
|
+
const [days, setDays] = useState<number | null>(7);
|
|
91
|
+
const [reps, setReps] = useState<number | null>(3);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Content>
|
|
95
|
+
<InputNumber
|
|
96
|
+
label="Price"
|
|
97
|
+
prefix={{ label: "$" }}
|
|
98
|
+
suffix={{ label: "USD" }}
|
|
99
|
+
value={price}
|
|
100
|
+
onValueCommitted={setPrice}
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<InputNumber
|
|
104
|
+
label="Follow-up in"
|
|
105
|
+
suffix={{ icon: "calendar", label: "days" }}
|
|
106
|
+
value={days}
|
|
107
|
+
onValueCommitted={setDays}
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
<InputNumber
|
|
111
|
+
label="Repetitions"
|
|
112
|
+
suffix={{
|
|
113
|
+
icon: "remove",
|
|
114
|
+
ariaLabel: "Clear value",
|
|
115
|
+
onClick: () => setReps(null),
|
|
116
|
+
}}
|
|
117
|
+
value={reps}
|
|
118
|
+
onValueCommitted={setReps}
|
|
119
|
+
/>
|
|
120
|
+
</Content>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Sizes
|
|
126
|
+
|
|
127
|
+
3 sizes are available. `default` fits almost every form; use `small` only in
|
|
128
|
+
tight spaces and `large` only in especially spacious layouts.
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import React, { useState } from "react";
|
|
132
|
+
import { InputNumber } from "@jobber/components";
|
|
133
|
+
import { Content } from "@jobber/components/Content";
|
|
134
|
+
|
|
135
|
+
export function InputNumberSizesExample() {
|
|
136
|
+
const [small, setSmall] = useState<number | null>(42);
|
|
137
|
+
const [base, setBase] = useState<number | null>(42);
|
|
138
|
+
const [large, setLarge] = useState<number | null>(42);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Content>
|
|
142
|
+
<InputNumber
|
|
143
|
+
label="Small"
|
|
144
|
+
size="small"
|
|
145
|
+
suffix={{ label: "items" }}
|
|
146
|
+
value={small}
|
|
147
|
+
onValueCommitted={setSmall}
|
|
148
|
+
/>
|
|
149
|
+
<InputNumber
|
|
150
|
+
label="Default"
|
|
151
|
+
size="default"
|
|
152
|
+
suffix={{ label: "items" }}
|
|
153
|
+
value={base}
|
|
154
|
+
onValueCommitted={setBase}
|
|
155
|
+
/>
|
|
156
|
+
<InputNumber
|
|
157
|
+
label="Large"
|
|
158
|
+
size="large"
|
|
159
|
+
suffix={{ label: "items" }}
|
|
160
|
+
value={large}
|
|
161
|
+
onValueCommitted={setLarge}
|
|
162
|
+
/>
|
|
163
|
+
</Content>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Formatting
|
|
169
|
+
|
|
170
|
+
`format` takes any `Intl.NumberFormatOptions` and controls only how the value is
|
|
171
|
+
displayed; the committed value stays a plain number. See the **Implement** tab
|
|
172
|
+
for how percent and currency values map to the underlying number.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import React, { useState } from "react";
|
|
176
|
+
import { InputNumber } from "@jobber/components";
|
|
177
|
+
import { Content } from "@jobber/components/Content";
|
|
178
|
+
|
|
179
|
+
export function InputNumberFormattingExample() {
|
|
180
|
+
const [currency, setCurrency] = useState<number | null>(1234.5);
|
|
181
|
+
const [percent, setPercent] = useState<number | null>(0.5);
|
|
182
|
+
const [decimal, setDecimal] = useState<number | null>(11.13);
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<Content>
|
|
186
|
+
<InputNumber
|
|
187
|
+
label="Currency"
|
|
188
|
+
description='{ style: "currency", currency: "USD" }'
|
|
189
|
+
format={{ style: "currency", currency: "USD" }}
|
|
190
|
+
value={currency}
|
|
191
|
+
onValueCommitted={setCurrency}
|
|
192
|
+
/>
|
|
193
|
+
<InputNumber
|
|
194
|
+
label="Percent"
|
|
195
|
+
description='{ style: "percent" } — value is a ratio: 0.5 → 50%'
|
|
196
|
+
format={{ style: "percent", maximumFractionDigits: 2 }}
|
|
197
|
+
value={percent}
|
|
198
|
+
onValueCommitted={setPercent}
|
|
199
|
+
/>
|
|
200
|
+
<InputNumber
|
|
201
|
+
label="Decimal"
|
|
202
|
+
description="{ maximumFractionDigits: 2 }"
|
|
203
|
+
format={{ maximumFractionDigits: 2 }}
|
|
204
|
+
value={decimal}
|
|
205
|
+
onValueCommitted={setDecimal}
|
|
206
|
+
/>
|
|
207
|
+
</Content>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Loading
|
|
213
|
+
|
|
214
|
+
`loading` shows a non-blocking indicator in the stepper's slot for background
|
|
215
|
+
work, like saving. The field stays editable and the stepper is hidden while
|
|
216
|
+
loading.
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
import React, { useState } from "react";
|
|
220
|
+
import { InputNumber } from "@jobber/components";
|
|
221
|
+
|
|
222
|
+
export function InputNumberLoadingExample() {
|
|
223
|
+
const [value, setValue] = useState<number | null>(42);
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<InputNumber
|
|
227
|
+
loading
|
|
228
|
+
label="Quantity"
|
|
229
|
+
suffix={{ label: "items" }}
|
|
230
|
+
value={value}
|
|
231
|
+
onValueCommitted={setValue}
|
|
232
|
+
/>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Content guidelines
|
|
238
|
+
|
|
239
|
+
### Label the unit, don't repeat it
|
|
240
|
+
|
|
241
|
+
Put the unit in the label or an affix, not both.
|
|
242
|
+
|
|
243
|
+
| ✅ Do | ❌ Don't |
|
|
244
|
+
| ------------------------------- | --------------------------------------- |
|
|
245
|
+
| Label "Weight", suffix "kg" | Label "Weight (kg)", suffix "kg" |
|
|
246
|
+
| Label "Duration", suffix "days" | Label "Duration in days", suffix "days" |
|
|
247
|
+
|
|
248
|
+
### Keep labels short and sentence case
|
|
249
|
+
|
|
250
|
+
| ✅ Do | ❌ Don't |
|
|
251
|
+
| -------- | ----------------------- |
|
|
252
|
+
| Quantity | Enter the quantity here |
|
|
253
|
+
| Discount | DISCOUNT % |
|
|
254
|
+
|
|
255
|
+
### Put the symbol where it's read
|
|
256
|
+
|
|
257
|
+
Use a prefix for a leading symbol and a suffix for a trailing unit, matching how
|
|
258
|
+
the value is spoken.
|
|
259
|
+
|
|
260
|
+
| ✅ Do | ❌ Don't |
|
|
261
|
+
| -------------------- | -------------------- |
|
|
262
|
+
| Prefix "$", value 40 | Suffix "$", value 40 |
|
|
263
|
+
| Suffix "%", value 15 | Prefix "%", value 15 |
|
|
264
|
+
|
|
265
|
+
### Keep validation errors helpful
|
|
266
|
+
|
|
267
|
+
When a value breaks `min` or `max`, provide helpful guidance on what values will
|
|
268
|
+
be accepted as opposed to just providing a generic error.
|
|
269
|
+
|
|
270
|
+
| ✅ Do | ❌ Don't |
|
|
271
|
+
| ------------------------------ | ------------- |
|
|
272
|
+
| Enter a value between 1 and 99 | Invalid input |
|
|
273
|
+
| Quantity can't be more than 50 | Error |
|
|
274
|
+
|
|
275
|
+
### Use numbers as opposed to spelling them
|
|
276
|
+
|
|
277
|
+
Use numerals in labels, helper text, affixes, and bounds.
|
|
278
|
+
|
|
279
|
+
| ✅ Do | ❌ Don't |
|
|
280
|
+
| ----------- | --------------- |
|
|
281
|
+
| Max 3 items | Max three items |
|
|
282
|
+
|
|
283
|
+
## Do's and Don'ts
|
|
284
|
+
|
|
285
|
+
#### Do:
|
|
286
|
+
|
|
287
|
+
* ✅ Use for values the user increments or decrements
|
|
288
|
+
* ✅ Set `min` and `max` when the value has real bounds
|
|
289
|
+
* ✅ Use `format` for currency, percent, and decimals rather than formatting the
|
|
290
|
+
value yourself
|
|
291
|
+
* ✅ Use `loading` for background work so the field stays usable
|
|
292
|
+
|
|
293
|
+
#### Don't:
|
|
294
|
+
|
|
295
|
+
* ❌ Use it for digit sequences that are never calculated with, like phone or
|
|
296
|
+
credit card numbers
|
|
297
|
+
* ❌ Disable the field to communicate an error; show an `error` message instead
|
|
298
|
+
* ❌ Repeat the unit in both the label and an affix
|
|
299
|
+
|
|
300
|
+
## Accessibility notes
|
|
301
|
+
|
|
302
|
+
The field is a native number input, so it is reachable and operable by keyboard
|
|
303
|
+
and assistive technology.
|
|
304
|
+
|
|
305
|
+
| Key | Behavior |
|
|
306
|
+
| ---------------- | ------------------------------- |
|
|
307
|
+
| Tab | Moves focus to the field |
|
|
308
|
+
| Up / Down arrows | Increment / decrement by `step` |
|
|
309
|
+
| Enter | Commits the current value |
|
|
310
|
+
| Type | Replaces the value |
|
|
311
|
+
|
|
312
|
+
Give a clickable affix a clear `ariaLabel` describing its action, like "Clear
|
|
313
|
+
value".
|
|
314
|
+
|
|
315
|
+
## Related components
|
|
316
|
+
|
|
317
|
+
* For digit sequences that are not calculated with, like phone or credit card
|
|
318
|
+
numbers, use [InputText](../InputText/InputText.md).
|
|
319
|
+
* For dates, use [InputDate](../InputDate/InputDate.md).
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
## Anatomy
|
|
323
|
+
|
|
324
|
+
The prop-driven `<InputNumber>` composes a set of parts. You only
|
|
325
|
+
need these when the props can't express a layout; otherwise reach for the props
|
|
326
|
+
shown on the **Design** tab.
|
|
327
|
+
|
|
328
|
+
| Part | Description |
|
|
329
|
+
| ----------------------- | -------------------------------------------------------------------- |
|
|
330
|
+
| `Wrapper` | Owns the field configuration and state; provides it to the parts |
|
|
331
|
+
| `Group` | The bordered field row |
|
|
332
|
+
| `Input` | The input area; holds the `Label` and the `Stepper` / `Loading` slot |
|
|
333
|
+
| `Label` | Floating field label |
|
|
334
|
+
| `Stepper` | The increment / decrement button pair |
|
|
335
|
+
| `Increment` `Decrement` | The individual stepper buttons |
|
|
336
|
+
| `Affix` | Prefix / suffix content (label, icon, or clickable icon) |
|
|
337
|
+
| `Loading` | Non-blocking loading indicator slot |
|
|
338
|
+
| `Footer` | Below-field row that holds `Description` and `Error` |
|
|
339
|
+
| `Description` | Helper text below the field |
|
|
340
|
+
| `Error` | Styled error message below the field |
|
|
341
|
+
|
|
342
|
+
## Composition
|
|
343
|
+
|
|
344
|
+
The prop-driven component is sugar: it renders exactly the tree you would write
|
|
345
|
+
by hand with `<InputNumber.Wrapper>` and the parts. To customize a
|
|
346
|
+
single piece, compose the tree yourself and swap that one part — the other parts
|
|
347
|
+
keep their defaults. The sugar does not merge consumer-provided parts into its
|
|
348
|
+
render, so there is no per-slot precedence to reason about.
|
|
349
|
+
|
|
350
|
+
`Wrapper` owns the field state and shares it with the parts through context, so
|
|
351
|
+
every part must be rendered inside a `Wrapper` (a part used outside one throws).
|
|
352
|
+
|
|
353
|
+
The example below replaces the default stepper icons with `+` / `−` and leaves
|
|
354
|
+
everything else as the default:
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import React, { useState } from "react";
|
|
358
|
+
import { InputNumber } from "@jobber/components";
|
|
359
|
+
|
|
360
|
+
export function InputNumberCompositionExample() {
|
|
361
|
+
const [value, setValue] = useState<number | null>(3);
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<InputNumber.Wrapper value={value} onValueCommitted={setValue}>
|
|
365
|
+
<InputNumber.Group>
|
|
366
|
+
<InputNumber.Input>
|
|
367
|
+
<InputNumber.Label>Quantity</InputNumber.Label>
|
|
368
|
+
<InputNumber.Stepper>
|
|
369
|
+
<InputNumber.Increment ariaLabel="Increase Quantity">
|
|
370
|
+
+
|
|
371
|
+
</InputNumber.Increment>
|
|
372
|
+
<InputNumber.Decrement ariaLabel="Decrease Quantity">
|
|
373
|
+
−
|
|
374
|
+
</InputNumber.Decrement>
|
|
375
|
+
</InputNumber.Stepper>
|
|
376
|
+
</InputNumber.Input>
|
|
377
|
+
</InputNumber.Group>
|
|
378
|
+
</InputNumber.Wrapper>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## Controlled usage
|
|
384
|
+
|
|
385
|
+
The field is controlled: pass `value` (a `number`, or `null` for empty) and read
|
|
386
|
+
changes back through one of two callbacks.
|
|
387
|
+
|
|
388
|
+
| Callback | Fires | Use for |
|
|
389
|
+
| ------------------ | ----------------------------------------------------------- | ---------------------------------- |
|
|
390
|
+
| `onValueChange` | On every parsed change (typing, paste, stepper, arrow step) | Live-updating UI as the user types |
|
|
391
|
+
| `onValueCommitted` | When the user commits (blur, Enter, stepper, arrow step) | Saving / validating a final value |
|
|
392
|
+
|
|
393
|
+
Both emit `null` when the field is empty. Prefer `onValueCommitted` for
|
|
394
|
+
persistence so you are not writing on every keystroke.
|
|
395
|
+
|
|
396
|
+
## Formatting semantics
|
|
397
|
+
|
|
398
|
+
`format` is forwarded to Base UI's `NumberField` `format` and accepts any
|
|
399
|
+
`Intl.NumberFormatOptions`. It changes the display only; the committed value is
|
|
400
|
+
always a plain number. Two things to know:
|
|
401
|
+
|
|
402
|
+
* **Percent** (`{ style: "percent" }`) treats the value as a ratio: `0.5`
|
|
403
|
+
renders `50%`, and the stepper moves in ratio units. If you want the value to
|
|
404
|
+
be the number itself (`50` → `50%`), use `{ style: "unit", unit: "percent" }`.
|
|
405
|
+
* With no `format`, typed decimals are preserved and grouping is off
|
|
406
|
+
(`useGrouping: false`), so large numbers render without thousands separators
|
|
407
|
+
unless you opt in.
|
|
18
408
|
|
|
19
409
|
|
|
20
410
|
## Props
|
|
@@ -29,6 +29,14 @@ number automatically fills in the rest of the time. For example, typing `2` will
|
|
|
29
29
|
fill in `2:00 PM` and typing `1` waits for a few milliseconds in case the user
|
|
30
30
|
wants to type `10`, `11`, or `12`.
|
|
31
31
|
|
|
32
|
+
## Sizes and the placeholder
|
|
33
|
+
|
|
34
|
+
Consistent with other inputs, `size="small"` does not show the floating mini
|
|
35
|
+
label. The placeholder appears while the field is empty and unfocused, and is
|
|
36
|
+
hidden while the field is being edited or has a value, keeping the field at its
|
|
37
|
+
small height throughout. The default and `large` sizes float the placeholder up
|
|
38
|
+
as a mini label while editing or once a value is set.
|
|
39
|
+
|
|
32
40
|
|
|
33
41
|
## Props
|
|
34
42
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Progress Bar
|
|
2
2
|
|
|
3
|
+
> **Deprecated.** Use [ProgressIndicator](/components/ProgressIndicator) for new
|
|
4
|
+
> work. `ProgressIndicator` is the supported determinate progress indicator
|
|
5
|
+
> going forward — it offers the same semantic with a cleaner prop surface
|
|
6
|
+
> (`value` / `max` instead of `currentStep` / `totalSteps`,
|
|
7
|
+
> `variation="continuous"` instead of `"progress"`, plain `className` / `style`
|
|
8
|
+
> instead of `UNSAFE_*`), theme-adaptive tokens, and a unified
|
|
9
|
+
> `<div role="progressbar">` structure across continuous and stepped variations.
|
|
10
|
+
> `ProgressBar` continues to work unchanged for existing call sites.
|
|
11
|
+
|
|
3
12
|
A ProgressBar is a visual indicator of how close something is to completion.
|
|
4
13
|
|
|
5
14
|
## Design & usage guidelines
|