@coinbase/cds-mcp-server 8.31.3 → 8.31.5

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/CHANGELOG.md CHANGED
@@ -8,6 +8,14 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  <!-- template-start -->
10
10
 
11
+ ## 8.31.5 ((12/16/2025, 03:27 PM PST))
12
+
13
+ This is an artificial version bump with no new change.
14
+
15
+ ## 8.31.4 ((12/16/2025, 10:41 AM PST))
16
+
17
+ This is an artificial version bump with no new change.
18
+
11
19
  ## 8.31.3 ((12/16/2025, 07:55 AM PST))
12
20
 
13
21
  This is an artificial version bump with no new change.
@@ -0,0 +1,559 @@
1
+ # DateInput
2
+
3
+ DateInput is a text input field for entering dates by typing. The input automatically formats dates based on the user's locale.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { DateInput } from '@coinbase/cds-mobile/dates/DateInput'
9
+ ```
10
+
11
+ ## Examples
12
+
13
+ DateInput uses [TextInput](/components/inputs/TextInput/) for entering dates by typing. Check out [DatePicker](/components/other/DatePicker/) if you would like [Calendar](/components/other/Calendar/) to be shown in a popup as well.
14
+
15
+ ### Basics
16
+
17
+ DateInput requires controlled state for both the date value and error state. The component automatically formats dates based on the user's locale and validates input on blur.
18
+
19
+ ```jsx
20
+ function Example() {
21
+ const [date, setDate] = useState(null);
22
+ const [error, setError] = useState(null);
23
+
24
+ return (
25
+ <DateInput
26
+ date={date}
27
+ error={error}
28
+ onChangeDate={setDate}
29
+ onErrorDate={setError}
30
+ label="Birthdate"
31
+ invalidDateError="Please enter a valid date"
32
+ requiredError="This field is required"
33
+ disabledDateError="Date unavailable"
34
+ />
35
+ );
36
+ }
37
+ ```
38
+
39
+ #### Validation
40
+
41
+ ##### Minimum and maximum dates
42
+
43
+ Use `minDate` and `maxDate` props to restrict the date range. Provide the `disabledDateError` prop to show an error when users enter a date outside the allowed range.
44
+
45
+ ```jsx
46
+ function Example() {
47
+ const [date, setDate] = useState(null);
48
+ const [error, setError] = useState(null);
49
+
50
+ const today = new Date(new Date().setHours(0, 0, 0, 0));
51
+ const oneYearAgo = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());
52
+ const oneYearLater = new Date(today.getFullYear() + 1, today.getMonth(), today.getDate());
53
+
54
+ return (
55
+ <DateInput
56
+ date={date}
57
+ error={error}
58
+ onChangeDate={setDate}
59
+ onErrorDate={setError}
60
+ minDate={oneYearAgo}
61
+ maxDate={oneYearLater}
62
+ label="Date within range"
63
+ helperText="Date must be within one year of today"
64
+ invalidDateError="Please enter a valid date"
65
+ disabledDateError="Date must be within one year of today"
66
+ />
67
+ );
68
+ }
69
+ ```
70
+
71
+ ##### Disabled dates
72
+
73
+ The `disabledDates` prop accepts an array of `Date` objects or `[Date, Date]` tuples to disable specific dates or ranges.
74
+
75
+ ```jsx
76
+ function Example() {
77
+ const [date, setDate] = useState(null);
78
+ const [error, setError] = useState(null);
79
+
80
+ const today = new Date(new Date().setHours(0, 0, 0, 0));
81
+ const oneWeekAgo = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);
82
+ const twoDaysAgo = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 2);
83
+ const oneWeekLater = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 7);
84
+
85
+ const disabledDates = [[oneWeekAgo, twoDaysAgo], oneWeekLater];
86
+
87
+ return (
88
+ <DateInput
89
+ date={date}
90
+ error={error}
91
+ onChangeDate={setDate}
92
+ onErrorDate={setError}
93
+ disabledDates={disabledDates}
94
+ label="Birthdate"
95
+ invalidDateError="Please enter a valid date"
96
+ disabledDateError="Date unavailable"
97
+ />
98
+ );
99
+ }
100
+ ```
101
+
102
+ ##### Custom validation
103
+
104
+ Use the `DateInputValidationError` class to create custom error states for application-specific validation rules.
105
+
106
+ ```jsx
107
+ function Example() {
108
+ const [date, setDate] = useState(null);
109
+ const [error, setError] = useState(null);
110
+
111
+ const handleChangeDate = (newDate) => {
112
+ setDate(newDate);
113
+ if (newDate && newDate <= new Date()) {
114
+ setError(new DateInputValidationError('custom', 'Date must be in the future'));
115
+ } else {
116
+ setError(null);
117
+ }
118
+ };
119
+
120
+ return (
121
+ <DateInput
122
+ date={date}
123
+ error={error}
124
+ onChangeDate={handleChangeDate}
125
+ onErrorDate={setError}
126
+ label="Future date only"
127
+ invalidDateError="Please enter a valid date"
128
+ />
129
+ );
130
+ }
131
+ ```
132
+
133
+ ### Accessibility
134
+
135
+ DateInput inherits accessibility props from TextInput. If no `accessibilityLabel` is passed, it will use the `label` as the `accessibilityLabel`. If you want an `accessibilityLabel` that differs from the label, you can set this prop.
136
+
137
+ Here, since no `accessibilityLabel` is passed, the `accessibilityLabel` will be "Birthdate".
138
+
139
+ ```jsx
140
+ <DateInput label="Birthdate" />
141
+ ```
142
+
143
+ Example of passing an `accessibilityLabel`:
144
+
145
+ ```jsx
146
+ <DateInput accessibilityLabel="Enter your date of birth" label="Birthdate" />
147
+ ```
148
+
149
+ :::tip Accessibility tip
150
+
151
+ Like any component system, much of the responsibility for building accessible UIs is in your hands as the consumer to properly implement the component composition. We'll do our best to provide sane fallbacks, but here are the biggest gotchas for `DateInput`s you can watch out for.
152
+
153
+ <br />
154
+
155
+ ##### Error message format
156
+
157
+ It's advised you always format error messages with `Error: ${errorMessage}`. We'd do that for you, but _i18n_ isn't baked into CDS. DateInput automatically switches to `variant="negative"` when an error is present.
158
+
159
+ :::
160
+
161
+ ### Localization
162
+
163
+ The date format automatically adjusts based on the `LocaleContext` provided by `LocaleProvider`.
164
+
165
+ ```jsx
166
+ function Example() {
167
+ const [usDate, setUsDate] = useState(null);
168
+ const [usError, setUsError] = useState(null);
169
+ const [esDate, setEsDate] = useState(null);
170
+ const [esError, setEsError] = useState(null);
171
+
172
+ return (
173
+ <VStack gap={3}>
174
+ <VStack>
175
+ <Text font="label2" color="fgMuted">
176
+ English (US) - MM/DD/YYYY
177
+ </Text>
178
+ <DateInput
179
+ date={usDate}
180
+ error={usError}
181
+ onChangeDate={setUsDate}
182
+ onErrorDate={setUsError}
183
+ label="Date"
184
+ invalidDateError="Please enter a valid date"
185
+ />
186
+ </VStack>
187
+ <LocaleProvider locale="es-ES">
188
+ <VStack>
189
+ <Text font="label2" color="fgMuted">
190
+ Spanish - DD/MM/YYYY
191
+ </Text>
192
+ <DateInput
193
+ date={esDate}
194
+ error={esError}
195
+ onChangeDate={setEsDate}
196
+ onErrorDate={setEsError}
197
+ label="Fecha"
198
+ invalidDateError="Ingrese una fecha válida"
199
+ />
200
+ </VStack>
201
+ </LocaleProvider>
202
+ </VStack>
203
+ );
204
+ }
205
+ ```
206
+
207
+ ### Styling
208
+
209
+ #### Compact
210
+
211
+ Use the `compact` prop for a smaller input size.
212
+
213
+ ```jsx
214
+ function Example() {
215
+ const [date, setDate] = useState(null);
216
+ const [error, setError] = useState(null);
217
+
218
+ return (
219
+ <VStack gap={3}>
220
+ <DateInput
221
+ date={date}
222
+ error={error}
223
+ onChangeDate={setDate}
224
+ onErrorDate={setError}
225
+ label="Default size"
226
+ invalidDateError="Please enter a valid date"
227
+ />
228
+ <DateInput
229
+ compact
230
+ date={date}
231
+ error={error}
232
+ onChangeDate={setDate}
233
+ onErrorDate={setError}
234
+ label="Compact size"
235
+ invalidDateError="Please enter a valid date"
236
+ />
237
+ </VStack>
238
+ );
239
+ }
240
+ ```
241
+
242
+ #### Disabled
243
+
244
+ ```jsx
245
+ function Example() {
246
+ const [date, setDate] = useState(new Date());
247
+ const [error, setError] = useState(null);
248
+
249
+ return (
250
+ <DateInput
251
+ disabled
252
+ date={date}
253
+ error={error}
254
+ onChangeDate={setDate}
255
+ onErrorDate={setError}
256
+ label="Disabled input"
257
+ invalidDateError="Please enter a valid date"
258
+ />
259
+ );
260
+ }
261
+ ```
262
+
263
+ #### Helper text
264
+
265
+ ```jsx
266
+ function Example() {
267
+ const [date, setDate] = useState(null);
268
+ const [error, setError] = useState(null);
269
+
270
+ return (
271
+ <DateInput
272
+ date={date}
273
+ error={error}
274
+ onChangeDate={setDate}
275
+ onErrorDate={setError}
276
+ label="Start date"
277
+ helperText="Select when you'd like to begin"
278
+ invalidDateError="Please enter a valid date"
279
+ />
280
+ );
281
+ }
282
+ ```
283
+
284
+ #### Label
285
+
286
+ If you need to render a custom label (e.g. a label with a tooltip), you can use the `labelNode` prop.
287
+
288
+ ```jsx
289
+ function Example() {
290
+ const [date, setDate] = useState(null);
291
+ const [error, setError] = useState(null);
292
+
293
+ return (
294
+ <DateInput
295
+ date={date}
296
+ error={error}
297
+ onChangeDate={setDate}
298
+ onErrorDate={setError}
299
+ label="Birthdate"
300
+ labelNode={
301
+ <HStack alignItems="center" gap={1}>
302
+ <InputLabel>Birthdate</InputLabel>
303
+ <Tooltip content="This will be visible to other users.">
304
+ <Icon active color="fg" name="info" size="xs" />
305
+ </Tooltip>
306
+ </HStack>
307
+ }
308
+ invalidDateError="Please enter a valid date"
309
+ />
310
+ );
311
+ }
312
+ ```
313
+
314
+ #### Required
315
+
316
+ Use the `required` prop to indicate that the field is mandatory. Provide `requiredError` to display a message if the user blurs the input without a date after typing.
317
+
318
+ ```jsx
319
+ function Example() {
320
+ const [date, setDate] = useState(null);
321
+ const [error, setError] = useState(null);
322
+
323
+ return (
324
+ <DateInput
325
+ required
326
+ date={date}
327
+ error={error}
328
+ onChangeDate={setDate}
329
+ onErrorDate={setError}
330
+ label="Birthdate"
331
+ invalidDateError="Please enter a valid date"
332
+ requiredError="This field is required"
333
+ />
334
+ );
335
+ }
336
+ ```
337
+
338
+ #### Variants
339
+
340
+ Use the `variant` prop to change the visual style of the input.
341
+
342
+ ```jsx
343
+ function Example() {
344
+ const [date, setDate] = useState(null);
345
+ const [error, setError] = useState(null);
346
+
347
+ return (
348
+ <VStack gap={3}>
349
+ <DateInput
350
+ date={date}
351
+ error={error}
352
+ onChangeDate={setDate}
353
+ onErrorDate={setError}
354
+ label="Default variant"
355
+ invalidDateError="Please enter a valid date"
356
+ />
357
+ <DateInput
358
+ variant="secondary"
359
+ date={date}
360
+ error={error}
361
+ onChangeDate={setDate}
362
+ onErrorDate={setError}
363
+ label="Secondary variant"
364
+ invalidDateError="Please enter a valid date"
365
+ />
366
+ </VStack>
367
+ );
368
+ }
369
+ ```
370
+
371
+ #### Separator
372
+
373
+ Customize the date format separator using the `separator` prop. Defaults to `/`.
374
+
375
+ ```jsx
376
+ function Example() {
377
+ const [date1, setDate1] = useState(null);
378
+ const [error1, setError1] = useState(null);
379
+ const [date2, setDate2] = useState(null);
380
+ const [error2, setError2] = useState(null);
381
+
382
+ return (
383
+ <VStack gap={3}>
384
+ <DateInput
385
+ date={date1}
386
+ error={error1}
387
+ onChangeDate={setDate1}
388
+ onErrorDate={setError1}
389
+ separator="/"
390
+ label="Slash separator"
391
+ invalidDateError="Please enter a valid date"
392
+ />
393
+ <DateInput
394
+ date={date2}
395
+ error={error2}
396
+ onChangeDate={setDate2}
397
+ onErrorDate={setError2}
398
+ separator="-"
399
+ label="Dash separator"
400
+ invalidDateError="Please enter a valid date"
401
+ />
402
+ </VStack>
403
+ );
404
+ }
405
+ ```
406
+
407
+ #### Start and end adornments
408
+
409
+ Use the `start` and `end` props to add icons or other elements to the input.
410
+
411
+ ```jsx
412
+ function Example() {
413
+ const [date, setDate] = useState(null);
414
+ const [error, setError] = useState(null);
415
+
416
+ return (
417
+ <DateInput
418
+ date={date}
419
+ error={error}
420
+ onChangeDate={setDate}
421
+ onErrorDate={setError}
422
+ label="Event date"
423
+ start={<Icon name="calendarEmpty" size="m" />}
424
+ invalidDateError="Please enter a valid date"
425
+ />
426
+ );
427
+ }
428
+ ```
429
+
430
+ ### Event lifecycle
431
+
432
+ The DateInput fires events in a specific order:
433
+
434
+ - Typing a date in a blank DateInput:
435
+
436
+ `onChange -> onChange -> ... -> onChangeDate -> onErrorDate`
437
+
438
+ - Typing a date in a DateInput that already had a date:
439
+
440
+ `onChange -> onChangeDate -> onChange -> onChange -> ... -> onChangeDate -> onErrorDate`
441
+
442
+ ## Props
443
+
444
+ | Prop | Type | Required | Default | Description |
445
+ | --- | --- | --- | --- | --- |
446
+ | `date` | `Date \| null` | Yes | `-` | Control the date value of the DateInput. |
447
+ | `error` | `DateInputValidationError \| null` | Yes | `-` | Control the error value of the DateInput. |
448
+ | `onChangeDate` | `(date: Date \| null) => void` | Yes | `-` | Callback function fired when the date changes, e.g. when a valid date is selected or unselected. |
449
+ | `onErrorDate` | `(error: DateInputValidationError \| null) => void` | Yes | `-` | Callback function fired when validation finds an error, e.g. required input fields and impossible or disabled dates. Will always be called after onChangeDate. |
450
+ | `align` | `end \| start \| center \| justify` | No | `start` | Aligns text inside input and helperText |
451
+ | `allowFontScaling` | `boolean` | No | `-` | Specifies whether fonts should scale to respect Text Size accessibility settings. The default is true. |
452
+ | `autoCapitalize` | `none \| sentences \| words \| characters` | No | `-` | Can tell TextInput to automatically capitalize certain characters. characters: all characters, words: first letter of each word sentences: first letter of each sentence (default) none: dont auto capitalize anything https://reactnative.dev/docs/textinput#autocapitalize |
453
+ | `autoComplete` | `email \| off \| name \| additional-name \| address-line1 \| address-line2 \| birthdate-day \| birthdate-full \| birthdate-month \| birthdate-year \| cc-csc \| cc-exp \| cc-exp-day \| cc-exp-month \| cc-exp-year \| cc-number \| cc-name \| cc-given-name \| cc-middle-name \| cc-family-name \| cc-type \| country \| current-password \| family-name \| gender \| given-name \| honorific-prefix \| honorific-suffix \| name-family \| name-given \| name-middle \| name-middle-initial \| name-prefix \| name-suffix \| new-password \| nickname \| one-time-code \| organization \| organization-title \| password \| password-new \| postal-address \| postal-address-country \| postal-address-extended \| postal-address-extended-postal-code \| postal-address-locality \| postal-address-region \| postal-code \| street-address \| sms-otp \| tel \| tel-country-code \| tel-national \| tel-device \| url \| username \| username-new` | No | `-` | Specifies autocomplete hints for the system, so it can provide autofill. On Android, the system will always attempt to offer autofill by using heuristics to identify the type of content. To disable autocomplete, set autoComplete to off. The following values work across platforms: - additional-name - address-line1 - address-line2 - cc-number - country - current-password - email - family-name - given-name - honorific-prefix - honorific-suffix - name - new-password - off - one-time-code - postal-code - street-address - tel - username The following values work on iOS only: - nickname - organization - organization-title - url The following values work on Android only: - birthdate-day - birthdate-full - birthdate-month - birthdate-year - cc-csc - cc-exp - cc-exp-day - cc-exp-month - cc-exp-year - gender - name-family - name-given - name-middle - name-middle-initial - name-prefix - name-suffix - password - password-new - postal-address - postal-address-country - postal-address-extended - postal-address-extended-postal-code - postal-address-locality - postal-address-region - sms-otp - tel-country-code - tel-national - tel-device - username-new |
454
+ | `autoCorrect` | `boolean` | No | `-` | If false, disables auto-correct. The default value is true. |
455
+ | `autoFocus` | `boolean` | No | `-` | If true, focuses the input on componentDidMount. The default value is false. |
456
+ | `blurOnSubmit` | `boolean` | No | `-` | If true, the text field will blur when submitted. The default value is true. |
457
+ | `borderRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `200` | Leverage one of the borderRadius styles we offer to round the corners of the input. |
458
+ | `bordered` | `boolean` | No | `true` | Determines if the input should have a border |
459
+ | `caretHidden` | `boolean` | No | `-` | If true, caret is hidden. The default value is false. |
460
+ | `clearButtonMode` | `never \| while-editing \| unless-editing \| always` | No | `-` | enum(never, while-editing, unless-editing, always) When the clear button should appear on the right side of the text view |
461
+ | `clearTextOnFocus` | `boolean` | No | `-` | If true, clears the text field automatically when editing begins |
462
+ | `compact` | `boolean` | No | `false` | Enables compact variation |
463
+ | `contextMenuHidden` | `boolean` | No | `-` | If true, context menu is hidden. The default value is false. |
464
+ | `cursorColor` | `ColorValue \| null` | No | `-` | When provided it will set the color of the cursor (or caret) in the component. Unlike the behavior of selectionColor the cursor color will be set independently from the color of the text selection box. |
465
+ | `dataDetectorTypes` | `DataDetectorTypes \| DataDetectorTypes[]` | No | `-` | Determines the types of data converted to clickable URLs in the text input. Only valid if multiline={true} and editable={false}. By default no data types are detected. You can provide one type or an array of many types. Possible values for dataDetectorTypes are: - phoneNumber - link - address - calendarEvent - none - all |
466
+ | `disableFullscreenUI` | `boolean` | No | `-` | When false, if there is a small amount of space available around a text input (e.g. landscape orientation on a phone), the OS may choose to have the user edit the text inside of a full screen text input mode. When true, this feature is disabled and users will always edit the text directly inside of the text input. Defaults to false. |
467
+ | `disabled` | `boolean` | No | `false` | Toggles input interactability and opacity |
468
+ | `disabledDateError` | `string` | No | `'Date unavailable'` | Error text to display when a disabled date is selected, including dates before the minDate or after the maxDate. However if the selected date is more than 100 years before the minDate or more than 100 years after the maxDate, the invalidDateError will be displayed instead. |
469
+ | `editable` | `boolean` | No | `-` | If false, text is not editable. The default value is true. |
470
+ | `enableColorSurge` | `boolean` | No | `-` | Enable Color Surge motion |
471
+ | `enablesReturnKeyAutomatically` | `boolean` | No | `-` | If true, the keyboard disables the return key when there is no text and automatically enables it when there is text. The default value is false. |
472
+ | `end` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Adds content to the end of the inner input. Refer to diagram for location of endNode in InputStack component |
473
+ | `enterKeyHint` | `search \| done \| go \| next \| send \| previous \| enter` | No | `-` | Determines what text should be shown to the return key on virtual keyboards. Has precedence over the returnKeyType prop. |
474
+ | `height` | `string \| number` | No | `-` | Height of input |
475
+ | `helperText` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | For cases where label is not enough information to describe what the text input is for. Can also be used for showing positive/negative messages |
476
+ | `helperTextErrorIconAccessibilityLabel` | `string` | No | `'error'` | Accessibility label for helper text error icon when variant=negative |
477
+ | `importantForAutofill` | `auto \| yes \| no \| noExcludeDescendants \| yesExcludeDescendants` | No | `-` | Determines whether the individual fields in your app should be included in a view structure for autofill purposes on Android API Level 26+. Defaults to auto. To disable auto complete, use off. *Android Only* The following values work on Android only: - auto - let Android decide - no - not important for autofill - noExcludeDescendants - this view and its children arent important for autofill - yes - is important for autofill - yesExcludeDescendants - this view is important for autofill but its children arent |
478
+ | `inlineImageLeft` | `string` | No | `-` | If defined, the provided image resource will be rendered on the left. |
479
+ | `inlineImagePadding` | `number` | No | `-` | Padding between the inline image, if any, and the text input itself. |
480
+ | `inputAccessoryViewID` | `string` | No | `-` | Used to connect to an InputAccessoryView. Not part of react-natives documentation, but present in examples and code. See https://reactnative.dev/docs/inputaccessoryview for more information. |
481
+ | `inputBackground` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `'bg'` | Background color of the input |
482
+ | `inputMode` | `search \| none \| text \| email \| tel \| url \| numeric \| decimal` | No | `-` | Works like the inputmode attribute in HTML, it determines which keyboard to open, e.g. numeric and has precedence over keyboardType. |
483
+ | `invalidDateError` | `string` | No | `'Please enter a valid date'` | Error text to display when an impossible date is selected, e.g. 99/99/2000. This should always be defined for accessibility. Also displays when a date is selected that is more than 100 years before the minDate, or more than 100 years after the maxDate. |
484
+ | `key` | `Key \| null` | No | `-` | - |
485
+ | `keyboardAppearance` | `light \| default \| dark` | No | `-` | Determines the color of the keyboard. |
486
+ | `keyboardType` | `default \| url \| number-pad \| decimal-pad \| numeric \| email-address \| phone-pad \| visible-password \| ascii-capable \| numbers-and-punctuation \| name-phone-pad \| twitter \| web-search` | No | `-` | enum(default, numeric, email-address, ascii-capable, numbers-and-punctuation, url, number-pad, phone-pad, name-phone-pad, decimal-pad, twitter, web-search, visible-password) Determines which keyboard to open, e.g.numeric. The following values work across platforms: - default - numeric - email-address - phone-pad The following values work on iOS: - ascii-capable - numbers-and-punctuation - url - number-pad - name-phone-pad - decimal-pad - twitter - web-search The following values work on Android: - visible-password |
487
+ | `label` | `string` | No | `-` | Short messageArea indicating purpose of input |
488
+ | `labelNode` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | React node to render label. Takes precedence over label. |
489
+ | `labelVariant` | `inside \| outside` | No | `'outside'` | The variant of the label. Only used when compact is not true. |
490
+ | `lineBreakStrategyIOS` | `none \| standard \| hangul-word \| push-out` | No | `-` | Set line break strategy on iOS. |
491
+ | `maxDate` | `Date` | No | `-` | Maximum date allowed to be selected, inclusive. Dates after the maxDate are disabled. Make sure to set disabledDateError as well. |
492
+ | `maxFontSizeMultiplier` | `number \| null` | No | `-` | Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values: - null/undefined (default): inherit from the parent node or the global default (0) - 0: no max, ignore parent/global default - >= 1: sets the maxFontSizeMultiplier of this node to this value |
493
+ | `maxLength` | `number` | No | `-` | Limits the maximum number of characters that can be entered. Use this instead of implementing the logic in JS to avoid flicker. |
494
+ | `minDate` | `Date` | No | `-` | Minimum date allowed to be selected, inclusive. Dates before the minDate are disabled. Make sure to set disabledDateError as well. |
495
+ | `minHeight` | `string \| number` | No | `auto` | minimum height of input |
496
+ | `multiline` | `boolean` | No | `-` | If true, the text input can be multiple lines. The default value is false. |
497
+ | `numberOfLines` | `number` | No | `-` | Sets the number of lines for a TextInput. Use it with multiline set to true to be able to fill the lines. |
498
+ | `onBlur` | `((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)` | No | `-` | Callback that is called when the text input is blurred |
499
+ | `onChange` | `((e: NativeSyntheticEvent<TextInputChangeEventData>) => void)` | No | `-` | - |
500
+ | `onChangeText` | `((text: string) => void)` | No | `-` | - |
501
+ | `onContentSizeChange` | `((e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => void)` | No | `-` | Callback that is called when the text inputs content size changes. This will be called with { nativeEvent: { contentSize: { width, height } } }. Only called for multiline text inputs. |
502
+ | `onEndEditing` | `((e: NativeSyntheticEvent<TextInputEndEditingEventData>) => void)` | No | `-` | Callback that is called when text input ends. |
503
+ | `onFocus` | `((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)` | No | `-` | Callback that is called when the text input is focused |
504
+ | `onKeyPress` | `((e: NativeSyntheticEvent<TextInputKeyPressEventData>) => void)` | No | `-` | Callback that is called when a key is pressed. This will be called with { nativeEvent: { key: keyValue } } where keyValue is Enter or Backspace for respective keys and the typed-in character otherwise including for space. Fires before onChange callbacks. Note: on Android only the inputs from soft keyboard are handled, not the hardware keyboard inputs. |
505
+ | `onPointerCancel` | `((event: PointerEvent) => void)` | No | `-` | - |
506
+ | `onPointerCancelCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
507
+ | `onPointerDown` | `((event: PointerEvent) => void)` | No | `-` | - |
508
+ | `onPointerDownCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
509
+ | `onPointerEnter` | `((event: PointerEvent) => void)` | No | `-` | - |
510
+ | `onPointerEnterCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
511
+ | `onPointerLeave` | `((event: PointerEvent) => void)` | No | `-` | - |
512
+ | `onPointerLeaveCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
513
+ | `onPointerMove` | `((event: PointerEvent) => void)` | No | `-` | - |
514
+ | `onPointerMoveCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
515
+ | `onPointerUp` | `((event: PointerEvent) => void)` | No | `-` | - |
516
+ | `onPointerUpCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
517
+ | `onPress` | `((e: NativeSyntheticEvent<NativeTouchEvent>) => void)` | No | `-` | Called when a single tap gesture is detected. |
518
+ | `onPressIn` | `((e: NativeSyntheticEvent<NativeTouchEvent>) => void)` | No | `-` | Callback that is called when a touch is engaged. |
519
+ | `onPressOut` | `((e: NativeSyntheticEvent<NativeTouchEvent>) => void)` | No | `-` | Callback that is called when a touch is released. |
520
+ | `onScroll` | `((e: NativeSyntheticEvent<TextInputScrollEventData>) => void)` | No | `-` | Invoked on content scroll with { nativeEvent: { contentOffset: { x, y } } }. May also contain other properties from ScrollEvent but on Android contentSize is not provided for performance reasons. |
521
+ | `onSelectionChange` | `((e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void)` | No | `-` | Callback that is called when the text input selection is changed. |
522
+ | `onSubmitEditing` | `((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)` | No | `-` | Callback that is called when the text inputs submit button is pressed. |
523
+ | `onTextInput` | `((e: NativeSyntheticEvent<TextInputTextInputEventData>) => void)` | No | `-` | Callback that is called on new text input with the argument { nativeEvent: { text, previousText, range: { start, end } } }. This prop requires multiline={true} to be set. |
524
+ | `passwordRules` | `string \| null` | No | `-` | Provide rules for your password. For example, say you want to require a password with at least eight characters consisting of a mix of uppercase and lowercase letters, at least one number, and at most two consecutive characters. required: upper; required: lower; required: digit; max-consecutive: 2; minlength: 8; |
525
+ | `placeholder` | `string` | No | `-` | Placeholder text displayed inside of the input. Will be replaced if there is a value. The string that will be rendered before text input has been entered |
526
+ | `placeholderTextColor` | `string \| OpaqueColorValue` | No | `-` | The text color of the placeholder string |
527
+ | `readOnly` | `boolean` | No | `-` | If true, text is not editable. The default value is false. |
528
+ | `ref` | `((instance: TextInput \| null) => void) \| RefObject<TextInput> \| null` | No | `-` | - |
529
+ | `rejectResponderTermination` | `boolean \| null` | No | `-` | If true, allows TextInput to pass touch events to the parent component. This allows components to be swipeable from the TextInput on iOS, as is the case on Android by default. If false, TextInput always asks to handle the input (except when disabled). |
530
+ | `required` | `boolean` | No | `-` | If required, the requiredError will be displayed if a user blurs the input, without a date selected, after having typed into it. |
531
+ | `requiredError` | `string` | No | `'This field is required'` | Error text to display when required is true and a user blurs the input without a date selected, after having typed into it. |
532
+ | `returnKeyLabel` | `string` | No | `-` | Sets the return key to the label. Use it instead of returnKeyType. |
533
+ | `returnKeyType` | `search \| join \| done \| none \| default \| go \| next \| send \| previous \| google \| route \| yahoo \| emergency-call` | No | `-` | enum(default, go, google, join, next, route, search, send, yahoo, done, emergency-call) Determines how the return key should look. |
534
+ | `scrollEnabled` | `boolean` | No | `-` | If false, scrolling of the text view will be disabled. The default value is true. Only works with multiline={true} |
535
+ | `secureTextEntry` | `boolean` | No | `-` | If true, the text input obscures the text entered so that sensitive text like passwords stay secure. The default value is false. |
536
+ | `selectTextOnFocus` | `boolean` | No | `-` | If true, all text will automatically be selected on focus |
537
+ | `selection` | `{ start: number; end?: number; } \| undefined` | No | `-` | The start and end of the text inputs selection. Set start and end to the same value to position the cursor. |
538
+ | `selectionColor` | `string \| OpaqueColorValue` | No | `-` | The highlight (and cursor on ios) color of the text input |
539
+ | `selectionHandleColor` | `ColorValue \| null` | No | `-` | When provided it will set the color of the selection handles when highlighting text. Unlike the behavior of selectionColor the handle color will be set independently from the color of the text selection box. |
540
+ | `selectionState` | `DocumentSelectionState` | No | `-` | See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document |
541
+ | `separator` | `string` | No | `-` | Date format separator character, e.g. the / in MM/DD/YYYY. Defaults to forward slash (/). |
542
+ | `showSoftInputOnFocus` | `boolean` | No | `-` | When false, it will prevent the soft keyboard from showing when the field is focused. The default value is true |
543
+ | `smartInsertDelete` | `boolean` | No | `-` | If false, the iOS system will not insert an extra space after a paste operation neither delete one or two spaces after a cut or delete operation. The default value is true. |
544
+ | `spellCheck` | `boolean` | No | `-` | If false, disables spell-check style (i.e. red underlines). The default value is inherited from autoCorrect |
545
+ | `start` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Adds content to the start of the inner input. Refer to diagram for location of startNode in InputStack component |
546
+ | `style` | `null \| false \| ViewStyle \| RegisteredStyle<ViewStyle> \| RecursiveArray<ViewStyle \| Falsy \| RegisteredStyle<ViewStyle>>` | No | `-` | - |
547
+ | `suffix` | `string` | No | `-` | Adds suffix text to the end of input |
548
+ | `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID Used to locate this view in end-to-end tests |
549
+ | `testIDMap` | `{ start?: string; end?: string \| undefined; label?: string \| undefined; helperText?: string \| undefined; } \| undefined` | No | `-` | Add ability to test individual parts of the input |
550
+ | `textAlign` | `left \| right \| center \| unset` | No | `-` | Native TextInput textAlign with the extra unset option to remove the textAlign style. Use this to workaround the issue where long text does not ellipsis in TextInput |
551
+ | `textAlignVertical` | `top \| bottom \| auto \| center` | No | `-` | Vertically align text when multiline is set to true |
552
+ | `textBreakStrategy` | `simple \| highQuality \| balanced` | No | `-` | Set text break strategy on Android API Level 23+, possible values are simple, highQuality, balanced The default value is simple. |
553
+ | `textContentType` | `none \| location \| name \| nickname \| password \| username \| URL \| addressCity \| addressCityAndState \| addressState \| countryName \| creditCardNumber \| creditCardExpiration \| creditCardExpirationMonth \| creditCardExpirationYear \| creditCardSecurityCode \| creditCardType \| creditCardName \| creditCardGivenName \| creditCardMiddleName \| creditCardFamilyName \| emailAddress \| familyName \| fullStreetAddress \| givenName \| jobTitle \| middleName \| namePrefix \| nameSuffix \| organizationName \| postalCode \| streetAddressLine1 \| streetAddressLine2 \| sublocality \| telephoneNumber \| newPassword \| oneTimeCode \| birthdate \| birthdateDay \| birthdateMonth \| birthdateYear` | No | `-` | Give the keyboard and the system information about the expected semantic meaning for the content that users enter. To disable autofill, set textContentType to none. Possible values for textContentType are: - none - URL - addressCity - addressCityAndState - addressState - countryName - creditCardNumber - creditCardExpiration (iOS 17+) - creditCardExpirationMonth (iOS 17+) - creditCardExpirationYear (iOS 17+) - creditCardSecurityCode (iOS 17+) - creditCardType (iOS 17+) - creditCardName (iOS 17+) - creditCardGivenName (iOS 17+) - creditCardMiddleName (iOS 17+) - creditCardFamilyName (iOS 17+) - emailAddress - familyName - fullStreetAddress - givenName - jobTitle - location - middleName - name - namePrefix - nameSuffix - nickname - organizationName - postalCode - streetAddressLine1 - streetAddressLine2 - sublocality - telephoneNumber - username - password - newPassword - oneTimeCode - birthdate (iOS 17+) - birthdateDay (iOS 17+) - birthdateMonth (iOS 17+) - birthdateYear (iOS 17+) |
554
+ | `underlineColorAndroid` | `string \| OpaqueColorValue` | No | `-` | The color of the textInput underline. |
555
+ | `variant` | `primary \| secondary \| positive \| negative \| foregroundMuted \| foreground` | No | `-` | Determines the sentiment of the input. Because we allow startContent and endContent to be custom ReactNode, the content placed inside these slots will not change colors according to the variant. You will have to add that yourself |
556
+ | `verticalAlign` | `top \| bottom \| auto \| middle` | No | `-` | Vertically align text when multiline is set to true |
557
+ | `width` | `string \| number` | No | `100%` | Width of input as a percentage string. |
558
+
559
+
@@ -10,7 +10,9 @@ import { DatePicker } from '@coinbase/cds-mobile/dates/DatePicker'
10
10
 
11
11
  ## Examples
12
12
 
13
- ### Basic example
13
+ DatePicker combines [DateInput](/components/other/DateInput/) with [Calendar](/components/other/Calendar/) for date selection.
14
+
15
+ ### Basics
14
16
 
15
17
  A basic DatePicker with the minimum props necessary for correct UX.
16
18
 
@@ -36,7 +38,7 @@ function Example() {
36
38
  }
37
39
  ```
