You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/components/DateField/README.md
+61-35Lines changed: 61 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -347,44 +347,70 @@ LANDING_BLOCK-->
347
347
348
348
<!--/GITHUB_BLOCK-->
349
349
350
+
### Custom Date Parser
351
+
352
+
You can provide a custom parser function to handle pasted date strings through the `parseDateFromString` prop. This is useful when you need to support specific date formats or custom parsing logic that differs from the default behavior.
returndateTime({input: dateStr, format, timeZone});
368
+
};
369
+
370
+
<DateFieldparseDateFromString={customParser} />
371
+
```
372
+
373
+
<!--/GITHUB_BLOCK-->
374
+
350
375
## Time zone
351
376
352
377
`timeZone` is the property to set the time zone of the value in the input. [Learn more about time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List)
| aria-describedby | The control's `aria-describedby` attribute |`string`||
359
-
| aria-details | The control's `aria-details` attribute |`string`||
360
-
| aria-label | The control's `aria-label` attribute |`string`||
361
-
| aria-labelledby | The control's `aria-labelledby` attribute |`string`||
362
-
| autoFocus | The control's `autofocus` attribute |`boolean`||
363
-
| className | The control's wrapper class name |`string`||
364
-
| defaultValue | Sets the initial value for uncontrolled component. |`DateTime`||
365
-
| disabled | Indicates that the user cannot interact with the control |`boolean`|`false`|
366
-
| errorMessage | Error text |`ReactNode`||
367
-
| format | Format of the date when rendered in the input. [Available formats](https://day.js.org/docs/en/display/format)|`string`||
368
-
| hasClear | Shows the icon for clearing control's value |`boolean`|`false`|
369
-
| id | The control's `id` attribute |`string`||
370
-
| isDateUnavailable | Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. |`((date: DateTime) => boolean)`||
371
-
| label | Help text rendered to the left of the input node |`string`||
372
-
| startContent | The user`s node rendered before label and input |`React.ReactNode`||
373
-
| maxValue | The maximum allowed date that a user may select. |`DateTime`||
374
-
| minValue | The minimum allowed date that a user may select. |`DateTime`||
375
-
| onBlur | Fires when the control lost focus. Provides focus event as a callback's argument |`((e: FocusEvent<Element, Element>) => void)`||
376
-
| onFocus | Fires when the control gets focus. Provides focus event as a callback's argument |`((e: FocusEvent<Element, Element>) => void)`||
377
-
| onKeyDown | Fires when a key is pressed. Provides keyboard event as a callback's argument |`((e: KeyboardEvent<Element>) => void)`||
378
-
| onKeyUp | Fires when a key is released. Provides keyboard event as a callback's argument |`((e: KeyboardEvent<Element>) => void)`||
379
-
| onUpdate | Fires when the value is changed by the user. Provides new value as an callback's argument |`((value: DateTime \| null) => void`||
| placeholder | Text that appears in the control when it has no value set |`string`||
382
-
| placeholderValue | A placeholder date that controls the default values of each segment when the user first interacts with them. |`DateTime`|`today's date at midnigh`|
383
-
| readOnly | Whether the component's value is immutable. |`boolean`|`false`|
384
-
| endContent | User`s node rendered after the input node and clear button |`React.ReactNode`||
385
-
| size | The size of the control |`"s"``"m"``"l"``"xl"`|`"m"`|
386
-
| style | Sets inline style for the element. |`CSSProperties`||
387
-
| timeZone | Sets the time zone. [Learn more about time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List)|`string`||
388
-
| validationState | Validation state |`"invalid"`||
389
-
| value | The value of the control |`DateTime``null`||
390
-
| view | The view of the control |`"normal"``"clear"`|`"normal"`|
| aria-describedby | The control's `aria-describedby` attribute |`string`||
384
+
| aria-details | The control's `aria-details` attribute |`string`||
385
+
| aria-label | The control's `aria-label` attribute |`string`||
386
+
| aria-labelledby | The control's `aria-labelledby` attribute |`string`||
387
+
| autoFocus | The control's `autofocus` attribute |`boolean`||
388
+
| className | The control's wrapper class name |`string`||
389
+
| defaultValue | Sets the initial value for uncontrolled component. |`DateTime`||
390
+
| disabled | Indicates that the user cannot interact with the control |`boolean`|`false`|
391
+
| errorMessage | Error text |`ReactNode`||
392
+
| format | Format of the date when rendered in the input. [Available formats](https://day.js.org/docs/en/display/format)|`string`||
393
+
| hasClear | Shows the icon for clearing control's value |`boolean`|`false`|
394
+
| id | The control's `id` attribute |`string`||
395
+
| isDateUnavailable | Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. |`((date: DateTime) => boolean)`||
396
+
| label | Help text rendered to the left of the input node |`string`||
397
+
| startContent | The user`s node rendered before label and input |`React.ReactNode`||
398
+
| maxValue | The maximum allowed date that a user may select. |`DateTime`||
399
+
| minValue | The minimum allowed date that a user may select. |`DateTime`||
400
+
| onBlur | Fires when the control lost focus. Provides focus event as a callback's argument |`((e: FocusEvent<Element, Element>) => void)`||
401
+
| onFocus | Fires when the control gets focus. Provides focus event as a callback's argument |`((e: FocusEvent<Element, Element>) => void)`||
402
+
| onKeyDown | Fires when a key is pressed. Provides keyboard event as a callback's argument |`((e: KeyboardEvent<Element>) => void)`||
403
+
| onKeyUp | Fires when a key is released. Provides keyboard event as a callback's argument |`((e: KeyboardEvent<Element>) => void)`||
404
+
| onUpdate | Fires when the value is changed by the user. Provides new value as an callback's argument |`((value: DateTime \| null) => void`||
405
+
| parseDateFromString | Custom parser function for parsing pasted date strings. If not provided, the default parser will be used. |`((dateStr: string, format: string, timeZone?: string) => DateTime)`||
| placeholder | Text that appears in the control when it has no value set |`string`||
408
+
| placeholderValue | A placeholder date that controls the default values of each segment when the user first interacts with them. |`DateTime`|`today's date at midnigh`|
409
+
| readOnly | Whether the component's value is immutable. |`boolean`|`false`|
410
+
| endContent | User`s node rendered after the input node and clear button |`React.ReactNode`||
411
+
| size | The size of the control |`"s"``"m"``"l"``"xl"`|`"m"`|
412
+
| style | Sets inline style for the element. |`CSSProperties`||
413
+
| timeZone | Sets the time zone. [Learn more about time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List)|`string`||
414
+
| validationState | Validation state |`"invalid"`||
415
+
| value | The value of the control |`DateTime``null`||
416
+
| view | The view of the control |`"normal"``"clear"`|`"normal"`|
0 commit comments