├── .all-contributorsrc ├── .babelrc ├── .coveralls.yml ├── .eslintrc ├── .gitignore ├── .prettierrc ├── .travis.yml ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── LICENSE ├── README.md ├── cypress.json ├── cypress ├── fixtures │ └── example.json ├── integration │ ├── docs │ │ └── demo.spec.js │ └── examples │ │ ├── actions.spec.js │ │ ├── aliasing.spec.js │ │ ├── assertions.spec.js │ │ ├── connectors.spec.js │ │ ├── cookies.spec.js │ │ ├── cypress_api.spec.js │ │ ├── files.spec.js │ │ ├── local_storage.spec.js │ │ ├── location.spec.js │ │ ├── misc.spec.js │ │ ├── navigation.spec.js │ │ ├── network_requests.spec.js │ │ ├── querying.spec.js │ │ ├── spies_stubs_clocks.spec.js │ │ ├── traversal.spec.js │ │ ├── utilities.spec.js │ │ ├── viewport.spec.js │ │ ├── waiting.spec.js │ │ └── window.spec.js ├── plugins │ └── index.js └── support │ ├── commands.js │ └── index.js ├── dist ├── es │ └── index.js ├── types │ └── index.d.ts └── umd │ └── index.js ├── docs ├── 5ab35a4f6a5cd08716e051e558e1adb8.jpg ├── 9eb4201acbd6df6f84ac8959af82a81c.jpg ├── css │ ├── breakpoint.scss │ ├── examples.scss │ ├── hero.scss │ ├── higlight.scss │ ├── reset.scss │ ├── style.css │ ├── style.min.css │ └── style.scss ├── demo_bundles.js ├── demo_bundles.js.map ├── fonts │ ├── Vazir-WOL.eot │ ├── Vazir-WOL.ttf │ ├── Vazir-WOL.woff │ ├── Vazir-WOL.woff2 │ └── opensans.woff2 ├── images │ ├── logo.png │ ├── react-datepicker2.gif │ └── ribbon.png ├── index.html ├── preview │ └── index.html └── src │ ├── boot.js │ ├── code_example_component.js │ ├── example_components.js │ ├── examples │ ├── Disabled.js │ ├── HideTodayButton.js │ ├── HighlightRange.js │ ├── JalaaliWithEnglishDigit.js │ ├── OnInputChange.js │ ├── Placeholder.js │ ├── ReactHook.js │ ├── RemoveDate.js │ ├── SetTodayOnBlur.js │ ├── ToggleButton.js │ ├── calendarPicker.js │ ├── default.js │ ├── disabledRange.js │ ├── disabledTimepicker.js │ ├── jalaali.js │ ├── limitWithMinMax.js │ └── switchIsGregorian.js │ ├── hero_example.js │ ├── images │ └── hero_background.jpg │ ├── root.js │ └── styles │ ├── demo.scss │ └── font.scss ├── jest.config.js ├── jest ├── haste-map-90c8bedf58fb8c35e1aefe5ab7033aea-4f4b57051d0e7857d69440bd7aadde10 ├── jest-transform-cache-90c8bedf58fb8c35e1aefe5ab7033aea-9336f95f429d02e8e8ee9e032bb56429 │ ├── 14 │ │ └── CustomTimePicker_14117f5d092366cbc2c7eadcb7377fb4 │ ├── 29 │ │ └── Header_290bc82b3be0d3467ee948c9d61892dd │ ├── 34 │ │ └── example_components_34e6ed01cb038530136fcd84844f2ff8 │ ├── 41 │ │ └── default_418edb7731b427a46ddba55a07167878 │ ├── 49 │ │ ├── Calendar_49d9a353a3e252eadb8250a221ac1a7a │ │ └── switchIsGregorian_495500e11c8cca1ba1ce59fc770a3e05 │ ├── 51 │ │ └── Day_5182605b04bd37866f3234f5ca84d7f3 │ ├── 58 │ │ └── TimePicker_581723ea047cbcd17eecd4cf77cf85d9 │ ├── 59 │ │ └── index_5981c889a216c53cc86fdae2ae981729 │ ├── 61 │ │ └── docs.test_61f9d26e853386fc294e8a5c8d77a3c3 │ ├── 62 │ │ └── Select_627c6e53acecefafcd63418d56ca42df │ ├── 70 │ │ └── jalaali_709d93190483ed494bc3a3af68b6268a │ ├── 89 │ │ ├── disabledTimepicker_8962d3441b5e0a01883ceb7e3b9ad50d │ │ └── persian_895255b495935fcd3aa50f83a09e2863 │ ├── 04 │ │ └── DefaultStyles_0426067cf78702fde267b48a1613750d │ ├── 0e │ │ └── assets_0e4d24d48a799d0f1638d9d4018b0e11 │ ├── 1d │ │ └── MonthSelector_1dff901c2703b1aed54aa5ab54f8d374 │ ├── 4a │ │ └── DaysViewHeading_4a31fdfca946455d15f3c6be6686cd56 │ ├── 4c │ │ └── DaysOfWeek_4c58b3e516dd84657aca209197ad452e │ ├── 7f │ │ └── moment-helper_7f2978e6b727b56ebb4572eebd368230 │ ├── 9c │ │ └── datepicker.test_9c5bb204d927362a228722f991550509 │ ├── a7 │ │ └── placements_a77283b7d59c4471ee5f7b14d73a9fb2 │ ├── ac │ │ └── index_ac2248ecf7f754a50f8bb12822c1467b │ ├── b5 │ │ └── root_b546b2f97678118f63eb1c3cbce2291c │ ├── c0 │ │ └── hero_example_c0f2f10709e849ab6432ab051de0cc53 │ ├── cf │ │ └── calendar.test_cfd9b7a807944f300d61d17275cb9371 │ ├── da │ │ └── MonthsViewHeading_da0c0bc74baf5c00afde92b492693eb5 │ ├── de │ │ └── code_example_component_de9f83a86d1645ecf3131aa8395e37fa │ ├── e8 │ │ └── DatePicker_e8e0f8538a6a319d21fff3582963f5fb │ ├── f2 │ │ └── Panel_f2e89774820a8f238e9c2d6f2ec857d4 │ └── f5 │ │ └── Combobox_f55b787b6058f771e22dafbc1a5fb026 └── perf-cache-90c8bedf58fb8c35e1aefe5ab7033aea-f2a6b052d4b7af6a6d27c76b07ddacc5 ├── jsconfig.json ├── mocks └── fileMock.js ├── package.json ├── rollup.config.js ├── src ├── components │ ├── Calendar.js │ ├── CustomTimePicker.js │ ├── DatePicker.js │ ├── Day.js │ ├── DaysOfWeek.js │ ├── DaysViewHeading.js │ ├── DefaultStyles.js │ ├── MonthSelector.js │ ├── MonthsViewHeading.js │ ├── TimePicker │ │ ├── Combobox.js │ │ ├── Header.js │ │ ├── Panel.js │ │ ├── Select.js │ │ ├── TimePicker.js │ │ ├── index.js │ │ └── placements.js │ └── YearSelector.js ├── index.dev.js ├── index.js ├── style.min.css ├── style.min.css.map ├── styles │ ├── style.css │ ├── style.css.map │ └── style.scss ├── theme │ └── DefaultTheme.js └── utils │ ├── RangesList.js │ ├── assets.js │ ├── moment-helper.js │ └── persian.js ├── tests ├── calendar.test.js ├── datepicker.test.js ├── docs.test.js ├── rangelist.test.js └── transform.js ├── webpack.config.dev.js └── webpack.config.docs.js /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | "login": "mberneti", 10 | "name": "mohammadreza berneti", 11 | "avatar_url": "https://avatars3.githubusercontent.com/u/3443365?v=4", 12 | "profile": "http://berneti.ir", 13 | "contributions": [ 14 | "code", 15 | "ideas", 16 | "doc", 17 | "bug", 18 | "design", 19 | "example", 20 | "maintenance", 21 | "platform", 22 | "question", 23 | "review", 24 | "projectManagement" 25 | ] 26 | }, 27 | { 28 | "login": "mohebifar", 29 | "name": "Mohamad Mohebifar", 30 | "avatar_url": "https://avatars1.githubusercontent.com/u/6104558?v=4", 31 | "profile": "https://github.com/mohebifar", 32 | "contributions": [ 33 | "ideas", 34 | "doc", 35 | "code" 36 | ] 37 | }, 38 | { 39 | "login": "aliazizi", 40 | "name": "Ali Akbar Azizi", 41 | "avatar_url": "https://avatars1.githubusercontent.com/u/8492767?v=4", 42 | "profile": "https://github.com/aliazizi", 43 | "contributions": [ 44 | "maintenance", 45 | "platform", 46 | "code", 47 | "bug", 48 | "question" 49 | ] 50 | }, 51 | { 52 | "login": "alinjf", 53 | "name": "Ali Najafi", 54 | "avatar_url": "https://avatars3.githubusercontent.com/u/15678289?v=4", 55 | "profile": "https://github.com/alinjf", 56 | "contributions": [ 57 | "maintenance", 58 | "code" 59 | ] 60 | }, 61 | { 62 | "login": "dadwic", 63 | "name": "Mehrdad Mehralian", 64 | "avatar_url": "https://avatars0.githubusercontent.com/u/13819774?v=4", 65 | "profile": "http://mehralian.org", 66 | "contributions": [ 67 | "code", 68 | "design" 69 | ] 70 | }, 71 | { 72 | "login": "shayegh", 73 | "name": "mojtaba Shayegh", 74 | "avatar_url": "https://avatars1.githubusercontent.com/u/10929932?v=4", 75 | "profile": "https://github.com/shayegh", 76 | "contributions": [ 77 | "bug", 78 | "code" 79 | ] 80 | }, 81 | { 82 | "login": "moryrasb", 83 | "name": "mory rezaee", 84 | "avatar_url": "https://avatars1.githubusercontent.com/u/15072825?v=4", 85 | "profile": "https://github.com/moryrasb", 86 | "contributions": [ 87 | "maintenance", 88 | "code" 89 | ] 90 | }, 91 | { 92 | "login": "Doomfang3", 93 | "name": "Mathieu Saubin", 94 | "avatar_url": "https://avatars1.githubusercontent.com/u/37439688?v=4", 95 | "profile": "https://github.com/Doomfang3", 96 | "contributions": [ 97 | "maintenance", 98 | "code" 99 | ] 100 | }, 101 | { 102 | "login": "alireza-molaee", 103 | "name": "alireza molaee", 104 | "avatar_url": "https://avatars0.githubusercontent.com/u/15848730?v=4", 105 | "profile": "https://github.com/alireza-molaee", 106 | "contributions": [ 107 | "maintenance", 108 | "code" 109 | ] 110 | }, 111 | { 112 | "login": "alimzadeh", 113 | "name": "Ali MoghaddasZadeh", 114 | "avatar_url": "https://avatars3.githubusercontent.com/u/11006666?v=4", 115 | "profile": "https://github.com/alimzadeh", 116 | "contributions": [ 117 | "bug" 118 | ] 119 | }, 120 | { 121 | "login": "azadkuh", 122 | "name": "amir zamani", 123 | "avatar_url": "https://avatars0.githubusercontent.com/u/6501462?v=4", 124 | "profile": "http://ir.linkedin.com/in/amirzamani", 125 | "contributions": [ 126 | "maintenance", 127 | "platform", 128 | "code", 129 | "bug", 130 | "question" 131 | ] 132 | }, 133 | { 134 | "login": "afsanefda", 135 | "name": "Afsane Fadaei", 136 | "avatar_url": "https://avatars0.githubusercontent.com/u/37764909?v=4", 137 | "profile": "http://afsanefadaei.ir", 138 | "contributions": [ 139 | "maintenance", 140 | "question" 141 | ] 142 | }, 143 | { 144 | "login": "whossein", 145 | "name": "Hossein Aghatabar", 146 | "avatar_url": "https://avatars2.githubusercontent.com/u/17334987?v=4", 147 | "profile": "http://learnyab.com", 148 | "contributions": [ 149 | "bug" 150 | ] 151 | }, 152 | { 153 | "login": "mahdisalehian", 154 | "name": "Mahdi ", 155 | "avatar_url": "https://avatars1.githubusercontent.com/u/8876390?v=4", 156 | "profile": "http://salehian.me/", 157 | "contributions": [ 158 | "code" 159 | ] 160 | }, 161 | { 162 | "login": "hoseinBL", 163 | "name": "Hosein BehkamaL", 164 | "avatar_url": "https://avatars1.githubusercontent.com/u/3403583?v=4", 165 | "profile": "https://github.com/hoseinBL", 166 | "contributions": [ 167 | "code" 168 | ] 169 | } 170 | ], 171 | "contributorsPerLine": 7, 172 | "projectName": "react-datepicker2", 173 | "projectOwner": "mberneti", 174 | "repoType": "github", 175 | "repoHost": "https://github.com", 176 | "skipCi": true 177 | } 178 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "modules": false 7 | } 8 | ], 9 | "@babel/preset-react" 10 | ], 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 | } -------------------------------------------------------------------------------- /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service-name: travis-ci 2 | repo_token: 2HqkR8C3Nr8mQyBOGS0PGBDPwUCzEeSWT -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "airbnb", 4 | "plugin:prettier/recommended", 5 | "prettier/react" 6 | ], 7 | "env": { 8 | "browser": true, 9 | "node": true, 10 | "es6": true, 11 | "jest": true, 12 | "jquery": true 13 | }, 14 | "parser": "babel-eslint", 15 | "parserOptions": { 16 | "ecmaVersion": 6, 17 | "sourceType": "module", 18 | "ecmaFeatures": { 19 | "arrowFunctions": true, 20 | "binaryLiterals": true, 21 | "blockBindings": true, 22 | "classes": true, 23 | "defaultParams": true, 24 | "destructuring": true, 25 | "forOf": true, 26 | "generators": true, 27 | "modules": true, 28 | "objectLiteralComputedProperties": true, 29 | "objectLiteralDuplicateProperties": true, 30 | "objectLiteralShorthandMethods": true, 31 | "objectLiteralShorthandProperties": true, 32 | "octalLiterals": true, 33 | "regexUFlag": true, 34 | "regexYFlag": true, 35 | "spread": true, 36 | "superInFunctions": true, 37 | "templateStrings": true, 38 | "unicodeCodePointEscapes": true, 39 | "globalReturn": true, 40 | "jsx": true, 41 | "experimentalObjectRestSpread": true 42 | } 43 | }, 44 | "plugins": [ 45 | "react" 46 | ], 47 | "rules": { 48 | "strict": 0 49 | } 50 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Node template 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | 13 | # Directory for instrumented libs generated by jscoverage/JSCover 14 | lib-cov 15 | 16 | # Coverage directory used by tools like istanbul 17 | coverage 18 | 19 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 20 | .grunt 21 | 22 | # node-waf configuration 23 | .lock-wscript 24 | 25 | # Compiled binary addons (http://nodejs.org/api/addons.html) 26 | build/Release 27 | 28 | # Dependency directories 29 | node_modules 30 | 31 | # Optional npm cache directory 32 | .npm 33 | 34 | # Optional REPL history 35 | .node_repl_history 36 | 37 | #ide files 38 | /.idea 39 | 40 | # OS X 41 | .DS_Store 42 | 43 | yarn.lock 44 | 45 | package-lock.json 46 | #intellij Project File 47 | *.iml 48 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "singleQuote": true 4 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | before_install: 4 | - 'npm i -g public-ip' 5 | - 'npm i -g npm' 6 | node_js: 7 | - 'v12' 8 | install: 9 | - npm install 10 | script: 11 | - npm run test 12 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "chrome", 9 | "request": "launch", 10 | "name": "Launch Chrome", 11 | "url": "http://localhost:8080", 12 | "webRoot": "${workspaceFolder}" 13 | }, 14 | { 15 | "name": ".NET Core Launch (web)", 16 | "type": "coreclr", 17 | "request": "launch", 18 | "preLaunchTask": "build", 19 | // If you have changed target frameworks, make sure to update the program path. 20 | "program": "${workspaceFolder}/BCore/bin/Debug/netcoreapp2.0/BCore.dll", 21 | "args": [], 22 | "cwd": "${workspaceFolder}/BCore", 23 | "stopAtEntry": false, 24 | "internalConsoleOptions": "openOnSessionStart", 25 | "launchBrowser": { 26 | "enabled": true, 27 | "args": "${auto-detect-url}", 28 | "windows": { 29 | "command": "cmd.exe", 30 | "args": "/C start ${auto-detect-url}" 31 | }, 32 | "osx": { 33 | "command": "open" 34 | }, 35 | "linux": { 36 | "command": "xdg-open" 37 | } 38 | }, 39 | "env": { 40 | "ASPNETCORE_ENVIRONMENT": "Development" 41 | }, 42 | "sourceFileMap": { 43 | "/Views": "${workspaceFolder}/Views" 44 | } 45 | }, 46 | { 47 | "name": ".NET Core Attach", 48 | "type": "coreclr", 49 | "request": "attach", 50 | "processId": "${command:pickProcess}" 51 | }, 52 | ] 53 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.enable": false, 3 | "files.exclude": { 4 | ".vscode/": true, 5 | "**/admin/css/app.css": true, 6 | "**/appLogin-light.css": true, 7 | "**/appLogin.css": true, 8 | "**/assets/stylesheets/": true, 9 | "**/bin/": true, 10 | "**/bootstrap-editable.css": true, 11 | "**/bootstrap.css": true, 12 | "**/bower_components/": true, 13 | "**/bs-editable.css": true, 14 | "**/css/components/": true, 15 | "**/dark-components.css": true, 16 | "**/docs/assets/": true, 17 | "**/font-icons.css": true, 18 | "**/magnific-popup.css": true, 19 | "**/node_modules/": true, 20 | "**/pricing-table.css": true, 21 | "**/responsive.css": true, 22 | "**/swagger2/swagger-ui.css": true, 23 | "**/sweetalert.css": true, 24 | "**/swiper.css": true, 25 | "**/wwwroot/demos/": true, 26 | "coverage/": true 27 | } 28 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/BCore/BCore.csproj" 11 | ], 12 | "problemMatcher": "$msCompile" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 mohammadreza berneti 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /cypress/fixtures/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Using fixtures to represent data", 3 | "email": "hello@cypress.io", 4 | "body": "Fixtures are a great way to mock data for responses to routes" 5 | } -------------------------------------------------------------------------------- /cypress/integration/docs/demo.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Demo', () => { 4 | beforeEach(() => { 5 | cy.visit('http://localhost:8080') 6 | }) 7 | 8 | // https://on.cypress.io/interacting-with-elements 9 | 10 | // it('.focus() - focus on a DOM element', () => { 11 | // // https://on.cypress.io/focus 12 | // cy.get('.action-focus').focus() 13 | // .should('have.class', 'focus') 14 | // .prev().should('have.attr', 'style', 'color: orange;') 15 | // }) 16 | 17 | // it('.blur() - blur off a DOM element', () => { 18 | // // https://on.cypress.io/blur 19 | // cy.get('.action-blur').type('About to blur').blur() 20 | // .should('have.class', 'error') 21 | // .prev().should('have.attr', 'style', 'color: red;') 22 | // }) 23 | 24 | // it('.clear() - clears an input or textarea element', () => { 25 | // // https://on.cypress.io/clear 26 | // cy.get('.action-clear').type('Clear this text') 27 | // .should('have.value', 'Clear this text') 28 | // .clear() 29 | // .should('have.value', '') 30 | // }) 31 | }); 32 | -------------------------------------------------------------------------------- /cypress/integration/examples/aliasing.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Aliasing', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/aliasing') 6 | }) 7 | 8 | it('.as() - alias a DOM element for later use', () => { 9 | // https://on.cypress.io/as 10 | 11 | // Alias a DOM element for use later 12 | // We don't have to traverse to the element 13 | // later in our code, we reference it with @ 14 | 15 | cy.get('.as-table').find('tbody>tr') 16 | .first().find('td').first() 17 | .find('button').as('firstBtn') 18 | 19 | // when we reference the alias, we place an 20 | // @ in front of its name 21 | cy.get('@firstBtn').click() 22 | 23 | cy.get('@firstBtn') 24 | .should('have.class', 'btn-success') 25 | .and('contain', 'Changed') 26 | }) 27 | 28 | it('.as() - alias a route for later use', () => { 29 | // Alias the route to wait for its response 30 | cy.server() 31 | cy.route('GET', 'comments/*').as('getComment') 32 | 33 | // we have code that gets a comment when 34 | // the button is clicked in scripts.js 35 | cy.get('.network-btn').click() 36 | 37 | // https://on.cypress.io/wait 38 | cy.wait('@getComment').its('status').should('eq', 200) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /cypress/integration/examples/connectors.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Connectors', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/connectors') 6 | }) 7 | 8 | it('.each() - iterate over an array of elements', () => { 9 | // https://on.cypress.io/each 10 | cy.get('.connectors-each-ul>li') 11 | .each(($el, index, $list) => { 12 | console.log($el, index, $list) 13 | }) 14 | }) 15 | 16 | it('.its() - get properties on the current subject', () => { 17 | // https://on.cypress.io/its 18 | cy.get('.connectors-its-ul>li') 19 | // calls the 'length' property yielding that value 20 | .its('length') 21 | .should('be.gt', 2) 22 | }) 23 | 24 | it('.invoke() - invoke a function on the current subject', () => { 25 | // our div is hidden in our script.js 26 | // $('.connectors-div').hide() 27 | 28 | // https://on.cypress.io/invoke 29 | cy.get('.connectors-div').should('be.hidden') 30 | // call the jquery method 'show' on the 'div.container' 31 | .invoke('show') 32 | .should('be.visible') 33 | }) 34 | 35 | it('.spread() - spread an array as individual args to callback function', () => { 36 | // https://on.cypress.io/spread 37 | const arr = ['foo', 'bar', 'baz'] 38 | 39 | cy.wrap(arr).spread((foo, bar, baz) => { 40 | expect(foo).to.eq('foo') 41 | expect(bar).to.eq('bar') 42 | expect(baz).to.eq('baz') 43 | }) 44 | }) 45 | 46 | describe('.then()', () => { 47 | it('invokes a callback function with the current subject', () => { 48 | // https://on.cypress.io/then 49 | cy.get('.connectors-list > li') 50 | .then(($lis) => { 51 | expect($lis, '3 items').to.have.length(3) 52 | expect($lis.eq(0), 'first item').to.contain('Walk the dog') 53 | expect($lis.eq(1), 'second item').to.contain('Feed the cat') 54 | expect($lis.eq(2), 'third item').to.contain('Write JavaScript') 55 | }) 56 | }) 57 | 58 | it('yields the returned value to the next command', () => { 59 | cy.wrap(1) 60 | .then((num) => { 61 | expect(num).to.equal(1) 62 | 63 | return 2 64 | }) 65 | .then((num) => { 66 | expect(num).to.equal(2) 67 | }) 68 | }) 69 | 70 | it('yields the original subject without return', () => { 71 | cy.wrap(1) 72 | .then((num) => { 73 | expect(num).to.equal(1) 74 | // note that nothing is returned from this callback 75 | }) 76 | .then((num) => { 77 | // this callback receives the original unchanged value 1 78 | expect(num).to.equal(1) 79 | }) 80 | }) 81 | 82 | it('yields the value yielded by the last Cypress command inside', () => { 83 | cy.wrap(1) 84 | .then((num) => { 85 | expect(num).to.equal(1) 86 | // note how we run a Cypress command 87 | // the result yielded by this Cypress command 88 | // will be passed to the second ".then" 89 | cy.wrap(2) 90 | }) 91 | .then((num) => { 92 | // this callback receives the value yielded by "cy.wrap(2)" 93 | expect(num).to.equal(2) 94 | }) 95 | }) 96 | }) 97 | }) 98 | -------------------------------------------------------------------------------- /cypress/integration/examples/cookies.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Cookies', () => { 4 | beforeEach(() => { 5 | Cypress.Cookies.debug(true) 6 | 7 | cy.visit('https://example.cypress.io/commands/cookies') 8 | 9 | // clear cookies again after visiting to remove 10 | // any 3rd party cookies picked up such as cloudflare 11 | cy.clearCookies() 12 | }) 13 | 14 | it('cy.getCookie() - get a browser cookie', () => { 15 | // https://on.cypress.io/getcookie 16 | cy.get('#getCookie .set-a-cookie').click() 17 | 18 | // cy.getCookie() yields a cookie object 19 | cy.getCookie('token').should('have.property', 'value', '123ABC') 20 | }) 21 | 22 | it('cy.getCookies() - get browser cookies', () => { 23 | // https://on.cypress.io/getcookies 24 | cy.getCookies().should('be.empty') 25 | 26 | cy.get('#getCookies .set-a-cookie').click() 27 | 28 | // cy.getCookies() yields an array of cookies 29 | cy.getCookies().should('have.length', 1).should((cookies) => { 30 | // each cookie has these properties 31 | expect(cookies[0]).to.have.property('name', 'token') 32 | expect(cookies[0]).to.have.property('value', '123ABC') 33 | expect(cookies[0]).to.have.property('httpOnly', false) 34 | expect(cookies[0]).to.have.property('secure', false) 35 | expect(cookies[0]).to.have.property('domain') 36 | expect(cookies[0]).to.have.property('path') 37 | }) 38 | }) 39 | 40 | it('cy.setCookie() - set a browser cookie', () => { 41 | // https://on.cypress.io/setcookie 42 | cy.getCookies().should('be.empty') 43 | 44 | cy.setCookie('foo', 'bar') 45 | 46 | // cy.getCookie() yields a cookie object 47 | cy.getCookie('foo').should('have.property', 'value', 'bar') 48 | }) 49 | 50 | it('cy.clearCookie() - clear a browser cookie', () => { 51 | // https://on.cypress.io/clearcookie 52 | cy.getCookie('token').should('be.null') 53 | 54 | cy.get('#clearCookie .set-a-cookie').click() 55 | 56 | cy.getCookie('token').should('have.property', 'value', '123ABC') 57 | 58 | // cy.clearCookies() yields null 59 | cy.clearCookie('token').should('be.null') 60 | 61 | cy.getCookie('token').should('be.null') 62 | }) 63 | 64 | it('cy.clearCookies() - clear browser cookies', () => { 65 | // https://on.cypress.io/clearcookies 66 | cy.getCookies().should('be.empty') 67 | 68 | cy.get('#clearCookies .set-a-cookie').click() 69 | 70 | cy.getCookies().should('have.length', 1) 71 | 72 | // cy.clearCookies() yields null 73 | cy.clearCookies() 74 | 75 | cy.getCookies().should('be.empty') 76 | }) 77 | }) 78 | -------------------------------------------------------------------------------- /cypress/integration/examples/files.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | /// JSON fixture file can be loaded directly using 4 | // the built-in JavaScript bundler 5 | // @ts-ignore 6 | const requiredExample = require('../../fixtures/example') 7 | 8 | context('Files', () => { 9 | beforeEach(() => { 10 | cy.visit('https://example.cypress.io/commands/files') 11 | }) 12 | 13 | beforeEach(() => { 14 | // load example.json fixture file and store 15 | // in the test context object 16 | cy.fixture('example.json').as('example') 17 | }) 18 | 19 | it('cy.fixture() - load a fixture', () => { 20 | // https://on.cypress.io/fixture 21 | 22 | // Instead of writing a response inline you can 23 | // use a fixture file's content. 24 | 25 | cy.server() 26 | cy.fixture('example.json').as('comment') 27 | // when application makes an Ajax request matching "GET comments/*" 28 | // Cypress will intercept it and reply with object 29 | // from the "comment" alias 30 | cy.route('GET', 'comments/*', '@comment').as('getComment') 31 | 32 | // we have code that gets a comment when 33 | // the button is clicked in scripts.js 34 | cy.get('.fixture-btn').click() 35 | 36 | cy.wait('@getComment').its('responseBody') 37 | .should('have.property', 'name') 38 | .and('include', 'Using fixtures to represent data') 39 | 40 | // you can also just write the fixture in the route 41 | cy.route('GET', 'comments/*', 'fixture:example.json').as('getComment') 42 | 43 | // we have code that gets a comment when 44 | // the button is clicked in scripts.js 45 | cy.get('.fixture-btn').click() 46 | 47 | cy.wait('@getComment').its('responseBody') 48 | .should('have.property', 'name') 49 | .and('include', 'Using fixtures to represent data') 50 | 51 | // or write fx to represent fixture 52 | // by default it assumes it's .json 53 | cy.route('GET', 'comments/*', 'fx:example').as('getComment') 54 | 55 | // we have code that gets a comment when 56 | // the button is clicked in scripts.js 57 | cy.get('.fixture-btn').click() 58 | 59 | cy.wait('@getComment').its('responseBody') 60 | .should('have.property', 'name') 61 | .and('include', 'Using fixtures to represent data') 62 | }) 63 | 64 | it('cy.fixture() or require - load a fixture', function () { 65 | // we are inside the "function () { ... }" 66 | // callback and can use test context object "this" 67 | // "this.example" was loaded in "beforeEach" function callback 68 | expect(this.example, 'fixture in the test context') 69 | .to.deep.equal(requiredExample) 70 | 71 | // or use "cy.wrap" and "should('deep.equal', ...)" assertion 72 | // @ts-ignore 73 | cy.wrap(this.example, 'fixture vs require') 74 | .should('deep.equal', requiredExample) 75 | }) 76 | 77 | it('cy.readFile() - read file contents', () => { 78 | // https://on.cypress.io/readfile 79 | 80 | // You can read a file and yield its contents 81 | // The filePath is relative to your project's root. 82 | cy.readFile('cypress.json').then((json) => { 83 | expect(json).to.be.an('object') 84 | }) 85 | }) 86 | 87 | it('cy.writeFile() - write to a file', () => { 88 | // https://on.cypress.io/writefile 89 | 90 | // You can write to a file 91 | 92 | // Use a response from a request to automatically 93 | // generate a fixture file for use later 94 | cy.request('https://jsonplaceholder.cypress.io/users') 95 | .then((response) => { 96 | cy.writeFile('cypress/fixtures/users.json', response.body) 97 | }) 98 | 99 | cy.fixture('users').should((users) => { 100 | expect(users[0].name).to.exist 101 | }) 102 | 103 | // JavaScript arrays and objects are stringified 104 | // and formatted into text. 105 | cy.writeFile('cypress/fixtures/profile.json', { 106 | id: 8739, 107 | name: 'Jane', 108 | email: 'jane@example.com', 109 | }) 110 | 111 | cy.fixture('profile').should((profile) => { 112 | expect(profile.name).to.eq('Jane') 113 | }) 114 | }) 115 | }) 116 | -------------------------------------------------------------------------------- /cypress/integration/examples/local_storage.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Local Storage', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/local-storage') 6 | }) 7 | // Although local storage is automatically cleared 8 | // in between tests to maintain a clean state 9 | // sometimes we need to clear the local storage manually 10 | 11 | it('cy.clearLocalStorage() - clear all data in local storage', () => { 12 | // https://on.cypress.io/clearlocalstorage 13 | cy.get('.ls-btn').click().should(() => { 14 | expect(localStorage.getItem('prop1')).to.eq('red') 15 | expect(localStorage.getItem('prop2')).to.eq('blue') 16 | expect(localStorage.getItem('prop3')).to.eq('magenta') 17 | }) 18 | 19 | // clearLocalStorage() yields the localStorage object 20 | cy.clearLocalStorage().should((ls) => { 21 | expect(ls.getItem('prop1')).to.be.null 22 | expect(ls.getItem('prop2')).to.be.null 23 | expect(ls.getItem('prop3')).to.be.null 24 | }) 25 | 26 | // Clear key matching string in Local Storage 27 | cy.get('.ls-btn').click().should(() => { 28 | expect(localStorage.getItem('prop1')).to.eq('red') 29 | expect(localStorage.getItem('prop2')).to.eq('blue') 30 | expect(localStorage.getItem('prop3')).to.eq('magenta') 31 | }) 32 | 33 | cy.clearLocalStorage('prop1').should((ls) => { 34 | expect(ls.getItem('prop1')).to.be.null 35 | expect(ls.getItem('prop2')).to.eq('blue') 36 | expect(ls.getItem('prop3')).to.eq('magenta') 37 | }) 38 | 39 | // Clear keys matching regex in Local Storage 40 | cy.get('.ls-btn').click().should(() => { 41 | expect(localStorage.getItem('prop1')).to.eq('red') 42 | expect(localStorage.getItem('prop2')).to.eq('blue') 43 | expect(localStorage.getItem('prop3')).to.eq('magenta') 44 | }) 45 | 46 | cy.clearLocalStorage(/prop1|2/).should((ls) => { 47 | expect(ls.getItem('prop1')).to.be.null 48 | expect(ls.getItem('prop2')).to.be.null 49 | expect(ls.getItem('prop3')).to.eq('magenta') 50 | }) 51 | }) 52 | }) 53 | -------------------------------------------------------------------------------- /cypress/integration/examples/location.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Location', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/location') 6 | }) 7 | 8 | it('cy.hash() - get the current URL hash', () => { 9 | // https://on.cypress.io/hash 10 | cy.hash().should('be.empty') 11 | }) 12 | 13 | it('cy.location() - get window.location', () => { 14 | // https://on.cypress.io/location 15 | cy.location().should((location) => { 16 | expect(location.hash).to.be.empty 17 | expect(location.href).to.eq('https://example.cypress.io/commands/location') 18 | expect(location.host).to.eq('example.cypress.io') 19 | expect(location.hostname).to.eq('example.cypress.io') 20 | expect(location.origin).to.eq('https://example.cypress.io') 21 | expect(location.pathname).to.eq('/commands/location') 22 | expect(location.port).to.eq('') 23 | expect(location.protocol).to.eq('https:') 24 | expect(location.search).to.be.empty 25 | }) 26 | }) 27 | 28 | it('cy.url() - get the current URL', () => { 29 | // https://on.cypress.io/url 30 | cy.url().should('eq', 'https://example.cypress.io/commands/location') 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /cypress/integration/examples/misc.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Misc', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/misc') 6 | }) 7 | 8 | it('.end() - end the command chain', () => { 9 | // https://on.cypress.io/end 10 | 11 | // cy.end is useful when you want to end a chain of commands 12 | // and force Cypress to re-query from the root element 13 | cy.get('.misc-table').within(() => { 14 | // ends the current chain and yields null 15 | cy.contains('Cheryl').click().end() 16 | 17 | // queries the entire table again 18 | cy.contains('Charles').click() 19 | }) 20 | }) 21 | 22 | it('cy.exec() - execute a system command', () => { 23 | // execute a system command. 24 | // so you can take actions necessary for 25 | // your test outside the scope of Cypress. 26 | // https://on.cypress.io/exec 27 | 28 | // we can use Cypress.platform string to 29 | // select appropriate command 30 | // https://on.cypress/io/platform 31 | cy.log(`Platform ${Cypress.platform} architecture ${Cypress.arch}`) 32 | 33 | // on CircleCI Windows build machines we have a failure to run bash shell 34 | // https://github.com/cypress-io/cypress/issues/5169 35 | // so skip some of the tests by passing flag "--env circle=true" 36 | const isCircleOnWindows = Cypress.platform === 'win32' && Cypress.env('circle') 37 | 38 | if (isCircleOnWindows) { 39 | cy.log('Skipping test on CircleCI') 40 | 41 | return 42 | } 43 | 44 | // cy.exec problem on Shippable CI 45 | // https://github.com/cypress-io/cypress/issues/6718 46 | const isShippable = Cypress.platform === 'linux' && Cypress.env('shippable') 47 | 48 | if (isShippable) { 49 | cy.log('Skipping test on ShippableCI') 50 | 51 | return 52 | } 53 | 54 | cy.exec('echo Jane Lane') 55 | .its('stdout').should('contain', 'Jane Lane') 56 | 57 | if (Cypress.platform === 'win32') { 58 | cy.exec('print cypress.json') 59 | .its('stderr').should('be.empty') 60 | } else { 61 | cy.exec('cat cypress.json') 62 | .its('stderr').should('be.empty') 63 | 64 | cy.exec('pwd') 65 | .its('code').should('eq', 0) 66 | } 67 | }) 68 | 69 | it('cy.focused() - get the DOM element that has focus', () => { 70 | // https://on.cypress.io/focused 71 | cy.get('.misc-form').find('#name').click() 72 | cy.focused().should('have.id', 'name') 73 | 74 | cy.get('.misc-form').find('#description').click() 75 | cy.focused().should('have.id', 'description') 76 | }) 77 | 78 | context('Cypress.Screenshot', function () { 79 | it('cy.screenshot() - take a screenshot', () => { 80 | // https://on.cypress.io/screenshot 81 | cy.screenshot('my-image') 82 | }) 83 | 84 | it('Cypress.Screenshot.defaults() - change default config of screenshots', function () { 85 | Cypress.Screenshot.defaults({ 86 | blackout: ['.foo'], 87 | capture: 'viewport', 88 | clip: { x: 0, y: 0, width: 200, height: 200 }, 89 | scale: false, 90 | disableTimersAndAnimations: true, 91 | screenshotOnRunFailure: true, 92 | onBeforeScreenshot () { }, 93 | onAfterScreenshot () { }, 94 | }) 95 | }) 96 | }) 97 | 98 | it('cy.wrap() - wrap an object', () => { 99 | // https://on.cypress.io/wrap 100 | cy.wrap({ foo: 'bar' }) 101 | .should('have.property', 'foo') 102 | .and('include', 'bar') 103 | }) 104 | }) 105 | -------------------------------------------------------------------------------- /cypress/integration/examples/navigation.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Navigation', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io') 6 | cy.get('.navbar-nav').contains('Commands').click() 7 | cy.get('.dropdown-menu').contains('Navigation').click() 8 | }) 9 | 10 | it('cy.go() - go back or forward in the browser\'s history', () => { 11 | // https://on.cypress.io/go 12 | 13 | cy.location('pathname').should('include', 'navigation') 14 | 15 | cy.go('back') 16 | cy.location('pathname').should('not.include', 'navigation') 17 | 18 | cy.go('forward') 19 | cy.location('pathname').should('include', 'navigation') 20 | 21 | // clicking back 22 | cy.go(-1) 23 | cy.location('pathname').should('not.include', 'navigation') 24 | 25 | // clicking forward 26 | cy.go(1) 27 | cy.location('pathname').should('include', 'navigation') 28 | }) 29 | 30 | it('cy.reload() - reload the page', () => { 31 | // https://on.cypress.io/reload 32 | cy.reload() 33 | 34 | // reload the page without using the cache 35 | cy.reload(true) 36 | }) 37 | 38 | it('cy.visit() - visit a remote url', () => { 39 | // https://on.cypress.io/visit 40 | 41 | // Visit any sub-domain of your current domain 42 | 43 | // Pass options to the visit 44 | cy.visit('https://example.cypress.io/commands/navigation', { 45 | timeout: 50000, // increase total time for the visit to resolve 46 | onBeforeLoad (contentWindow) { 47 | // contentWindow is the remote page's window object 48 | expect(typeof contentWindow === 'object').to.be.true 49 | }, 50 | onLoad (contentWindow) { 51 | // contentWindow is the remote page's window object 52 | expect(typeof contentWindow === 'object').to.be.true 53 | }, 54 | }) 55 | }) 56 | }) 57 | -------------------------------------------------------------------------------- /cypress/integration/examples/querying.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Querying', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/querying') 6 | }) 7 | 8 | // The most commonly used query is 'cy.get()', you can 9 | // think of this like the '$' in jQuery 10 | 11 | it('cy.get() - query DOM elements', () => { 12 | // https://on.cypress.io/get 13 | 14 | cy.get('#query-btn').should('contain', 'Button') 15 | 16 | cy.get('.query-btn').should('contain', 'Button') 17 | 18 | cy.get('#querying .well>button:first').should('contain', 'Button') 19 | // ↲ 20 | // Use CSS selectors just like jQuery 21 | 22 | cy.get('[data-test-id="test-example"]').should('have.class', 'example') 23 | 24 | // 'cy.get()' yields jQuery object, you can get its attribute 25 | // by invoking `.attr()` method 26 | cy.get('[data-test-id="test-example"]') 27 | .invoke('attr', 'data-test-id') 28 | .should('equal', 'test-example') 29 | 30 | // or you can get element's CSS property 31 | cy.get('[data-test-id="test-example"]') 32 | .invoke('css', 'position') 33 | .should('equal', 'static') 34 | 35 | // or use assertions directly during 'cy.get()' 36 | // https://on.cypress.io/assertions 37 | cy.get('[data-test-id="test-example"]') 38 | .should('have.attr', 'data-test-id', 'test-example') 39 | .and('have.css', 'position', 'static') 40 | }) 41 | 42 | it('cy.contains() - query DOM elements with matching content', () => { 43 | // https://on.cypress.io/contains 44 | cy.get('.query-list') 45 | .contains('bananas') 46 | .should('have.class', 'third') 47 | 48 | // we can pass a regexp to `.contains()` 49 | cy.get('.query-list') 50 | .contains(/^b\w+/) 51 | .should('have.class', 'third') 52 | 53 | cy.get('.query-list') 54 | .contains('apples') 55 | .should('have.class', 'first') 56 | 57 | // passing a selector to contains will 58 | // yield the selector containing the text 59 | cy.get('#querying') 60 | .contains('ul', 'oranges') 61 | .should('have.class', 'query-list') 62 | 63 | cy.get('.query-button') 64 | .contains('Save Form') 65 | .should('have.class', 'btn') 66 | }) 67 | 68 | it('.within() - query DOM elements within a specific element', () => { 69 | // https://on.cypress.io/within 70 | cy.get('.query-form').within(() => { 71 | cy.get('input:first').should('have.attr', 'placeholder', 'Email') 72 | cy.get('input:last').should('have.attr', 'placeholder', 'Password') 73 | }) 74 | }) 75 | 76 | it('cy.root() - query the root DOM element', () => { 77 | // https://on.cypress.io/root 78 | 79 | // By default, root is the document 80 | cy.root().should('match', 'html') 81 | 82 | cy.get('.query-ul').within(() => { 83 | // In this within, the root is now the ul DOM element 84 | cy.root().should('have.class', 'query-ul') 85 | }) 86 | }) 87 | 88 | it('best practices - selecting elements', () => { 89 | // https://on.cypress.io/best-practices#Selecting-Elements 90 | cy.get('[data-cy=best-practices-selecting-elements]').within(() => { 91 | // Worst - too generic, no context 92 | cy.get('button').click() 93 | 94 | // Bad. Coupled to styling. Highly subject to change. 95 | cy.get('.btn.btn-large').click() 96 | 97 | // Average. Coupled to the `name` attribute which has HTML semantics. 98 | cy.get('[name=submission]').click() 99 | 100 | // Better. But still coupled to styling or JS event listeners. 101 | cy.get('#main').click() 102 | 103 | // Slightly better. Uses an ID but also ensures the element 104 | // has an ARIA role attribute 105 | cy.get('#main[role=button]').click() 106 | 107 | // Much better. But still coupled to text content that may change. 108 | cy.contains('Submit').click() 109 | 110 | // Best. Insulated from all changes. 111 | cy.get('[data-cy=submit]').click() 112 | }) 113 | }) 114 | }) 115 | -------------------------------------------------------------------------------- /cypress/integration/examples/traversal.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Traversal', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/traversal') 6 | }) 7 | 8 | it('.children() - get child DOM elements', () => { 9 | // https://on.cypress.io/children 10 | cy.get('.traversal-breadcrumb') 11 | .children('.active') 12 | .should('contain', 'Data') 13 | }) 14 | 15 | it('.closest() - get closest ancestor DOM element', () => { 16 | // https://on.cypress.io/closest 17 | cy.get('.traversal-badge') 18 | .closest('ul') 19 | .should('have.class', 'list-group') 20 | }) 21 | 22 | it('.eq() - get a DOM element at a specific index', () => { 23 | // https://on.cypress.io/eq 24 | cy.get('.traversal-list>li') 25 | .eq(1).should('contain', 'siamese') 26 | }) 27 | 28 | it('.filter() - get DOM elements that match the selector', () => { 29 | // https://on.cypress.io/filter 30 | cy.get('.traversal-nav>li') 31 | .filter('.active').should('contain', 'About') 32 | }) 33 | 34 | it('.find() - get descendant DOM elements of the selector', () => { 35 | // https://on.cypress.io/find 36 | cy.get('.traversal-pagination') 37 | .find('li').find('a') 38 | .should('have.length', 7) 39 | }) 40 | 41 | it('.first() - get first DOM element', () => { 42 | // https://on.cypress.io/first 43 | cy.get('.traversal-table td') 44 | .first().should('contain', '1') 45 | }) 46 | 47 | it('.last() - get last DOM element', () => { 48 | // https://on.cypress.io/last 49 | cy.get('.traversal-buttons .btn') 50 | .last().should('contain', 'Submit') 51 | }) 52 | 53 | it('.next() - get next sibling DOM element', () => { 54 | // https://on.cypress.io/next 55 | cy.get('.traversal-ul') 56 | .contains('apples').next().should('contain', 'oranges') 57 | }) 58 | 59 | it('.nextAll() - get all next sibling DOM elements', () => { 60 | // https://on.cypress.io/nextall 61 | cy.get('.traversal-next-all') 62 | .contains('oranges') 63 | .nextAll().should('have.length', 3) 64 | }) 65 | 66 | it('.nextUntil() - get next sibling DOM elements until next el', () => { 67 | // https://on.cypress.io/nextuntil 68 | cy.get('#veggies') 69 | .nextUntil('#nuts').should('have.length', 3) 70 | }) 71 | 72 | it('.not() - remove DOM elements from set of DOM elements', () => { 73 | // https://on.cypress.io/not 74 | cy.get('.traversal-disabled .btn') 75 | .not('[disabled]').should('not.contain', 'Disabled') 76 | }) 77 | 78 | it('.parent() - get parent DOM element from DOM elements', () => { 79 | // https://on.cypress.io/parent 80 | cy.get('.traversal-mark') 81 | .parent().should('contain', 'Morbi leo risus') 82 | }) 83 | 84 | it('.parents() - get parent DOM elements from DOM elements', () => { 85 | // https://on.cypress.io/parents 86 | cy.get('.traversal-cite') 87 | .parents().should('match', 'blockquote') 88 | }) 89 | 90 | it('.parentsUntil() - get parent DOM elements from DOM elements until el', () => { 91 | // https://on.cypress.io/parentsuntil 92 | cy.get('.clothes-nav') 93 | .find('.active') 94 | .parentsUntil('.clothes-nav') 95 | .should('have.length', 2) 96 | }) 97 | 98 | it('.prev() - get previous sibling DOM element', () => { 99 | // https://on.cypress.io/prev 100 | cy.get('.birds').find('.active') 101 | .prev().should('contain', 'Lorikeets') 102 | }) 103 | 104 | it('.prevAll() - get all previous sibling DOM elements', () => { 105 | // https://on.cypress.io/prevAll 106 | cy.get('.fruits-list').find('.third') 107 | .prevAll().should('have.length', 2) 108 | }) 109 | 110 | it('.prevUntil() - get all previous sibling DOM elements until el', () => { 111 | // https://on.cypress.io/prevUntil 112 | cy.get('.foods-list').find('#nuts') 113 | .prevUntil('#veggies').should('have.length', 3) 114 | }) 115 | 116 | it('.siblings() - get all sibling DOM elements', () => { 117 | // https://on.cypress.io/siblings 118 | cy.get('.traversal-pills .active') 119 | .siblings().should('have.length', 2) 120 | }) 121 | }) 122 | -------------------------------------------------------------------------------- /cypress/integration/examples/utilities.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Utilities', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/utilities') 6 | }) 7 | 8 | it('Cypress._ - call a lodash method', () => { 9 | // https://on.cypress.io/_ 10 | cy.request('https://jsonplaceholder.cypress.io/users') 11 | .then((response) => { 12 | let ids = Cypress._.chain(response.body).map('id').take(3).value() 13 | 14 | expect(ids).to.deep.eq([1, 2, 3]) 15 | }) 16 | }) 17 | 18 | it('Cypress.$ - call a jQuery method', () => { 19 | // https://on.cypress.io/$ 20 | let $li = Cypress.$('.utility-jquery li:first') 21 | 22 | cy.wrap($li) 23 | .should('not.have.class', 'active') 24 | .click() 25 | .should('have.class', 'active') 26 | }) 27 | 28 | it('Cypress.Blob - blob utilities and base64 string conversion', () => { 29 | // https://on.cypress.io/blob 30 | cy.get('.utility-blob').then(($div) => { 31 | // https://github.com/nolanlawson/blob-util#imgSrcToDataURL 32 | // get the dataUrl string for the javascript-logo 33 | return Cypress.Blob.imgSrcToDataURL('https://example.cypress.io/assets/img/javascript-logo.png', undefined, 'anonymous') 34 | .then((dataUrl) => { 35 | // create an element and set its src to the dataUrl 36 | let img = Cypress.$('', { src: dataUrl }) 37 | 38 | // need to explicitly return cy here since we are initially returning 39 | // the Cypress.Blob.imgSrcToDataURL promise to our test 40 | // append the image 41 | $div.append(img) 42 | 43 | cy.get('.utility-blob img').click() 44 | .should('have.attr', 'src', dataUrl) 45 | }) 46 | }) 47 | }) 48 | 49 | it('Cypress.minimatch - test out glob patterns against strings', () => { 50 | // https://on.cypress.io/minimatch 51 | let matching = Cypress.minimatch('/users/1/comments', '/users/*/comments', { 52 | matchBase: true, 53 | }) 54 | 55 | expect(matching, 'matching wildcard').to.be.true 56 | 57 | matching = Cypress.minimatch('/users/1/comments/2', '/users/*/comments', { 58 | matchBase: true, 59 | }) 60 | 61 | expect(matching, 'comments').to.be.false 62 | 63 | // ** matches against all downstream path segments 64 | matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/**', { 65 | matchBase: true, 66 | }) 67 | 68 | expect(matching, 'comments').to.be.true 69 | 70 | // whereas * matches only the next path segment 71 | 72 | matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/*', { 73 | matchBase: false, 74 | }) 75 | 76 | expect(matching, 'comments').to.be.false 77 | }) 78 | 79 | it('Cypress.moment() - format or parse dates using a moment method', () => { 80 | // https://on.cypress.io/moment 81 | const time = Cypress.moment('2014-04-25T19:38:53.196Z').utc().format('h:mm A') 82 | 83 | expect(time).to.be.a('string') 84 | 85 | cy.get('.utility-moment').contains('3:38 PM') 86 | .should('have.class', 'badge') 87 | 88 | // the time in the element should be between 3pm and 5pm 89 | const start = Cypress.moment('3:00 PM', 'LT') 90 | const end = Cypress.moment('5:00 PM', 'LT') 91 | 92 | cy.get('.utility-moment .badge') 93 | .should(($el) => { 94 | // parse American time like "3:38 PM" 95 | const m = Cypress.moment($el.text().trim(), 'LT') 96 | 97 | // display hours + minutes + AM|PM 98 | const f = 'h:mm A' 99 | 100 | expect(m.isBetween(start, end), 101 | `${m.format(f)} should be between ${start.format(f)} and ${end.format(f)}`).to.be.true 102 | }) 103 | }) 104 | 105 | it('Cypress.Promise - instantiate a bluebird promise', () => { 106 | // https://on.cypress.io/promise 107 | let waited = false 108 | 109 | /** 110 | * @return Bluebird 111 | */ 112 | function waitOneSecond () { 113 | // return a promise that resolves after 1 second 114 | // @ts-ignore TS2351 (new Cypress.Promise) 115 | return new Cypress.Promise((resolve, reject) => { 116 | setTimeout(() => { 117 | // set waited to true 118 | waited = true 119 | 120 | // resolve with 'foo' string 121 | resolve('foo') 122 | }, 1000) 123 | }) 124 | } 125 | 126 | cy.then(() => { 127 | // return a promise to cy.then() that 128 | // is awaited until it resolves 129 | // @ts-ignore TS7006 130 | return waitOneSecond().then((str) => { 131 | expect(str).to.eq('foo') 132 | expect(waited).to.be.true 133 | }) 134 | }) 135 | }) 136 | }) 137 | -------------------------------------------------------------------------------- /cypress/integration/examples/viewport.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Viewport', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/viewport') 6 | }) 7 | 8 | it('cy.viewport() - set the viewport size and dimension', () => { 9 | // https://on.cypress.io/viewport 10 | 11 | cy.get('#navbar').should('be.visible') 12 | cy.viewport(320, 480) 13 | 14 | // the navbar should have collapse since our screen is smaller 15 | cy.get('#navbar').should('not.be.visible') 16 | cy.get('.navbar-toggle').should('be.visible').click() 17 | cy.get('.nav').find('a').should('be.visible') 18 | 19 | // lets see what our app looks like on a super large screen 20 | cy.viewport(2999, 2999) 21 | 22 | // cy.viewport() accepts a set of preset sizes 23 | // to easily set the screen to a device's width and height 24 | 25 | // We added a cy.wait() between each viewport change so you can see 26 | // the change otherwise it is a little too fast to see :) 27 | 28 | cy.viewport('macbook-15') 29 | cy.wait(200) 30 | cy.viewport('macbook-13') 31 | cy.wait(200) 32 | cy.viewport('macbook-11') 33 | cy.wait(200) 34 | cy.viewport('ipad-2') 35 | cy.wait(200) 36 | cy.viewport('ipad-mini') 37 | cy.wait(200) 38 | cy.viewport('iphone-6+') 39 | cy.wait(200) 40 | cy.viewport('iphone-6') 41 | cy.wait(200) 42 | cy.viewport('iphone-5') 43 | cy.wait(200) 44 | cy.viewport('iphone-4') 45 | cy.wait(200) 46 | cy.viewport('iphone-3') 47 | cy.wait(200) 48 | 49 | // cy.viewport() accepts an orientation for all presets 50 | // the default orientation is 'portrait' 51 | cy.viewport('ipad-2', 'portrait') 52 | cy.wait(200) 53 | cy.viewport('iphone-4', 'landscape') 54 | cy.wait(200) 55 | 56 | // The viewport will be reset back to the default dimensions 57 | // in between tests (the default can be set in cypress.json) 58 | }) 59 | }) 60 | -------------------------------------------------------------------------------- /cypress/integration/examples/waiting.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Waiting', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/waiting') 6 | }) 7 | // BE CAREFUL of adding unnecessary wait times. 8 | // https://on.cypress.io/best-practices#Unnecessary-Waiting 9 | 10 | // https://on.cypress.io/wait 11 | it('cy.wait() - wait for a specific amount of time', () => { 12 | cy.get('.wait-input1').type('Wait 1000ms after typing') 13 | cy.wait(1000) 14 | cy.get('.wait-input2').type('Wait 1000ms after typing') 15 | cy.wait(1000) 16 | cy.get('.wait-input3').type('Wait 1000ms after typing') 17 | cy.wait(1000) 18 | }) 19 | 20 | it('cy.wait() - wait for a specific route', () => { 21 | cy.server() 22 | 23 | // Listen to GET to comments/1 24 | cy.route('GET', 'comments/*').as('getComment') 25 | 26 | // we have code that gets a comment when 27 | // the button is clicked in scripts.js 28 | cy.get('.network-btn').click() 29 | 30 | // wait for GET comments/1 31 | cy.wait('@getComment').its('status').should('eq', 200) 32 | }) 33 | }) 34 | -------------------------------------------------------------------------------- /cypress/integration/examples/window.spec.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | context('Window', () => { 4 | beforeEach(() => { 5 | cy.visit('https://example.cypress.io/commands/window') 6 | }) 7 | 8 | it('cy.window() - get the global window object', () => { 9 | // https://on.cypress.io/window 10 | cy.window().should('have.property', 'top') 11 | }) 12 | 13 | it('cy.document() - get the document object', () => { 14 | // https://on.cypress.io/document 15 | cy.document().should('have.property', 'charset').and('eq', 'UTF-8') 16 | }) 17 | 18 | it('cy.title() - get the title', () => { 19 | // https://on.cypress.io/title 20 | cy.title().should('include', 'Kitchen Sink') 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | /// 2 | // *********************************************************** 3 | // This example plugins/index.js can be used to load plugins 4 | // 5 | // You can change the location of this file or turn off loading 6 | // the plugins file with the 'pluginsFile' configuration option. 7 | // 8 | // You can read more here: 9 | // https://on.cypress.io/plugins-guide 10 | // *********************************************************** 11 | 12 | // This function is called when a project is opened or re-opened (e.g. due to 13 | // the project's config changing) 14 | 15 | /** 16 | * @type {Cypress.PluginConfig} 17 | */ 18 | module.exports = (on, config) => { 19 | // `on` is used to hook into various events Cypress emits 20 | // `config` is the resolved Cypress config 21 | } 22 | -------------------------------------------------------------------------------- /cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add("login", (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This will overwrite an existing command -- 25 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) 26 | -------------------------------------------------------------------------------- /cypress/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands' 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | -------------------------------------------------------------------------------- /dist/types/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'react-datepicker2' { 2 | import { Component, DOMAttributes, CSSProperties, ChangeEventHandler } from 'react'; 3 | import { Moment } from 'moment-jalaali'; 4 | 5 | export interface CalenderProps { 6 | min?: Moment; 7 | max?: Moment; 8 | styles?: { 9 | calendarContainer?: string; 10 | heading?: string; 11 | prev?: string; 12 | next?: string; 13 | title?: string; 14 | dayWrapper?: string; 15 | currentMonth?: string; 16 | daysOfWeek?: string; 17 | monthsList?: string; 18 | selected?: string; 19 | today?: string; 20 | dayPickerContainer?: string; 21 | }; 22 | selectedDay?: Moment; 23 | defaultMonth?: Moment; 24 | onSelect?: (date: Moment) => void; 25 | onClickOutside?: () => void; 26 | containerProps?: object; 27 | isGregorian?: boolean; 28 | calendarClass?: string; 29 | ranges?: Array<{ 30 | start: Moment; 31 | end: Moment; 32 | color?: string; 33 | disabled?: boolean; 34 | }>; 35 | value?: Moment; 36 | defaultValue?: Moment; 37 | onChange?: (date: Moment) => void; 38 | onInputChange?: (e: ChangeEventHandler) => void; 39 | onMonthChange?: (month: Moment) => void; 40 | inputFormat?: string; 41 | inputJalaaliFormat?: string; 42 | } 43 | 44 | export class Calendar extends Component { 45 | setMode: (mode: string) => void; 46 | 47 | setMonth: (month: Moment) => void; 48 | 49 | nextMonth: () => void; 50 | 51 | prevMonth: () => void; 52 | 53 | selectDay: (selectedDay: Moment) => void; 54 | } 55 | 56 | export interface DatePickerProps { 57 | value?: Moment; 58 | defaultValue?: Moment; 59 | onChange?: (date: Moment) => void; 60 | onFocus?: DOMAttributes['onFocus']; 61 | onBlur?: DOMAttributes['onBlur']; 62 | min?: Moment; 63 | max?: Moment; 64 | defaultMonth?: Moment; 65 | inputFormat?: string; 66 | inputJalaaliFormat?: string; 67 | removable?: boolean; 68 | styles?: { [key: string]: string }; 69 | calendarStyles?: CSSProperties; 70 | calendarContainerProps?: CalenderProps; 71 | isGregorian?: boolean; // jalaali or gregorian 72 | timePicker?: boolean; 73 | calendarClass?: string; 74 | datePickerClass?: string; 75 | tetherAttachment?: string; 76 | inputReadOnly?: boolean; 77 | ranges?: [Moment, Moment]; 78 | className?: string; 79 | persianDigits?: boolean; 80 | } 81 | 82 | export default class DatePicker extends Component { 83 | setOpen: (isOpen: boolean) => void; 84 | toEnglishDigits(str: string): string; 85 | toPersianDigits(str: string): string; 86 | toPersianDigits(): void; 87 | input: HTMLInputElement; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /docs/5ab35a4f6a5cd08716e051e558e1adb8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/5ab35a4f6a5cd08716e051e558e1adb8.jpg -------------------------------------------------------------------------------- /docs/9eb4201acbd6df6f84ac8959af82a81c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/9eb4201acbd6df6f84ac8959af82a81c.jpg -------------------------------------------------------------------------------- /docs/css/breakpoint.scss: -------------------------------------------------------------------------------- 1 | @mixin breakpoint($breakpoint) { 2 | @media (min-width: $breakpoint) { @content; } 3 | } 4 | -------------------------------------------------------------------------------- /docs/css/examples.scss: -------------------------------------------------------------------------------- 1 | .examples__navigation-container { 2 | display: none; 3 | 4 | @include breakpoint(640px) { 5 | width: 200px; 6 | float: left; 7 | display: block; 8 | margin: 0; 9 | margin-right: 20px; 10 | overflow: hidden; 11 | } 12 | } 13 | 14 | .examples__navigation { 15 | display: none; 16 | max-height: calc(100vh - 130px); 17 | overflow-y: scroll; 18 | 19 | @include breakpoint(640px) { 20 | top: 90px !important; 21 | width: 200px; 22 | float: left; 23 | display: block; 24 | list-style: none; 25 | margin: 0; 26 | margin-right: 20px; 27 | border: 1px solid #e4e4e4; 28 | background: #fff; 29 | border-radius: 4px; 30 | } 31 | } 32 | 33 | .examples__navigation-item { 34 | border-bottom: 1px solid #e4e4e4; 35 | 36 | &:last-child { 37 | border-bottom: none; 38 | } 39 | 40 | a { 41 | padding: 10px; 42 | color: inherit; 43 | text-decoration: none; 44 | display: block; 45 | 46 | &:hover { 47 | background: #f5f5f5; 48 | text-decoration: underline; 49 | } 50 | } 51 | } 52 | 53 | .examples { 54 | overflow: hidden; 55 | } 56 | 57 | .example { 58 | background-color: #fff; 59 | border-radius: 4px; 60 | border: 1px solid #e4e4e4; 61 | padding: 20px; 62 | margin-bottom: 20px; 63 | 64 | &__heading { 65 | color: #216ba5; 66 | font-weight: 400; 67 | font-size: 18px; 68 | border: 0; 69 | margin: 0; 70 | padding: 0; 71 | margin-bottom: 20px; 72 | } 73 | 74 | &__code { 75 | background-color: #f5f8fb; 76 | padding: 20px; 77 | margin: 0 -20px 20px; 78 | border-top: 1px solid #d8e4ef; 79 | border-bottom: 1px solid #d8e4ef; 80 | overflow-x: auto; 81 | overflow-y: hidden; 82 | 83 | @include breakpoint(768px) { 84 | border-top-right-radius: 4px; 85 | border-bottom-right-radius: 4px; 86 | border-right: 1px solid #d8e4ef; 87 | margin-bottom: 0; 88 | } 89 | 90 | code { 91 | background: none; 92 | border: 0; 93 | } 94 | } 95 | } 96 | 97 | .red-border { 98 | border-color: #f00; 99 | } 100 | 101 | .rasta-stripes { 102 | .react-datepicker__week:nth-child(3n + 1) { 103 | background-color: #215005; 104 | } 105 | .react-datepicker__week:nth-child(3n + 2) { 106 | background-color: #eea429; 107 | } 108 | .react-datepicker__week:nth-child(3n + 3) { 109 | background-color: #a82a15; 110 | } 111 | } 112 | 113 | .example-custom-input { 114 | cursor: pointer; 115 | padding: 5px 15px; 116 | border: 0; 117 | border-radius: 4px; 118 | background-color: #216ba5; 119 | font: inherit; 120 | color: #fff; 121 | } 122 | 123 | .example__timezone-selector { 124 | margin-left: 10px; 125 | } 126 | -------------------------------------------------------------------------------- /docs/css/hero.scss: -------------------------------------------------------------------------------- 1 | .hero { 2 | color: #fff; 3 | background-color: #6abcf3; 4 | 5 | &__content { 6 | @extend %container-styling; 7 | text-align: center; 8 | padding: 175px 0; 9 | } 10 | 11 | &__title { 12 | font-size: 34px; 13 | font-weight: 600; 14 | line-height: 1.2; 15 | margin: 0; 16 | padding: 0; 17 | border-bottom: 0; 18 | margin-bottom: 5px; 19 | } 20 | 21 | &__image { 22 | height: 14px; 23 | } 24 | 25 | &__example { 26 | width: 210px; 27 | margin: 0 auto; 28 | } 29 | 30 | &__crafted-by { 31 | margin-bottom: 30px; 32 | } 33 | 34 | &__crafted-by-link { 35 | color: #fff; 36 | } 37 | } 38 | 39 | .github-ribbon { 40 | position: absolute; 41 | top: 0; 42 | right: 0; 43 | border: 0; 44 | } 45 | -------------------------------------------------------------------------------- /docs/css/higlight.scss: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | color: #333; 12 | -webkit-text-size-adjust: none; 13 | } 14 | 15 | .hljs-comment, 16 | .diff .hljs-header { 17 | color: #998; 18 | font-style: italic; 19 | } 20 | 21 | .hljs-keyword, 22 | .css .rule .hljs-keyword, 23 | .hljs-winutils, 24 | .nginx .hljs-title, 25 | .hljs-subst, 26 | .hljs-request, 27 | .hljs-status { 28 | color: #333; 29 | font-weight: bold; 30 | } 31 | 32 | .hljs-number, 33 | .hljs-hexcolor, 34 | .ruby .hljs-constant { 35 | color: #008080; 36 | } 37 | 38 | .hljs-string, 39 | .hljs-tag .hljs-value, 40 | .hljs-doctag, 41 | .tex .hljs-formula { 42 | color: #d14; 43 | } 44 | 45 | .hljs-title, 46 | .hljs-id, 47 | .scss .hljs-preprocessor { 48 | color: #900; 49 | font-weight: bold; 50 | } 51 | 52 | .hljs-list .hljs-keyword, 53 | .hljs-subst { 54 | font-weight: normal; 55 | } 56 | 57 | .hljs-class .hljs-title, 58 | .hljs-type, 59 | .vhdl .hljs-literal, 60 | .tex .hljs-command { 61 | color: #458; 62 | font-weight: bold; 63 | } 64 | 65 | .hljs-tag, 66 | .hljs-tag .hljs-title, 67 | .hljs-rule .hljs-property, 68 | .django .hljs-tag .hljs-keyword { 69 | color: #000080; 70 | font-weight: normal; 71 | } 72 | 73 | .hljs-attribute, 74 | .hljs-variable, 75 | .lisp .hljs-body, 76 | .hljs-name { 77 | color: #008080; 78 | } 79 | 80 | .hljs-regexp { 81 | color: #009926; 82 | } 83 | 84 | .hljs-symbol, 85 | .ruby .hljs-symbol .hljs-string, 86 | .lisp .hljs-keyword, 87 | .clojure .hljs-keyword, 88 | .scheme .hljs-keyword, 89 | .tex .hljs-special, 90 | .hljs-prompt { 91 | color: #990073; 92 | } 93 | 94 | .hljs-built_in { 95 | color: #0086b3; 96 | } 97 | 98 | .hljs-preprocessor, 99 | .hljs-pragma, 100 | .hljs-pi, 101 | .hljs-doctype, 102 | .hljs-shebang, 103 | .hljs-cdata { 104 | color: #999; 105 | font-weight: bold; 106 | } 107 | 108 | .hljs-deletion { 109 | background: #fdd; 110 | } 111 | 112 | .hljs-addition { 113 | background: #dfd; 114 | } 115 | 116 | .diff .hljs-change { 117 | background: #0086b3; 118 | } 119 | 120 | .hljs-chunk { 121 | color: #aaa; 122 | } 123 | -------------------------------------------------------------------------------- /docs/css/reset.scss: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | div, 4 | span, 5 | applet, 6 | object, 7 | iframe, 8 | h1, 9 | h2, 10 | h3, 11 | h4, 12 | h5, 13 | h6, 14 | p, 15 | blockquote, 16 | pre, 17 | a, 18 | abbr, 19 | acronym, 20 | address, 21 | big, 22 | cite, 23 | code, 24 | del, 25 | dfn, 26 | em, 27 | img, 28 | ins, 29 | kbd, 30 | q, 31 | s, 32 | samp, 33 | small, 34 | strike, 35 | strong, 36 | sub, 37 | sup, 38 | tt, 39 | var, 40 | b, 41 | u, 42 | i, 43 | center, 44 | dl, 45 | dt, 46 | dd, 47 | ol, 48 | ul, 49 | li, 50 | fieldset, 51 | form, 52 | label, 53 | legend, 54 | table, 55 | caption, 56 | tbody, 57 | tfoot, 58 | thead, 59 | tr, 60 | th, 61 | td, 62 | article, 63 | aside, 64 | canvas, 65 | details, 66 | embed, 67 | figure, 68 | figcaption, 69 | footer, 70 | header, 71 | hgroup, 72 | menu, 73 | nav, 74 | output, 75 | ruby, 76 | section, 77 | summary, 78 | time, 79 | mark, 80 | audio, 81 | video { 82 | margin: 0; 83 | padding: 0; 84 | border: 0; 85 | font: inherit; 86 | font-size: 100%; 87 | vertical-align: baseline; 88 | } 89 | 90 | html { 91 | line-height: 1; 92 | } 93 | 94 | ol, 95 | ul { 96 | list-style: none; 97 | } 98 | 99 | table { 100 | border-collapse: collapse; 101 | border-spacing: 0; 102 | } 103 | 104 | caption, 105 | th, 106 | td { 107 | text-align: left; 108 | font-weight: normal; 109 | vertical-align: middle; 110 | } 111 | 112 | q, 113 | blockquote { 114 | quotes: none; 115 | } 116 | 117 | q:before, 118 | q:after, 119 | blockquote:before, 120 | blockquote:after { 121 | content: ""; 122 | content: none; 123 | } 124 | 125 | a img { 126 | border: none; 127 | } 128 | 129 | article, 130 | aside, 131 | details, 132 | figcaption, 133 | figure, 134 | footer, 135 | header, 136 | hgroup, 137 | menu, 138 | nav, 139 | section, 140 | summary { 141 | display: block; 142 | } 143 | -------------------------------------------------------------------------------- /docs/css/style.min.css: -------------------------------------------------------------------------------- 1 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline;}html{line-height:1;}ol,ul{list-style:none;}table{border-collapse:collapse;border-spacing:0;}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle;}q,blockquote{quotes:none;}q:before,q:after,blockquote:before,blockquote:after{content:"";content:none;}a img{border:none;}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{display:block;}.hljs{display:block;overflow-x:auto;padding:.5em;color:#333;-webkit-text-size-adjust:none;}.hljs-comment,.diff .hljs-header{color:#998;font-style:italic;}.hljs-keyword,.css .rule .hljs-keyword,.hljs-winutils,.nginx .hljs-title,.hljs-subst,.hljs-request,.hljs-status{color:#333;font-weight:bold;}.hljs-number,.hljs-hexcolor,.ruby .hljs-constant{color:#008080;}.hljs-string,.hljs-tag .hljs-value,.hljs-doctag,.tex .hljs-formula{color:#d14;}.hljs-title,.hljs-id,.scss .hljs-preprocessor{color:#900;font-weight:bold;}.hljs-list .hljs-keyword,.hljs-subst{font-weight:normal;}.hljs-class .hljs-title,.hljs-type,.vhdl .hljs-literal,.tex .hljs-command{color:#458;font-weight:bold;}.hljs-tag,.hljs-tag .hljs-title,.hljs-rule .hljs-property,.django .hljs-tag .hljs-keyword{color:#000080;font-weight:normal;}.hljs-attribute,.hljs-variable,.lisp .hljs-body,.hljs-name{color:#008080;}.hljs-regexp{color:#009926;}.hljs-symbol,.ruby .hljs-symbol .hljs-string,.lisp .hljs-keyword,.clojure .hljs-keyword,.scheme .hljs-keyword,.tex .hljs-special,.hljs-prompt{color:#990073;}.hljs-built_in{color:#0086b3;}.hljs-preprocessor,.hljs-pragma,.hljs-pi,.hljs-doctype,.hljs-shebang,.hljs-cdata{color:#999;font-weight:bold;}.hljs-deletion{background:#fdd;}.hljs-addition{background:#dfd;}.diff .hljs-change{background:#0086b3;}.hljs-chunk{color:#aaa;} 2 | .hero{color:#fff;background-color:#6abcf3;} 3 | .hero__content{height: 40vh; 4 | color: #fff;text-align:center;padding:175px 0;}.hero__title{font-size:34px;font-weight:600;line-height:1.2;margin:0;padding:0;border-bottom:0;margin-bottom:5px;}.hero__image{height:14px;}.hero__example{width:210px;margin:0 auto;}.hero__crafted-by{margin-bottom:30px;}.hero__crafted-by-link{color:#fff;}.github-ribbon{position:absolute;top:0;right:0;border:0;}.examples__navigation{display:none;}@media(min-width:640px){.examples__navigation{width:200px;float:left;display:block;list-style:none;margin:0;margin-right:20px;border:1px solid #e4e4e4;background:#fff;border-radius:4px;overflow:hidden;}}.examples__navigation-item{border-bottom:1px solid #e4e4e4;}.examples__navigation-item:last-child{border-bottom:none;}.examples__navigation-item a{padding:10px;color:inherit;text-decoration:none;display:block;}.examples__navigation-item a:hover{background:#f5f5f5;text-decoration:underline;}.examples{overflow:hidden;}.example{background-color:#fff;border-radius:4px;border:1px solid #e4e4e4;padding:20px;margin-bottom:20px;}.example__heading{color:#216ba5;font-weight:400;font-size:18px;border:0;margin:0;padding:0;margin-bottom:20px;}.example__code{background-color:#f5f8fb;padding:20px;margin:0 -20px 20px;border-top:1px solid #d8e4ef;border-bottom:1px solid #d8e4ef;overflow-x:auto;overflow-y:hidden;}@media(min-width:768px){.example__code{border-top-right-radius:4px;border-bottom-right-radius:4px;border-right:1px solid #d8e4ef;margin-bottom:0;}}.example__code code{background:none;border:0;}.red-border{border-color:#f00;}.rasta-stripes .react-datepicker__week:nth-child(3n+1){background-color:#215005;}.rasta-stripes .react-datepicker__week:nth-child(3n+2){background-color:#eea429;}.rasta-stripes .react-datepicker__week:nth-child(3n+3){background-color:#a82a15;}.example-custom-input{cursor:pointer;padding:5px 15px;border:0;border-radius:4px;background-color:#216ba5;font:inherit;color:#fff;}.example__timezone-selector{margin-left:10px;}.hero__content,.wrapper{max-width:1100px;margin:0 auto;}html,body{height:100%;background:#f5f5f5;font-family:"Open Sans",sans-serif;color:#555;font-size:14px;line-height:21px;}html input,body input{width:100%;}a{text-decoration:none;}p{margin-bottom:15px;}ul{list-style:disc;margin-left:40px;margin-bottom:15px;}h1,h2{margin-top:1em;margin-bottom:16px;font-weight:bold;line-height:1.4;}h1{padding-bottom:.3em;font-size:2.25em;line-height:1.2;border-bottom:1px solid #eee;}h2{padding-bottom:.3em;font-size:1.75em;line-height:1.225;border-bottom:1px solid #eee;}code{padding:2px 4px;border:1px solid #ccc;margin:0;font-size:85%;background-color:#e8e7e7;border-radius:3px;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;}strong{font-weight:600;}.wrapper{padding:20px;}@media(min-width:768px){.row{display:flex;}}@media(min-width:768px){.column{width:50%;}.column:first-child{margin-right:20px;}}input{font-size:13px;border-radius:4px;box-shadow:inset 0 2px 2px #e9e9e9;border:1px solid #aeaeae;line-height:16px;padding:6px 10px 5px;}input:focus{outline:none;border-color:#aeaeae;box-shadow:inset 0 2px 2px #e9e9e9,0 0 10px 0 rgba(73,107,125,.3);}.logo{display:inline;font-size:1.4em;letter-spacing:1px;} -------------------------------------------------------------------------------- /docs/css/style.scss: -------------------------------------------------------------------------------- 1 | @import "reset"; 2 | @import "higlight"; 3 | @import "breakpoint"; 4 | @import "hero"; 5 | @import "examples"; 6 | 7 | %container-styling { 8 | max-width: 1100px; 9 | margin: 0 auto; 10 | } 11 | 12 | *{ 13 | font-family: 'Open Sans','Vazir'; 14 | } 15 | 16 | html, 17 | body { 18 | height: 100%; 19 | background: #f5f5f5; 20 | font-family: 'Open Sans', 'Vazir'; 21 | color: #555; 22 | font-size: 14px; 23 | line-height: 21px; 24 | 25 | input { 26 | width: 100%; 27 | } 28 | } 29 | 30 | a { 31 | text-decoration: none; 32 | } 33 | 34 | p { 35 | margin-bottom: 15px; 36 | } 37 | 38 | ul { 39 | list-style: disc; 40 | margin-left: 40px; 41 | margin-bottom: 15px; 42 | } 43 | 44 | h1, 45 | h2 { 46 | margin-top: 1em; 47 | margin-bottom: 16px; 48 | font-weight: bold; 49 | line-height: 1.4; 50 | } 51 | 52 | h1 { 53 | padding-bottom: .3em; 54 | font-size: 2.25em; 55 | line-height: 1.2; 56 | border-bottom: 1px solid #eee; 57 | } 58 | 59 | h2 { 60 | padding-bottom: .3em; 61 | font-size: 1.75em; 62 | line-height: 1.225; 63 | border-bottom: 1px solid #eee; 64 | } 65 | 66 | code { 67 | padding: 2px 4px; 68 | border: 1px solid #ccc; 69 | margin: 0; 70 | font-size: 85%; 71 | background-color: #e8e7e7; 72 | border-radius: 3px; 73 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; 74 | } 75 | 76 | strong { 77 | font-weight: 600; 78 | } 79 | 80 | .wrapper { 81 | @extend %container-styling; 82 | padding: 20px; 83 | } 84 | 85 | .row { 86 | @include breakpoint(768px) { 87 | display: flex; 88 | } 89 | } 90 | 91 | .column { 92 | @include breakpoint(768px) { 93 | width: 50%; 94 | 95 | &:first-child { 96 | margin-right: 20px; 97 | } 98 | } 99 | } 100 | 101 | input { 102 | font-size: 13px; 103 | border-radius: 4px; 104 | box-shadow: inset 0 2px 2px #e9e9e9; 105 | border: 1px solid #aeaeae; 106 | line-height: 16px; 107 | padding: 6px 10px 5px; 108 | 109 | &:focus { 110 | outline: none; 111 | border-color: #aeaeae; 112 | box-shadow: inset 0 2px 2px #e9e9e9, 0 0 10px 0 rgba(73, 107, 125, .3); 113 | } 114 | } 115 | .logo{ 116 | display:inline; 117 | font-size:1.4em; 118 | letter-spacing:1px; 119 | } -------------------------------------------------------------------------------- /docs/fonts/Vazir-WOL.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/fonts/Vazir-WOL.eot -------------------------------------------------------------------------------- /docs/fonts/Vazir-WOL.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/fonts/Vazir-WOL.ttf -------------------------------------------------------------------------------- /docs/fonts/Vazir-WOL.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/fonts/Vazir-WOL.woff -------------------------------------------------------------------------------- /docs/fonts/Vazir-WOL.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/fonts/Vazir-WOL.woff2 -------------------------------------------------------------------------------- /docs/fonts/opensans.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/fonts/opensans.woff2 -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/images/logo.png -------------------------------------------------------------------------------- /docs/images/react-datepicker2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/images/react-datepicker2.gif -------------------------------------------------------------------------------- /docs/images/ribbon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mberneti/react-datepicker2/6c68d729c44549f6eb35f7daac8de75fc3d5d9d9/docs/images/ribbon.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | react-datepicker2 demo 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/preview/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | react-datepicker2 demo 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | -------------------------------------------------------------------------------- /docs/src/boot.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import Root from './root'; 4 | 5 | ReactDOM.render(, document.getElementById('app')) 6 | -------------------------------------------------------------------------------- /docs/src/code_example_component.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from "prop-types"; 3 | 4 | export default class CodeExampleComponent extends React.Component { 5 | 6 | static propTypes = { 7 | children: PropTypes.element, 8 | id: PropTypes.number, 9 | title: PropTypes.string 10 | }; 11 | 12 | render () { 13 | return
14 |