38
40
 
39
- ### Custom Label
41
+ #### Custom Label
40
42
 
41
43
  If you need to render a custom label (e.g. a label with a tooltip), you can use the `labelNode` prop.
42
44
 
@@ -70,7 +72,7 @@ function Example() {
70
72
  }
71
73
  ```
72
74
 
73
- ### Invalid dates
75
+ #### Invalid dates
74
76
 
75
77
  Always provide the `invalidDateError` prop for when users type an impossible date like 99/99/2000.
76
78
 
@@ -92,7 +94,7 @@ function Example() {
92
94
  }
93
95
  ```
94
96
 
95
- ### Validation
97
+ #### Validation
96
98
 
97
99
  The DatePicker handles common error states internally, and calls `onErrorDate` when the validity / error state changes.
98
100
 
@@ -120,7 +122,7 @@ function Example() {
120
122
  }
121
123
  ```
122
124
 
123
- ### Accessibility
125
+ #### Accessibility
124
126
 
125
127
  Always provide the accessibility label props and all necessary error props. See the Accessibility section under the Guidelines tab at the top of the page for more info.
126
128
 
@@ -150,7 +152,7 @@ function Example() {
150
152
  }
151
153
  ```
152
154
 
153
- ### Localization
155
+ #### Localization
154
156
 
