Added logging, changed some directory structure

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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