@jobber/components-native 0.111.1 → 0.112.1
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/ActivityIndicator/ActivityIndicator.md +11 -11
- package/dist/docs/Icon/Icon.md +19 -1
- package/dist/docs/InputNumber/InputNumber.md +400 -10
- package/dist/docs/empty-states/empty-states.md +13 -5
- package/dist/package.json +4 -4
- package/dist/src/BottomSheet/BottomSheet.js +1 -1
- package/dist/src/Chip/Chip.js +1 -1
- package/dist/src/Chip/Chip.test.js +1 -1
- package/dist/src/Icon/Icon.js +6 -2
- package/dist/src/Icon/Icon.test.js +14 -0
- package/dist/src/Toast/Toast.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/BottomSheet/BottomSheet.tsx +1 -1
- package/src/Chip/Chip.test.tsx +1 -1
- package/src/Chip/Chip.tsx +1 -1
- package/src/Glimmer/Glimmer.stories.tsx +3 -3
- package/src/Icon/Icon.test.tsx +24 -0
- package/src/Icon/Icon.tsx +12 -3
- package/src/Icon/__snapshots__/Icon.test.tsx.snap +1 -13
- package/src/IconButton/IconButton.stories.tsx +1 -1
- package/src/IconButton/docs/IconButtonBasic.tsx +1 -1
- package/src/InputDate/docs/InputDateBasic.tsx +2 -1
- package/src/InputDate/docs/InputDateEmptyValueLabel.tsx +2 -1
- package/src/InputDate/docs/InputDateInvalid.tsx +2 -1
- package/src/Toast/Toast.stories.tsx +4 -4
- package/src/Toast/Toast.tsx +1 -1
|
@@ -65,19 +65,19 @@ cases. The `small` size (16px) should be used on individual elements of an
|
|
|
65
65
|
interface (e.g. inside a `Button` or `Card`) or when sitting next to short
|
|
66
66
|
inline text.
|
|
67
67
|
|
|
68
|
-
Layout is the consumer's responsibility — `ActivityIndicator` does not expose
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
Layout is the consumer's responsibility — `ActivityIndicator` does not expose an
|
|
69
|
+
`inline` prop. Place it inside your own flex / inline-block container, or pass a
|
|
70
|
+
`className` / `style`, to control surrounding layout.
|
|
71
71
|
|
|
72
72
|
## Accessibility
|
|
73
73
|
|
|
74
74
|
`ActivityIndicator` announces itself politely to assistive technology:
|
|
75
75
|
|
|
76
|
-
* `role="status"` marks the element as a polite live region, appropriate for
|
|
77
|
-
|
|
78
|
-
* `aria-label` defaults to the literal English string `"Loading"`. Pass a
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
* `role="status"` marks the element as a polite live region, appropriate for a
|
|
77
|
+
non-urgent loading state.
|
|
78
|
+
* `aria-label` defaults to the literal English string `"Loading"`. Pass a custom
|
|
79
|
+
`ariaLabel` to localize or to describe the specific activity (e.g.
|
|
80
|
+
`ariaLabel="Uploading file"`).
|
|
81
81
|
|
|
82
82
|
The indicator does not participate in the keyboard tab order.
|
|
83
83
|
|
|
@@ -85,9 +85,9 @@ The indicator does not participate in the keyboard tab order.
|
|
|
85
85
|
|
|
86
86
|
When the user's operating system reports
|
|
87
87
|
[`prefers-reduced-motion: reduce`](https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion),
|
|
88
|
-
the indicator hides its rocking and rotating layers, repaints a single
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
the indicator hides its rocking and rotating layers, repaints a single static
|
|
89
|
+
ring in the icon foreground colour, and gently pulses its opacity so the
|
|
90
|
+
indicator still reads as "busy" without rotational motion.
|
|
91
91
|
|
|
92
92
|
## Relationship to Spinner
|
|
93
93
|
|
package/dist/docs/Icon/Icon.md
CHANGED
|
@@ -427,7 +427,6 @@ export function IconSizesExample() {
|
|
|
427
427
|
| | `import` |
|
|
428
428
|
| | `merge` |
|
|
429
429
|
| | `redo` |
|
|
430
|
-
| | `remove` |
|
|
431
430
|
| | `search` |
|
|
432
431
|
| | `sort` |
|
|
433
432
|
| | `sync` |
|
|
@@ -512,6 +511,25 @@ export function IconSizesExample() {
|
|
|
512
511
|
| | `plus2` |
|
|
513
512
|
|
|
514
513
|
|
|
514
|
+
## Validating icon names at runtime
|
|
515
|
+
|
|
516
|
+
When icon names arrive as runtime data (API responses, configuration, user
|
|
517
|
+
input), validate them before rendering with the exports from
|
|
518
|
+
`@jobber/components` (also available from `@jobber/design`):
|
|
519
|
+
|
|
520
|
+
* `iconNames`: a readonly array of every valid icon name
|
|
521
|
+
* `isIconName(value)`: a type guard that narrows a value to `IconNames`
|
|
522
|
+
|
|
523
|
+
```tsx
|
|
524
|
+
import { Icon, isIconName } from "@jobber/components";
|
|
525
|
+
|
|
526
|
+
function StatusIcon({ iconName }: { readonly iconName: string }) {
|
|
527
|
+
if (!isIconName(iconName)) return null;
|
|
528
|
+
|
|
529
|
+
return <Icon name={iconName} />;
|
|
530
|
+
}
|
|
531
|
+
```
|
|
532
|
+
|
|
515
533
|
## Component customization
|
|
516
534
|
|
|
517
535
|
### UNSAFE\_ props (advanced usage)
|
|
@@ -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: "cross",
|
|
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 need these
|
|
325
|
+
when the props can't express a layout; otherwise reach for the props shown on
|
|
326
|
+
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 single piece,
|
|
346
|
+
compose the tree yourself and swap that one part — the other parts keep their
|
|
347
|
+
defaults. The sugar does not merge consumer-provided parts into its render, so
|
|
348
|
+
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 (up to 12 fractional digits)
|
|
406
|
+
and thousands grouping follows the locale default, so `1234.5` renders as
|
|
407
|
+
`1,234.5`. Pass `{ useGrouping: false }` to render without separators.
|
|
18
408
|
|
|
19
409
|
|
|
20
410
|
## Props
|
|
@@ -21,7 +21,8 @@ for the “emptiness” may include, but are not limited to…
|
|
|
21
21
|
* Search results with no match
|
|
22
22
|
* An error has resulted in the user not being able to access content they
|
|
23
23
|
otherwise could
|
|
24
|
-
* A specific field doesn't have a value (for example, a custom field that the
|
|
24
|
+
* A specific field doesn't have a value (for example, a custom field that the
|
|
25
|
+
user hasn't populated)
|
|
25
26
|
|
|
26
27
|
## Solution
|
|
27
28
|
|
|
@@ -70,22 +71,29 @@ When a field doesn't have a value, use a dash to indicate the lack of a value.
|
|
|
70
71
|
This provides:
|
|
71
72
|
|
|
72
73
|
* confirmation that nothing was entered
|
|
73
|
-
* confirmation that something *can* be entered there should the information
|
|
74
|
+
* confirmation that something *can* be entered there should the information
|
|
75
|
+
require an update
|
|
74
76
|
|
|
75
77
|
```tsx
|
|
76
78
|
<Card>
|
|
77
79
|
<Content>
|
|
78
80
|
<Heading level={4}>Additional details</Heading>
|
|
79
81
|
<Stack gap="smallest">
|
|
80
|
-
<Text size="small" variation="subdued">
|
|
82
|
+
<Text size="small" variation="subdued">
|
|
83
|
+
Preferred service date
|
|
84
|
+
</Text>
|
|
81
85
|
<Text>June 25, 2026</Text>
|
|
82
86
|
</Stack>
|
|
83
87
|
<Stack gap="smallest">
|
|
84
|
-
<Text size="small" variation="subdued">
|
|
88
|
+
<Text size="small" variation="subdued">
|
|
89
|
+
Gate code
|
|
90
|
+
</Text>
|
|
85
91
|
<Text>—</Text>
|
|
86
92
|
</Stack>
|
|
87
93
|
<Stack gap="smallest">
|
|
88
|
-
<Text size="small" variation="subdued">
|
|
94
|
+
<Text size="small" variation="subdued">
|
|
95
|
+
Additional requests
|
|
96
|
+
</Text>
|
|
89
97
|
<Text>—</Text>
|
|
90
98
|
</Stack>
|
|
91
99
|
</Content>
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.112.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/runtime": "^7.29.2",
|
|
75
75
|
"@gorhom/bottom-sheet": "^5.2.8",
|
|
76
|
-
"@jobber/design": "0.
|
|
77
|
-
"@jobber/hooks": "2.21.
|
|
76
|
+
"@jobber/design": "0.111.0",
|
|
77
|
+
"@jobber/hooks": "2.21.1",
|
|
78
78
|
"@react-native-community/datetimepicker": "^8.4.5",
|
|
79
79
|
"@react-native/babel-preset": "^0.82.1",
|
|
80
80
|
"@storybook/addon-a11y": "10.3.5",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"react-native-screens": ">=4.18.0",
|
|
125
125
|
"react-native-svg": ">=12.0.0"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "2557e3892ae9903c706aebba90ff44bbb349618c"
|
|
128
128
|
}
|
|
@@ -64,7 +64,7 @@ function Footer({ styles, close, cancelLabel, }) {
|
|
|
64
64
|
return (React.createElement(View, null,
|
|
65
65
|
React.createElement(View, { style: styles.footerDivider },
|
|
66
66
|
React.createElement(Divider, null)),
|
|
67
|
-
React.createElement(BottomSheetOption, { text: cancelLabel, icon: "
|
|
67
|
+
React.createElement(BottomSheetOption, { text: cancelLabel, icon: "cross", onPress: close })));
|
|
68
68
|
}
|
|
69
69
|
function dismissKeyboard() {
|
|
70
70
|
//Dismisses the keyboard before opening the bottom sheet.
|
package/dist/src/Chip/Chip.js
CHANGED
|
@@ -42,7 +42,7 @@ export function Chip({ icon, label, onPress, isDismissible, isActive, inactiveBa
|
|
|
42
42
|
label && (React.createElement(View, { style: styles.chipText },
|
|
43
43
|
React.createElement(Typography, { color: "base", fontWeight: "medium", maxFontScaleSize: tokens["typography--fontSize-large"], maxLines: "single", reverseTheme: isActive }, label))),
|
|
44
44
|
isDismissible && (React.createElement(View, { style: [styles.dismissIcon, dismissColor] },
|
|
45
|
-
React.createElement(Icon, { name: "
|
|
45
|
+
React.createElement(Icon, { name: "cross", size: "small" })))));
|
|
46
46
|
}
|
|
47
47
|
function getBorderStyle(inactiveBackgroundColor, tokens) {
|
|
48
48
|
let borderColor = "transparent";
|
|
@@ -38,7 +38,7 @@ it("renders an inactive Chip with icon", () => {
|
|
|
38
38
|
});
|
|
39
39
|
it("renders a Chip with the dismiss icon", () => {
|
|
40
40
|
const { getByTestId } = render(React.createElement(Chip, { label: "Foo", onPress: jest.fn(), isActive: true, isDismissible: true }));
|
|
41
|
-
expect(getByTestId("
|
|
41
|
+
expect(getByTestId("cross")).toBeDefined();
|
|
42
42
|
});
|
|
43
43
|
it("should call the handler with the new value", () => {
|
|
44
44
|
const pressHandler = jest.fn();
|
package/dist/src/Icon/Icon.js
CHANGED
|
@@ -7,14 +7,18 @@ export function Icon({ name, color, size = "base", customColor, testID, }) {
|
|
|
7
7
|
const { svgStyle, paths, viewBox } = getIcon({
|
|
8
8
|
name,
|
|
9
9
|
color,
|
|
10
|
+
customColor,
|
|
10
11
|
size,
|
|
11
12
|
platform: "mobile",
|
|
12
13
|
format: "js",
|
|
13
14
|
tokens,
|
|
14
15
|
});
|
|
16
|
+
// Paths with their own fill are static artwork; only unfilled paths take
|
|
17
|
+
// the themed color and customColor.
|
|
15
18
|
// getIcon returns undefined paths for an unknown icon name; render nothing rather than crash.
|
|
16
|
-
const icon = (paths !== null && paths !== void 0 ? paths : []).map(
|
|
17
|
-
|
|
19
|
+
const icon = (paths !== null && paths !== void 0 ? paths : []).map(path => {
|
|
20
|
+
var _a;
|
|
21
|
+
return (React.createElement(Path, { key: path.d, d: path.d, fill: (_a = path.fill) !== null && _a !== void 0 ? _a : (customColor || svgStyle.fill), fillOpacity: path.fillOpacity, opacity: path.opacity }));
|
|
18
22
|
});
|
|
19
23
|
return (React.createElement(Svg, { style: Object.assign(Object.assign({}, svgStyle), { display: "flex" }), testID: testID || name, viewBox: viewBox }, icon));
|
|
20
24
|
}
|
|
@@ -45,6 +45,20 @@ it("renders an empty svg without throwing for an unknown icon name", () => {
|
|
|
45
45
|
const svg = render(React.createElement(Icon, { name: "someNonexistentIcon" }));
|
|
46
46
|
expect(svg.UNSAFE_root.findAllByType(Path)).toHaveLength(0);
|
|
47
47
|
});
|
|
48
|
+
it("renders the multi-color truck icon with its static fills", () => {
|
|
49
|
+
const svg = render(React.createElement(Icon, { name: "truck" }));
|
|
50
|
+
const fills = svg.UNSAFE_root.findAllByType(Path).map(path => path.props.fill);
|
|
51
|
+
expect(fills).toHaveLength(5);
|
|
52
|
+
expect(fills).toContain("#2B2B2B");
|
|
53
|
+
expect(fills.filter(fill => fill.startsWith("#"))).toHaveLength(4);
|
|
54
|
+
});
|
|
55
|
+
it("applies customColor to the truck body path but not its static artwork", () => {
|
|
56
|
+
const svg = render(React.createElement(Icon, { name: "truck", customColor: "#abc123" }));
|
|
57
|
+
const fills = svg.UNSAFE_root.findAllByType(Path).map(path => path.props.fill);
|
|
58
|
+
expect(fills).toHaveLength(5);
|
|
59
|
+
expect(fills.filter(fill => fill === "#abc123")).toHaveLength(1);
|
|
60
|
+
expect(fills).toEqual(expect.arrayContaining(["#2B2B2B", "#000000", "#FFFFFF", "#2A2A2A"]));
|
|
61
|
+
});
|
|
48
62
|
describe("theme-aware fill", () => {
|
|
49
63
|
function getPathFills(svg) {
|
|
50
64
|
return svg.UNSAFE_root.findAllByType(Path).map(p => p.props.fill);
|
package/dist/src/Toast/Toast.js
CHANGED
|
@@ -21,7 +21,7 @@ function DefaultToast({ text1 }) {
|
|
|
21
21
|
React.createElement(TouchableOpacity, { style: styles.toastMessage, accessibilityRole: "alert" },
|
|
22
22
|
React.createElement(Text, { reverseTheme: true }, text1)),
|
|
23
23
|
React.createElement(View, { style: styles.toastIcon },
|
|
24
|
-
React.createElement(IconButton, { onPress: Toast.hide, name: "
|
|
24
|
+
React.createElement(IconButton, { onPress: Toast.hide, name: "cross", customColor: tokens["color-greyBlue--light"], accessibilityLabel: t("dismiss") })))));
|
|
25
25
|
}
|
|
26
26
|
const toastConfig = {
|
|
27
27
|
default: DefaultToast,
|