155
157
  The date format is automatically adjusted to the `LocaleContext`. Check `LocaleProvider` usage below.
156
158
 
@@ -174,7 +176,7 @@ function Example() {
174
176
  }
175
177
  ```
176
178
 
177
- ### Seeding the date
179
+ #### Seeding the date
178
180
 
179
181
  Defaults to today when undefined.
180
182
 
@@ -201,7 +203,7 @@ function Example() {
201
203
  }
202
204
  ```
203
205
 
204
- ### Required field
206
+ #### Required field
205
207
 
206
208
  Make sure to provide the `requiredError` prop when setting the `required` prop to true. The `requiredError` will be displayed if a user blurs the input, without a date selected, after having typed into it.
207
209
 
@@ -225,7 +227,7 @@ function Example() {
225
227
  }
226
228
  ```
227
229
 
228
- ### Minimum and maximum dates
230
+ #### Minimum and maximum dates
229
231
 
230
232
  Make sure to provide the `disabledDateError` prop when providing `minDate`, `maxDate`, or `disabledDates` props. Navigation to dates before the `minDate` and after the `maxDate` is disabled.
231
233
 
@@ -254,7 +256,7 @@ function Example() {
254
256
  }
255
257
  ```
256
258
 
257
- ### Multiple pickers
259
+ #### Multiple pickers
258
260
 
