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: docs/DateInput.md
+77
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,8 @@ Ideal for editing dates, `<DateInput>` renders an HTML `<input type="date">` ele
16
16
17
17
The appearance of `<DateInput>` depends on the browser, and falls back to a text input on Safari. The date formatting in this input depends on the user's locale.
18
18
19
+
React-admin also proposes a [DateInput styled with Material UI](#material-ui) documented at the end of this page.
20
+
19
21
## Usage
20
22
21
23
```jsx
@@ -53,3 +55,78 @@ If you need to render a UI despite the browser locale, MUI also proposes a [Date
53
55
Your browser does not support the video tag.
54
56
</video>
55
57
58
+
## Material UI
59
+
60
+
[React-admin Enterprise Edition](https://marmelab.com/ra-enterprise)<imgclass="icon"src="./img/premium.svg" /> proposes an alternative `<DateInput>` styled with Material UI.
61
+
62
+

63
+
64
+
This input also allows to specify the date format and the locale used. It is based on the [MUI X Date/Time pickers](https://mui.com/x/react-date-pickers/getting-started/).
`<DateInput>` will accept either a `Date` object or any string that can be parsed into a `Date` as value. It will return a `Date` object, or `null` if the date is invalid.
82
+
83
+
**Tip:** You can use the `parse` prop to change the format of the returned value. See [Parsing the date/time as an ISO string](#parsing-the-datetime-as-an-iso-string) for an example.
|`fullWidth`| - | boolean |`false`| If `true`, the input will expand to fill the form width |
90
+
|`helperText`| - | string | - | Text to be displayed under the input |
91
+
|`mask`| - | string | - | Alias for the MUI [`format`](https://mui.com/x/api/date-pickers/date-picker/#DatePicker-prop-format) prop. Format of the date/time when rendered in the input. Defaults to localized format. |
92
+
|`parse`| - | Function |`value => value === '' ? null : value`| Callback taking the input value, and returning the value you want stored in the form state. |
93
+
|`validate`| - | Function or Array | - | Validation rules for the input. See the [Validation Documentation](https://marmelab.com/react-admin/Validation.html#per-input-validation-built-in-field-validators) for details. |
94
+
95
+
Except for the `format` prop (renamed `mask`), `<DateInput>` accepts the same props as the [MUI X Date/Time pickers](https://mui.com/x/api/date-pickers/). They also accept the common input props.
96
+
97
+
### Providing your own `LocalizationProvider`
98
+
99
+
MUI X Pickers need to be wrapped in a [LocalizationProvider](https://mui.com/components/pickers/#localization) to work properly. `<DateInput>` already includes a default `<LocalizationProvider>` using the `date-fns` adapter and the `enUS` locale.
100
+
101
+
You can change the locale and the date format globally by wrapping the `<Admin>` with your own `<LocalizationProvider>`.
102
+
103
+
Here is how to set up the pickers to use the `fr` locale:
**Note:** React Admin only supports the `date-fns` adapter for now.
122
+
123
+
### Parsing the date/time as an ISO string
124
+
125
+
By default, `<DateInput>` stores the date/time as a `Date` object in the form state. If you wish to store the date/time as an ISO string instead (or any other format), you can use the `parse` prop.
Copy file name to clipboardexpand all lines: docs/DateTimeInput.md
+79-1
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,8 @@ An input for editing dates with time. `<DateTimeInput>` renders an `<input type=
16
16
17
17
The appearance depends on the browser, and falls back to a text input on safari. The date formatting in this input depends on the user's locale.
18
18
19
+
React-admin also proposes a [DateTimeInput styled with Material UI](#material-ui) documented at the end of this page.
20
+
19
21
## Usage
20
22
21
23
```jsx
@@ -38,4 +40,80 @@ After modification by the user, the value is stored as a `Date` object, using th
38
40
39
41
Internally, `<DateTimeInput>` renders an [`<input type="datetime-local">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local).
40
42
41
-
If you need to implement your own `format` and `parse` functions, make sure the **format** function actually formats the input into [a valid local date and time string](https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#local_date_and_time_strings).
43
+
If you need to implement your own `format` and `parse` functions, make sure the **format** function actually formats the input into [a valid local date and time string](https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#local_date_and_time_strings).
44
+
45
+
## Material UI
46
+
47
+
[React-admin Enterprise Edition](https://marmelab.com/ra-enterprise)<imgclass="icon"src="./img/premium.svg" /> proposes an alternative `<DateTimeInput>` styled with Material UI.
48
+
49
+

50
+
51
+
This input also allows to specify the date format and the locale used. It is based on the [MUI X Date/Time pickers](https://mui.com/x/react-date-pickers/getting-started/).
`<DateTimeInput>` will accept either a `Date` object or any string that can be parsed into a `Date` as value. It will return a `Date` object, or `null` if the date is invalid.
69
+
70
+
**Tip:** You can use the `parse` prop to change the format of the returned value. See [Parsing the date/time as an ISO string](#parsing-the-datetime-as-an-iso-string) for an example.
|`fullWidth`| - | boolean |`false`| If `true`, the input will expand to fill the form width |
77
+
|`helperText`| - | string | - | Text to be displayed under the input |
78
+
|`mask`| - | string | - | Alias for the MUI [`format`](https://mui.com/x/api/date-pickers/date-picker/#DatePicker-prop-format) prop. Format of the date/time when rendered in the input. Defaults to localized format. |
79
+
|`parse`| - | Function |`value => value === '' ? null : value`| Callback taking the input value, and returning the value you want stored in the form state. |
80
+
|`validate`| - | Function or Array | - | Validation rules for the input. See the [Validation Documentation](https://marmelab.com/react-admin/Validation.html#per-input-validation-built-in-field-validators) for details. |
81
+
82
+
Except for the `format` prop (renamed `mask`), `<DateTimeInput> accepts the same props as the [MUI X Date/Time pickers](https://mui.com/x/api/date-pickers/). They also accept the common input props.
83
+
84
+
### Providing your own `LocalizationProvider`
85
+
86
+
MUI X Pickers need to be wrapped in a [LocalizationProvider](https://mui.com/components/pickers/#localization) to work properly. `<DateTimeInput>` already includes a default `<LocalizationProvider>` using the `date-fns` adapter and the `enUS` locale.
87
+
88
+
You can change the locale and the date format globally by wrapping the `<Admin>` with your own `<LocalizationProvider>`.
89
+
90
+
Here is how to set up the pickers to use the `fr` locale:
**Note:** React Admin only supports the `date-fns` adapter for now.
109
+
110
+
### Parsing the date/time as an ISO string
111
+
112
+
By default, `<DateTimeInput>` stores the date/time as a `Date` object in the form state. If you wish to store the date/time as an ISO string instead (or any other format), you can use the `parse` prop.
Copy file name to clipboardexpand all lines: docs/TimeInput.md
+78
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,8 @@ An input for editing time. `<TimeInput>` renders a standard browser [Time Picker
37
37
This component works with Date objects to handle the timezone using the browser locale.
38
38
You can still pass string values as long as those can be converted to a JavaScript Date object.
39
39
40
+
React-admin also proposes a [TimeInput styled with Material UI](#material-ui) documented at the end of this page.
41
+
40
42
## Usage
41
43
42
44
```jsx
@@ -51,3 +53,79 @@ import { TimeInput } from 'react-admin';
51
53
52
54
`<TimeInput>` accepts the [common input props](./Inputs.md#common-input-props).
53
55
56
+
57
+
## Material UI
58
+
59
+
[React-admin Enterprise Edition](https://marmelab.com/ra-enterprise)<imgclass="icon"src="./img/premium.svg" /> proposes an alternative `<TimeInput>` styled with Material UI.
60
+
61
+

62
+
63
+
It allows for more customization of the UI than the default browser pickers. It also make it easier to work with specific locale and date formats.
`<TimeInput>` will accept either a `Date` object or any string that can be parsed into a `Date` as value. It will return a `Date` object, or `null` if the date is invalid.
81
+
82
+
**Tip:** You can use the `parse` prop to change the format of the returned value. See [Parsing the date/time as an ISO string](#parsing-the-datetime-as-an-iso-string) for an example.
|`fullWidth`| - | boolean |`false`| If `true`, the input will expand to fill the form width |
89
+
|`helperText`| - | string | - | Text to be displayed under the input |
90
+
|`mask`| - | string | - | Alias for the MUI [`format`](https://mui.com/x/api/date-pickers/date-picker/#DatePicker-prop-format) prop. Format of the date/time when rendered in the input. Defaults to localized format. |
91
+
|`parse`| - | Function |`value => value === '' ? null : value`| Callback taking the input value, and returning the value you want stored in the form state. |
92
+
|`validate`| - | Function or Array | - | Validation rules for the input. See the [Validation Documentation](https://marmelab.com/react-admin/Validation.html#per-input-validation-built-in-field-validators) for details. |
93
+
94
+
Except for the `format` prop (renamed `mask`), `<TimeInput> accepts the same props as the [MUI X Date/Time pickers](https://mui.com/x/api/date-pickers/). They also accept the common input props.
95
+
96
+
### Providing your own `LocalizationProvider`
97
+
98
+
MUI X Pickers need to be wrapped in a [LocalizationProvider](https://mui.com/components/pickers/#localization) to work properly. `<TimeInput>` already includes a default `<LocalizationProvider>` using the `date-fns` adapter and the `enUS` locale.
99
+
100
+
You can change the locale and the date format globally by wrapping the `<Admin>` with your own `<LocalizationProvider>`.
101
+
102
+
Here is how to set up the pickers to use the `fr` locale:
**Note:** React Admin only supports the `date-fns` adapter for now.
121
+
122
+
### Parsing the date/time as an ISO string
123
+
124
+
By default, `<TimeInput>` stores the date/time as a `Date` object in the form state. If you wish to store the date/time as an ISO string instead (or any other format), you can use the `parse` prop.
0 commit comments