@jobber/components-native 0.101.5 → 0.101.6
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/ActionItem/ActionItem.md +65 -0
- package/dist/docs/ActionItemGroup/ActionItemGroup.md +33 -0
- package/dist/docs/ActionLabel/ActionLabel.md +43 -0
- package/dist/docs/ActivityIndicator/ActivityIndicator.md +116 -0
- package/dist/docs/Animation/Animation.md +71 -0
- package/dist/docs/AtlantisThemeContext/AtlantisThemeContext.md +256 -0
- package/dist/docs/AutoLink/AutoLink.md +47 -0
- package/dist/docs/Banner/Banner.md +390 -0
- package/dist/docs/Borders/Borders.md +45 -0
- package/dist/docs/BottomSheet/BottomSheet.md +67 -0
- package/dist/docs/Button/Button.md +918 -0
- package/dist/docs/ButtonGroup/ButtonGroup.md +89 -0
- package/dist/docs/Card/Card.md +270 -0
- package/dist/docs/Checkbox/Checkbox.md +69 -0
- package/dist/docs/Chip/Chip.md +371 -0
- package/dist/docs/Colors/Colors.md +217 -0
- package/dist/docs/Content/Content.md +67 -0
- package/dist/docs/ContentOverlay/ContentOverlay.md +64 -0
- package/dist/docs/Disclosure/Disclosure.md +161 -0
- package/dist/docs/Divider/Divider.md +84 -0
- package/dist/docs/Elevations/Elevations.md +76 -0
- package/dist/docs/EmptyState/EmptyState.md +72 -0
- package/dist/docs/Flex/Flex.md +37 -0
- package/dist/docs/Form/Form.md +126 -0
- package/dist/docs/FormField/FormField.md +57 -0
- package/dist/docs/FormatFile/FormatFile.md +56 -0
- package/dist/docs/Glimmer/Glimmer.md +143 -0
- package/dist/docs/Heading/Heading.md +132 -0
- package/dist/docs/Icon/Icon.md +585 -0
- package/dist/docs/IconButton/IconButton.md +25 -0
- package/dist/docs/InputCurrency/InputCurrency.md +61 -0
- package/dist/docs/InputDate/InputDate.md +133 -0
- package/dist/docs/InputEmail/InputEmail.md +69 -0
- package/dist/docs/InputFieldWrapper/InputFieldWrapper.md +70 -0
- package/dist/docs/InputNumber/InputNumber.md +72 -0
- package/dist/docs/InputPassword/InputPassword.md +61 -0
- package/dist/docs/InputPressable/InputPressable.md +64 -0
- package/dist/docs/InputSearch/InputSearch.md +49 -0
- package/dist/docs/InputText/InputText.md +324 -0
- package/dist/docs/InputTime/InputTime.md +54 -0
- package/dist/docs/Opacity/Opacity.md +12 -0
- package/dist/docs/ProgressBar/ProgressBar.md +39 -0
- package/dist/docs/Radii/Radii.md +23 -0
- package/dist/docs/ResponsiveBreakpoint/ResponsiveBreakpoint.md +74 -0
- package/dist/docs/Select/Select.md +213 -0
- package/dist/docs/Spacing/Spacing.md +103 -0
- package/dist/docs/StatusLabel/StatusLabel.md +119 -0
- package/dist/docs/Switch/Switch.md +54 -0
- package/dist/docs/Text/Text.md +368 -0
- package/dist/docs/TextList/TextList.md +29 -0
- package/dist/docs/ThumbnailList/ThumbnailList.md +16 -0
- package/dist/docs/Toast/Toast.md +71 -0
- package/dist/docs/Typography/Typography.md +170 -0
- package/dist/docs/choosing-components/choosing-components.md +76 -0
- package/dist/docs/customizing-components/customizing-components.md +167 -0
- package/dist/docs/disabled-states/disabled-states.md +86 -0
- package/dist/docs/empty-states/empty-states.md +126 -0
- package/dist/docs/errors/errors.md +114 -0
- package/dist/docs/index.md +64 -0
- package/dist/docs/interaction/interaction.md +109 -0
- package/dist/docs/page-layouts/page-layouts.md +323 -0
- package/dist/docs/scaffolding/scaffolding.md +109 -0
- package/dist/docs/settings/settings.md +58 -0
- package/dist/docs/usage-guidelines/usage-guidelines.md +177 -0
- package/dist/package.json +8 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -4
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# Input Text
|
|
2
|
+
|
|
3
|
+
Input text is used in forms that accept short or long answers from users.
|
|
4
|
+
|
|
5
|
+
## Design & usage guidelines
|
|
6
|
+
|
|
7
|
+
### Controlled
|
|
8
|
+
|
|
9
|
+
Use this to allow users to provide short answers.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import React, { useState } from "react";
|
|
13
|
+
import type { InputTextRebuiltProps } from "@jobber/components/InputText";
|
|
14
|
+
import { InputText } from "@jobber/components/InputText";
|
|
15
|
+
|
|
16
|
+
export const ControlledExample = ({
|
|
17
|
+
onChange,
|
|
18
|
+
...props
|
|
19
|
+
}: Partial<InputTextRebuiltProps>) => {
|
|
20
|
+
const [age, setAge] = useState("Veintisiete");
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<InputText
|
|
24
|
+
version={2}
|
|
25
|
+
name="age"
|
|
26
|
+
placeholder="Age in words"
|
|
27
|
+
{...props}
|
|
28
|
+
value={age}
|
|
29
|
+
onChange={newValue => {
|
|
30
|
+
setAge(newValue);
|
|
31
|
+
onChange?.(newValue);
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Show code**
|
|
39
|
+
|
|
40
|
+
### Multiline
|
|
41
|
+
|
|
42
|
+
Use this to allow users to provide long answers. The default number of rows is
|
|
43
|
+
three. Note that `loading={true}` is unimplemented for multiline input text.
|
|
44
|
+
|
|
45
|
+
For web, you can set a minimum and maximum number of rows. See:
|
|
46
|
+
[Web/rows example](/storybook/web/?path=/story/components-forms-and-inputs-inputtext--multiline).
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import React from "react";
|
|
50
|
+
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
51
|
+
import { InputText } from "@jobber/components/InputText";
|
|
52
|
+
|
|
53
|
+
export function InputTextMultilineExample(
|
|
54
|
+
props: Partial<Omit<InputTextLegacyProps, "multiline">>,
|
|
55
|
+
) {
|
|
56
|
+
return (
|
|
57
|
+
<InputText multiline={true} placeholder="Describe your age" {...props} />
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Prefix/suffix
|
|
63
|
+
|
|
64
|
+
Use a prefix or suffix when additional visual cues about an input's function may
|
|
65
|
+
be helpful.
|
|
66
|
+
|
|
67
|
+
Some fields have common visual patterns such as "search" having a magnifying
|
|
68
|
+
glass icon, "Select" having a downwards arrow, or currency inputs having a
|
|
69
|
+
currency symbol. These signifiers reinforce the purpose of the input to increase
|
|
70
|
+
[Recognition over Recall](https://www.nngroup.com/articles/ten-usability-heuristics/)
|
|
71
|
+
and align the input with
|
|
72
|
+
[Consistency and Standards](https://www.nngroup.com/articles/ten-usability-heuristics/).
|
|
73
|
+
With clearer guidance around the purpose of inputs, the user is able to better
|
|
74
|
+
focus on the task at hand.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import React from "react";
|
|
78
|
+
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
79
|
+
import { InputText } from "@jobber/components/InputText";
|
|
80
|
+
import { Content } from "@jobber/components/Content";
|
|
81
|
+
|
|
82
|
+
export function InputTextPrefixSuffixExample(
|
|
83
|
+
props: Partial<Omit<InputTextLegacyProps, "multiline" | "rows">>,
|
|
84
|
+
) {
|
|
85
|
+
return (
|
|
86
|
+
<Content>
|
|
87
|
+
<InputText
|
|
88
|
+
defaultValue="1,000,000"
|
|
89
|
+
placeholder="Invoice Total"
|
|
90
|
+
prefix={{ label: "$", icon: "invoice" }}
|
|
91
|
+
suffix={{ label: ".00" }}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
<InputText
|
|
95
|
+
placeholder="Search"
|
|
96
|
+
prefix={{ icon: "search" }}
|
|
97
|
+
suffix={{
|
|
98
|
+
icon: "cross",
|
|
99
|
+
ariaLabel: "clear search",
|
|
100
|
+
onClick: () => alert("This could clear a search value"),
|
|
101
|
+
}}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
</Content>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Validation message
|
|
110
|
+
|
|
111
|
+
You can add your own custom validation messages on a field to assist the user in
|
|
112
|
+
successfully completing a form. This doesn't *replace* server-side validation,
|
|
113
|
+
but minimizes the need for it as the user should be set up for success by proper
|
|
114
|
+
guidance pre-submission before any "bad" data gets to the server.
|
|
115
|
+
|
|
116
|
+
Follow the
|
|
117
|
+
[product vocabulary](/content/product-vocabulary#component-view-general-phrasing)
|
|
118
|
+
for guidance on writing helpful error messages.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import React from "react";
|
|
122
|
+
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
123
|
+
import { InputText } from "@jobber/components/InputText";
|
|
124
|
+
|
|
125
|
+
export function InputTextValidationExample(
|
|
126
|
+
props: Partial<Omit<InputTextLegacyProps, "multiline" | "rows">>,
|
|
127
|
+
) {
|
|
128
|
+
return (
|
|
129
|
+
<InputText
|
|
130
|
+
placeholder="What's your age"
|
|
131
|
+
validations={{
|
|
132
|
+
required: {
|
|
133
|
+
value: true,
|
|
134
|
+
message: "You have to tell us your age",
|
|
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
|
+
}}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## States
|
|
155
|
+
|
|
156
|
+
### Disabled
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import React from "react";
|
|
160
|
+
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
161
|
+
import { InputText } from "@jobber/components/InputText";
|
|
162
|
+
|
|
163
|
+
export function InputTextDisabledExample(
|
|
164
|
+
props: Partial<Omit<InputTextLegacyProps, "multiline" | "rows">>,
|
|
165
|
+
) {
|
|
166
|
+
return (
|
|
167
|
+
<InputText
|
|
168
|
+
placeholder="Credit card"
|
|
169
|
+
value="**** **** **** 1234"
|
|
170
|
+
disabled={true}
|
|
171
|
+
{...props}
|
|
172
|
+
/>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Invalid
|
|
178
|
+
|
|
179
|
+
For mobile, you can pass a string to the `invalid` prop to display an error.
|
|
180
|
+
See:
|
|
181
|
+
[Mobile/invalid example](/storybook/mobile/?path=/story/components-forms-and-inputs-inputtext--invalid).
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import React from "react";
|
|
185
|
+
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
186
|
+
import { InputText } from "@jobber/components/InputText";
|
|
187
|
+
|
|
188
|
+
export function InputTextInvalidExample(
|
|
189
|
+
props: Partial<Omit<InputTextLegacyProps, "multiline" | "rows">>,
|
|
190
|
+
) {
|
|
191
|
+
return (
|
|
192
|
+
<InputText placeholder="Email" value="atlantis" invalid={true} {...props} />
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### External label
|
|
198
|
+
|
|
199
|
+
You can use `FormFieldLabel` to provide a label outside of the input. The
|
|
200
|
+
`showMiniLabel` prop on `InputText` can be used to hide the mini label that
|
|
201
|
+
appears when a value is provided.
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import React from "react";
|
|
205
|
+
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
206
|
+
import { InputText } from "@jobber/components/InputText";
|
|
207
|
+
import { FormFieldLabel } from "@jobber/components/FormField";
|
|
208
|
+
|
|
209
|
+
export function InputTextExternalLabelExample(
|
|
210
|
+
props: Partial<Omit<InputTextLegacyProps, "multiline" | "rows">>,
|
|
211
|
+
) {
|
|
212
|
+
return (
|
|
213
|
+
<div style={{ width: "100%" }}>
|
|
214
|
+
<FormFieldLabel external={true} htmlFor="ext-input">
|
|
215
|
+
External label
|
|
216
|
+
</FormFieldLabel>
|
|
217
|
+
<InputText
|
|
218
|
+
id="ext-input"
|
|
219
|
+
name="name"
|
|
220
|
+
clearable="always"
|
|
221
|
+
showMiniLabel={false}
|
|
222
|
+
{...props}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Keyboard
|
|
230
|
+
|
|
231
|
+
Determine what default keyboard appears on mobile.
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
import React from "react";
|
|
235
|
+
import type { InputTextLegacyProps } from "@jobber/components/InputText";
|
|
236
|
+
import { InputText } from "@jobber/components/InputText";
|
|
237
|
+
|
|
238
|
+
export function InputTextKeyboardExample(
|
|
239
|
+
props: Partial<Omit<InputTextLegacyProps, "multiline" | "rows">>,
|
|
240
|
+
) {
|
|
241
|
+
return (
|
|
242
|
+
<InputText placeholder="Describe your age" keyboard="numeric" {...props} />
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
|
|
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
|
+
## Props
|
|
284
|
+
|
|
285
|
+
### Mobile
|
|
286
|
+
|
|
287
|
+
| Prop | Type | Required | Default | Description |
|
|
288
|
+
|------|------|----------|---------|-------------|
|
|
289
|
+
| `accessibilityHint` | `string` | No | — | An accessibility hint helps users understand what will happen when they perform an action on the accessibility elemen... |
|
|
290
|
+
| `accessibilityLabel` | `string` | No | — | VoiceOver will read this string when a user selects the associated element |
|
|
291
|
+
| `assistiveText` | `string` | No | — | Text that helps the user understand the input |
|
|
292
|
+
| `autoCapitalize` | `"characters" | "words" | "sentences" | "none"` | No | — | Determines where to autocapitalize |
|
|
293
|
+
| `autoComplete` | `"name" | "additional-name" | "address-line1" | "address-line2" | "birthdate-day" | "birthdate-full" | "birthdate-month" | "birthdate-year" | "cc-csc" | "cc-exp" | "cc-exp-day" | ... 45 more ... | "off"` | No | — | Determines which content to suggest on auto complete, e.g.`username`. Default is `off` which disables auto complete ... |
|
|
294
|
+
| `autoCorrect` | `boolean` | No | — | Turn off autocorrect |
|
|
295
|
+
| `autoFocus` | `boolean` | No | — | Automatically focus the input after it is rendered |
|
|
296
|
+
| `clearable` | `Clearable` | No | — | Add a clear action on the input that clears the value. You should always use `while-editing` if you want the input t... |
|
|
297
|
+
| `defaultValue` | `string` | No | — | Default value for when component is uncontrolled |
|
|
298
|
+
| `disabled` | `boolean` | No | — | Disable the input |
|
|
299
|
+
| `invalid` | `string | boolean` | No | — | Highlights the field red and shows message below (if string) to indicate an error |
|
|
300
|
+
| `keyboard` | `"default" | "numeric" | "phone-pad" | "email-address" | "numbers-and-punctuation" | "decimal-pad"` | No | — | Determines what keyboard is shown |
|
|
301
|
+
| `loading` | `boolean` | No | — | Show loading indicator. |
|
|
302
|
+
| `loadingType` | `"spinner" | "glimmer"` | No | — | Change the type of loading indicator to spinner or glimmer. |
|
|
303
|
+
| `multiline` | `boolean` | No | — | Determines if inputText will span multiple lines. Default is `false` https://reactnative.dev/docs/textinput#multiline |
|
|
304
|
+
| `name` | `string` | No | — | Name of the input. |
|
|
305
|
+
| `onBlur` | `(event?: FocusEvent) => void` | No | — | Callback that is called when the text input is blurred |
|
|
306
|
+
| `onChangeText` | `(newValue: string) => void` | No | — | Simplified callback that only provides the new value @param newValue |
|
|
307
|
+
| `onFocus` | `(event?: FocusEvent) => void` | No | — | Callback that is called when the text input is focused @param event |
|
|
308
|
+
| `onSubmitEditing` | `(event?: SyntheticEvent<Element, Event>) => void` | No | — | Callback that is called when the text input's submit button is pressed @param event |
|
|
309
|
+
| `placeholder` | `string` | No | — | Hint text that goes above the value once the field is filled out |
|
|
310
|
+
| `prefix` | `{ icon?: IconNames; label?: string; }` | No | — | Symbol to display before the text input |
|
|
311
|
+
| `readonly` | `boolean` | No | — | Makes the input read-only |
|
|
312
|
+
| `ref` | `Ref<InputTextRef>` | No | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (... |
|
|
313
|
+
| `secureTextEntry` | `boolean` | No | — | Use secure text entry |
|
|
314
|
+
| `showMiniLabel` | `boolean` | No | `true` | Controls the visibility of the mini label that appears inside the input when a value is entered. By default, the plac... |
|
|
315
|
+
| `spellCheck` | `boolean` | No | — | Determines whether spell check is used. Turn it off to hide empty autoCorrect suggestions when autoCorrect is off. *... |
|
|
316
|
+
| `styleOverride` | `InputTextStyleOverride` | No | — | Custom styling to override default style of the input text |
|
|
317
|
+
| `suffix` | `{ icon?: IconNames; label?: string; onPress?: () => void; }` | No | — | Symbol to display after the text input |
|
|
318
|
+
| `testID` | `string` | No | — | Used to locate this view in end-to-end tests |
|
|
319
|
+
| `textContentType` | `"name" | "none" | "nickname" | "password" | "username" | "URL" | "addressCity" | "addressCityAndState" | "addressState" | "countryName" | "creditCardNumber" | "creditCardExpiration" | ... 33 more ... | "shipmentTrackingNumber"` | No | — | Determines which content to suggest on auto complete, e.g.`username`. Default is `none` which disables auto complete ... |
|
|
320
|
+
| `toolbar` | `ReactNode` | No | — | Add a toolbar below the input field for actions like rewriting the text. |
|
|
321
|
+
| `toolbarVisibility` | `"while-editing" | "always"` | No | — | Change the behaviour of when the toolbar becomes visible. |
|
|
322
|
+
| `transform` | `{ input?: (v: any) => string; output?: (v: string) => any; }` | No | — | transform object is used to transform the internal TextInput value It's useful for components like InputNumber where ... |
|
|
323
|
+
| `validations` | `RegisterOptions` | No | — | Shows an error message below the field and highlight the field red when value is invalid |
|
|
324
|
+
| `value` | `string` | No | — | Set the component to a given value |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Input Time
|
|
2
|
+
|
|
3
|
+
The InputTime component is a text input that allows the user to enter a time
|
|
4
|
+
value.
|
|
5
|
+
|
|
6
|
+
## Design & usage guidelines
|
|
7
|
+
|
|
8
|
+
This component obeys the system locale settings to determine 24 or 12 hour time.
|
|
9
|
+
|
|
10
|
+
### States
|
|
11
|
+
|
|
12
|
+
A
|
|
13
|
+
[disabled](/storybook/web/?path=/story/components-forms-and-inputs-inputtime--disabled)
|
|
14
|
+
state will be visually muted and the input will not be editable. This is similar
|
|
15
|
+
to the
|
|
16
|
+
[read-only](/storybook/web/?path=/story/components-forms-and-inputs-inputtime--read-only)
|
|
17
|
+
state, but the input is not muted.
|
|
18
|
+
|
|
19
|
+
An
|
|
20
|
+
[invalid](/storybook/web/?path=/story/components-forms-and-inputs-inputtime--invalid)
|
|
21
|
+
state will indicate that the input is not valid. This can be used when the input
|
|
22
|
+
is required and the user has not entered a value.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Controlled & Uncontrolled
|
|
26
|
+
|
|
27
|
+
### Controlled component
|
|
28
|
+
|
|
29
|
+
Web's
|
|
30
|
+
[Controlled](/storybook/web/?path=/story/components-forms-and-inputs-inputtime--controlled)
|
|
31
|
+
version includes a type-ahead feature where typing at least 1 number
|
|
32
|
+
automatically fills in the rest of the time. For example, typing `2` will fill
|
|
33
|
+
in `2:00 PM` and typing `1` waits for a few milliseconds in case the user wants
|
|
34
|
+
to type `10`, `11`, or `12`.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Props
|
|
38
|
+
|
|
39
|
+
### Mobile
|
|
40
|
+
|
|
41
|
+
| Prop | Type | Required | Default | Description |
|
|
42
|
+
|------|------|----------|---------|-------------|
|
|
43
|
+
| `clearable` | `"never" | "always"` | No | — | Defaulted to "always" so user can clear the time whenever there's a value. |
|
|
44
|
+
| `disabled` | `boolean` | No | — | Disable the input |
|
|
45
|
+
| `emptyValueLabel` | `string` | No | `undefined` | Add a custom value to display when no time is selected |
|
|
46
|
+
| `invalid` | `string | boolean` | No | — | Highlights the field red and shows message below (if string) to indicate an error |
|
|
47
|
+
| `name` | `string` | No | — | Adding a `name` would make this component "Form controlled" and must be nested within a `<Form />` component. Cannot... |
|
|
48
|
+
| `onChange` | `((value?: Date) => void) | ((value?: Date) => void)` | No | — | The callback that fires whenever a time gets selected. |
|
|
49
|
+
| `placeholder` | `string` | No | — | Hint text that goes above the value once the field is filled out |
|
|
50
|
+
| `showIcon` | `boolean` | No | — | Hide or show the timer icon. |
|
|
51
|
+
| `showMiniLabel` | `boolean` | No | `true` | Controls the visibility of the mini label that appears inside the input when a value is entered. By default, the plac... |
|
|
52
|
+
| `type` | `"granular" | "scheduling"` | No | `scheduling` | Adjusts the UX of the time picker based on where you'd use it. - `"granular"` - allows the user to pick a very speci... |
|
|
53
|
+
| `validations` | `Omit<RegisterOptions<FieldValues, string>, "disabled" | "valueAsNumber" | "valueAsDate" | "setValueAs">` | No | — | Shows an error message below the field and highlights it red when the value is invalid. Only applies when nested with... |
|
|
54
|
+
| `value` | `string | Date` | No | — | The value shown on the field. This gets automatically formatted to the account's time format. |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Opacity
|
|
2
|
+
|
|
3
|
+
Opacity is used to adjust the transparency of an element.
|
|
4
|
+
|
|
5
|
+
These tokens should be used for particular instances where the transparency of
|
|
6
|
+
an element needs to be altered when pressed, or to modify the transparency of an
|
|
7
|
+
overlay.
|
|
8
|
+
|
|
9
|
+
| Opacity | Visual | Value |
|
|
10
|
+
| :------------------ | :----- | :---- |
|
|
11
|
+
| `--opacity-overlay` | | 0.8 |
|
|
12
|
+
| `--opacity-pressed` | | 0.6 |
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Progress Bar
|
|
2
|
+
|
|
3
|
+
A ProgressBar is a visual indicator of how close something is to completion.
|
|
4
|
+
|
|
5
|
+
## Design & usage guidelines
|
|
6
|
+
|
|
7
|
+
The ProgressBar should be used to show "definite" progress; we know exactly how
|
|
8
|
+
close the process is to completion. For "indefinite" progress, where we may not
|
|
9
|
+
know exactly how much longer something might take, use a
|
|
10
|
+
[Spinner](/components/Spinner).
|
|
11
|
+
|
|
12
|
+
Some great use cases for a ProgressBar include:
|
|
13
|
+
|
|
14
|
+
* Setup wizard, where we know how many steps the user has completed and how many
|
|
15
|
+
steps remain.
|
|
16
|
+
* File uploads, where we know the total file size and how much data has already
|
|
17
|
+
been sent.
|
|
18
|
+
|
|
19
|
+
An example where you might be better served using a Spinner:
|
|
20
|
+
|
|
21
|
+
* Loading a calendar within a view, where we do not know it's "complete" until
|
|
22
|
+
there's no more data left to load.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
### Mobile
|
|
28
|
+
|
|
29
|
+
| Prop | Type | Required | Default | Description |
|
|
30
|
+
|------|------|----------|---------|-------------|
|
|
31
|
+
| `current` | `number` | Yes | — | The number of items that are currently completed |
|
|
32
|
+
| `total` | `number` | Yes | — | The total number of items to be completed |
|
|
33
|
+
| `header` | `ReactNode` | No | — | Component to render above the progress bar. |
|
|
34
|
+
| `inProgress` | `number` | No | `0` | The number of items in progress (not completed, but to be less than the total); not applicable with stepped variation |
|
|
35
|
+
| `loading` | `boolean` | No | — | If the progress bar is loading, the progress indicators aren't rendered on the screen |
|
|
36
|
+
| `reverseTheme` | `boolean` | No | `false` | If the amountFormatted and totalAmountFormatted text needs to appear more visibile because of the background, for exa... |
|
|
37
|
+
| `size` | `"smaller" | "small" | "base"` | No | `base` | Set the size of the progress bar |
|
|
38
|
+
| `UNSAFE_style` | `ProgressBarUnsafeStyle` | No | — | **Use at your own risk:** Custom style for specific elements. This should only be used as a **last resort**. Using th... |
|
|
39
|
+
| `variation` | `"progress" | "stepped"` | No | `progress` | Set the variation of the progress bar |
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Border Radius
|
|
2
|
+
|
|
3
|
+
This base radius can be found in almost all of our components that have a
|
|
4
|
+
defined "edge": [Button](../Button/Button.md), [Card](../Card/Card.md),
|
|
5
|
+
[InputText](../InputText/InputText.md), and [Menu](/components/Menu) are all
|
|
6
|
+
examples of this in practice.
|
|
7
|
+
|
|
8
|
+
If an element is nested directly inside of a container with the base radius, or
|
|
9
|
+
is itself smaller than the base radius, the small radius may be applied.
|
|
10
|
+
|
|
11
|
+
Larger rounded corners should be used sparingly, but are available for cases
|
|
12
|
+
where the user may expect a smoother corner, such as
|
|
13
|
+
[ProgressBar](../ProgressBar/ProgressBar.md). `--radius-circle` can be used for
|
|
14
|
+
circular elements like [Radio](/components/RadioGroup) options or the "pip" in
|
|
15
|
+
[Switch](../Switch/Switch.md).
|
|
16
|
+
|
|
17
|
+
| Radius | Visual |
|
|
18
|
+
| :---------------- | :----- |
|
|
19
|
+
| `--radius-small` | |
|
|
20
|
+
| `--radius-base` | |
|
|
21
|
+
| `--radius-large` | |
|
|
22
|
+
| `--radius-larger` | |
|
|
23
|
+
| `--radius-circle` | |
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Responsive Breakpoints
|
|
2
|
+
|
|
3
|
+
We have 3 different ways to deal with responsive breakpoints in our components.
|
|
4
|
+
|
|
5
|
+
1. CSS variables (`@custom-media`) that are relative to the browser size.
|
|
6
|
+
2. [`useBreakpoints` hook](/hooks/useBreakpoints) that is the JS counterpart of
|
|
7
|
+
the CSS variables.
|
|
8
|
+
3. [`useResizeObserver` hook](/hooks/useResizeObserver) that is used to make
|
|
9
|
+
components responsive depending on the size of its container rather than the
|
|
10
|
+
browser.
|
|
11
|
+
|
|
12
|
+
## CSS variables
|
|
13
|
+
|
|
14
|
+
We have 5 CSS breakpoints that you can choose from when styling your components.
|
|
15
|
+
|
|
16
|
+
| Breakpoint | Width |
|
|
17
|
+
| :----------------------------- | :---------- |
|
|
18
|
+
| `--small-screens-and-below` | `< 490px` |
|
|
19
|
+
| `--small-screens-and-up` | `>= 490px` |
|
|
20
|
+
| `--medium-screens-and-up` | `>= 768px` |
|
|
21
|
+
| `--large-screens-and-up` | `>= 1080px` |
|
|
22
|
+
| `--extra-large-screens-and-up` | `>= 1440px` |
|
|
23
|
+
|
|
24
|
+
### Usage
|
|
25
|
+
|
|
26
|
+
Components should be styled mobile-first, meaning that they should be styled for
|
|
27
|
+
small screens and then scaled up. This means that the
|
|
28
|
+
`--small-screens-and-below` breakpoint should be rarely considered.
|
|
29
|
+
|
|
30
|
+
Media queries can also be nested inside selectors. This will help with clarity
|
|
31
|
+
when reading your CSS.
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
.foo {
|
|
35
|
+
/** small screens first **/
|
|
36
|
+
padding: var(--space-base);
|
|
37
|
+
|
|
38
|
+
@media (--medium-screens-and-up) {
|
|
39
|
+
padding: var(--space-large);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@media (--large-screens-and-up) {
|
|
43
|
+
padding: var(--space-extravagant);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### Caveat
|
|
49
|
+
|
|
50
|
+
We use [custom-media](https://www.w3.org/TR/mediaqueries-5/#custom-mq) that
|
|
51
|
+
creates a CSS variable-like pattern for media queries. It isn't widely supported
|
|
52
|
+
yet so you'd have to install
|
|
53
|
+
[postcss-custom-media](https://www.npmjs.com/package/postcss-custom-media) on
|
|
54
|
+
your compiler to transform them back to normal media queries.
|
|
55
|
+
|
|
56
|
+
### Deprecated breakpoints
|
|
57
|
+
|
|
58
|
+
| Breakpoint | Width |
|
|
59
|
+
| :----------------- | :---------- |
|
|
60
|
+
| `--handhelds` | `< 640px` |
|
|
61
|
+
| `--medium-screens` | `>= 640px` |
|
|
62
|
+
| `--wide-screens` | `>= 1024px` |
|
|
63
|
+
|
|
64
|
+
## 2. useBreakpoints hook
|
|
65
|
+
|
|
66
|
+
This closely mimics the CSS breakpoints but you can use within a JS code. Read
|
|
67
|
+
more about useBreakpoints [here](/hooks/useBreakpoints).
|
|
68
|
+
|
|
69
|
+
## 3. useResizeObserver hook
|
|
70
|
+
|
|
71
|
+
To make components responsive depending on the size of its container rather than
|
|
72
|
+
the browser, you should use the
|
|
73
|
+
[useResizeObserver hook](/hooks/useResizeObserver) so that the component can be
|
|
74
|
+
responsive based on its container.
|