259
261
  This is a complex example using many different props. We use multiple DatePickers together to allow a user to select a date range.
260
262
 
@@ -356,7 +358,7 @@ function Example() {
356
358
  }
357
359
  ```
358
360
 
359
- ### Event lifecycle
361
+ #### Event lifecycle
360
362
 
361
363
  - Selecting a date with the native picker (mobile) or Calendar (web):
362
364
 
@@ -30,6 +30,7 @@
30
30
  - [DotStatusColor](mobile/components/DotStatusColor.txt): Dots are component adornments, typically used to communicate a numerical value or indicate the status or identity of a component to the end-user.
31
31
  - [DotCount](mobile/components/DotCount.txt): Dots are component adornments, typically used to communicate a numerical value or indicate the status or identity of a component to the end-user.
32
32
  - [DatePicker](mobile/components/DatePicker.txt): Date Picker allows our global users to input past, present, future and important dates into our interface in a simple and intuitive manner. Date Picker offers both manual and calendar entry options - accommodating both internationalization and accessibility needs while being adaptable across screen platforms.
33
+ - [DateInput](mobile/components/DateInput.txt): DateInput is a text input field for entering dates by typing. The input automatically formats dates based on the user's locale.
33
34
  - [RollingNumber](mobile/components/RollingNumber.txt): A numeric display that animates value changes with rolling digits.
34
35
  - [Tour](mobile/components/Tour.txt): Creates guided tours of a user interface.
35
36
  - [TopNavBar](mobile/components/TopNavBar.txt): A customizable top navigation bar that can contain start, middle, and end content, as well as a bottom section for elements like tabs. It remains sticky at the top of the screen.
@@ -0,0 +1,469 @@
1
+ # DateInput
2
+
3
+ DateInput is a text input field for entering dates by typing. The input automatically formats dates based on the user's locale.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { DateInput } from '@coinbase/cds-web/dates/DateInput'
9
+ ```
10
+
11
+ ## Examples
12
+
13
+ DateInput uses [TextInput](/components/inputs/TextInput/) for entering dates by typing. Check out [DatePicker](/components/other/DatePicker/) if you would like [Calendar](/components/other/Calendar/) to be shown in a popup as well.
14
+
15
+ ### Basics
16
+
17
+ DateInput requires controlled state for both the date value and error state. The component automatically formats dates based on the user's locale and validates input on blur.
18
+
19
+ ```jsx live
20
+ function Example() {
21
+ const [date, setDate] = useState(null);
22
+ const [error, setError] = useState(null);
23
+
24
+ return (
25
+ <DateInput
26
+ date={date}
27
+ error={error}
28
+ onChangeDate={setDate}
29
+ onErrorDate={setError}
30
+ label="Birthdate"
31
+ invalidDateError="Please enter a valid date"
32
+ requiredError="This field is required"
33
+ disabledDateError="Date unavailable"
34
+ />
35
+ );
36
+ }
37
+ ```
38
+
39
+ #### Validation
40
+
41
+ ##### Minimum and maximum dates
42
+
43
+ Use `minDate` and `maxDate` props to restrict the date range. Provide the `disabledDateError` prop to show an error when users enter a date outside the allowed range.
44
+
45
+ ```jsx live
46
+ function Example() {
47
+ const [date, setDate] = useState(null);
48
+ const [error, setError] = useState(null);
49
+
50
+ const today = new Date(new Date().setHours(0, 0, 0, 0));
51
+ const oneYearAgo = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());
52
+ const oneYearLater = new Date(today.getFullYear() + 1, today.getMonth(), today.getDate());
53
+
54
+ return (
55
+ <DateInput
56
+ date={date}
57
+ error={error}
58
+ onChangeDate={setDate}
59
+ onErrorDate={setError}
60
+ minDate={oneYearAgo}
61
+ maxDate={oneYearLater}
62
+ label="Date within range"
63
+ helperText="Date must be within one year of today"
64
+ invalidDateError="Please enter a valid date"
65
+ disabledDateError="Date must be within one year of today"
66
+ />
67
+ );
68
+ }
69
+ ```
70
+
71
+ ##### Disabled dates
72
+
73
+ The `disabledDates` prop accepts an array of `Date` objects or `[Date, Date]` tuples to disable specific dates or ranges.
74
+
75
+ ```jsx live
76
+ function Example() {
77
+ const [date, setDate] = useState(null);
78
+ const [error, setError] = useState(null);
79
+
80
+ const today = new Date(new Date().setHours(0, 0, 0, 0));
81
+ const oneWeekAgo = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);
82
+ const twoDaysAgo = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 2);
83
+ const oneWeekLater = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 7);
84
+
85
+ const disabledDates = [[oneWeekAgo, twoDaysAgo], oneWeekLater];
86
+
87
+ return (
88
+ <DateInput
89
+ date={date}
90
+ error={error}
91
+ onChangeDate={setDate}
92
+ onErrorDate={setError}
93
+ disabledDates={disabledDates}
94
+ label="Birthdate"
95
+ invalidDateError="Please enter a valid date"
96
+ disabledDateError="Date unavailable"
97
+ />
98
+ );
99
+ }
100
+ ```
101
+
102
+ ##### Custom validation
103
+
104
+ Use the `DateInputValidationError` class to create custom error states for application-specific validation rules.
105
+
106
+ ```jsx live
107
+ function Example() {
108
+ const [date, setDate] = useState(null);
109
+ const [error, setError] = useState(null);
110
+
111
+ const handleChangeDate = (newDate) => {
112
+ setDate(newDate);
113
+ if (newDate && newDate <= new Date()) {
114
+ setError(new DateInputValidationError('custom', 'Date must be in the future'));
115
+ } else {
116
+ setError(null);
117
+ }
118
+ };
119
+
120
+ return (
121
+ <DateInput
122
+ date={date}
123
+ error={error}
124
+ onChangeDate={handleChangeDate}
125
+ onErrorDate={setError}
126
+ label="Future date only"
127
+ invalidDateError="Please enter a valid date"
128
+ />
129
+ );
130
+ }
131
+ ```
132
+
133
+ ### Accessibility
134
+
135
+ DateInput inherits accessibility props from TextInput. If no `accessibilityLabel` is passed, it will use the `label` as the `accessibilityLabel`. If you want an `accessibilityLabel` that differs from the label, you can set this prop.
136
+
137
+ Here, since no `accessibilityLabel` is passed, the `accessibilityLabel` will be "Birthdate".
138
+
139
+ ```jsx
140
+ <DateInput label="Birthdate" />
141
+ ```
142
+
143
+ Example of passing an `accessibilityLabel`. For web, this will set `aria-label="Enter your date of birth"` under the hood.
144
+
145
+ ```jsx
146
+ <DateInput accessibilityLabel="Enter your date of birth" label="Birthdate" />
147
+ ```
148
+
149
+ :::tip Accessibility tip
150
+
151
+ Like any component system, much of the responsibility for building accessible UIs is in your hands as the consumer to properly implement the component composition. We'll do our best to provide sane fallbacks, but here are the biggest gotchas for `DateInput`s you can watch out for.
152
+
153
+ <br />
154
+
155
+ ##### Error message format
156
+
157
+ It's advised you always format error messages with `Error: ${errorMessage}`. We'd do that for you, but _i18n_ isn't baked into CDS. DateInput automatically switches to `variant="negative"` when an error is present.
158
+
159
+ :::
160
+
161
+ ### Localization
162
+
163
+ The date format automatically adjusts based on the `LocaleContext` provided by `LocaleProvider`.
164
+
165
+ ```jsx live
166
+ function Example() {
167
+ const [usDate, setUsDate] = useState(null);
168
+ const [usError, setUsError] = useState(null);
169
+ const [esDate, setEsDate] = useState(null);
170
+ const [esError, setEsError] = useState(null);
171
+
172
+ return (
173
+ <VStack gap={3}>
174
+ <VStack>
175
+ <Text font="label2" color="fgMuted">
176
+ English (US) - MM/DD/YYYY
177
+ </Text>
178
+ <DateInput
179
+ date={usDate}
180
+ error={usError}
181
+ onChangeDate={setUsDate}
182
+ onErrorDate={setUsError}
183
+ label="Date"
184
+ invalidDateError="Please enter a valid date"
185
+ />
186
+ </VStack>
187
+ <LocaleProvider locale="es-ES">
188
+ <VStack>
189
+ <Text font="label2" color="fgMuted">
190
+ Spanish - DD/MM/YYYY
191
+ </Text>
192
+ <DateInput
193
+ date={esDate}
194
+ error={esError}
195
+ onChangeDate={setEsDate}
196
+ onErrorDate={setEsError}
197
+ label="Fecha"
198
+ invalidDateError="Ingrese una fecha válida"
199
+ />
200
+ </VStack>
201
+ </LocaleProvider>
202
+ </VStack>
203
+ );
204
+ }
205
+ ```
206
+
207
+ ### Styling
208
+
209
+ DateInput supports the same styling functionality as [TextInput](/components/inputs/TextInput/).
210
+
211
+ #### Compact
212
+
213
+ Use the `compact` prop for a smaller input size.
214
+
215
+ ```jsx live
216
+ function Example() {
217
+ const [date, setDate] = useState(null);
218
+ const [error, setError] = useState(null);
219
+
220
+ return (
221
+ <VStack gap={3}>
222
+ <DateInput
223
+ date={date}
224
+ error={error}
225
+ onChangeDate={setDate}
226
+ onErrorDate={setError}
227
+ label="Default size"
228
+ invalidDateError="Please enter a valid date"
229
+ />
230
+ <DateInput
231
+ compact
232
+ date={date}
233
+ error={error}
234
+ onChangeDate={setDate}
235
+ onErrorDate={setError}
236
+ label="Compact size"
237
+ invalidDateError="Please enter a valid date"
238
+ />
239
+ </VStack>
240
+ );
241
+ }
242
+ ```
243
+
244
+ #### Disabled
245
+
246
+ ```jsx live
247
+ function Example() {
248
+ const [date, setDate] = useState(new Date());
249
+ const [error, setError] = useState(null);
250
+
251
+ return (
252
+ <DateInput
253
+ disabled
254
+ date={date}
255
+ error={error}
256
+ onChangeDate={setDate}
257
+ onErrorDate={setError}
258
+ label="Disabled input"
259
+ invalidDateError="Please enter a valid date"
260
+ />
261
+ );
262
+ }
263
+ ```
264
+
265
+ #### Helper text
266
+
267
+ ```jsx live
268
+ function Example() {
269
+ const [date, setDate] = useState(null);
270
+ const [error, setError] = useState(null);
271
+
272
+ return (
273
+ <DateInput
274
+ date={date}
275
+ error={error}
276
+ onChangeDate={setDate}
277
+ onErrorDate={setError}
278
+ label="Start date"
279
+ helperText="Select when you'd like to begin"
280
+ invalidDateError="Please enter a valid date"
281
+ />
282
+ );
283
+ }
284
+ ```
285
+
286
+ #### Label
287
+
288
+ If you need to render a custom label (e.g. a label with a tooltip), you can use the `labelNode` prop.
289
+
290
+ ```jsx live
291
+ function Example() {
292
+ const [date, setDate] = useState(null);
293
+ const [error, setError] = useState(null);
294
+
295
+ return (
296
+ <DateInput
297
+ id="birthdate-tooltip"
298
+ date={date}
299
+ error={error}
300
+ onChangeDate={setDate}
301
+ onErrorDate={setError}
302
+ label="Birthdate"
303
+ labelNode={
304
+ <InputLabel htmlFor="birthdate-tooltip">
305
+ <HStack alignItems="center" gap={1}>
306
+ Birthdate
307
+ <Tooltip content="This will be visible to other users.">
308
+ <Icon active color="fg" name="info" size="xs" tabIndex={0} />
309
+ </Tooltip>
310
+ </HStack>
311
+ </InputLabel>
312
+ }
313
+ invalidDateError="Please enter a valid date"
314
+ />
315
+ );
316
+ }
317
+ ```
318
+
319
+ #### Required
320
+
321
+ Use the `required` prop to indicate that the field is mandatory. Provide `requiredError` to display a message if the user blurs the input without a date after typing.
322
+
323
+ ```jsx live
324
+ function Example() {
325
+ const [date, setDate] = useState(null);
326
+ const [error, setError] = useState(null);
327
+
328
+ return (
329
+ <DateInput
330
+ required
331
+ date={date}
332
+ error={error}
333
+ onChangeDate={setDate}
334
+ onErrorDate={setError}
335
+ label="Birthdate"
336
+ invalidDateError="Please enter a valid date"
337
+ requiredError="This field is required"
338
+ />
339
+ );
340
+ }
341
+ ```
342
+
343
+ #### Variants
344
+
345
+ Use the `variant` prop to change the visual style of the input.
346
+
347
+ ```jsx live
348
+ function Example() {
349
+ const [date, setDate] = useState(null);
350
+ const [error, setError] = useState(null);
351
+
352
+ return (
353
+ <VStack gap={3}>
354
+ <DateInput
355
+ date={date}
356
+ error={error}
357
+ onChangeDate={setDate}
358
+ onErrorDate={setError}
359
+ label="Default variant"
360
+ invalidDateError="Please enter a valid date"
361
+ />
362
+ <DateInput
363
+ variant="secondary"
364
+ date={date}
365
+ error={error}
366
+ onChangeDate={setDate}
367
+ onErrorDate={setError}
368
+ label="Secondary variant"
369
+ invalidDateError="Please enter a valid date"
370
+ />
371
+ </VStack>
372
+ );
373
+ }
374
+ ```
375
+
376
+ #### Separator
377
+
378
+ Customize the date format separator using the `separator` prop. Defaults to `/`.
379
+
380
+ ```jsx live
381
+ function Example() {
382
+ const [date1, setDate1] = useState(null);
383
+ const [error1, setError1] = useState(null);
384
+ const [date2, setDate2] = useState(null);
385
+ const [error2, setError2] = useState(null);
386
+
387
+ return (
388
+ <VStack gap={3}>
389
+ <DateInput
390
+ date={date1}
391
+ error={error1}
392
+ onChangeDate={setDate1}
393
+ onErrorDate={setError1}
394
+ separator="/"
395
+ label="Slash separator"
396
+ invalidDateError="Please enter a valid date"
397
+ />
398
+ <DateInput
399
+ date={date2}
400
+ error={error2}
401
+ onChangeDate={setDate2}
402
+ onErrorDate={setError2}
403
+ separator="-"
404
+ label="Dash separator"
405
+ invalidDateError="Please enter a valid date"
406
+ />
407
+ </VStack>
408
+ );
409
+ }
410
+ ```
411
+
412
+ ### Event Lifecycle
413
+
414
+ The DateInput fires events in a specific order:
415
+
416
+ - Typing a date in a blank DateInput:
417
+
418
+ `onChange -> onChange -> ... -> onChangeDate -> onErrorDate`
419
+
420
+ - Typing a date in a DateInput that already had a date:
421
+
422
+ `onChange -> onChangeDate -> onChange -> onChange -> ... -> onChangeDate -> onErrorDate`
423
+
424
+ ## Props
425
+
426
+ | Prop | Type | Required | Default | Description |
427
+ | --- | --- | --- | --- | --- |
428
+ | `date` | `Date \| null` | Yes | `-` | Control the date value of the DateInput. |
429
+ | `error` | `DateInputValidationError \| null` | Yes | `-` | Control the error value of the DateInput. |
430
+ | `onChangeDate` | `(date: Date \| null) => void` | Yes | `-` | Callback function fired when the date changes, e.g. when a valid date is selected or unselected. |
431
+ | `onErrorDate` | `(error: DateInputValidationError \| null) => void` | Yes | `-` | Callback function fired when validation finds an error, e.g. required input fields and impossible or disabled dates. Will always be called after onChangeDate. |
432
+ | `align` | `center \| start \| end \| justify` | No | `start` | Aligns text inside input and helperText |
433
+ | `borderRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `200` | Leverage one of the borderRadius styles we offer to round the corners of the input. |
434
+ | `bordered` | `boolean` | No | `true` | Adds border to input |
435
+ | `className` | `string` | No | `-` | - |
436
+ | `compact` | `boolean` | No | `false` | Enables compact variation |
437
+ | `disabled` | `boolean` | No | `false` | Toggles input interactability and opacity |
438
+ | `disabledDateError` | `string` | No | `'Date unavailable'` | Error text to display when a disabled date is selected, including dates before the minDate or after the maxDate. However if the selected date is more than 100 years before the minDate or more than 100 years after the maxDate, the invalidDateError will be displayed instead. |
439
+ | `disabledDates` | `(Date \| [Date, Date])[]` | No | `-` | Array of disabled dates, and date tuples for date ranges. Make sure to set disabledDateError as well. A number is created for every individual date within a tuple range, so do not abuse this with massive ranges. |
440
+ | `enableColorSurge` | `boolean` | No | `-` | Enable Color Surge motion |
441
+ | `end` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Adds content to the end of the inner input. Refer to diagram for location of endNode in InputStack component |
442
+ | `height` | `((Height<string \| number> \| { base?: Height<string \| number>; phone?: Height<string \| number> \| undefined; tablet?: Height<string \| number> \| undefined; desktop?: Height<string \| number> \| undefined; }) & (string \| number)) \| undefined` | No | `-` | Height of input |
443
+ | `helperText` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | For cases where label is not enough information to describe what the text input is for. Can also be used for showing positive/negative messages |
444
+ | `helperTextErrorIconAccessibilityLabel` | `string` | No | `'error'` | Accessibility label for helper text error icon when variant=negative |
445
+ | `inputBackground` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `'bg'` | Background color of the input. |
446
+ | `invalidDateError` | `string` | No | `'Please enter a valid date'` | Error text to display when an impossible date is selected, e.g. 99/99/2000. This should always be defined for accessibility. Also displays when a date is selected that is more than 100 years before the minDate, or more than 100 years after the maxDate. |
447
+ | `key` | `Key \| null` | No | `-` | - |
448
+ | `label` | `string` | No | `-` | Short messageArea indicating purpose of input |
449
+ | `labelNode` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | React node to render label. Takes precedence over label. |
450
+ | `labelVariant` | `inside \| outside` | No | `'outside'` | The variant of the label. Only used when compact is not true. |
451
+ | `maxDate` | `Date` | No | `-` | Maximum date allowed to be selected, inclusive. Dates after the maxDate are disabled. Make sure to set disabledDateError as well. |
452
+ | `minDate` | `Date` | No | `-` | Minimum date allowed to be selected, inclusive. Dates before the minDate are disabled. Make sure to set disabledDateError as well. |
453
+ | `onChange` | `ChangeEventHandler<HTMLInputElement>` | No | `-` | - |
454
+ | `onClick` | `(MouseEventHandler<Element> & MouseEventHandler<HTMLInputElement>)` | No | `-` | Callback fired when pressed/clicked |
455
+ | `placeholder` | `string` | No | `-` | Placeholder text displayed inside of the input. Will be replaced if there is a value. |
456
+ | `ref` | `((instance: HTMLInputElement \| null) => void) \| RefObject<HTMLInputElement> \| null` | No | `-` | - |
457
+ | `required` | `boolean` | No | `-` | If required, the requiredError will be displayed if a user blurs the input, without a date selected, after having typed into it. |
458
+ | `requiredError` | `string` | No | `'This field is required'` | Error text to display when required is true and a user blurs the input without a date selected, after having typed into it. |
459
+ | `separator` | `string` | No | `-` | Date format separator character, e.g. the / in MM/DD/YYYY. Defaults to forward slash (/). |
460
+ | `start` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Adds content to the start of the inner input. Refer to diagram for location of startNode in InputStack component |
461
+ | `style` | `CSSProperties` | No | `-` | - |
462
+ | `suffix` | `string` | No | `-` | Adds suffix text to the end of input |
463
+ | `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |
464
+ | `testIDMap` | `{ start?: string; end?: string \| undefined; label?: string \| undefined; helperText?: string \| undefined; } \| undefined` | No | `-` | Add ability to test individual parts of the input |
465
+ | `type` | `number \| color \| button \| search \| time \| image \| text \| hidden \| string & {} \| email \| checkbox \| radio \| tel \| url \| date \| submit \| reset \| datetime-local \| file \| month \| password \| range \| week` | No | `-` | - |
466
+ | `variant` | `primary \| secondary \| positive \| negative \| foregroundMuted \| foreground` | No | `foregroundMuted` | Determines the sentiment of the input. Because we allow startContent and endContent to be custom ReactNode, the content placed inside these slots will not change colors according to the variant. You will have to add that yourself |
467
+ | `width` | `ResponsiveProp<Width<string \| number>>` | No | `100%` | Width of input as a percentage string. |
468
+
469
+
@@ -10,7 +10,9 @@ import { DatePicker } from '@coinbase/cds-web/dates/DatePicker'
10
10
 