{this.props.title}

15 | {this.props.children} 16 |
17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/src/example_components.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import hljs from 'highlight.js'; 3 | import CodeExampleComponent from './code_example_component'; 4 | import Highlight from 'react-syntax-highlight'; 5 | 6 | import Default from './examples/default'; 7 | import Jalaali from './examples/jalaali'; 8 | import HideTodayButton from './examples/HideTodayButton'; 9 | import DisabledTimepicker from './examples/disabledTimepicker'; 10 | import SwitchIsGregorian from './examples/switchIsGregorian'; 11 | import CalendarPicker from './examples/calendarPicker'; 12 | import LimitWithMinMax from './examples/limitWithMinMax'; 13 | import DisabledRange from './examples/disabledRange'; 14 | import HighlightRange from './examples/HighlightRange'; 15 | import Disabled from './examples/Disabled'; 16 | import ReactHook from './examples/ReactHook'; 17 | import RemoveDate from './examples/RemoveDate'; 18 | import Placeholder from './examples/Placeholder'; 19 | import ToggleButton from './examples/ToggleButton'; 20 | import OnInputChange from './examples/OnInputChange'; 21 | import JalaaliWithEnglishDigit from './examples/JalaaliWithEnglishDigit'; 22 | import SetTodayOnBlur from './examples/SetTodayOnBlur'; 23 | 24 | import { StickyContainer, Sticky } from 'react-sticky'; 25 | 26 | export default class ExampleComponents extends React.Component { 27 | constructor(props) { 28 | super(props); 29 | this.examples = [ 30 | Default, 31 | Jalaali, 32 | HideTodayButton, 33 | DisabledTimepicker, 34 | SwitchIsGregorian, 35 | CalendarPicker, 36 | LimitWithMinMax, 37 | DisabledRange, 38 | HighlightRange, 39 | Disabled, 40 | ReactHook, 41 | RemoveDate, 42 | Placeholder, 43 | ToggleButton, 44 | OnInputChange, 45 | JalaaliWithEnglishDigit, 46 | SetTodayOnBlur 47 | ]; 48 | } 49 | 50 | componentDidMount() { 51 | hljs.initHighlightingOnLoad(); 52 | } 53 | 54 | renderExamples() { 55 | return this.examples.map((example, index) => ( 56 | 57 |
58 |
59 | 60 |
61 |
{}
62 |
63 |
64 | )); 65 | } 66 | 67 | renderLeftColumn() { 68 | return this.examples.map((example, index) => ( 69 |
  • 70 | {example.title} 71 |
  • 72 | )); 73 | } 74 | 75 | render() { 76 | return ( 77 |
    78 | 79 | 80 | {({ style, isSticky }) => { 81 | const border = isSticky ? { border: 'none' } : {}; 82 | return

    Examples

    ; 83 | }} 84 |
    85 |
    86 | 87 | {({ style }) => ( 88 |
      89 | {this.renderLeftColumn()} 90 |
    91 | )} 92 |
    93 |
    94 |
    {this.renderExamples()}
    95 |
    96 |
    97 | ); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /docs/src/examples/Disabled.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('1396/7/6', 'jYYYY/jM/jD') 10 | }; 11 | } 12 | render() { 13 | return this.setState({ value })} 17 | /> 18 | } 19 | } 20 | 21 | const title = 'Disabled'; 22 | const code = `class component extends React.Component{ 23 | constructor(props) { 24 | super(props); 25 | this.state = { 26 | value: momentJalaali('1396/7/6', 'jYYYY/jM/jD') 27 | }; 28 | } 29 | render() { 30 | return this.setState({ value })} 34 | /> 35 | } 36 | } 37 | `; 38 | const Disabled = { component, title, code }; 39 | export default Disabled; -------------------------------------------------------------------------------- /docs/src/examples/HideTodayButton.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 | 9 | this.state = { value: momentJalaali() }; 10 | } 11 | render() { 12 | return ( 13 | this.setState({ value })} 17 | /> 18 | ); 19 | } 20 | } 21 | 22 | const title = 'Hide Today Button'; 23 | const code = `class component extends React.Component { 24 | constructor(props) { 25 | super(props); 26 | this.state = {value: momentJalaali()}; 27 | } 28 | render() { 29 | return this.setState({ value })} 33 | /> 34 | } 35 | } 36 | `; 37 | const Default = { component, title, code }; 38 | 39 | export default Default; 40 | -------------------------------------------------------------------------------- /docs/src/examples/HighlightRange.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 | this.highlightRanges = [ 15 | { color: 'brown', start: momentJalaali().add(-1, 'days'), end: momentJalaali().add(1, 'days') }, 16 | { color: '#00BCD4', start: momentJalaali(), end: momentJalaali().add(3, 'days') }, 17 | { color: '#FF9800', disabled: true, start: momentJalaali().add(1, 'days'), end: momentJalaali().add(6, 'days') }, 18 | ] 19 | 20 | } 21 | render() { 22 | return
    23 | this.setState({ value })} 30 | /> 31 |
    32 | 35 |
    36 | } 37 | } 38 | 39 | const title = 'Highlight By Date Range'; 40 | const code = `class component extends React.Component { 41 | constructor(props) { 42 | super(props); 43 | 44 | this.state = { 45 | value: momentJalaali(), 46 | isGregorian: true 47 | }; 48 | 49 | this.highlightRanges = [ 50 | { 51 | color: 'brown', 52 | start:momentJalaali().add(-1,'days'), 53 | end:momentJalaali().add(1,'days') 54 | }, 55 | { 56 | color: '#00BCD4', 57 | start:momentJalaali(), 58 | end:momentJalaali().add(3,'days') 59 | }, 60 | { 61 | color: '#FF9800', 62 | disabled: ture, 63 | start:momentJalaali().add(1,'days'), 64 | end:momentJalaali().add(6,'days') 65 | }, 66 | ] 67 | 68 | } 69 | render() { 70 | return
    71 | this.setState({ value })} 78 | /> 79 |
    80 | 83 |
    84 | } 85 | } 86 | `; 87 | const SwitchIsGregorian = { component, title, code }; 88 | export default SwitchIsGregorian; -------------------------------------------------------------------------------- /docs/src/examples/JalaaliWithEnglishDigit.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 | 9 | this.state = { 10 | value: momentJalaali('1396/7/6', 'jYYYY/jM/jD') 11 | }; 12 | } 13 | render() { 14 | return ( 15 | this.setState({ value })} 19 | isGregorian={false} 20 | timePicker={false} 21 | /> 22 | ); 23 | } 24 | } 25 | 26 | const title = 'Jalaali Mode With the english digits'; 27 | const code = `class component extends React.Component { 28 | constructor(props) { 29 | super(props); 30 | this.state = { 31 | value: momentJalaali('1396/7/6', 'jYYYY/jM/jD')}; 32 | } 33 | render() { 34 | return this.setState({ value })} 38 | isGregorian={false} 39 | timePicker={false} 40 | /> 41 | } 42 | } 43 | `; 44 | const Default = { component, title, code }; 45 | 46 | export default Default; 47 | -------------------------------------------------------------------------------- /docs/src/examples/OnInputChange.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 | 9 | this.state = { 10 | onChangeValue: momentJalaali(), 11 | onInputChangeValue: '', 12 | onChangeLastUpdate: new Date(), 13 | onInputChangeLastUpdate: new Date() 14 | }; 15 | } 16 | 17 | dateToString = date => `${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`; 18 | 19 | render() { 20 | const { 21 | onChangeValue, 22 | onInputChangeValue, 23 | onChangeLastUpdate, 24 | onInputChangeLastUpdate 25 | } = this.state; 26 | 27 | return ( 28 | 29 |
    30 | 31 |

    {onChangeValue.format('YYYY/M/D hh:mm A')}

    32 | 33 |

    {this.dateToString(onChangeLastUpdate)}

    34 |
    35 |
    36 | 37 |

    {onInputChangeValue}

    38 | 39 |

    {this.dateToString(onInputChangeLastUpdate)}

    40 |
    41 | 44 | this.setState({ 45 | onChangeValue: onChangeValue, 46 | onChangeLastUpdate: new Date() 47 | }) 48 | } 49 | onInputChange={e => 50 | this.setState({ 51 | onInputChangeValue: e.target.value, 52 | onInputChangeLastUpdate: new Date() 53 | }) 54 | } 55 | /> 56 |
    57 | ); 58 | } 59 | } 60 | 61 | const title = 'OnInputChange'; 62 | const code = 63 | `class component extends React.Component { 64 | constructor(props) { 65 | super(props); 66 | 67 | this.state = { 68 | onChangeValue: momentJalaali(), 69 | onInputChangeValue: '', 70 | onChangeLastUpdate: new Date(), 71 | onInputChangeLastUpdate: new Date() 72 | }; 73 | } 74 | 75 | dateToString = date => ` + 76 | '`${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;' + 77 | ` 78 | 79 | render() { 80 | const { 81 | onChangeValue, 82 | onInputChangeValue, 83 | onChangeLastUpdate, 84 | onInputChangeLastUpdate 85 | } = this.state; 86 | 87 | return ( 88 | 89 |
    90 | 91 |

    {onChangeValue.format('YYYY/M/D hh:mm A')}

    92 | 93 |

    {this.dateToString(onChangeLastUpdate)}

    94 |
    95 |
    96 | 97 |

    {onInputChangeValue}

    98 | 99 |

    {this.dateToString(onInputChangeLastUpdate)}

    100 |
    101 | 104 | this.setState({ 105 | onChangeValue: onChangeValue, 106 | onChangeLastUpdate: new Date() 107 | }) 108 | } 109 | onInputChange={e => 110 | this.setState({ 111 | onInputChangeValue: e.target.value, 112 | onInputChangeLastUpdate: new Date() 113 | }) 114 | } 115 | /> 116 |
    117 | ); 118 | } 119 | } 120 | `; 121 | const Default = { component, title, code }; 122 | 123 | export default Default; 124 | -------------------------------------------------------------------------------- /docs/src/examples/Placeholder.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 | 9 | this.state = { value: momentJalaali() }; 10 | } 11 | render() { 12 | return ( 13 | this.setState({ value })} 17 | /> 18 | ); 19 | } 20 | } 21 | 22 | const title = 'Placeholder'; 23 | const code = `class component extends React.Component { 24 | constructor(props) { 25 | super(props); 26 | this.state = {value: momentJalaali()}; 27 | } 28 | render() { 29 | return this.setState({ value })} 33 | /> 34 | } 35 | } 36 | `; 37 | const Default = { component, title, code }; 38 | 39 | export default Default; 40 | -------------------------------------------------------------------------------- /docs/src/examples/ReactHook.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import momentJalaali from 'moment-jalaali'; 3 | import DatePicker from '../../../src/components/DatePicker'; 4 | 5 | function component() { 6 | const [value, setValue] = useState(momentJalaali()); 7 | 8 | return setValue(value)} />; 9 | } 10 | 11 | const title = 'React Hook sample'; 12 | const code = `function component() { 13 | const [value, setValue] = useState(0); 14 | setSelectedDate(momentJalaali()); 15 | 16 | return setValue(value)} />; 19 | } 20 | `; 21 | 22 | const ReactHook = { component, title, code }; 23 | 24 | export default ReactHook; 25 | -------------------------------------------------------------------------------- /docs/src/examples/RemoveDate.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('1396/7/6', 'jYYYY/jM/jD') 10 | }; 11 | } 12 | render() { 13 | return ( 14 |
    15 | { 17 | this.dt = r; 18 | }} 19 | value={this.state.value} 20 | onChange={value => this.setState({ value })} 21 | /> 22 |
    23 | 24 |
    25 | ); 26 | } 27 | } 28 | 29 | const title = 'Remove Date'; 30 | const code = `class component extends React.Component { 31 | constructor(props) { 32 | super(props); 33 | this.state = { 34 | value: momentJalaali('1396/7/6', 'jYYYY/jM/jD') 35 | }; 36 | } 37 | render() { 38 | return ( 39 |
    40 | { 42 | this.dt = r; 43 | }} 44 | value={this.state.value} 45 | onChange={value => this.setState({ value })} 46 | /> 47 |
    48 | 49 |
    50 | ); 51 | } 52 | } 53 | `; 54 | const Disabled = { component, title, code }; 55 | export default Disabled; 56 | -------------------------------------------------------------------------------- /docs/src/examples/SetTodayOnBlur.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('1396/7/6', 'jYYYY/jM/jD'), 10 | setTodayOnBlur: false 11 | }; 12 | } 13 | render() { 14 | return ( 15 |
    16 | { 19 | this.dt = r; 20 | }} 21 | value={this.state.value} 22 | onChange={value => this.setState({ value })} 23 | /> 24 |
    25 | 26 | 27 |
    28 | ); 29 | } 30 | } 31 | 32 | const title = 'SetTodayOnBlur'; 33 | const code = `class component extends React.Component { 34 | constructor(props) { 35 | super(props); 36 | this.state = { 37 | value: momentJalaali('1396/7/6', 'jYYYY/jM/jD'), 38 | setTodayOnBlur: false 39 | }; 40 | } 41 | render() { 42 | return ( 43 |
    44 | { 47 | this.dt = r; 48 | }} 49 | value={this.state.value} 50 | onChange={value => this.setState({ value })} 51 | /> 52 |
    53 | 54 | 55 |
    56 | ); 57 | } 58 | } 59 | `; 60 | const Disabled = { component, title, code }; 61 | export default Disabled; 62 | -------------------------------------------------------------------------------- /docs/src/examples/ToggleButton.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 | 9 | this.state = { value: momentJalaali() }; 10 | } 11 | render() { 12 | return ( 13 | this.setState({ value })} 17 | /> 18 | ); 19 | } 20 | } 21 | 22 | const title = 'ToggleButton'; 23 | const code = `class component extends React.Component { 24 | constructor(props) { 25 | super(props); 26 | this.state = {value: momentJalaali()}; 27 | } 28 | render() { 29 | return this.setState({ value })} 33 | /> 34 | } 35 | } 36 | `; 37 | const Default = { component, title, code }; 38 | 39 | export default Default; 40 | -------------------------------------------------------------------------------- /docs/src/examples/calendarPicker.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 | this.state = { 9 | value: momentJalaali(), 10 | isGregorian: true 11 | }; 12 | } 13 | 14 | getCustomFormat(inputValue, isGregorian) { 15 | if (!inputValue) 16 | return ''; 17 | const inputFormat = isGregorian ? 'YYYY/M/D' : 'jYYYY/jM/jD'; 18 | return isGregorian ? inputValue.locale('es').format(inputFormat) : 19 | inputValue.locale('fa').format(inputFormat); 20 | } 21 | 22 | render() { 23 | return
    24 | { this.setState({ value }) }} 28 | /> 29 |
    30 | 34 |

    35 | selected date: {this.getCustomFormat(this.state.value, this.state.isGregorian)} 36 |

    37 |
    38 | } 39 | } 40 | 41 | const title = 'Calendar'; 42 | const code = `import momentJalaali from 'moment-jalaali'; 43 | import { Calendar } from 'react-datepicker2'; 44 | 45 | class component extends React.Component { 46 | constructor(props) { 47 | super(props); 48 | this.state = { 49 | value: momentJalaali(), 50 | isGregorian: true 51 | }; 52 | } 53 | 54 | getCustomFormat(inputValue, isGregorian) { 55 | if (!inputValue) 56 | return ''; 57 | const inputFormat = isGregorian ? 'YYYY/M/D' : 'jYYYY/jM/jD'; 58 | return isGregorian ? inputValue.locale('es').format(inputFormat) : 59 | inputValue.locale('fa').format(inputFormat); 60 | } 61 | 62 | render() { 63 | return
    64 | { this.setState({ value }) }} 68 | /> 69 |
    70 | 74 |

    75 | selected date: {this.getCustomFormat(this.state.value, this.state.isGregorian)} 76 |

    77 |
    78 | } 79 | } 80 | `; 81 | const CalendarPicker = { component, title, code }; 82 | export default CalendarPicker; -------------------------------------------------------------------------------- /docs/src/examples/default.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 | 9 | this.state = {value: momentJalaali()}; 10 | } 11 | render() { 12 | return this.setState({ value })} 15 | /> 16 | } 17 | } 18 | 19 | const title = 'Default'; 20 | const code = `class component extends React.Component { 21 | constructor(props) { 22 | super(props); 23 | this.state = {value: momentJalaali()}; 24 | } 25 | render() { 26 | return this.setState({ value })} 29 | /> 30 | } 31 | } 32 | `; 33 | const Default = { component, title, code }; 34 | 35 | export default Default; -------------------------------------------------------------------------------- /docs/src/examples/disabledRange.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 | this.disabledRanges = [ 15 | { 16 | disabled: true, 17 | start:momentJalaali().add(-1,'days'), 18 | end:momentJalaali().add(1,'days') 19 | }, 20 | { 21 | disabled: true, 22 | start:momentJalaali().add(3,'days'), 23 | end:momentJalaali().add(6,'days') 24 | } 25 | ] 26 | 27 | } 28 | render() { 29 | return
    30 | this.setState({ value })} 37 | /> 38 |
    39 | 42 |
    43 | } 44 | } 45 | 46 | const title = 'Disable By Date Range'; 47 | const code = `class component extends React.Component { 48 | constructor(props) { 49 | super(props); 50 | 51 | this.state = { 52 | value: momentJalaali(), 53 | isGregorian: true 54 | }; 55 | 56 | this.disabledRanges = [ 57 | { 58 | disabled: true, 59 | start:momentJalaali().add(-1,'days'), 60 | end:momentJalaali().add(1,'days') 61 | }, 62 | { 63 | disabled: true, 64 | start:momentJalaali().add(3,'days'), 65 | end:momentJalaali().add(6,'days') 66 | } 67 | ] 68 | 69 | } 70 | render() { 71 | return
    72 | this.setState({ value })} 79 | /> 80 |
    81 | 84 |
    85 | } 86 | } 87 | `; 88 | const SwitchIsGregorian = { component, title, code }; 89 | export default SwitchIsGregorian; -------------------------------------------------------------------------------- /docs/src/examples/disabledTimepicker.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 = {value: momentJalaali()}; 9 | } 10 | render() { 11 | return this.setState({ value })} 15 | /> 16 | } 17 | } 18 | 19 | const title = 'Disabled Timepicker'; 20 | const code = `class component extends React.Component { 21 | constructor(props) { 22 | super(props); 23 | this.state = {value: momentJalaali()}; 24 | } 25 | render() { 26 | return this.setState({ value })} 30 | /> 31 | } 32 | } 33 | `; 34 | const DisabledTimepicker = { component, title, code }; 35 | export default DisabledTimepicker; -------------------------------------------------------------------------------- /docs/src/examples/jalaali.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('1396/7/6', 'jYYYY/jM/jD') 10 | }; 11 | } 12 | render() { 13 | return this.setState({ value })} 18 | /> 19 | } 20 | } 21 | 22 | const title = 'Jalaali'; 23 | const code = `class component extends React.Component{ 24 | constructor(props) { 25 | super(props); 26 | this.state = { 27 | value: momentJalaali('1396/7/6', 'jYYYY/jM/jD') 28 | }; 29 | } 30 | render() { 31 | return 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 | Fork me on GitHub 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 |
    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 |
    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":"AAIA;EACE,kBAAkB;EAClB,kBAAkB;EAElB,mDAAmD;EACnD,2CAA2C;EAC3C,YAAY;EACZ,YAAY;EACZ,kBAAkB;EAClB,aAAa;EACb,sBAAsB;ACHxB;;ADMA;EACE,8BAAsB;UAAtB,sBAAsB;ACHxB;;ADMA;;;EAGE,WAAW;EACX,cAAc;EACd,WAAW;ACHb;;ADMA;EACE,8BAAsB;UAAtB,sBAAsB;ACHxB;;ADMA,YAAA;AAEA;EACE,YAAY;EACZ,iBAAiB;EACjB,mBAAmB;ACJrB;;ADOA;EACE,gBAAgB;EAChB,aAAa;EACb,YAAY;EACZ,kBAAkB;EAClB,iBAAiB;EACjB,WAAW;EACX,YAAY;EACZ,eAAe;ACJjB;;ADOA;EACE,yBAAyB;ACJ3B;;ADOA;EACE,WAAW;EACX,UA1Dc;ACsDhB;;ADOA;;EAEE,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB,SAAS;ACJX;;ADOA;EACE,YAAY;ACJd;;ADOA;EACE,WAAW;ACJb;;ADOA;EACE,YAAY;EACZ,kBAAkB;EAClB,WAAW;EACX,aAAa;EACb,yBAAyB;EACzB,kBAAkB;EAClB,qBAAqB;EACrB,mBAAmB;EACnB,0BAA0B;EAC1B,gBAAgB;EAChB,gBAAgB;EAChB,gBAAgB;ACJlB;;ADOA;EACE,0BAA0B;ACJ5B;;ADOA,uBAAA;AAEA;EACE,WAAW;EACX,mBAAmB;EACnB,eAAe;EACf,kBAAkB;ACLpB;;ADQA,8BAAA;AACA;EACE,YAAY;EACZ,gBAAgB;EAChB,aAAa;EACb,WAAW;EACX,eAAe;EACf,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB,gBAAgB;EAChB,UAAU;EACV,gBAAgB;EAChB,wBAAwB;ACL1B;;ADQA;EACE,wBAAwB;ACL1B;;ADQA;EACE,yBA5HkB;ACuHpB;;ADQA;EACE,WAAW;EACX,mBAAmB;EACnB,yBAAyB;ACL3B;;ADQA;EACE,yBAAyB;EACzB,cAAc;ACLhB;;ADQA;EACE,YAAY;ACLd;;ADQA,qBAAA;AAEA;EACE,kBAAkB;EAClB,mBAAmB;EACnB,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,WAAW;EACX,cAA+B;ACNjC;;ADSA;EACE,mBAAY;MAAZ,oBAAY;UAAZ,YAAY;EACZ,yBAA8B;MAA9B,sBAA8B;UAA9B,8BAA8B;EAC9B,WAAW;ACNb;;ADSA,2BAAA;AAEA;EACE,WAAW;EACX,WAAW;ACPb;;ADUA;EACE,mBAAmB;EACnB,WAAW;EACX,YAAY;EACZ,yBAAyB;EACzB,aAAa;EACb,cAAc;EACd,gBAAgB;EAChB,eAAe;EACf,eAAe;ACPjB;;ADUA;EACE,mBAAmB;EACnB,eAAe;ACPjB;;ADUA,0BAAA;AAEA;EACE,WAAW;EACX,WAAW;EACX,iBAAiB;EACjB,kBAAkB;ACRpB;;ADWA;EACE,UAAU;EACV,WAAW;EACX,YAAY;EACZ,yBAAyB;EACzB,aAAa;EACb,cAAc;EACd,gBAAgB;EAChB,eAAe;EACf,eAAe;ACRjB;;ADWA;EACE,mBAAmB;EACnB,eAAe;ACRjB;;ADWA,8BAAA;AAEA;;;;EAIE,yBAvNqB;EAwNrB,cAAc;ACThB;;ADYA;EACE,cAAc;ACThB;;ADYA;EACE,YAAY;ACTd;;ADYA,oBAAA;AAEA;EACE,iBAAiB;ACVnB;;ADaA;EACE,WAAW;EACX,iBAAiB;EACjB,UAAU;EACV,kBAAkB;ACVpB;;ADaA;EACE,YAAY;EACZ,UAAU;ACVZ;;ADaA;EACE,YAAY;ACVd;;ADaA;EACE,WAAW;ACVb;;ADaA;EACE,kBAAkB;EAClB,qBAAqB;EACrB,8BAAsB;UAAtB,sBAAsB;EACtB,YAAY;EACZ,yBAAyB;EACzB,gBAAgB;ACVlB;;ADaA;EACE,8BAAsB;UAAtB,sBAAsB;ACVxB;;ADaA;EACE,aAAa;EACb,0BAA0B;EAC1B,cAAc;EACd,kBAAkB;EAClB,WAAW;EACX,kBAAkB;EAClB,qBAAqB;EACrB,eAAe;EACf,cAAc;EACd,gBAAgB;EAEhB,YAAY;EACZ,sBAAsB;EACtB,6BAA6B;EAC7B,wBAAwB;EAExB,gBAAgB;ACXlB;;ADcA;EACE,0BAA0B;ACX5B;;ADcA;EACE,wBAAgB;UAAhB,gBAAgB;EAChB,YAAY;EACZ,yBAAyB;ACX3B;;ADcA;EACE,yBAAyB;ACX3B;;ADcA;EACE,aAAa;EACb,YAAY;EACZ,kBAAkB;EAClB,8BAAsB;UAAtB,sBAAsB;ACXxB;;ADcA;EACE,8BAAsB;UAAtB,sBAAsB;ACXxB;;ADcA;EACE,qBAAqB;EACrB,kBAAkB;EAClB,aAAa;EACb,gBAAgB;EAChB,eAAe;EACf,gBAAgB;EAChB,sBAAsB;EACtB,kBAAkB;EAClB,kCAA0B;UAA1B,0BAA0B;EAC1B,4BAA4B;EAC5B,sBAAsB;EACtB,gBAAgB;ACXlB;;ADcA;EACE,SAAS;EACT,UAAU;EACV,WAAW;EACX,eAAe;EACf,gBAAgB;EAChB,UAAU;EACV,6BAA6B;EAC7B,cAAc;EACd,gBAAgB;EAChB,kBAAkB;EAClB,oBAAoB;ACXtB;;ADcA;;EAEE,wBAAgB;UAAhB,gBAAgB;EAChB,YAAY;ACXd;;ADcA;EACE,8BAAsB;UAAtB,sBAAsB;EACtB,kBAAkB;EAClB,YAAY;EACZ,gCAAgC;ACXlC;;ADcA;EACE,iBAAiB;ACXnB;;ADcA;EACE,kBAAkB;EAClB,UAAU;EACV,eAAe;EACf,gBAAgB;EAChB,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB,iBAAiB;EACjB,QAAQ;EACR,SAAS;ACXX;;ADcA;EACE,YAAY;EACZ,eAAe;EACf,WAAW;EACX,qBAAqB;EACrB,cAAc;EACd,WAAW;EACX,mCAA2B;EAA3B,2BAA2B;ACX7B;;ADcA;EACE,WAAW;ACXb;;ADcA;EACE,WAAW;EACX,eAAe;EACf,yBAAyB;EACzB,mBAAmB;EACnB,iBAAiB;EACjB,8BAAsB;UAAtB,sBAAsB;EACtB,WAAW;EACX,gBAAgB;EAChB,kBAAkB;ACXpB;;ADcA;EACE,gBAAgB;ACXlB;;ADcA;EACE,cAAc;EACd,cAAc;ACXhB;;ADcA;EACE,eAAe;ACXjB;;ADcA;EACE,gBAAgB;EAChB,8BAAsB;UAAtB,sBAAsB;EACtB,SAAS;EACT,UAAU;EACV,WAAW;EACX,iBAAiB;EACjB,kBAAkB;EAClB,kBAAkB;ACXpB;;ADcA;EACE,gBAAgB;EAChB,+BAAuB;UAAvB,uBAAuB;EACvB,SAAS;EACT,mBAAmB;EACnB,WAAW;EACX,YAAY;EACZ,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;EACf,yBAAiB;KAAjB,sBAAiB;MAAjB,qBAAiB;UAAjB,iBAAiB;ACXnB;;ADcA;EACE,mBAAmB;ACXrB;;ADcA;EACE,mBAAmB;EACnB,cAAc;ACXhB;;ADcA;EACE,cAAc;ACXhB;;ADcA;EACE,uBAAuB;EACvB,mBAAmB;ACXrB;;ADcA;EACE,aAAa;ACXf;;ADcA;;EAEE,oBAAoB;ACXtB;;ADcA;EAEI,oCAAoC;ACZxC;;ADgBA;EAEI,oBAAoB;ACdxB;;ADkBA;EACE,cAAc;EACd,WAAW;EACX,mBAAmB;EACnB,WAAW;EACX,aAAa;EACb,kBAAkB;EAClB,SAAS;EACT,eAAe;EACf,oBAAoB;EACpB,wCAAgC;EAAhC,gCAAgC;EAChC,uCAA+B;EAA/B,+BAA+B;ACfjC;;ADIA;EAcI,mBAA+B;ACdnC;;ADkBA;EACE,mBAAmB;ACfrB;;ADkBA;EACE,gBAAgB;ACflB;;ADkBA;EACE,kBAAkB;EAClB,SAAS;EACT,WAAW;EACX,kBAAkB;EAClB,eAAe;EACf,cAAc;ACfhB;;ADSA;EAaI,sBAAsB;EACtB,qBAAqB;EACrB,UAAU;EACV,WAAW;EACX,kBAAkB;AClBtB;;ADCA;EAUM,gBAAgB;ACPtB;;ADkBA;EACE,mBAAmB;ACfrB;;ADkBA;;EAEE,WAAW;EACX,mBAAmB;EACnB,yBAAyB;ACf3B","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 | } --------------------------------------------------------------------------------