this.setState({ value })}
35 | />
36 | }
37 | }
38 | `;
39 | const Jalaali = { component, title, code };
40 | export default Jalaali;
--------------------------------------------------------------------------------
/docs/src/examples/limitWithMinMax.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import momentJalaali from 'moment-jalaali'
3 | import Calendar from '../../../src/components/Calendar';
4 |
5 | class component extends React.Component {
6 | constructor(props) {
7 | super(props);
8 |
9 | this.state = {
10 | value: momentJalaali(),
11 | isGregorian: true
12 | };
13 |
14 | // limit selection to current months days
15 | this.enabledRange = {
16 | min: momentJalaali().startOf('month'),
17 | max: momentJalaali().endOf('month')
18 | };
19 |
20 | }
21 | render() {
22 | return
23 | this.setState({ value })}
31 | />
32 |
33 |
34 |
35 |
42 |
43 | }
44 | }
45 |
46 | const title = 'Limit Selection Range';
47 | const code = `class component extends React.Component {
48 | constructor(props) {
49 | super(props);
50 | this.state = {
51 | value: momentJalaali(),
52 | isGregorian: true
53 | };
54 | // limit selection to current months days
55 | this.enabledRange = {
56 | min: momentJalaali().startOf('month'),
57 | max: momentJalaali().endOf('month')
58 | };
59 | }
60 | render() {
61 | return
62 | this.setState({ value })}
68 | />
69 |
70 |
71 |
72 |
79 |
80 | }
81 | }
82 | `;
83 | const SwitchIsGregorian = { component, title, code };
84 | export default SwitchIsGregorian;
--------------------------------------------------------------------------------
/docs/src/examples/switchIsGregorian.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import momentJalaali from 'moment-jalaali'
3 | import DatePicker from '../../../src/components/DatePicker';
4 |
5 | class component extends React.Component {
6 | constructor(props) {
7 | super(props);
8 | this.state = {
9 | value: momentJalaali(),
10 | isGregorian: true
11 | };
12 | }
13 | render() {
14 | return
15 | this.setState({ value })}
21 | />
22 |
23 |
26 |
27 | }
28 | }
29 |
30 | const title = 'Switch IsGregorian';
31 | const code = `class component extends React.Component {
32 | constructor(props) {
33 | super(props);
34 | this.state = {
35 | value: momentJalaali(),
36 | isGregorian:true
37 | };
38 | }
39 | render() {
40 | return
41 | this.setState({ value })}
45 | />
46 |
47 |
50 |
51 | }
52 | }
53 | `;
54 | const SwitchIsGregorian = { component, title, code };
55 | export default SwitchIsGregorian;
--------------------------------------------------------------------------------
/docs/src/hero_example.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import momentJalaali from 'moment-jalaali';
3 | import DatePicker from '../../src/index.dev.js';
4 |
5 | import Switch from 'react-switch';
6 |
7 | const buttonContainerStyle = {
8 | marginTop: 20
9 | };
10 | const labelStyle = {
11 | float: 'left'
12 | };
13 | const switchStyle = {
14 | float: 'right'
15 | };
16 |
17 | export default class ReactClass extends React.Component {
18 | constructor(props) {
19 | super(props);
20 | this.state = { value: momentJalaali(), checked: false };
21 | this.handleChange = this.handleChange.bind(this);
22 | }
23 |
24 | handleChange(checked) {
25 | this.setState({ checked });
26 | }
27 |
28 | render() {
29 | return (
30 |
31 |
32 | {
36 | this.setState({ value });
37 | }}
38 | value={this.state.value}
39 | />
40 |
41 |
42 |
62 |
63 |
64 | );
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/docs/src/images/hero_background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/src/images/hero_background.jpg
--------------------------------------------------------------------------------
/docs/src/root.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ExampleComponents from './example_components.js'
3 | import HeroExample from './hero_example.js'
4 |
5 | import background from "./images/hero_background.jpg";
6 | import { Parallax, Background } from 'react-parallax';
7 |
8 | import "./styles/demo.scss"
9 | import "../css/style.scss"
10 |
11 | export default class Root extends React.Component {
12 | render() {
13 | return (
14 |
15 |
16 |
17 |
18 |
19 | ReactJS Datepicker2
20 |
21 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
ReactJS Datepicker2
34 |
A simple and reusable datepicker component for React. (with persian jalaali calendar)
35 |
36 |
Installation
37 |
The package can be installed via NPM:
38 |
npm install react-datepicker2 --save
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | )
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/docs/src/styles/demo.scss:
--------------------------------------------------------------------------------
1 | @import './font';
2 |
3 |
4 | body {
5 | font-family: $fontFamily;
6 | }
7 |
--------------------------------------------------------------------------------
/docs/src/styles/font.scss:
--------------------------------------------------------------------------------
1 | $fontFamily:'Open Sans', 'Vazir';
2 |
3 | @font-face {
4 | font-family: 'Open Sans';
5 | font-style: normal;
6 | font-weight: normal;
7 | font-display: swap;
8 | src: local('Open Sans Regular'), local('OpenSans-Regular'),
9 | url(https://mberneti.github.io/react-datepicker2/fonts/opensans.woff2) format('woff2');
10 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
11 | }
12 |
13 | @font-face {
14 | font-family: 'Vazir';
15 | src: url('https://mberneti.github.io/react-datepicker2/fonts/Vazir-WOL.eot');
16 | src: local('Vazir'),
17 | url('https://mberneti.github.io/react-datepicker2/fonts/Vazir-WOL.eot?#iefix') format('embedded-opentype'),
18 | url('https://mberneti.github.io/react-datepicker2/fonts/Vazir-WOL.woff2') format('woff2'),
19 | url('https://mberneti.github.io/react-datepicker2/fonts/Vazir-WOL.woff') format('woff'),
20 | url('https://mberneti.github.io/react-datepicker2/fonts/Vazir-WOL.ttf') format('truetype');
21 | font-weight: normal;
22 | font-style: normal;
23 | }
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | verbose: true,
3 | moduleFileExtensions: ["js", "jsx", "ts", "tsx"],
4 | transform: {
5 | "^.+\\.(js|jsx|ts|tsx)$": "./tests/transform.js"
6 | },
7 | "moduleNameMapper": {
8 | "\\.(css|less|scss|sass)$": "identity-obj-proxy",
9 | "\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/mocks/fileMock.js"
10 | }
11 | };
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/04/DefaultStyles_0426067cf78702fde267b48a1613750d:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_29k6g8vqf9 = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/components/DefaultStyles.js',hash = '4ae21b5a41d83814814fc78899499028f28818e1',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/components/DefaultStyles.js', statementMap: { '0': { start: { line: 1, column: 29 }, end: { line: 13, column: 1 } } }, fnMap: {}, branchMap: {}, s: { '0': 0 }, f: {}, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var defaultStyles = /* istanbul ignore next */exports.defaultStyles = (++cov_29k6g8vqf9.s[0], {
2 | calendarContainer: 'calendarContainer',
3 | heading: 'heading',
4 | prev: 'prev',
5 | next: 'next',
6 | title: 'title',
7 | dayWrapper: 'dayWrapper',
8 | currentMonth: 'currentMonth',
9 | daysOfWeek: 'daysOfWeek',
10 | monthsList: 'monthsList',
11 | selected: 'selected',
12 | dayPickerContainer: 'dayPickerContainer' });
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/0e/assets_0e4d24d48a799d0f1638d9d4018b0e11:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_9eiztr36y = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/utils/assets.js',hash = 'dad0c07ddc8c160887b3cb4af4e6b1ed07992660',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/utils/assets.js', statementMap: { '0': { start: { line: 1, column: 25 }, end: { line: 3, column: 1 } }, '1': { start: { line: 5, column: 26 }, end: { line: 7, column: 1 } }, '2': { start: { line: 9, column: 22 }, end: { line: 11, column: 1 } } }, fnMap: {}, branchMap: {}, s: { '0': 0, '1': 0, '2': 0 }, f: {}, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var leftArrow = /* istanbul ignore next */exports.leftArrow = (++cov_9eiztr36y.s[0], {
2 | __html: '' });
3 |
4 |
5 | var rightArrow = /* istanbul ignore next */exports.rightArrow = (++cov_9eiztr36y.s[1], {
6 | __html: '' });
7 |
8 |
9 | var remove = /* istanbul ignore next */exports.remove = (++cov_9eiztr36y.s[2], {
10 | __html: '' });
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/41/default_418edb7731b427a46ddba55a07167878:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_u8ixqmbk5 = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/default.js',hash = '4d6cd3ab583df8f1ab2f4bad6b4c8a954398038d',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/default.js', statementMap: { '0': { start: { line: 5, column: 18 }, end: { line: 17, column: 2 } }, '1': { start: { line: 7, column: 4 }, end: { line: 9, column: 5 } }, '2': { start: { line: 12, column: 4 }, end: { line: 15, column: 6 } }, '3': { start: { line: 14, column: 25 }, end: { line: 14, column: 49 } }, '4': { start: { line: 19, column: 14 }, end: { line: 19, column: 23 } }, '5': { start: { line: 20, column: 13 }, end: { line: 33, column: 1 } }, '6': { start: { line: 34, column: 16 }, end: { line: 34, column: 42 } } }, fnMap: { '0': { name: '(anonymous_0)', decl: { start: { line: 14, column: 16 }, end: { line: 14, column: 17 } }, loc: { start: { line: 14, column: 25 }, end: { line: 14, column: 49 } }, line: 14 } }, branchMap: {}, s: { '0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0 }, f: { '0': 0 }, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);
2 | var /* istanbul ignore next */_moment = require('moment'); /* istanbul ignore next */var _moment2 = _interopRequireDefault(_moment);
3 | var /* istanbul ignore next */_DatePicker = require('../../../src/components/DatePicker'); /* istanbul ignore next */var _DatePicker2 = _interopRequireDefault(_DatePicker);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
4 |
5 | var component = /* istanbul ignore next */(++cov_u8ixqmbk5.s[0], /* istanbul ignore next */_react2.default.createClass({ /* istanbul ignore next */displayName: 'component', /* istanbul ignore next */
6 | getInitialState: function getInitialState() {/* istanbul ignore next */++cov_u8ixqmbk5.s[1];
7 | return {
8 | value: /* istanbul ignore next */(0, _moment2.default)() };
9 |
10 | }, /* istanbul ignore next */
11 | render: function render() {/* istanbul ignore next */var _this = this;++cov_u8ixqmbk5.s[2];
12 | return (/* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */_DatePicker2.default, /* istanbul ignore next */{
13 | value: this.state.value,
14 | onChange: function /* istanbul ignore next */onChange(value) {/* istanbul ignore next */++cov_u8ixqmbk5.f[0];++cov_u8ixqmbk5.s[3];return (/* istanbul ignore next */_this.setState({ value: value }));} }));
15 |
16 | } }));
17 |
18 |
19 | var title = /* istanbul ignore next */(++cov_u8ixqmbk5.s[4], 'Default');
20 | var code = /* istanbul ignore next */(++cov_u8ixqmbk5.s[5], 'const component = React.createClass({\n getInitialState() {\n return {\n value: moment()\n }\n },\n render() {\n return this.setState({ value })}\n />\n }\n});\n');
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | var Default = /* istanbul ignore next */(++cov_u8ixqmbk5.s[6], { component: component, title: title, code: code }); /* istanbul ignore next */exports.default =
35 |
36 | Default;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/49/switchIsGregorian_495500e11c8cca1ba1ce59fc770a3e05:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_rp5l9qu0f = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/switchIsGregorian.js',hash = '50d90331cebeec112a3fa1dbe7cb20330a6997ba',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/switchIsGregorian.js', statementMap: { '0': { start: { line: 5, column: 18 }, end: { line: 25, column: 2 } }, '1': { start: { line: 7, column: 4 }, end: { line: 10, column: 5 } }, '2': { start: { line: 13, column: 4 }, end: { line: 23, column: 16 } }, '3': { start: { line: 17, column: 33 }, end: { line: 17, column: 57 } }, '4': { start: { line: 20, column: 35 }, end: { line: 20, column: 90 } }, '5': { start: { line: 27, column: 14 }, end: { line: 27, column: 34 } }, '6': { start: { line: 28, column: 13 }, end: { line: 42, column: 1 } }, '7': { start: { line: 43, column: 26 }, end: { line: 43, column: 52 } } }, fnMap: { '0': { name: '(anonymous_0)', decl: { start: { line: 17, column: 24 }, end: { line: 17, column: 25 } }, loc: { start: { line: 17, column: 33 }, end: { line: 17, column: 57 } }, line: 17 }, '1': { name: '(anonymous_1)', decl: { start: { line: 20, column: 29 }, end: { line: 20, column: 30 } }, loc: { start: { line: 20, column: 35 }, end: { line: 20, column: 90 } }, line: 20 } }, branchMap: { '0': { loc: { start: { line: 21, column: 15 }, end: { line: 21, column: 79 } }, type: 'cond-expr', locations: [{ start: { line: 21, column: 38 }, end: { line: 21, column: 57 } }, { start: { line: 21, column: 58 }, end: { line: 21, column: 79 } }], line: 21 } }, s: { '0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0 }, f: { '0': 0, '1': 0 }, b: { '0': [0, 0] }, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);
2 | var /* istanbul ignore next */_momentJalaali = require('moment-jalaali'); /* istanbul ignore next */var _momentJalaali2 = _interopRequireDefault(_momentJalaali);
3 | var /* istanbul ignore next */_DatePicker = require('../../../src/components/DatePicker'); /* istanbul ignore next */var _DatePicker2 = _interopRequireDefault(_DatePicker);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
4 |
5 | var component = /* istanbul ignore next */(++cov_rp5l9qu0f.s[0], /* istanbul ignore next */_react2.default.createClass({ /* istanbul ignore next */displayName: 'component', /* istanbul ignore next */
6 | getInitialState: function getInitialState() {/* istanbul ignore next */++cov_rp5l9qu0f.s[1];
7 | return {
8 | value: /* istanbul ignore next */(0, _momentJalaali2.default)(),
9 | isGregorian: true };
10 |
11 | }, /* istanbul ignore next */
12 | render: function render() {/* istanbul ignore next */var _this = this;++cov_rp5l9qu0f.s[2];
13 | return (/* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */null,
14 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */_DatePicker2.default, /* istanbul ignore next */{
15 | value: this.state.value,
16 | isGregorian: this.state.isGregorian,
17 | onChange: function /* istanbul ignore next */onChange(value) {/* istanbul ignore next */++cov_rp5l9qu0f.f[0];++cov_rp5l9qu0f.s[3];return (/* istanbul ignore next */_this.setState({ value: value }));} }),
18 |
19 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'br', /* istanbul ignore next */null),
20 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'button', /* istanbul ignore next */{ onClick: function /* istanbul ignore next */onClick() {/* istanbul ignore next */++cov_rp5l9qu0f.f[1];++cov_rp5l9qu0f.s[4];return (/* istanbul ignore next */_this.setState({ isGregorian: ! /* istanbul ignore next */_this.state.isGregorian }));} },
21 | this.state.isGregorian ? /* istanbul ignore next */(++cov_rp5l9qu0f.b[0][0], 'switch to jalaali') : /* istanbul ignore next */(++cov_rp5l9qu0f.b[0][1], 'switch to gregorian'))));
22 |
23 |
24 | } }));
25 |
26 |
27 | var title = /* istanbul ignore next */(++cov_rp5l9qu0f.s[5], 'Switch IsGregorian');
28 | var code = /* istanbul ignore next */(++cov_rp5l9qu0f.s[6], 'const component = React.createClass({\n getInitialState() {\n return {\n value: moment()\n }\n },\n render() {\n return this.setState({ value })}\n />\n }\n});\n');
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | var SwitchIsGregorian = /* istanbul ignore next */(++cov_rp5l9qu0f.s[7], { component: component, title: title, code: code }); /* istanbul ignore next */exports.default =
44 | SwitchIsGregorian;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/4c/DaysOfWeek_4c58b3e516dd84657aca209197ad452e:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_1ggqs6m8l6 = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/components/DaysOfWeek.js',hash = '7bd699ac3454ff3ce690a74b4ecd4d10715fc885',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/components/DaysOfWeek.js', statementMap: { '0': { start: { line: 4, column: 30 }, end: { line: 4, column: 65 } }, '1': { start: { line: 5, column: 32 }, end: { line: 5, column: 74 } }, '2': { start: { line: 14, column: 36 }, end: { line: 14, column: 46 } }, '3': { start: { line: 16, column: 27 }, end: { line: 16, column: 88 } }, '4': { start: { line: 18, column: 4 }, end: { line: 22, column: 6 } }, '5': { start: { line: 20, column: 43 }, end: { line: 20, column: 70 } } }, fnMap: { '0': { name: '(anonymous_0)', decl: { start: { line: 13, column: 2 }, end: { line: 13, column: 3 } }, loc: { start: { line: 13, column: 11 }, end: { line: 23, column: 3 } }, line: 13 }, '1': { name: '(anonymous_1)', decl: { start: { line: 20, column: 28 }, end: { line: 20, column: 29 } }, loc: { start: { line: 20, column: 43 }, end: { line: 20, column: 70 } }, line: 20 } }, branchMap: { '0': { loc: { start: { line: 16, column: 27 }, end: { line: 16, column: 88 } }, type: 'cond-expr', locations: [{ start: { line: 16, column: 41 }, end: { line: 16, column: 64 } }, { start: { line: 16, column: 67 }, end: { line: 16, column: 88 } }], line: 16 } }, s: { '0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0 }, f: { '0': 0, '1': 0 }, b: { '0': [0, 0] }, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}
2 |
3 | // Day of week names for use in date-picker heading
4 | var dayOfWeekNamesJalaali = /* istanbul ignore next */(++cov_1ggqs6m8l6.s[0], ['ش', 'ی', 'د', 'س', 'چ', 'پ', 'ج']);
5 | var dayOfWeekNamesGregorian = /* istanbul ignore next */(++cov_1ggqs6m8l6.s[1], ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']); /* istanbul ignore next */var
6 |
7 | DaysOfWeek = function (_Component) {_inherits(DaysOfWeek, _Component);function DaysOfWeek() {_classCallCheck(this, DaysOfWeek);return _possibleConstructorReturn(this, (DaysOfWeek.__proto__ || Object.getPrototypeOf(DaysOfWeek)).apply(this, arguments));}_createClass(DaysOfWeek, [{ key: 'render', value: function render()
8 |
9 |
10 |
11 |
12 |
13 | {/* istanbul ignore next */++cov_1ggqs6m8l6.f[0];var _ref = (++cov_1ggqs6m8l6.s[2],
14 | this.props),styles = _ref.styles,isGregorian = _ref.isGregorian;
15 |
16 | var dayOfWeekNames = /* istanbul ignore next */(++cov_1ggqs6m8l6.s[3], isGregorian ? /* istanbul ignore next */(++cov_1ggqs6m8l6.b[0][0], dayOfWeekNamesGregorian) : /* istanbul ignore next */(++cov_1ggqs6m8l6.b[0][1], dayOfWeekNamesJalaali)); /* istanbul ignore next */++cov_1ggqs6m8l6.s[4];
17 |
18 | return (
19 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ className: styles.daysOfWeek },
20 | dayOfWeekNames.map(function (name, key) {/* istanbul ignore next */++cov_1ggqs6m8l6.f[1];++cov_1ggqs6m8l6.s[5];return (/* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ key: key }, name));})));
21 |
22 |
23 | } }]);return DaysOfWeek;}(_react.Component); /* istanbul ignore next */DaysOfWeek.propTypes = { styles: /* istanbul ignore next */_react.PropTypes.object, isGregorian: /* istanbul ignore next */_react.PropTypes.bool }; /* istanbul ignore next */exports.default = DaysOfWeek;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/59/index_5981c889a216c53cc86fdae2ae981729:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.Calendar = undefined;var cov_2djbu68kaq = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/index.js',hash = 'dd3279a80399ba7d28503a3d6b0f6ba17ae99764',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/index.js', statementMap: {}, fnMap: {}, branchMap: {}, s: {}, f: {}, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_DatePicker = require('./components/DatePicker'); /* istanbul ignore next */var _DatePicker2 = _interopRequireDefault(_DatePicker);var _Calendar2 = require('./components/Calendar');var _Calendar3 = _interopRequireDefault(_Calendar2);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}exports.default = _DatePicker2.default;exports.
2 |
3 | Calendar = _Calendar3.default;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/61/docs.test_61f9d26e853386fc294e8a5c8d77a3c3:
--------------------------------------------------------------------------------
1 | 'use strict';var _react = require('react');var _react2 = _interopRequireDefault(_react);
2 | var _enzyme = require('enzyme');
3 | var _root = require('../docs/src/root');var _root2 = _interopRequireDefault(_root);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
4 |
5 | describe('', function () {
6 |
7 | it('should render docs ', function () {
8 | var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_root2.default, null));
9 | wrapper.render();
10 | });
11 |
12 | });
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/70/jalaali_709d93190483ed494bc3a3af68b6268a:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_236juvmlqc = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/jalaali.js',hash = '36aaa8fae82cd0dab476dd45caf97b93f5f0d4bd',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/jalaali.js', statementMap: { '0': { start: { line: 5, column: 18 }, end: { line: 18, column: 2 } }, '1': { start: { line: 7, column: 4 }, end: { line: 9, column: 5 } }, '2': { start: { line: 12, column: 4 }, end: { line: 16, column: 6 } }, '3': { start: { line: 15, column: 25 }, end: { line: 15, column: 49 } }, '4': { start: { line: 20, column: 14 }, end: { line: 20, column: 23 } }, '5': { start: { line: 21, column: 13 }, end: { line: 35, column: 1 } }, '6': { start: { line: 36, column: 16 }, end: { line: 36, column: 42 } } }, fnMap: { '0': { name: '(anonymous_0)', decl: { start: { line: 15, column: 16 }, end: { line: 15, column: 17 } }, loc: { start: { line: 15, column: 25 }, end: { line: 15, column: 49 } }, line: 15 } }, branchMap: {}, s: { '0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0 }, f: { '0': 0 }, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);
2 | var /* istanbul ignore next */_momentJalaali = require('moment-jalaali'); /* istanbul ignore next */var _momentJalaali2 = _interopRequireDefault(_momentJalaali);
3 | var /* istanbul ignore next */_DatePicker = require('../../../src/components/DatePicker'); /* istanbul ignore next */var _DatePicker2 = _interopRequireDefault(_DatePicker);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
4 |
5 | var component = /* istanbul ignore next */(++cov_236juvmlqc.s[0], /* istanbul ignore next */_react2.default.createClass({ /* istanbul ignore next */displayName: 'component', /* istanbul ignore next */
6 | getInitialState: function getInitialState() {/* istanbul ignore next */++cov_236juvmlqc.s[1];
7 | return {
8 | value: /* istanbul ignore next */(0, _momentJalaali2.default)() };
9 |
10 | }, /* istanbul ignore next */
11 | render: function render() {/* istanbul ignore next */var _this = this;++cov_236juvmlqc.s[2];
12 | return (/* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */_DatePicker2.default, /* istanbul ignore next */{
13 | isGregorian: false,
14 | value: this.state.value,
15 | onChange: function /* istanbul ignore next */onChange(value) {/* istanbul ignore next */++cov_236juvmlqc.f[0];++cov_236juvmlqc.s[3];return (/* istanbul ignore next */_this.setState({ value: value }));} }));
16 |
17 | } }));
18 |
19 |
20 | var title = /* istanbul ignore next */(++cov_236juvmlqc.s[4], 'Jalaali');
21 | var code = /* istanbul ignore next */(++cov_236juvmlqc.s[5], 'const component = React.createClass({\n getInitialState() {\n return {\n value: moment()\n }\n },\n render() {\n return this.setState({ value })}\n />\n }\n});\n');
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | var Jalaali = /* istanbul ignore next */(++cov_236juvmlqc.s[6], { component: component, title: title, code: code }); /* istanbul ignore next */exports.default =
37 | Jalaali;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/7f/moment-helper_7f2978e6b727b56ebb4572eebd368230:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_httdjmaaq = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/utils/moment-helper.js',hash = '04e10cb8d8092457a78959e7efa3b47f469d51ca',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/utils/moment-helper.js', statementMap: { '0': { start: { line: 8, column: 15 }, end: { line: 8, column: 17 } }, '1': { start: { line: 10, column: 22 }, end: { line: 10, column: 54 } }, '2': { start: { line: 11, column: 20 }, end: { line: 11, column: 39 } }, '3': { start: { line: 13, column: 18 }, end: { line: 13, column: 52 } }, '4': { start: { line: 14, column: 14 }, end: { line: 14, column: 46 } }, '5': { start: { line: 17, column: 2 }, end: { line: 17, column: 60 } }, '6': { start: { line: 20, column: 2 }, end: { line: 20, column: 51 } }, '7': { start: { line: 22, column: 2 }, end: { line: 25, column: 3 } }, '8': { start: { line: 23, column: 4 }, end: { line: 23, column: 31 } }, '9': { start: { line: 24, column: 4 }, end: { line: 24, column: 27 } }, '10': { start: { line: 27, column: 2 }, end: { line: 27, column: 14 } } }, fnMap: { '0': { name: 'getDaysOfMonth', decl: { start: { line: 7, column: 16 }, end: { line: 7, column: 30 } }, loc: { start: { line: 7, column: 51 }, end: { line: 28, column: 1 } }, line: 7 } }, branchMap: { '0': { loc: { start: { line: 10, column: 22 }, end: { line: 10, column: 54 } }, type: 'cond-expr', locations: [{ start: { line: 10, column: 36 }, end: { line: 10, column: 43 } }, { start: { line: 10, column: 46 }, end: { line: 10, column: 54 } }], line: 10 }, '1': { loc: { start: { line: 11, column: 20 }, end: { line: 11, column: 39 } }, type: 'cond-expr', locations: [{ start: { line: 11, column: 34 }, end: { line: 11, column: 35 } }, { start: { line: 11, column: 38 }, end: { line: 11, column: 39 } }], line: 11 } }, s: { '0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0, '10': 0 }, f: { '0': 0 }, b: { '0': [0, 0], '1': [0, 0] }, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();exports.
2 |
3 |
4 |
5 |
6 |
7 | getDaysOfMonth = getDaysOfMonth; /**
8 | * Get days of a month that should be shown on a month page
9 | *
10 | * @param month A moment object
11 | * @returns {Array}
12 | */function getDaysOfMonth(month, isGregorian) {/* istanbul ignore next */++cov_httdjmaaq.f[0];var days = /* istanbul ignore next */(++cov_httdjmaaq.s[0], []);var monthFormat = /* istanbul ignore next */(++cov_httdjmaaq.s[1], isGregorian ? /* istanbul ignore next */(++cov_httdjmaaq.b[0][0], 'Month') : /* istanbul ignore next */(++cov_httdjmaaq.b[0][1], 'jMonth'));var dayOffset = /* istanbul ignore next */(++cov_httdjmaaq.s[2], isGregorian ? /* istanbul ignore next */(++cov_httdjmaaq.b[1][0], 0) : /* istanbul ignore next */(++cov_httdjmaaq.b[1][1], 1));
13 | var current = /* istanbul ignore next */(++cov_httdjmaaq.s[3], month.clone().startOf(monthFormat));
14 | var end = /* istanbul ignore next */(++cov_httdjmaaq.s[4], month.clone().endOf(monthFormat));
15 |
16 | // Set start to the first day of week in the last month
17 | /* istanbul ignore next */++cov_httdjmaaq.s[5];current.subtract((current.day() + dayOffset) % 7, 'days');
18 |
19 | // Set end to the last day of week in the next month
20 | /* istanbul ignore next */++cov_httdjmaaq.s[6];end.add(6 - (end.day() + dayOffset) % 7, 'days'); /* istanbul ignore next */++cov_httdjmaaq.s[7];
21 |
22 | while (current.isBefore(end)) {/* istanbul ignore next */++cov_httdjmaaq.s[8];
23 | days.push(current.clone()); /* istanbul ignore next */++cov_httdjmaaq.s[9];
24 | current.add(1, 'days');
25 | } /* istanbul ignore next */++cov_httdjmaaq.s[10];
26 |
27 | return days;
28 | }
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/89/disabledTimepicker_8962d3441b5e0a01883ceb7e3b9ad50d:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_10k3nthl4x = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/disabledTimepicker.js',hash = 'c93cbe0556a102b77245eb1159de18ca4269cfd7',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/examples/disabledTimepicker.js', statementMap: { '0': { start: { line: 5, column: 18 }, end: { line: 18, column: 2 } }, '1': { start: { line: 7, column: 4 }, end: { line: 9, column: 5 } }, '2': { start: { line: 12, column: 4 }, end: { line: 16, column: 6 } }, '3': { start: { line: 15, column: 25 }, end: { line: 15, column: 49 } }, '4': { start: { line: 20, column: 14 }, end: { line: 20, column: 35 } }, '5': { start: { line: 21, column: 13 }, end: { line: 36, column: 1 } }, '6': { start: { line: 37, column: 27 }, end: { line: 37, column: 53 } } }, fnMap: { '0': { name: '(anonymous_0)', decl: { start: { line: 15, column: 16 }, end: { line: 15, column: 17 } }, loc: { start: { line: 15, column: 25 }, end: { line: 15, column: 49 } }, line: 15 } }, branchMap: {}, s: { '0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0 }, f: { '0': 0 }, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);
2 | var /* istanbul ignore next */_momentJalaali = require('moment-jalaali'); /* istanbul ignore next */var _momentJalaali2 = _interopRequireDefault(_momentJalaali);
3 | var /* istanbul ignore next */_DatePicker = require('../../../src/components/DatePicker'); /* istanbul ignore next */var _DatePicker2 = _interopRequireDefault(_DatePicker);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
4 |
5 | var component = /* istanbul ignore next */(++cov_10k3nthl4x.s[0], /* istanbul ignore next */_react2.default.createClass({ /* istanbul ignore next */displayName: 'component', /* istanbul ignore next */
6 | getInitialState: function getInitialState() {/* istanbul ignore next */++cov_10k3nthl4x.s[1];
7 | return {
8 | value: /* istanbul ignore next */(0, _momentJalaali2.default)() };
9 |
10 | }, /* istanbul ignore next */
11 | render: function render() {/* istanbul ignore next */var _this = this;++cov_10k3nthl4x.s[2];
12 | return (/* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */_DatePicker2.default, /* istanbul ignore next */{
13 | timePicker: false,
14 | value: this.state.value,
15 | onChange: function /* istanbul ignore next */onChange(value) {/* istanbul ignore next */++cov_10k3nthl4x.f[0];++cov_10k3nthl4x.s[3];return (/* istanbul ignore next */_this.setState({ value: value }));} }));
16 |
17 | } }));
18 |
19 |
20 | var title = /* istanbul ignore next */(++cov_10k3nthl4x.s[4], 'Disabled Timepicker');
21 | var code = /* istanbul ignore next */(++cov_10k3nthl4x.s[5], 'const component = React.createClass({\n getInitialState() {\n return {\n value: moment()\n }\n },\n render() {\n return this.setState({ value })}\n />\n }\n});\n');
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var DisabledTimepicker = /* istanbul ignore next */(++cov_10k3nthl4x.s[6], { component: component, title: title, code: code }); /* istanbul ignore next */exports.default =
38 | DisabledTimepicker;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/89/persian_895255b495935fcd3aa50f83a09e2863:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_2oa2hq8i39 = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/utils/persian.js',hash = '0e2bc96312f2c96ea765952ead6311c2e3388c66',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/utils/persian.js', statementMap: { '0': { start: { line: 1, column: 26 }, end: { line: 1, column: 76 } }, '1': { start: { line: 2, column: 21 }, end: { line: 2, column: 81 } }, '2': { start: { line: 6, column: 2 }, end: { line: 12, column: 3 } }, '3': { start: { line: 7, column: 4 }, end: { line: 7, column: 30 } }, '4': { start: { line: 8, column: 9 }, end: { line: 12, column: 3 } }, '5': { start: { line: 9, column: 4 }, end: { line: 9, column: 16 } }, '6': { start: { line: 11, column: 4 }, end: { line: 11, column: 19 } }, '7': { start: { line: 14, column: 2 }, end: { line: 14, column: 16 } }, '8': { start: { line: 18, column: 15 }, end: { line: 18, column: 21 } }, '9': { start: { line: 20, column: 2 }, end: { line: 22, column: 3 } }, '10': { start: { line: 21, column: 4 }, end: { line: 21, column: 75 } }, '11': { start: { line: 24, column: 2 }, end: { line: 24, column: 16 } }, '12': { start: { line: 28, column: 2 }, end: { line: 28, column: 46 } } }, fnMap: { '0': { name: 'prepareNumber', decl: { start: { line: 4, column: 9 }, end: { line: 4, column: 22 } }, loc: { start: { line: 4, column: 30 }, end: { line: 15, column: 1 } }, line: 4 }, '1': { name: 'latinToPersian', decl: { start: { line: 17, column: 9 }, end: { line: 17, column: 23 } }, loc: { start: { line: 17, column: 32 }, end: { line: 25, column: 1 } }, line: 17 }, '2': { name: 'persianNumber', decl: { start: { line: 27, column: 16 }, end: { line: 27, column: 29 } }, loc: { start: { line: 27, column: 37 }, end: { line: 29, column: 1 } }, line: 27 } }, branchMap: { '0': { loc: { start: { line: 6, column: 2 }, end: { line: 12, column: 3 } }, type: 'if', locations: [{ start: { line: 6, column: 2 }, end: { line: 12, column: 3 } }, { start: { line: 6, column: 2 }, end: { line: 12, column: 3 } }], line: 6 }, '1': { loc: { start: { line: 8, column: 9 }, end: { line: 12, column: 3 } }, type: 'if', locations: [{ start: { line: 8, column: 9 }, end: { line: 12, column: 3 } }, { start: { line: 8, column: 9 }, end: { line: 12, column: 3 } }], line: 8 } }, s: { '0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0, '10': 0, '11': 0, '12': 0 }, f: { '0': 0, '1': 0, '2': 0 }, b: { '0': [0, 0], '1': [0, 0] }, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();exports.
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | persianNumber = persianNumber;var latinToPersianMap = /* istanbul ignore next */(++cov_2oa2hq8i39.s[0], ['۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰']);var latinNumbers = /* istanbul ignore next */(++cov_2oa2hq8i39.s[1], [/1/g, /2/g, /3/g, /4/g, /5/g, /6/g, /7/g, /8/g, /9/g, /0/g]);function prepareNumber(input) {/* istanbul ignore next */++cov_2oa2hq8i39.f[0];var string = /* istanbul ignore next */void 0; /* istanbul ignore next */++cov_2oa2hq8i39.s[2];if (typeof input === 'number') {/* istanbul ignore next */++cov_2oa2hq8i39.b[0][0];++cov_2oa2hq8i39.s[3];string = input.toString();} else {/* istanbul ignore next */++cov_2oa2hq8i39.b[0][1];++cov_2oa2hq8i39.s[4];if (typeof input === 'undefined') {/* istanbul ignore next */++cov_2oa2hq8i39.b[1][0];++cov_2oa2hq8i39.s[5];string = '';} else {/* istanbul ignore next */++cov_2oa2hq8i39.b[1][1];++cov_2oa2hq8i39.s[6];string = input;}} /* istanbul ignore next */++cov_2oa2hq8i39.s[7];return string;}function latinToPersian(string) {/* istanbul ignore next */++cov_2oa2hq8i39.f[1];var result = /* istanbul ignore next */(++cov_2oa2hq8i39.s[8], string); /* istanbul ignore next */++cov_2oa2hq8i39.s[9];for (var index = 0; index < 10; index++) {/* istanbul ignore next */++cov_2oa2hq8i39.s[10];result = result.replace(latinNumbers[index], latinToPersianMap[index]);} /* istanbul ignore next */++cov_2oa2hq8i39.s[11];return result;}function persianNumber(input) {/* istanbul ignore next */++cov_2oa2hq8i39.f[2];++cov_2oa2hq8i39.s[12];
28 | return latinToPersian(prepareNumber(input));
29 | }
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/9c/datepicker.test_9c5bb204d927362a228722f991550509:
--------------------------------------------------------------------------------
1 | 'use strict';var _react = require('react');var _react2 = _interopRequireDefault(_react);
2 | var _enzyme = require('enzyme');
3 | var _src = require('../src');var _src2 = _interopRequireDefault(_src);
4 | var _momentJalaali = require('moment-jalaali');var _momentJalaali2 = _interopRequireDefault(_momentJalaali);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
5 |
6 | describe('', function () {
7 |
8 | it('should render in gregorian mode ', function () {
9 | var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_src2.default, { value: (0, _momentJalaali2.default)() }));
10 | wrapper.render();
11 | });
12 |
13 | it('should render in jalaali mode ', function () {
14 | var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_src2.default, { value: (0, _momentJalaali2.default)(), isGregorian: false }));
15 | wrapper.render();
16 | });
17 |
18 | });
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/a7/placements_a77283b7d59c4471ee5f7b14d73a9fb2:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_7vn1csgpe = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/components/TimePicker/placements.js',hash = 'a1145f03816f736ba38a97ccb10404734abc0f05',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/components/TimePicker/placements.js', statementMap: { '0': { start: { line: 1, column: 27 }, end: { line: 4, column: 1 } }, '1': { start: { line: 6, column: 21 }, end: { line: 6, column: 27 } }, '2': { start: { line: 8, column: 19 }, end: { line: 33, column: 1 } } }, fnMap: {}, branchMap: {}, s: { '0': 0, '1': 0, '2': 0 }, f: {}, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var autoAdjustOverflow = /* istanbul ignore next */(++cov_7vn1csgpe.s[0], {
2 | adjustX: 1,
3 | adjustY: 1 });
4 |
5 |
6 | var targetOffset = /* istanbul ignore next */(++cov_7vn1csgpe.s[1], [0, 0]);
7 |
8 | var placements = /* istanbul ignore next */(++cov_7vn1csgpe.s[2], {
9 | bottomLeft: {
10 | points: ['tl', 'tl'],
11 | overflow: autoAdjustOverflow,
12 | offset: [0, -3],
13 | targetOffset: targetOffset },
14 |
15 | bottomRight: {
16 | points: ['tr', 'tr'],
17 | overflow: autoAdjustOverflow,
18 | offset: [0, -3],
19 | targetOffset: targetOffset },
20 |
21 | topRight: {
22 | points: ['br', 'br'],
23 | overflow: autoAdjustOverflow,
24 | offset: [0, 3],
25 | targetOffset: targetOffset },
26 |
27 | topLeft: {
28 | points: ['bl', 'bl'],
29 | overflow: autoAdjustOverflow,
30 | offset: [0, 3],
31 | targetOffset: targetOffset } }); /* istanbul ignore next */exports.default =
32 |
33 |
34 |
35 | placements;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/ac/index_ac2248ecf7f754a50f8bb12822c1467b:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_983t83y2q = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/src/components/TimePicker/index.js',hash = '3ae874e57bdefadc38f3dce2d18430a967f91808',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/src/components/TimePicker/index.js', statementMap: {}, fnMap: {}, branchMap: {}, s: {}, f: {}, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_TimePicker = require('./TimePicker'); /* istanbul ignore next */var _TimePicker2 = _interopRequireDefault(_TimePicker);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}exports.default = _TimePicker2.default;
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/b5/root_b546b2f97678118f63eb1c3cbce2291c:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_nie90bsq6 = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/root.js',hash = 'd670d3980e98f460da03118369f24ee9e67d5922',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/root.js', statementMap: { '0': { start: { line: 9, column: 4 }, end: { line: 42, column: 5 } } }, fnMap: {}, branchMap: {}, s: { '0': 0 }, f: {}, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);
2 | var /* istanbul ignore next */_example_components = require('./example_components.js'); /* istanbul ignore next */var _example_components2 = _interopRequireDefault(_example_components);
3 | var /* istanbul ignore next */_hero_example = require('./hero_example.js'); /* istanbul ignore next */var _hero_example2 = _interopRequireDefault(_hero_example);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}exports.default =
4 |
5 | /* istanbul ignore next */_react2.default.createClass({
6 | displayName: 'Root', /* istanbul ignore next */
7 |
8 | render: function render() {/* istanbul ignore next */++cov_nie90bsq6.s[0];
9 | return (
10 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */null,
11 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ className: 'hero' },
12 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ className: 'hero__content' },
13 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'h1', /* istanbul ignore next */{ className: 'hero__title' }, /* istanbul ignore next */'ReactJS Datepicker2'),
14 |
15 |
16 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ className: 'hero__crafted-by' },
17 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'a', /* istanbul ignore next */{ href: 'https://berneti.ir', className: 'hero__crafted-by-link' }, /* istanbul ignore next */'Crafted by ',
18 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'h3', /* istanbul ignore next */{ className: 'logo' }, /* istanbul ignore next */'mberneti'))),
19 |
20 |
21 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ className: 'hero__example' },
22 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */_hero_example2.default, /* istanbul ignore next */null)))),
23 |
24 |
25 |
26 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ className: 'wrapper' },
27 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'h1', /* istanbul ignore next */null, /* istanbul ignore next */'ReactJS Datepicker2'),
28 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'p', /* istanbul ignore next */null, /* istanbul ignore next */'A simple and reusable datepicker component for React. (with persian jalaali calendar)'),
29 |
30 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'h2', /* istanbul ignore next */null, /* istanbul ignore next */'Installation'),
31 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'p', /* istanbul ignore next */null, /* istanbul ignore next */'The package can be installed via NPM:'),
32 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'p', /* istanbul ignore next */null, /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'code', /* istanbul ignore next */null, /* istanbul ignore next */'npm install react-datepicker2 --save'))),
33 |
34 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ className: 'wrapper' },
35 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */_example_components2.default, /* istanbul ignore next */null)),
36 |
37 |
38 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'a', /* istanbul ignore next */{ href: 'https://github.com/mberneti/react-datepicker2/' },
39 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'img', /* istanbul ignore next */{ className: 'github-ribbon', src: 'https://mberneti.github.io/react-datepicker2/images/ribbon.png', alt: 'Fork me on GitHub' }))));
40 |
41 |
42 |
43 | } });
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/c0/hero_example_c0f2f10709e849ab6432ab051de0cc53:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_1e1liwrctw = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/hero_example.js',hash = '275c0f09499b2c92289bf518742a670a48d0a83e',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/hero_example.js', statementMap: { '0': { start: { line: 7, column: 4 }, end: { line: 9, column: 5 } }, '1': { start: { line: 12, column: 4 }, end: { line: 15, column: 6 } }, '2': { start: { line: 13, column: 25 }, end: { line: 13, column: 49 } } }, fnMap: { '0': { name: '(anonymous_0)', decl: { start: { line: 13, column: 16 }, end: { line: 13, column: 17 } }, loc: { start: { line: 13, column: 25 }, end: { line: 13, column: 49 } }, line: 13 } }, branchMap: {}, s: { '0': 0, '1': 0, '2': 0 }, f: { '0': 0 }, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);
2 | var /* istanbul ignore next */_moment = require('moment'); /* istanbul ignore next */var _moment2 = _interopRequireDefault(_moment);
3 | var /* istanbul ignore next */_src = require('../../src'); /* istanbul ignore next */var _src2 = _interopRequireDefault(_src);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}exports.default =
4 |
5 | /* istanbul ignore next */_react2.default.createClass({ /* istanbul ignore next */displayName: 'hero_example', /* istanbul ignore next */
6 | getInitialState: function getInitialState() {/* istanbul ignore next */++cov_1e1liwrctw.s[0];
7 | return {
8 | value: /* istanbul ignore next */(0, _moment2.default)() };
9 |
10 | }, /* istanbul ignore next */
11 | render: function render() {/* istanbul ignore next */var _this = this;++cov_1e1liwrctw.s[1];
12 | return (/* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */_src2.default, /* istanbul ignore next */{
13 | onChange: function /* istanbul ignore next */onChange(value) {/* istanbul ignore next */++cov_1e1liwrctw.f[0];++cov_1e1liwrctw.s[2];return (/* istanbul ignore next */_this.setState({ value: value }));},
14 | value: this.state.value }));
15 |
16 | } });
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/cf/calendar.test_cfd9b7a807944f300d61d17275cb9371:
--------------------------------------------------------------------------------
1 | 'use strict';var _react = require('react');var _react2 = _interopRequireDefault(_react);
2 | var _enzyme = require('enzyme');
3 | var _src = require('../src');var _src2 = _interopRequireDefault(_src);
4 | var _momentJalaali = require('moment-jalaali');var _momentJalaali2 = _interopRequireDefault(_momentJalaali);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
5 |
6 | describe('', function () {
7 |
8 | it('should render in gregorian mode ', function () {
9 | var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_src2.default, { value: (0, _momentJalaali2.default)() }));
10 | wrapper.render();
11 | });
12 |
13 | it('should render in jalaali mode ', function () {
14 | var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_src2.default, { value: (0, _momentJalaali2.default)(), isGregorian: false }));
15 | wrapper.render();
16 | });
17 |
18 | });
--------------------------------------------------------------------------------
/jest/jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429/de/code_example_component_de9f83a86d1645ecf3131aa8395e37fa:
--------------------------------------------------------------------------------
1 | /* istanbul ignore next */'use strict';Object.defineProperty(exports, "__esModule", { value: true });var cov_r7q5gof92 = function () {var path = '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/code_example_component.js',hash = '63775dae1320eadc29798d04a18141502d67d238',global = new Function('return this')(),gcv = '__coverage__',coverageData = { path: '/mnt/g/Work/Current/projects/react-datepicker2/docs/src/code_example_component.js', statementMap: { '0': { start: { line: 13, column: 4 }, end: { line: 16, column: 10 } } }, fnMap: {}, branchMap: {}, s: { '0': 0 }, f: {}, b: {}, _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c' },coverage = global[gcv] || (global[gcv] = {});if (coverage[path] && coverage[path].hash === hash) {return coverage[path];}coverageData.hash = hash;return coverage[path] = coverageData;}();var /* istanbul ignore next */_react = require('react'); /* istanbul ignore next */var _react2 = _interopRequireDefault(_react);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}exports.default =
2 |
3 | /* istanbul ignore next */_react2.default.createClass({
4 | displayName: 'CodeExampleComponent',
5 |
6 | propTypes: {
7 | children: /* istanbul ignore next */_react2.default.PropTypes.element,
8 | id: /* istanbul ignore next */_react2.default.PropTypes.number,
9 | title: /* istanbul ignore next */_react2.default.PropTypes.string }, /* istanbul ignore next */
10 |
11 |
12 | render: function render() {/* istanbul ignore next */++cov_r7q5gof92.s[0];
13 | return (/* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'div', /* istanbul ignore next */{ key: this.props.id, id: /* istanbul ignore next */'example-' + this.props.id, className: 'example' },
14 | /* istanbul ignore next */_react2.default.createElement( /* istanbul ignore next */'h2', /* istanbul ignore next */{ className: 'example__heading' }, this.props.title),
15 | this.props.children));
16 |
17 | } });
--------------------------------------------------------------------------------
/jest/perf-cache-90c8bedf58fb8c35e1aefe5ab7033aea-f2a6b052d4b7af6a6d27c76b07ddacc5:
--------------------------------------------------------------------------------
1 | {"/mnt/g/Work/Current/projects/react-datepicker2/test/datepicker.test.js":[1,0],"/mnt/g/Work/Current/projects/react-datepicker2/test/calendar.test.js":[1,13881],"/mnt/g/Work/Current/projects/react-datepicker2/test/docs.test.js":[1,14077]}
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES6",
4 | "module": "commonjs",
5 | "experimentalDecorators": true
6 | },
7 | "include": [
8 | "src/**/*"
9 | ],
10 | "exclude": [
11 | "node_modules"
12 | ]
13 | }
--------------------------------------------------------------------------------
/mocks/fileMock.js:
--------------------------------------------------------------------------------
1 | module.exports = '';
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-datepicker2",
3 | "version": "v3.3.13",
4 | "description": "react datepicker component. (include persian jalaali calendar)",
5 | "main": "dist/umd/index.js",
6 | "types": "dist/types/index.d.ts",
7 | "module": "dist/umd/index.js",
8 | "repository": {
9 | "type": "git",
10 | "url": "https://github.com/mberneti/react-datepicker2"
11 | },
12 | "keywords": [
13 | "react",
14 | "react-datepicker",
15 | "react-datepicker2",
16 | "react-jalaali-datepicker",
17 | "jalaali-datepicker",
18 | "jalaali",
19 | "datepicker",
20 | "component",
21 | "react component",
22 | "react-component"
23 | ],
24 | "author": "mohammadreza berneti (mberneti)",
25 | "license": "MIT",
26 | "scripts": {
27 | "cypress": "cypress open",
28 | "test": "jest --runInBand --detectOpenHandles --no-cache --config ./jest.config.js --coverage && minicat coverage/lcov.info | coveralls",
29 | "start": "webpack-dev-server --mode development --config webpack.config.dev.js",
30 | "build": "npm-run-all build:dist build:docs",
31 | "build:dist": "npm run build:css && npm run build:js",
32 | "build:docs": "webpack --config webpack.config.docs.js",
33 | "build:js": "rollup -c",
34 | "build:css": "npm run compile && npm run prefix && npm run minify",
35 | "compile": "node-sass --output-style=expanded --source-map=true src/styles/style.scss src/styles/style.css",
36 | "prefix": "postcss src/styles/style.css --use=autoprefixer --map=false --output=src/styles/style.css",
37 | "minify": "cleancss --level=1 --source-map --source-map-inline-sources --output src/style.min.css src/styles/style.css",
38 | "lint": "eslint src --fix",
39 | "formatcodes": "prettier --write \"./src/**/*.js\""
40 | },
41 | "dependencies": {
42 | "classnames": "^2.2.5",
43 | "lodash.range": "^3.2.0",
44 | "moment-jalaali": "0.9.1",
45 | "moment-range": "^4.0.2",
46 | "prop-types": "^15.7.2",
47 | "rc-trigger": "3.0.0",
48 | "react-onclickoutside": "^6.8.0",
49 | "react-tether": "^2.0.0",
50 | "react-with-styles": "4.1.0"
51 | },
52 | "devDependencies": {
53 | "@babel/cli": "^7.4.4",
54 | "@babel/core": "^7.4.5",
55 | "@babel/plugin-external-helpers": "^7.2.0",
56 | "@babel/plugin-proposal-class-properties": "^7.4.4",
57 | "@babel/plugin-proposal-decorators": "^7.4.4",
58 | "@babel/plugin-proposal-object-rest-spread": "^7.4.4",
59 | "@babel/plugin-transform-modules-commonjs": "^7.4.4",
60 | "@babel/plugin-transform-object-assign": "^7.2.0",
61 | "@babel/plugin-transform-runtime": "^7.4.4",
62 | "@babel/preset-env": "^7.4.5",
63 | "@babel/preset-react": "^7.0.0",
64 | "@babel/preset-stage-0": "^7.0.0",
65 | "@babel/runtime": "^7.4.5",
66 | "autoprefixer": "^9.5.1",
67 | "babel-core": "^7.0.0-bridge.0",
68 | "babel-eslint": "^10.0.1",
69 | "babel-loader": "^8.0.6",
70 | "babel-plugin-module-resolver": "^3.2.0",
71 | "babel-plugin-transform-decorators-legacy": "^1.3.5",
72 | "babel-polyfill": "^6.23.0",
73 | "babel-preset-es2015": "^6.24.0",
74 | "babel-preset-es2016": "^6.22.0",
75 | "babel-preset-next": "^1.2.0",
76 | "babel-preset-stage-0": "^6.22.0",
77 | "babel-runtime": "^6.23.0",
78 | "clean-css-cli": "^4.3.0",
79 | "coveralls": "^2.12.0",
80 | "css-loader": "^2.1.1",
81 | "cypress": "^5.0.0",
82 | "enzyme": "^2.9.1",
83 | "enzyme-adapter-react-16": "^1.13.1",
84 | "eslint": "^5.16.0",
85 | "eslint-config-airbnb": "^17.1.0",
86 | "eslint-config-prettier": "^4.3.0",
87 | "eslint-plugin-import": "^2.17.3",
88 | "eslint-plugin-jsx-a11y": "^6.2.1",
89 | "eslint-plugin-prettier": "^3.1.0",
90 | "eslint-plugin-react": "^7.13.0",
91 | "file-loader": "^3.0.1",
92 | "highlight.js": "^9.10.0",
93 | "html-webpack-plugin": "^3.2.0",
94 | "identity-obj-proxy": "^3.0.0",
95 | "jest": "^24.8.0",
96 | "jest-enzyme": "^7.0.2",
97 | "jscoverage": "^0.6.0",
98 | "mini-css-extract-plugin": "^0.6.0",
99 | "minicat": "^1.0.0",
100 | "moment": "^2.18.1",
101 | "node-sass": "^4.12.0",
102 | "nodeunit": "^0.11.0",
103 | "npm-run-all": "^4.1.5",
104 | "path": "^0.12.7",
105 | "postcss-cli": "^6.1.2",
106 | "postcss-loader": "^3.0.0",
107 | "prettier": "^1.18.2",
108 | "react": "^16.8.4",
109 | "react-addons-test-utils": "^15.4.2",
110 | "react-dom": "^16.8.4",
111 | "react-parallax": "^2.2.0",
112 | "react-sticky": "^6.0.3",
113 | "react-switch": "^4.1.0",
114 | "react-syntax-highlight": "^15.3.1",
115 | "react-test-renderer": "^16.8.4",
116 | "rollup": "2.6.0",
117 | "rollup-plugin-babel": "^4.3.2",
118 | "rollup-plugin-commonjs": "10.1.0",
119 | "rollup-plugin-filesize": "^6.2.1",
120 | "rollup-plugin-local-resolve": "^1.0.7",
121 | "rollup-plugin-node-globals": "^1.4.0",
122 | "rollup-plugin-node-resolve": "5.2.0",
123 | "rollup-plugin-peer-deps-external": "^2.2.0",
124 | "rollup-plugin-postcss": "^2.0.3",
125 | "rollup-plugin-replace": "^2.2.0",
126 | "rollup-plugin-terser": "^5.1.3",
127 | "sass-loader": "^7.1.0",
128 | "style-loader": "^0.23.1",
129 | "webpack": "^4.32.2",
130 | "webpack-cli": "^3.3.2",
131 | "webpack-dev-server": "^3.4.1",
132 | "webpack-node-externals": "^1.7.2"
133 | },
134 | "peerDependencies": {
135 | "react": "^16.0.0",
136 | "react-dom": "^16.0.0"
137 | },
138 | "browserslist": [
139 | "last 2 versions"
140 | ]
141 | }
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import nodeResolve from 'rollup-plugin-node-resolve';
2 | import babel from 'rollup-plugin-babel';
3 | import commonjs from 'rollup-plugin-commonjs';
4 | import postcss from 'rollup-plugin-postcss';
5 | import peerDepsExternal from 'rollup-plugin-peer-deps-external';
6 | import filesize from 'rollup-plugin-filesize';
7 | import localResolve from 'rollup-plugin-local-resolve';
8 | import { terser } from 'rollup-plugin-terser';
9 | import replace from 'rollup-plugin-replace';
10 |
11 | import pkg from './package.json';
12 |
13 | const globals = {
14 | react: 'React',
15 | 'react-dom': 'ReactDom',
16 | 'prop-types': 'PropTypes',
17 | 'react-onclickoutside': 'onClickOutside',
18 | 'react-popper': 'ReactPopper',
19 | classnames: 'classNames',
20 | 'moment-jalaali': 'moment',
21 | 'react-tether': 'TetherComponent',
22 | 'rc-trigger': 'Trigger'
23 | };
24 |
25 | const config = {
26 | input: 'src/index.js',
27 | // sourcemap: true,
28 | output: [
29 | {
30 | file: pkg.module,
31 | format: 'umd',
32 | name: 'DatePicker',
33 | exports: 'named'
34 | }
35 | ],
36 | plugins: [
37 | nodeResolve({
38 | mainFields: ['module'],
39 | extensions: ['.js', '.jsx']
40 | }),
41 | peerDepsExternal(),
42 | babel({
43 | exclude: 'node_modules/**',
44 | runtimeHelpers: true
45 | }),
46 | localResolve(),
47 | commonjs({
48 | include: 'node_modules/**'
49 | }),
50 | // filesize(),
51 | // terser(),
52 | postcss(),
53 | replace({
54 | 'process.env.NODE_ENV': JSON.stringify('production')
55 | })
56 | ],
57 | external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies))
58 | };
59 |
60 | export default config;
61 |
--------------------------------------------------------------------------------
/src/components/CustomTimePicker.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 | import momentJalaali from 'moment-jalaali';
4 | import TimePicker from './TimePicker';
5 | import { persianNumber } from '../utils/persian';
6 |
7 | const disabledMinutes = () => {
8 | return [...Array(60)].map((v, i) => i).filter(v => v % 5 !== 0);
9 | };
10 |
11 | export default class MyTimePicker extends Component {
12 | static propTypes = {
13 | momentValue: PropTypes.object,
14 | setMomentValue: PropTypes.func,
15 | isGregorian: PropTypes.bool
16 | };
17 |
18 | static defaultProps = {
19 | momentValue: momentJalaali()
20 | };
21 |
22 | handleChange(value) {
23 | const { momentValue, min } = this.props;
24 | let newValue;
25 |
26 | if (momentValue) {
27 | newValue = momentValue.clone();
28 | } else if (min && min.isAfter(momentJalaali())) {
29 | newValue = min.clone();
30 | } else {
31 | newValue = momentJalaali(value);
32 | }
33 |
34 | newValue.hour(value ? value.hour() : null);
35 | newValue.minute(value ? value.minute() : null);
36 |
37 | this.props.setMomentValue(newValue);
38 | }
39 |
40 | render() {
41 | const { momentValue, isGregorian, outsideClickIgnoreClass } = this.props;
42 |
43 | return (
44 | persianNumber(value)}
56 | hideDisabledOptions
57 | />
58 | );
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/components/Day.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 | import classnames from 'classnames';
4 | import { persianNumber } from '../utils/persian';
5 |
6 | export default class Day extends Component {
7 | static propTypes = {
8 | day: PropTypes.object.isRequired,
9 | isCurrentMonth: PropTypes.bool,
10 | disabled: PropTypes.bool,
11 | selected: PropTypes.bool,
12 | onClick: PropTypes.func,
13 | isGregorian: PropTypes.bool
14 | };
15 |
16 | shouldComponentUpdate(nextProps) {
17 | return (
18 | nextProps.selected !== this.props.selected ||
19 | nextProps.disabled !== this.props.disabled ||
20 | nextProps.isCurrentMonth !== this.props.isCurrentMonth
21 | );
22 | }
23 |
24 | handleClick(event) {
25 | event.preventDefault();
26 | event.stopPropagation();
27 | event.nativeEvent.stopImmediatePropagation();
28 |
29 | const { disabled, onClick, day } = this.props;
30 | if (disabled)
31 | return;
32 |
33 | if (onClick) {
34 | onClick(day);
35 | }
36 | }
37 |
38 | render() {
39 | const {
40 | day,
41 | disabled,
42 | selected,
43 | isCurrentMonth,
44 | onClick,
45 | styles,
46 | isGregorian,
47 | isToday,
48 | colors,
49 | ...rest
50 | } = this.props;
51 |
52 | const className = classnames(styles.dayWrapper, {
53 | [styles.selected]: selected,
54 | [styles.currentMonth]: isCurrentMonth,
55 | [styles.today]: isToday,
56 | [styles.disabled]: disabled
57 | });
58 |
59 | const highlightDotContainer = classnames("highLightDot-container", {
60 | [styles.disabled]: disabled
61 | });
62 |
63 | return (
64 |
65 |
68 |
69 | {colors.map((x, i) => (
70 |
71 | ))}
72 |
73 |
74 | );
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/components/DaysOfWeek.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | // Day of week names for use in date-picker heading
5 | const dayOfWeekNamesJalaali = ['ش', 'ی', 'د', 'س', 'چ', 'پ', 'ج'];
6 | const dayOfWeekNamesGregorian = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
7 |
8 | export default class DaysOfWeek extends Component {
9 | static propTypes = {
10 | styles: PropTypes.object,
11 | isGregorian: PropTypes.bool
12 | };
13 |
14 | render() {
15 | const { styles, isGregorian } = this.props;
16 |
17 | const dayOfWeekNames = isGregorian ? dayOfWeekNamesGregorian : dayOfWeekNamesJalaali;
18 |
19 | return (
20 |
21 | {dayOfWeekNames.map((name, key) => (
22 |
{name}
23 | ))}
24 |
25 | );
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/components/DaysViewHeading.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 | import { persianNumber } from '../utils/persian';
4 | import { leftArrow, rightArrow } from '../utils/assets';
5 |
6 | export default class Heading extends Component {
7 | static propTypes = {
8 | month: PropTypes.object.isRequired,
9 | isGregorian: PropTypes.bool
10 | };
11 |
12 | static contextTypes = {
13 | styles: PropTypes.object,
14 | nextMonth: PropTypes.func.isRequired,
15 | prevMonth: PropTypes.func.isRequired,
16 | setCalendarMode: PropTypes.func.isRequired
17 | };
18 |
19 | handleMonthClick(event) {
20 | const { setCalendarMode } = this.context;
21 | event.preventDefault();
22 | setCalendarMode('monthSelector');
23 | }
24 |
25 | render() {
26 | const { nextMonth, prevMonth } = this.context;
27 | const { month, styles } = this.props;
28 |
29 | return (
30 |
31 |
36 | {this.props.timePicker}
37 | {!this.props.isGregorian && (
38 |
39 |
46 |
53 |
54 | )}
55 | {this.props.isGregorian && (
56 |
57 |
64 |
71 |
72 | )}
73 |
74 | );
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/components/DefaultStyles.js:
--------------------------------------------------------------------------------
1 | export const defaultStyles = {
2 | calendarContainer: 'calendarContainer',
3 | heading: 'heading',
4 | prev: 'prev',
5 | next: 'next',
6 | title: 'title',
7 | dayWrapper: 'dayWrapper',
8 | currentMonth: 'currentMonth',
9 | daysOfWeek: 'daysOfWeek',
10 | yearsList: 'yearsList',
11 | monthsList: 'monthsList',
12 | selected: 'selected',
13 | today: 'today',
14 | dayPickerContainer: 'dayPickerContainer',
15 | disabled: 'disabled'
16 | };
17 |
--------------------------------------------------------------------------------
/src/components/MonthSelector.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 | import momentJalaali from 'moment-jalaali';
4 | import classnames from 'classnames';
5 | import MonthsViewHeading from './MonthsViewHeading';
6 |
7 | // List of months
8 | const monthsJalaali = [
9 | 'فروردین',
10 | 'اردیبهشت',
11 | 'خرداد',
12 | 'تیر',
13 | 'مرداد',
14 | 'شهریور',
15 | 'مهر',
16 | 'آبان',
17 | 'آذر',
18 | 'دی',
19 | 'بهمن',
20 | 'اسفند'
21 | ];
22 |
23 | const monthsGregorian = [
24 | 'January',
25 | 'February',
26 | 'March',
27 | 'April',
28 | 'May',
29 | 'June',
30 | 'July',
31 | 'August',
32 | 'September',
33 | 'October',
34 | 'November',
35 | 'December'
36 | ];
37 |
38 | export default class MonthSelector extends Component {
39 | static propTypes = {
40 | styles: PropTypes.object,
41 | selectedMonth: PropTypes.object.isRequired,
42 | isGregorian: PropTypes.bool,
43 | disableYearSelector: PropTypes.bool,
44 | };
45 |
46 | static contextTypes = {
47 | setCalendarMode: PropTypes.func.isRequired,
48 | setMonth: PropTypes.func.isRequired
49 | };
50 |
51 | state = {
52 | year: this.props.selectedMonth
53 | };
54 |
55 | nextYear() {
56 | this.setState({
57 | year: this.state.year.clone().add(1, 'year')
58 | });
59 | }
60 |
61 | prevYear() {
62 | this.setState({
63 | year: this.state.year.clone().subtract(1, 'year')
64 | });
65 | }
66 |
67 | handleClick(key) {
68 | const { setMonth, setCalendarMode } = this.context;
69 | const { isGregorian } = this.props;
70 | const monthYearFormat = isGregorian ? 'M-YYYY' : 'jM-jYYYY';
71 | setMonth(momentJalaali(key, monthYearFormat));
72 | setCalendarMode('days');
73 | }
74 |
75 | render() {
76 | const { year } = this.state;
77 | const { selectedMonth, styles, isGregorian, disableYearSelector } = this.props;
78 | const yearFormat = isGregorian ? 'YYYY' : 'jYYYY';
79 | const monthYearFormat = isGregorian ? 'M-YYYY' : 'jM-jYYYY';
80 | const months = isGregorian ? monthsGregorian : monthsJalaali;
81 |
82 | return (
83 |
84 |
92 |
93 | {months.map((name, key) => {
94 | const buttonFingerprint = `${key + 1}-${year.format(yearFormat)}`;
95 | const selectedMonthFingerprint = selectedMonth.format(monthYearFormat);
96 | const isCurrent = selectedMonthFingerprint === buttonFingerprint;
97 |
98 | const className = classnames(styles.monthWrapper, {
99 | [styles.selected]: isCurrent
100 | });
101 |
102 | return (
103 |
104 |
105 |
106 | );
107 | })}
108 |
109 |
110 | );
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/components/MonthsViewHeading.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 | import { persianNumber } from '../utils/persian';
4 | import { leftArrow, rightArrow } from '../utils/assets';
5 |
6 | export default class MonthsViewHeading extends Component {
7 | static propTypes = {
8 | year: PropTypes.object.isRequired,
9 | onNextYear: PropTypes.func.isRequired,
10 | onPrevYear: PropTypes.func.isRequired,
11 | isGregorian: PropTypes.bool,
12 | disableYearSelector: PropTypes.bool,
13 | };
14 |
15 | static contextTypes = {
16 | styles: PropTypes.object,
17 | type: PropTypes.number,
18 | setCalendarMode: PropTypes.func.isRequired
19 | };
20 |
21 | handleYearClick(event) {
22 | const { setCalendarMode } = this.context;
23 | event.preventDefault();
24 | setCalendarMode('yearSelector');
25 | }
26 |
27 | render() {
28 | const { year, styles, type, isGregorian, disableYearSelector } = this.props;
29 |
30 | const yearFormat = isGregorian ? 'YYYY' : 'jYYYY';
31 |
32 | return (
33 |
34 |
37 |
45 |
53 |
54 | );
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/components/TimePicker/Panel.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import momentJalaali from 'moment-jalaali';
4 | import Header from './Header';
5 | import Combobox from './Combobox';
6 |
7 | function noop() {}
8 |
9 | function generateOptions(length, disabledOptions, hideDisabledOptions) {
10 | const arr = [];
11 | for (let value = 0; value < length; value++) {
12 | if (!disabledOptions || disabledOptions.indexOf(value) < 0 || !hideDisabledOptions) {
13 | arr.push(value);
14 | }
15 | }
16 | return arr;
17 | }
18 |
19 | class Panel extends React.Component {
20 | static propTypes = {
21 | clearText: PropTypes.string,
22 | prefixCls: PropTypes.string,
23 | defaultOpenValue: PropTypes.object,
24 | value: PropTypes.object,
25 | placeholder: PropTypes.string,
26 | name: PropTypes.string,
27 | format: PropTypes.string,
28 | disabledHours: PropTypes.func,
29 | disabledMinutes: PropTypes.func,
30 | disabledSeconds: PropTypes.func,
31 | hideDisabledOptions: PropTypes.bool,
32 | onChange: PropTypes.func,
33 | onEsc: PropTypes.func,
34 | allowEmpty: PropTypes.bool,
35 | showHour: PropTypes.bool,
36 | showSecond: PropTypes.bool,
37 | onClear: PropTypes.func,
38 | showAMPM: PropTypes.bool,
39 | isGregorian: PropTypes.bool
40 | };
41 |
42 | static defaultProps = {
43 | prefixCls: 'rc-time-picker-panel',
44 | onChange: noop,
45 | onClear: noop,
46 | defaultOpenValue: momentJalaali()
47 | };
48 |
49 | constructor(props) {
50 | super(props);
51 | this.state = {
52 | value: this.props.value,
53 | selectionRange: []
54 | };
55 | }
56 |
57 | UNSAFE_componentWillReceiveProps(nextProps) {
58 | const { value } = nextProps;
59 | if (value) {
60 | this.setState({
61 | value
62 | });
63 | }
64 | }
65 |
66 | onChange = newValue => {
67 | this.setState({ value: newValue });
68 | this.props.onChange(newValue);
69 | };
70 |
71 | onClear = () => {
72 | this.props.onClear();
73 | };
74 |
75 | onCurrentSelectPanelChange = currentSelectPanel => {
76 | this.setState({ currentSelectPanel });
77 | };
78 |
79 | render() {
80 | const {
81 | isGregorian,
82 | formatter,
83 | prefixCls,
84 | className,
85 | placeholder,
86 | name,
87 | disabledHours,
88 | disabledMinutes,
89 | disabledSeconds,
90 | hideDisabledOptions,
91 | allowEmpty,
92 | showHour,
93 | showSecond,
94 | showAMPM,
95 | format,
96 | defaultOpenValue,
97 | clearText,
98 | onEsc
99 | } = this.props;
100 | const { value, currentSelectPanel } = this.state;
101 | const disabledHourOptions = disabledHours();
102 | const disabledMinuteOptions = disabledMinutes(value ? value.hour() : null);
103 | const disabledSecondOptions = disabledSeconds(
104 | value ? value.hour() : null,
105 | value ? value.minute() : null
106 | );
107 | const hourOptions = generateOptions(24, disabledHourOptions, hideDisabledOptions);
108 | const minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions);
109 | const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions);
110 |
111 | return (
112 |
113 |
133 |
152 |
153 | );
154 | }
155 | }
156 |
157 | export default Panel;
158 |
--------------------------------------------------------------------------------
/src/components/TimePicker/Select.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDom from 'react-dom';
3 | import classnames from 'classnames';
4 | import PropTypes from 'prop-types';
5 |
6 | const scrollTo = (element, to, duration) => {
7 | const requestAnimationFrame =
8 | window.requestAnimationFrame ||
9 | function requestAnimationFrameTimeout() {
10 | return setTimeout(arguments[0], 10);
11 | };
12 | // jump to target if duration zero
13 | if (duration <= 0) {
14 | element.scrollTop = to;
15 | return;
16 | }
17 | const difference = to - element.scrollTop;
18 | const perTick = (difference / duration) * 10;
19 |
20 | requestAnimationFrame(() => {
21 | element.scrollTop += perTick;
22 | if (element.scrollTop === to) return;
23 | scrollTo(element, to, duration - 10);
24 | });
25 | };
26 |
27 | class Select extends React.Component {
28 | static propTypes = {
29 | prefixCls: PropTypes.string,
30 | options: PropTypes.array,
31 | selectedIndex: PropTypes.number,
32 | type: PropTypes.string,
33 | onSelect: PropTypes.func,
34 | onMouseEnter: PropTypes.func
35 | };
36 |
37 | componentDidMount() {
38 | // jump to selected option
39 | this.scrollToSelected(0);
40 | }
41 |
42 | componentDidUpdate(prevProps) {
43 | // smooth scroll to selected option
44 | if (prevProps.selectedIndex !== this.props.selectedIndex) {
45 | this.scrollToSelected(120);
46 | }
47 | }
48 |
49 | onSelect = value => {
50 | const { onSelect, type } = this.props;
51 | this.props.onSelect(type, value);
52 | };
53 |
54 | getOptions = () => {
55 | const { options, selectedIndex, prefixCls } = this.props;
56 | return options.map((item, index) => {
57 | const cls = classnames({
58 | [`${prefixCls}-select-option-selected`]: selectedIndex === index,
59 | [`${prefixCls}-select-option-disabled`]: item.disabled
60 | });
61 | let onclick = null;
62 | if (!item.disabled) {
63 | let value = +item.value;
64 | if (Number.isNaN(value)) {
65 | value = item.value;
66 | }
67 | onclick = this.onSelect.bind(this, value);
68 | }
69 |
70 | return (
71 |
72 | {typeof item.label !== 'undefined' ? item.label : item.value}
73 |
74 | );
75 | });
76 | };
77 |
78 | scrollToSelected = duration => {
79 | // move to selected item
80 | const select = ReactDom.findDOMNode(this);
81 | const list = ReactDom.findDOMNode(this.list);
82 | let index = this.props.selectedIndex;
83 | if (index < 0) {
84 | index = 0;
85 | }
86 | const topOption = list.children[index];
87 | const to = topOption.offsetTop;
88 | scrollTo(select, to, duration);
89 | };
90 |
91 | render() {
92 | if (this.props.options.length === 0) {
93 | return null;
94 | }
95 |
96 | const { prefixCls } = this.props;
97 |
98 | return (
99 |
100 |
{
102 | this.list = inst;
103 | }}
104 | >
105 | {this.getOptions()}
106 |
107 |
108 | );
109 | }
110 | }
111 |
112 | export default Select;
113 |
--------------------------------------------------------------------------------
/src/components/TimePicker/index.js:
--------------------------------------------------------------------------------
1 | import TimePicker from './TimePicker';
2 |
3 | export default TimePicker;
4 |
--------------------------------------------------------------------------------
/src/components/TimePicker/placements.js:
--------------------------------------------------------------------------------
1 | const autoAdjustOverflow = {
2 | adjustX: 1,
3 | adjustY: 1
4 | };
5 |
6 | const targetOffset = [0, 0];
7 |
8 | const placements = {
9 | bottomLeft: {
10 | points: ['tl', 'tl'],
11 | overflow: autoAdjustOverflow,
12 | offset: [0, -3],
13 | targetOffset
14 | },
15 | bottomRight: {
16 | points: ['tr', 'tr'],
17 | overflow: autoAdjustOverflow,
18 | offset: [0, -3],
19 | targetOffset
20 | },
21 | topRight: {
22 | points: ['br', 'br'],
23 | overflow: autoAdjustOverflow,
24 | offset: [0, 3],
25 | targetOffset
26 | },
27 | topLeft: {
28 | points: ['bl', 'bl'],
29 | overflow: autoAdjustOverflow,
30 | offset: [0, 3],
31 | targetOffset
32 | }
33 | };
34 |
35 | export default placements;
36 |
--------------------------------------------------------------------------------
/src/components/YearSelector.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 | import momentJalaali from 'moment-jalaali';
4 | import classnames from 'classnames';
5 | import range from 'lodash.range';
6 | import MonthsViewHeading from './MonthsViewHeading';
7 |
8 | // List of months
9 | const yearsJalaali = range(momentJalaali(new Date()).jYear() + 100, 1300);
10 |
11 | const yearsGregorian = range(momentJalaali(new Date()).year() + 100, 1920);
12 |
13 | export default class YearSelector extends Component {
14 | constructor(props) {
15 | super(props);
16 | this.currentYearPositionRef = React.createRef();
17 | this.yearsContainerRef = React.createRef();
18 | }
19 |
20 | static propTypes = {
21 | styles: PropTypes.object,
22 | selectedYear: PropTypes.object.isRequired,
23 | selectedMonth: PropTypes.object.isRequired,
24 | isGregorian: PropTypes.bool
25 | };
26 |
27 | static contextTypes = {
28 | setCalendarMode: PropTypes.func.isRequired,
29 | setMonth: PropTypes.func.isRequired
30 | };
31 |
32 | state = {
33 | year: this.props.selectedYear,
34 | month: this.props.selectedMonth
35 | };
36 |
37 | getOffsetTop = element => {
38 | let offsetTop = 0;
39 | while (element) {
40 | console.log(element.scrollTop);
41 | offsetTop += element.offsetTop;
42 | element = element.offsetParent;
43 | }
44 | return offsetTop;
45 | };
46 |
47 | scrollToCurrentYearPositionRef = () => {
48 | const marginTop = 160;
49 | this.yearsContainerRef.current.scrollTo({
50 | top: this.getOffsetTop(this.currentYearPositionRef.current) - marginTop,
51 | behavior: 'smooth' // optional
52 | });
53 | };
54 |
55 | componentDidMount() {
56 | this.scrollToCurrentYearPositionRef();
57 | }
58 |
59 | nextYear() {
60 | this.setState({
61 | year: this.state.year.clone().add(1, 'year')
62 | });
63 | }
64 |
65 | prevYear() {
66 | this.setState({
67 | year: this.state.year.clone().subtract(1, 'year')
68 | });
69 | }
70 |
71 | handleClick(key) {
72 | const { setMonth, setCalendarMode } = this.context;
73 | const { isGregorian } = this.props;
74 | const monthYearFormat = isGregorian ? 'M-YYYY' : 'jM-jYYYY';
75 | setMonth(momentJalaali(key, monthYearFormat));
76 | setCalendarMode('days');
77 | }
78 |
79 | render() {
80 | const { year, month } = this.state;
81 | const { styles, isGregorian } = this.props;
82 | const yearFormat = isGregorian ? 'YYYY' : 'jYYYY';
83 | const monthFormat = isGregorian ? 'M' : 'jM';
84 | const years = isGregorian ? yearsGregorian : yearsJalaali;
85 |
86 | return (
87 |
88 |
95 |
96 | {years.map((yearItem, key) => {
97 | const buttonFingerprint = `${month.format(monthFormat)}-${years[key]}`;
98 | const isCurrent = Number(year.format(yearFormat)) === years[key];
99 |
100 | const isCurrentYearPosition = Number(year.format(yearFormat)) === years[key];
101 |
102 | const currentYearClass = classnames(styles.yearWrapper, {
103 | [styles.selected]: isCurrent
104 | });
105 |
106 | return (
107 |
108 |
114 |
115 | );
116 | })}
117 |
118 |
119 | );
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/src/index.dev.js:
--------------------------------------------------------------------------------
1 | import './styles/style.scss';
2 | import momentJalaali from 'moment-jalaali';
3 | import DatePicker from './components/DatePicker';
4 |
5 | momentJalaali.loadPersian({ dialect: 'persian-modern' });
6 | export { Calendar } from './components/Calendar';
7 | export default DatePicker;
8 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import './style.min.css';
2 | import momentJalaali from 'moment-jalaali';
3 | import DatePicker from './components/DatePicker';
4 |
5 | momentJalaali.loadPersian({ dialect: 'persian-modern' });
6 | export { Calendar } from './components/Calendar';
7 | export default DatePicker;
8 |
--------------------------------------------------------------------------------
/src/styles/style.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["style.scss","style.css"],"names":[],"mappings":"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","file":"style.css"}
--------------------------------------------------------------------------------
/src/utils/RangesList.js:
--------------------------------------------------------------------------------
1 | import momentJalaali from 'moment-jalaali';
2 |
3 | const MomentRange = require('moment-range');
4 |
5 | const extendedMoment = MomentRange.extendMoment(momentJalaali);
6 |
7 | export default class RangesList {
8 | constructor(ranges) {
9 | this.ranges = [];
10 |
11 | if (ranges) {
12 | ranges.forEach(item => {
13 | this.validateRangeObject(item);
14 |
15 | const range = extendedMoment.range(item.start, item.end);
16 |
17 | // include start
18 | const start = range.start.add(-1, 'days');
19 |
20 | this.ranges.push({ color: item.color, range, disabled: !!item.disabled });
21 | });
22 | }
23 | }
24 |
25 | getDayState(day) {
26 | const disabled = this.ranges.some(x => x.disabled && x.range.contains(day));
27 |
28 | const colors = this.ranges.filter(x => x.color && x.range.contains(day)).map(x => x.color);
29 |
30 | return { disabled, colors };
31 | }
32 |
33 | validateRangeObject(range) {
34 | if (!('start' in range))
35 | throw `'start' property is a required property of 'range' object.
36 | range object: ${JSON.stringify(range)}`;
37 | if (!('end' in range))
38 | throw `'end' property is a required property of 'range' object.
39 | range object: ${JSON.stringify(range)}`;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/utils/assets.js:
--------------------------------------------------------------------------------
1 | export const leftArrow = {
2 | __html:
3 | ''
4 | };
5 |
6 | export const rightArrow = {
7 | __html:
8 | ''
9 | };
10 |
11 | export const remove = {
12 | __html:
13 | ''
14 | };
15 |
--------------------------------------------------------------------------------
/src/utils/moment-helper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Get days of a month that should be shown on a month page
3 | *
4 | * @param month A moment object
5 | * @returns {Array}
6 | */
7 | export function getDaysOfMonth(month, isGregorian) {
8 | const days = [];
9 |
10 | const monthFormat = isGregorian ? 'Month' : 'jMonth';
11 | const dayOffset = isGregorian ? 0 : 1;
12 |
13 | const current = month.clone().startOf(monthFormat);
14 | const end = month.clone().endOf(monthFormat);
15 |
16 | // Set start to the first day of week in the last month
17 | current.subtract((current.day() + dayOffset) % 7, 'days');
18 |
19 | // Set end to the last day of week in the next month
20 | end.add(6 - ((end.day() + dayOffset) % 7), 'days');
21 |
22 | while (current.isBefore(end)) {
23 | days.push(current.clone());
24 | current.add(1, 'days');
25 | }
26 |
27 | return days;
28 | }
29 |
30 | export function addZero(val) {
31 | val = Number(val);
32 | if (val < 10) return `0${val}`;
33 | return val;
34 | }
35 |
36 | export function checkToday(compare) {
37 | const today = new Date();
38 | const todayString =
39 | String(today.getFullYear()) +
40 | addZero(String(today.getMonth() + 1)) +
41 | addZero(String(today.getDate()));
42 |
43 | return compare === todayString;
44 | }
45 |
--------------------------------------------------------------------------------
/src/utils/persian.js:
--------------------------------------------------------------------------------
1 | const latinToPersianMap = ['۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰'];
2 | const latinNumbers = [/1/g, /2/g, /3/g, /4/g, /5/g, /6/g, /7/g, /8/g, /9/g, /0/g];
3 |
4 | function prepareNumber(input) {
5 | let string;
6 | if (typeof input === 'number') {
7 | string = input.toString();
8 | } else if (typeof input === 'undefined') {
9 | string = '';
10 | } else {
11 | string = input;
12 | }
13 |
14 | return string;
15 | }
16 |
17 | function latinToPersian(string) {
18 | let result = string;
19 |
20 | for (let index = 0; index < 10; index++) {
21 | result = result.replace(latinNumbers[index], latinToPersianMap[index]);
22 | }
23 |
24 | return result;
25 | }
26 |
27 | export function persianNumber(input) {
28 | return latinToPersian(prepareNumber(input));
29 | }
30 |
--------------------------------------------------------------------------------
/tests/calendar.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { shallow } from 'enzyme';
3 | import Calendar from '../src';
4 | import moment from 'moment-jalaali';
5 |
6 | describe('', () => {
7 |
8 | it('should render in gregorian mode ', () => {
9 | const wrapper = shallow();
10 | wrapper.render();
11 | });
12 |
13 | it('should render in jalaali mode ', () => {
14 | const wrapper = shallow();
15 | wrapper.render();
16 | });
17 |
18 | })
--------------------------------------------------------------------------------
/tests/datepicker.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { shallow } from 'enzyme';
3 | import Datepicker from '../src';
4 | import moment from 'moment-jalaali';
5 |
6 | describe('', () => {
7 |
8 | it('should render in gregorian mode ', () => {
9 | const wrapper = shallow();
10 | wrapper.render();
11 | });
12 |
13 | it('should render in jalaali mode ', () => {
14 | const wrapper = shallow();
15 | wrapper.render();
16 | });
17 |
18 | })
--------------------------------------------------------------------------------
/tests/docs.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { shallow } from 'enzyme';
3 | import Root from '../docs/src/root';
4 |
5 | describe('', () => {
6 |
7 | it('should render docs ', () => {
8 | const wrapper = shallow();
9 | wrapper.render();
10 | });
11 |
12 | })
--------------------------------------------------------------------------------
/tests/rangelist.test.js:
--------------------------------------------------------------------------------
1 | import RangesList from '../src/utils/RangesList';
2 |
3 | function inValidStartRange() {
4 | new RangesList([{ end: new Date(1993, 12, 5) }]);
5 | }
6 |
7 | function inValidEndRange() {
8 | new RangesList([{ start: new Date(1993, 12, 5) }]);
9 | }
10 |
11 | function createMultipleRangeList() {
12 |
13 | const ranges = [
14 | {
15 | color: 'skyblue',
16 | start: new Date(1993, 12, 1),
17 | end: new Date(1993, 12, 10)
18 | },
19 | {
20 | color: 'red',
21 | disabled: true,
22 | start: new Date(1993, 12, 5),
23 | end: new Date(1993, 12, 15)
24 | }
25 | ];
26 |
27 | return new RangesList(ranges);
28 | }
29 |
30 | test('throw errors for invalid ranges', () => {
31 | expect(inValidStartRange).toThrow(/'start'/);
32 | expect(inValidEndRange).toThrow(/'end'/);
33 | });
34 |
35 | test('color ranges list items count', () => {
36 |
37 | const multipleRangeList = createMultipleRangeList();
38 |
39 | expect(multipleRangeList.ranges.filter(x => x.color).length)
40 | .toEqual(2);
41 | })
42 |
43 | test('simple highlight range', () => {
44 |
45 | const multipleRangeList = createMultipleRangeList();
46 |
47 | const skyblueDayOnly = new Date(1993, 12, 2);
48 |
49 | expect(multipleRangeList.getDayState(skyblueDayOnly))
50 | .toEqual({ disabled: false, colors: ['skyblue'] });
51 |
52 | })
53 |
54 | test('disable and highlight range', () => {
55 |
56 | const multipleRangeList = createMultipleRangeList();
57 |
58 | const redDisabledDayOnly = new Date(1993, 12, 15);
59 |
60 | expect(multipleRangeList.getDayState(redDisabledDayOnly))
61 | .toEqual({ disabled: true, colors: ['red'] });
62 |
63 | })
64 |
65 | test('highlight and disable multiple range', () => {
66 |
67 | const multipleRangeList = createMultipleRangeList();
68 |
69 | const skyblueAndRedDisabledDay = new Date(1993, 12, 10);
70 |
71 | expect(multipleRangeList.getDayState(skyblueAndRedDisabledDay))
72 | .toEqual({ disabled: true, colors: ['skyblue', 'red'] });
73 |
74 | })
--------------------------------------------------------------------------------
/tests/transform.js:
--------------------------------------------------------------------------------
1 | // custom-transformer.js
2 | 'use strict';
3 |
4 | const {transform} = require('@babel/core');
5 |
6 | module.exports = {
7 | process(src, filename) {
8 | const result = transform(src, {
9 | filename,
10 | presets: ['@babel/preset-env', '@babel/preset-react'],
11 | "plugins": [
12 | "@babel/plugin-transform-runtime",
13 | "transform-export-extensions",
14 | "@babel/plugin-proposal-class-properties",
15 | "@babel/plugin-proposal-object-rest-spread"
16 | ]
17 | });
18 |
19 | return result ? result.code : src;
20 | },
21 | };
--------------------------------------------------------------------------------
/webpack.config.dev.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | const HtmlWebpackPlugin = require('html-webpack-plugin');
4 |
5 | const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
6 | template: './docs/preview/index.html',
7 | filename: './index.html',
8 | inject: 'false'
9 | })
10 |
11 | module.exports = {
12 | entry: './docs/src/boot.js',
13 | output: {
14 | path: path.resolve(__dirname, 'docs/preview'),
15 | libraryTarget: 'umd',
16 | filename: 'demo_bundles.js',
17 | library: 'react-datepicker2'
18 | },
19 | module: {
20 | rules: [
21 | {
22 | test: /\.(jpg|png|svg)$/,
23 | loader: 'file-loader'
24 | },
25 | {
26 | test: /\.(ttf|eot|woff|woff2)$/,
27 | use: {
28 | loader: "file-loader",
29 | options: {
30 | name: "fonts/[name].[ext]",
31 | },
32 | },
33 | },
34 | {
35 | test: /\.(js|jsx)$/,
36 | use: [{
37 | loader: 'babel-loader',
38 | options: {
39 | presets: ['@babel/preset-env', '@babel/preset-react']
40 | }
41 | }],
42 | exclude: /node_modules/
43 | },
44 | {
45 | test: /\.css$/,
46 | use: ['style-loader', 'css-loader'],
47 | },
48 | {
49 | use: 'file-loader',
50 | test: /\.(woff(2)?|ttf)(\?v=\d+\.\d+\.\d+)?$/,
51 | }, {
52 | test: /\.scss$/,
53 | use: [
54 | "style-loader", // creates style nodes from JS strings
55 | "css-loader", // translates CSS into CommonJS
56 | "sass-loader" // compiles Sass to CSS, using Node Sass by default
57 | ]
58 | }]
59 | },
60 | plugins: [HtmlWebpackPluginConfig],
61 | resolve: {
62 | extensions: ['.js', '.jsx'],
63 | },
64 | devtool: 'source-map',
65 | devServer: {
66 | // host: '0.0.0.0',//type your ip address for testing on local network
67 | port: 8080
68 | }
69 | }
--------------------------------------------------------------------------------
/webpack.config.docs.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | module.exports = {
4 | entry: './docs/src/boot.js',
5 | output: {
6 | path: path.resolve(__dirname, 'docs'),
7 | libraryTarget: 'umd',
8 | filename: 'demo_bundles.js',
9 | library: 'react-datepicker2'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.(jpg|png|svg)$/,
15 | loader: 'file-loader'
16 | },
17 | {
18 | test: /\.(ttf|eot|woff|woff2)$/,
19 | use: {
20 | loader: "file-loader",
21 | options: {
22 | name: "fonts/[name].[ext]",
23 | },
24 | },
25 | },
26 | {
27 | test: /\.(js|jsx)$/,
28 | use: [{
29 | loader: 'babel-loader',
30 | options: {
31 | plugins: ['@babel/plugin-transform-runtime'],
32 | presets: ['@babel/preset-env','@babel/preset-react']
33 | }
34 | }],
35 | exclude: /node_modules/
36 | },
37 | {
38 | test: /\.css$/,
39 | use: ['style-loader', 'css-loader'],
40 | },
41 | {
42 | use: 'file-loader',
43 | test: /\.(woff(2)?|ttf)(\?v=\d+\.\d+\.\d+)?$/,
44 | },
45 | {
46 | test: /\.scss$/,
47 | use: [
48 | "style-loader", // creates style nodes from JS strings
49 | "css-loader", // translates CSS into CommonJS
50 | "sass-loader" // compiles Sass to CSS, using Node Sass by default
51 | ]
52 | }]
53 | },
54 | resolve: {
55 | extensions: ['.js', '.jsx'],
56 | },
57 | devtool: 'source-map',
58 | }
--------------------------------------------------------------------------------