From 99be4d17b77e7f9cc8a74b818dacbf6b41f33dcf Mon Sep 17 00:00:00 2001 From: omer Date: Sun, 27 Oct 2019 16:50:35 +0200 Subject: [PATCH 01/14] fix(selector): Add support for shadow DOM elements --- src/index.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 1db5a0c9..9bcf60f4 100644 --- a/src/index.js +++ b/src/index.js @@ -186,15 +186,25 @@ class ReactTooltip extends React.Component { * Pick out corresponded target elements */ getTargetArray (id) { - let targetArray + let targetArray = []; + let selector; if (!id) { - targetArray = document.querySelectorAll('[data-tip]:not([data-for])') + selector = '[data-tip]:not([data-for])'; } else { - const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"') - targetArray = document.querySelectorAll(`[data-tip][data-for="${escaped}"]`) + const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); + selector = '[data-tip][data-for="' + escaped + '"]'; } - // targetArray is a NodeList, convert it to a real array - return nodeListToArray(targetArray) + + // Scan document for shadow DOM elements + nodeListToArray(document.getElementsByTagName('*')) + .filter(element => element.shadowRoot) + .forEach(element => { + targetArray = targetArray.concat(nodeListToArray(element.shadowRoot.querySelectorAll(selector))); + }); + + targetArray = targetArray.concat(nodeListToArray(document.querySelectorAll(selector))); + + return targetArray } /** From 873c2a8be03dc59dec712f09b04fe88edddcf1ca Mon Sep 17 00:00:00 2001 From: omer Date: Sun, 27 Oct 2019 17:17:36 +0200 Subject: [PATCH 02/14] fix(selector): lint fixes --- src/index.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index 9bcf60f4..ae2b6d02 100644 --- a/src/index.js +++ b/src/index.js @@ -186,24 +186,22 @@ class ReactTooltip extends React.Component { * Pick out corresponded target elements */ getTargetArray (id) { - let targetArray = []; - let selector; + let targetArray = [] + let selector if (!id) { - selector = '[data-tip]:not([data-for])'; + selector = '[data-tip]:not([data-for])' } else { - const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); - selector = '[data-tip][data-for="' + escaped + '"]'; + const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + selector = '[data-tip][data-for="' + escaped + '"]' } // Scan document for shadow DOM elements nodeListToArray(document.getElementsByTagName('*')) .filter(element => element.shadowRoot) .forEach(element => { - targetArray = targetArray.concat(nodeListToArray(element.shadowRoot.querySelectorAll(selector))); - }); - - targetArray = targetArray.concat(nodeListToArray(document.querySelectorAll(selector))); - + targetArray = targetArray.concat(nodeListToArray(element.shadowRoot.querySelectorAll(selector))) + }) + targetArray = targetArray.concat(nodeListToArray(document.querySelectorAll(selector))) return targetArray } From f30ae74ce911599fb5b4b3aaec05a1f264654092 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 00:24:36 -0500 Subject: [PATCH 03/14] fix: deleting warning in peer dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 81a7d900..e0010cbc 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "react-dom": "global:ReactDOM" }, "peerDependencies": { - "react": ">=^16.0.0", - "react-dom": ">=^16.0.0" + "react": ">=16.0.0", + "react-dom": ">=16.0.0" }, "dependencies": { "prop-types": "^15.6.0" From 208bdc91e9a6a6da2b8831d3343d0338770b77d0 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 08:57:40 -0500 Subject: [PATCH 04/14] chore: adding github pages configuration for deploy --- .travis.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 10321766..371c62bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,20 @@ script: - git config --global user.email "aron.helser@kitware.com" - export GIT_PUBLISH_URL=https://${GH_TOKEN}@github.com/wwayne/react-tooltip.git - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then yarn gh-pages -- --repo ${GIT_PUBLISH_URL}; fi + - cd example + - yarn build +deploy: + provider: pages + skip_cleanup: true + token: $GH_TOKEN + keep_history: true + on: + branch: refactoring + after_success: - yarn semantic-release - + branches: except: - "/^v\\d+\\.\\d+\\.\\d+$/" From 7ba8b28f672b2ca3fc9f5fbe860ec975f10fa0bb Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 09:04:52 -0500 Subject: [PATCH 05/14] fix: install dependencies in example travis --- .gitignore | 2 +- .travis.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 57ee6244..edb1b90a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,5 @@ # files node_modules/ -example/dist/ dist/ +build/ diff --git a/.travis.yml b/.travis.yml index 371c62bc..4e11870c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ script: - export GIT_PUBLISH_URL=https://${GH_TOKEN}@github.com/wwayne/react-tooltip.git - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then yarn gh-pages -- --repo ${GIT_PUBLISH_URL}; fi - cd example + - yarn - yarn build deploy: From 356821b1be23321bea29be1e6895595a753881c0 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 09:26:05 -0500 Subject: [PATCH 06/14] fix: string into example --- example/package.json | 2 +- example/src/App.js | 49 ++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/example/package.json b/example/package.json index 678bced6..6ae2a142 100644 --- a/example/package.json +++ b/example/package.json @@ -15,7 +15,7 @@ "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", - "predeploy": "npm run build", + "predeploy": "yarn build", "deploy": "gh-pages -d build" } } diff --git a/example/src/App.js b/example/src/App.js index 229a9c5e..2fff41c8 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -126,7 +126,7 @@ export default class App extends Component { className={effect === "float" ? "active" : ""} onClick={this.changeEffect.bind(this, "float")} > - Float(default) + Float{'(default)'} - d(`・∀・)b + {'d(`・∀・)b'} Show happy face @@ -209,12 +209,12 @@ export default class App extends Component {
@@ -263,7 +263,7 @@ export default class App extends Component { data-tip="custom show" data-event="click focus" > - ( •̀д•́) + {'( •̀д•́)'}
@@ -275,7 +275,7 @@ export default class App extends Component { data-event="click" data-event-off="dblclick" > - ( •̀д•́) + {'( •̀д•́)'} @@ -305,7 +305,7 @@ export default class App extends Component { data-for="custom-class" data-tip="hover on me will keep the tooltip" > - (・ω´・ ) + {'(・ω´・ )'} @@ -362,7 +362,7 @@ export default class App extends Component {
- =( •̀д•́) + {'=( •̀д•́)'}
- =( •̀д•́) + {'=( •̀д•́)'} @@ -666,14 +666,13 @@ export default class App extends Component {

- When clickable property is set to true", tooltip - can respond to mouse (or touch) events." + When clickable property is set to true{', tooltip can respond to mouse (or touch) events.'}

@@ -715,7 +714,7 @@ export default class App extends Component {
- ( •̀д•́) noOverride + {'( •̀д•́) noOverride'}
header
From 2c57366c6ed6f9fb55dc3279d36ef33b546bc288 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 10:34:17 -0500 Subject: [PATCH 07/14] refactor: contributing readme updated --- .travis.yml | 14 +++++++------- contributing.md | 19 +++++++++++++------ example/src/App.js | 10 +++++----- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e11870c..c7dd9469 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,13 +23,13 @@ script: - yarn - yarn build -deploy: - provider: pages - skip_cleanup: true - token: $GH_TOKEN - keep_history: true - on: - branch: refactoring +#deploy: +# provider: pages +# skip_cleanup: true +# token: $GH_TOKEN +# keep_history: true +# on: +# branch: refactoring after_success: - yarn semantic-release diff --git a/contributing.md b/contributing.md index a3d72257..e2db610e 100644 --- a/contributing.md +++ b/contributing.md @@ -4,24 +4,31 @@ This doc needs help! Please submit your PR... ## Commit messages -We are using semantic-release to automate the release process, and this depends on a specific format for commit messages. Please run `npm run commit` to use `commitizen` to properly format your commit messages so they can be automatically processed and included in release notes. +We are using semantic-release to automate the release process, and this depends on a specific format for commit messages. Please run `yarn commit` to use `commitizen` to properly format your commit messages so they can be automatically processed and included in release notes. ## Pull request testing Some notes on testing and releasing. * For a PR, follow Github's command-line instructions for retrieving the branch with the changes. -* `make dev` starts a development server, open `http://localhost:8888` to see the example website. +* To start a development server: + +```sh +yarn build +cd example +yarn +yarn start +``` + * Provide feedback on the PR about your results. ## Doing a release We are using semantic-release instead of this: -* `make deploy` updates the files in the `standalone` directory * update the version number in `package.json` - - Fixes update the patch number, features update the minor number. - - Major version update is reserved for API breaking changes, not just additions. -* `npm run github-changes -- -n 3.X.Y` to update the changelog + - Fixes update the patch number, features update the minor number. + - Major version update is reserved for API breaking changes, not just additions. +* `yarn github-changes -- -n 3.X.Y` to update the changelog * `git add`, `git commit` and `git push` to get the version to master. * `git tag -a 3.X.Y -m 3.X.Y` `git push --tags` * `npm publish` diff --git a/example/src/App.js b/example/src/App.js index 2fff41c8..edbb0195 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -217,7 +217,7 @@ export default class App extends Component { {'(〃∀〃)'}
- +

This is a global react component tooltip

You can put every thing here

    @@ -232,7 +232,7 @@ export default class App extends Component {

    {" σ`∀´)σ \n" + " (〃∀〃) \n" + - "\n" + + "\n" + "

    This is a global react component tooltip

    \n" + "

    You can put every thing here

    \n" + "
      \n" + @@ -430,7 +430,7 @@ export default class App extends Component {

      {"(❂‿❂)\n" + "(❂‿❂)\n" + - " `This little buddy is ${dataTip}`}/>"} + ` \`This little buddy is \${dataTip}\`}/>`}

@@ -738,7 +738,7 @@ export default class App extends Component {
header
lorem image 100x1500
footer
@@ -749,7 +749,7 @@ export default class App extends Component {
header
lorem image 100x1500
footer
From 431007f5d5970ca68b42d88cf9945c9cf1e1d4b7 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 10:44:08 -0500 Subject: [PATCH 08/14] chore: trying deploy pages in travis --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7dd9469..4e11870c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,13 +23,13 @@ script: - yarn - yarn build -#deploy: -# provider: pages -# skip_cleanup: true -# token: $GH_TOKEN -# keep_history: true -# on: -# branch: refactoring +deploy: + provider: pages + skip_cleanup: true + token: $GH_TOKEN + keep_history: true + on: + branch: refactoring after_success: - yarn semantic-release From e5142e2ebcf0d02e30290c5310441c3feaed45f7 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 11:01:31 -0500 Subject: [PATCH 09/14] refactor: changing url in travis example --- .travis.yml | 2 +- example/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e11870c..3186e2d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ script: - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then yarn gh-pages -- --repo ${GIT_PUBLISH_URL}; fi - cd example - yarn - - yarn build + - yarn deploy deploy: provider: pages diff --git a/example/package.json b/example/package.json index 6ae2a142..56e8a9d3 100644 --- a/example/package.json +++ b/example/package.json @@ -1,6 +1,6 @@ { "name": "react-tooltip-example", - "homepage": "https://github.com/wwayne/react-tooltip", + "homepage": "https://wwayne.github.io/react-tooltip/", "version": "1.0.0", "license": "MIT", "dependencies": { From 9356b8de9c63fccdfb89abf9ee4005d50826a685 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 11:06:48 -0500 Subject: [PATCH 10/14] refactor: changing local dir in deploy travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3186e2d7..4c440f5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,10 +21,11 @@ script: - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then yarn gh-pages -- --repo ${GIT_PUBLISH_URL}; fi - cd example - yarn - - yarn deploy +# - yarn deploy deploy: provider: pages + local_dir: example/build skip_cleanup: true token: $GH_TOKEN keep_history: true From 5ff3f625c3833881e491f907f319dbfdafdab71c Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 11:10:05 -0500 Subject: [PATCH 11/14] refactor: adding yarn build sentence into script in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4c440f5f..8f1da2ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ script: - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then yarn gh-pages -- --repo ${GIT_PUBLISH_URL}; fi - cd example - yarn -# - yarn deploy + - yarn build deploy: provider: pages From 0598a1c95563584c6c01ccc011df1971a895b6e8 Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 11:16:23 -0500 Subject: [PATCH 12/14] refactor: github page for example --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f1da2ce..2a4eb1be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,6 @@ script: - yarn build - git config --global user.name "Travis CI" - git config --global user.email "aron.helser@kitware.com" - - export GIT_PUBLISH_URL=https://${GH_TOKEN}@github.com/wwayne/react-tooltip.git - - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then yarn gh-pages -- --repo ${GIT_PUBLISH_URL}; fi - cd example - yarn - yarn build @@ -30,7 +28,7 @@ deploy: token: $GH_TOKEN keep_history: true on: - branch: refactoring + branch: master after_success: - yarn semantic-release From efa2fa401e9ff820823ff42c6db09b0e8197844f Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 12:05:35 -0500 Subject: [PATCH 13/14] chore: updating readme for standalone files and travis for releases --- .travis.yml | 9 +- README.md | 2 +- package.json | 1 - standalone/react-tooltip.js | 2622 ------------------------------- standalone/react-tooltip.min.js | 2 - 5 files changed, 6 insertions(+), 2630 deletions(-) delete mode 100644 standalone/react-tooltip.js delete mode 100644 standalone/react-tooltip.min.js diff --git a/.travis.yml b/.travis.yml index 2a4eb1be..057cd786 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,11 @@ script: - cd example - yarn - yarn build + - cd .. +after_success: + - yarn semantic-release + deploy: provider: pages local_dir: example/build @@ -28,10 +32,7 @@ deploy: token: $GH_TOKEN keep_history: true on: - branch: master - -after_success: - - yarn semantic-release + branch: master branches: except: diff --git a/README.md b/README.md index 79b41659..a08477e3 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ import ReactTooltip from 'react-tooltip' **Standalone** -You can import `node_modules/react-tooltip/standalone/react-tooltip.min.js` into your page. Please make sure that you have already imported `react` and `react-dom` into your page. +You can import `node_modules/react-tooltip/dist/index.js` into your page. Please make sure that you have already imported `react` and `react-dom` into your page. ## Options Notes: diff --git a/package.json b/package.json index e0010cbc..fb6beaf5 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "npm": ">=5" }, "scripts": { - "test": "make lint", "pretest": "./node_modules/.bin/eslint . --fix", "clean": "rimraf dist", "build": "rollup -c", diff --git a/standalone/react-tooltip.js b/standalone/react-tooltip.js deleted file mode 100644 index a8c74a91..00000000 --- a/standalone/react-tooltip.js +++ /dev/null @@ -1,2622 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactTooltip = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - var argIndex = 0; - var message = 'Warning: ' + format.replace(/%s/g, function () { - return args[argIndex++]; - }); - if (typeof console !== 'undefined') { - console.error(message); - } - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; - - warning = function warning(condition, format) { - if (format === undefined) { - throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); - } - - if (format.indexOf('Failed Composite propType: ') === 0) { - return; // Ignore CompositeComponent proptype check. - } - - if (!condition) { - for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { - args[_key2 - 2] = arguments[_key2]; - } - - printWarning.apply(undefined, [format].concat(args)); - } - }; -} - -module.exports = warning; -}).call(this,require('_process')) -},{"./emptyFunction":2,"_process":6}],5:[function(require,module,exports){ -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ - -'use strict'; -/* eslint-disable no-unused-vars */ -var getOwnPropertySymbols = Object.getOwnPropertySymbols; -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); -} - -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} - -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; -}; - -},{}],6:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],7:[function(require,module,exports){ -(function (process){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -if (process.env.NODE_ENV !== 'production') { - var invariant = require('fbjs/lib/invariant'); - var warning = require('fbjs/lib/warning'); - var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); - var loggedTypeFailures = {}; -} - -/** - * Assert that the values match with the type specs. - * Error messages are memorized and will only be shown once. - * - * @param {object} typeSpecs Map of name to a ReactPropType - * @param {object} values Runtime values that need to be type-checked - * @param {string} location e.g. "prop", "context", "child context" - * @param {string} componentName Name of the component for error messages. - * @param {?Function} getStack Returns the component stack. - * @private - */ -function checkPropTypes(typeSpecs, values, location, componentName, getStack) { - if (process.env.NODE_ENV !== 'production') { - for (var typeSpecName in typeSpecs) { - if (typeSpecs.hasOwnProperty(typeSpecName)) { - var error; - // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]); - error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); - } catch (ex) { - error = ex; - } - warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); - if (error instanceof Error && !(error.message in loggedTypeFailures)) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error.message] = true; - - var stack = getStack ? getStack() : ''; - - warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); - } - } - } - } -} - -module.exports = checkPropTypes; - -}).call(this,require('_process')) -},{"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/invariant":3,"fbjs/lib/warning":4}],8:[function(require,module,exports){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -var emptyFunction = require('fbjs/lib/emptyFunction'); -var invariant = require('fbjs/lib/invariant'); -var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); - -module.exports = function() { - function shim(props, propName, componentName, location, propFullName, secret) { - if (secret === ReactPropTypesSecret) { - // It is still safe when called from React. - return; - } - invariant( - false, - 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + - 'Use PropTypes.checkPropTypes() to call them. ' + - 'Read more at http://fb.me/use-check-prop-types' - ); - }; - shim.isRequired = shim; - function getShim() { - return shim; - }; - // Important! - // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. - var ReactPropTypes = { - array: shim, - bool: shim, - func: shim, - number: shim, - object: shim, - string: shim, - symbol: shim, - - any: shim, - arrayOf: getShim, - element: shim, - instanceOf: getShim, - node: shim, - objectOf: getShim, - oneOf: getShim, - oneOfType: getShim, - shape: getShim, - exact: getShim - }; - - ReactPropTypes.checkPropTypes = emptyFunction; - ReactPropTypes.PropTypes = ReactPropTypes; - - return ReactPropTypes; -}; - -},{"./lib/ReactPropTypesSecret":11,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3}],9:[function(require,module,exports){ -(function (process){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -var emptyFunction = require('fbjs/lib/emptyFunction'); -var invariant = require('fbjs/lib/invariant'); -var warning = require('fbjs/lib/warning'); -var assign = require('object-assign'); - -var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); -var checkPropTypes = require('./checkPropTypes'); - -module.exports = function(isValidElement, throwOnDirectAccess) { - /* global Symbol */ - var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. - - /** - * Returns the iterator method function contained on the iterable object. - * - * Be sure to invoke the function with the iterable as context: - * - * var iteratorFn = getIteratorFn(myIterable); - * if (iteratorFn) { - * var iterator = iteratorFn.call(myIterable); - * ... - * } - * - * @param {?object} maybeIterable - * @return {?function} - */ - function getIteratorFn(maybeIterable) { - var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } - } - - /** - * Collection of methods that allow declaration and validation of props that are - * supplied to React components. Example usage: - * - * var Props = require('ReactPropTypes'); - * var MyArticle = React.createClass({ - * propTypes: { - * // An optional string prop named "description". - * description: Props.string, - * - * // A required enum prop named "category". - * category: Props.oneOf(['News','Photos']).isRequired, - * - * // A prop named "dialog" that requires an instance of Dialog. - * dialog: Props.instanceOf(Dialog).isRequired - * }, - * render: function() { ... } - * }); - * - * A more formal specification of how these methods are used: - * - * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) - * decl := ReactPropTypes.{type}(.isRequired)? - * - * Each and every declaration produces a function with the same signature. This - * allows the creation of custom validation functions. For example: - * - * var MyLink = React.createClass({ - * propTypes: { - * // An optional string or URI prop named "href". - * href: function(props, propName, componentName) { - * var propValue = props[propName]; - * if (propValue != null && typeof propValue !== 'string' && - * !(propValue instanceof URI)) { - * return new Error( - * 'Expected a string or an URI for ' + propName + ' in ' + - * componentName - * ); - * } - * } - * }, - * render: function() {...} - * }); - * - * @internal - */ - - var ANONYMOUS = '<>'; - - // Important! - // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. - var ReactPropTypes = { - array: createPrimitiveTypeChecker('array'), - bool: createPrimitiveTypeChecker('boolean'), - func: createPrimitiveTypeChecker('function'), - number: createPrimitiveTypeChecker('number'), - object: createPrimitiveTypeChecker('object'), - string: createPrimitiveTypeChecker('string'), - symbol: createPrimitiveTypeChecker('symbol'), - - any: createAnyTypeChecker(), - arrayOf: createArrayOfTypeChecker, - element: createElementTypeChecker(), - instanceOf: createInstanceTypeChecker, - node: createNodeChecker(), - objectOf: createObjectOfTypeChecker, - oneOf: createEnumTypeChecker, - oneOfType: createUnionTypeChecker, - shape: createShapeTypeChecker, - exact: createStrictShapeTypeChecker, - }; - - /** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ - /*eslint-disable no-self-compare*/ - function is(x, y) { - // SameValue algorithm - if (x === y) { - // Steps 1-5, 7-10 - // Steps 6.b-6.e: +0 != -0 - return x !== 0 || 1 / x === 1 / y; - } else { - // Step 6.a: NaN == NaN - return x !== x && y !== y; - } - } - /*eslint-enable no-self-compare*/ - - /** - * We use an Error-like object for backward compatibility as people may call - * PropTypes directly and inspect their output. However, we don't use real - * Errors anymore. We don't inspect their stack anyway, and creating them - * is prohibitively expensive if they are created too often, such as what - * happens in oneOfType() for any type before the one that matched. - */ - function PropTypeError(message) { - this.message = message; - this.stack = ''; - } - // Make `instanceof Error` still work for returned errors. - PropTypeError.prototype = Error.prototype; - - function createChainableTypeChecker(validate) { - if (process.env.NODE_ENV !== 'production') { - var manualPropTypeCallCache = {}; - var manualPropTypeWarningCount = 0; - } - function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { - componentName = componentName || ANONYMOUS; - propFullName = propFullName || propName; - - if (secret !== ReactPropTypesSecret) { - if (throwOnDirectAccess) { - // New behavior only for users of `prop-types` package - invariant( - false, - 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + - 'Use `PropTypes.checkPropTypes()` to call them. ' + - 'Read more at http://fb.me/use-check-prop-types' - ); - } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { - // Old behavior for people using React.PropTypes - var cacheKey = componentName + ':' + propName; - if ( - !manualPropTypeCallCache[cacheKey] && - // Avoid spamming the console because they are often not actionable except for lib authors - manualPropTypeWarningCount < 3 - ) { - warning( - false, - 'You are manually calling a React.PropTypes validation ' + - 'function for the `%s` prop on `%s`. This is deprecated ' + - 'and will throw in the standalone `prop-types` package. ' + - 'You may be seeing this warning due to a third-party PropTypes ' + - 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', - propFullName, - componentName - ); - manualPropTypeCallCache[cacheKey] = true; - manualPropTypeWarningCount++; - } - } - } - if (props[propName] == null) { - if (isRequired) { - if (props[propName] === null) { - return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); - } - return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); - } - return null; - } else { - return validate(props, propName, componentName, location, propFullName); - } - } - - var chainedCheckType = checkType.bind(null, false); - chainedCheckType.isRequired = checkType.bind(null, true); - - return chainedCheckType; - } - - function createPrimitiveTypeChecker(expectedType) { - function validate(props, propName, componentName, location, propFullName, secret) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== expectedType) { - // `propValue` being instance of, say, date/regexp, pass the 'object' - // check, but we can offer a more precise error message here rather than - // 'of type `object`'. - var preciseType = getPreciseType(propValue); - - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createAnyTypeChecker() { - return createChainableTypeChecker(emptyFunction.thatReturnsNull); - } - - function createArrayOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - if (typeof typeChecker !== 'function') { - return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); - } - var propValue = props[propName]; - if (!Array.isArray(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); - } - for (var i = 0; i < propValue.length; i++) { - var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); - if (error instanceof Error) { - return error; - } - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createElementTypeChecker() { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - if (!isValidElement(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createInstanceTypeChecker(expectedClass) { - function validate(props, propName, componentName, location, propFullName) { - if (!(props[propName] instanceof expectedClass)) { - var expectedClassName = expectedClass.name || ANONYMOUS; - var actualClassName = getClassName(props[propName]); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createEnumTypeChecker(expectedValues) { - if (!Array.isArray(expectedValues)) { - process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; - return emptyFunction.thatReturnsNull; - } - - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - for (var i = 0; i < expectedValues.length; i++) { - if (is(propValue, expectedValues[i])) { - return null; - } - } - - var valuesString = JSON.stringify(expectedValues); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); - } - return createChainableTypeChecker(validate); - } - - function createObjectOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - if (typeof typeChecker !== 'function') { - return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); - } - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); - } - for (var key in propValue) { - if (propValue.hasOwnProperty(key)) { - var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error instanceof Error) { - return error; - } - } - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createUnionTypeChecker(arrayOfTypeCheckers) { - if (!Array.isArray(arrayOfTypeCheckers)) { - process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; - return emptyFunction.thatReturnsNull; - } - - for (var i = 0; i < arrayOfTypeCheckers.length; i++) { - var checker = arrayOfTypeCheckers[i]; - if (typeof checker !== 'function') { - warning( - false, - 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + - 'received %s at index %s.', - getPostfixForTypeWarning(checker), - i - ); - return emptyFunction.thatReturnsNull; - } - } - - function validate(props, propName, componentName, location, propFullName) { - for (var i = 0; i < arrayOfTypeCheckers.length; i++) { - var checker = arrayOfTypeCheckers[i]; - if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { - return null; - } - } - - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); - } - return createChainableTypeChecker(validate); - } - - function createNodeChecker() { - function validate(props, propName, componentName, location, propFullName) { - if (!isNode(props[propName])) { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createShapeTypeChecker(shapeTypes) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); - } - for (var key in shapeTypes) { - var checker = shapeTypes[key]; - if (!checker) { - continue; - } - var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error) { - return error; - } - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createStrictShapeTypeChecker(shapeTypes) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); - } - // We need to check all keys in case some are required but missing from - // props. - var allKeys = assign({}, props[propName], shapeTypes); - for (var key in allKeys) { - var checker = shapeTypes[key]; - if (!checker) { - return new PropTypeError( - 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + - '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + - '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') - ); - } - var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error) { - return error; - } - } - return null; - } - - return createChainableTypeChecker(validate); - } - - function isNode(propValue) { - switch (typeof propValue) { - case 'number': - case 'string': - case 'undefined': - return true; - case 'boolean': - return !propValue; - case 'object': - if (Array.isArray(propValue)) { - return propValue.every(isNode); - } - if (propValue === null || isValidElement(propValue)) { - return true; - } - - var iteratorFn = getIteratorFn(propValue); - if (iteratorFn) { - var iterator = iteratorFn.call(propValue); - var step; - if (iteratorFn !== propValue.entries) { - while (!(step = iterator.next()).done) { - if (!isNode(step.value)) { - return false; - } - } - } else { - // Iterator will provide entry [k,v] tuples rather than values. - while (!(step = iterator.next()).done) { - var entry = step.value; - if (entry) { - if (!isNode(entry[1])) { - return false; - } - } - } - } - } else { - return false; - } - - return true; - default: - return false; - } - } - - function isSymbol(propType, propValue) { - // Native Symbol. - if (propType === 'symbol') { - return true; - } - - // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' - if (propValue['@@toStringTag'] === 'Symbol') { - return true; - } - - // Fallback for non-spec compliant Symbols which are polyfilled. - if (typeof Symbol === 'function' && propValue instanceof Symbol) { - return true; - } - - return false; - } - - // Equivalent of `typeof` but with special handling for array and regexp. - function getPropType(propValue) { - var propType = typeof propValue; - if (Array.isArray(propValue)) { - return 'array'; - } - if (propValue instanceof RegExp) { - // Old webkits (at least until Android 4.0) return 'function' rather than - // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ - // passes PropTypes.object. - return 'object'; - } - if (isSymbol(propType, propValue)) { - return 'symbol'; - } - return propType; - } - - // This handles more types than `getPropType`. Only used for error messages. - // See `createPrimitiveTypeChecker`. - function getPreciseType(propValue) { - if (typeof propValue === 'undefined' || propValue === null) { - return '' + propValue; - } - var propType = getPropType(propValue); - if (propType === 'object') { - if (propValue instanceof Date) { - return 'date'; - } else if (propValue instanceof RegExp) { - return 'regexp'; - } - } - return propType; - } - - // Returns a string that is postfixed to a warning about an invalid type. - // For example, "undefined" or "of type array" - function getPostfixForTypeWarning(value) { - var type = getPreciseType(value); - switch (type) { - case 'array': - case 'object': - return 'an ' + type; - case 'boolean': - case 'date': - case 'regexp': - return 'a ' + type; - default: - return type; - } - } - - // Returns class name of the object, if any. - function getClassName(propValue) { - if (!propValue.constructor || !propValue.constructor.name) { - return ANONYMOUS; - } - return propValue.constructor.name; - } - - ReactPropTypes.checkPropTypes = checkPropTypes; - ReactPropTypes.PropTypes = ReactPropTypes; - - return ReactPropTypes; -}; - -}).call(this,require('_process')) -},{"./checkPropTypes":7,"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3,"fbjs/lib/warning":4,"object-assign":5}],10:[function(require,module,exports){ -(function (process){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -if (process.env.NODE_ENV !== 'production') { - var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && - Symbol.for && - Symbol.for('react.element')) || - 0xeac7; - - var isValidElement = function(object) { - return typeof object === 'object' && - object !== null && - object.$$typeof === REACT_ELEMENT_TYPE; - }; - - // By explicitly using `prop-types` you are opting into new development behavior. - // http://fb.me/prop-types-in-prod - var throwOnDirectAccess = true; - module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess); -} else { - // By explicitly using `prop-types` you are opting into new production behavior. - // http://fb.me/prop-types-in-prod - module.exports = require('./factoryWithThrowingShims')(); -} - -}).call(this,require('_process')) -},{"./factoryWithThrowingShims":8,"./factoryWithTypeCheckers":9,"_process":6}],11:[function(require,module,exports){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; - -module.exports = ReactPropTypesSecret; - -},{}],12:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = { - - GLOBAL: { - HIDE: '__react_tooltip_hide_event', - REBUILD: '__react_tooltip_rebuild_event', - SHOW: '__react_tooltip_show_event' - } -}; - -},{}],13:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (target) { - target.prototype.isCustomEvent = function (ele) { - var event = this.state.event; - - return event || !!ele.getAttribute('data-event'); - }; - - /* Bind listener for custom event */ - target.prototype.customBindListener = function (ele) { - var _this = this; - - var _state = this.state, - event = _state.event, - eventOff = _state.eventOff; - - var dataEvent = ele.getAttribute('data-event') || event; - var dataEventOff = ele.getAttribute('data-event-off') || eventOff; - - dataEvent.split(' ').forEach(function (event) { - ele.removeEventListener(event, customListeners.get(ele, event)); - var customListener = checkStatus.bind(_this, dataEventOff); - customListeners.set(ele, event, customListener); - ele.addEventListener(event, customListener, false); - }); - if (dataEventOff) { - dataEventOff.split(' ').forEach(function (event) { - ele.removeEventListener(event, _this.hideTooltip); - ele.addEventListener(event, _this.hideTooltip, false); - }); - } - }; - - /* Unbind listener for custom event */ - target.prototype.customUnbindListener = function (ele) { - var _state2 = this.state, - event = _state2.event, - eventOff = _state2.eventOff; - - var dataEvent = event || ele.getAttribute('data-event'); - var dataEventOff = eventOff || ele.getAttribute('data-event-off'); - - ele.removeEventListener(dataEvent, customListeners.get(ele, event)); - if (dataEventOff) ele.removeEventListener(dataEventOff, this.hideTooltip); - }; -}; - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -/** - * Custom events to control showing and hiding of tooltip - * - * @attributes - * - `event` {String} - * - `eventOff` {String} - */ - -var checkStatus = function checkStatus(dataEventOff, e) { - var show = this.state.show; - var id = this.props.id; - - var dataIsCapture = e.currentTarget.getAttribute('data-iscapture'); - var isCapture = dataIsCapture && dataIsCapture === 'true' || this.props.isCapture; - var currentItem = e.currentTarget.getAttribute('currentItem'); - - if (!isCapture) e.stopPropagation(); - if (show && currentItem === 'true') { - if (!dataEventOff) this.hideTooltip(e); - } else { - e.currentTarget.setAttribute('currentItem', 'true'); - setUntargetItems(e.currentTarget, this.getTargetArray(id)); - this.showTooltip(e); - } -}; - -var setUntargetItems = function setUntargetItems(currentTarget, targetArray) { - for (var i = 0; i < targetArray.length; i++) { - if (currentTarget !== targetArray[i]) { - targetArray[i].setAttribute('currentItem', 'false'); - } else { - targetArray[i].setAttribute('currentItem', 'true'); - } - } -}; - -var customListeners = { - id: '9b69f92e-d3fe-498b-b1b4-c5e63a51b0cf', - set: function set(target, event, listener) { - if (this.id in target) { - var map = target[this.id]; - map[event] = listener; - } else { - // this is workaround for WeakMap, which is not supported in older browsers, such as IE - Object.defineProperty(target, this.id, { - configurable: true, - value: _defineProperty({}, event, listener) - }); - } - }, - get: function get(target, event) { - var map = target[this.id]; - if (map !== undefined) { - return map[event]; - } - } -}; - -},{}],14:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (target) { - target.prototype.getEffect = function (currentTarget) { - var dataEffect = currentTarget.getAttribute('data-effect'); - return dataEffect || this.props.effect || 'float'; - }; -}; - -},{}],15:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (target) { - target.prototype.isCapture = function (currentTarget) { - return currentTarget && currentTarget.getAttribute('data-iscapture') === 'true' || this.props.isCapture || false; - }; -}; - -},{}],16:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (target) { - /** - * Hide all tooltip - * @trigger ReactTooltip.hide() - */ - target.hide = function (target) { - dispatchGlobalEvent(_constant2.default.GLOBAL.HIDE, { target: target }); - }; - - /** - * Rebuild all tooltip - * @trigger ReactTooltip.rebuild() - */ - target.rebuild = function () { - dispatchGlobalEvent(_constant2.default.GLOBAL.REBUILD); - }; - - /** - * Show specific tooltip - * @trigger ReactTooltip.show() - */ - target.show = function (target) { - dispatchGlobalEvent(_constant2.default.GLOBAL.SHOW, { target: target }); - }; - - target.prototype.globalRebuild = function () { - if (this.mount) { - this.unbindListener(); - this.bindListener(); - } - }; - - target.prototype.globalShow = function (event) { - if (this.mount) { - // Create a fake event, specific show will limit the type to `solid` - // only `float` type cares e.clientX e.clientY - var e = { currentTarget: event.detail.target }; - this.showTooltip(e, true); - } - }; - - target.prototype.globalHide = function (event) { - if (this.mount) { - var hasTarget = event && event.detail && event.detail.target && true || false; - this.hideTooltip({ currentTarget: hasTarget && event.detail.target }, hasTarget); - } - }; -}; - -var _constant = require('../constant'); - -var _constant2 = _interopRequireDefault(_constant); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var dispatchGlobalEvent = function dispatchGlobalEvent(eventName, opts) { - // Compatibale with IE - // @see http://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work - var event = void 0; - - if (typeof window.CustomEvent === 'function') { - event = new window.CustomEvent(eventName, { detail: opts }); - } else { - event = document.createEvent('Event'); - event.initEvent(eventName, false, true); - event.detail = opts; - } - - window.dispatchEvent(event); -}; /** - * Static methods for react-tooltip - */ - -},{"../constant":12}],17:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (target) { - target.prototype.bindRemovalTracker = function () { - var _this = this; - - var MutationObserver = getMutationObserverClass(); - if (MutationObserver == null) return; - - var observer = new MutationObserver(function (mutations) { - for (var m1 = 0; m1 < mutations.length; m1++) { - var mutation = mutations[m1]; - for (var m2 = 0; m2 < mutation.removedNodes.length; m2++) { - var element = mutation.removedNodes[m2]; - if (element === _this.state.currentTarget) { - _this.hideTooltip(); - return; - } - } - } - }); - - observer.observe(window.document, { childList: true, subtree: true }); - - this.removalTracker = observer; - }; - - target.prototype.unbindRemovalTracker = function () { - if (this.removalTracker) { - this.removalTracker.disconnect(); - this.removalTracker = null; - } - }; -}; - -/** - * Tracking target removing from DOM. - * It's nessesary to hide tooltip when it's target disappears. - * Otherwise, the tooltip would be shown forever until another target - * is triggered. - * - * If MutationObserver is not available, this feature just doesn't work. - */ - -// https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/ -var getMutationObserverClass = function getMutationObserverClass() { - return window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; -}; - -},{}],18:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (target) { - target.prototype.bindWindowEvents = function (resizeHide) { - // ReactTooltip.hide - window.removeEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide); - window.addEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide, false); - - // ReactTooltip.rebuild - window.removeEventListener(_constant2.default.GLOBAL.REBUILD, this.globalRebuild); - window.addEventListener(_constant2.default.GLOBAL.REBUILD, this.globalRebuild, false); - - // ReactTooltip.show - window.removeEventListener(_constant2.default.GLOBAL.SHOW, this.globalShow); - window.addEventListener(_constant2.default.GLOBAL.SHOW, this.globalShow, false); - - // Resize - if (resizeHide) { - window.removeEventListener('resize', this.onWindowResize); - window.addEventListener('resize', this.onWindowResize, false); - } - }; - - target.prototype.unbindWindowEvents = function () { - window.removeEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide); - window.removeEventListener(_constant2.default.GLOBAL.REBUILD, this.globalRebuild); - window.removeEventListener(_constant2.default.GLOBAL.SHOW, this.globalShow); - window.removeEventListener('resize', this.onWindowResize); - }; - - /** - * invoked by resize event of window - */ - target.prototype.onWindowResize = function () { - if (!this.mount) return; - this.hideTooltip(); - }; -}; - -var _constant = require('../constant'); - -var _constant2 = _interopRequireDefault(_constant); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"../constant":12}],19:[function(require,module,exports){ -(function (global){ -'use strict'; - -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 _class, _class2, _temp; - -/* Decoraters */ - - -/* Utils */ - - -/* CSS */ - - -var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _reactDom = (typeof window !== "undefined" ? window['ReactDOM'] : typeof global !== "undefined" ? global['ReactDOM'] : null); - -var _reactDom2 = _interopRequireDefault(_reactDom); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _staticMethods = require('./decorators/staticMethods'); - -var _staticMethods2 = _interopRequireDefault(_staticMethods); - -var _windowListener = require('./decorators/windowListener'); - -var _windowListener2 = _interopRequireDefault(_windowListener); - -var _customEvent = require('./decorators/customEvent'); - -var _customEvent2 = _interopRequireDefault(_customEvent); - -var _isCapture = require('./decorators/isCapture'); - -var _isCapture2 = _interopRequireDefault(_isCapture); - -var _getEffect = require('./decorators/getEffect'); - -var _getEffect2 = _interopRequireDefault(_getEffect); - -var _trackRemoval = require('./decorators/trackRemoval'); - -var _trackRemoval2 = _interopRequireDefault(_trackRemoval); - -var _getPosition = require('./utils/getPosition'); - -var _getPosition2 = _interopRequireDefault(_getPosition); - -var _getTipContent = require('./utils/getTipContent'); - -var _getTipContent2 = _interopRequireDefault(_getTipContent); - -var _aria = require('./utils/aria'); - -var _nodeListToArray = require('./utils/nodeListToArray'); - -var _nodeListToArray2 = _interopRequireDefault(_nodeListToArray); - -var _style = require('./style'); - -var _style2 = _interopRequireDefault(_style); - -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 ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.default)(_class = (0, _customEvent2.default)(_class = (0, _isCapture2.default)(_class = (0, _getEffect2.default)(_class = (0, _trackRemoval2.default)(_class = (_temp = _class2 = function (_React$Component) { - _inherits(ReactTooltip, _React$Component); - - function ReactTooltip(props) { - _classCallCheck(this, ReactTooltip); - - var _this = _possibleConstructorReturn(this, (ReactTooltip.__proto__ || Object.getPrototypeOf(ReactTooltip)).call(this, props)); - - _this.state = { - place: props.place || 'top', // Direction of tooltip - desiredPlace: props.place || 'top', - type: 'dark', // Color theme of tooltip - effect: 'float', // float or fixed - show: false, - border: false, - offset: {}, - extraClass: '', - html: false, - delayHide: 0, - delayShow: 0, - event: props.event || null, - eventOff: props.eventOff || null, - currentEvent: null, // Current mouse event - currentTarget: null, // Current target of mouse event - ariaProps: (0, _aria.parseAria)(props), // aria- and role attributes - isEmptyTip: false, - disable: false, - originTooltip: null, - isMultiline: false - }; - - _this.bind(['showTooltip', 'updateTooltip', 'hideTooltip', 'getTooltipContent', 'globalRebuild', 'globalShow', 'globalHide', 'onWindowResize', 'mouseOnToolTip']); - - _this.mount = true; - _this.delayShowLoop = null; - _this.delayHideLoop = null; - _this.delayReshow = null; - _this.intervalUpdateContent = null; - return _this; - } - - /** - * For unify the bind and unbind listener - */ - - - _createClass(ReactTooltip, [{ - key: 'bind', - value: function bind(methodArray) { - var _this2 = this; - - methodArray.forEach(function (method) { - _this2[method] = _this2[method].bind(_this2); - }); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - var _props = this.props, - insecure = _props.insecure, - resizeHide = _props.resizeHide; - - if (insecure) { - this.setStyleHeader(); // Set the style to the - } - this.bindListener(); // Bind listener for tooltip - this.bindWindowEvents(resizeHide); // Bind global event for static method - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(props) { - var ariaProps = this.state.ariaProps; - - var newAriaProps = (0, _aria.parseAria)(props); - - var isChanged = Object.keys(newAriaProps).some(function (props) { - return newAriaProps[props] !== ariaProps[props]; - }); - if (isChanged) { - this.setState({ ariaProps: newAriaProps }); - } - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.mount = false; - - this.clearTimer(); - - this.unbindListener(); - this.removeScrollListener(); - this.unbindWindowEvents(); - } - - /** - * Return if the mouse is on the tooltip. - * @returns {boolean} true - mouse is on the tooltip - */ - - }, { - key: 'mouseOnToolTip', - value: function mouseOnToolTip() { - var show = this.state.show; - - - if (show && this.tooltipRef) { - /* old IE or Firefox work around */ - if (!this.tooltipRef.matches) { - /* old IE work around */ - if (this.tooltipRef.msMatchesSelector) { - this.tooltipRef.matches = this.tooltipRef.msMatchesSelector; - } else { - /* old Firefox work around */ - this.tooltipRef.matches = this.tooltipRef.mozMatchesSelector; - } - } - return this.tooltipRef.matches(':hover'); - } - return false; - } - /** - * Pick out corresponded target elements - */ - - }, { - key: 'getTargetArray', - value: function getTargetArray(id) { - var targetArray = void 0; - if (!id) { - targetArray = document.querySelectorAll('[data-tip]:not([data-for])'); - } else { - var escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); - targetArray = document.querySelectorAll('[data-tip][data-for="' + escaped + '"]'); - } - // targetArray is a NodeList, convert it to a real array - return (0, _nodeListToArray2.default)(targetArray); - } - - /** - * Bind listener to the target elements - * These listeners used to trigger showing or hiding the tooltip - */ - - }, { - key: 'bindListener', - value: function bindListener() { - var _this3 = this; - - var _props2 = this.props, - id = _props2.id, - globalEventOff = _props2.globalEventOff, - isCapture = _props2.isCapture; - - var targetArray = this.getTargetArray(id); - - targetArray.forEach(function (target) { - var isCaptureMode = _this3.isCapture(target); - var effect = _this3.getEffect(target); - if (target.getAttribute('currentItem') === null) { - target.setAttribute('currentItem', 'false'); - } - _this3.unbindBasicListener(target); - - if (_this3.isCustomEvent(target)) { - _this3.customBindListener(target); - return; - } - - target.addEventListener('mouseenter', _this3.showTooltip, isCaptureMode); - if (effect === 'float') { - target.addEventListener('mousemove', _this3.updateTooltip, isCaptureMode); - } - target.addEventListener('mouseleave', _this3.hideTooltip, isCaptureMode); - }); - - // Global event to hide tooltip - if (globalEventOff) { - window.removeEventListener(globalEventOff, this.hideTooltip); - window.addEventListener(globalEventOff, this.hideTooltip, isCapture); - } - - // Track removal of targetArray elements from DOM - this.bindRemovalTracker(); - } - - /** - * Unbind listeners on target elements - */ - - }, { - key: 'unbindListener', - value: function unbindListener() { - var _this4 = this; - - var _props3 = this.props, - id = _props3.id, - globalEventOff = _props3.globalEventOff; - - var targetArray = this.getTargetArray(id); - targetArray.forEach(function (target) { - _this4.unbindBasicListener(target); - if (_this4.isCustomEvent(target)) _this4.customUnbindListener(target); - }); - - if (globalEventOff) window.removeEventListener(globalEventOff, this.hideTooltip); - this.unbindRemovalTracker(); - } - - /** - * Invoke this before bind listener and ummount the compont - * it is necessary to invloke this even when binding custom event - * so that the tooltip can switch between custom and default listener - */ - - }, { - key: 'unbindBasicListener', - value: function unbindBasicListener(target) { - var isCaptureMode = this.isCapture(target); - target.removeEventListener('mouseenter', this.showTooltip, isCaptureMode); - target.removeEventListener('mousemove', this.updateTooltip, isCaptureMode); - target.removeEventListener('mouseleave', this.hideTooltip, isCaptureMode); - } - }, { - key: 'getTooltipContent', - value: function getTooltipContent() { - var _props4 = this.props, - getContent = _props4.getContent, - children = _props4.children; - - // Generate tooltip content - - var content = void 0; - if (getContent) { - if (Array.isArray(getContent)) { - content = getContent[0] && getContent[0](this.state.originTooltip); - } else { - content = getContent(this.state.originTooltip); - } - } - - return (0, _getTipContent2.default)(this.state.originTooltip, children, content, this.state.isMultiline); - } - }, { - key: 'isEmptyTip', - value: function isEmptyTip(placeholder) { - return typeof placeholder === 'string' && placeholder === '' || placeholder === null; - } - - /** - * When mouse enter, show the tooltip - */ - - }, { - key: 'showTooltip', - value: function showTooltip(e, isGlobalCall) { - if (isGlobalCall) { - // Don't trigger other elements belongs to other ReactTooltip - var targetArray = this.getTargetArray(this.props.id); - var isMyElement = targetArray.some(function (ele) { - return ele === e.currentTarget; - }); - if (!isMyElement) return; - } - // Get the tooltip content - // calculate in this phrase so that tip width height can be detected - var _props5 = this.props, - multiline = _props5.multiline, - getContent = _props5.getContent; - - var originTooltip = e.currentTarget.getAttribute('data-tip'); - var isMultiline = e.currentTarget.getAttribute('data-multiline') || multiline || false; - - // If it is focus event or called by ReactTooltip.show, switch to `solid` effect - var switchToSolid = e instanceof window.FocusEvent || isGlobalCall; - - // if it needs to skip adding hide listener to scroll - var scrollHide = true; - if (e.currentTarget.getAttribute('data-scroll-hide')) { - scrollHide = e.currentTarget.getAttribute('data-scroll-hide') === 'true'; - } else if (this.props.scrollHide != null) { - scrollHide = this.props.scrollHide; - } - - // Make sure the correct place is set - var desiredPlace = e.currentTarget.getAttribute('data-place') || this.props.place || 'top'; - var effect = switchToSolid && 'solid' || this.getEffect(e.currentTarget); - var offset = e.currentTarget.getAttribute('data-offset') || this.props.offset || {}; - var result = (0, _getPosition2.default)(e, e.currentTarget, _reactDom2.default.findDOMNode(this), desiredPlace, desiredPlace, effect, offset); - var place = result.isNewState ? result.newState.place : desiredPlace; - - // To prevent previously created timers from triggering - this.clearTimer(); - - var target = e.currentTarget; - - var reshowDelay = this.state.show ? target.getAttribute('data-delay-update') || this.props.delayUpdate : 0; - - var self = this; - - var updateState = function updateState() { - self.setState({ - originTooltip: originTooltip, - isMultiline: isMultiline, - desiredPlace: desiredPlace, - place: place, - type: target.getAttribute('data-type') || self.props.type || 'dark', - effect: effect, - offset: offset, - html: target.getAttribute('data-html') ? target.getAttribute('data-html') === 'true' : self.props.html || false, - delayShow: target.getAttribute('data-delay-show') || self.props.delayShow || 0, - delayHide: target.getAttribute('data-delay-hide') || self.props.delayHide || 0, - delayUpdate: target.getAttribute('data-delay-update') || self.props.delayUpdate || 0, - border: target.getAttribute('data-border') ? target.getAttribute('data-border') === 'true' : self.props.border || false, - extraClass: target.getAttribute('data-class') || self.props.class || self.props.className || '', - disable: target.getAttribute('data-tip-disable') ? target.getAttribute('data-tip-disable') === 'true' : self.props.disable || false, - currentTarget: target - }, function () { - if (scrollHide) self.addScrollListener(self.state.currentTarget); - self.updateTooltip(e); - - if (getContent && Array.isArray(getContent)) { - self.intervalUpdateContent = setInterval(function () { - if (self.mount) { - var _getContent = self.props.getContent; - - var placeholder = (0, _getTipContent2.default)(originTooltip, '', _getContent[0](), isMultiline); - var isEmptyTip = self.isEmptyTip(placeholder); - self.setState({ - isEmptyTip: isEmptyTip - }); - self.updatePosition(); - } - }, getContent[1]); - } - }); - }; - - // If there is no delay call immediately, don't allow events to get in first. - if (reshowDelay) { - this.delayReshow = setTimeout(updateState, reshowDelay); - } else { - updateState(); - } - } - - /** - * When mouse hover, updatetooltip - */ - - }, { - key: 'updateTooltip', - value: function updateTooltip(e) { - var _this5 = this; - - var _state = this.state, - delayShow = _state.delayShow, - disable = _state.disable; - var afterShow = this.props.afterShow; - - var placeholder = this.getTooltipContent(); - var delayTime = parseInt(delayShow, 10); - var eventTarget = e.currentTarget || e.target; - - // Check if the mouse is actually over the tooltip, if so don't hide the tooltip - if (this.mouseOnToolTip()) { - return; - } - - if (this.isEmptyTip(placeholder) || disable) return; // if the tooltip is empty, disable the tooltip - var updateState = function updateState() { - if (Array.isArray(placeholder) && placeholder.length > 0 || placeholder) { - var isInvisible = !_this5.state.show; - _this5.setState({ - currentEvent: e, - currentTarget: eventTarget, - show: true - }, function () { - _this5.updatePosition(); - if (isInvisible && afterShow) afterShow(); - }); - } - }; - - clearTimeout(this.delayShowLoop); - if (delayShow) { - this.delayShowLoop = setTimeout(updateState, delayTime); - } else { - updateState(); - } - } - - /* - * If we're mousing over the tooltip remove it when we leave. - */ - - }, { - key: 'listenForTooltipExit', - value: function listenForTooltipExit() { - var show = this.state.show; - - - if (show && this.tooltipRef) { - this.tooltipRef.addEventListener('mouseleave', this.hideTooltip); - } - } - }, { - key: 'removeListenerForTooltipExit', - value: function removeListenerForTooltipExit() { - var show = this.state.show; - - - if (show && this.tooltipRef) { - this.tooltipRef.removeEventListener('mouseleave', this.hideTooltip); - } - } - - /** - * When mouse leave, hide tooltip - */ - - }, { - key: 'hideTooltip', - value: function hideTooltip(e, hasTarget) { - var _this6 = this; - - var _state2 = this.state, - delayHide = _state2.delayHide, - disable = _state2.disable; - var afterHide = this.props.afterHide; - - var placeholder = this.getTooltipContent(); - if (!this.mount) return; - if (this.isEmptyTip(placeholder) || disable) return; // if the tooltip is empty, disable the tooltip - if (hasTarget) { - // Don't trigger other elements belongs to other ReactTooltip - var targetArray = this.getTargetArray(this.props.id); - var isMyElement = targetArray.some(function (ele) { - return ele === e.currentTarget; - }); - if (!isMyElement || !this.state.show) return; - } - - var resetState = function resetState() { - var isVisible = _this6.state.show; - // Check if the mouse is actually over the tooltip, if so don't hide the tooltip - if (_this6.mouseOnToolTip()) { - _this6.listenForTooltipExit(); - return; - } - _this6.removeListenerForTooltipExit(); - - _this6.setState({ - show: false - }, function () { - _this6.removeScrollListener(); - if (isVisible && afterHide) afterHide(); - }); - }; - - this.clearTimer(); - if (delayHide) { - this.delayHideLoop = setTimeout(resetState, parseInt(delayHide, 10)); - } else { - resetState(); - } - } - - /** - * Add scroll eventlistener when tooltip show - * automatically hide the tooltip when scrolling - */ - - }, { - key: 'addScrollListener', - value: function addScrollListener(currentTarget) { - var isCaptureMode = this.isCapture(currentTarget); - window.addEventListener('scroll', this.hideTooltip, isCaptureMode); - } - }, { - key: 'removeScrollListener', - value: function removeScrollListener() { - window.removeEventListener('scroll', this.hideTooltip); - } - - // Calculation the position - - }, { - key: 'updatePosition', - value: function updatePosition() { - var _this7 = this; - - var _state3 = this.state, - currentEvent = _state3.currentEvent, - currentTarget = _state3.currentTarget, - place = _state3.place, - desiredPlace = _state3.desiredPlace, - effect = _state3.effect, - offset = _state3.offset; - - var node = _reactDom2.default.findDOMNode(this); - var result = (0, _getPosition2.default)(currentEvent, currentTarget, node, place, desiredPlace, effect, offset); - - if (result.isNewState) { - // Switch to reverse placement - return this.setState(result.newState, function () { - _this7.updatePosition(); - }); - } - // Set tooltip position - node.style.left = result.position.left + 'px'; - node.style.top = result.position.top + 'px'; - } - - /** - * Set style tag in header - * in this way we can insert default css - */ - - }, { - key: 'setStyleHeader', - value: function setStyleHeader() { - var head = document.getElementsByTagName('head')[0]; - if (!head.querySelector('style[id="react-tooltip"]')) { - var tag = document.createElement('style'); - tag.id = 'react-tooltip'; - tag.innerHTML = _style2.default; - /* eslint-disable */ - if (typeof __webpack_nonce__ !== 'undefined' && __webpack_nonce__) { - tag.setAttribute('nonce', __webpack_nonce__); - } - /* eslint-enable */ - head.insertBefore(tag, head.firstChild); - } - } - - /** - * CLear all kinds of timeout of interval - */ - - }, { - key: 'clearTimer', - value: function clearTimer() { - clearTimeout(this.delayShowLoop); - clearTimeout(this.delayHideLoop); - clearTimeout(this.delayReshow); - clearInterval(this.intervalUpdateContent); - } - }, { - key: 'render', - value: function render() { - var _this8 = this; - - var _state4 = this.state, - extraClass = _state4.extraClass, - html = _state4.html, - ariaProps = _state4.ariaProps, - disable = _state4.disable; - - var placeholder = this.getTooltipContent(); - var isEmptyTip = this.isEmptyTip(placeholder); - var tooltipClass = (0, _classnames2.default)('__react_component_tooltip', { 'show': this.state.show && !disable && !isEmptyTip }, { 'border': this.state.border }, { 'place-top': this.state.place === 'top' }, { 'place-bottom': this.state.place === 'bottom' }, { 'place-left': this.state.place === 'left' }, { 'place-right': this.state.place === 'right' }, { 'type-dark': this.state.type === 'dark' }, { 'type-success': this.state.type === 'success' }, { 'type-warning': this.state.type === 'warning' }, { 'type-error': this.state.type === 'error' }, { 'type-info': this.state.type === 'info' }, { 'type-light': this.state.type === 'light' }, { 'allow_hover': this.props.delayUpdate }); - - var Wrapper = this.props.wrapper; - if (ReactTooltip.supportedWrappers.indexOf(Wrapper) < 0) { - Wrapper = ReactTooltip.defaultProps.wrapper; - } - - if (html) { - return _react2.default.createElement(Wrapper, _extends({ className: tooltipClass + ' ' + extraClass, - id: this.props.id, - ref: function ref(_ref) { - return _this8.tooltipRef = _ref; - } - }, ariaProps, { - 'data-id': 'tooltip', - dangerouslySetInnerHTML: { __html: placeholder } })); - } else { - return _react2.default.createElement( - Wrapper, - _extends({ className: tooltipClass + ' ' + extraClass, - id: this.props.id - }, ariaProps, { - ref: function ref(_ref2) { - return _this8.tooltipRef = _ref2; - }, - 'data-id': 'tooltip' }), - placeholder - ); - } - } - }]); - - return ReactTooltip; -}(_react2.default.Component), _class2.propTypes = { - children: _propTypes2.default.any, - place: _propTypes2.default.string, - type: _propTypes2.default.string, - effect: _propTypes2.default.string, - offset: _propTypes2.default.object, - multiline: _propTypes2.default.bool, - border: _propTypes2.default.bool, - insecure: _propTypes2.default.bool, - class: _propTypes2.default.string, - className: _propTypes2.default.string, - id: _propTypes2.default.string, - html: _propTypes2.default.bool, - delayHide: _propTypes2.default.number, - delayUpdate: _propTypes2.default.number, - delayShow: _propTypes2.default.number, - event: _propTypes2.default.string, - eventOff: _propTypes2.default.string, - watchWindow: _propTypes2.default.bool, - isCapture: _propTypes2.default.bool, - globalEventOff: _propTypes2.default.string, - getContent: _propTypes2.default.any, - afterShow: _propTypes2.default.func, - afterHide: _propTypes2.default.func, - disable: _propTypes2.default.bool, - scrollHide: _propTypes2.default.bool, - resizeHide: _propTypes2.default.bool, - wrapper: _propTypes2.default.string -}, _class2.defaultProps = { - insecure: true, - resizeHide: true, - wrapper: 'div' -}, _class2.supportedWrappers = ['div', 'span'], _class2.displayName = 'ReactTooltip', _temp)) || _class) || _class) || _class) || _class) || _class) || _class; - -/* export default not fit for standalone, it will exports {default:...} */ - - -module.exports = ReactTooltip; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./decorators/customEvent":13,"./decorators/getEffect":14,"./decorators/isCapture":15,"./decorators/staticMethods":16,"./decorators/trackRemoval":17,"./decorators/windowListener":18,"./style":20,"./utils/aria":21,"./utils/getPosition":22,"./utils/getTipContent":23,"./utils/nodeListToArray":24,"classnames":1,"prop-types":10}],20:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = '.__react_component_tooltip{border-radius:3px;display:inline-block;font-size:13px;left:-999em;opacity:0;padding:8px 21px;position:fixed;pointer-events:none;transition:opacity 0.3s ease-out;top:-999em;visibility:hidden;z-index:999}.__react_component_tooltip.allow_hover{pointer-events:auto}.__react_component_tooltip:before,.__react_component_tooltip:after{content:"";width:0;height:0;position:absolute}.__react_component_tooltip.show{opacity:0.9;margin-top:0px;margin-left:0px;visibility:visible}.__react_component_tooltip.type-dark{color:#fff;background-color:#222}.__react_component_tooltip.type-dark.place-top:after{border-top-color:#222;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-dark.place-bottom:after{border-bottom-color:#222;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-dark.place-left:after{border-left-color:#222;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-dark.place-right:after{border-right-color:#222;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-dark.border{border:1px solid #fff}.__react_component_tooltip.type-dark.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-dark.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-dark.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-dark.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-success{color:#fff;background-color:#8DC572}.__react_component_tooltip.type-success.place-top:after{border-top-color:#8DC572;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-success.place-bottom:after{border-bottom-color:#8DC572;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-success.place-left:after{border-left-color:#8DC572;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-success.place-right:after{border-right-color:#8DC572;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-success.border{border:1px solid #fff}.__react_component_tooltip.type-success.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-success.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-success.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-success.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-warning{color:#fff;background-color:#F0AD4E}.__react_component_tooltip.type-warning.place-top:after{border-top-color:#F0AD4E;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-warning.place-bottom:after{border-bottom-color:#F0AD4E;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-warning.place-left:after{border-left-color:#F0AD4E;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-warning.place-right:after{border-right-color:#F0AD4E;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-warning.border{border:1px solid #fff}.__react_component_tooltip.type-warning.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-warning.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-warning.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-warning.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-error{color:#fff;background-color:#BE6464}.__react_component_tooltip.type-error.place-top:after{border-top-color:#BE6464;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-error.place-bottom:after{border-bottom-color:#BE6464;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-error.place-left:after{border-left-color:#BE6464;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-error.place-right:after{border-right-color:#BE6464;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-error.border{border:1px solid #fff}.__react_component_tooltip.type-error.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-error.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-error.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-error.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-info{color:#fff;background-color:#337AB7}.__react_component_tooltip.type-info.place-top:after{border-top-color:#337AB7;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-info.place-bottom:after{border-bottom-color:#337AB7;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-info.place-left:after{border-left-color:#337AB7;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-info.place-right:after{border-right-color:#337AB7;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-info.border{border:1px solid #fff}.__react_component_tooltip.type-info.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-info.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-info.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-info.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-light{color:#222;background-color:#fff}.__react_component_tooltip.type-light.place-top:after{border-top-color:#fff;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-light.place-bottom:after{border-bottom-color:#fff;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-light.place-left:after{border-left-color:#fff;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-light.place-right:after{border-right-color:#fff;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-light.border{border:1px solid #222}.__react_component_tooltip.type-light.border.place-top:before{border-top:8px solid #222}.__react_component_tooltip.type-light.border.place-bottom:before{border-bottom:8px solid #222}.__react_component_tooltip.type-light.border.place-left:before{border-left:8px solid #222}.__react_component_tooltip.type-light.border.place-right:before{border-right:8px solid #222}.__react_component_tooltip.place-top{margin-top:-10px}.__react_component_tooltip.place-top:before{border-left:10px solid transparent;border-right:10px solid transparent;bottom:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-top:after{border-left:8px solid transparent;border-right:8px solid transparent;bottom:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-bottom{margin-top:10px}.__react_component_tooltip.place-bottom:before{border-left:10px solid transparent;border-right:10px solid transparent;top:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-bottom:after{border-left:8px solid transparent;border-right:8px solid transparent;top:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-left{margin-left:-10px}.__react_component_tooltip.place-left:before{border-top:6px solid transparent;border-bottom:6px solid transparent;right:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-left:after{border-top:5px solid transparent;border-bottom:5px solid transparent;right:-6px;top:50%;margin-top:-4px}.__react_component_tooltip.place-right{margin-left:10px}.__react_component_tooltip.place-right:before{border-top:6px solid transparent;border-bottom:6px solid transparent;left:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-right:after{border-top:5px solid transparent;border-bottom:5px solid transparent;left:-6px;top:50%;margin-top:-4px}.__react_component_tooltip .multi-line{display:block;padding:2px 0px;text-align:center}'; - -},{}],21:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.parseAria = parseAria; -/** - * Support aria- and role in ReactTooltip - * - * @params props {Object} - * @return {Object} - */ -function parseAria(props) { - var ariaObj = {}; - Object.keys(props).filter(function (prop) { - // aria-xxx and role is acceptable - return (/(^aria-\w+$|^role$)/.test(prop) - ); - }).forEach(function (prop) { - ariaObj[prop] = props[prop]; - }); - - return ariaObj; -} - -},{}],22:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (e, target, node, place, desiredPlace, effect, offset) { - var _getDimensions = getDimensions(node), - tipWidth = _getDimensions.width, - tipHeight = _getDimensions.height; - - var _getDimensions2 = getDimensions(target), - targetWidth = _getDimensions2.width, - targetHeight = _getDimensions2.height; - - var _getCurrentOffset = getCurrentOffset(e, target, effect), - mouseX = _getCurrentOffset.mouseX, - mouseY = _getCurrentOffset.mouseY; - - var defaultOffset = getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight); - - var _calculateOffset = calculateOffset(offset), - extraOffset_X = _calculateOffset.extraOffset_X, - extraOffset_Y = _calculateOffset.extraOffset_Y; - - var windowWidth = window.innerWidth; - var windowHeight = window.innerHeight; - - var _getParent = getParent(node), - parentTop = _getParent.parentTop, - parentLeft = _getParent.parentLeft; - - // Get the edge offset of the tooltip - - - var getTipOffsetLeft = function getTipOffsetLeft(place) { - var offset_X = defaultOffset[place].l; - return mouseX + offset_X + extraOffset_X; - }; - var getTipOffsetRight = function getTipOffsetRight(place) { - var offset_X = defaultOffset[place].r; - return mouseX + offset_X + extraOffset_X; - }; - var getTipOffsetTop = function getTipOffsetTop(place) { - var offset_Y = defaultOffset[place].t; - return mouseY + offset_Y + extraOffset_Y; - }; - var getTipOffsetBottom = function getTipOffsetBottom(place) { - var offset_Y = defaultOffset[place].b; - return mouseY + offset_Y + extraOffset_Y; - }; - - // - // Functions to test whether the tooltip's sides are inside - // the client window for a given orientation p - // - // _____________ - // | | <-- Right side - // | p = 'left' |\ - // | |/ |\ - // |_____________| |_\ <-- Mouse - // / \ | - // | - // | - // Bottom side - // - var outsideLeft = function outsideLeft(p) { - return getTipOffsetLeft(p) < 0; - }; - var outsideRight = function outsideRight(p) { - return getTipOffsetRight(p) > windowWidth; - }; - var outsideTop = function outsideTop(p) { - return getTipOffsetTop(p) < 0; - }; - var outsideBottom = function outsideBottom(p) { - return getTipOffsetBottom(p) > windowHeight; - }; - - // Check whether the tooltip with orientation p is completely inside the client window - var outside = function outside(p) { - return outsideLeft(p) || outsideRight(p) || outsideTop(p) || outsideBottom(p); - }; - var inside = function inside(p) { - return !outside(p); - }; - - var placesList = ['top', 'bottom', 'left', 'right']; - var insideList = []; - for (var i = 0; i < 4; i++) { - var p = placesList[i]; - if (inside(p)) { - insideList.push(p); - } - } - - var isNewState = false; - var newPlace = void 0; - if (inside(desiredPlace) && desiredPlace !== place) { - isNewState = true; - newPlace = desiredPlace; - } else if (insideList.length > 0 && outside(desiredPlace) && outside(place)) { - isNewState = true; - newPlace = insideList[0]; - } - - if (isNewState) { - return { - isNewState: true, - newState: { place: newPlace } - }; - } - - return { - isNewState: false, - position: { - left: parseInt(getTipOffsetLeft(place) - parentLeft, 10), - top: parseInt(getTipOffsetTop(place) - parentTop, 10) - } - }; -}; - -var getDimensions = function getDimensions(node) { - var _node$getBoundingClie = node.getBoundingClientRect(), - height = _node$getBoundingClie.height, - width = _node$getBoundingClie.width; - - return { - height: parseInt(height, 10), - width: parseInt(width, 10) - }; -}; - -// Get current mouse offset -/** - * Calculate the position of tooltip - * - * @params - * - `e` {Event} the event of current mouse - * - `target` {Element} the currentTarget of the event - * - `node` {DOM} the react-tooltip object - * - `place` {String} top / right / bottom / left - * - `effect` {String} float / solid - * - `offset` {Object} the offset to default position - * - * @return {Object} - * - `isNewState` {Bool} required - * - `newState` {Object} - * - `position` {Object} {left: {Number}, top: {Number}} - */ -var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) { - var boundingClientRect = currentTarget.getBoundingClientRect(); - var targetTop = boundingClientRect.top; - var targetLeft = boundingClientRect.left; - - var _getDimensions3 = getDimensions(currentTarget), - targetWidth = _getDimensions3.width, - targetHeight = _getDimensions3.height; - - if (effect === 'float') { - return { - mouseX: e.clientX, - mouseY: e.clientY - }; - } - return { - mouseX: targetLeft + targetWidth / 2, - mouseY: targetTop + targetHeight / 2 - }; -}; - -// List all possibility of tooltip final offset -// This is useful in judging if it is necessary for tooltip to switch position when out of window -var getDefaultPosition = function getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight) { - var top = void 0; - var right = void 0; - var bottom = void 0; - var left = void 0; - var disToMouse = 3; - var triangleHeight = 2; - var cursorHeight = 12; // Optimize for float bottom only, cause the cursor will hide the tooltip - - if (effect === 'float') { - top = { - l: -(tipWidth / 2), - r: tipWidth / 2, - t: -(tipHeight + disToMouse + triangleHeight), - b: -disToMouse - }; - bottom = { - l: -(tipWidth / 2), - r: tipWidth / 2, - t: disToMouse + cursorHeight, - b: tipHeight + disToMouse + triangleHeight + cursorHeight - }; - left = { - l: -(tipWidth + disToMouse + triangleHeight), - r: -disToMouse, - t: -(tipHeight / 2), - b: tipHeight / 2 - }; - right = { - l: disToMouse, - r: tipWidth + disToMouse + triangleHeight, - t: -(tipHeight / 2), - b: tipHeight / 2 - }; - } else if (effect === 'solid') { - top = { - l: -(tipWidth / 2), - r: tipWidth / 2, - t: -(targetHeight / 2 + tipHeight + triangleHeight), - b: -(targetHeight / 2) - }; - bottom = { - l: -(tipWidth / 2), - r: tipWidth / 2, - t: targetHeight / 2, - b: targetHeight / 2 + tipHeight + triangleHeight - }; - left = { - l: -(tipWidth + targetWidth / 2 + triangleHeight), - r: -(targetWidth / 2), - t: -(tipHeight / 2), - b: tipHeight / 2 - }; - right = { - l: targetWidth / 2, - r: tipWidth + targetWidth / 2 + triangleHeight, - t: -(tipHeight / 2), - b: tipHeight / 2 - }; - } - - return { top: top, bottom: bottom, left: left, right: right }; -}; - -// Consider additional offset into position calculation -var calculateOffset = function calculateOffset(offset) { - var extraOffset_X = 0; - var extraOffset_Y = 0; - - if (Object.prototype.toString.apply(offset) === '[object String]') { - offset = JSON.parse(offset.toString().replace(/\'/g, '\"')); - } - for (var key in offset) { - if (key === 'top') { - extraOffset_Y -= parseInt(offset[key], 10); - } else if (key === 'bottom') { - extraOffset_Y += parseInt(offset[key], 10); - } else if (key === 'left') { - extraOffset_X -= parseInt(offset[key], 10); - } else if (key === 'right') { - extraOffset_X += parseInt(offset[key], 10); - } - } - - return { extraOffset_X: extraOffset_X, extraOffset_Y: extraOffset_Y }; -}; - -// Get the offset of the parent elements -var getParent = function getParent(currentTarget) { - var currentParent = currentTarget; - while (currentParent) { - if (window.getComputedStyle(currentParent).getPropertyValue('transform') !== 'none') break; - currentParent = currentParent.parentElement; - } - - var parentTop = currentParent && currentParent.getBoundingClientRect().top || 0; - var parentLeft = currentParent && currentParent.getBoundingClientRect().left || 0; - - return { parentTop: parentTop, parentLeft: parentLeft }; -}; - -},{}],23:[function(require,module,exports){ -(function (global){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (tip, children, getContent, multiline) { - if (children) return children; - if (getContent !== undefined && getContent !== null) return getContent; // getContent can be 0, '', etc. - if (getContent === null) return null; // Tip not exist and childern is null or undefined - - var regexp = //; - if (!multiline || multiline === 'false' || !regexp.test(tip)) { - // No trim(), so that user can keep their input - return tip; - } - - // Multiline tooltip content - return tip.split(regexp).map(function (d, i) { - return _react2.default.createElement( - 'span', - { key: i, className: 'multi-line' }, - d - ); - }); -}; - -var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); - -var _react2 = _interopRequireDefault(_react); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],24:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -exports.default = function (nodeList) { - var length = nodeList.length; - if (nodeList.hasOwnProperty) { - return Array.prototype.slice.call(nodeList); - } - return new Array(length).fill().map(function (index) { - return nodeList[index]; - }); -}; - -},{}]},{},[19])(19) -}); diff --git a/standalone/react-tooltip.min.js b/standalone/react-tooltip.min.js deleted file mode 100644 index 8c3a998c..00000000 --- a/standalone/react-tooltip.min.js +++ /dev/null @@ -1,2 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactTooltip=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.error(message)}try{throw new Error(message)}catch(x){}};warning=function warning(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(format.indexOf("Failed Composite propType: ")===0){return}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=warning}).call(this,require("_process"))},{"./emptyFunction":2,_process:6}],5:[function(require,module,exports){"use strict";var getOwnPropertySymbols=Object.getOwnPropertySymbols;var hasOwnProperty=Object.prototype.hasOwnProperty;var propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(val){if(val===null||val===undefined){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(val)}function shouldUseNative(){try{if(!Object.assign){return false}var test1=new String("abc");test1[5]="de";if(Object.getOwnPropertyNames(test1)[0]==="5"){return false}var test2={};for(var i=0;i<10;i++){test2["_"+String.fromCharCode(i)]=i}var order2=Object.getOwnPropertyNames(test2).map(function(n){return test2[n]});if(order2.join("")!=="0123456789"){return false}var test3={};"abcdefghijklmnopqrst".split("").forEach(function(letter){test3[letter]=letter});if(Object.keys(Object.assign({},test3)).join("")!=="abcdefghijklmnopqrst"){return false}return true}catch(err){return false}}module.exports=shouldUseNative()?Object.assign:function(target,source){var from;var to=toObject(target);var symbols;for(var s=1;s1){for(var i=1;i0||placeholder){var isInvisible=!_this5.state.show;_this5.setState({currentEvent:e,currentTarget:eventTarget,show:true},function(){_this5.updatePosition();if(isInvisible&&afterShow)afterShow()})}};clearTimeout(this.delayShowLoop);if(delayShow){this.delayShowLoop=setTimeout(updateState,delayTime)}else{updateState()}}},{key:"listenForTooltipExit",value:function listenForTooltipExit(){var show=this.state.show;if(show&&this.tooltipRef){this.tooltipRef.addEventListener("mouseleave",this.hideTooltip)}}},{key:"removeListenerForTooltipExit",value:function removeListenerForTooltipExit(){var show=this.state.show;if(show&&this.tooltipRef){this.tooltipRef.removeEventListener("mouseleave",this.hideTooltip)}}},{key:"hideTooltip",value:function hideTooltip(e,hasTarget){var _this6=this;var _state2=this.state,delayHide=_state2.delayHide,disable=_state2.disable;var afterHide=this.props.afterHide;var placeholder=this.getTooltipContent();if(!this.mount)return;if(this.isEmptyTip(placeholder)||disable)return;if(hasTarget){var targetArray=this.getTargetArray(this.props.id);var isMyElement=targetArray.some(function(ele){return ele===e.currentTarget});if(!isMyElement||!this.state.show)return}var resetState=function resetState(){var isVisible=_this6.state.show;if(_this6.mouseOnToolTip()){_this6.listenForTooltipExit();return}_this6.removeListenerForTooltipExit();_this6.setState({show:false},function(){_this6.removeScrollListener();if(isVisible&&afterHide)afterHide()})};this.clearTimer();if(delayHide){this.delayHideLoop=setTimeout(resetState,parseInt(delayHide,10))}else{resetState()}}},{key:"addScrollListener",value:function addScrollListener(currentTarget){var isCaptureMode=this.isCapture(currentTarget);window.addEventListener("scroll",this.hideTooltip,isCaptureMode)}},{key:"removeScrollListener",value:function removeScrollListener(){window.removeEventListener("scroll",this.hideTooltip)}},{key:"updatePosition",value:function updatePosition(){var _this7=this;var _state3=this.state,currentEvent=_state3.currentEvent,currentTarget=_state3.currentTarget,place=_state3.place,desiredPlace=_state3.desiredPlace,effect=_state3.effect,offset=_state3.offset;var node=_reactDom2.default.findDOMNode(this);var result=(0,_getPosition2.default)(currentEvent,currentTarget,node,place,desiredPlace,effect,offset);if(result.isNewState){return this.setState(result.newState,function(){_this7.updatePosition()})}node.style.left=result.position.left+"px";node.style.top=result.position.top+"px"}},{key:"setStyleHeader",value:function setStyleHeader(){var head=document.getElementsByTagName("head")[0];if(!head.querySelector('style[id="react-tooltip"]')){var tag=document.createElement("style");tag.id="react-tooltip";tag.innerHTML=_style2.default;if(typeof __webpack_nonce__!=="undefined"&&__webpack_nonce__){tag.setAttribute("nonce",__webpack_nonce__)}head.insertBefore(tag,head.firstChild)}}},{key:"clearTimer",value:function clearTimer(){clearTimeout(this.delayShowLoop);clearTimeout(this.delayHideLoop);clearTimeout(this.delayReshow);clearInterval(this.intervalUpdateContent)}},{key:"render",value:function render(){var _this8=this;var _state4=this.state,extraClass=_state4.extraClass,html=_state4.html,ariaProps=_state4.ariaProps,disable=_state4.disable;var placeholder=this.getTooltipContent();var isEmptyTip=this.isEmptyTip(placeholder);var tooltipClass=(0,_classnames2.default)("__react_component_tooltip",{show:this.state.show&&!disable&&!isEmptyTip},{border:this.state.border},{"place-top":this.state.place==="top"},{"place-bottom":this.state.place==="bottom"},{"place-left":this.state.place==="left"},{"place-right":this.state.place==="right"},{"type-dark":this.state.type==="dark"},{"type-success":this.state.type==="success"},{"type-warning":this.state.type==="warning"},{"type-error":this.state.type==="error"},{"type-info":this.state.type==="info"},{"type-light":this.state.type==="light"},{allow_hover:this.props.delayUpdate});var Wrapper=this.props.wrapper;if(ReactTooltip.supportedWrappers.indexOf(Wrapper)<0){Wrapper=ReactTooltip.defaultProps.wrapper}if(html){return _react2.default.createElement(Wrapper,_extends({className:tooltipClass+" "+extraClass,id:this.props.id,ref:function ref(_ref){return _this8.tooltipRef=_ref}},ariaProps,{"data-id":"tooltip",dangerouslySetInnerHTML:{__html:placeholder}}))}else{return _react2.default.createElement(Wrapper,_extends({className:tooltipClass+" "+extraClass,id:this.props.id},ariaProps,{ref:function ref(_ref2){return _this8.tooltipRef=_ref2},"data-id":"tooltip"}),placeholder)}}}]);return ReactTooltip}(_react2.default.Component),_class2.propTypes={children:_propTypes2.default.any,place:_propTypes2.default.string,type:_propTypes2.default.string,effect:_propTypes2.default.string,offset:_propTypes2.default.object,multiline:_propTypes2.default.bool,border:_propTypes2.default.bool,insecure:_propTypes2.default.bool,class:_propTypes2.default.string,className:_propTypes2.default.string,id:_propTypes2.default.string,html:_propTypes2.default.bool,delayHide:_propTypes2.default.number,delayUpdate:_propTypes2.default.number,delayShow:_propTypes2.default.number,event:_propTypes2.default.string,eventOff:_propTypes2.default.string,watchWindow:_propTypes2.default.bool,isCapture:_propTypes2.default.bool,globalEventOff:_propTypes2.default.string,getContent:_propTypes2.default.any,afterShow:_propTypes2.default.func,afterHide:_propTypes2.default.func,disable:_propTypes2.default.bool,scrollHide:_propTypes2.default.bool,resizeHide:_propTypes2.default.bool,wrapper:_propTypes2.default.string},_class2.defaultProps={insecure:true,resizeHide:true,wrapper:"div"},_class2.supportedWrappers=["div","span"],_class2.displayName="ReactTooltip",_temp))||_class)||_class)||_class)||_class)||_class)||_class;module.exports=ReactTooltip}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./decorators/customEvent":13,"./decorators/getEffect":14,"./decorators/isCapture":15,"./decorators/staticMethods":16,"./decorators/trackRemoval":17,"./decorators/windowListener":18,"./style":20,"./utils/aria":21,"./utils/getPosition":22,"./utils/getTipContent":23,"./utils/nodeListToArray":24,classnames:1,"prop-types":10}],20:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default='.__react_component_tooltip{border-radius:3px;display:inline-block;font-size:13px;left:-999em;opacity:0;padding:8px 21px;position:fixed;pointer-events:none;transition:opacity 0.3s ease-out;top:-999em;visibility:hidden;z-index:999}.__react_component_tooltip.allow_hover{pointer-events:auto}.__react_component_tooltip:before,.__react_component_tooltip:after{content:"";width:0;height:0;position:absolute}.__react_component_tooltip.show{opacity:0.9;margin-top:0px;margin-left:0px;visibility:visible}.__react_component_tooltip.type-dark{color:#fff;background-color:#222}.__react_component_tooltip.type-dark.place-top:after{border-top-color:#222;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-dark.place-bottom:after{border-bottom-color:#222;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-dark.place-left:after{border-left-color:#222;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-dark.place-right:after{border-right-color:#222;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-dark.border{border:1px solid #fff}.__react_component_tooltip.type-dark.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-dark.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-dark.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-dark.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-success{color:#fff;background-color:#8DC572}.__react_component_tooltip.type-success.place-top:after{border-top-color:#8DC572;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-success.place-bottom:after{border-bottom-color:#8DC572;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-success.place-left:after{border-left-color:#8DC572;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-success.place-right:after{border-right-color:#8DC572;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-success.border{border:1px solid #fff}.__react_component_tooltip.type-success.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-success.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-success.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-success.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-warning{color:#fff;background-color:#F0AD4E}.__react_component_tooltip.type-warning.place-top:after{border-top-color:#F0AD4E;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-warning.place-bottom:after{border-bottom-color:#F0AD4E;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-warning.place-left:after{border-left-color:#F0AD4E;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-warning.place-right:after{border-right-color:#F0AD4E;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-warning.border{border:1px solid #fff}.__react_component_tooltip.type-warning.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-warning.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-warning.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-warning.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-error{color:#fff;background-color:#BE6464}.__react_component_tooltip.type-error.place-top:after{border-top-color:#BE6464;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-error.place-bottom:after{border-bottom-color:#BE6464;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-error.place-left:after{border-left-color:#BE6464;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-error.place-right:after{border-right-color:#BE6464;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-error.border{border:1px solid #fff}.__react_component_tooltip.type-error.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-error.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-error.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-error.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-info{color:#fff;background-color:#337AB7}.__react_component_tooltip.type-info.place-top:after{border-top-color:#337AB7;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-info.place-bottom:after{border-bottom-color:#337AB7;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-info.place-left:after{border-left-color:#337AB7;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-info.place-right:after{border-right-color:#337AB7;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-info.border{border:1px solid #fff}.__react_component_tooltip.type-info.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-info.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-info.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-info.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-light{color:#222;background-color:#fff}.__react_component_tooltip.type-light.place-top:after{border-top-color:#fff;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-light.place-bottom:after{border-bottom-color:#fff;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-light.place-left:after{border-left-color:#fff;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-light.place-right:after{border-right-color:#fff;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-light.border{border:1px solid #222}.__react_component_tooltip.type-light.border.place-top:before{border-top:8px solid #222}.__react_component_tooltip.type-light.border.place-bottom:before{border-bottom:8px solid #222}.__react_component_tooltip.type-light.border.place-left:before{border-left:8px solid #222}.__react_component_tooltip.type-light.border.place-right:before{border-right:8px solid #222}.__react_component_tooltip.place-top{margin-top:-10px}.__react_component_tooltip.place-top:before{border-left:10px solid transparent;border-right:10px solid transparent;bottom:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-top:after{border-left:8px solid transparent;border-right:8px solid transparent;bottom:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-bottom{margin-top:10px}.__react_component_tooltip.place-bottom:before{border-left:10px solid transparent;border-right:10px solid transparent;top:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-bottom:after{border-left:8px solid transparent;border-right:8px solid transparent;top:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-left{margin-left:-10px}.__react_component_tooltip.place-left:before{border-top:6px solid transparent;border-bottom:6px solid transparent;right:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-left:after{border-top:5px solid transparent;border-bottom:5px solid transparent;right:-6px;top:50%;margin-top:-4px}.__react_component_tooltip.place-right{margin-left:10px}.__react_component_tooltip.place-right:before{border-top:6px solid transparent;border-bottom:6px solid transparent;left:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-right:after{border-top:5px solid transparent;border-bottom:5px solid transparent;left:-6px;top:50%;margin-top:-4px}.__react_component_tooltip .multi-line{display:block;padding:2px 0px;text-align:center}'},{}],21:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.parseAria=parseAria;function parseAria(props){var ariaObj={};Object.keys(props).filter(function(prop){return/(^aria-\w+$|^role$)/.test(prop)}).forEach(function(prop){ariaObj[prop]=props[prop]});return ariaObj}},{}],22:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=function(e,target,node,place,desiredPlace,effect,offset){var _getDimensions=getDimensions(node),tipWidth=_getDimensions.width,tipHeight=_getDimensions.height;var _getDimensions2=getDimensions(target),targetWidth=_getDimensions2.width,targetHeight=_getDimensions2.height;var _getCurrentOffset=getCurrentOffset(e,target,effect),mouseX=_getCurrentOffset.mouseX,mouseY=_getCurrentOffset.mouseY;var defaultOffset=getDefaultPosition(effect,targetWidth,targetHeight,tipWidth,tipHeight);var _calculateOffset=calculateOffset(offset),extraOffset_X=_calculateOffset.extraOffset_X,extraOffset_Y=_calculateOffset.extraOffset_Y;var windowWidth=window.innerWidth;var windowHeight=window.innerHeight;var _getParent=getParent(node),parentTop=_getParent.parentTop,parentLeft=_getParent.parentLeft;var getTipOffsetLeft=function getTipOffsetLeft(place){var offset_X=defaultOffset[place].l;return mouseX+offset_X+extraOffset_X};var getTipOffsetRight=function getTipOffsetRight(place){var offset_X=defaultOffset[place].r;return mouseX+offset_X+extraOffset_X};var getTipOffsetTop=function getTipOffsetTop(place){var offset_Y=defaultOffset[place].t;return mouseY+offset_Y+extraOffset_Y};var getTipOffsetBottom=function getTipOffsetBottom(place){var offset_Y=defaultOffset[place].b;return mouseY+offset_Y+extraOffset_Y};var outsideLeft=function outsideLeft(p){return getTipOffsetLeft(p)<0};var outsideRight=function outsideRight(p){return getTipOffsetRight(p)>windowWidth};var outsideTop=function outsideTop(p){return getTipOffsetTop(p)<0};var outsideBottom=function outsideBottom(p){return getTipOffsetBottom(p)>windowHeight};var outside=function outside(p){return outsideLeft(p)||outsideRight(p)||outsideTop(p)||outsideBottom(p)};var inside=function inside(p){return!outside(p)};var placesList=["top","bottom","left","right"];var insideList=[];for(var i=0;i<4;i++){var p=placesList[i];if(inside(p)){insideList.push(p)}}var isNewState=false;var newPlace=void 0;if(inside(desiredPlace)&&desiredPlace!==place){isNewState=true;newPlace=desiredPlace}else if(insideList.length>0&&outside(desiredPlace)&&outside(place)){isNewState=true;newPlace=insideList[0]}if(isNewState){return{isNewState:true,newState:{place:newPlace}}}return{isNewState:false,position:{left:parseInt(getTipOffsetLeft(place)-parentLeft,10),top:parseInt(getTipOffsetTop(place)-parentTop,10)}}};var getDimensions=function getDimensions(node){var _node$getBoundingClie=node.getBoundingClientRect(),height=_node$getBoundingClie.height,width=_node$getBoundingClie.width;return{height:parseInt(height,10),width:parseInt(width,10)}};var getCurrentOffset=function getCurrentOffset(e,currentTarget,effect){var boundingClientRect=currentTarget.getBoundingClientRect();var targetTop=boundingClientRect.top;var targetLeft=boundingClientRect.left;var _getDimensions3=getDimensions(currentTarget),targetWidth=_getDimensions3.width,targetHeight=_getDimensions3.height;if(effect==="float"){return{mouseX:e.clientX,mouseY:e.clientY}}return{mouseX:targetLeft+targetWidth/2,mouseY:targetTop+targetHeight/2}};var getDefaultPosition=function getDefaultPosition(effect,targetWidth,targetHeight,tipWidth,tipHeight){var top=void 0;var right=void 0;var bottom=void 0;var left=void 0;var disToMouse=3;var triangleHeight=2;var cursorHeight=12;if(effect==="float"){top={l:-(tipWidth/2),r:tipWidth/2,t:-(tipHeight+disToMouse+triangleHeight),b:-disToMouse};bottom={l:-(tipWidth/2),r:tipWidth/2,t:disToMouse+cursorHeight,b:tipHeight+disToMouse+triangleHeight+cursorHeight};left={l:-(tipWidth+disToMouse+triangleHeight),r:-disToMouse,t:-(tipHeight/2),b:tipHeight/2};right={l:disToMouse,r:tipWidth+disToMouse+triangleHeight,t:-(tipHeight/2),b:tipHeight/2}}else if(effect==="solid"){top={l:-(tipWidth/2),r:tipWidth/2,t:-(targetHeight/2+tipHeight+triangleHeight),b:-(targetHeight/2)};bottom={l:-(tipWidth/2),r:tipWidth/2,t:targetHeight/2,b:targetHeight/2+tipHeight+triangleHeight};left={l:-(tipWidth+targetWidth/2+triangleHeight),r:-(targetWidth/2),t:-(tipHeight/2),b:tipHeight/2};right={l:targetWidth/2,r:tipWidth+targetWidth/2+triangleHeight,t:-(tipHeight/2),b:tipHeight/2}}return{top:top,bottom:bottom,left:left,right:right}};var calculateOffset=function calculateOffset(offset){var extraOffset_X=0;var extraOffset_Y=0;if(Object.prototype.toString.apply(offset)==="[object String]"){offset=JSON.parse(offset.toString().replace(/\'/g,'"'))}for(var key in offset){if(key==="top"){extraOffset_Y-=parseInt(offset[key],10)}else if(key==="bottom"){extraOffset_Y+=parseInt(offset[key],10)}else if(key==="left"){extraOffset_X-=parseInt(offset[key],10)}else if(key==="right"){extraOffset_X+=parseInt(offset[key],10)}}return{extraOffset_X:extraOffset_X,extraOffset_Y:extraOffset_Y}};var getParent=function getParent(currentTarget){var currentParent=currentTarget;while(currentParent){if(window.getComputedStyle(currentParent).getPropertyValue("transform")!=="none")break;currentParent=currentParent.parentElement}var parentTop=currentParent&¤tParent.getBoundingClientRect().top||0;var parentLeft=currentParent&¤tParent.getBoundingClientRect().left||0;return{parentTop:parentTop,parentLeft:parentLeft}}},{}],23:[function(require,module,exports){(function(global){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=function(tip,children,getContent,multiline){if(children)return children;if(getContent!==undefined&&getContent!==null)return getContent;if(getContent===null)return null;var regexp=//;if(!multiline||multiline==="false"||!regexp.test(tip)){return tip}return tip.split(regexp).map(function(d,i){return _react2.default.createElement("span",{key:i,className:"multi-line"},d)})};var _react=typeof window!=="undefined"?window["React"]:typeof global!=="undefined"?global["React"]:null;var _react2=_interopRequireDefault(_react);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],24:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=function(nodeList){var length=nodeList.length;if(nodeList.hasOwnProperty){return Array.prototype.slice.call(nodeList)}return new Array(length).fill().map(function(index){return nodeList[index]})}},{}]},{},[19])(19)}); From 87b810a5d0e4caf8fec6503e1bdfa7e765885d9b Mon Sep 17 00:00:00 2001 From: Rogger794 Date: Sun, 9 Feb 2020 17:19:12 -0500 Subject: [PATCH 14/14] fix(githubPage): updating github page build in travis --- README.md | 3 +++ example/src/App.js | 24 ++++++++++++++---------- package.json | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a08477e3..56e1f499 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) [![npm download][download-image]][download-url] [![Build Status](https://travis-ci.org/wwayne/react-tooltip.svg?branch=master)](https://travis-ci.org/wwayne/react-tooltip) +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [download-image]: https://img.shields.io/npm/dm/react-tooltip.svg?style=flat-square [download-url]: https://npmjs.org/package/react-tooltip @@ -11,6 +12,8 @@ [![Edit ReactTooltip](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/heuristic-curran-bddeu?fontsize=14&hidenavigation=1&theme=dark) +Or see it on [Github Page](https://wwayne.github.io/react-tooltip/). + ## Maintainers [aronhelser](https://github.com/aronhelser) Passive maintainer - accepting PRs and doing minor testing, but not fixing issues or doing active development. diff --git a/example/src/App.js b/example/src/App.js index edbb0195..70cd5ef5 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -652,15 +652,16 @@ export default class App extends Component {

{"8 (❂‿❂)"}

{" \n" + + " getContent={(dataTip) => \n" + "

This little buddy is {dataTip}

Put mouse here

}\n" + - " effect='solid'\n" + - " delayHide={500}\n" + - " delayShow={500}\n" + - " delayUpdate={500}\n" + - " place={'right'}\n" + - " border={true}\n" + - " type={'light'}"} + " effect='solid'\n" + + " delayHide={500}\n" + + " delayShow={500}\n" + + " delayUpdate={500}\n" + + " place={'right'}\n" + + " border={true}\n" + + " type={'light'}\n" + + "/>"}

@@ -760,8 +761,11 @@ export default class App extends Component {

{"( •̀д•́) override\n" + - " {\n" + + " {\n" + " const d = document.documentElement;\n" + " left = Math.min(d.clientWidth - node.clientWidth, left);\n" + " top = Math.min(d.clientHeight - node.clientHeight, top);\n" + diff --git a/package.json b/package.json index fb6beaf5..b5dd6b43 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "path": "node_modules/cz-conventional-changelog" } }, + "publishConfig": { "registry": "https://npm.pkg.github.com/" }, "standard": { "parser": "babel-eslint", "ignore": [