11
11
  ## Examples
12
12
 
13
- ### Basic example
13
+ DatePicker combines [DateInput](/components/other/DateInput/) with [Calendar](/components/other/Calendar/) for date selection.
14
+
15
+ ### Basics
14
16
 
15
17
  A basic DatePicker with the minimum props necessary for correct UX.
16
18
 
@@ -36,7 +38,7 @@ function Example() {
36
38
  }
37
39
  ```
38
40
 
39
- ### Custom Label
41
+ #### Custom Label
40
42
 
41
43
  If you need to render a custom label (e.g. a label with a tooltip), you can use the `labelNode` prop.
42
44
 
@@ -70,7 +72,7 @@ function Example() {
70
72
  }
71
73
  ```
72
74
 
73
- ### Invalid dates
75
+ #### Invalid dates
74
76
 
75
77
  Always provide the `invalidDateError` prop for when users type an impossible date like 99/99/2000.
76
78
 
@@ -92,7 +94,7 @@ function Example() {
92
94
  }
93
95
  ```
94
96
 
95
- ### Validation
97
+ #### Validation
96
98
 
97
99
  The DatePicker handles common error states internally, and calls `onErrorDate` when the validity / error state changes.
98
100
 
@@ -120,7 +122,7 @@ function Example() {
120
122
  }
121
123
  ```
