@digitransit-component/digitransit-component-datetimepicker v1.1.9
@digitransit-component/digitransit-component-datetimepicker
Datetimepicker
This component renders an input to choose a date and time. Renders separate input fields for date and time selection. Values for timestamp and arriveBy correspond to Digitransit query params time and arriveBy. This component will display a native date input on mobile and a custom one for desktop. Mobile detection is done by parsing user agent.
Parameters
propsObjectprops.realtimeboolean Determine if selected time should be updated in realtime when 'now' is selected.props.initialArriveByboolean Initial value for arriveBy. Determines if picker is in arrival mode (true) or departure mode (false). Correct value is kept in component state even if this is not updated. Changing this will also trigger change in the component.props.initialTimestampNumber Initial value for selected time. Unix timestamp in seconds. Updating this will change timepicker value but the correct value is kept in component state even if this is not updated.props.onDepartureClickfunction Called with (time) when "departure" button is clicked. time is current input value in secondsprops.onArrivalClickfunction Called with (time) when "arrival" button is clicked. time is current input value in secondsprops.onTimeChangefunction Called with (time, arriveBy) when time input changes. time is number timestamp in seconds, arriveBy is booleanprops.onDateChangefunction Called with (time, arriveBy) when date input changes. time is number timestamp in seconds, arriveBy is booleanprops.onNowClickfunction Called when "depart now" button is clicked. time is current input value in secondsprops.embedWhenClosednode JSX element to render in the corner when input is closedprops.embedWhenOpennode JSX element to render when input is openprops.langstring Language selection. Default 'en'props.colorprops.timeZoneprops.fontWeights
Examples
<Datetimepicker
realtime={true}
initialTimestamp={1590133823}
initialArriveBy={false}
onTimeChange={(time, arriveBy) => changeUrl(time, arriveBy)}
onDateChange={(time, arriveBy) => changeUrl(time, arriveBy)}
onNowClick={(time) => changeUrl(undefined, undefined)}
onDepartureClick={(time) => changeUrl(time, 'true')}
onArrivalClick={(time) => changeUrl(time, undefined)}
embedWhenClosed={<button />}
lang={'en'}
/>This module is part of the Digitransit-ui project. It is maintained in the HSLdevcom/digitransit-ui repository, where you can create PRs and issues.
Installation
Install this module individually:
$ npm install @digitransit-component/digitransit-component-datetimepickerOr install the digitransit-component module that includes it as a class:
$ npm install @digitransit-component/digitransit-component5 months ago
8 months ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago