{"name":"react-datetime","version":"3.0.0-beta.1","description":"A lightweight but complete datetime picker React.js component","homepage":"https://github.com/YouCanBookMe/react-datetime","repository":{"type":"git","url":"git+https://github.com/YouCanBookMe/react-datetime.git"},"main":"./DateTime.js","typings":"./DateTime.d.ts","scripts":{"build:mac":"gulp","build:win":"gulp.cmd","dev":"webpack-dev-server --config example/webpack.config.js --devtool eval --progress --colors --hot --content-base example","lint":"eslint src/ DateTime.js test/ && echo 'Linting OK! 💪'","notify-pre-commit-hook":"echo '### Starting pre-commit hook 🦄'","test":"node ./node_modules/jest/bin/jest.js","test:typings":"node ./node_modules/typescript/bin/tsc -p ./typings","test:snapshot":"node ./node_modules/jest/bin/jest.js snapshot","test:snapshot:update":"node ./node_modules/jest/bin/jest.js snapshot --updateSnapshot","test:all":"echo 'Running tests...' && npm run test:typings && npm run test && echo 'All tests passed! 🤘'","test:watch":"node ./node_modules/jest/bin/jest.js --watch"},"keywords":["react","react-component","datepicker","timepicker","datetimepicker","datetime"],"author":{"name":"Javier Marquez"},"license":"MIT","peerDependencies":{"moment":">=2.16.0","react":">=0.13","react-dom":">=0.13"},"devDependencies":{"@types/react":">=15","babel-core":"^6.22.1","babel-jest":"^18.0.0","babel-loader":"^6.2.1","babel-plugin-transform-remove-strict-mode":"0.0.2","babel-preset-es2015":"^6.22.0","babel-preset-react":"^6.22.0","enzyme":"^3.0.0","enzyme-adapter-react-15":"^1.0.5","eslint":"^3.1.0","gulp":"^3.9.0","gulp-babel":"^6.1","gulp-insert":"^0.4.0","gulp-plumber":"^1.1.0","gulp-rename":"^1.2.2","gulp-sourcemaps":"^2.4.0","gulp-uglify":"^1.2.0","jest":"^18.1.0","jest-cli":"^18.1.0","jsdom":"^7.0.2","mocha":"^5.2.0","moment":">=2.16.0","moment-timezone":"^0.5.13","pre-commit":"^1.1.3","react":"^15.5.0","react-addons-test-utils":">=0.13","react-dom":"^15.5.0","react-test-renderer":"^15.5.0","through2":"^2.0.3","typescript":"^2.0.10","webpack":"^2.2.1","webpack-stream":"^3.2.0"},"dependencies":{"create-react-class":"^15.6.3","object-assign":"^3.0.0","prop-types":"^15.5.7","react-onclickoutside":"^6.5.0"},"pre-commit":["notify-pre-commit-hook","lint","test:all"],"readme":"# react-datetime\n\n[![Build Status](https://secure.travis-ci.org/YouCanBookMe/react-datetime.svg)](https://travis-ci.org/YouCanBookMe/react-datetime.svg?branch=master)\n[![npm version](https://badge.fury.io/js/react-datetime.svg)](http://badge.fury.io/js/react-datetime)\n\nA date and time picker in the same React.js component. It can be used as a datepicker, timepicker or both at the same time. It is **highly customizable** and it even allows to edit date's milliseconds.\n\nThis project started as a fork of https://github.com/quri/react-bootstrap-datetimepicker but the code and the API has changed a lot.\n\n## Installation\n\nInstall using npm:\n```sh\nnpm install --save react-datetime\n```\n\nInstall using yarn:\n```sh\nyarn add react-datetime\n```\n\n## Usage\n\n[React.js](http://facebook.github.io/react/) and [Moment.js](http://momentjs.com/) are peer dependencies for react-datetime (as well as [Moment.js timezones](https://momentjs.com/timezone/) if you want to use the `displayTimeZone` prop). These dependencies are not installed along with react-datetime automatically, but your project needs to have them installed in order to make the datepicker work. You can then use the datepicker like in the example below.\n\n\n```js\nrequire('react-datetime');\n\n...\n\nrender: function() {\n    return <Datetime />;\n}\n```\n[See this example working](http://codepen.io/simeg/pen/mEmQmP).\n\n**Don't forget to add the [CSS stylesheet](https://github.com/YouCanBookMe/react-datetime/blob/master/css/react-datetime.css) to make it work out of the box.**\n\n## API\n\n| Name         | Type    | Default | Description |\n| ------------ | ------- | ------- | ----------- |\n| **value** | `Date` | `new Date()` | Represents the selected date by the component, in order to use it as a [controlled component](https://facebook.github.io/react/docs/forms.html#controlled-components). This prop is parsed by Moment.js, so it is possible to use a date `string` or a `moment` object. |\n| **initialValue** | `Date` | `new Date()` | Represents the selected date for the component to use it as a [uncontrolled component](https://facebook.github.io/react/docs/uncontrolled-components.html). This prop is parsed by Moment.js, so it is possible to use a date `string` or a `moment` object. If you need to set the selected date programmatically after the picker is initialized, please use the `value` prop instead. |\n| **initialViewDate** | `Date` | `new Date()` | Define the month/year/decade/time which is viewed on opening the calendar. This prop is parsed by Moment.js, so it is possible to use a date `string` or a `moment` object. |\n| **initialViewMode** | `string` or `number` | `'days'` | The default view to display when the picker is shown for the first time. (`'years'`, `'months'`, `'days'`, `'time'`) |\n| **updateOnView** | `string` | Intelligent guess | In the calendar we can navigate through years and months without actualling updating the selected view. Only when we get to one view called the \"updating view\", we make a selection there and the value gets updated, triggering an `onChange` event. By default the updating view will get guessed by using the `dateFormat` so if our dates only show months and never days, the update is done in the `months` view. If we set `updateOnView=\"time\"` selecting a day will navigate to the time view. The time view always updates the selected date, never navigates. If `closeOnSelect={ true }`, making a selection in the view defined by `updateOnView` will close the calendar. |\n| **dateFormat**   | `boolean` or `string`  | `true` | Defines the format for the date. It accepts any [Moment.js date format](http://momentjs.com/docs/#/displaying/format/) (not in localized format). If `true` the date will be displayed using the defaults for the current locale. If `false` the datepicker is disabled and the component can be used as timepicker, see [available units docs](#specify-available-units). |\n| **timeFormat**   | `boolean` or `string`  | `true` | Defines the format for the time. It accepts any [Moment.js time format](http://momentjs.com/docs/#/displaying/format/) (not in localized format). If `true` the time will be displayed using the defaults for the current locale. If `false` the timepicker is disabled and the component can be used as datepicker, see [available units docs](#specify-available-units). |\n| **input** | `boolean` | `true` | Whether to show an input field to edit the date manually. |\n| **open** | `boolean` | `null` | Whether to open or close the picker. If not set react-datetime will open the datepicker on input focus and close it on click outside. |\n| **locale** | `string` | `null` | Manually set the locale for the react-datetime instance. Moment.js locale needs to be loaded to be used, see [i18n docs](#i18n).\n| **utc** | `boolean` | `false` | When true, input time values will be interpreted as UTC (Zulu time) by Moment.js. Otherwise they will default to the user's local timezone.\n| **displayTimeZone** | `string` | `null` | **Needs [moment's timezone](https://momentjs.com/timezone/) available in your project.** When specified, input time values will be displayed in the given time zone. Otherwise they will default to the user's local timezone (unless `utc` specified).\n| **onChange** | `function` | empty function | Callback trigger when the date changes. The callback receives the selected `moment` object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback receives the value of the input (a string). |\n| **onFocus** | `function` | empty function | Callback trigger for when the user opens the datepicker. The callback receives an event of type SyntheticEvent. |\n| **onBlur** | `function` | empty function | Callback trigger for when the user clicks outside of the input, simulating a regular onBlur. The callback receives the selected `moment` object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback returned. |\n| **onViewModeChange** | `function` | empty function | Callback trigger when the view mode changes. The callback receives the selected view mode string (`years`, `months`, `days` or `time`) as only parameter.|\n| **onNavigateBack** | `function` | empty function | Callback trigger when the user navigates to the previous month, year or decade. The callback receives the amount and type ('month', 'year') as parameters. |\n| **onNavigateForward** | `function` | empty function | Callback trigger when the user navigates to the next month, year or decade. The callback receives the amount and type ('month', 'year') as parameters. |\n| **className** | `string` or `string array` | `''` | Extra class name for the outermost markup element. |\n| **inputProps** | `object` | `undefined` | Defines additional attributes for the input element of the component. For example: `onClick`, `placeholder`, `disabled`, `required`, `name` and `className` (`className` *sets* the class attribute for the input element). See [Customize the Input Appearance](#customize-the-input-appearance). |\n| **isValidDate** | `function` | `() => true` | Define the dates that can be selected. The function receives `(currentDate, selectedDate)` and shall return a `true` or `false` whether the `currentDate` is valid or not. See [selectable dates](#selectable-dates).|\n| **renderInput** | `function` | `undefined` | Replace the rendering of the input element. The function has the following arguments: the default calculated `props` for the input, `openCalendar` (a function which opens the calendar) and `closeCalendar` (a function which closes the calendar). Must return a React component or `null`. See [Customize the Input Appearance](#customize-the-input-appearance). |\n| **renderView** | `function` | `(viewType, renderDefault) => renderDefault()` | Customize the way the calendar is rendered. The accepted function receives the type of the view\nit's going to be rendered `'years', 'months', 'days', 'time'` and a function to render the default\nview of react-datetime, this way it's possible to wrap the original view adding our own markup or\noverride it completely with our own code. See [Customize the Datepicker Appearance](#customize-the-datepicker-appearance). |\n| **renderDay** | `function` | `DOM.td(day)` | Customize the way that the days are shown in the daypicker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, and must return a React component. See [Customize the Datepicker Appearance](#customize-the-datepicker-appearance). |\n| **renderMonth** | `function` | `DOM.td(month)` | Customize the way that the months are shown in the monthpicker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, the `month` and the `year` to be shown, and must return a React component. See [Customize the Datepicker Appearance](#customize-the-datepicker-appearance). |\n| **renderYear** | `function` | `DOM.td(year)` | Customize the way that the years are shown in the year picker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, the `year` to be shown, and must return a React component. See [Customize the Datepicker Appearance](#customize-the-datepicker-appearance). |\n| **strictParsing** | `boolean` | `true` | Whether to use Moment.js's [strict parsing](http://momentjs.com/docs/#/parsing/string-format/) when parsing input.\n| **closeOnSelect** | `boolean` | `false` | When `true`, once the day has been selected, the datepicker will be automatically closed.\n| **closeOnTab** | `boolean` | `true` | When `true` and the input is focused, pressing the `tab` key will close the datepicker.\n| **timeConstraints** | `object` | `null` | Add some constraints to the timepicker. It accepts an `object` with the format `{ hours: { min: 9, max: 15, step: 2 }}`, this example means the hours can't be lower than `9` and higher than `15`, and it will change adding or subtracting `2` hours everytime the buttons are clicked. The constraints can be added to the `hours`, `minutes`, `seconds` and `milliseconds`.\n| **closeOnClickOutside** | `boolean` | `false` | When `true`, keep the datepicker open when click event is triggered outside of component. When `false`, close it.\n\n## i18n\nDifferent language and date formats are supported by react-datetime. React uses [Moment.js](http://momentjs.com/) to format the dates, and the easiest way of changing the language of the calendar is [changing the Moment.js locale](http://momentjs.com/docs/#/i18n/changing-locale/).\n\n```js\nvar moment = require('moment');\nrequire('moment/locale/fr');\n// Now react-datetime will be in french\n```\n\nIf there are multiple locales loaded, you can use the prop `locale` to define what language shall be used by the instance.\n```js\n<Datetime locale=\"fr-ca\" />\n<Datetime locale=\"de\" />\n```\n[Here you can see the i18n example working](http://codepen.io/simeg/pen/yVVjdJ).\n\n## Customize the Input Appearance\nIt is possible to customize the way that the input is displayed. The simplest is to supply `inputProps` which get assigned to the default `<input />` element within the component.\n\n```js\n<Datetime inputProps={{ placeholder: 'N/A', disabled: true }}>\n```\n\nAlternatively, if you need to render different content than an `<input />` element, you may supply a `renderInput` function which is called instead.\n\n```js\nvar MyDTPicker = React.createClass({\n    render: function(){\n        return <Datetime renderInput={ this.renderInput } />;\n    },\n    renderInput: function( props, openCalendar, closeCalendar ){\n        function clear(){\n            props.onChange({target: {value: ''}});\n        }\n        return (\n            <div>\n                <input {...props} />\n                <button onClick={openCalendar}>open calendar</button>\n                <button onClick={closeCalendar}>close calendar</button>\n                <button onClick={clear}>clear</button>\n            </div>\n        );\n    },\n});\n```\n\n## Customize the Datepicker Appearance\nIt is possible to customize the way that the datepicker display the days, months and years in the calendar. To adapt the calendar for every need it is possible to use the props `renderDay(props, currentDate, selectedDate)`, `renderMonth(props, month, year, selectedDate)` and `renderYear(props, year, selectedDate)` to customize the output of each rendering method.\n\n```js\nvar MyDTPicker = React.createClass({\n    render: function(){\n        return <Datetime\n            renderDay={ this.renderDay }\n            renderMonth={ this.renderMonth }\n            renderYear={ this.renderYear }\n        />;\n    },\n    renderDay: function( props, currentDate, selectedDate ){\n        return <td {...props}>{ '0' + currentDate.date() }</td>;\n    },\n    renderMonth: function( props, month, year, selectedDate ){\n        return <td {...props}>{ month }</td>;\n    },\n    renderYear: function( props, year, selectedDate ){\n        return <td {...props}>{ year % 100 }</td>;\n    }\n});\n```\n[You can see a customized calendar here.](http://codepen.io/simeg/pen/YppLmO)\n\n#### Method Parameters\n* `props` is the object that the datepicker has calculated for this object. It is convenient to use this object as the `props` for your custom component, since it knows how to handle the click event and its `className` attribute is used by the default styles.\n* `selectedDate` and `currentDate` are [moment objects](http://momentjs.com) and can be used to change the output depending on the selected date, or the date for the current day.\n* `month` and `year` are the numeric representation of the current month and year to be displayed. Notice that the possible `month` values range from `0` to `11`.\n\n## Specify Available Units\nYou can filter out what you want the user to be able to pick by using `dateFormat` and `timeFormat`, e.g. to create a timepicker, yearpicker etc.\n\nIn this example the component is being used as a *timepicker* and can *only be used for selecting a time*.\n```js\n<Datetime dateFormat={false} />\n```\n[Working example of a timepicker here.](http://codepen.io/simeg/pen/mRQBrp)\n\nIn this example you can *only select a year and month*.\n```js\n<Datetime dateFormat=\"YYYY-MM\" timeFormat={false} />\n```\n[Working example of only selecting year and month here.](http://codepen.io/simeg/pen/apQLdd)\n\n## Selectable Dates\nIt is possible to disable dates in the calendar if the user are not allowed to select them, e.g. dates in the past. This is done using the prop `isValidDate`, which admits a function in the form `function(currentDate, selectedDate)` where both arguments are [moment objects](http://momentjs.com). The function shall return `true` for selectable dates, and `false` for disabled ones.\n\nIn the example below are *all dates before today* disabled.\n\n```js\n// Let's use the static moment reference in the Datetime component\nvar yesterday = Datetime.moment().subtract( 1, 'day' );\nvar valid = function( current ){\n    return current.isAfter( yesterday );\n};\n<Datetime isValidDate={ valid } />\n```\n[Working example of disabled days here.](http://codepen.io/simeg/pen/XNNYJg)\n\nIt's also possible to disable *the weekends*, as shown in the example below.\n```js\nvar valid = function( current ){\n    return current.day() !== 0 && current.day() !== 6;\n};\n<Datetime isValidDate={ valid } />\n```\n[Working example of disabled weekends here.](http://codepen.io/simeg/pen/jVVKWq)\n\n## Usage with TypeScript\n\nThis project includes typings for TypeScript versions 1.8 and 2.0. Additional typings are not\nrequired.\n\nTypings for 1.8 are found in `react-datetime.d.ts` and typings for 2.0 are found in `typings/index.d.ts`.\n\n```js\nimport * as Datetime from 'react-datetime';\n\nclass MyDTPicker extends React.Component<MyDTPickerProps, MyDTPickerState> {\n    render() JSX.Element {\n        return <Datetime />;\n    }\n}\n```\n\n## Contributions\nFor information about how to contribute, see the [CONTRIBUTING](.github/CONTRIBUTING.md) file.\n\n## Development\n```sh\nnpm run dev\n```\nThis will start a local `webpack-dev-server` based on `example/example.js` where most development can be done.\n\nIf you want to develop using the component inside a React application, we recommend that you use [react-datetime-playground](https://github.com/arqex/react-datetime-playground).\n\n### [Changelog](CHANGELOG.md)\n\n### [MIT Licensed](LICENSE.md)\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/YouCanBookMe/react-datetime/issues"},"_id":"react-datetime@3.0.0-beta.1","_npmVersion":"6.4.1","_nodeVersion":"10.14.2","_npmUser":{"name":"arqex","email":"javi@arqex.com"},"dist":{"integrity":"sha512-O2UkIYvQFRH1/1TRGobKsjzMV7pOEZH4l7KRubcm+R2+PV83rZmFWHsdelyezskKfKKD5QpxPJ5Ub3ypwOyRwg==","shasum":"2f7b87b45e8d7455c0d35087dccb6474c269ef78","tarball":"http://registry-npm.ywwl.com/react-datetime/download/react-datetime-3.0.0-beta.1.tgz","fileCount":15,"unpackedSize":556552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcG4SeCRA9TVsSAnZWagAAgoMP/3/VBkzEKAjx6QCNlvRP\n34C6t8prtllmcAcZKq86o8qLWehEEPf/0vzi8JI1PzF69yd3unFmJhrLK/Ht\nLs8W3Ou9XsRBWCqhnsXCvXuefmLwxQgPHiRNEtHw4AilazFM56++OzYr6hj7\njKra3nu/nUTnSZF3Vdr5fzai1/nprqGHiLhoYyw6fO26x5+SBMa0lEww1AvN\nRRR0Xw5hwOC/00aa5vLrl8dUWuSp1rK7BN7PouPYNxHY9QgoU//ZWO+FiUzW\nfWQAdT9VEpX5N9kGjScOjudLadLt0NDpUA5C/3g8pzKV10BzGR3L+oMFHRGl\nS1J1nLmlk422uZJX1ft24zrS2NMxA+/BN2rEItaPA9RQ/Fjg3V85VlWtxE+V\nF31B/fWEYoVZKsH2TkQcYIFHmrrcnjUBi2JRf6Ept4ltJVuicBJ/oplKJkC6\nzabyNSnJQ8IlX/C30w+fMCtCfpUF541vK0msK2vo0dYrVnqo1ey2GOvZj4Uv\nE1sZ98iXbGYaKyfv/Yddhk+ceFzGvfgpMMQLc/hYbaBKvOAgS8FhgV/2C+Nn\n8FqIZA/EPnHNy23hVHbdskIHEmEKwIr8/jlNCHMCA3PMOC5ZotKBFmpzSz/W\n7AvzVJaTD4Vxe28OnQ2/GYagkVMTVt6EnjVM8Huew198A4MHBwKXx+rSqIVW\nyb4r\r\n=CQUB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDZw+nOHGfTJs8ruJNRc8HBt66sE/Eh+dOaoSPJvFJsFAiBS9EmF2cNr8wytxr94K7eT0pX5m+r+HiONnVznM5ND3A=="}],"size":135397,"noattachment":false,"key":"/react-datetime/-/react-datetime-3.0.0-beta.1.tgz"},"maintainers":[{"name":"arqex","email":"javi@arqex.com"},{"name":"layneanderson","email":"layneand@gmail.com"},{"name":"simeg","email":"s.egersand@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-datetime_3.0.0-beta.1_1545307294000_0.37783893708622585"},"_hasShrinkwrap":false,"publish_time":1545307294205,"_cnpm_publish_time":1545307294205,"dist-tags":{"alpha":"3.0.0-alpha.5","beta":"3.0.0-beta.8","latest":"3.3.1"}}