122
124
 
123
- ### Accessibility
125
+ #### Accessibility
124
126
 
125
127
  Always provide the accessibility label props and all necessary error props. See the Accessibility section under the Guidelines tab at the top of the page for more info.
126
128
 
@@ -150,7 +152,7 @@ function Example() {
150
152
  }
151
153
  ```
152
154
 
153
- ### Localization
155
+ #### Localization
154
156
 
155
157
  The date format is automatically adjusted to the `LocaleContext`. Check `LocaleProvider` usage below.
156
158
 
@@ -174,7 +176,7 @@ function Example() {
174
176
  }
175
177
  ```
176
178
 
177
- ### Seeding the date
179
+ #### Seeding the date
178
180
 
179
181
  Defaults to today when undefined.
180
182
 
@@ -203,7 +205,7 @@ function Example() {
203
205
  }
204
206
  ```
205
207
 
206
- ### Required field
208
+ #### Required field
207
209
 
208
210
  Make sure to provide the `requiredError` prop when setting the `required` prop to true. The `requiredError` will be displayed if a user blurs the input, without a date selected, after having typed into it.
209
211
 
@@ -227,7 +229,7 @@ function Example() {
227
229
  }
228
230
  ```
229
231
 
230
- ### Highlighted dates
232
+ #### Highlighted dates
231
233
 
