@commercetools-uikit/date-time-input

The `DateTimeInput` component allows the user to select a date. This component also supports multiple date selection.

Usage no npm install needed!

<script type="module">
  import commercetoolsUikitDateTimeInput from 'https://cdn.skypack.dev/@commercetools-uikit/date-time-input';
</script>

README

DateTimeInput

Description

The DateTimeInput component allows the user to select a date. This component also supports multiple date selection.

It formats the selected date depending on the current locale.

Installation

yarn add @commercetools-uikit/date-time-input
npm --save install @commercetools-uikit/date-time-input

Additionally install the peer dependencies (if not present)

yarn add moment react react-intl
npm --save install moment react react-intl

Usage

import DateTimeInput from '@commercetools-uikit/date-time-input';

const Example = () => (
  <DateTimeInput
    placeholder="Select a date..."
    timeZone="Europe/Berlin"
    value="2018-10-04T09:00:00.000Z"
    onChange={() => {}}
  />
);

export default Example;

Properties

Props Type Required Default Description
horizontalConstraint union
Possible values:
, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'
Horizontal size limit of the input field.
value string The selected date, must either be an empty string or a date formatted in ISO 8601 (e.g. "2018-10-04T09:00:00.000Z").
onChange Function
See signature.
Called when the date changes. Called with an event containing an empty string (no value) or a string in this format: "YYYY-MM-DD".
onFocus FocusEventHandler Called when the date input gains focus.
onBlur Function
See signature.
Called when the date input loses focus.
timeZone string Specifies the time zone in which the calendar and selected values are shown. It also influences how entered dates and times are parsed. Get list of timezone with moment.tz.names() See moment docs
id string Used as the HTML id attribute.
name string Used as the HTML name attribute.
placeholder string Placeholder value to show in the input field
isDisabled boolean Disables the date picker
isReadOnly boolean Disables the date picker menu and sets the input field as read-only
hasError boolean Indicates the input field has an error
hasWarning boolean Indicates the input field has a warning

Signatures

Signature onChange

(event: TEvent) => void

Signature onBlur

(event: TEvent) => void

props.timeZone

The timeZone specifies which time zone the calendar uses, which time zone the selected value is shown in and which time zone entered dates and times are parsed in. For example, given the value is 2018-10-18T00:00:00.000Z and thetimeZoneis set toEurope/Berlin, then entering "13:00" as the time results in theonChangebeing called with2018-10-15T11:00:00.000Z (as the time zone offset for that date is two hours).