Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,10 @@
{
"presets": [
"env",
"react",
"stage-2"
],
"plugins": [
"add-module-exports"
]
}

View File

@@ -0,0 +1 @@
master

View File

@@ -0,0 +1,8 @@
v3.1.2 - Mon, 06 Nov 2017 19:52:38 UTC
--------------------------------------
- [0f2bf9e](../../commit/0f2bf9e) [fixed] corretly walk when using TAB.
- [5cf9326](../../commit/5cf9326) Update README.md
- [cdcc1cb](../../commit/cdcc1cb) [chore]: fixed changelog generator.

View File

@@ -0,0 +1,50 @@
module.exports = {
"env": {
"es6": true,
"browser": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"settings": {
"react": {
"createClass": "createReactClass",
"pragma": "React",
"version": "15.0"
},
"propWrapperFunctions": [ "forbidExtraProps" ]
},
"extends": ["eslint:recommended", "plugin:react/recommended", "prettier"],
"plugins": ["prettier"],
"globals": {
"process": true
},
"rules": {
"quotes": [0],
"comma-dangle": [2, "only-multiline"],
"max-len": [1, {"code": 80}],
"no-unused-expressions": [0],
"no-continue": [0],
"no-plusplus": [0],
"func-names": [0],
"arrow-parens": [0],
"space-before-function-paren": [0],
"jsx-a11y/no-static-element-interactions": [0],
"prettier/prettier": "error",
"react/no-find-dom-node": [0],
"react/jsx-closing-bracket-location": [0],
"react/require-default-props": 0
}
}

View File

@@ -0,0 +1,18 @@
### Summary:
### Steps to reproduce:
1.
2.
3.
### Expected behavior:
### Link to example of issue:
<!--
Please create a Minimal, Complete, and Verifiable example
Sandbox starter: https://codesandbox.io/s/mgwy6V6E
-->
### Additional notes:

View File

@@ -0,0 +1,16 @@
Fixes #[issue number].
Changes proposed:
-
-
-
Upgrade Path (for changed or removed APIs):
Acceptance Checklist:
- [ ] All commits have been squashed to one.
- [ ] The commit message follows the guidelines in `CONTRIBUTING.md`.
- [ ] Documentation (README.md) and examples have been updated as needed.
- [ ] If this is a code change, a spec testing the functionality has been added.
- [ ] If the commit message has [changed] or [removed], there is an upgrade path above.

View File

@@ -0,0 +1,9 @@
language: node_js
node_js:
- "8"
cache: yarn
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- make tests-ci

View File

@@ -0,0 +1 @@
3.1.2

View File

@@ -0,0 +1,651 @@
v3.1.2 - Mon, 06 Nov 2017 19:52:38 UTC
--------------------------------------
- [0f2bf9e](../../commit/0f2bf9e) [fixed] corretly walk when using TAB.
- [5cf9326](../../commit/5cf9326) Update README.md
- [cdcc1cb](../../commit/cdcc1cb) [chore]: fixed changelog generator.
v3.1.0 - Wed, 25 Oct 2017 14:26:17 UTC
--------------------------------------
- [42d724c](../../commit/42d724c) [added] shouldReturnFocusAfterClose to control focus.
- [400ac13](../../commit/400ac13) [chore] make sure all tests meet line-length requirement.
- [18a15eb](../../commit/18a15eb) [fixed] correct property name shouldFocusAfterRender.
v3.0.4 - Wed, 18 Oct 2017 19:52:46 UTC
--------------------------------------
- [1fb33d9](../../commit/1fb33d9) [chore] run tests only on node 8.
- [59fbdb3](../../commit/59fbdb3) [chore] specifiy the object when overriding class names.
v3.0.3 - Sat, 14 Oct 2017 17:37:10 UTC
--------------------------------------
-
v3.0.2 - Sat, 14 Oct 2017 12:03:32 UTC
--------------------------------------
- [d98f091](../../commit/d98f091) [chore] update CHANGELOG.md
- [95f628a](../../commit/95f628a) [chore] fix prettier linting after merge issue
- [47d0d87](../../commit/47d0d87) [chore] prettier all the things
- [c0620e0](../../commit/c0620e0) [chore] Use babel-preset-env instead of babel-preset-es2015
- [2a05bd8](../../commit/2a05bd8) [chore] Updated eslint and a few related deps
- [b3701f6](../../commit/b3701f6) [fixed] Issue #526 Import PropTypes as default import.
v3.0.0 - Fri, 06 Oct 2017 13:29:20 UTC
--------------------------------------
- [a2a7128](../../commit/a2a7128) Release v3.0.0.
- [d0f242b](../../commit/d0f242b) Merged next into master.
- [de3c039](../../commit/de3c039) [chore] remove warning about injectCSS.
- [f77b53e](../../commit/f77b53e) [chore] use canUseDOM from exenv.
- [cc4577c](../../commit/cc4577c) Release 3.0.0-rc2.
- [1260850](../../commit/1260850) [fixed] backward compatibility with previous react versions.
- [45ca9d4](../../commit/45ca9d4) Release v3.0.0-rc1.
- [d25563c](../../commit/d25563c) [fixed] check for both window and document.createElement.
- [2b835d6](../../commit/2b835d6) [fixed] typeof returns a string (canUseDOM).
- [cd10612](../../commit/cd10612) Release v3.0.0-alpha.
- [b942504](../../commit/b942504) [feature] initial support for react 16.
v2.4.1 - Fri, 06 Oct 2017 13:23:42 UTC
--------------------------------------
- [4fa5628](../../commit/4fa5628) [fixed] Drag stop (mouseup) on Overlay closes Modal
- [a712d88](../../commit/a712d88) [chore] update README.md installation for react 16 support.
- [f9a2f3f](../../commit/f9a2f3f) [chore] update README.md.
v2.3.3 - Wed, 04 Oct 2017 01:59:30 UTC
--------------------------------------
- [876972b](../../commit/876972b) [chore] removed depencendy 'react-dom-factory'.
- [73db6dd](../../commit/73db6dd) [chore] improve examples style.
- [8970956](../../commit/8970956) [chore] remove code climate yml.
- [d896241](../../commit/d896241) [chore] fix multiple modal example.
- [ce2b34e](../../commit/ce2b34e) [chore] added example with react-router.
- [16c3dce](../../commit/16c3dce) [chore] update dependencies, lint rules and refactor tests.
- [13dfc4e](../../commit/13dfc4e) [chore] update tests.
- [ba81894](../../commit/ba81894) Remove required flag from contentLabel propType in Modal
- [f007aeb](../../commit/f007aeb) [chore] Update description for onRequestClose.
v2.3.2 - Wed, 06 Sep 2017 16:09:58 UTC
--------------------------------------
- [ba526cf](../../commit/ba526cf) [chore] fix changelog generator.
v2.3.1 - Tue, 05 Sep 2017 16:18:41 UTC
--------------------------------------
- [93256e9](../../commit/93256e9) [added] Don't focus after render if we don't want to
- [2adb45d](../../commit/2adb45d) [chore] update readme syntax flavour to jsx
v2.2.4 - Mon, 14 Aug 2017 09:41:39 UTC
--------------------------------------
- [fafa127](../../commit/fafa127) typo fix
- [fe1983b](../../commit/fe1983b) fix #466: Dragging inside modal and release outside of modal closes the modal
- [825fd00](../../commit/825fd00) Release v2.2.3.
- [1caabed](../../commit/1caabed) [fixed] `Uncaught TypeError: Cannot read property 'state' of null` when unmouting
- [92c23b5](../../commit/92c23b5) [chore] Mention shouldCloseOnOverlayClick dependency
- [a2d5c4e](../../commit/a2d5c4e) [chore] allow latest version for exenv dependency
v2.2.2 - Tue, 11 Jul 2017 14:20:29 UTC
--------------------------------------
- [9076eb7](../../commit/9076eb7) [added] Support using multiple document.body classes
- [581be77](../../commit/581be77) [chore] added test for default parentSelector.
- [e56c414](../../commit/e56c414) [chore] Return null for portal when modal is closed
v2.2.1 - Fri, 30 Jun 2017 09:22:10 UTC
--------------------------------------
- [7301aa7](../../commit/7301aa7) [chore] Change 'a11y' to 'accessibility' in README.md
- [f47e79d](../../commit/f47e79d) [fixed] Modal.removePortal not called when using closeTimeoutMS
- [f386aa4](../../commit/f386aa4) [chore] added more examples.
v2.2.0 - Wed, 28 Jun 2017 18:56:24 UTC
--------------------------------------
- [67ee9f5](../../commit/67ee9f5) [added] allow users to pass aria-* attribute.
- [6f73764](../../commit/6f73764) [chore] update installation documentation.
v2.1.0 - Mon, 26 Jun 2017 22:11:54 UTC
--------------------------------------
- [1baebf4](../../commit/1baebf4) [change] Track open body className appropriately
v2.0.7 - Sun, 25 Jun 2017 17:44:29 UTC
--------------------------------------
- [d1fe05e](../../commit/d1fe05e) [chore] use local babel instead of requiring a global installation.
- [bb69a91](../../commit/bb69a91) [chore] improvements on readme testing section.
- [c2f582f](../../commit/c2f582f) [chore] fix typo.
- [f8edc2b](../../commit/f8edc2b) [fixed] improvements on setAppElement...
- [5641f40](../../commit/5641f40) [chore] update installation section.
- [ae258ec](../../commit/ae258ec) [chore] removing active development section.
- [f5d95e2](../../commit/f5d95e2) Add codesandbox link to the ISSUE_TEMPLATE
v2.0.6 - Tue, 20 Jun 2017 11:23:30 UTC
--------------------------------------
- [1676259](../../commit/1676259) removing trailing space. (#2)
- [07a2753](../../commit/07a2753) [fixed] check if the modal content is available when async update... (#1)
- [cb6504c](../../commit/cb6504c) [fixed] Use bound ref functions
- [7da6ec8](../../commit/7da6ec8) [fix] Unnecessary renders when modal is closed
- [648cc2f](../../commit/648cc2f) [fixed] update script path on bootstrap example.
- [6c780ae](../../commit/6c780ae) Update react-addons-test-utils to react-dom/test-utils
- [385a8eb](../../commit/385a8eb) Update react dependencies
- [8480042](../../commit/8480042) [chore] cache yarn when running on travis-ci.
- [8d87599](../../commit/8d87599) [chore] added documentation for development.
- [aaeb310](../../commit/aaeb310) [chore] added patterns on .gitignore.
- [4ec7184](../../commit/4ec7184) [chode] Add table of contents
- [96fdb90](../../commit/96fdb90) [chore] don't test on node versions < 6.x.y.
- [20fcdc3](../../commit/20fcdc3) [chore] update README.md.
- [4b57b2a](../../commit/4b57b2a) [chore] added script to regenerate all the changelog.
- [21dc212](../../commit/21dc212) [chore] ask before publishing...
- [2af9b89](../../commit/2af9b89) chore] improve publish docs commands.
v2.0.2 - Fri, 16 Jun 2017 13:10:06 UTC
--------------------------------------
- [c1dc7fd](../../commit/c1dc7fd) change PropTypes.String to PropTypes.string
v2.0.1 - Fri, 16 Jun 2017 11:30:58 UTC
--------------------------------------
- [435ab91](../../commit/435ab91) Update eslint config so it should pass
- [b1a28a4](../../commit/b1a28a4) remove yarn.lock per comment
- [389a8fa](../../commit/389a8fa) Address review comments
- [ab11c36](../../commit/ab11c36) [fixed] removing 'es' for now.
- [2f0a1a9](../../commit/2f0a1a9) [fixed] added rules to compile on Makefile.
- [e921de8](../../commit/e921de8) [fixed] use the correct babel presets combination.
- [92ccf1d](../../commit/92ccf1d) Additional changes to support move from src to lib
- [138f8ef](../../commit/138f8ef) Remove unnecessary comma
- [e36336a](../../commit/e36336a) Update yarn.lock
- [d08b96e](../../commit/d08b96e) Create es and commonjs separate build steps
- [d024d3a](../../commit/d024d3a) Transform based on env
- [4704fa7](../../commit/4704fa7) Remove unnecessary react-create-class dependency
- [a6422f6](../../commit/a6422f6) Use ES module for top level export
- [c05e88d](../../commit/c05e88d) Move lib to src so we can use lib for build output
v2.0.0 - Thu, 15 Jun 2017 18:16:21 UTC
--------------------------------------
- [0374b6b](../../commit/0374b6b) [chore] update makefile to run coverage.
- [ba2c124](../../commit/ba2c124) [chore] passing lint...
- [a5cc01b](../../commit/a5cc01b) Use callback ref in readme
- [933f3a4](../../commit/933f3a4) Modify the sample code to es2015 syntax in README.md (#295)
- [8059ded](../../commit/8059ded) Updates License (#303)
- [315d1e1](../../commit/315d1e1) Add code climate and code coverage
- [1c326a1](../../commit/1c326a1) Add Linting (#293)
- [d2fbe55](../../commit/d2fbe55) [chore] added babel stage-2 preset.
v1.9.7 - Thu, 15 Jun 2017 13:28:17 UTC
--------------------------------------
- [df14528](../../commit/df14528) Added cross-env to run tests on windows
v1.9.6 - Thu, 15 Jun 2017 00:57:18 UTC
--------------------------------------
- [91e1a67](../../commit/91e1a67) Remove deprecation warning in react 15.6.0 about React.DOM.noscript
- [937f835](../../commit/937f835) [chore] removing unnecessary file.
v1.9.5 - Wed, 14 Jun 2017 22:57:03 UTC
--------------------------------------
- [3139e85](../../commit/3139e85) [added] refresh portalClassName on componentWillUpdate
v1.9.4 - Tue, 13 Jun 2017 10:12:34 UTC
--------------------------------------
- [0510f62](../../commit/0510f62) Add gzip size badge
v1.9.3 - Tue, 13 Jun 2017 09:21:26 UTC
--------------------------------------
- [28ecc0b](../../commit/28ecc0b) [fixed] compatibility with unstable_handleError.
v1.9.2 - Mon, 12 Jun 2017 21:05:11 UTC
--------------------------------------
- [a61f73c](../../commit/a61f73c) fix react proptypes warning
v1.9.1 - Mon, 12 Jun 2017 16:27:34 UTC
--------------------------------------
- [a12246e](../../commit/a12246e) [changed] use object className and overlayClassName prop to override...
v1.8.1 - Mon, 12 Jun 2017 12:37:12 UTC
--------------------------------------
- [e5bb415](../../commit/e5bb415) [change] allow to customize the react-modal document.body open class.
v1.7.13 - Mon, 12 Jun 2017 10:26:34 UTC
---------------------------------------
- [3bc4719](../../commit/3bc4719) [chore] refactoring tests...
v1.7.12 - Fri, 09 Jun 2017 22:27:37 UTC
---------------------------------------
- [4b69478](../../commit/4b69478) [chore] clean publish resources before start...
- [00ea6fe](../../commit/00ea6fe) [chore] refactor and clean up build system.
v1.7.11 - Thu, 08 Jun 2017 16:47:56 UTC
---------------------------------------
- [a3f69d5](../../commit/a3f69d5) [chore] add travis ci build status on README.md.
v1.7.10 - Thu, 08 Jun 2017 16:43:41 UTC
---------------------------------------
- [651ce99](../../commit/651ce99) [chore] prevent publish if an error occur.
v1.7.9 - Thu, 08 Jun 2017 12:59:39 UTC
--------------------------------------
- [99c7e32](../../commit/99c7e32) [fixed] use Object.assign for now.
v1.7.8 - Thu, 08 Jun 2017 01:45:46 UTC
--------------------------------------
- [14a2fd0](../../commit/14a2fd0) [chore] improving build and publish pipeline.
v1.7.7 - Tue, 18 Apr 2017 07:40:29 UTC
--------------------------------------
- [889ffde](../../commit/889ffde) [fixed] Removed additional es2015 causing problems
v1.7.6 - Thu, 13 Apr 2017 08:41:16 UTC
--------------------------------------
- [048ef2d](../../commit/048ef2d) [fixed] remove additional es2015 from refCount
v1.7.5 - Thu, 13 Apr 2017 08:20:34 UTC
--------------------------------------
- [1db0ee1](../../commit/1db0ee1) [fixed] remove es2015 from v1 branch
v1.7.4 - Thu, 13 Apr 2017 07:37:19 UTC
--------------------------------------
- [86987d5](../../commit/86987d5) Use create-react-class to avoid React.createClass deprecations
- [16efd72](../../commit/16efd72) Use prop-types
- [e579a0d](../../commit/e579a0d) [fix] keep references of modals.
v1.7.3 - Mon, 13 Mar 2017 19:22:00 UTC
--------------------------------------
- [e1df119](../../commit/e1df119) [fixed] remove portal context in timeout (#353)
v1.7.2 - Wed, 08 Mar 2017 20:59:52 UTC
--------------------------------------
- [185f2b0](../../commit/185f2b0) Remove .bind(this) from removePortal call
v1.7.1 - Thu, 02 Mar 2017 07:49:30 UTC
--------------------------------------
- [a1d29c6](../../commit/a1d29c6) [fixed] rewrite removePortal as es5 function
v1.7.0 - Wed, 01 Mar 2017 20:54:08 UTC
--------------------------------------
- [fb3eb5e](../../commit/fb3eb5e) [chore] use afterEach to cleanup modals automatically.
- [ea4f37a](../../commit/ea4f37a) [fixed] respect closeTimeoutMS during unmount
- [f6768b7](../../commit/f6768b7) [change] improve reliability on focus management.
- [4232477](../../commit/4232477) [fixed] Enable click to close in iOS (#301) (#304) (#313)
v1.6.5 - Sat, 31 Dec 2016 10:14:28 UTC
--------------------------------------
- [c50f19a](../../commit/c50f19a) [fixed] Add file extention to entry point (#294)
- [f22c206](../../commit/f22c206) Add v2 development info
- [426f5e4](../../commit/426f5e4) Update testing setup
- [945919d](../../commit/945919d) Ignore the _book directory
- [ff23603](../../commit/ff23603) Move documentation site to GitBook
- [08bf920](../../commit/08bf920) [fixed] closeTimeoutMS doesn't work without onRequestClose (#278)
- [6c68e95](../../commit/6c68e95) Update CHANGELOG.md
v1.6.4 - Wed, 14 Dec 2016 22:48:59 UTC
--------------------------------------
- [ad0b071](../../commit/ad0b071) Bumps lodash.assign to 4.2.0 (#277)
- [694cb87](../../commit/694cb87) [fixed] updated references from rackt to reactjs. (#244)
- [1dea51d](../../commit/1dea51d) Update travis build matrix
- [e50dc70](../../commit/e50dc70) Update CHANGELOG.md
v1.6.3 - Mon, 12 Dec 2016 07:03:43 UTC
--------------------------------------
- [a2e5952](../../commit/a2e5952) [docs] added required props info to README (#274)
- [f460c10](../../commit/f460c10) Update CHANGELOG.md
v1.6.2 - Sun, 11 Dec 2016 10:32:03 UTC
--------------------------------------
-
v1.6.1 - Tue, 06 Dec 2016 10:16:10 UTC
--------------------------------------
- [62d87e1](../../commit/62d87e1) [fixed] Remove arrow function from ES5 source
v1.6.0 - Tue, 06 Dec 2016 08:09:25 UTC
--------------------------------------
- [de14816](../../commit/de14816) [added] Ability for modal to be appended to arbitrary elements (#183)
- [3fdc672](../../commit/3fdc672) Ensure aria-hidden on appElement is reset on unmount
- [e9fd43d](../../commit/e9fd43d) Document ReactModal__Body--open so people dare to use it
- [3d8e5a0](../../commit/3d8e5a0) [added] Add contentLabel prop to put aria-label on modal content
v1.5.2 - Sat, 08 Oct 2016 08:29:09 UTC
--------------------------------------
- [d78428b](../../commit/d78428b) [fixed] Remove remaining reference to role dialog
- [b09cdf9](../../commit/b09cdf9) Update CHANGELOG.md
v1.5.1 - Fri, 07 Oct 2016 22:11:39 UTC
--------------------------------------
-
v1.5.0 - Fri, 07 Oct 2016 20:18:52 UTC
--------------------------------------
- [919daa3](../../commit/919daa3) [fixed] Remove the default aria role dialog
- [c8106f2](../../commit/c8106f2) Update ModalPortal.js (#228)
- [2e806c7](../../commit/2e806c7) [added] Make modal portal have the dialog role (#223)
- [abe88a8](../../commit/abe88a8) installation instructions (#227)
- [5429f7c](../../commit/5429f7c) [fixed] Don't steal focus from a descendent when rendering (#222)
- [8e767e9](../../commit/8e767e9) [fixed] Add react-dom as a peer dependency
- [ff09b49](../../commit/ff09b49) [fixed] Close modal when mouseDown and MouseUp happen only on the overlay (#217)
- [6550b87](../../commit/6550b87) Revert "[fixed] Dont change body class if isOpen not change (#201)"
- [8e5f5b7](../../commit/8e5f5b7) [fixed] Fix incorrect details in the README
- [e5b0181](../../commit/e5b0181) [added] ability to change default 'ReactModalPortal' class (#208)
- [1e29e4f](../../commit/1e29e4f) [fixed] Dont change body class if isOpen not change (#201)
- [d347547](../../commit/d347547) [fixed] Updates webpack distribution config to reference the correct externals (#210)
- [f0933fd](../../commit/f0933fd) [doc] fix onRequestClose callback in Usage (#195)
v1.4.0 - Thu, 30 Jun 2016 13:12:02 UTC
--------------------------------------
- [13bd46e](../../commit/13bd46e) [fixed] clear the delayed close timer when modal opens again. (#189)
- [70d91eb](../../commit/70d91eb) [fixed] Add missing envify npm dependency. Closes #193 (#194)
v1.3.0 - Tue, 17 May 2016 10:04:50 UTC
--------------------------------------
- [9089a2d](../../commit/9089a2d) [fixed] Make the modal portal render into body again (#176)
- [e9aff7a](../../commit/e9aff7a) Update PULL_REQUEST_TEMPLATE.md
v1.2.1 - Sat, 23 Apr 2016 13:09:46 UTC
--------------------------------------
- [aa66819](../../commit/aa66819) [fixed] Removes unneeded sanitizeProps function (#169)
v1.2.0 - Thu, 21 Apr 2016 16:02:02 UTC
--------------------------------------
- [18f5eae](../../commit/18f5eae) fix typo in README :memo: (#168)
- [a10683a](../../commit/a10683a) [fixed] Make the non-minified dist build present again (#164)
- [04db149](../../commit/04db149) [added] Propagate event on close request (#91)
v1.1.2 - Mon, 18 Apr 2016 20:36:05 UTC
--------------------------------------
- [4509133](../../commit/4509133) [fixed] moved sanitizeProps out of the render calls. (#162)
- [25c1dad](../../commit/25c1dad) Update changelog for 1.1.1
v1.1.1 - Thu, 14 Apr 2016 23:30:45 UTC
--------------------------------------
- [f1555d9](../../commit/f1555d9) Merge branch 'development-improvements'
- [9823bc5](../../commit/9823bc5) Use -p flag in webpack for minification and exclude externals react and react-dom (#159)
- [72c8498](../../commit/72c8498) Move to using webpack for building the library
v1.1.0 - Tue, 12 Apr 2016 07:03:08 UTC
--------------------------------------
- [6c03d17](../../commit/6c03d17) [added] trigger onAfterOpen callback when available. (#154)
- [7cf8463](../../commit/7cf8463) [doc] Update docs to include details about CSS classes
v1.0.0 - Fri, 08 Apr 2016 23:03:25 UTC
--------------------------------------
- [7af8ee5](../../commit/7af8ee5) Update README.md to include testing gotchas (#136)
- [e4be332](../../commit/e4be332) Add extra information for contributors (#143)
- [4e2447a](../../commit/4e2447a) [changed] Updated to add support for React 15 (#152)
- [0d4e600](../../commit/0d4e600) [added] module for default style
- [cf70338](../../commit/cf70338) Avoid stopPropagation
- [f9871c6](../../commit/f9871c6) Merge pull request #94 from apprennet/remove-body-class-unmount
- [cb53bca](../../commit/cb53bca) [fixed] Remove ReactModal__Body--open class when unmounting Modal
- [fe46c63](../../commit/fe46c63) Merge pull request #108 from evoyy/pr/override-anchor-to-document-body
- [b5e38cf](../../commit/b5e38cf) Merge pull request #141 from everdimension/fix-no-tabbable-focus
- [c844719](../../commit/c844719) keep focus on modal if no tabbable elements are within it
- [e8749dd](../../commit/e8749dd) Merge pull request #128 from dorsha/master
- [93c73f3](../../commit/93c73f3) Merge pull request #140 from everdimension/add_missing_webpack_dependency
- [d732041](../../commit/d732041) add missing webpack devDependency
- [6282c3e](../../commit/6282c3e) Added the ability to decide whether the modal should be closed when clicking the overlay area. This is an important ability since in some cases we don't want the modal to be closed when users are clicking outside. Added tests and README instructions.
- [23eee3b](../../commit/23eee3b) Merge pull request #120 from evoyy/pr/bugfix_empty_tabbable_array
- [471ef4c](../../commit/471ef4c) Handle case when no tabbable element exists
- [c13fed9](../../commit/c13fed9) Restore Modal.setAppElement() functionality
- [06ebde2](../../commit/06ebde2) Merge pull request #121 from evoyy/pr/listen-on-all-interfaces
- [597882d](../../commit/597882d) Merge pull request #123 from evoyy/pr/fix_example_css_for_firefox
- [980ad5d](../../commit/980ad5d) Merge pull request #132 from shunjikonishi/shunjikonishi-patch-1
- [bc58b9c](../../commit/bc58b9c) Merge pull request #100 from claydiffrient/bugfix/classes-take-precedence
- [ef02e29](../../commit/ef02e29) Prevent default behavior of ESC key
- [7f631bd](../../commit/7f631bd) Update README.md
- [aac1841](../../commit/aac1841) CSS transform for non-Webkit browsers
- [3e89412](../../commit/3e89412) dev server listens on all interfaces
- [63bee72](../../commit/63bee72) [fixed] Custom classnames override default styles
v0.6.1 - Fri, 23 Oct 2015 12:03:54 UTC
--------------------------------------
- [e20595e](../../commit/e20595e) Merge pull request #87 from flskif/master
- [5705b85](../../commit/5705b85) Ignore react-dom in build
v0.6.0 - Wed, 21 Oct 2015 15:39:48 UTC
--------------------------------------
- [cd4dd21](../../commit/cd4dd21) Merge pull request #85 from miracle2k/master
- [5c59b9f](../../commit/5c59b9f) Use renderSubtreeIntoContainer to keep context.
- [c7153d1](../../commit/c7153d1) Merge pull request #84 from existentialism/typos
- [78fa9bd](../../commit/78fa9bd) fix a couple typos
- [acdcb7c](../../commit/acdcb7c) Merge pull request #83 from roth1002/feature/react-14
- [4b3b885](../../commit/4b3b885) move exenv to dependencies
- [c107d02](../../commit/c107d02) Merge pull request #81 from roth1002/feature/react-14
- [7e12d8a](../../commit/7e12d8a) Modify spec Readme.md example to use ReactDOM.render to replace React.render
- [496bb0b](../../commit/496bb0b) upgrade react 0.14
- [920d421](../../commit/920d421) Merge pull request #70 from dinodsaurus/master
- [4c8ed91](../../commit/4c8ed91) imporved env check
- [33d47db](../../commit/33d47db) added suport for isomorphic rendering
v0.5.0 - Tue, 22 Sep 2015 13:19:44 UTC
--------------------------------------
- [408329f](../../commit/408329f) Updating dependencies
- [b24bc4b](../../commit/b24bc4b) Merge pull request #65 from web2style/master
- [6b50f7b](../../commit/6b50f7b) Merge pull request #58 from jackofseattle/fix/NoMoreInjectCSS
- [4d25989](../../commit/4d25989) [added] Inline CSS for modal and overlay as well as props to override. [changed] injectCSS has been changed to a warning message in preperation for a future removal. lib/components/Modal.js [changed] setAppElement method is now optional. Defaults to document.body and now allows for a css selector to be passed in rather than the whole element.
- [acd3c65](../../commit/acd3c65) Merge pull request #53 from ewiner/master
- [9e092ae](../../commit/9e092ae) Merge pull request #52 from DelvarWorld/noscript
- [8ccf23a](../../commit/8ccf23a) Merge pull request #63 from basarat/patch-1
- [9bd8f68](../../commit/9bd8f68) Update peerDependencies
- [9545427](../../commit/9545427) :memo: link to demos
- [02cf2c3](../../commit/02cf2c3) [fixed] Clear the closeWithTimeout timer before unmounting
- [85a13b8](../../commit/85a13b8) Returning noscript tag instead of null
- [0d5e76a](../../commit/0d5e76a) Updating README
v0.3.0 - Wed, 15 Jul 2015 00:17:24 UTC
--------------------------------------
- [adecf62](../../commit/adecf62) [added] Class name on body when modal is open
- [0e94233](../../commit/0e94233) Updating dependencies
- [3938e55](../../commit/3938e55) Merge pull request #42 from claydiffrient/patch-1
- [669f3a8](../../commit/669f3a8) Merge pull request #39 from wisely0515/ie8-support
- [fbb07d4](../../commit/fbb07d4) Moves classnames to dependencies
- [278b9ba](../../commit/278b9ba) fixed 'unknow runtime error' ie IE8
v0.2.0 - Fri, 08 May 2015 23:16:40 UTC
--------------------------------------
- [1a51bf8](../../commit/1a51bf8) Merge pull request #31 from maisano/patch-1
- [494d7d2](../../commit/494d7d2) Merge pull request #28 from peterjmag/use-classnames-module
- [e06e801](../../commit/e06e801) Merge pull request #22 from misuba/bugfix/server-clean
- [1829f43](../../commit/1829f43) Merge pull request #27 from claydiffrient/master
- [e898b6b](../../commit/e898b6b) Check if modalElement exists in handleFocus.
- [930c4ca](../../commit/930c4ca) Use classnames instead of react/lib/cx.
- [f5fe537](../../commit/f5fe537) [added] Ability to specify style for the modal contents
- [6887b00](../../commit/6887b00) Shim the possibly-absent HTMLElement
v0.1.1 - Tue, 31 Mar 2015 09:56:47 UTC
--------------------------------------
- [bb57045](../../commit/bb57045) Merge pull request #19 from amccloud/patch-2
- [10e9582](../../commit/10e9582) Merge pull request #18 from amccloud/patch-1
- [f86de0a](../../commit/f86de0a) [fixed] shift+tab closes #23
- [bb218ca](../../commit/bb218ca) ignore node_modules
- [c464368](../../commit/c464368) Check for addEventListener before tying to use to support IE 8
- [63b6828](../../commit/63b6828) Remove trailing commas for IE8 support
v0.1.0 - Thu, 26 Feb 2015 10:14:27 UTC
--------------------------------------
- [db8b725](../../commit/db8b725) Merge pull request #16 from arasmussen/master
- [1b8e2d0](../../commit/1b8e2d0) [fixed] ModalPortal's componentWillReceiveProps
v0.0.7 - Fri, 02 Jan 2015 23:44:47 UTC
--------------------------------------
- [ea31beb](../../commit/ea31beb) Using shared stylesheet
- [8e01b27](../../commit/8e01b27) Renaming example
- [399b386](../../commit/399b386) Merge pull request #8 from leoasis/update_react_version
- [a8faa92](../../commit/a8faa92) Fixing paths so they work on gh-pages
- [1024026](../../commit/1024026) Fixing paths so they work on gh-pages
- [2d62f51](../../commit/2d62f51) Adding default example
- [4a85cd2](../../commit/4a85cd2) Update to React 0.12. Fix warnings.
v0.0.6 - Wed, 03 Dec 2014 14:24:45 UTC
--------------------------------------
- [2f1973b](../../commit/2f1973b) Merge branch 'master' of https://github.com/rackt/react-modal
- [28dbc63](../../commit/28dbc63) [added] Supporting custom overlay className closes #14
- [1038e3b](../../commit/1038e3b) Merge pull request #13 from knomedia/kill-extra-alias-in-build
- [6626dae](../../commit/6626dae) [fixed] erroneous alias in webpack build
v0.0.5 - Thu, 13 Nov 2014 11:55:47 UTC
--------------------------------------
- [edd0dc7](../../commit/edd0dc7) Merge pull request #12 from cavneb/example-bootstrap
- [e5cb4e2](../../commit/e5cb4e2) Bootstrap-style modal example
- [b15aa82](../../commit/b15aa82) [added] Supporting custom className
- [b7a38de](../../commit/b7a38de) [fixed] Warning caused by trying to focus null element closes #11
- [2ac5290](../../commit/2ac5290) Better solution for applying focus
v0.0.4 - Tue, 11 Nov 2014 09:08:14 UTC
--------------------------------------
- [ebcc11f](../../commit/ebcc11f) s/script/scripts/
- [278cfbc](../../commit/278cfbc) Merge pull request #10 from rackt/bug-9
- [9616a8c](../../commit/9616a8c) Removing console.log
- [e57bab5](../../commit/e57bab5) [fixed] Issue with focus being lost - closes #9
- [07541b3](../../commit/07541b3) example displaying bug
- [31c160d](../../commit/31c160d) switch to web pack dev server for examples
v0.0.3 - Fri, 31 Oct 2014 13:25:20 UTC
--------------------------------------
- [cf3e57a](../../commit/cf3e57a) Merge pull request #5 from leoasis/fix_main_package_json
- [5ea6651](../../commit/5ea6651) Fix main entry point in package.json
- [2277726](../../commit/2277726) Merge pull request #1 from claydiffrient/master
- [8f7cefd](../../commit/8f7cefd) Updates keyboard handling to use keyCode
- [de0b661](../../commit/de0b661) slightly less junky README
- [cde1572](../../commit/cde1572) hang on people, just hang on.
v0.0.2 - Wed, 24 Sep 2014 20:36:47 UTC
--------------------------------------
-
v0.0.1 - Wed, 24 Sep 2014 16:26:40 UTC
--------------------------------------
- [f0727db](../../commit/f0727db) add built files

View File

@@ -0,0 +1,19 @@
Copyright (c) 2017 Ryan Florence
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,156 @@
NODE=$(shell which node)
NPM=$(shell which npm)
YARN=$(shell which yarn)
JQ=$(shell which jq)
BABEL=./node_modules/.bin/babel
COVERALLS=./node_modules/coveralls/bin/coveralls.js
REMOTE="git@github.com:reactjs/react-modal"
CURRENT_VERSION:=$(shell jq ".version" package.json)
COVERAGE?=true
help: info
@echo
@echo "Current version: $(CURRENT_VERSION)"
@echo
@echo "List of commands:"
@echo
@echo " make info - display node, npm and yarn versions..."
@echo " make deps - install all dependencies."
@echo " make serve - start the server."
@echo " make tests - run tests."
@echo " make tests-single-run - run tests (used by continuous integration)."
@echo " make coveralls - show coveralls."
@echo " make lint - run lint."
@echo " make docs - build and serve the docs."
@echo " make build - build project artifacts."
@echo " make publish - build and publish version on npm."
@echo " make publish-docs - build the docs and publish to gh-pages."
@echo " make publish-all - publish version and docs."
info:
@echo node version: `$(NODE) --version` "($(NODE))"
@echo npm version: `$(NPM) --version` "($(NPM))"
@echo yarn version: `$(YARN) --version` "($(YARN))"
@echo jq version: `$(JQ) --version` "($(JQ))"
deps: deps-project deps-docs
deps-project:
@[[ ! -z "$(YARN)" ]] && $(YARN) install || $(NPM) install
deps-docs:
@gitbook install
# Rules for development
serve:
@npm start
tests:
@npm run test
tests-single-run:
@npm run test -- --single-run
coveralls:
-cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js 2>/dev/null
tests-ci: clean lint
@COVERAGE=$(COVERAGE) make tests-single-run coveralls
lint:
@npm run lint
docs: build-docs
gitbook serve
# Rules for build and publish
check-working-tree:
@sh ./scripts/repo_status
.version:
@echo "[Updating react-modal version]"
@sh ./scripts/version $(CURRENT_VERSION)
@$(JQ) '.version' package.json | cut -d\" -f2 > .version
.branch:
@echo "[Release from branch]"
@git branch | grep '^*' | awk '{ print $$2 }' > .branch
@echo "Current branch: `cat .branch`"
changelog:
@echo "[Updating CHANGELOG.md $(CURRENT_VERSION) > `cat .version`]"
@python3 ./scripts/changelog.py v$(CURRENT_VERSION) v`cat .version` > .changelog_update
@cat .changelog_update CHANGELOG.md > tmp && mv tmp CHANGELOG.md
compile:
@echo "[Compiling source]"
$(BABEL) src --out-dir lib
build: compile
@echo "[Building dists]"
@./node_modules/.bin/webpack --config webpack.dist.config.js
release-commit:
git commit --allow-empty -m "Release v`cat .version`."
@git add .
@git commit --amend -m "`git log -1 --format=%s`"
release-tag:
git tag "v`cat .version`"
publish-version: release-commit release-tag
@echo "[Publishing]"
git push $(REMOTE) "`cat .branch`" "v`cat .version`"
npm publish
pre-publish: clean .branch .version changelog
pre-build: deps-project tests-ci build
publish: check-working-tree pre-publish pre-build publish-version publish-finished
publish-finished: clean
# Rules for documentation
init-docs-repo:
@mkdir _book
build-docs:
@echo "[Building documentation]"
@rm -rf _book
@gitbook build -g reactjs/react-modal
pre-publish-docs: clean-docs init-docs-repo deps-docs
publish-docs: clean pre-publish-docs build-docs
@echo "[Publishing docs]"
@make -C _book -f ../Makefile _publish-docs
_publish-docs:
git init .
git commit --allow-empty -m 'update book'
git checkout -b gh-pages
touch .nojekyll
git add .
git commit -am 'update book'
git push git@github.com:reactjs/react-modal gh-pages --force
# Run for a full publish
publish-all: publish publish-docs
# Rules for clean up
clean-docs:
@rm -rf _book
clean-coverage:
@rm -rf ./coverage/*
clean-build:
@rm -rf .version .branch lib/*
clean: clean-build clean-docs clean-coverage

View File

@@ -0,0 +1,311 @@
# react-modal
Accessible modal dialog component for React.JS
[![Build Status](https://travis-ci.org/reactjs/react-modal.svg?branch=v1)](https://travis-ci.org/reactjs/react-modal)
[![Code Climate](https://codeclimate.com/github/reactjs/react-modal/badges/gpa.svg)](https://codeclimate.com/github/reactjs/react-modal)
[![Coverage Status](https://coveralls.io/repos/github/reactjs/react-modal/badge.svg?branch=master)](https://coveralls.io/github/reactjs/react-modal?branch=master)
![gzip size](http://img.badgesize.io/https://unpkg.com/react-modal/dist/react-modal.min.js?compression=gzip)
## Table of Contents
* [Installation](#installation)
* [Usage](#usage)
* [Styles](#styles)
* [Examples](#examples)
* [Testing](#testing)
* [Demos](#demos)
## Installation
To install, you can use [npm](https://npmjs.org/) or [yarn](https://yarnpkg.com):
$ npm install react-modal
$ yarn add react-modal
## Usage
The Modal object has one required prop:
- `isOpen` to render its children.
Example:
```jsx
<Modal
isOpen={bool}
onAfterOpen={afterOpenFn}
onRequestClose={requestCloseFn}
closeTimeoutMS={n}
style={customStyle}
contentLabel="Modal"
>
<h1>Modal Content</h1>
<p>Etc.</p>
</Modal>
```
> Use the prop `contentLabel` which adds `aria-label` to the modal if there is no label text visible on the screen, otherwise specify the element including the label text using `aria-labelledby`
### App Element
The app element allows you to specify the portion
of your app that should be hidden (via aria-hidden)
to prevent assistive technologies such as screenreaders
from reading content outside of the content of
your modal.
It's optional and if not specified it will try to use
`document.body` as your app element.
If you are doing server-side rendering, you should use
this property.
It can be specified in the following ways:
- DOMElement
```js
Modal.setAppElement(appElement);
```
- query selector - uses the first element found if you pass in a class.
```js
Modal.setAppElement('#your-app-element');
```
### Additional Aria Attributes
Use the property `aria` to pass any additional aria attributes. It accepts
an object where the keys are the names of the attributes without the prefix
`aria-`.
Example:
```jsx
<Modal
isOpen={modalIsOpen}
aria={{
labelledby: "heading",
describedby: "full_description"
}}>
<h1 id="heading">H1</h1>
<div id="full_description">
<p>Description goes here.</p>
</div>
</Modal>
```
## Styles
Styles are passed as an object with 2 keys, 'overlay' and 'content' like so
```js
{
overlay : {
position : 'fixed',
top : 0,
left : 0,
right : 0,
bottom : 0,
backgroundColor : 'rgba(255, 255, 255, 0.75)'
},
content : {
position : 'absolute',
top : '40px',
left : '40px',
right : '40px',
bottom : '40px',
border : '1px solid #ccc',
background : '#fff',
overflow : 'auto',
WebkitOverflowScrolling : 'touch',
borderRadius : '4px',
outline : 'none',
padding : '20px'
}
}
```
Styles passed to the modal are merged in with the above defaults and applied to their respective elements.
At this time, media queries will need to be handled by the consumer.
### Using CSS Classes
If you prefer not to use inline styles or are unable to do so in your project,
you can pass `className` and `overlayClassName` props to the Modal. If you do
this then none of the default styles will apply and you will have full control
over styling via CSS.
If you want to override default content and overlay classes you can pass object
with three required properties: `base`, `afterOpen`, `beforeClose`.
```jsx
<Modal
...
className={{
base: 'myClass',
afterOpen: 'myClass_after-open',
beforeClose: 'myClass_before-close'
}}
overlayClassName={{
base: 'myOverlayClass',
afterOpen: 'myOverlayClass_after-open',
beforeClose: 'myOverlayClass_before-close'
}}
...
>
```
You can also pass a `portalClassName` to change the wrapper's class (*ReactModalPortal*).
This doesn't affect styling as no styles are applied to this element by default.
### Overriding styles globally
The default styles above are available on `Modal.defaultStyles`. Changes to this
object will apply to all instances of the modal.
### Appended to custom node
You can choose an element for the modal to be appended to, rather than using
body tag. To do this, provide a function to `parentSelector` prop that return
the element to be used.
```jsx
function getParent() {
return document.querySelector('#root');
}
<Modal
...
parentSelector={getParent}
...
>
<p>Modal Content.</p>
</Modal>
```
### Body class
When the modal is opened a `ReactModal__Body--open` class is added to the `body` tag.
You can use this to remove scrolling on the body while the modal is open.
```CSS
/* Remove scroll on the body when react-modal is open */
.ReactModal__Body--open {
overflow: hidden;
}
```
## Examples
Inside an app:
```jsx
import React from 'react';
import ReactDOM from 'react-dom';
import Modal from 'react-modal';
const customStyles = {
content : {
top : '50%',
left : '50%',
right : 'auto',
bottom : 'auto',
marginRight : '-50%',
transform : 'translate(-50%, -50%)'
}
};
class App extends React.Component {
constructor() {
super();
this.state = {
modalIsOpen: false
};
this.openModal = this.openModal.bind(this);
this.afterOpenModal = this.afterOpenModal.bind(this);
this.closeModal = this.closeModal.bind(this);
}
openModal() {
this.setState({modalIsOpen: true});
}
afterOpenModal() {
// references are now sync'd and can be accessed.
this.subtitle.style.color = '#f00';
}
closeModal() {
this.setState({modalIsOpen: false});
}
render() {
return (
<div>
<button onClick={this.openModal}>Open Modal</button>
<Modal
isOpen={this.state.modalIsOpen}
onAfterOpen={this.afterOpenModal}
onRequestClose={this.closeModal}
style={customStyles}
contentLabel="Example Modal"
>
<h2 ref={subtitle => this.subtitle = subtitle}>Hello</h2>
<button onClick={this.closeModal}>close</button>
<div>I am a modal</div>
<form>
<input />
<button>tab navigation</button>
<button>stays</button>
<button>inside</button>
<button>the modal</button>
</form>
</Modal>
</div>
);
}
}
ReactDOM.render(<App />, appElement);
```
## Testing
When using React Test Utils with this library, here are some things to keep in mind:
- You need to set `isOpen={true}` on the modal component for it to render its children.
- You need to use the `.portal` property, as in `ReactDOM.findDOMNode(renderedModal.portal)` or `TestUtils.scryRenderedDOMComponentsWithClass(Modal.portal, 'my-modal-class')` to acquire a handle to the inner contents of your modal.
By default the modal is closed when clicking outside of it (the overlay area). If you want to prevent this behavior you can
pass the 'shouldCloseOnOverlayClick' prop with 'false' value.
```jsx
<Modal
isOpen={bool}
onAfterOpen={afterOpenFn}
onRequestClose={requestCloseFn}
closeTimeoutMS={n}
shouldCloseOnOverlayClick={false}
style={customStyle}
contentLabel="No Overlay Click Modal"
>
<h1>Force Modal</h1>
<p>Modal cannot be closed when clicking the overlay area</p>
<button onClick={handleCloseFunc}>Close Modal...</button>
</Modal>
```
## Demos
* http://reactjs.github.io/react-modal/

View File

@@ -0,0 +1,7 @@
Upgrade Guide
=============
To see discussion around these API changes, please refer to the
[changelog](/CHANGELOG.md) and visit the commits and issues they
reference.

View File

@@ -0,0 +1,31 @@
{
"gitbook": ">=3.2.2",
"title": "react-modal",
"root": "./docs",
"plugins": [
"codepen",
"edit-link",
"prism",
"-highlight",
"anchorjs",
"github"
],
"pluginsConfig": {
"codepen": {
"height": 1000,
"defaultTab": "js"
},
"edit-link": {
"base": "https://github.com/reactjs/react-modal/tree/master/docs",
"label": "Edit This Page"
},
"prism": {
"css": [
"prismjs/themes/prism-tomorrow.css"
]
},
"github": {
"url": "https://github.com/reactjs/react-modal"
}
}
}

View File

@@ -0,0 +1,36 @@
#!/bin/sh
NODE=`which node`
NPM=`which npm`
YARN=`which yarn`
JQ=`which jq`
echo $NODE $NPM $YARN $JQ
if [[ ! -z "$NODE" ]]; then
echo "Node is installed and it's version is: `$NODE --version`"
else
echo "Please, install node.js."
exit 1
fi
if [[ ! -z "$NPM" ]]; then
echo "NPM is installed and it's version is: `$NPM --version`"
else
echo "Please, install npm."
exit 1
fi
if [[ ! -z "$YARN" ]]; then
echo "yarn is installed and it's version is: `$YARN --version`"
else
echo "yarn is optional."
fi
if [[ ! -z "$JQ" ]]; then
echo "jq is installed and it's version is: `$JQ --version`"
else
echo "jq is optional and used only for publish purpose."
fi
npm install -g gitbook-cli

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,112 @@
# react-modal
> Accessible modal dialog component for React.JS
We maintain that accessibility is a key component of any modern web application. As such, we have created this modal in such a way that it fulfills the accessibility requirements of the modern web. We seek to keep the focus on accessibility while providing a functional, capable modal component for general use.
## Installation
To install the stable version you can use [npm](https://npmjs.org/) or [yarn](https://yarnpkg.com):
$ npm install react-modal
$ yarn add react-modal
## General Usage
The following is an example of using react-modal specifying all the possible props and options:
```js
import ReactModal from 'react-modal';
<ReactModal
/*
Boolean describing if the modal should be shown or not.
*/
isOpen={false}
/*
Function that will be run after the modal has opened.
*/
onAfterOpen={handleAfterOpenFunc}
/*
Function that will be run when the modal is requested to be closed (either by clicking on overlay or pressing ESC)
Note: It is not called if isOpen is changed by other means.
*/
onRequestClose={handleRequestCloseFunc}
/*
Number indicating the milliseconds to wait before closing the modal.
*/
closeTimeoutMS={0}
/*
Object indicating styles to be used for the modal.
It has two keys, `overlay` and `content`. See the `Styles` section for more details.
*/
style={{ overlay: {}, content: {} }}
/*
String indicating how the content container should be announced to screenreaders
*/
contentLabel="Example Modal"
/*
String className to be applied to the portal.
See the `Styles` section for more details.
*/
portalClassName="ReactModalPortal"
/*
String className to be applied to the overlay.
See the `Styles` section for more details.
*/
overlayClassName="ReactModal__Overlay"
/*
String className to be applied to the modal content.
See the `Styles` section for more details.
*/
className="ReactModal__Content"
/*
String className to be applied to the document.body (must be a constant string).
See the `Styles` section for more details.
*/
bodyOpenClassName="ReactModal__Body--open"
/*
Boolean indicating if the appElement should be hidden
*/
ariaHideApp={true}
/*
Boolean indicating if the modal should be focused after render
*/
shouldFocusAfterRender={true}
/*
Boolean indicating if the overlay should close the modal
*/
shouldCloseOnOverlayClick={true}
/*
Boolean indicating if pressing the esc key should close the modal
Note: By disabling the esc key from closing the modal you may introduce an accessibility issue.
*/
shouldCloseOnEsc={true}
/*
Boolean indicating if the modal should restore focus to the element that
had focus prior to its display.
*/
shouldReturnFocusAfterClose={true}
/*
String indicating the role of the modal, allowing the 'dialog' role to be applied if desired.
*/
role="dialog"
/*
Function that will be called to get the parent element that the modal will be attached to.
*/
parentSelector={() => document.body}
/*
Additional aria attributes (optional).
*/
aria={{
labelledby: "heading",
describedby: "full_description"
}}
/>
```
## License
MIT

View File

@@ -0,0 +1,22 @@
# Summary
* [Read Me](/README.md)
* [Development](dev/README.md)
* [Styles](styles/README.md)
* [Using CSS Classes](styles/classes.md)
* [Overriding Defaults](styles/defaults.md)
* [Testing](testing/README.md)
* [Examples](examples/README.md)
* [Minimal](examples/minimal.md)
* [Using setAppElement](examples/set_app_element.md)
* [Using onRequestClose](examples/on_request_close.md)
* [Using shouldCloseOnOverlayClick](examples/should_close_on_overlay_click.md)
* [Using Inline Styles](examples/inline_styles.md)
* [Using CSS Classes](examples/css_classes.md)
* [Using Global Style Overrides](examples/global_overrides.md)
* [Contributing](contributing/README.md)

View File

@@ -0,0 +1,33 @@
# Development
`react-modal` uses `make` to build and publish new versions and documentation.
It works as a checklist for the future releases to keep everything updated such as
`CHANGELOG.md`, `package.json` and `bower.json` and so on.
The minimun works as a normal `npm script`.
## Usage
Once you clone `react-modal`, you can run `sh bootstrap.sh` to check
and download dependencies not managed by `react-modal` such as `gitbook-cli`.
It will also show information about the current versions of `node`, `npm`,
`yarn` and `jq` available.
## List of `npm` commands:
$ npm start -s or yarn start # to run examples
$ npm run tests
$ npm run lint
## List of `make` commands:
$ make help # show all make commands available
$ make deps # npm install, gitbook plugins...
$ make serve # to run examples
$ make tests # use when developing
$ make tests-ci # single run
$ make lint # pass lint
$ make publish # execute the entire pipeline to publish
$ make publish-docs # execute the pipeline for docs

View File

@@ -0,0 +1,30 @@
## Styles
Styles passed into the Modal via the `style` prop are merged with the defaults. The default styles are:
```js
{
overlay : {
position : 'fixed',
top : 0,
left : 0,
right : 0,
bottom : 0,
backgroundColor : 'rgba(255, 255, 255, 0.75)'
},
content : {
position : 'absolute',
top : '40px',
left : '40px',
right : '40px',
bottom : '40px',
border : '1px solid #ccc',
background : '#fff',
overflow : 'auto',
WebkitOverflowScrolling : 'touch',
borderRadius : '4px',
outline : 'none',
padding : '20px'
}
}
```

View File

@@ -0,0 +1,22 @@
### CSS Classes
Sometimes it may be preferable to use CSS classes rather than inline styles.
You can use the `className` and `overlayClassName` props to specify a given CSS
class for each of those.
You can override the default class that is added to `document.body` when the
modal is open by defining a property `bodyOpenClassName`.
It's required that `bodyOpenClassName` must be `constant string`, otherwise we
would end up with a complex system to manage which class name should appear or
be removed from `document.body` from which modal (if using multiple modals
simultaneously).
`bodyOpenClassName` can support adding multiple classes to `document.body` when
the modal is open. Add as many class names as you desire, delineated by spaces.
Note: If you provide those props all default styles will not be applied, leaving
all styles under control of the CSS class.
The `portalClassName` can also be used however there are no styles by default applied

View File

@@ -0,0 +1,3 @@
### Global Overrides
If you'd like to override all instances of modals you can make changes to `Modal.defaultStyles`.

View File

@@ -0,0 +1,6 @@
# Testing
When using React Test Utils with this library, here are some things to keep in mind:
- You need to set `isOpen={true}` on the modal component for it to render its children.
- You need to use the `.portal` property, as in `ReactDOM.findDOMNode(renderedModal.portal)` or `TestUtils.scryRenderedDOMComponentsWithClass(Modal.portal, 'my-modal-class')` to acquire a handle to the inner contents of your modal.

View File

@@ -0,0 +1,244 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bodyOpenClassName = exports.portalClassName = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
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 _react = require("react");
var _react2 = _interopRequireDefault(_react);
var _reactDom = require("react-dom");
var _reactDom2 = _interopRequireDefault(_reactDom);
var _propTypes = require("prop-types");
var _propTypes2 = _interopRequireDefault(_propTypes);
var _ModalPortal = require("./ModalPortal");
var _ModalPortal2 = _interopRequireDefault(_ModalPortal);
var _ariaAppHider = require("../helpers/ariaAppHider");
var ariaAppHider = _interopRequireWildcard(_ariaAppHider);
var _safeHTMLElement = require("../helpers/safeHTMLElement");
var _safeHTMLElement2 = _interopRequireDefault(_safeHTMLElement);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
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; }
var portalClassName = exports.portalClassName = "ReactModalPortal";
var bodyOpenClassName = exports.bodyOpenClassName = "ReactModal__Body--open";
var isReact16 = _reactDom2.default.createPortal !== undefined;
var createPortal = isReact16 ? _reactDom2.default.createPortal : _reactDom2.default.unstable_renderSubtreeIntoContainer;
function getParentElement(parentSelector) {
return parentSelector();
}
var Modal = function (_Component) {
_inherits(Modal, _Component);
function Modal() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Modal);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Modal.__proto__ || Object.getPrototypeOf(Modal)).call.apply(_ref, [this].concat(args))), _this), _this.removePortal = function () {
!isReact16 && _reactDom2.default.unmountComponentAtNode(_this.node);
var parent = getParentElement(_this.props.parentSelector);
parent.removeChild(_this.node);
}, _this.portalRef = function (ref) {
_this.portal = ref;
}, _this.renderPortal = function (props) {
var portal = createPortal(_this, _react2.default.createElement(_ModalPortal2.default, _extends({ defaultStyles: Modal.defaultStyles }, props)), _this.node);
_this.portalRef(portal);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(Modal, [{
key: "componentDidMount",
value: function componentDidMount() {
if (!_safeHTMLElement.canUseDOM) return;
if (!isReact16) {
this.node = document.createElement("div");
}
this.node.className = this.props.portalClassName;
var parent = getParentElement(this.props.parentSelector);
parent.appendChild(this.node);
!isReact16 && this.renderPortal(this.props);
}
}, {
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(newProps) {
if (!_safeHTMLElement.canUseDOM) return;
var isOpen = newProps.isOpen;
// Stop unnecessary renders if modal is remaining closed
if (!this.props.isOpen && !isOpen) return;
var currentParent = getParentElement(this.props.parentSelector);
var newParent = getParentElement(newProps.parentSelector);
if (newParent !== currentParent) {
currentParent.removeChild(this.node);
newParent.appendChild(this.node);
}
!isReact16 && this.renderPortal(newProps);
}
}, {
key: "componentWillUpdate",
value: function componentWillUpdate(newProps) {
if (!_safeHTMLElement.canUseDOM) return;
if (newProps.portalClassName !== this.props.portalClassName) {
this.node.className = newProps.portalClassName;
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (!_safeHTMLElement.canUseDOM || !this.node || !this.portal) return;
var state = this.portal.state;
var now = Date.now();
var closesAt = state.isOpen && this.props.closeTimeoutMS && (state.closesAt || now + this.props.closeTimeoutMS);
if (closesAt) {
if (!state.beforeClose) {
this.portal.closeWithTimeout();
}
setTimeout(this.removePortal, closesAt - now);
} else {
this.removePortal();
}
}
}, {
key: "render",
value: function render() {
if (!_safeHTMLElement.canUseDOM || !isReact16) {
return null;
}
if (!this.node && isReact16) {
this.node = document.createElement("div");
}
return createPortal(_react2.default.createElement(_ModalPortal2.default, _extends({
ref: this.portalRef,
defaultStyles: Modal.defaultStyles
}, this.props)), this.node);
}
}], [{
key: "setAppElement",
value: function setAppElement(element) {
ariaAppHider.setElement(element);
}
/* eslint-disable react/no-unused-prop-types */
/* eslint-enable react/no-unused-prop-types */
}]);
return Modal;
}(_react.Component);
Modal.propTypes = {
isOpen: _propTypes2.default.bool.isRequired,
style: _propTypes2.default.shape({
content: _propTypes2.default.object,
overlay: _propTypes2.default.object
}),
portalClassName: _propTypes2.default.string,
bodyOpenClassName: _propTypes2.default.string,
className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({
base: _propTypes2.default.string.isRequired,
afterOpen: _propTypes2.default.string.isRequired,
beforeClose: _propTypes2.default.string.isRequired
})]),
overlayClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({
base: _propTypes2.default.string.isRequired,
afterOpen: _propTypes2.default.string.isRequired,
beforeClose: _propTypes2.default.string.isRequired
})]),
appElement: _propTypes2.default.instanceOf(_safeHTMLElement2.default),
onAfterOpen: _propTypes2.default.func,
onRequestClose: _propTypes2.default.func,
closeTimeoutMS: _propTypes2.default.number,
ariaHideApp: _propTypes2.default.bool,
shouldFocusAfterRender: _propTypes2.default.bool,
shouldCloseOnOverlayClick: _propTypes2.default.bool,
shouldReturnFocusAfterClose: _propTypes2.default.bool,
parentSelector: _propTypes2.default.func,
aria: _propTypes2.default.object,
role: _propTypes2.default.string,
contentLabel: _propTypes2.default.string,
shouldCloseOnEsc: _propTypes2.default.bool
};
Modal.defaultProps = {
isOpen: false,
portalClassName: portalClassName,
bodyOpenClassName: bodyOpenClassName,
ariaHideApp: true,
closeTimeoutMS: 0,
shouldFocusAfterRender: true,
shouldCloseOnEsc: true,
shouldCloseOnOverlayClick: true,
shouldReturnFocusAfterClose: true,
parentSelector: function parentSelector() {
return document.body;
}
};
Modal.defaultStyles = {
overlay: {
position: "fixed",
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: "rgba(255, 255, 255, 0.75)"
},
content: {
position: "absolute",
top: "40px",
left: "40px",
right: "40px",
bottom: "40px",
border: "1px solid #ccc",
background: "#fff",
overflow: "auto",
WebkitOverflowScrolling: "touch",
borderRadius: "4px",
outline: "none",
padding: "20px"
}
};
exports.default = Modal;

View File

@@ -0,0 +1,397 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
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 _react = require("react");
var _react2 = _interopRequireDefault(_react);
var _propTypes = require("prop-types");
var _propTypes2 = _interopRequireDefault(_propTypes);
var _focusManager = require("../helpers/focusManager");
var focusManager = _interopRequireWildcard(_focusManager);
var _scopeTab = require("../helpers/scopeTab");
var _scopeTab2 = _interopRequireDefault(_scopeTab);
var _ariaAppHider = require("../helpers/ariaAppHider");
var ariaAppHider = _interopRequireWildcard(_ariaAppHider);
var _refCount = require("../helpers/refCount");
var refCount = _interopRequireWildcard(_refCount);
var _bodyClassList = require("../helpers/bodyClassList");
var bodyClassList = _interopRequireWildcard(_bodyClassList);
var _safeHTMLElement = require("../helpers/safeHTMLElement");
var _safeHTMLElement2 = _interopRequireDefault(_safeHTMLElement);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
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; }
// so that our CSS is statically analyzable
var CLASS_NAMES = {
overlay: "ReactModal__Overlay",
content: "ReactModal__Content"
};
var TAB_KEY = 9;
var ESC_KEY = 27;
var ModalPortal = function (_Component) {
_inherits(ModalPortal, _Component);
function ModalPortal(props) {
_classCallCheck(this, ModalPortal);
var _this = _possibleConstructorReturn(this, (ModalPortal.__proto__ || Object.getPrototypeOf(ModalPortal)).call(this, props));
_this.setFocusAfterRender = function (focus) {
_this.focusAfterRender = _this.props.shouldFocusAfterRender && focus;
};
_this.setOverlayRef = function (overlay) {
_this.overlay = overlay;
};
_this.setContentRef = function (content) {
_this.content = content;
};
_this.afterClose = function () {
// Remove body class
bodyClassList.remove(_this.props.bodyOpenClassName);
if (_this.props.shouldFocusAfterRender) {
if (_this.props.shouldReturnFocusAfterClose) {
focusManager.returnFocus();
focusManager.teardownScopedFocus();
} else {
focusManager.popWithoutFocus();
}
}
};
_this.open = function () {
_this.beforeOpen();
if (_this.state.afterOpen && _this.state.beforeClose) {
clearTimeout(_this.closeTimer);
_this.setState({ beforeClose: false });
} else {
if (_this.props.shouldFocusAfterRender) {
focusManager.setupScopedFocus(_this.node);
focusManager.markForFocusLater();
}
_this.setState({ isOpen: true }, function () {
_this.setState({ afterOpen: true });
if (_this.props.isOpen && _this.props.onAfterOpen) {
_this.props.onAfterOpen();
}
});
}
};
_this.close = function () {
_this.beforeClose();
if (_this.props.closeTimeoutMS > 0) {
_this.closeWithTimeout();
} else {
_this.closeWithoutTimeout();
}
};
_this.focusContent = function () {
return _this.content && !_this.contentHasFocus() && _this.content.focus();
};
_this.closeWithTimeout = function () {
var closesAt = Date.now() + _this.props.closeTimeoutMS;
_this.setState({ beforeClose: true, closesAt: closesAt }, function () {
_this.closeTimer = setTimeout(_this.closeWithoutTimeout, _this.state.closesAt - Date.now());
});
};
_this.closeWithoutTimeout = function () {
_this.setState({
beforeClose: false,
isOpen: false,
afterOpen: false,
closesAt: null
}, _this.afterClose);
};
_this.handleKeyDown = function (event) {
if (event.keyCode === TAB_KEY) {
(0, _scopeTab2.default)(_this.content, event);
}
if (_this.props.shouldCloseOnEsc && event.keyCode === ESC_KEY) {
event.preventDefault();
_this.requestClose(event);
}
};
_this.handleOverlayOnClick = function (event) {
if (_this.shouldClose === null) {
_this.shouldClose = true;
}
if (_this.shouldClose && _this.props.shouldCloseOnOverlayClick) {
if (_this.ownerHandlesClose()) {
_this.requestClose(event);
} else {
_this.focusContent();
}
}
_this.shouldClose = null;
_this.moveFromContentToOverlay = null;
};
_this.handleOverlayOnMouseUp = function () {
if (_this.moveFromContentToOverlay === null) {
_this.shouldClose = false;
}
};
_this.handleContentOnMouseUp = function () {
_this.shouldClose = false;
};
_this.handleOverlayOnMouseDown = function () {
_this.moveFromContentToOverlay = false;
};
_this.handleContentOnClick = function () {
_this.shouldClose = false;
};
_this.handleContentOnMouseDown = function () {
_this.shouldClose = false;
_this.moveFromContentToOverlay = false;
};
_this.requestClose = function (event) {
return _this.ownerHandlesClose() && _this.props.onRequestClose(event);
};
_this.ownerHandlesClose = function () {
return _this.props.onRequestClose;
};
_this.shouldBeClosed = function () {
return !_this.state.isOpen && !_this.state.beforeClose;
};
_this.contentHasFocus = function () {
return document.activeElement === _this.content || _this.content.contains(document.activeElement);
};
_this.buildClassName = function (which, additional) {
var classNames = (typeof additional === "undefined" ? "undefined" : _typeof(additional)) === "object" ? additional : {
base: CLASS_NAMES[which],
afterOpen: CLASS_NAMES[which] + "--after-open",
beforeClose: CLASS_NAMES[which] + "--before-close"
};
var className = classNames.base;
if (_this.state.afterOpen) {
className = className + " " + classNames.afterOpen;
}
if (_this.state.beforeClose) {
className = className + " " + classNames.beforeClose;
}
return typeof additional === "string" && additional ? className + " " + additional : className;
};
_this.ariaAttributes = function (items) {
return Object.keys(items).reduce(function (acc, name) {
acc["aria-" + name] = items[name];
return acc;
}, {});
};
_this.state = {
afterOpen: false,
beforeClose: false
};
_this.shouldClose = null;
_this.moveFromContentToOverlay = null;
return _this;
}
_createClass(ModalPortal, [{
key: "componentDidMount",
value: function componentDidMount() {
// Focus needs to be set when mounting and already open
if (this.props.isOpen) {
this.setFocusAfterRender(true);
this.open();
}
}
}, {
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(newProps) {
if (process.env.NODE_ENV !== "production") {
if (newProps.bodyOpenClassName !== this.props.bodyOpenClassName) {
// eslint-disable-next-line no-console
console.warn('React-Modal: "bodyOpenClassName" prop has been modified. ' + "This may cause unexpected behavior when multiple modals are open.");
}
}
// Focus only needs to be set once when the modal is being opened
if (!this.props.isOpen && newProps.isOpen) {
this.setFocusAfterRender(true);
this.open();
} else if (this.props.isOpen && !newProps.isOpen) {
this.close();
}
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
if (this.focusAfterRender) {
this.focusContent();
this.setFocusAfterRender(false);
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
// Remove body class
bodyClassList.remove(this.props.bodyOpenClassName);
this.beforeClose();
clearTimeout(this.closeTimer);
}
}, {
key: "beforeOpen",
value: function beforeOpen() {
var _props = this.props,
appElement = _props.appElement,
ariaHideApp = _props.ariaHideApp,
bodyOpenClassName = _props.bodyOpenClassName;
// Add body class
bodyClassList.add(bodyOpenClassName);
// Add aria-hidden to appElement
if (ariaHideApp) {
ariaAppHider.hide(appElement);
}
}
}, {
key: "beforeClose",
value: function beforeClose() {
var _props2 = this.props,
appElement = _props2.appElement,
ariaHideApp = _props2.ariaHideApp;
// Reset aria-hidden attribute if all modals have been removed
if (ariaHideApp && refCount.totalCount() < 1) {
ariaAppHider.show(appElement);
}
}
// Don't steal focus from inner elements
}, {
key: "render",
value: function render() {
var _props3 = this.props,
className = _props3.className,
overlayClassName = _props3.overlayClassName,
defaultStyles = _props3.defaultStyles;
var contentStyles = className ? {} : defaultStyles.content;
var overlayStyles = overlayClassName ? {} : defaultStyles.overlay;
return this.shouldBeClosed() ? null : _react2.default.createElement(
"div",
{
ref: this.setOverlayRef,
className: this.buildClassName("overlay", overlayClassName),
style: _extends({}, overlayStyles, this.props.style.overlay),
onClick: this.handleOverlayOnClick,
onMouseDown: this.handleOverlayOnMouseDown,
onMouseUp: this.handleOverlayOnMouseUp
},
_react2.default.createElement(
"div",
_extends({
ref: this.setContentRef,
style: _extends({}, contentStyles, this.props.style.content),
className: this.buildClassName("content", className),
tabIndex: "-1",
onKeyDown: this.handleKeyDown,
onMouseDown: this.handleContentOnMouseDown,
onMouseUp: this.handleContentOnMouseUp,
onClick: this.handleContentOnClick,
role: this.props.role,
"aria-label": this.props.contentLabel
}, this.ariaAttributes(this.props.aria || {})),
this.props.children
)
);
}
}]);
return ModalPortal;
}(_react.Component);
ModalPortal.defaultProps = {
style: {
overlay: {},
content: {}
}
};
ModalPortal.propTypes = {
isOpen: _propTypes2.default.bool.isRequired,
defaultStyles: _propTypes2.default.shape({
content: _propTypes2.default.object,
overlay: _propTypes2.default.object
}),
style: _propTypes2.default.shape({
content: _propTypes2.default.object,
overlay: _propTypes2.default.object
}),
className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]),
overlayClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]),
bodyOpenClassName: _propTypes2.default.string,
ariaHideApp: _propTypes2.default.bool,
appElement: _propTypes2.default.instanceOf(_safeHTMLElement2.default),
onAfterOpen: _propTypes2.default.func,
onRequestClose: _propTypes2.default.func,
closeTimeoutMS: _propTypes2.default.number,
shouldFocusAfterRender: _propTypes2.default.bool,
shouldCloseOnOverlayClick: _propTypes2.default.bool,
shouldReturnFocusAfterClose: _propTypes2.default.bool,
role: _propTypes2.default.string,
contentLabel: _propTypes2.default.string,
aria: _propTypes2.default.object,
children: _propTypes2.default.node,
shouldCloseOnEsc: _propTypes2.default.bool
};
exports.default = ModalPortal;
module.exports = exports["default"];

View File

@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.assertNodeList = assertNodeList;
exports.setElement = setElement;
exports.tryForceFallback = tryForceFallback;
exports.validateElement = validateElement;
exports.hide = hide;
exports.show = show;
exports.documentNotReadyOrSSRTesting = documentNotReadyOrSSRTesting;
exports.resetForTesting = resetForTesting;
var globalElement = null;
function assertNodeList(nodeList, selector) {
if (!nodeList || !nodeList.length) {
throw new Error("react-modal: No elements were found for selector " + selector + ".");
}
}
function setElement(element) {
var useElement = element;
if (typeof useElement === "string") {
var el = document.querySelectorAll(useElement);
assertNodeList(el, useElement);
useElement = "length" in el ? el[0] : el;
}
globalElement = useElement || globalElement;
return globalElement;
}
function tryForceFallback() {
if (document && document.body) {
// force fallback to document.body
setElement(document.body);
return true;
}
return false;
}
function validateElement(appElement) {
if (!appElement && !globalElement && !tryForceFallback()) {
throw new Error(["react-modal: Cannot fallback to `document.body`, because it is not", "ready or available. If you are doing server-side rendering, use this", "function to defined an element. `Modal.setAppElement(el)` to make", "this accessible"].join(" "));
}
}
function hide(appElement) {
validateElement(appElement);
(appElement || globalElement).setAttribute("aria-hidden", "true");
}
function show(appElement) {
validateElement(appElement);
(appElement || globalElement).removeAttribute("aria-hidden");
}
function documentNotReadyOrSSRTesting() {
globalElement = null;
}
function resetForTesting() {
globalElement = document.body;
}

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.add = add;
exports.remove = remove;
var _refCount = require("./refCount");
var refCount = _interopRequireWildcard(_refCount);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function add(bodyClass) {
// Increment class(es) on refCount tracker and add class(es) to body
bodyClass.split(" ").map(refCount.add).forEach(function (className) {
return document.body.classList.add(className);
});
}
function remove(bodyClass) {
var classListMap = refCount.get();
// Decrement class(es) from the refCount tracker
// and remove unused class(es) from body
bodyClass.split(" ").map(refCount.remove).filter(function (className) {
return classListMap[className] === 0;
}).forEach(function (className) {
return document.body.classList.remove(className);
});
}

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.handleBlur = handleBlur;
exports.handleFocus = handleFocus;
exports.markForFocusLater = markForFocusLater;
exports.returnFocus = returnFocus;
exports.popWithoutFocus = popWithoutFocus;
exports.setupScopedFocus = setupScopedFocus;
exports.teardownScopedFocus = teardownScopedFocus;
var _tabbable = require("../helpers/tabbable");
var _tabbable2 = _interopRequireDefault(_tabbable);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var focusLaterElements = [];
var modalElement = null;
var needToFocus = false;
function handleBlur() {
needToFocus = true;
}
function handleFocus() {
if (needToFocus) {
needToFocus = false;
if (!modalElement) {
return;
}
// need to see how jQuery shims document.on('focusin') so we don't need the
// setTimeout, firefox doesn't support focusin, if it did, we could focus
// the element outside of a setTimeout. Side-effect of this implementation
// is that the document.body gets focus, and then we focus our element right
// after, seems fine.
setTimeout(function () {
if (modalElement.contains(document.activeElement)) {
return;
}
var el = (0, _tabbable2.default)(modalElement)[0] || modalElement;
el.focus();
}, 0);
}
}
function markForFocusLater() {
focusLaterElements.push(document.activeElement);
}
/* eslint-disable no-console */
function returnFocus() {
var toFocus = null;
try {
toFocus = focusLaterElements.pop();
toFocus.focus();
return;
} catch (e) {
console.warn(["You tried to return focus to", toFocus, "but it is not in the DOM anymore"].join(" "));
}
}
/* eslint-enable no-console */
function popWithoutFocus() {
focusLaterElements.length > 0 && focusLaterElements.pop();
}
function setupScopedFocus(element) {
modalElement = element;
if (window.addEventListener) {
window.addEventListener("blur", handleBlur, false);
document.addEventListener("focus", handleFocus, true);
} else {
window.attachEvent("onBlur", handleBlur);
document.attachEvent("onFocus", handleFocus);
}
}
function teardownScopedFocus() {
modalElement = null;
if (window.addEventListener) {
window.removeEventListener("blur", handleBlur);
document.removeEventListener("focus", handleFocus);
} else {
window.detachEvent("onBlur", handleBlur);
document.detachEvent("onFocus", handleFocus);
}
}

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.get = get;
exports.add = add;
exports.remove = remove;
exports.totalCount = totalCount;
var classListMap = {};
function get() {
return classListMap;
}
function add(bodyClass) {
// Set variable and default if none
if (!classListMap[bodyClass]) {
classListMap[bodyClass] = 0;
}
classListMap[bodyClass] += 1;
return bodyClass;
}
function remove(bodyClass) {
if (classListMap[bodyClass]) {
classListMap[bodyClass] -= 1;
}
return bodyClass;
}
function totalCount() {
return Object.keys(classListMap).reduce(function (acc, curr) {
return acc + classListMap[curr];
}, 0);
}

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.canUseDOM = undefined;
var _exenv = require("exenv");
var _exenv2 = _interopRequireDefault(_exenv);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var EE = _exenv2.default;
var SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {};
var canUseDOM = exports.canUseDOM = EE.canUseDOM;
exports.default = SafeHTMLElement;

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = scopeTab;
var _tabbable = require("./tabbable");
var _tabbable2 = _interopRequireDefault(_tabbable);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function scopeTab(node, event) {
var tabbable = (0, _tabbable2.default)(node);
if (!tabbable.length) {
// Do nothing, since there are no elements that can receive focus.
event.preventDefault();
return;
}
var shiftKey = event.shiftKey;
var head = tabbable[0];
var tail = tabbable[tabbable.length - 1];
// proceed with default browser behavior
if (node === document.activeElement) {
return;
}
var target;
if (tail === document.activeElement && !shiftKey) {
target = head;
}
if (head === document.activeElement && shiftKey) {
target = tail;
}
if (target) {
event.preventDefault();
target.focus();
return;
}
// Safari radio issue.
//
// Safari does not move the focus to the radio button,
// so we need to force it to really walk through all elements.
//
// This is very error prune, since we are trying to guess
// if it is a safari browser from the first occurence between
// chrome or safari.
//
// The chrome user agent contains the first ocurrence
// as the 'chrome/version' and later the 'safari/version'.
var checkSafari = /(\bChrome\b|\bSafari\b)\//.exec(navigator.userAgent);
var isSafariDesktop = checkSafari != null && checkSafari[1] != "Chrome" && /\biPod\b|\biPad\b/g.exec(navigator.userAgent) == null;
// If we are not in safari desktop, let the browser control
// the focus
if (!isSafariDesktop) return;
var x = tabbable.indexOf(document.activeElement);
if (x > -1) {
x += shiftKey ? -1 : 1;
}
event.preventDefault();
tabbable[x].focus();
}
module.exports = exports["default"];

View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findTabbableDescendants;
/*!
* Adapted from jQuery UI core
*
* http://jqueryui.com
*
* Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/category/ui-core/
*/
var tabbableNode = /input|select|textarea|button|object/;
function hidden(el) {
return el.offsetWidth <= 0 && el.offsetHeight <= 0 || el.style.display === "none";
}
function visible(element) {
var parentElement = element;
while (parentElement) {
if (parentElement === document.body) break;
if (hidden(parentElement)) return false;
parentElement = parentElement.parentNode;
}
return true;
}
function focusable(element, isTabIndexNotNaN) {
var nodeName = element.nodeName.toLowerCase();
var res = tabbableNode.test(nodeName) && !element.disabled || (nodeName === "a" ? element.href || isTabIndexNotNaN : isTabIndexNotNaN);
return res && visible(element);
}
function tabbable(element) {
var tabIndex = element.getAttribute("tabindex");
if (tabIndex === null) tabIndex = undefined;
var isTabIndexNaN = isNaN(tabIndex);
return (isTabIndexNaN || tabIndex >= 0) && focusable(element, !isTabIndexNaN);
}
function findTabbableDescendants(element) {
return [].slice.call(element.querySelectorAll("*"), 0).filter(tabbable);
}
module.exports = exports["default"];

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Modal = require("./components/Modal");
var _Modal2 = _interopRequireDefault(_Modal);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _Modal2.default;
module.exports = exports["default"];

View File

@@ -0,0 +1,112 @@
{
"_args": [
[
"react-modal@3.1.2",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "react-modal@3.1.2",
"_id": "react-modal@3.1.2",
"_inBundle": false,
"_integrity": "sha512-a3L2qP0kaqMBy4C1aojs2caUIz3kHRFlnuWJ8zsnuUmh/fKHEDASujVBiQcatn+yUosdE9hViB6JvLfkB0tN2A==",
"_location": "/react-bootstrap-table/react-modal",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "react-modal@3.1.2",
"name": "react-modal",
"escapedName": "react-modal",
"rawSpec": "3.1.2",
"saveSpec": null,
"fetchSpec": "3.1.2"
},
"_requiredBy": [
"/react-bootstrap-table"
],
"_resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.1.2.tgz",
"_spec": "3.1.2",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"authors": [
"Ryan Florence"
],
"bugs": {
"url": "https://github.com/reactjs/react-modal/issues"
},
"dependencies": {
"exenv": "^1.2.0",
"prop-types": "^15.5.10"
},
"description": "Accessible modal dialog component for React.JS",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.25.0",
"babel-eslint": "^8.0.1",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"coveralls": "^2.13.1",
"cross-env": "^5.0.1",
"eslint": "^4.8.0",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.4.0",
"gitbook-cli": "^2.3.0",
"istanbul-instrumenter-loader": "^3.0.0",
"karma": "^1.3.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "1.0.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
"mocha": "3.5.3",
"npm-run-all": "^4.1.1",
"prettier": "^1.7.4",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"should": "^13.1.0",
"sinon": "next",
"uglify-js": "3.1.1",
"webpack": "^3.6.0",
"webpack-dev-server": "2.8.2"
},
"directories": {
"example": "examples"
},
"homepage": "https://github.com/reactjs/react-modal",
"keywords": [
"react",
"react-component",
"modal",
"dialog"
],
"license": "MIT",
"main": "./lib/index.js",
"name": "react-modal",
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0 || ^16",
"react-dom": "^0.14.0 || ^15.0.0 || ^16"
},
"repository": {
"type": "git",
"url": "git+https://github.com/reactjs/react-modal.git"
},
"scripts": {
"lint": "eslint src/ specs/",
"start": "webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
"test": "cross-env NODE_ENV=test karma start"
},
"tags": [
"react",
"modal",
"dialog"
],
"version": "3.1.2"
}

View File

@@ -0,0 +1,159 @@
# Requires python3 to work since, python 3< does not implement %z.
import sys
import os
import json
from datetime import datetime
import pytz
from subprocess import Popen, PIPE, STDOUT
class Version(object):
def __init__(self, version):
v = version
if v.startswith('v'):
v = v[1:].split('\n')[0]
fix = v.split('.')
self.major = int(fix[0])
self.minor = int(fix[1])
self.patch = int(fix[2])
self.build = None
self.tip = False
def __str__(self):
return self.__repr__()
def __repr__(self):
return "v" + str(self.major) + "." + str(self.minor) + "." + str(self.patch)
class Changelog(object):
def __init__(self, info):
a, b, log = info
self.log = log
self.a = a
self.b = b
def log_in_between_versions(self):
hash = self.log.split(' ')[0]
if zeroversion(self.a):
return ""
date_time = git_log([str(self.a), "-1", '--format="%ad"']).split('\n')[0]
if date_time is not '':
dt = datetime.strptime(date_time, '%a %b %d %H:%M:%S %Y %z')
else:
dt = datetime.now()
dt = dt.strftime('%a, %d %b %Y %H:%M:%S')
log = str(self.a) + " - " + dt + " UTC\n"
log = log + ("-" * (len(log) - 1)) + "\n\n"
actual_log = self.log.splitlines()
if len(actual_log) == 1:
entries = "-\n\n"
else:
entries = "\n".join(map(url_entry, actual_log[1:])) + "\n\n"
log = log + entries
return log
def __str__(self):
return self.__repr__(self)
def __repr__(self):
return "Changelog: " + self.log
def url_entry(entry):
log = entry.split(' ')
hash = log[0]
log = ' '.join(log[1:])
return "- [%s](../../commit/%s) %s" % (hash, hash, log)
def zeroversion(v):
return v.major == 0 and v.minor == 0 and v.patch == 0
class compareversions(object):
def __init__(self, obj, *args):
self.obj = obj
def __lt__(self, other):
if self.obj.major < other.obj.major:
return True
if self.obj.minor < other.obj.minor:
return True
if self.obj.patch < other.obj.patch:
return True
return False
def git_exec(args):
p = Popen(" ".join(["git"] + args), shell=True, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
return out.decode('utf-8')
def git_log(args):
return git_exec(["log"] + args)
def adjacents(ls, f, res):
if len(ls) == 0:
return res
first = ls[0]
if len(ls) == 1:
next = None
else:
next = ls[1]
res.append(f(first, next))
return adjacents(ls[1:], f, res)
def logs_between(a, b):
v = a
if b is None:
_ = str(a)
else:
if a.tip:
a = "HEAD"
else:
a = str(a)
_ = str(b) + ".." + a
return (v, b, git_log(["--format='%h %s'", _]))
def changelog(with_versions):
process = with_versions
versions = []
generate_all = len(with_versions) == 0
if generate_all:
lines = git_exec(["tag", "-l"])
process = lines.splitlines()
for item in process:
versions.append(Version(item))
versions = sorted(versions, key=compareversions, reverse=True)
if generate_all:
vs = map(Changelog, adjacents(versions, logs_between, []))
else:
versions[0].tip = True
vs = map(Changelog, [logs_between(versions[0], versions[1])])
return [v.log_in_between_versions() for v in vs]
if __name__ == "__main__":
args = sys.argv[1:]
for_version=[]
if len(args) > 0:
for_version = list(args)
print("\n".join(changelog(for_version)))

View File

@@ -0,0 +1,11 @@
#!/bin/bash
if [ ! -z "`git status -s`" ]; then
echo "Working tree is not clean"
git status -s
read -p "Proceed? [Y/n] " OK
if [[ "$OK" -eq "n" || "$OK" -eq "N" || -z "$OK" ]]; then
echo "Stopping publish"
exit 1
fi
fi

View File

@@ -0,0 +1,25 @@
#!/bin/sh
JQ=$(which jq)
if [[ -z "$JQ" ]]; then
echo "jq is missing."
fi
echo "Current version is: $1"
read -p "Bump to: " NEW_VERSION
if [[ ! -z "$(git tag -l | grep v${NEW_VERSION})" ]]; then
echo "Tag $NEW_VERSION already exists."
exit 1
fi
FILES="package.json bower.json"
for F in $FILES; do
$JQ ".version = \"${NEW_VERSION}\"" "$F" > up.json
cat up.json > "$F"
done
rm up.json

View File

@@ -0,0 +1,53 @@
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var EXAMPLES_DIR = path.resolve(__dirname, 'examples');
function isDirectory(dir) {
return fs.lstatSync(dir).isDirectory();
}
function buildEntries() {
return fs.readdirSync(EXAMPLES_DIR).reduce(function (entries, dir) {
if (dir === 'build')
return entries;
var isDraft = dir.charAt(0) === '_';
if (!isDraft && isDirectory(path.join(EXAMPLES_DIR, dir)))
entries[dir] = path.join(EXAMPLES_DIR, dir, 'app.js');
return entries;
}, {});
}
module.exports = {
entry: buildEntries(),
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: path.resolve(__dirname, './examples/__build__'),
publicPath: '/__build__/'
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader' } }
]
},
resolve: {
alias: {
"react-modal": path.resolve(__dirname, "./src")
}
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('shared'),
new webpack.LoaderOptionsPlugin({ debug: true })
]
};

View File

@@ -0,0 +1,58 @@
var webpack = require('webpack');
var path = require('path');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var reactExternal = {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
};
var reactDOMExternal = {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
};
module.exports = {
entry: {
'react-modal': './src/index.js',
'react-modal.min': './src/index.js'
},
externals: {
'react': reactExternal,
'react-dom': reactDOMExternal
},
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
libraryTarget: 'umd',
library: 'ReactModal'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
compress: {
warnings: false
}
})
],
module: {
rules: [
{ test: /\.js?$/, exclude: /node_modules/, use: { loader: 'babel-loader' } }
]
}
};

View File

@@ -0,0 +1,15 @@
const path = require('path');
const commonConfig = require('./webpack.config');
commonConfig.plugins = [];
commonConfig.entry = './specs/index.js';
commonConfig.devtool = 'inline-source-map';
commonConfig.module.rules.unshift({
test: /\.js$/,
use: { loader: 'istanbul-instrumenter-loader' },
enforce: 'post',
include: path.resolve(__dirname, './src')
});
module.exports = commonConfig;

File diff suppressed because it is too large Load Diff