232
234
  The `highlightedDates` prop is an array of Dates and Date tuples for date ranges. A number is created for every individual date within a tuple range, so do not abuse this with massive ranges.
233
235
 
@@ -259,7 +261,7 @@ function Example() {
259
261
  }
260
262
  ```
261
263
 
262
- ### Minimum and maximum dates
264
+ #### Minimum and maximum dates
263
265
 
264
266
  Make sure to provide the `disabledDateError` prop when providing `minDate`, `maxDate`, or `disabledDates` props. Navigation to dates before the `minDate` and after the `maxDate` is disabled.
265
267
 
@@ -288,7 +290,7 @@ function Example() {
288
290
  }
289
291
  ```
290
292
 
291
- ### Disabled dates
293
+ #### Disabled dates
292
294
 
293
295
  The `disabledDates` prop is an array of Dates and Date tuples for date ranges. A number is created for every individual date within a tuple range, so do not abuse this with massive ranges.
294
296
 
@@ -323,7 +325,7 @@ function Example() {
323
325
  }
324
326
  ```
325
327
 
326
- ### Multiple pickers
328
+ #### Multiple pickers
327
329
 
328
330
  This is a complex example using many different props. We use multiple DatePickers together to allow a user to select a date range.
329
331
 
@@ -427,7 +429,7 @@ function Example() {
427
429
  }
428
430
  ```
