├── .bowerrc ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── stale.yml ├── .gitignore ├── .jshintrc ├── .travis.yml ├── CONTRIBUTING.md ├── HISTORY.md ├── LICENSE ├── OSS_Notice.pdf ├── README.md ├── bower.json ├── css ├── px-datetime-picker-content-styles.html └── px-datetime-picker-styles.html ├── demo ├── px-datetime-picker-demo.html ├── simple-demo-fit-element.html └── simple_demo.html ├── deploy.enc ├── favicon.ico ├── gulpfile.js ├── index.html ├── package-lock.json ├── package.json ├── px-datetime-picker-api.json ├── px-datetime-picker-content.html ├── px-datetime-picker.html ├── sass ├── px-datetime-picker-content.scss └── px-datetime-picker.scss ├── scripts └── ghp.sh ├── test ├── index.html ├── px-datetime-picker-custom-tests.js └── px-datetime-picker-test-fixture.html ├── wct.conf.json └── yarn.lock /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "./bower_components" 3 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 2 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Submit an Issue Hi, Thanks for helping us improve the Predix UI platform by submitting an issue. Before you begin, please check the list of existing issues to avoid submitting a duplicate issue. To help us solve this issue as fast as possible, please fill out the following sections: ## Expected behavior and actual behavior: ## Steps to reproduce the problem: ## Environment (_component version number, Browser (including version), operating system, hardware, etc_): ## Screenshots (_optional, but very helpful_): ## Code examples help us better understand the issue - follow the appropriate codepen for the component by going to https://predix-ui.com, finding the component in question, and clicking on the pencil icon under the demo. 2 | Once you've created your code example, you can save it under a new url. 3 | Please note that you should NOT use the same methods for production as the ones used in codepen - these methods are not production ready. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Pull Request Hi, Thanks for helping us improve the Predix UI platform by submitting a Pull Request. To help us merge your Pull Request as fast as possible, please fill out the following sections: * ## A description of the changes proposed in the pull request: * ## A reference to a related issue (if applicable): * ## @mentions of the person or team responsible for reviewing proposed changes: * ## working tests: #### The tests need to be functional and/or unit tests, written for the wct framework, and placed in the test folder, following our testing guidelines. -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Issues/PRs with no activity for a year will be marked as stale 2 | daysUntilStale: 365 3 | 4 | # If no one has replied inside a week after an issue is marked stale, close it. 5 | daysUntilClose: 7 6 | 7 | staleLabel: wontfix 8 | markComment: > 9 | This issue or PR has been automatically marked as stale because there has been 10 | no activity in over a year. It will be closed in 1 week if no further activity occurs. 11 | Thanks for your contribution, and please don't hesitate to comment if this issue/PR 12 | is still relevant. 13 | exemptLabels: 14 | - pinned 15 | - security 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | temp 4 | bower_components* 5 | .idea 6 | reports 7 | css/noprefix 8 | .yo-rc.json 9 | bower-*.json 10 | monogram-wdmk.png 11 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "noarg": true, 7 | "sub": true, 8 | "undef": true, 9 | "boss": true, 10 | "eqnull": true, 11 | "node": true, 12 | "browser": true, 13 | "expr":true, 14 | "globals" : { 15 | "it" : false, 16 | "xit" : false, 17 | "describe" : false, 18 | "xdescribe" : false, 19 | "before" : false, 20 | "after" : false, 21 | "beforeEach" : false, 22 | "afterEach" : false, 23 | "expect" : false, 24 | "spyOn" : false, 25 | "alert" : false, 26 | "require" : false, 27 | "requirejs" : false, 28 | "Card" : true, 29 | "iOS" : false, 30 | "$" : true, 31 | "define" : false, 32 | "angular": false, 33 | "Polymer": false, 34 | "suite": false, 35 | "test": false, 36 | "assert": false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | language: node_js 4 | node_js: 5 | - stable 6 | branches: 7 | except: 8 | - gh-pages 9 | addons: 10 | firefox: latest 11 | apt: 12 | sources: 13 | - google-chrome 14 | packages: 15 | - google-chrome-stable 16 | before_script: 17 | - yarn add polymer-cli 18 | - polymer install --variants 19 | script: 20 | - xvfb-run wct --skip-plugin sauce 21 | - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct --plugin sauce --skip-plugin 22 | local; fi 23 | after_success: 24 | - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then openssl aes-256-cbc -k "$DEPLOYSECRET" 25 | -in deploy.enc -out deploy_key -d; fi 26 | - cd $TRAVIS_BUILD_DIR/scripts 27 | - chmod 755 ghp.sh 28 | - "./ghp.sh" 29 | env: 30 | global: 31 | - secure: TU2loewaGr36wIu96Xh2aN4/e32ui8L7WZvqtaInZirHXpUUczLR4NWPP+b2pvMJGCTBRMVRMaAsGXYhNuyWW8y3AVvjTYG+qcH7CRv/LT7kHPHPzTJiH0lYwB9wDXJnKj1SqsoqFWNBb706rlVKZzz4xYWSbFUCsn2xLjrIAaxTQXScYM7iXLanZhr5d07LXiMTu0t5iYLOOnGmhx5Of+nnDcyshr8GXFs2Rt4vtCZ09c4vQEQ9i2leeOxRklYnTvGYRUhdAnk51aJRXaUPCDG1ZHIeqQaLqgtkUxYRG0QhxFok1WgTp0lAToJI6LFQqUWyo6CEQ6JHJE9RNcE/PxrttlNQR4bTGTTET1GzTw3DWZr2uabdQN6rOJXxNFKvEkCaWx2d23S0aAcqfjpgNVabMtzMiAHxCc1esB5a+/od/9kRMVTvl/w9Cp9DIxxy5udB/8tRpVMXbO/ZMZ+l3koItIjY599gIqMzL71fQf4irH7AiYBbwolPmdDdGnniPCKToBym0BxMXZHaFw9gAa/dJzoRFBGRp25mBAKFPZy59ulpmN1vCQDD0R5OL2CCV5We+eIajqW2Xe0UcWveyAN/TC9K40VOgcGOFg+HuZP9jLyysal2iT6ALzmSe/w2wVub/POr0v2qRC4T4s5suS5Un6K2+2Z9JTw9mOi+CUw= 32 | - secure: k7SPZ6ug35aBDhBk/dBN5K2cdunEvCpFRHfGEtdIw4feqbJziljoJiU3Zu2lbxmgYLHWq7oAZe1ztpTNnG/crJyO1966KSHpdv2TNqBwrIfjCxU7Y+KTPrDe1nnI3zrcYsP2uFlhh/3sSShq6+Yky1tn8TpBemdRu9LUJ9mOMQBtoACCbK2VeiCZNAPP2UnplcrD3LiFl5rbSTHe6QZq/qIl3XrcTrTruxtw3t9lszZ79n6yyVdfF2nXkiIIM4Sa7z/ow6ULAPX1MzPP7AB5bDw0XY28gTeYp2pxP9dNjbfDmr1kpB49/BsFLe3WDsXxEP2VdZgWGsphQaY8h9auFQD1h67T0a6kBau0ntm8gy1qx4njBwORngbvXVD8DtEssxsFW9clb4knQSn+ZUMXHxGWlWkEWGETy7ptGloB5TITBgHgVZWmcqICX+wjIp8eNx+Nfc3GKUjWodpwhNvyzNCb4kb1yCG32rbj8M8YC9XQ5T+Oe2aqhniRIYGu9ydlf2fM/bOObob/FDgQU1jwtFWir6Sta8wkub96TlglzN9/8lE1WnUW36tb3j2MJX3aYHbyU3+RjliIHeXhY5NnAdZbTbNDlT5mkUJa1EQOb6Qscy/cj6PaCuoBsiwTA9XOibt0IkMT5Ir/1nziZqgkZhjhYgdzOZHntE/1GrtqJiw= 33 | - secure: FP7JSFtS0ZPKPUMksF3szfbVrwNQmz/O/4vttJkDurZn2q4b7zjXfdREct/KF/8gXD4XSMvkf+HcWtukX4CDFX1JbsNvAZ0/9/XXMG/FGVoyG5zKv3RM4tUPrXAQSq6EUYfGY4xBBRE0C15EXwcSqtZ7BUE49meXenQbR4jGkOM5JXjKhAPe9lnovmGGDxGKM1MNrH2Lmgs9u36n8imvpaMMNl1XiHqh+mKgQg3/d/ssXXfUZGg++/7z8EnqKzki1Ph07Ip9BqodTbSXnda7NX+QQ06VR6F+lZA9iyApx9hOv2Nlfoi3Hg8erVfYILPTCdHQXn0CTWnGKToM9VS5gSVUrZ4TxU7kmVRmueZGFbP4+GqmSMlFduy/jVtLoVBH6WUyOVNzv6Z5LGKEs/2dVReP3Jvp+Zoo0ruNVEGalmV/X1eVJouRKVzm/ftT2uIgfsXr5X9zG/eodTsFZggcUJappK9azJEMydu0dMH2onVxbvri3qIBqZpAPvvRdODarfQ2RvResuDbI+HS9hSpW+X4WjLqT7VTji6QrNdDREErMPHixnF2FXZdbevC7lxiJkqH3MDQkQMG35eNjqEekCHzkrdwEAy89DTfggTq1KW0+fM0N/q/vxYfj0HOjaCgM7hkjYiy86L3hayUDLoqCyPfym7m1nyJ1yayyNR4V0Q= 34 | - secure: YhuzikAqLixazpELcQsomF6EGFll2/zZuxdkpHdic28onqdY8VgMPuFnY3sHiYLL2ruqPIuWNvGXwnUQHgz6MvBVDjBlkRR9G0w1uRyzJ7nWnzFBOPvPTNnvZo9qcz1Yflo70VkslxWpERQeMbj6zgom5GpM7bNWrgpvAZ7Q1ec+QfwB/9m+xgTevRwuM+MzIa2OvYAlE9pVs4yMTO/w5m1YsIQiZnmquhxt5CVrhFxUS3RWSJKJ20PY3R3qPpwD7fge1MoAQUUgfDgtqP3b0e8G3DxiYKfvxhe+syW85MFwYH7b4sugBoOdwO81UK6C1JpPCX156lZp6pUdzaMQdjZz1+g5SjlY2oSmmBOMuQLyfayPmbeuVtusgfB3M9+/YeB6/tqQctsjijWrmrRl9HRVmpAU7uqXYr9sq+AOIOVtXxeprQRxvBI1ZsjeT6+0eS9PRcTgtH0UJMBNg+wddIaEalna5inGZGZ643Leq4jOO+qcBMv0MIuzL+B/buec4Hwt338Tusc8LKmk8zJWgXSi/d27UKUN6OnBSj0RSmL8aWkaKtGnpJkxsQXlOgCvEqzv1s7HnNqWx3hhAogVSgj/ENjCae/0ANOSecdz+ICebQkENNfcEvsz0tMhARBxYoLNclSDa8fdUT9ZO1wSqgKFOUS4yfSWUvM3ApMpTvE= 35 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Predix UI Hi, Want to contribute your suggestions to Predix UI? **Here's how you can help.** Please follow the below steps carefully, so your suggestions will be clear and developers can make effective fixes. ## Using the GitHub issue tracker The GitHub issue tracker is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests) and [submitting pull requests](#pull-requests), so please respect the following restrictions: * Please **do not** use the GitHub issue tracker for personal support requests. Stack Overflow ([`predix ui`](https://stackoverflow.com/questions/tagged/predix-ui) tag), or [Predix.io](https://predix.io) are better places to get help. * Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. * Please **do not** post vague comments like "+1" or ":thumbsup:". Use [GitHub's "reactions" feature](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). We reserve the right to delete comments. ## Issues and labels Our bug tracker utilizes several labels to help organize and identify issues. Here's what they represent and how we use them: - `browser bug` - Issues that are reported to us, but are actually the result of a browser-specific bug. These issues are diagnosed with reduced test cases and result in an issue opened on that browser's own bug tracker. - `confirmed` - Issues that have been confirmed with a reduced test case and identify a bug in a Predix UI component. - `css` - Issues stemming from our compiled CSS or source Sass files. - `docs` - Issues for improving or updating our documentation. - `examples` - Issues involving the example templates included in our docs. - `enhancement` - Issues asking for a new feature to be added, or an existing one to be extended or modified. New features require a minor version bump (e.g., `v3.0.0` to `v3.1.0`). - `grunt` - Issues with our included JavaScript-based Gruntfile, which is used to run all our tests, concatenate and compile source files, and more. - `help wanted` - Issues that we need or would like the community to help us resolve. - `js` - Issues stemming from our compiled or source JavaScript files. - `meta` - Issues with the project itself or our GitHub repository. ## Bug reports A bug is a _demonstrable problem_ caused by the code in the repository. Good bug reports are extremely helpful. Guidelines for bug reports: 0. **Validate and lint your code**; [validate your HTML](http://html5.validator.nu) and [lint your HTML](http://www.dirtymarkup.com/) to ensure your problem isn't caused by a simple error in your own code. 1. **Use the GitHub issue search**; check if the issue has already been reported. 2. **Check if the issue has been fixed**; try to reproduce the issue by using the latest `master` or development branch in the repository. 3. **Isolate the problem**; ideally create a [reduced test case](https://css-tricks.com/reduced-test-cases/) and a live example using [CodePen](http://codepen.io/mdwragg/pen/LNwmpB) or [jsfiddle](https://jsfiddle.net/Lqmcwhw0/3/). A good bug report shouldn't require others to get more information. Please be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and OS experience the problem? Do other browsers show the bug differently? What would you expect for the outcome? Such details will help people fix potential bugs. Example: > Short and descriptive example bug report title > > A summary of the issue and the browser/OS environment in which it occurs. If > suitable, include the steps required to reproduce the bug. > > 1. This is the first step > 2. This is the second step > 3. Further steps, etc. > > `` - a link to the reduced test case > > Any other information relevant to the bug report. This might include the lines of code that you have identified as > causing the bug, and potential solutions (and your opinions on their > merits). ## Feature Requests Feature requests are welcome, but before opening one, determine if your idea suits the scope and aims of Predix UI. *You* need to make a strong case and convince the Predix UI team to adopt your feature. Please provide as much detail and context as possible. ## Pull Requests Your pull requests�patches, improvements, and new features�are a big help. The requests should be focused and avoid unrelated commits. **Please ask** before making a significant pull request (e.g., implementing features, refactoring code, or porting to a different language) that Predix UI developers might not merge into the component. Please follow the [coding guidelines](#code-guidelines) used throughout the project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). **Do not edit any of the CSS files directly!** The files are automatically generated. You should edit the source files in [`sass/`] instead. **Do not edit the `gh-pages` branch.** That branch is generated from the documentation source files and is managed separately by the Predix UI team. Please use the following process to have your work considered for the project: 1. [Fork](https://help.github.com/fork-a-repo/) the component. 2. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix: ``` bash git checkout -b ``` 3. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) or your code is unlikely to be merged into the main project. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public. 4. Locally merge (or rebase) the latest commits into your branch: ``` bash git pull [--rebase] origin master ``` 5. Push your topic branch up to your fork: ``` bash git push origin ``` 6. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description against the `master` branch. ## Code guidelines ### HTML [Adhere to the Code Guide.](http://codeguide.co/#html) - Use tags and elements appropriate for an HTML5 doctype (e.g., self-closing tags). - Use [WAI-ARIA](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) attributes in documentation examples to promote accessibility. ### CSS [Adhere to the Code Guide.](http://codeguide.co/#css) - When feasible, default color palettes should comply with [WCAG color contrast guidelines](http://www.w3.org/TR/WCAG20/#visual-audio-contrast). - Except in rare cases, don't remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](http://a11yproject.com/posts/never-remove-css-outlines/) for more details. ### JS - 2 spaces (no tabs) - "Attractive" - no errors / warnings -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | v2.3.0 2 | ================== 3 | * Added i18n support for date picker placeholder text via the `resources` property. 4 | 5 | v2.2.1 6 | ================== 7 | * Added ability to hoist timezone dropdown 8 | 9 | v2.2.0 10 | ================== 11 | * added the ability for the picker to go into full screen mode through `collapseAt` 12 | * added `required`, `collapseAt`, and `collapsed` properties 13 | 14 | v2.1.1 15 | ================== 16 | * added a `focus` function 17 | 18 | v2.1.0 19 | ================== 20 | * Broke components up so iron-dropdown content is in a separate component, px-datetime-picker-content 21 | * Added px-overlay-content to hoist px-datetime-picker-content up the dom 22 | * Added hoist option, defaulted to false 23 | * Added containerType option to specify which container it should hoist to 24 | 25 | ================== 26 | * fixing demo pages for IE11 27 | 28 | v2.0.4 29 | ================== 30 | * Updated to newest px-datetime-common behavior versions 31 | 32 | v2.0.3 33 | ================== 34 | * added `sudo:required` to travis file 35 | 36 | v2.0.2 37 | ================== 38 | * fix links in docs 39 | 40 | v2.0.1 41 | ================== 42 | * Add editor for momentObj to demo 43 | 44 | v2.0.0 45 | ================== 46 | * Polymer 1.X/2.Xhybrid support 47 | * `dateTime` property no longer exists. Please use only `momentObj` instead (which is a moment object.) 48 | * Ability to have `momentObj` null so that the datepicker can be empty 49 | 50 | v1.2.0 51 | ================== 52 | * added properties fullContainer and fitIntoElement 53 | 54 | v1.1.2 55 | ================== 56 | * fixed/refactored tests 57 | * fixed typo that caused button to always apply the change 58 | 59 | v1.1.1 60 | ================== 61 | * add device flags 62 | 63 | v1.1.0 64 | ================== 65 | * migrate to iron-dropdown 66 | 67 | v1.0.4 68 | ================== 69 | * updated css variables documentation 70 | 71 | v1.0.3 72 | ================== 73 | * add min and max date support 74 | 75 | v1.0.2 76 | ================== 77 | * Fix comment for analyzer 78 | 79 | v1.0.1 80 | ================== 81 | * runtime theming for demo 82 | 83 | v1.0.0 84 | ================== 85 | * component redesign 86 | * combined -predix and -sketch sass files 87 | * update dependencies for design refresh 88 | 89 | v0.4.2 90 | ================== 91 | * part of the timezone time issue fix. px-rangepicker issue #39 92 | 93 | v0.4.1 94 | ================== 95 | * update readme and remove old component image 96 | * add resolution for webcomponentsjs 97 | 98 | v0.4.0 99 | ================== 100 | * added localization through resources, language, formats and Px.moment.changeLocale() 101 | 102 | v0.3.14 103 | ================== 104 | * converted time zone property to typeahead 105 | 106 | v0.3.13 107 | ================== 108 | * fixed border color and exposed css variable 109 | 110 | v0.3.12 111 | ================== 112 | * add Event Fired information 113 | 114 | v0.3.11 115 | ================== 116 | * merged PR fixing attached typo 117 | 118 | v0.3.10 119 | ================== 120 | * add link to Moment documentation 121 | 122 | v0.3.9 123 | ================== 124 | * added styling section to API documentation 125 | 126 | v0.3.8 127 | ================== 128 | * fixed timing bug that prevented the dateTime property from getting applied 129 | 130 | v0.3.7 131 | ================== 132 | * Moved theming style includes and updated ghp.sh 133 | * updated api for new colors 134 | 135 | v0.3.6 136 | ================== 137 | * fix component link in demo 138 | 139 | v0.3.5 140 | ================== 141 | * Update to px-demo 142 | * removed demosass 143 | * Updated to cool grays 144 | 145 | v0.3.4 146 | ================== 147 | * Update colors design to pick up new colors 148 | 149 | v0.3.3 150 | ================== 151 | * changing ghp.sh to account for Alpha releases 152 | 153 | v0.3.2 154 | ================== 155 | * fixed demo (#9) 156 | 157 | v0.3.1 158 | ================== 159 | * Update missed design dependencies 160 | 161 | v0.3.0 162 | ================== 163 | * Updated dependencies 164 | 165 | v0.2.16 166 | ================== 167 | * changing browser in wct testing from safari 8 to safari 10 on elcapitan 168 | 169 | v0.2.15 170 | ================== 171 | * updating slider dependency 172 | 173 | v0.2.14 174 | ================== 175 | * changing all devDeps to ^ 176 | 177 | v0.2.13 178 | ================== 179 | * Update dependencies 180 | 181 | v0.2.12 182 | ================== 183 | * Update px-theme to 2.0.1 and update test fixtures 184 | 185 | v0.2.11 186 | ================== 187 | * fixed the bug that prevented the up and down arrows from going to a past or future date if blocked 188 | 189 | v0.2.10 190 | ================== 191 | * update dependencies for dropdown 192 | 193 | v0.2.9 194 | ================== 195 | * removing px-theme style call 196 | 197 | v0.2.8 198 | ================== 199 | * changing Gruntfile.js to gulpfile.js 200 | 201 | v0.2.7 202 | ================== 203 | * added style variables for theming 204 | 205 | v0.2.6 206 | ================== 207 | * bower updating px-demo-snippet 208 | 209 | v0.2.5 210 | ================== 211 | * bumped calendar picker to fix icons not showing up 212 | 213 | v0.2.4 214 | ================== 215 | * Fixed codepen 216 | 217 | v0.2.3 218 | ================== 219 | * Update dependencies 220 | 221 | v0.2.2 222 | ================== 223 | * Latest gulpfile update to latest demo snippet component 224 | 225 | v0.2.1 226 | ================== 227 | * Fixing up dependency versions 228 | 229 | v0.2.0 230 | ================== 231 | * Grunt to gulp migration & style modules 232 | 233 | v0.1.8 234 | ================== 235 | * Fixed demo event counter 236 | 237 | v0.1.7 238 | ================== 239 | * added overflow to demoContainer and removed flex__wrap from mega-demo 240 | 241 | v0.1.6 242 | ================== 243 | * updated mega demo styles and bower px-demo-snippet to ^ 244 | 245 | v0.1.5 246 | ================== 247 | * added image to readme, removed watch, added view on github 248 | 249 | v0.1.4 250 | ================== 251 | * Added vulcanize 252 | 253 | v0.1.3 254 | ================== 255 | * Updated wording in demo 256 | 257 | v0.1.2 258 | ================== 259 | * Added blockPastDates and blockFutureDates to px-datetime-field 260 | 261 | v0.1.1 262 | ================== 263 | * Added new demos 264 | 265 | v0.1.0 266 | ================== 267 | * Added blockPastDates 268 | 269 | v0.0.2 270 | ================== 271 | * Use local copy of moment.js 272 | 273 | v0.0.2 274 | ================== 275 | * upgrade bower dependencies 276 | 277 | v0.0.1 278 | ================== 279 | * Initial release 280 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /OSS_Notice.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/predixdesignsystem/px-datetime-picker/eb1d8867a9eced6fec2291f714cae0ef07a78de1/OSS_Notice.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # px-datetime-picker [![Build Status](https://travis-ci.org/PredixDev/px-datetime-picker.svg?branch=master)](https://travis-ci.org/PredixDev/px-datetime-picker) 2 | 3 | ## Overview 4 | 5 | `Px-datetime-picker` is a Predix UI component which allows the user to select a date and time precisely to the second or millisecond. The user may select the date from a calendar. 6 | 7 | ## Usage 8 | 9 | ### Prerequisites 10 | 1. node.js 11 | 2. npm 12 | 3. bower 13 | 4. [webcomponents-lite.js polyfill](https://github.com/webcomponents/webcomponentsjs) 14 | 15 | Node, npm and bower are necessary to install the component and dependencies. webcomponents.js adds support for web components and custom elements to your application. 16 | 17 | ## Getting Started 18 | 19 | First, install the component via bower on the command line. 20 | 21 | ``` 22 | bower install px-datetime-picker --save 23 | ``` 24 | 25 | Second, import the component to your application with the following tag in your head. 26 | 27 | ``` 28 | 29 | ``` 30 | 31 | Finally, use the component in your application: 32 | 33 | ``` 34 | 40 | 41 | ``` 42 | 43 |
44 |
45 | 46 | ## Documentation 47 | 48 | Read the full API and view the demo [here](https://predixdev.github.io/px-datetime-picker). 49 | 50 | The documentation in this repository is supplemental to the official Predix documentation, which is continuously updated and maintained by the Predix documentation team. Go to [http://predix.io](http://predix.io) to see the official Predix documentation. 51 | 52 | 53 | ## Local Development 54 | 55 | From the component's directory... 56 | 57 | ``` 58 | $ npm install 59 | $ bower install 60 | $ gulp sass 61 | ``` 62 | 63 | From the component's directory, to start a local server run: 64 | 65 | ``` 66 | $ gulp serve 67 | ``` 68 | 69 | Navigate to the root of that server (e.g. http://localhost:8080/) in a browser to open the API documentation page, with link to the "Demo" / working examples. 70 | 71 | 72 | 73 | 74 | ### GE Coding Style Guide 75 | [GE JS Developer's Guide](https://github.com/GeneralElectric/javascript) 76 | 77 |
78 |
79 | 80 | ## Known Issues 81 | 82 | Please use [Github Issues](https://github.com/PredixDev/px-datetime-picker/issues) to submit any bugs you might find. 83 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "px-datetime-picker", 3 | "version": "2.3.0", 4 | "main": [ 5 | "px-datetime-picker.html" 6 | ], 7 | "ignore": [ 8 | "*.enc", 9 | ".*", 10 | "node_modules", 11 | "bower_components", 12 | "sass", 13 | "HISTORY.md", 14 | "CONTRIBUTING.md", 15 | "OSS_Notice.pdf", 16 | "scripts", 17 | ".github", 18 | ".editorconfig", 19 | ".jshintrc", 20 | ".gitignore", 21 | "LICENSE.md", 22 | "gulpfile.js", 23 | "monogram-wdmk.png", 24 | "README.md", 25 | "wct.conf.json", 26 | "px-datetime-picker.png" 27 | ], 28 | "dependencies": { 29 | "polymer": "#1.9 - 2", 30 | "px-datetime-field": "^2.0.0", 31 | "px-calendar-picker": "^2.0.0", 32 | "px-datetime-common": "^3.3.0", 33 | "iron-a11y-keys-behavior": "^2.0.0", 34 | "iron-dropdown": "^2.0.0", 35 | "iron-media-query": "^2.0.0", 36 | "px-overlay": "^2.0.0" 37 | }, 38 | "devDependencies": { 39 | "px-theme": "^3.0.0", 40 | "px-demo": "^3.0.0", 41 | "px-normalize-design": "^1.0.0", 42 | "px-box-sizing-design": "^1.0.0", 43 | "px-helpers-design": "^1.0.0", 44 | "px-flexbox-design": "^1.0.0", 45 | "px-box-design": "^1.0.0", 46 | "px-actionable-design": "^2.0.0", 47 | "px-shadows-design": "^1.0.0", 48 | "px-spacing-design": "^1.0.0", 49 | "web-component-tester": "^6.3.0", 50 | "iron-test-helpers": "^2.0.0" 51 | }, 52 | "resolutions": { 53 | "webcomponentsjs": "^1.0.0" 54 | }, 55 | "variants": { 56 | "1.x": { 57 | "dependencies": { 58 | "polymer": "^1.9.0" 59 | }, 60 | "devDependencies": { 61 | "web-component-tester": "^5.0.0" 62 | }, 63 | "resolutions": { 64 | "webcomponentsjs": "^0.7.0" 65 | } 66 | } 67 | }, 68 | "license": "Apache-2.0" 69 | } -------------------------------------------------------------------------------- /css/px-datetime-picker-content-styles.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /css/px-datetime-picker-styles.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /demo/px-datetime-picker-demo.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 99 | 100 | 101 | 301 | -------------------------------------------------------------------------------- /demo/simple-demo-fit-element.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Predix UI 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 50 | 51 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /demo/simple_demo.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Predix UI 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 44 | 45 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /deploy.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/predixdesignsystem/px-datetime-picker/eb1d8867a9eced6fec2291f714cae0ef07a78de1/deploy.enc -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/predixdesignsystem/px-datetime-picker/eb1d8867a9eced6fec2291f714cae0ef07a78de1/favicon.ico -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (c) 2018, General Electric 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 'use strict'; 19 | const path = require('path'); 20 | const gulp = require('gulp'); 21 | const pkg = require('./package.json'); 22 | const $ = require('gulp-load-plugins')(); 23 | const gulpSequence = require('gulp-sequence'); 24 | const importOnce = require('node-sass-import-once'); 25 | const stylemod = require('gulp-style-modules'); 26 | const browserSync = require('browser-sync').create(); 27 | const gulpif = require('gulp-if'); 28 | const combiner = require('stream-combiner2'); 29 | const bump = require('gulp-bump'); 30 | const argv = require('yargs').argv; 31 | const exec = require('child_process').exec; 32 | const { ensureLicense } = require('ensure-px-license'); 33 | 34 | const sassOptions = { 35 | importer: importOnce, 36 | importOnce: { 37 | index: true, 38 | bower: true 39 | } 40 | }; 41 | 42 | gulp.task('clean', function() { 43 | return gulp.src(['.tmp', 'css'], { read: false }) 44 | .pipe($.clean()); 45 | }); 46 | 47 | function handleError(err) { 48 | console.log(err.toString()); 49 | this.emit('end'); 50 | } 51 | 52 | function buildCSS() { 53 | return combiner.obj([ 54 | $.sass(sassOptions), 55 | $.autoprefixer({ 56 | browsers: ['last 2 versions'], 57 | cascade: false, 58 | flexbox: false 59 | }), 60 | gulpif(!argv.debug, $.cssmin()) 61 | ]).on('error', handleError); 62 | } 63 | 64 | gulp.task('sass', function() { 65 | return gulp.src(['./sass/*.scss']) 66 | .pipe(buildCSS()) 67 | .pipe(stylemod({ 68 | moduleId(file) { 69 | return path.basename(file.path, path.extname(file.path)) + '-styles'; 70 | } 71 | })) 72 | .pipe(ensureLicense()) 73 | .pipe(gulp.dest('css')) 74 | .pipe(browserSync.stream({ match: 'css/*.html' })); 75 | }); 76 | 77 | gulp.task('watch', function() { 78 | gulp.watch(['sass/*.scss'], ['sass']); 79 | }); 80 | 81 | gulp.task('serve', function() { 82 | browserSync.init({ 83 | port: 8080, 84 | notify: false, 85 | reloadOnRestart: true, 86 | logPrefix: `${pkg.name}`, 87 | https: false, 88 | server: ['./', 'bower_components'], 89 | }); 90 | 91 | gulp.watch(['css/*-styles.html', '*.html', '*.js', 'demo/*.html']).on('change', browserSync.reload); 92 | gulp.watch(['sass/*.scss'], ['sass']); 93 | }); 94 | 95 | gulp.task('bump:patch', function() { 96 | gulp.src(['./bower.json', './package.json']) 97 | .pipe(bump({ type: 'patch' })) 98 | .pipe(gulp.dest('./')); 99 | }); 100 | 101 | gulp.task('bump:minor', function() { 102 | gulp.src(['./bower.json', './package.json']) 103 | .pipe(bump({ type: 'minor' })) 104 | .pipe(gulp.dest('./')); 105 | }); 106 | 107 | gulp.task('bump:major', function() { 108 | gulp.src(['./bower.json', './package.json']) 109 | .pipe(bump({ type: 'major' })) 110 | .pipe(gulp.dest('./')); 111 | }); 112 | 113 | gulp.task('license', function() { 114 | return gulp.src(['./**/*.{html,js,css,scss}', '!./node_modules/**/*', '!./bower_components?(-1.x)/**/*']) 115 | .pipe(ensureLicense()) 116 | .pipe(gulp.dest('.')); 117 | }); 118 | 119 | gulp.task('default', function(callback) { 120 | gulpSequence('clean', 'sass', 'generate-api', 'license')(callback); 121 | }); 122 | 123 | /** 124 | * Special task for Polymer component repos. Analyzes the component source code 125 | * and generates documentation in `[component-name]-api.json`. 126 | */ 127 | gulp.task('generate-api', function (cb) { 128 | exec(`node_modules/.bin/polymer analyze ${pkg.name}.html > ${pkg.name}-api.json`, function(err, stdout, stderr) { 129 | console.log(stdout); 130 | console.log(stderr); 131 | cb(err); 132 | }); 133 | }); 134 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Predix UI px-datetime-picker 23 | 24 | 28 | 57 | 58 | 61 | 62 | 63 | 66 | 67 | 68 | 69 | 70 | 71 | 75 | 80 | 81 | 84 | 85 | 86 | 89 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "px-datetime-picker", 3 | "author": "General Electric", 4 | "description": "A Px component allowing to pick a date using a calendar or by typing it", 5 | "version": "2.3.0", 6 | "private": false, 7 | "extName": null, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/PredixDev/px-datetime-picker.git" 11 | }, 12 | "homepage": "https://www.predix-ui.com/", 13 | "devDependencies": { 14 | "browser-sync": "^2.13.0", 15 | "ensure-px-license": "^1.0.0", 16 | "gulp": "^3.9.1", 17 | "gulp-autoprefixer": "^3.1.0", 18 | "gulp-bump": "^2.4.0", 19 | "gulp-clean": "^0.3.2", 20 | "gulp-concat": "^2.6.0", 21 | "gulp-cssmin": "^0.1.7", 22 | "gulp-if": "^2.0.1", 23 | "gulp-load-plugins": "^1.2.4", 24 | "gulp-match": "^1.0.2", 25 | "gulp-rename": "^1.2.2", 26 | "gulp-sass": "^4.0.1", 27 | "gulp-sequence": "^0.4.5", 28 | "gulp-style-modules": "^0.1.0", 29 | "node-sass-import-once": "^1.2.0", 30 | "polymer-cli": "^1.5.7", 31 | "stream-combiner2": "^1.1.1", 32 | "yargs": "^6.0.0" 33 | }, 34 | "license": "Apache-2.0" 35 | } 36 | -------------------------------------------------------------------------------- /px-datetime-picker-content.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 101 | 102 | 103 | 266 | -------------------------------------------------------------------------------- /px-datetime-picker.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 54 | 55 | 115 | 116 | 117 | 501 | -------------------------------------------------------------------------------- /sass/px-datetime-picker-content.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, General Electric 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // 18 | // Sass for the "sketch" notion of the px-datetime-picker component 19 | // 20 | // @author 21 | // 22 | 23 | /* 24 | THIS FILE SHOULD CONTAIN ONLY ABSTRACT/'SKETCH' THEME RULES, NOT SPECIFIC TO PREDIX BRANDING 25 | Predix branding rules go in px-datetime-picker-predix.scss, not in this file. 26 | */ 27 | 28 | 29 | 30 | // Generic 31 | @import "px-normalize-design/_generic.normalize.scss"; 32 | @import "px-box-sizing-design/_generic.box-sizing.scss"; 33 | @import "px-helpers-design/_generic.helpers.scss"; 34 | 35 | // Base 36 | 37 | //Objects 38 | @import 'px-actionable-design/_objects.actionable.scss'; 39 | @import "px-shadows-design/_objects.shadows.scss"; 40 | 41 | //Component 42 | 43 | /************************************* 44 | * Panel 45 | *************************************/ 46 | .dt-p-today { 47 | height: $inuit-base-spacing-unit--huge; 48 | width: 100%; 49 | } 50 | 51 | .dt-container__box { 52 | background-color: var(--px-datetime-picker-background-color, white); 53 | border: 1px solid var(--px-datetime-picker-border-color, lightgray); 54 | z-index: var(--px-datetime-picker-z-index, 300); 55 | padding: $inuit-base-spacing-unit--small $inuit-base-spacing-unit--large $inuit-base-spacing-unit--large; 56 | } 57 | 58 | .dt-p-buttons { 59 | display: flex; 60 | justify-content: flex-end; 61 | padding-top: $inuit-base-spacing-unit--large; 62 | } 63 | 64 | 65 | /************************************* 66 | * Fill Container 67 | *************************************/ 68 | :host([fill-container]) .dt-container__box { 69 | padding: 0; 70 | height: 100vh; 71 | display: flex; 72 | flex-direction: column; 73 | } 74 | 75 | :host([fill-container]) .dt-iron-dropdown { 76 | width:100%; 77 | } 78 | 79 | .dt-p__selected-date { 80 | text-align: center; 81 | } 82 | 83 | /* Only exists in fill-container */ 84 | .dt-p-time { 85 | --px-datetime-entry-font-size: calculateRem(30px); 86 | --px-datetime-field-height: calculateRem(40px); 87 | --px-btn-height: 1em; 88 | display: flex; 89 | justify-content: center; 90 | padding-top: $inuit-base-spacing-unit; 91 | padding-bottom: $inuit-base-spacing-unit; 92 | } 93 | 94 | :host([fill-container]) .dt-p-calendar__wrapper { 95 | padding: $inuit-base-spacing-unit--large; 96 | width: 100%; 97 | flex-grow: 1; 98 | overflow-y: auto; 99 | } 100 | 101 | :host([fill-container]) .dt-p-calendar { 102 | margin-left: auto; 103 | margin-right: auto; 104 | display: block; 105 | max-width: 500px; 106 | } 107 | 108 | :host([fill-container]) .dt-p-buttons { 109 | background-color: var(--px-datetime-picker-btn-container-background-color, lightgray); 110 | padding: $inuit-base-spacing-unit--small $inuit-base-spacing-unit--large; 111 | } 112 | 113 | // Trumps 114 | -------------------------------------------------------------------------------- /sass/px-datetime-picker.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, General Electric 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // 18 | // Sass for the "sketch" notion of the px-datetime-picker component 19 | // 20 | // @author 21 | // 22 | 23 | /* 24 | THIS FILE SHOULD CONTAIN ONLY ABSTRACT/'SKETCH' THEME RULES, NOT SPECIFIC TO PREDIX BRANDING 25 | Predix branding rules go in px-datetime-picker-predix.scss, not in this file. 26 | */ 27 | 28 | 29 | 30 | // Generic 31 | @import "px-normalize-design/_generic.normalize.scss"; 32 | @import "px-box-sizing-design/_generic.box-sizing.scss"; 33 | @import "px-helpers-design/_generic.helpers.scss"; 34 | 35 | // Base 36 | 37 | //Component 38 | px-datetime-field { 39 | display: inline-block; 40 | } 41 | -------------------------------------------------------------------------------- /scripts/ghp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit with nonzero exit code if anything fails 4 | set -e 5 | 6 | # ------------------------------------------------------------------------------ 7 | # CONFIGURE SCRIPT 8 | # ------------------------------------------------------------------------------ 9 | 10 | # Set our source branch (where we'll build from) and our target branch (where we 11 | # want to send the build page to) 12 | SOURCE_BRANCH="master" 13 | TARGET_BRANCH="gh-pages" 14 | REPO=`git config remote.origin.url` 15 | 16 | # Prep git credentials 17 | GIT_USER_NAME="Travis CI" 18 | GIT_USER_EMAIL="PredixtravisCI@ge.com" 19 | GIT_COMMIT_MESSAGE="[Travis] Rebuild documentation for Github Pages" 20 | 21 | # Check if we should run a deploy, or if we should skip it. Only commits to master 22 | # should trigger a build. Pull requests and commits to features branches should not. 23 | if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then 24 | echo "Skipping deploy; just doing a build." 25 | exit 0 26 | fi 27 | 28 | # ------------------------------------------------------------------------------ 29 | # PREPARE FILESYSTEM 30 | # ------------------------------------------------------------------------------ 31 | 32 | cd $TRAVIS_BUILD_DIR 33 | 34 | # Find out our repo name from the bower file 35 | REPO_NAME=$(grep "name" bower.json | sed 's/"name": "//' | sed 's/",//') 36 | echo "repo name is ${REPO_NAME}" 37 | 38 | #delete all the files! 39 | rm -rf node_modules 40 | rm -rf bower_components 41 | rm -rf css 42 | rm -rf sass 43 | rm -rf scripts 44 | rm -rf test 45 | rm -f *.html 46 | rm -f *.json 47 | rm -f *.enc 48 | rm -f *.js 49 | rm -f *.png 50 | rm -f *.lock 51 | rm -f *.ico 52 | rm -f *.md 53 | rm -f *.pdf 54 | yes | rm .travis.yml 55 | rm -f .bowerrc 56 | rm -f .editorconfig 57 | rm -rf .github 58 | rm -f .gitignore 59 | rm -f .jshintrc 60 | 61 | # force installation of bower packages at the root 62 | echo "{ \"directory\": \".\" }" > .bowerrc 63 | 64 | #make sure the deploy key isn't saved into the git repo 65 | echo "deploy_key" > .gitignore 66 | 67 | # add the redirect. 68 | # Note: We are not overwriting the component's documentation `index.html` file 69 | # here, we are making sure that http://url/px-something/ redirects to 70 | # http://url/px-something/px-something/, where the demo page is installed 71 | meta_temp='' 72 | echo ${meta_temp/'COMPONENT_NAME'/$REPO_NAME} > index.html 73 | 74 | # ------------------------------------------------------------------------------ 75 | # BOWER 76 | # ------------------------------------------------------------------------------ 77 | # 78 | #for some reason, bower isn't available here, so, install it globally, so it doesn't end up as another folder. 79 | npm install bower -g 80 | bower cache clean 81 | # Install the repo and the dark-theme. 82 | bower install ${REPO_NAME} px-dark-theme px-dark-demo-theme --force-latest 83 | 84 | #copy the bower file into our root 85 | yes | cp ${REPO_NAME}/bower.json bower.json 86 | 87 | #and run install 88 | bower install 89 | 90 | # ------------------------------------------------------------------------------ 91 | # BUILD PROJECT 92 | # ------------------------------------------------------------------------------ 93 | 94 | # Go into the component folder we've just installed from bower 95 | # cd ${REPO_NAME} 96 | 97 | # ------------------------------------------------------------------------------ 98 | # SW-PRECACHE 99 | # ------------------------------------------------------------------------------ 100 | 101 | # npm install sw-precache 102 | # sw-precache --root='.' --static-file-globs='**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff}' 103 | 104 | # ------------------------------------------------------------------------------ 105 | # GIT PUSH TO REMOTES 106 | # ------------------------------------------------------------------------------ 107 | 108 | # Remember to exit out of the component before we do any git stuff 109 | # cd ../ 110 | 111 | # Do the git stuff 112 | 113 | # checkout a new orphan 114 | git checkout --orphan $TARGET_BRANCH 115 | 116 | git add -A . > /dev/null 117 | echo "git add done" 118 | git commit -m "${GIT_COMMIT_MESSAGE}" --quiet 119 | echo "git commit done" 120 | 121 | # Set git credentials (defined in settings above) 122 | git config user.name ${GIT_USER_NAME} 123 | git config user.email ${GIT_USER_EMAIL} 124 | 125 | 126 | # We get the URL in this format: "https://github.com/PredixDev/px-something" 127 | # First, we need to replace https-style remote URL with a SSH-style remote 128 | # URL we can push to below 129 | SSH_GIT=${REPO/https:\/\/github.com\//git@github.com:} 130 | 131 | # Now, the URL is in this format: "git@github.com:PredixDev/px-something" 132 | # Next, replace `PredixDev` Github organization with `predix-ui` so configure 133 | # the correct remote to push to. 134 | # The resulting URL will be: "git@github.com:predix-ui/px-something" 135 | SSH_GIT_PREDIXUI=${SSH_GIT/:PredixDev\//:predix-ui\/} 136 | 137 | # Prepare ssh key, which we'll use to authenticate for SSH-push deploy 138 | eval `ssh-agent -s` 139 | # ... and change permissions for deploy key 140 | chmod 0400 $TRAVIS_BUILD_DIR/deploy_key 141 | 142 | # Push to predix-ui/repo `gh-pages` branch (force to override out-of-date refs) 143 | ssh-add $TRAVIS_BUILD_DIR/deploy_key 144 | git push $SSH_GIT_PREDIXUI $TARGET_BRANCH --force 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/px-datetime-picker-custom-tests.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (c) 2018, General Electric 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /******************************************************************************* 19 | * Without Buttons 20 | ******************************************************************************/ 21 | 22 | describe('px-datetime-picker no buttons', function () { 23 | var pickerEl; 24 | 25 | beforeEach(function (done) { 26 | pickerEl = fixture('datetime-picker'); 27 | 28 | flush(()=>{ 29 | setTimeout(function() { 30 | done(); 31 | }, 200); 32 | }); 33 | }); 34 | 35 | it('the calendar is hidden by default', function () { 36 | expect(pickerEl.opened).to.be.false; 37 | }); 38 | 39 | it('does not have time field', function () { 40 | 41 | var time = Polymer.dom(pickerEl.root).querySelector('#time'); 42 | expect(time === null).to.be.true; 43 | }); 44 | 45 | it('check that opened draws the panel for tests validity', function (done) { 46 | var panelEl = pickerEl.$.content.$.dropdown; 47 | expect(panelEl.offsetWidth, 'panel width before open').to.equal(0); 48 | expect(pickerEl.opened, 'panel is open').to.be.false; 49 | 50 | pickerEl.opened = true; 51 | 52 | panelEl = pickerEl.$.content.$.dropdown; 53 | async.until( 54 | ()=> { 55 | return panelEl.offsetWidth > 0; 56 | }, 57 | (callback)=> { 58 | setTimeout(callback, 50); 59 | }, 60 | ()=> { 61 | expect(panelEl.offsetWidth, 'panel width after open').to.be.within(230, 270); 62 | done(); 63 | } 64 | ); 65 | }); 66 | 67 | it('collapseAt set to 720 it will open full screen', function (done) { 68 | var panelEl = pickerEl.$.content.$.dropdown; 69 | pickerEl.collapseAt = 720; 70 | expect(panelEl.offsetWidth, 'panel width before open').to.equal(0); 71 | expect(pickerEl.opened, 'panel is open').to.be.false; 72 | pickerEl.opened = true; 73 | 74 | 75 | panelEl = pickerEl.$.content.$.dropdown; 76 | async.until( 77 | ()=> { 78 | console.log(pickerEl.opened) 79 | return panelEl.offsetWidth > 0; 80 | }, 81 | (callback)=> { 82 | setTimeout(callback, 50); 83 | }, 84 | ()=> { 85 | expect(panelEl.offsetWidth, 'panel width after open').to.be.within(450, 550); 86 | done(); 87 | } 88 | ); 89 | }); 90 | 91 | it('collapseAt set to null it never collapse', function (done) { 92 | var panelEl = pickerEl.$.content.$.dropdown; 93 | pickerEl.collapseAt = null; 94 | expect(panelEl.offsetWidth, 'panel width before open').to.equal(0); 95 | expect(pickerEl.opened, 'panel is open').to.be.false; 96 | pickerEl.opened = true; 97 | 98 | 99 | panelEl = pickerEl.$.content.$.dropdown; 100 | async.until( 101 | ()=> { 102 | console.log(pickerEl.opened) 103 | return panelEl.offsetWidth > 0; 104 | }, 105 | (callback)=> { 106 | setTimeout(callback, 50); 107 | }, 108 | ()=> { 109 | expect(panelEl.offsetWidth, 'panel width after open').to.be.within(230, 270); 110 | done(); 111 | } 112 | ); 113 | }); 114 | 115 | 116 | it('the calendar opens on _open function', function (done) { 117 | 118 | expect(pickerEl.opened, 'panel is not visible before open').to.be.false; 119 | pickerEl.$.content._open(); 120 | flush(() => { 121 | expect(pickerEl.opened, 'panel is visible after open').to.be.true; 122 | done(); 123 | }); 124 | }); 125 | 126 | 127 | it('the calendar opens when date icon is clicked', function (done) { 128 | //click on the date icon 129 | flush(() => { 130 | var fieldEl = Polymer.dom(pickerEl.root).querySelector('px-datetime-field'); 131 | var entryEl = Polymer.dom(fieldEl.root).querySelector('px-datetime-entry'); 132 | var dateIconEl = Polymer.dom(entryEl.root).querySelector('px-icon'); 133 | dateIconEl.click(); 134 | expect(pickerEl.opened, 'panel is visible').to.be.true; 135 | done(); 136 | }); 137 | }); 138 | 139 | 140 | it('host should propagate focus to the px-datetime-field', function () { 141 | var fieldEl = Polymer.dom(pickerEl.root).querySelector('px-datetime-field'); 142 | pickerEl.focus(); 143 | assert.equal(fieldEl, Polymer.dom(pickerEl.root).activeElement); 144 | }); 145 | 146 | 147 | //This should pass but there is a bug that needs to be fixed. 148 | it('focusing on the field doesn\'t close calendar when opened', function (done) { 149 | pickerEl.opened = true; 150 | 151 | expect(pickerEl.opened, 'panel is visible after open').to.be.true; 152 | var fieldEl = Polymer.dom(pickerEl.root).querySelector('px-datetime-field'); 153 | fieldEl.click(); 154 | 155 | flush( () => { 156 | setTimeout(function() { 157 | expect(pickerEl.opened, 'panel is visible after clicking on fieldEl').to.be.true; 158 | done(); 159 | }, 200); 160 | 161 | }); 162 | }); 163 | }); 164 | 165 | describe('px-datetime-picker no buttons with moment set', function () { 166 | var pickerEl; 167 | 168 | beforeEach(function (done) { 169 | pickerEl = fixture('datetime-picker'); 170 | pickerEl.momentObj = moment("2018-01-05T00:30:00.000Z").tz(pickerEl.timeZone); 171 | 172 | flush(()=>{ 173 | setTimeout(function() { 174 | done(); 175 | }, 200); 176 | }); 177 | }); 178 | 179 | it('Selecting a day will close panel and apply the value', function (done) { 180 | pickerEl.opened = true; 181 | 182 | flush( () => { 183 | expect(pickerEl.opened, 'panel is visible after open').to.be.true; 184 | expect(pickerEl.momentObj.toISOString(), 'dateTime value before selection').to.equal("2018-01-05T00:30:00.000Z"); 185 | 186 | var dropdownEl = pickerEl.$.content.$.dropdown, 187 | calendarEl = Polymer.dom(dropdownEl).querySelector('px-calendar-picker'), 188 | allCells = Polymer.dom(calendarEl.root).querySelectorAll('px-calendar-cell'); 189 | 190 | var btn = Polymer.dom(allCells[10].root).querySelector('button'); 191 | btn.click(); 192 | 193 | flush(() => { 194 | expect(pickerEl.opened, 'panel is visible after selection').to.be.false; 195 | expect(pickerEl.momentObj.toISOString(), 'dateTime value after selection').to.equal('2018-01-10T00:30:00.000Z'); 196 | done(); 197 | }); 198 | }); 199 | }); 200 | 201 | 202 | it('Selecting today will close panel and apply the value', function (done) { 203 | pickerEl.opened = true; 204 | 205 | flush( () => { 206 | expect(pickerEl.opened, 'panel is visible after open').to.be.true; 207 | expect(pickerEl.momentObj.toISOString(), 'dateTime value before selection').to.equal('2018-01-05T00:30:00.000Z'); 208 | 209 | var dropdownEl = pickerEl.$.content.$.dropdown, 210 | todayEl = Polymer.dom(dropdownEl).querySelector('.dt-p-today'); 211 | 212 | todayEl.click(); 213 | 214 | flush(function() { 215 | expect(pickerEl.opened, 'panel is visible after selection').to.be.false; 216 | 217 | //compare down to the day only cause clicking today will preserve previous time (00:30) 218 | expect(moment.tz().isSame(pickerEl.momentObj, 'day'), 'compare momentObj to now').to.be.true; 219 | 220 | done(); 221 | }); 222 | }); 223 | }); 224 | 225 | });//end of describe 'px-datetime-picker no button' 226 | 227 | 228 | 229 | /******************************************************************************* 230 | * With Buttons 231 | ******************************************************************************/ 232 | 233 | describe('px-datetime-picker with buttons', function () { 234 | var pickerEl, calendarEl, selectTenthDay; 235 | 236 | selectTenthDay = function (calendarEl) { 237 | var allCells = Polymer.dom(calendarEl.root).querySelectorAll('px-calendar-cell'); 238 | var btn = Polymer.dom(allCells[10].root).querySelector('button') 239 | btn.click(); 240 | } 241 | 242 | beforeEach(function (done) { 243 | pickerEl = fixture('datetime-picker-buttons'); 244 | calendarEl = pickerEl.$.content.$.calendar; 245 | pickerEl.momentObj = moment("2018-01-05T00:30:00.000Z").tz(pickerEl.timeZone); 246 | flush(()=>{ 247 | setTimeout(function() { 248 | done(); 249 | }, 200); 250 | }); 251 | }); 252 | 253 | 254 | it('Selecting a day will not close panel nor apply the value', function (done) { 255 | 256 | pickerEl.opened = true; 257 | 258 | flush(() => { 259 | 260 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'dateTime value'); 261 | 262 | selectTenthDay(calendarEl); 263 | 264 | flush(() => { 265 | 266 | expect(pickerEl.opened, 'pickerEl is open').to.be.true; 267 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'momentObj value'); 268 | done(); 269 | }); 270 | }); 271 | }); 272 | 273 | 274 | it('Selecting today will not close panel nor apply the value', function (done) { 275 | 276 | pickerEl.opened = true; 277 | 278 | flush(() => { 279 | expect(pickerEl.opened, 'panel is open before selection').to.be.true; 280 | expect(pickerEl.momentObj.toISOString(), 'check datetime has not changed').to.equal('2018-01-05T00:30:00.000Z'); 281 | 282 | var dropdownEl = pickerEl.$.content.$.dropdown, 283 | todayEl = Polymer.dom(dropdownEl).querySelector('.dt-p-today'); 284 | todayEl.click(); 285 | 286 | flush(() => { 287 | 288 | expect(pickerEl.opened, 'pickerEl is open').to.be.true; 289 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'momentObj value'); 290 | done(); 291 | }); 292 | }); 293 | }); 294 | 295 | 296 | it('pressing cancel cancels selection', function (done) { 297 | flush(() => { 298 | pickerEl.opened = true; 299 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'dateTime value'); 300 | 301 | selectTenthDay(calendarEl); 302 | 303 | var pickerButtons = Polymer.dom(pickerEl.$.content.root).querySelector('px-datetime-buttons'); 304 | cancelButton = Polymer.dom(pickerButtons.root).querySelector('button'); 305 | 306 | expect(cancelButton.id).to.equal('', 'make sure button is not the submit button'); 307 | cancelButton.click(); 308 | 309 | flush(() => { 310 | expect(pickerEl.opened, 'pickerEl is closed').to.be.false; 311 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'momentObj value'); 312 | done(); 313 | }); 314 | }); 315 | }); 316 | 317 | 318 | it('pressing Escape cancels selection', function (done) { 319 | flush(() => { 320 | pickerEl.opened = true; 321 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'dateTime value'); 322 | 323 | selectTenthDay(calendarEl); 324 | 325 | MockInteractions.pressAndReleaseKeyOn(pickerEl, undefined, [], 'Esc'); 326 | 327 | flush(() => { 328 | expect(pickerEl.opened, 'pickerEl is closed').to.be.false; 329 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'momentObj value'); 330 | done(); 331 | }); 332 | }); 333 | }); 334 | 335 | 336 | it('pressing the submit button applies selection', function (done) { 337 | flush(() => { 338 | pickerEl.opened = true; 339 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'dateTime value'); 340 | 341 | selectTenthDay(calendarEl); 342 | 343 | var pickerButtons = Polymer.dom(pickerEl.$.content.root).querySelector('px-datetime-buttons'); 344 | submit = Polymer.dom(pickerButtons.root).querySelector('#submitButton'); 345 | 346 | 347 | submit.click(); 348 | 349 | flush(() => { 350 | expect(pickerEl.opened, 'pickerEl is closed').to.be.false; 351 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-10T00:30:00.000Z', 'momentObj value'); 352 | done(); 353 | }); 354 | }); 355 | }); 356 | 357 | 358 | it('pressing enter applies selection', function (done) { 359 | flush(() => { 360 | pickerEl.opened = true; 361 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-05T00:30:00.000Z', 'dateTime value'); 362 | 363 | selectTenthDay(calendarEl); 364 | 365 | MockInteractions.pressAndReleaseKeyOn(pickerEl, undefined, [], 'Enter'); 366 | 367 | flush(() => { 368 | expect(pickerEl.opened, 'pickerEl is closed').to.be.false; 369 | expect(pickerEl.momentObj.toISOString()).to.equal('2018-01-10T00:30:00.000Z', 'momentObj value'); 370 | done(); 371 | }); 372 | }); 373 | }); 374 | 375 | });//end of describe 'px-datetime-picker with buttons' 376 | 377 | 378 | 379 | /******************************************************************************* 380 | * Time zones 381 | ******************************************************************************/ 382 | 383 | describe('synchronized date/time zones', function () { 384 | var pickerEl, fieldEl, calendarEl; 385 | 386 | beforeEach(function () { 387 | pickerEl = fixture('datetime-picker'); 388 | fieldEl = Polymer.dom(pickerEl.root).querySelector('px-datetime-field'); 389 | dropdownEl = pickerEl.$.content.$.dropdown; 390 | calendarEl = pickerEl.$.content.$.calendar; 391 | pickerEl.momentObj = moment("2018-01-05T00:30:00.000Z").tz(pickerEl.timeZone); 392 | }); 393 | 394 | 395 | it('calendar, field and datepicker have synchronized moment objects', function (done) { 396 | expect(pickerEl.momentObj.toISOString(), 'picker and field momentObj 1').to.equal(fieldEl.momentObj.toISOString()); 397 | expect(pickerEl.momentObj.toISOString(), 'picker and calendar momentObj 1').to.equal(calendarEl.fromMoment.toISOString()); 398 | 399 | done(); 400 | }); 401 | 402 | 403 | it('calendar, field and datepicker have synchronized time zones', function (done) { 404 | expect(pickerEl.timeZone, 'picker and field momentObj 1').to.equal(fieldEl.timeZone); 405 | expect(pickerEl.timeZone, 'picker and calendar momentObj 1').to.equal(calendarEl.timeZone); 406 | 407 | fieldEl.timeZone = 'America/Los_Angeles'; 408 | 409 | expect(pickerEl.timeZone, 'picker and field momentObj 2').to.equal(fieldEl.timeZone); 410 | expect(pickerEl.timeZone, 'picker and calendar momentObj 2').to.equal(calendarEl.timeZone); 411 | 412 | done(); 413 | }); 414 | 415 | 416 | });//end of describe 'synchronized date/time zones' 417 | 418 | 419 | /******************************************************************************* 420 | * Full Container 421 | ******************************************************************************/ 422 | describe('Full Container', function () { 423 | var pickerEl; 424 | var calendarEl; 425 | var fitEl; 426 | 427 | beforeEach(function (done) { 428 | templateEl = fixture('datetime-picker-full-container'); 429 | pickerEl = Polymer.dom(templateEl.root).querySelector('px-datetime-picker'); 430 | dropdownContentEl = Polymer.dom(pickerEl.$.content.root).querySelector('.dt-container__box'); 431 | fitEl = Polymer.dom(templateEl.root).querySelector('#fit'); 432 | pickerEl.fitIntoElement = fitEl; 433 | pickerEl.fillContainer = true; 434 | pickerEl.collapseAt = 0; 435 | pickerEl.momentObj = moment("2018-01-05T00:30:00.000Z").tz(pickerEl.timeZone); 436 | setTimeout(function() { 437 | done(); 438 | }, 200); 439 | }); 440 | 441 | it('the calendar is hidden by default', function () { 442 | expect(pickerEl.opened).to.be.false; 443 | }); 444 | 445 | it('check that the calendar fills the container when open', function (done) { 446 | 447 | expect(pickerEl.opened, 'panel is open').to.be.false; 448 | expect(dropdownContentEl.offsetWidth, 'panel width before open').to.equal(0); 449 | expect(dropdownContentEl.offsetWidth, 'panel width before open').to.equal(0); 450 | 451 | pickerEl.opened = true; 452 | 453 | async.until( 454 | ()=> { 455 | return dropdownContentEl.offsetWidth > 0; 456 | }, 457 | (callback)=> { 458 | setTimeout(callback, 50); 459 | }, 460 | ()=> { 461 | debugger 462 | expect(dropdownContentEl.offsetWidth, 'panel width after open').to.be.within(330, 355); 463 | expect(dropdownContentEl.offsetHeight, 'panel height after open').to.be.within(230, 255); 464 | done(); 465 | } 466 | ); 467 | }); 468 | 469 | it('has time field', function () { 470 | var time = Polymer.dom(pickerEl.$.content.root).querySelector('#time'); 471 | expect(time !== null).to.be.true; 472 | }); 473 | });//end of full container 474 | 475 | 476 | /******************************************************************************* 477 | * Full Window 478 | ******************************************************************************/ 479 | describe('Full window', function () { 480 | var pickerEl; 481 | var calendarEl; 482 | 483 | beforeEach(function (done) { 484 | pickerEl = fixture('datetime-picker-full-window'); 485 | dropdownContentEl = Polymer.dom(pickerEl.$.content.root).querySelector('.dt-container__box'); 486 | pickerEl.momentObj = moment("2018-01-05T00:30:00.000Z").tz(pickerEl.timeZone); 487 | setTimeout(function() { 488 | done(); 489 | }, 200); 490 | }); 491 | 492 | it('the calendar is hidden by default', function () { 493 | expect(pickerEl.opened).to.be.false; 494 | }); 495 | 496 | it('check that the calendar fills the window when open', function (done) { 497 | expect(pickerEl.opened, 'panel is open').to.be.false; 498 | expect(dropdownContentEl.offsetWidth, 'panel width before open').to.equal(0); 499 | expect(dropdownContentEl.offsetWidth, 'panel width before open').to.equal(0); 500 | 501 | pickerEl.opened = true; 502 | 503 | async.until( 504 | ()=> { 505 | return dropdownContentEl.offsetWidth > 0; 506 | }, 507 | (callback)=> { 508 | setTimeout(callback, 50); 509 | }, 510 | ()=> { 511 | expect(dropdownContentEl.offsetWidth, 'panel width after open').to.be.within((window.innerWidth - 20), window.innerWidth); 512 | expect(dropdownContentEl.offsetHeight, 'panel height after open').to.be.within((window.innerHeight - 20), window.innerHeight); 513 | done(); 514 | } 515 | ); 516 | }); 517 | 518 | it('does not have time field', function () { 519 | 520 | var time = Polymer.dom(pickerEl.$.content.root).querySelector('#time'); 521 | expect(time === null).to.be.true; 522 | }); 523 | });//end of full window 524 | 525 | -------------------------------------------------------------------------------- /test/px-datetime-picker-test-fixture.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Web Component Test : Fixture for px-datetime-picker 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 47 | 48 | 56 | 57 | 58 | 59 | 68 | 69 | 70 | 71 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /wct.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": false, 3 | "plugins": { 4 | "local": { 5 | "browsers": [ 6 | "chrome", 7 | "firefox" 8 | ] 9 | }, 10 | "sauce": { 11 | "disabled": true, 12 | "browsers": [ 13 | { 14 | "browserName": "microsoftedge", 15 | "platform": "Windows 10", 16 | "version": "" 17 | }, 18 | { 19 | "browserName": "internet explorer", 20 | "platform": "Windows 8.1", 21 | "version": "11" 22 | }, 23 | { 24 | "browserName": "safari", 25 | "platform": "OS X 10.11", 26 | "version": "10" 27 | }, 28 | { 29 | "browserName": "safari", 30 | "platform": "OS X 10.12", 31 | "version": "11" 32 | } 33 | ] 34 | } 35 | }, 36 | "suites": [ 37 | "test/index.html" 38 | ] 39 | } 40 | --------------------------------------------------------------------------------