@jobber/components-native 0.102.2-JOB-169769-8f4f946.0 → 0.102.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.
- package/dist/docs/ActivityIndicator/ActivityIndicator.md +1 -1
- package/dist/docs/InputNumber/InputNumber.md +0 -11
- package/dist/docs/InputText/InputText.md +111 -81
- package/dist/docs/usage-guidelines/usage-guidelines.md +4 -7
- package/dist/package.json +2 -13
- package/dist/src/Banner/Banner.js +2 -2
- package/dist/src/Banner/Banner.test.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -13
- package/src/Banner/Banner.test.tsx +2 -2
- package/src/Banner/Banner.tsx +2 -2
- package/dist/src/primitives/index.js +0 -1
- package/dist/types/src/primitives/index.d.ts +0 -9
- package/src/primitives/index.ts +0 -9
|
@@ -108,7 +108,7 @@ ActivityIndicator uses the core component
|
|
|
108
108
|
| `shouldRasterizeIOS` | `boolean` | No | — | Whether this view should be rendered as a bitmap before compositing. On iOS, this is useful for animations and inter... |
|
|
109
109
|
| `size` | `"large" | "small" | number` | No | — | Size of the indicator. Small has a height of 20, large has a height of 36. enum('small', 'large') |
|
|
110
110
|
| `style` | `StyleProp<ViewStyle>` | No | — | |
|
|
111
|
-
| `tabIndex` |
|
|
111
|
+
| `tabIndex` | `-1 | 0` | No | — | Indicates whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware ke... |
|
|
112
112
|
| `testID` | `string` | No | — | Used to locate this view in end-to-end tests. |
|
|
113
113
|
| `tvParallaxMagnification` | `number` | No | — | *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out ... |
|
|
114
114
|
| `tvParallaxShiftDistanceX` | `number` | No | — | *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out ... |
|
|
@@ -17,17 +17,6 @@ InputNumber does not show a clear button. The component enforces
|
|
|
17
17
|
`clearable="never"` to align with numeric, increment/decrement-focused usage.
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
## Configuration
|
|
21
|
-
|
|
22
|
-
## Using onValidation
|
|
23
|
-
|
|
24
|
-
If you need to capture the error message and render it outside of the component.
|
|
25
|
-
Read the [InputValidation](/components/InputValidation) documentation.
|
|
26
|
-
|
|
27
|
-
For more details about `validation` using `Input` components, see the
|
|
28
|
-
[InputText](../InputText/InputText.md) documentation.
|
|
29
|
-
|
|
30
|
-
|
|
31
20
|
## Props
|
|
32
21
|
|
|
33
22
|
### Mobile
|
|
@@ -10,24 +10,23 @@ Use this to allow users to provide short answers.
|
|
|
10
10
|
|
|
11
11
|
```tsx
|
|
12
12
|
import React, { useState } from "react";
|
|
13
|
-
import type {
|
|
13
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
14
14
|
import { InputText } from "@jobber/components/InputText";
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const InputTextBasicExample = ({
|
|
17
17
|
onChange,
|
|
18
18
|
...props
|
|
19
|
-
}: Partial<
|
|
20
|
-
const [
|
|
19
|
+
}: Partial<InputTextProps>) => {
|
|
20
|
+
const [value, setValue] = useState(props.value ?? "");
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<InputText
|
|
24
|
-
version={2}
|
|
25
24
|
name="age"
|
|
26
25
|
placeholder="Age in words"
|
|
27
26
|
{...props}
|
|
28
|
-
value={
|
|
27
|
+
value={value}
|
|
29
28
|
onChange={newValue => {
|
|
30
|
-
|
|
29
|
+
setValue(newValue);
|
|
31
30
|
onChange?.(newValue);
|
|
32
31
|
}}
|
|
33
32
|
/>
|
|
@@ -46,15 +45,29 @@ For web, you can set a minimum and maximum number of rows. See:
|
|
|
46
45
|
[Web/rows example](/storybook/web/?path=/story/components-forms-and-inputs-inputtext--multiline).
|
|
47
46
|
|
|
48
47
|
```tsx
|
|
49
|
-
import React from "react";
|
|
50
|
-
import type {
|
|
48
|
+
import React, { useState } from "react";
|
|
49
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
51
50
|
import { InputText } from "@jobber/components/InputText";
|
|
52
51
|
|
|
53
52
|
export function InputTextMultilineExample(
|
|
54
|
-
props: Partial<Omit<
|
|
53
|
+
props: Partial<Omit<InputTextProps, "multiline">>,
|
|
55
54
|
) {
|
|
55
|
+
const [value, setValue] = useState<string>(props.value ?? "");
|
|
56
|
+
|
|
56
57
|
return (
|
|
57
|
-
<InputText
|
|
58
|
+
<InputText
|
|
59
|
+
multiline={true}
|
|
60
|
+
placeholder="Describe your age"
|
|
61
|
+
{...props}
|
|
62
|
+
value={value}
|
|
63
|
+
onChange={(
|
|
64
|
+
newValue: string,
|
|
65
|
+
event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
66
|
+
) => {
|
|
67
|
+
setValue(newValue);
|
|
68
|
+
props.onChange?.(newValue, event);
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
58
71
|
);
|
|
59
72
|
}
|
|
60
73
|
```
|
|
@@ -74,19 +87,41 @@ With clearer guidance around the purpose of inputs, the user is able to better
|
|
|
74
87
|
focus on the task at hand.
|
|
75
88
|
|
|
76
89
|
```tsx
|
|
77
|
-
import React from "react";
|
|
78
|
-
import type {
|
|
90
|
+
import React, { useState } from "react";
|
|
91
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
79
92
|
import { InputText } from "@jobber/components/InputText";
|
|
80
93
|
import { Content } from "@jobber/components/Content";
|
|
81
94
|
|
|
82
95
|
export function InputTextPrefixSuffixExample(
|
|
83
|
-
props: Partial<Omit<
|
|
96
|
+
props: Partial<Omit<InputTextProps, "multiline" | "rows">>,
|
|
84
97
|
) {
|
|
98
|
+
const [invoiceTotal, setInvoiceTotal] = useState<string>(
|
|
99
|
+
props.value ?? "1,000,000",
|
|
100
|
+
);
|
|
101
|
+
const [search, setSearch] = useState<string>(props.value ?? "");
|
|
102
|
+
|
|
103
|
+
const handleChange = (
|
|
104
|
+
newValue: string,
|
|
105
|
+
event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
106
|
+
) => {
|
|
107
|
+
setInvoiceTotal(newValue);
|
|
108
|
+
props.onChange?.(newValue, event);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const handleSearchChange = (
|
|
112
|
+
newValue: string,
|
|
113
|
+
event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
114
|
+
) => {
|
|
115
|
+
setSearch(newValue);
|
|
116
|
+
props.onChange?.(newValue, event);
|
|
117
|
+
};
|
|
118
|
+
|
|
85
119
|
return (
|
|
86
120
|
<Content>
|
|
87
121
|
<InputText
|
|
88
|
-
defaultValue="1,000,000"
|
|
89
122
|
placeholder="Invoice Total"
|
|
123
|
+
value={invoiceTotal}
|
|
124
|
+
onChange={handleChange}
|
|
90
125
|
prefix={{ label: "$", icon: "invoice" }}
|
|
91
126
|
suffix={{ label: ".00" }}
|
|
92
127
|
{...props}
|
|
@@ -94,6 +129,8 @@ export function InputTextPrefixSuffixExample(
|
|
|
94
129
|
<InputText
|
|
95
130
|
placeholder="Search"
|
|
96
131
|
prefix={{ icon: "search" }}
|
|
132
|
+
value={search}
|
|
133
|
+
onChange={handleSearchChange}
|
|
97
134
|
suffix={{
|
|
98
135
|
icon: "cross",
|
|
99
136
|
ariaLabel: "clear search",
|
|
@@ -118,33 +155,37 @@ Follow the
|
|
|
118
155
|
for guidance on writing helpful error messages.
|
|
119
156
|
|
|
120
157
|
```tsx
|
|
121
|
-
import React from "react";
|
|
122
|
-
import type {
|
|
158
|
+
import React, { useState } from "react";
|
|
159
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
123
160
|
import { InputText } from "@jobber/components/InputText";
|
|
124
161
|
|
|
125
162
|
export function InputTextValidationExample(
|
|
126
|
-
props: Partial<Omit<
|
|
163
|
+
props: Partial<Omit<InputTextProps, "multiline" | "rows">>,
|
|
127
164
|
) {
|
|
165
|
+
const [value, setValue] = useState("");
|
|
166
|
+
const [error, setError] = useState<string | undefined>();
|
|
167
|
+
|
|
168
|
+
function handleChange(newValue: string) {
|
|
169
|
+
setValue(newValue);
|
|
170
|
+
|
|
171
|
+
if (!newValue) {
|
|
172
|
+
setError("You have to tell us your age");
|
|
173
|
+
} else if (!isNaN(Number(newValue))) {
|
|
174
|
+
setError("Type your age in words please.");
|
|
175
|
+
} else if (newValue.length >= 10) {
|
|
176
|
+
setError("That seems too old.");
|
|
177
|
+
} else {
|
|
178
|
+
setError(undefined);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
128
182
|
return (
|
|
129
183
|
<InputText
|
|
130
184
|
placeholder="What's your age"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
validate: val => {
|
|
137
|
-
if (val.length > 0 && !isNaN(val)) {
|
|
138
|
-
return "Type your age in words please.";
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (val.length >= 10) {
|
|
142
|
-
return "That seems too old.";
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return true;
|
|
146
|
-
},
|
|
147
|
-
}}
|
|
185
|
+
value={value}
|
|
186
|
+
onChange={handleChange}
|
|
187
|
+
invalid={!!error}
|
|
188
|
+
error={error}
|
|
148
189
|
{...props}
|
|
149
190
|
/>
|
|
150
191
|
);
|
|
@@ -157,11 +198,11 @@ export function InputTextValidationExample(
|
|
|
157
198
|
|
|
158
199
|
```tsx
|
|
159
200
|
import React from "react";
|
|
160
|
-
import type {
|
|
201
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
161
202
|
import { InputText } from "@jobber/components/InputText";
|
|
162
203
|
|
|
163
204
|
export function InputTextDisabledExample(
|
|
164
|
-
props: Partial<Omit<
|
|
205
|
+
props: Partial<Omit<InputTextProps, "multiline" | "rows">>,
|
|
165
206
|
) {
|
|
166
207
|
return (
|
|
167
208
|
<InputText
|
|
@@ -182,11 +223,11 @@ See:
|
|
|
182
223
|
|
|
183
224
|
```tsx
|
|
184
225
|
import React from "react";
|
|
185
|
-
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
186
226
|
import { InputText } from "@jobber/components/InputText";
|
|
227
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
187
228
|
|
|
188
229
|
export function InputTextInvalidExample(
|
|
189
|
-
props: Partial<Omit<
|
|
230
|
+
props: Partial<Omit<InputTextProps, "multiline" | "rows">>,
|
|
190
231
|
) {
|
|
191
232
|
return (
|
|
192
233
|
<InputText placeholder="Email" value="atlantis" invalid={true} {...props} />
|
|
@@ -201,14 +242,16 @@ You can use `FormFieldLabel` to provide a label outside of the input. The
|
|
|
201
242
|
appears when a value is provided.
|
|
202
243
|
|
|
203
244
|
```tsx
|
|
204
|
-
import React from "react";
|
|
205
|
-
import type {
|
|
245
|
+
import React, { useState } from "react";
|
|
246
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
206
247
|
import { InputText } from "@jobber/components/InputText";
|
|
207
248
|
import { FormFieldLabel } from "@jobber/components/FormField";
|
|
208
249
|
|
|
209
250
|
export function InputTextExternalLabelExample(
|
|
210
|
-
props: Partial<Omit<
|
|
251
|
+
props: Partial<Omit<InputTextProps, "multiline" | "rows">>,
|
|
211
252
|
) {
|
|
253
|
+
const [value, setValue] = useState<string>(props.value ?? "");
|
|
254
|
+
|
|
212
255
|
return (
|
|
213
256
|
<div style={{ width: "100%" }}>
|
|
214
257
|
<FormFieldLabel external={true} htmlFor="ext-input">
|
|
@@ -220,6 +263,14 @@ export function InputTextExternalLabelExample(
|
|
|
220
263
|
clearable="always"
|
|
221
264
|
showMiniLabel={false}
|
|
222
265
|
{...props}
|
|
266
|
+
value={value}
|
|
267
|
+
onChange={(
|
|
268
|
+
newValue: string,
|
|
269
|
+
event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
270
|
+
) => {
|
|
271
|
+
setValue(newValue);
|
|
272
|
+
props.onChange?.(newValue, event);
|
|
273
|
+
}}
|
|
223
274
|
/>
|
|
224
275
|
</div>
|
|
225
276
|
);
|
|
@@ -231,55 +282,34 @@ export function InputTextExternalLabelExample(
|
|
|
231
282
|
Determine what default keyboard appears on mobile.
|
|
232
283
|
|
|
233
284
|
```tsx
|
|
234
|
-
import React from "react";
|
|
235
|
-
import type {
|
|
285
|
+
import React, { useState } from "react";
|
|
286
|
+
import type { InputTextProps } from "@jobber/components/InputText";
|
|
236
287
|
import { InputText } from "@jobber/components/InputText";
|
|
237
288
|
|
|
238
289
|
export function InputTextKeyboardExample(
|
|
239
|
-
props: Partial<Omit<
|
|
290
|
+
props: Partial<Omit<InputTextProps, "multiline" | "rows">>,
|
|
240
291
|
) {
|
|
292
|
+
const [value, setValue] = useState<string>(props.value ?? "");
|
|
293
|
+
|
|
241
294
|
return (
|
|
242
|
-
<InputText
|
|
295
|
+
<InputText
|
|
296
|
+
placeholder="Describe your age"
|
|
297
|
+
inputMode="numeric"
|
|
298
|
+
{...props}
|
|
299
|
+
value={value}
|
|
300
|
+
onChange={(
|
|
301
|
+
newValue: string,
|
|
302
|
+
event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
303
|
+
) => {
|
|
304
|
+
setValue(newValue);
|
|
305
|
+
props.onChange?.(newValue, event);
|
|
306
|
+
}}
|
|
307
|
+
/>
|
|
243
308
|
);
|
|
244
309
|
}
|
|
245
310
|
```
|
|
246
311
|
|
|
247
312
|
|
|
248
|
-
## Configuration
|
|
249
|
-
|
|
250
|
-
### react-hook-form
|
|
251
|
-
|
|
252
|
-
Atlantis utilizes [React Hook Form](https://react-hook-form.com/) to handle
|
|
253
|
-
`input` and `form` validation. This means that the
|
|
254
|
-
[React Hook Form validation options](https://react-hook-form.com/api#register)
|
|
255
|
-
are available out of the box.
|
|
256
|
-
|
|
257
|
-
This includes, but is not limited to:
|
|
258
|
-
|
|
259
|
-
* `required` - A Boolean which, if true, indicates that the input must have a
|
|
260
|
-
value.
|
|
261
|
-
* `maxLength` - The maximum length of the value to accept for this input.
|
|
262
|
-
* `minLength` - The minimum length of the value to accept for this input.
|
|
263
|
-
* `pattern` - The regex pattern for the input.
|
|
264
|
-
* `validate` - You can pass a callback function as the argument to validate, or
|
|
265
|
-
you can pass an object of callback functions to validate all of them.
|
|
266
|
-
|
|
267
|
-
### Using onValidation (Web)
|
|
268
|
-
|
|
269
|
-
If you need to capture the error message and render it outside of the component.
|
|
270
|
-
Read the [InputValidation](/components/InputValidation) documentation.
|
|
271
|
-
|
|
272
|
-
### Version 2 Shim (Experimental)
|
|
273
|
-
|
|
274
|
-
If you need to use the version 2 shim, you can pass `version={2}` to the
|
|
275
|
-
`InputText` and provide the required props. Due to issues with typescript
|
|
276
|
-
[see](https://github.com/microsoft/TypeScript/issues/32447) the aria attributes
|
|
277
|
-
(and other props separated by `-`) are not typed correctly. This means that the
|
|
278
|
-
shim will not enforce the version to be set to `2` when using these props. As a
|
|
279
|
-
result version 1 usages will have these props appear in the intellisense but
|
|
280
|
-
they will not do anything.
|
|
281
|
-
|
|
282
|
-
|
|
283
313
|
## Props
|
|
284
314
|
|
|
285
315
|
### Mobile
|
|
@@ -14,17 +14,14 @@ deprecated.
|
|
|
14
14
|
| Component | Import | v2 prop |
|
|
15
15
|
| ------------ | ---------------------------------------------------------------- | ------------------------------------------------- |
|
|
16
16
|
| Autocomplete | `import { Autocomplete } from "@jobber/components/Autocomplete"` | `version={2}` — fully controlled, async support |
|
|
17
|
-
| InputNumber | `import { InputNumber } from "@jobber/components/InputNumber"` | `version={2}` |
|
|
18
|
-
| InputText | `import { InputText } from "@jobber/components/InputText"` | `version={2}` |
|
|
19
17
|
| Modal | `import { Modal } from "@jobber/components/Modal"` | `version={2}` — uses `Modal.Provider` composition |
|
|
20
18
|
|
|
21
19
|
## Deprecated components — do not use
|
|
22
20
|
|
|
23
|
-
| Deprecated | Replacement | Notes
|
|
24
|
-
| --------------------- | ----------------------------------------------------- |
|
|
25
|
-
| `MultiSelect` | `Autocomplete` v2 with `multiple` prop, or `Combobox` | Fully deprecated, no longer supported.
|
|
26
|
-
| `
|
|
27
|
-
| `Chips` (dismissible) | `Autocomplete` v2 with `multiple` prop | Dismissible Chips variant is deprecated. |
|
|
21
|
+
| Deprecated | Replacement | Notes |
|
|
22
|
+
| --------------------- | ----------------------------------------------------- | ---------------------------------------- |
|
|
23
|
+
| `MultiSelect` | `Autocomplete` v2 with `multiple` prop, or `Combobox` | Fully deprecated, no longer supported. |
|
|
24
|
+
| `Chips` (dismissible) | `Autocomplete` v2 with `multiple` prop | Dismissible Chips variant is deprecated. |
|
|
28
25
|
|
|
29
26
|
### Deprecated props on still-supported components
|
|
30
27
|
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.102.2
|
|
3
|
+
"version": "0.102.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -15,17 +15,6 @@
|
|
|
15
15
|
"main": "dist/src/index.js",
|
|
16
16
|
"module": "dist/src/index.js",
|
|
17
17
|
"types": "dist/types/src/index.d.ts",
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"types": "./dist/types/src/index.d.ts",
|
|
21
|
-
"default": "./dist/src/index.js"
|
|
22
|
-
},
|
|
23
|
-
"./primitives": {
|
|
24
|
-
"types": "./dist/types/src/primitives/index.d.ts",
|
|
25
|
-
"default": "./dist/src/primitives/index.js"
|
|
26
|
-
},
|
|
27
|
-
"./package.json": "./package.json"
|
|
28
|
-
},
|
|
29
18
|
"files": [
|
|
30
19
|
"dist",
|
|
31
20
|
"dist/docs/**/*",
|
|
@@ -120,5 +109,5 @@
|
|
|
120
109
|
"react-native-screens": ">=4.18.0",
|
|
121
110
|
"react-native-svg": ">=12.0.0"
|
|
122
111
|
},
|
|
123
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "2829a8684a94528cf087b63fa471c531c95d01c8"
|
|
124
113
|
}
|
|
@@ -43,9 +43,9 @@ function WrappingElement({ shouldFlow, children, styles, }) {
|
|
|
43
43
|
function getBannerIcon(type) {
|
|
44
44
|
switch (type) {
|
|
45
45
|
case "notice":
|
|
46
|
-
return "
|
|
46
|
+
return "info";
|
|
47
47
|
case "warning":
|
|
48
|
-
return "
|
|
48
|
+
return "warning";
|
|
49
49
|
case "error":
|
|
50
50
|
return "alert";
|
|
51
51
|
case "success":
|
|
@@ -15,13 +15,13 @@ describe("Banner", () => {
|
|
|
15
15
|
const { getByText, getByTestId } = render(React.createElement(Banner, { type: "warning", text: "Here is a warning" }));
|
|
16
16
|
const icon = getByTestId("ATL-Banner-Icon");
|
|
17
17
|
expect(getByText("Here is a warning")).toBeDefined();
|
|
18
|
-
expect(icon.props.children.props.name).toBe("
|
|
18
|
+
expect(icon.props.children.props.name).toBe("warning");
|
|
19
19
|
});
|
|
20
20
|
it("renders a notice Banner", () => {
|
|
21
21
|
const { getByText, getByTestId } = render(React.createElement(Banner, { type: "notice", text: "Notice me" }));
|
|
22
22
|
const icon = getByTestId("ATL-Banner-Icon");
|
|
23
23
|
expect(getByText("Notice me")).toBeDefined();
|
|
24
|
-
expect(icon.props.children.props.name).toBe("
|
|
24
|
+
expect(icon.props.children.props.name).toBe("info");
|
|
25
25
|
});
|
|
26
26
|
it("renders a success Banner", () => {
|
|
27
27
|
const { getByText, getByTestId } = render(React.createElement(Banner, { type: "success" },
|