429
431
 
430
- ### Event lifecycle
432
+ #### Event lifecycle
431
433
 
432
434
  - Selecting a date with the native picker (mobile) or Calendar (web):
433
435
 
@@ -35,6 +35,7 @@
35
35
  - [DotStatusColor](web/components/DotStatusColor.txt): Dots are component adornments, typically used to communicate a numerical value or indicate the status or identity of a component to the end-user.
36
36
  - [DotCount](web/components/DotCount.txt): Dots are component adornments, typically used to communicate a numerical value or indicate the status or identity of a component to the end-user.
37
37
  - [DatePicker](web/components/DatePicker.txt): Date Picker allows our global users to input past, present, future and important dates into our interface in a simple and intuitive manner. Date Picker offers both manual and calendar entry options - accommodating both internationalization and accessibility needs while being adaptable across screen platforms.
38
+ - [DateInput](web/components/DateInput.txt): DateInput is a text input field for entering dates by typing. The input automatically formats dates based on the user's locale.
38
39
  - [Calendar](web/components/Calendar.txt): Calendar is a flexible, accessible date grid component for selecting dates, supporting keyboard navigation, disabled/highlighted dates, and custom rendering.
39
40
  - [RollingNumber](web/components/RollingNumber.txt): A numeric display that animates value changes with rolling digits.
40
41
  - [Tour](web/components/Tour.txt): Creates guided tours of a user interface.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cds-mcp-server",
3
- "version": "8.31.3",
3
+ "version": "8.31.5",
4
4
  "description": "Coinbase Design System - MCP Server",
5
5
  "repository": {
6
6
  "type": "git",