From 38072225b001cdeb95353bb190e3c71a9fb7a74d Mon Sep 17 00:00:00 2001 From: Stefan Cameron Date: Sun, 10 Nov 2024 14:45:16 -0600 Subject: [PATCH] Updating demo to latest --- .gitignore | 2 - demo/demo-bundle.js | 38220 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 38220 insertions(+), 2 deletions(-) create mode 100644 demo/demo-bundle.js diff --git a/.gitignore b/.gitignore index 83a8217e..0f870e73 100644 --- a/.gitignore +++ b/.gitignore @@ -63,8 +63,6 @@ typings/ # Builds dist/ -# demo-bundle.js generated when running the demo -**/*-bundle.js # OS files .DS_Store diff --git a/demo/demo-bundle.js b/demo/demo-bundle.js new file mode 100644 index 00000000..4181262e --- /dev/null +++ b/demo/demo-bundle.js @@ -0,0 +1,38220 @@ +(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 r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } +var _require = require('react'), + useState = _require.useState; +var React = require('react'); +var _require2 = require('react-dom/client'), + createRoot = _require2.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-animated-dialog'); +var focusTrapOptions = { + checkCanFocusTrap: function checkCanFocusTrap(trapContainers) { + var results = trapContainers.map(function (trapContainer) { + return new Promise(function (resolve) { + var interval = setInterval(function () { + if (getComputedStyle(trapContainer).visibility !== 'hidden') { + resolve(); + clearInterval(interval); + } + }, 5); + }); + }); + // Return a promise that resolves when all the trap containers are able to receive focus + return Promise.all(results); + }, + // Called after focus is sent to the focus trap + onPostActivate: function onPostActivate() { + // eslint-disable-next-line no-console + console.log('Focus has been sent to the animated focus trap'); + } +}; +var DemoAnimatedDialog = function DemoAnimatedDialog() { + var _useState = useState(false), + _useState2 = _slicedToArray(_useState, 2), + isTrapActive = _useState2[0], + setIsTrapActive = _useState2[1]; + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, "\n .animated-dialog {\n position: absolute;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.5s, visibility 0.5s;\n }\n .animated-dialog.is-active {\n opacity: 1;\n visibility: visible;\n }\n "), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: function onClick() { + return setIsTrapActive(true); + }, + "aria-describedby": "animated-dialog-heading" + }, "activate trap"))), /*#__PURE__*/React.createElement(FocusTrap, { + active: isTrapActive, + focusTrapOptions: focusTrapOptions + }, /*#__PURE__*/React.createElement("div", { + className: ['trap', 'animated-dialog', isTrapActive ? 'is-active' : ''].join(' ') + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: function onClick() { + return setIsTrapActive(false); + }, + "aria-describedby": "animated-dialog-heading" + }, "deactivate trap"))))); +}; +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoAnimatedDialog, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],2:[function(require,module,exports){ +"use strict"; + +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } +var _require = require('react'), + useState = _require.useState; +var React = require('react'); +var _require2 = require('react-dom/client'), + createRoot = _require2.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-animated-trigger'); +var focusTrapOptions = { + // There is a delay between when the class is removed + // and when the trigger is focusable + checkCanReturnFocus: function checkCanReturnFocus(triggerButton) { + return new Promise(function (resolve) { + var interval = setInterval(function () { + if (getComputedStyle(triggerButton).visibility !== 'hidden') { + resolve(); + clearInterval(interval); + } + }, 5); + }); + }, + // Called after focus is sent to the trigger button + onPostDeactivate: function onPostDeactivate() { + // eslint-disable-next-line no-console + console.log('Focus has been sent to the animated focus trap trigger button'); + } +}; +var DemoAnimatedTrigger = function DemoAnimatedTrigger() { + var _useState = useState(false), + _useState2 = _slicedToArray(_useState, 2), + isTrapActive = _useState2[0], + setIsTrapActive = _useState2[1]; + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, "\n .animated-trigger {\n transition: opacity 0.5s, visibility 0.5s;\n }\n .animated-trigger.is-active {\n opacity: 0;\n visibility: hidden;\n }\n "), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + className: ['animated-trigger', isTrapActive ? 'is-active' : ''].join(' '), + onClick: function onClick() { + return setIsTrapActive(true); + }, + "aria-describedby": "animated-trigger-heading" + }, "activate trap"))), /*#__PURE__*/React.createElement(FocusTrap, { + active: isTrapActive, + focusTrapOptions: focusTrapOptions + }, /*#__PURE__*/React.createElement("div", { + className: ['trap', isTrapActive ? 'is-active' : ''].join(' ') + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: function onClick() { + return setIsTrapActive(false); + }, + "aria-describedby": "animated-trigger-heading" + }, "deactivate trap"))))); +}; +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoAnimatedTrigger, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],3:[function(require,module,exports){ +"use strict"; + +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +var React = require('react'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-autofocus'); +var DemoAutofocus = /*#__PURE__*/function (_React$Component) { + function DemoAutofocus(props) { + var _this; + _classCallCheck(this, DemoAutofocus); + _this = _callSuper(this, DemoAutofocus, [props]); + _this.state = { + activeTrap: false + }; + _this.mountTrap = _this.mountTrap.bind(_this); + _this.unmountTrap = _this.unmountTrap.bind(_this); + return _this; + } + _inherits(DemoAutofocus, _React$Component); + return _createClass(DemoAutofocus, [{ + key: "mountTrap", + value: function mountTrap() { + this.setState({ + activeTrap: true + }); + } + }, { + key: "unmountTrap", + value: function unmountTrap() { + this.setState({ + activeTrap: false + }); + } + }, { + key: "render", + value: function render() { + var trap = this.state.activeTrap && /*#__PURE__*/React.createElement(FocusTrap, { + focusTrapOptions: { + onDeactivate: this.unmountTrap + } + }, /*#__PURE__*/React.createElement("div", { + className: "trap is-active" + }, /*#__PURE__*/React.createElement("button", { + onClick: this.unmountTrap, + "aria-describedby": "autofocus-heading" + }, "deactivate trap"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", { + href: "#" + }, "Another focusable thing")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("label", { + htmlFor: "autofocused-input", + style: { + marginRight: 10 + } + }, "Autofocused input:"), /*#__PURE__*/React.createElement("input", { + id: "autofocused-input", + autoFocus: true, + "data-testid": "autofocus-el" + })))); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + key: "button", + onClick: this.mountTrap, + "aria-describedby": "autofocus-heading" + }, "activate trap")), trap); + } + }]); +}(React.Component); +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoAutofocus, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],4:[function(require,module,exports){ +"use strict"; + +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +var React = require('react'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-containerelements-childless'); +var DemoContainerElementsChildless = /*#__PURE__*/function (_React$Component) { + function DemoContainerElementsChildless(props) { + var _this; + _classCallCheck(this, DemoContainerElementsChildless); + _this = _callSuper(this, DemoContainerElementsChildless, [props]); + _this.state = { + activeTrap: false + }; + _this.mountTrap = _this.mountTrap.bind(_this); + _this.unmountTrap = _this.unmountTrap.bind(_this); + _this.setElementRef = _this.setElementRef.bind(_this); + _this.element1 = null; + _this.element2 = null; + return _this; + } + _inherits(DemoContainerElementsChildless, _React$Component); + return _createClass(DemoContainerElementsChildless, [{ + key: "mountTrap", + value: function mountTrap() { + this.setState({ + activeTrap: true + }); + } + }, { + key: "unmountTrap", + value: function unmountTrap() { + this.setState({ + activeTrap: false + }); + } + }, { + key: "setElementRef", + value: function setElementRef(refName) { + var _this2 = this; + return function (element) { + if (element && (!_this2[refName] || _this2[refName] !== element)) { + _this2[refName] = element; + _this2.forceUpdate(); // re-render + } + }; + } + }, { + key: "render", + value: function render() { + var trap = this.state.activeTrap && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FocusTrap, { + containerElements: [this.element1, this.element2], + focusTrapOptions: { + onDeactivate: this.unmountTrap, + allowOutsideClick: function allowOutsideClick(event) { + return event.target.id === 'demo-containerelements-childless-deactivate'; + } + } + }), /*#__PURE__*/React.createElement("div", { + className: "trap is-active" + }, /*#__PURE__*/React.createElement("p", { + ref: this.setElementRef('element1') + }, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, "Here is ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "something"), "."), /*#__PURE__*/React.createElement("p", { + ref: this.setElementRef('element2') + }, "Here is a another focus trap element. ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "See"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "how"), " it ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "works"), "."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + id: "demo-containerelements-childless-deactivate", + onClick: this.unmountTrap, + "aria-describedby": "containerelements-childless-heading" + }, "deactivate trap")))); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.mountTrap, + "aria-describedby": "containerelements-childless-heading" + }, "activate trap")), trap); + } + }]); +}(React.Component); +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoContainerElementsChildless, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],5:[function(require,module,exports){ +"use strict"; + +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +var React = require('react'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-containerelements'); +var DemoContainerElements = /*#__PURE__*/function (_React$Component) { + function DemoContainerElements(props) { + var _this; + _classCallCheck(this, DemoContainerElements); + _this = _callSuper(this, DemoContainerElements, [props]); + _this.state = { + activeTrap: false + }; + _this.mountTrap = _this.mountTrap.bind(_this); + _this.unmountTrap = _this.unmountTrap.bind(_this); + _this.setElementRef = _this.setElementRef.bind(_this); + _this.element1 = null; + _this.element2 = null; + return _this; + } + _inherits(DemoContainerElements, _React$Component); + return _createClass(DemoContainerElements, [{ + key: "mountTrap", + value: function mountTrap() { + this.setState({ + activeTrap: true + }); + } + }, { + key: "unmountTrap", + value: function unmountTrap() { + this.setState({ + activeTrap: false + }); + } + }, { + key: "setElementRef", + value: function setElementRef(refName) { + var _this2 = this; + return function (element) { + if (element && (!_this2[refName] || _this2[refName] !== element)) { + _this2[refName] = element; + _this2.forceUpdate(); // re-render + } + }; + } + }, { + key: "render", + value: function render() { + var trap = this.state.activeTrap && /*#__PURE__*/React.createElement(FocusTrap, { + containerElements: [this.element1, this.element2], + focusTrapOptions: { + onDeactivate: this.unmountTrap, + allowOutsideClick: function allowOutsideClick(event) { + return event.target.id === 'demo-containerelements-deactivate'; + } + } + }, /*#__PURE__*/React.createElement("div", { + className: "trap is-active" + }, /*#__PURE__*/React.createElement("p", { + ref: this.setElementRef('element1') + }, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, "Here is ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "something"), "."), /*#__PURE__*/React.createElement("p", { + ref: this.setElementRef('element2') + }, "Here is a another focus trap element. ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "See"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "how"), " it ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "works"), "."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + id: "demo-containerelements-deactivate", + onClick: this.unmountTrap, + "aria-describedby": "containerelements-heading" + }, "deactivate trap")))); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.mountTrap, + "aria-describedby": "containerelements-heading" + }, "activate trap")), trap); + } + }]); +}(React.Component); +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoContainerElements, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],6:[function(require,module,exports){ +"use strict"; + +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +var React = require('react'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-defaults'); +var DemoDefaults = /*#__PURE__*/function (_React$Component) { + function DemoDefaults(props) { + var _this; + _classCallCheck(this, DemoDefaults); + _this = _callSuper(this, DemoDefaults, [props]); + _this.state = { + activeTrap: false + }; + _this.mountTrap = _this.mountTrap.bind(_this); + _this.unmountTrap = _this.unmountTrap.bind(_this); + return _this; + } + _inherits(DemoDefaults, _React$Component); + return _createClass(DemoDefaults, [{ + key: "mountTrap", + value: function mountTrap() { + this.setState({ + activeTrap: true + }); + } + }, { + key: "unmountTrap", + value: function unmountTrap() { + this.setState({ + activeTrap: false + }); + } + }, { + key: "render", + value: function render() { + var trap = this.state.activeTrap && /*#__PURE__*/React.createElement(FocusTrap, { + focusTrapOptions: { + onDeactivate: this.unmountTrap + } + }, /*#__PURE__*/React.createElement("div", { + className: "trap is-active" + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.unmountTrap, + "aria-describedby": "defaults-heading" + }, "deactivate trap")))); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.mountTrap, + "aria-describedby": "defaults-heading" + }, "activate trap")), trap); + } + }]); +}(React.Component); +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoDefaults, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],7:[function(require,module,exports){ +"use strict"; + +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +var React = require('react'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-ffne'); +var DemoFfne = /*#__PURE__*/function (_React$Component) { + function DemoFfne(props) { + var _this; + _classCallCheck(this, DemoFfne); + _this = _callSuper(this, DemoFfne, [props]); + _this.state = { + activeTrap: false + }; + _this.mountTrap = _this.mountTrap.bind(_this); + _this.unmountTrap = _this.unmountTrap.bind(_this); + return _this; + } + _inherits(DemoFfne, _React$Component); + return _createClass(DemoFfne, [{ + key: "mountTrap", + value: function mountTrap() { + this.setState({ + activeTrap: true + }); + } + }, { + key: "unmountTrap", + value: function unmountTrap() { + this.setState({ + activeTrap: false + }); + } + }, { + key: "render", + value: function render() { + var trap = this.state.activeTrap && /*#__PURE__*/React.createElement(FocusTrap, { + focusTrapOptions: { + onDeactivate: this.unmountTrap, + initialFocus: '#focused-input', + escapeDeactivates: false + } + }, /*#__PURE__*/React.createElement("div", { + className: "trap is-active" + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("label", { + htmlFor: "focused-input", + style: { + marginRight: 10 + } + }, "Initially focused input:"), /*#__PURE__*/React.createElement("input", { + id: "focused-input" + })), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.unmountTrap, + "aria-describedby": "ffne-heading" + }, "deactivate trap")))); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.mountTrap, + "aria-describedby": "ffne-heading" + }, "activate trap")), trap); + } + }]); +}(React.Component); +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoFfne, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],8:[function(require,module,exports){ +"use strict"; + +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } +var React = require('react'); +var ReactDOM = require('react-dom'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var PropTypes = require('prop-types'); +var FocusTrap = require('../../dist/focus-trap-react'); +var useRef = React.useRef, + useState = React.useState, + useEffect = React.useEffect; +var container = document.getElementById('demo-iframe'); +var SandboxContext = React.createContext({ + document: document +}); +SandboxContext.displayName = 'SandboxContext'; +var SandboxContextConsumer = SandboxContext.Consumer; +var Sandbox = function Sandbox(_ref) { + var children = _ref.children; + var iframeRef = useRef(null); + var _useState = useState({ + iframeLoaded: false + }), + _useState2 = _slicedToArray(_useState, 2), + state = _useState2[0], + setState = _useState2[1]; + useEffect(function () { + var iframe = iframeRef.current; + var loadIframe = function loadIframe() { + var contentWindow = iframe.contentWindow; + var cssLink = document.createElement('link'); + cssLink.href = 'style.css'; + cssLink.rel = 'stylesheet'; + cssLink.type = 'text/css'; + if (contentWindow) { + var head = contentWindow.document.head; + head.appendChild(cssLink); + setTimeout(function () { + return setState({ + iframeLoaded: true + }); + }, 0); + } + }; + var isIframeLoaded = iframe.contentWindow !== null; + if (isIframeLoaded) { + loadIframe(); + } else { + iframe.onload = loadIframe; + } + }, []); + return /*#__PURE__*/React.createElement("iframe", { + ref: iframeRef, + style: { + padding: 0, + border: 0 + } + }, state.iframeLoaded && ReactDOM.createPortal(/*#__PURE__*/React.createElement(SandboxContext.Provider, { + value: iframeRef.current.contentDocument + }, children), iframeRef.current.contentDocument.body)); +}; +Sandbox.propTypes = { + children: PropTypes.node.isRequired +}; +var DemoIframe = function DemoIframe() { + var _useState3 = useState({ + activeTrap: false + }), + _useState4 = _slicedToArray(_useState3, 2), + state = _useState4[0], + setState = _useState4[1]; + var mountTrap = function mountTrap() { + setState({ + activeTrap: true + }); + }; + var unmountTrap = function unmountTrap() { + setState({ + activeTrap: false + }); + }; + var trap = state.activeTrap && /*#__PURE__*/React.createElement(Sandbox, null, /*#__PURE__*/React.createElement(SandboxContextConsumer, null, function (document) { + return /*#__PURE__*/React.createElement(FocusTrap, { + focusTrapOptions: { + document: document, + onDeactivate: unmountTrap + } + }, /*#__PURE__*/React.createElement("div", { + className: "trap is-active" + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap inside an iframe ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: unmountTrap, + "aria-describedby": "iframe-heading" + }, "deactivate trap")))); + })); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: mountTrap, + "aria-describedby": "iframe-heading" + }, "activate trap")), trap); +}; +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoIframe, null)); + +},{"../../dist/focus-trap-react":13,"prop-types":20,"react":32,"react-dom":29,"react-dom/client":28}],9:[function(require,module,exports){ +"use strict"; + +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } +var _require = require('react'), + useState = _require.useState, + useMemo = _require.useMemo; +var React = require('react'); +var _require2 = require('react-dom/client'), + createRoot = _require2.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-setReturnFocus'); +var DemoSetReturnFocusDialog = function DemoSetReturnFocusDialog() { + var _useState = useState(false), + _useState2 = _slicedToArray(_useState, 2), + isTrapActive = _useState2[0], + setIsTrapActive = _useState2[1]; + var focusTrapOptions = useMemo(function () { + return { + setReturnFocus: function setReturnFocus(prevSelNode) { + // contrived code to prove during tests that the setReturnFocus() option + // can be a function that is given a reference to the node that was focused + // prior to trap activation + return prevSelNode.parentNode.querySelector('#AlternateReturnFocusElement'); + }, + onDeactivate: function onDeactivate() { + return setIsTrapActive(false); + } + }; + }, []); + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: function onClick() { + return setIsTrapActive(true); + }, + "aria-describedby": "setReturnFocus-heading" + }, "activate trap"), /*#__PURE__*/React.createElement("button", { + id: "AlternateReturnFocusElement", + onClick: function onClick() {} + }, "Alternate Return Focus Element"))), isTrapActive && /*#__PURE__*/React.createElement(FocusTrap, { + focusTrapOptions: focusTrapOptions + }, /*#__PURE__*/React.createElement("div", { + className: "trap is-active" + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: function onClick() { + return setIsTrapActive(false); + }, + "aria-describedby": "setReturnFocus-heading" + }, "deactivate trap"))))); +}; +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoSetReturnFocusDialog, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],10:[function(require,module,exports){ +"use strict"; + +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +var React = require('react'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var container = document.getElementById('demo-special-element'); +var DemoSpecialElement = /*#__PURE__*/function (_React$Component) { + function DemoSpecialElement(props) { + var _this; + _classCallCheck(this, DemoSpecialElement); + _this = _callSuper(this, DemoSpecialElement, [props]); + _this.state = { + activeTrap: false, + passThruMsg: '' + }; + _this.mountTrap = _this.mountTrap.bind(_this); + _this.unmountTrap = _this.unmountTrap.bind(_this); + _this.updatePassThruMsg = _this.updatePassThruMsg.bind(_this); + return _this; + } + _inherits(DemoSpecialElement, _React$Component); + return _createClass(DemoSpecialElement, [{ + key: "mountTrap", + value: function mountTrap() { + this.setState({ + activeTrap: true, + passThruMsg: '' + }); + } + }, { + key: "unmountTrap", + value: function unmountTrap() { + this.setState({ + activeTrap: false + }); + } + }, { + key: "updatePassThruMsg", + value: function updatePassThruMsg() { + this.setState({ + passThruMsg: 'Clicked!' + }); + } + }, { + key: "render", + value: function render() { + var trapClass = 'trap'; + if (this.state.activeTrap) { + trapClass += ' is-active'; + } + return /*#__PURE__*/React.createElement(React.StrictMode, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.mountTrap, + "aria-describedby": "special-element-heading" + }, "activate trap"), /*#__PURE__*/React.createElement("button", { + onClick: this.updatePassThruMsg + }, "pass thru click"), /*#__PURE__*/React.createElement("span", null, this.state.passThruMsg)), /*#__PURE__*/React.createElement(FocusTrap, { + active: this.state.activeTrap, + focusTrapOptions: { + onPostDeactivate: this.unmountTrap, + clickOutsideDeactivates: true, + returnFocusOnDeactivate: true + } + }, /*#__PURE__*/React.createElement("section", { + id: "focus-trap-three", + style: this.state.activeTrap ? null : { + background: '#eee' + }, + "data-whatever": "nothing", + className: trapClass + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: this.unmountTrap, + "aria-describedby": "special-element-heading" + }, "deactivate trap")))))); + } + }]); +}(React.Component); +var root = createRoot(container); +root.render(/*#__PURE__*/React.createElement(DemoSpecialElement, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],11:[function(require,module,exports){ +"use strict"; + +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } +var React = require('react'); +var _require = require('react-dom/client'), + createRoot = _require.createRoot; +var FocusTrap = require('../../dist/focus-trap-react'); +var createShadow = function createShadow(hostEl, isOpen) { + var containerEl = document.createElement('div'); + containerEl.id = 'with-shadow-dom-closed-container'; + containerEl.style = "border: 1px dotted black; margin-top: 10px; padding: 10px; background-color: ".concat(isOpen ? 'transparent' : 'rgba(0, 0, 0, 0.05)', ";"); + containerEl.innerHTML = "\n

\n This field is inside a ".concat(isOpen ? 'opened' : 'closed', " Shadow DOM:\n

\n \n "); + + // use same styles as host + var styleLinkEl = document.createElement('link'); + styleLinkEl.setAttribute('rel', 'stylesheet'); + styleLinkEl.setAttribute('href', 'style.css'); + var shadowEl = hostEl.attachShadow({ + mode: isOpen ? 'open' : 'closed' + }); + shadowEl.appendChild(styleLinkEl); + shadowEl.appendChild(containerEl); + return shadowEl; +}; +var DemoWithShadowDom = function DemoWithShadowDom() { + var _React$useState = React.useState(false), + _React$useState2 = _slicedToArray(_React$useState, 2), + active = _React$useState2[0], + setActive = _React$useState2[1]; + var openedShadowHostRef = React.useRef(null); + var openedShadowRef = React.useRef(null); + var closedShadowHostRef = React.useRef(null); + var closedShadowRef = React.useRef(null); + var handleTrapActivate = React.useCallback(function () { + setActive(true); + }, []); + var handleTrapDeactivate = React.useCallback(function () { + setActive(false); + }, []); + React.useEffect(function () { + if (openedShadowHostRef.current && !openedShadowRef.current) { + openedShadowRef.current = createShadow(openedShadowHostRef.current, true); + } + if (closedShadowHostRef.current && !closedShadowRef.current) { + closedShadowRef.current = createShadow(closedShadowHostRef.current, false); + } + }, []); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: handleTrapActivate, + "aria-describedby": "with-shadow-dom-heading" + }, "activate trap")), /*#__PURE__*/React.createElement(FocusTrap, { + active: active, + focusTrapOptions: { + onDeactivate: handleTrapDeactivate, + tabbableOptions: { + getShadowRoot: function getShadowRoot(node) { + if (node === closedShadowHostRef.current) { + return closedShadowHostRef.current; + } + } + } + } + }, /*#__PURE__*/React.createElement("div", { + className: "trap ".concat(active ? 'is-active' : '') + }, /*#__PURE__*/React.createElement("p", null, "Here is a focus trap ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "with"), " ", /*#__PURE__*/React.createElement("a", { + href: "#" + }, "some"), ' ', /*#__PURE__*/React.createElement("a", { + href: "#" + }, "focusable"), " parts."), /*#__PURE__*/React.createElement("div", { + id: "with-shadow-dom-opened-host", + ref: openedShadowHostRef + }), /*#__PURE__*/React.createElement("div", { + id: "with-shadow-dom-closed-host", + ref: closedShadowHostRef + }), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", { + onClick: handleTrapDeactivate, + "aria-describedby": "with-shadow-dom-heading" + }, "deactivate trap"))))); +}; +var root = createRoot(document.getElementById('demo-with-shadow-dom')); +root.render(/*#__PURE__*/React.createElement(DemoWithShadowDom, null)); + +},{"../../dist/focus-trap-react":13,"react":32,"react-dom/client":28}],12:[function(require,module,exports){ +"use strict"; + +require('./demo-defaults'); +require('./demo-animated-dialog'); +require('./demo-animated-trigger'); +require('./demo-ffne'); +require('./demo-special-element'); +require('./demo-autofocus'); +require('./demo-containerelements'); +require('./demo-containerelements-childless'); +require('./demo-setReturnFocus'); +require('./demo-iframe'); +require('./demo-with-shadow-dom'); // TEST MANUALLY (Cypress doesn't support Shadow DOM well) + +},{"./demo-animated-dialog":1,"./demo-animated-trigger":2,"./demo-autofocus":3,"./demo-containerelements":5,"./demo-containerelements-childless":4,"./demo-defaults":6,"./demo-ffne":7,"./demo-iframe":8,"./demo-setReturnFocus":9,"./demo-special-element":10,"./demo-with-shadow-dom":11}],13:[function(require,module,exports){ +"use strict"; + +function _typeof(o) { + "@babel/helpers - typeof"; + + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, _typeof(o); +} +function _classCallCheck(a, n) { + if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); +} +function _defineProperties(e, r) { + for (var t = 0; t < r.length; t++) { + var o = r[t]; + o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); + } +} +function _createClass(e, r, t) { + return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { + writable: !1 + }), e; +} +function _callSuper(t, o, e) { + return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); +} +function _possibleConstructorReturn(t, e) { + if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; + if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); + return _assertThisInitialized(t); +} +function _assertThisInitialized(e) { + if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return e; +} +function _isNativeReflectConstruct() { + try { + var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (t) {} + return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { + return !!t; + })(); +} +function _getPrototypeOf(t) { + return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { + return t.__proto__ || Object.getPrototypeOf(t); + }, _getPrototypeOf(t); +} +function _inherits(t, e) { + if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); + t.prototype = Object.create(e && e.prototype, { + constructor: { + value: t, + writable: !0, + configurable: !0 + } + }), Object.defineProperty(t, "prototype", { + writable: !1 + }), e && _setPrototypeOf(t, e); +} +function _setPrototypeOf(t, e) { + return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { + return t.__proto__ = e, t; + }, _setPrototypeOf(t, e); +} +function _defineProperty(e, r, t) { + return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { + value: t, + enumerable: !0, + configurable: !0, + writable: !0 + }) : e[r] = t, e; +} +function _toPropertyKey(t) { + var i = _toPrimitive(t, "string"); + return "symbol" == _typeof(i) ? i : i + ""; +} +function _toPrimitive(t, r) { + if ("object" != _typeof(t) || !t) return t; + var e = t[Symbol.toPrimitive]; + if (void 0 !== e) { + var i = e.call(t, r || "default"); + if ("object" != _typeof(i)) return i; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return ("string" === r ? String : Number)(t); +} +var React = require('react'); +var PropTypes = require('prop-types'); +var _require = require('focus-trap'), + createFocusTrap = _require.createFocusTrap; +var _require2 = require('tabbable'), + isFocusable = _require2.isFocusable; +var FocusTrap = /*#__PURE__*/function (_React$Component) { + function FocusTrap(props) { + var _this; + _classCallCheck(this, FocusTrap); + _this = _callSuper(this, FocusTrap, [props]); + /** + * Gets the node for the given option, which is expected to be an option that + * can be either a DOM node, a string that is a selector to get a node, `false` + * (if a node is explicitly NOT given), or a function that returns any of these + * values. + * @param {string} optionName + * @returns {undefined | false | HTMLElement | SVGElement} Returns + * `undefined` if the option is not specified; `false` if the option + * resolved to `false` (node explicitly not given); otherwise, the resolved + * DOM node. + * @throws {Error} If the option is set, not `false`, and is not, or does not + * resolve to a node. + */ + _defineProperty(_this, "getNodeForOption", function (optionName) { + var _this$internalOptions; + // use internal options first, falling back to original options + var optionValue = (_this$internalOptions = this.internalOptions[optionName]) !== null && _this$internalOptions !== void 0 ? _this$internalOptions : this.originalOptions[optionName]; + if (typeof optionValue === 'function') { + for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + params[_key - 1] = arguments[_key]; + } + optionValue = optionValue.apply(void 0, params); + } + if (optionValue === true) { + optionValue = undefined; // use default value + } + if (!optionValue) { + if (optionValue === undefined || optionValue === false) { + return optionValue; + } + // else, empty string (invalid), null (invalid), 0 (invalid) + + throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node")); + } + var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point + + if (typeof optionValue === 'string') { + var _this$getDocument; + node = (_this$getDocument = this.getDocument()) === null || _this$getDocument === void 0 ? void 0 : _this$getDocument.querySelector(optionValue); // resolve to node, or null if fails + if (!node) { + throw new Error("`".concat(optionName, "` as selector refers to no known node")); + } + } + return node; + }); + _this.handleDeactivate = _this.handleDeactivate.bind(_this); + _this.handlePostDeactivate = _this.handlePostDeactivate.bind(_this); + _this.handleClickOutsideDeactivates = _this.handleClickOutsideDeactivates.bind(_this); + + // focus-trap options used internally when creating the trap + _this.internalOptions = { + // We need to hijack the returnFocusOnDeactivate option, + // because React can move focus into the element before we arrived at + // this lifecycle hook (e.g. with autoFocus inputs). So the component + // captures the previouslyFocusedElement in componentWillMount, + // then (optionally) returns focus to it in componentWillUnmount. + returnFocusOnDeactivate: false, + // the rest of these are also related to deactivation of the trap, and we + // need to use them and control them as well + checkCanReturnFocus: null, + onDeactivate: _this.handleDeactivate, + onPostDeactivate: _this.handlePostDeactivate, + // we need to special-case this setting as well so that we can know if we should + // NOT return focus if the trap gets auto-deactivated as the result of an + // outside click (otherwise, we'll always think we should return focus because + // of how we manage that flag internally here) + clickOutsideDeactivates: _this.handleClickOutsideDeactivates + }; + + // original options provided by the consumer + _this.originalOptions = { + // because of the above `internalOptions`, we maintain our own flag for + // this option, and default it to `true` because that's focus-trap's default + returnFocusOnDeactivate: true, + // because of the above `internalOptions`, we keep these separate since + // they're part of the deactivation process which we configure (internally) to + // be shared between focus-trap and focus-trap-react + onDeactivate: null, + onPostDeactivate: null, + checkCanReturnFocus: null, + // the user's setting, defaulted to false since focus-trap defaults this to false + clickOutsideDeactivates: false + }; + var focusTrapOptions = props.focusTrapOptions; + for (var optionName in focusTrapOptions) { + if (!Object.prototype.hasOwnProperty.call(focusTrapOptions, optionName)) { + continue; + } + if (optionName === 'returnFocusOnDeactivate' || optionName === 'onDeactivate' || optionName === 'onPostDeactivate' || optionName === 'checkCanReturnFocus' || optionName === 'clickOutsideDeactivates') { + _this.originalOptions[optionName] = focusTrapOptions[optionName]; + continue; // exclude from internalOptions + } + _this.internalOptions[optionName] = focusTrapOptions[optionName]; + } + + // if set, `{ target: Node, allowDeactivation: boolean }` where `target` is the outside + // node that was clicked, and `allowDeactivation` is the result of the consumer's + // option (stored in `this.originalOptions.clickOutsideDeactivates`, which may be a + // function) whether to allow or deny auto-deactivation on click on this outside node + _this.outsideClick = null; + + // elements from which to create the focus trap on mount; if a child is used + // instead of the `containerElements` prop, we'll get the child's related + // element when the trap renders and then is declared 'mounted' + _this.focusTrapElements = props.containerElements || []; + + // now we remember what the currently focused element is, not relying on focus-trap + _this.updatePreviousElement(); + return _this; + } + + /** + * Gets the configured document. + * @returns {Document|undefined} Configured document, falling back to the main + * document, if it exists. During SSR, `undefined` is returned since the + * document doesn't exist. + */ + _inherits(FocusTrap, _React$Component); + return _createClass(FocusTrap, [{ + key: "getDocument", + value: function getDocument() { + // SSR: careful to check if `document` exists before accessing it as a variable + return this.props.focusTrapOptions.document || (typeof document !== 'undefined' ? document : undefined); + } + }, { + key: "getReturnFocusNode", + value: function getReturnFocusNode() { + var node = this.getNodeForOption('setReturnFocus', this.previouslyFocusedElement); + return node ? node : node === false ? false : this.previouslyFocusedElement; + } + + /** Update the previously focused element with the currently focused element. */ + }, { + key: "updatePreviousElement", + value: function updatePreviousElement() { + var currentDocument = this.getDocument(); + if (currentDocument) { + this.previouslyFocusedElement = currentDocument.activeElement; + } + } + }, { + key: "deactivateTrap", + value: function deactivateTrap() { + // NOTE: it's possible the focus trap has already been deactivated without our knowing it, + // especially if the user set the `clickOutsideDeactivates: true` option on the trap, + // and the mouse was clicked on some element outside the trap; at that point, focus-trap + // will initiate its auto-deactivation process, which will call our own + // handleDeactivate(), which will call into this method + if (!this.focusTrap || !this.focusTrap.active) { + return; + } + this.focusTrap.deactivate({ + // NOTE: we never let the trap return the focus since we do that ourselves + returnFocus: false, + // we'll call this in our own post deactivate handler so make sure the trap doesn't + // do it prematurely + checkCanReturnFocus: null, + // let it call the user's original deactivate handler, if any, instead of + // our own which calls back into this function + onDeactivate: this.originalOptions.onDeactivate + // NOTE: for post deactivate, don't specify anything so that it calls the + // onPostDeactivate handler specified on `this.internalOptions` + // which will always be our own `handlePostDeactivate()` handler, which + // will finish things off by calling the user's provided onPostDeactivate + // handler, if any, at the right time + // onPostDeactivate: NOTHING + }); + } + }, { + key: "handleClickOutsideDeactivates", + value: function handleClickOutsideDeactivates(event) { + // use consumer's option (or call their handler) as the permission or denial + var allowDeactivation = typeof this.originalOptions.clickOutsideDeactivates === 'function' ? this.originalOptions.clickOutsideDeactivates.call(null, event) // call out of context + : this.originalOptions.clickOutsideDeactivates; // boolean + + if (allowDeactivation) { + // capture the outside target that was clicked so we can use it in the deactivation + // process since the consumer allowed it to cause auto-deactivation + this.outsideClick = { + target: event.target, + allowDeactivation: allowDeactivation + }; + } + return allowDeactivation; + } + }, { + key: "handleDeactivate", + value: function handleDeactivate() { + if (this.originalOptions.onDeactivate) { + this.originalOptions.onDeactivate.call(null); // call user's handler out of context + } + this.deactivateTrap(); + } + }, { + key: "handlePostDeactivate", + value: function handlePostDeactivate() { + var _this2 = this; + var finishDeactivation = function finishDeactivation() { + var returnFocusNode = _this2.getReturnFocusNode(); + var canReturnFocus = !!( + // did the consumer allow it? + + _this2.originalOptions.returnFocusOnDeactivate && + // can we actually focus the node? + returnFocusNode !== null && returnFocusNode !== void 0 && returnFocusNode.focus && ( + // was there an outside click that allowed deactivation? + !_this2.outsideClick || + // did the consumer allow deactivation when the outside node was clicked? + _this2.outsideClick.allowDeactivation && + // is the outside node NOT focusable (implying that it did NOT receive focus + // as a result of the click-through) -- in which case do NOT restore focus + // to `returnFocusNode` because focus should remain on the outside node + !isFocusable(_this2.outsideClick.target, _this2.internalOptions.tabbableOptions)) + + // if no, the restore focus to `returnFocusNode` at this point + ); + var _this2$internalOption = _this2.internalOptions.preventScroll, + preventScroll = _this2$internalOption === void 0 ? false : _this2$internalOption; + if (canReturnFocus) { + // return focus to the element that had focus when the trap was activated + returnFocusNode.focus({ + preventScroll: preventScroll + }); + } + if (_this2.originalOptions.onPostDeactivate) { + _this2.originalOptions.onPostDeactivate.call(null); // don't call it in context of "this" + } + _this2.outsideClick = null; // reset: no longer needed + }; + if (this.originalOptions.checkCanReturnFocus) { + this.originalOptions.checkCanReturnFocus.call(null, this.getReturnFocusNode()) // call out of context + .then(finishDeactivation, finishDeactivation); + } else { + finishDeactivation(); + } + } + }, { + key: "setupFocusTrap", + value: function setupFocusTrap() { + if (this.focusTrap) { + // trap already exists: it's possible we're in StrictMode and we're being remounted, + // in which case, we will have deactivated the trap when we got unmounted (remember, + // StrictMode, in development, purposely unmounts and remounts components after + // mounting them the first time to make sure they have reusable state, + // @see https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state) so now + // we need to restore the state of the trap according to our component state + // NOTE: Strict mode __violates__ assumptions about the `componentWillUnmount()` API + // which clearly states -- even for React 18 -- that, "Once a component instance is + // unmounted, __it will never be mounted again.__" (emphasis ours). So when we get + // unmounted, we assume we're gone forever and we deactivate the trap. But then + // we get remounted and we're supposed to restore state. But if you had paused, + // we've now deactivated (we don't know we're amount to get remounted again) + // which means we need to reactivate and then pause. Otherwise, do nothing. + if (this.props.active && !this.focusTrap.active) { + this.focusTrap.activate(); + if (this.props.paused) { + this.focusTrap.pause(); + } + } + } else { + var nodesExist = this.focusTrapElements.some(Boolean); + if (nodesExist) { + // eslint-disable-next-line react/prop-types -- _createFocusTrap is an internal prop + this.focusTrap = this.props._createFocusTrap(this.focusTrapElements, this.internalOptions); + if (this.props.active) { + this.focusTrap.activate(); + } + if (this.props.paused) { + this.focusTrap.pause(); + } + } + } + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + if (this.props.active) { + this.setupFocusTrap(); + } + // else, wait for later activation in case the `focusTrapOptions` will be updated + // again before the trap is activated (e.g. if waiting to know what the document + // object will be, so the Trap must be rendered, but the consumer is waiting to + // activate until they have obtained the document from a ref) + // @see https://github.com/focus-trap/focus-trap-react/issues/539 + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps) { + if (this.focusTrap) { + if (prevProps.containerElements !== this.props.containerElements) { + this.focusTrap.updateContainerElements(this.props.containerElements); + } + var hasActivated = !prevProps.active && this.props.active; + var hasDeactivated = prevProps.active && !this.props.active; + var hasPaused = !prevProps.paused && this.props.paused; + var hasUnpaused = prevProps.paused && !this.props.paused; + if (hasActivated) { + this.updatePreviousElement(); + this.focusTrap.activate(); + } + if (hasDeactivated) { + this.deactivateTrap(); + return; // un/pause does nothing on an inactive trap + } + if (hasPaused) { + this.focusTrap.pause(); + } + if (hasUnpaused) { + this.focusTrap.unpause(); + } + } else { + // NOTE: if we're in `componentDidUpdate` and we don't have a trap yet, + // it either means it shouldn't be active, or it should be but none of + // of given `containerElements` were present in the DOM the last time + // we tried to create the trap + + if (prevProps.containerElements !== this.props.containerElements) { + this.focusTrapElements = this.props.containerElements; + } + + // don't create the trap unless it should be active in case the consumer + // is still updating `focusTrapOptions` + // @see https://github.com/focus-trap/focus-trap-react/issues/539 + if (this.props.active) { + this.updatePreviousElement(); + this.setupFocusTrap(); + } + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.deactivateTrap(); + } + }, { + key: "render", + value: function render() { + var _this3 = this; + var child = this.props.children ? React.Children.only(this.props.children) : undefined; + if (child) { + if (child.type && child.type === React.Fragment) { + throw new Error('A focus-trap cannot use a Fragment as its child container. Try replacing it with a
element.'); + } + var callbackRef = function callbackRef(element) { + var containerElements = _this3.props.containerElements; + if (child) { + if (typeof child.ref === 'function') { + child.ref(element); + } else if (child.ref) { + child.ref.current = element; + } + } + _this3.focusTrapElements = containerElements ? containerElements : [element]; + }; + var childWithRef = React.cloneElement(child, { + ref: callbackRef + }); + return childWithRef; + } + return null; + } + }]); +}(React.Component); // support server-side rendering where `Element` will not be defined +var ElementType = typeof Element === 'undefined' ? Function : Element; +FocusTrap.propTypes = { + active: PropTypes.bool, + paused: PropTypes.bool, + focusTrapOptions: PropTypes.shape({ + document: PropTypes.object, + onActivate: PropTypes.func, + onPostActivate: PropTypes.func, + checkCanFocusTrap: PropTypes.func, + onPause: PropTypes.func, + onPostPause: PropTypes.func, + onUnpause: PropTypes.func, + onPostUnpause: PropTypes.func, + onDeactivate: PropTypes.func, + onPostDeactivate: PropTypes.func, + checkCanReturnFocus: PropTypes.func, + initialFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.bool, PropTypes.func]), + fallbackFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, + // NOTE: does not support `false` as value (or return value from function) + PropTypes.func]), + escapeDeactivates: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), + clickOutsideDeactivates: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), + returnFocusOnDeactivate: PropTypes.bool, + setReturnFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.bool, PropTypes.func]), + allowOutsideClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), + preventScroll: PropTypes.bool, + tabbableOptions: PropTypes.shape({ + displayCheck: PropTypes.oneOf(['full', 'legacy-full', 'non-zero-area', 'none']), + getShadowRoot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]) + }), + trapStack: PropTypes.array, + isKeyForward: PropTypes.func, + isKeyBackward: PropTypes.func + }), + containerElements: PropTypes.arrayOf(PropTypes.instanceOf(ElementType)), + // DOM element ONLY + children: PropTypes.oneOfType([PropTypes.element, + // React element + PropTypes.instanceOf(ElementType) // DOM element + ]) + + // NOTE: _createFocusTrap is internal, for testing purposes only, so we don't + // specify it here. It's expected to be set to the function returned from + // require('focus-trap'), or one with a compatible interface. +}; +FocusTrap.defaultProps = { + active: true, + paused: false, + focusTrapOptions: {}, + _createFocusTrap: createFocusTrap +}; +module.exports = FocusTrap; + +},{"focus-trap":14,"prop-types":20,"react":32,"tabbable":36}],14:[function(require,module,exports){ +/*! +* focus-trap 7.6.1 +* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE +*/ +'use strict'; + +var tabbable = require('tabbable'); + +function _arrayLikeToArray(r, a) { + (null == a || a > r.length) && (a = r.length); + for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; + return n; +} +function _arrayWithoutHoles(r) { + if (Array.isArray(r)) return _arrayLikeToArray(r); +} +function _defineProperty(e, r, t) { + return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { + value: t, + enumerable: !0, + configurable: !0, + writable: !0 + }) : e[r] = t, e; +} +function _iterableToArray(r) { + if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); +} +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +function ownKeys(e, r) { + var t = Object.keys(e); + if (Object.getOwnPropertySymbols) { + var o = Object.getOwnPropertySymbols(e); + r && (o = o.filter(function (r) { + return Object.getOwnPropertyDescriptor(e, r).enumerable; + })), t.push.apply(t, o); + } + return t; +} +function _objectSpread2(e) { + for (var r = 1; r < arguments.length; r++) { + var t = null != arguments[r] ? arguments[r] : {}; + r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { + _defineProperty(e, r, t[r]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { + Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); + }); + } + return e; +} +function _toConsumableArray(r) { + return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); +} +function _toPrimitive(t, r) { + if ("object" != typeof t || !t) return t; + var e = t[Symbol.toPrimitive]; + if (void 0 !== e) { + var i = e.call(t, r || "default"); + if ("object" != typeof i) return i; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return ("string" === r ? String : Number)(t); +} +function _toPropertyKey(t) { + var i = _toPrimitive(t, "string"); + return "symbol" == typeof i ? i : i + ""; +} +function _unsupportedIterableToArray(r, a) { + if (r) { + if ("string" == typeof r) return _arrayLikeToArray(r, a); + var t = {}.toString.call(r).slice(8, -1); + return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; + } +} + +var activeFocusTraps = { + activateTrap: function activateTrap(trapStack, trap) { + if (trapStack.length > 0) { + var activeTrap = trapStack[trapStack.length - 1]; + if (activeTrap !== trap) { + activeTrap.pause(); + } + } + var trapIndex = trapStack.indexOf(trap); + if (trapIndex === -1) { + trapStack.push(trap); + } else { + // move this existing trap to the front of the queue + trapStack.splice(trapIndex, 1); + trapStack.push(trap); + } + }, + deactivateTrap: function deactivateTrap(trapStack, trap) { + var trapIndex = trapStack.indexOf(trap); + if (trapIndex !== -1) { + trapStack.splice(trapIndex, 1); + } + if (trapStack.length > 0) { + trapStack[trapStack.length - 1].unpause(); + } + } +}; +var isSelectableInput = function isSelectableInput(node) { + return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function'; +}; +var isEscapeEvent = function isEscapeEvent(e) { + return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27; +}; +var isTabEvent = function isTabEvent(e) { + return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9; +}; + +// checks for TAB by default +var isKeyForward = function isKeyForward(e) { + return isTabEvent(e) && !e.shiftKey; +}; + +// checks for SHIFT+TAB by default +var isKeyBackward = function isKeyBackward(e) { + return isTabEvent(e) && e.shiftKey; +}; +var delay = function delay(fn) { + return setTimeout(fn, 0); +}; + +// Array.find/findIndex() are not supported on IE; this replicates enough +// of Array.findIndex() for our needs +var findIndex = function findIndex(arr, fn) { + var idx = -1; + arr.every(function (value, i) { + if (fn(value)) { + idx = i; + return false; // break + } + return true; // next + }); + return idx; +}; + +/** + * Get an option's value when it could be a plain value, or a handler that provides + * the value. + * @param {*} value Option's value to check. + * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function. + * @returns {*} The `value`, or the handler's returned value. + */ +var valueOrHandler = function valueOrHandler(value) { + for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + params[_key - 1] = arguments[_key]; + } + return typeof value === 'function' ? value.apply(void 0, params) : value; +}; +var getActualTarget = function getActualTarget(event) { + // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the + // shadow host. However, event.target.composedPath() will be an array of + // nodes "clicked" from inner-most (the actual element inside the shadow) to + // outer-most (the host HTML document). If we have access to composedPath(), + // then use its first element; otherwise, fall back to event.target (and + // this only works for an _open_ shadow DOM; otherwise, + // composedPath()[0] === event.target always). + return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target; +}; + +// NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this +// current instance use the same stack if `userOptions.trapStack` isn't specified +var internalTrapStack = []; +var createFocusTrap = function createFocusTrap(elements, userOptions) { + // SSR: a live trap shouldn't be created in this type of environment so this + // should be safe code to execute if the `document` option isn't specified + var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document; + var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack; + var config = _objectSpread2({ + returnFocusOnDeactivate: true, + escapeDeactivates: true, + delayInitialFocus: true, + isKeyForward: isKeyForward, + isKeyBackward: isKeyBackward + }, userOptions); + var state = { + // containers given to createFocusTrap() + // @type {Array} + containers: [], + // list of objects identifying tabbable nodes in `containers` in the trap + // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap + // is active, but the trap should never get to a state where there isn't at least one group + // with at least one tabbable node in it (that would lead to an error condition that would + // result in an error being thrown) + // @type {Array<{ + // container: HTMLElement, + // tabbableNodes: Array, // empty if none + // focusableNodes: Array, // empty if none + // posTabIndexesFound: boolean, + // firstTabbableNode: HTMLElement|undefined, + // lastTabbableNode: HTMLElement|undefined, + // firstDomTabbableNode: HTMLElement|undefined, + // lastDomTabbableNode: HTMLElement|undefined, + // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined + // }>} + containerGroups: [], + // same order/length as `containers` list + + // references to objects in `containerGroups`, but only those that actually have + // tabbable nodes in them + // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__ + // the same length + tabbableGroups: [], + nodeFocusedBeforeActivation: null, + mostRecentlyFocusedNode: null, + active: false, + paused: false, + // timer ID for when delayInitialFocus is true and initial focus in this trap + // has been delayed during activation + delayInitialFocusTimer: undefined, + // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any + recentNavEvent: undefined + }; + var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later + + /** + * Gets a configuration option value. + * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set, + * value will be taken from this object. Otherwise, value will be taken from base configuration. + * @param {string} optionName Name of the option whose value is sought. + * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName` + * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used. + */ + var getOption = function getOption(configOverrideOptions, optionName, configOptionName) { + return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName]; + }; + + /** + * Finds the index of the container that contains the element. + * @param {HTMLElement} element + * @param {Event} [event] If available, and `element` isn't directly found in any container, + * the event's composed path is used to see if includes any known trap containers in the + * case where the element is inside a Shadow DOM. + * @returns {number} Index of the container in either `state.containers` or + * `state.containerGroups` (the order/length of these lists are the same); -1 + * if the element isn't found. + */ + var findContainerIndex = function findContainerIndex(element, event) { + var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined; + // NOTE: search `containerGroups` because it's possible a group contains no tabbable + // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`) + // and we still need to find the element in there + return state.containerGroups.findIndex(function (_ref) { + var container = _ref.container, + tabbableNodes = _ref.tabbableNodes; + return container.contains(element) || (// fall back to explicit tabbable search which will take into consideration any + // web components if the `tabbableOptions.getShadowRoot` option was used for + // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't + // look inside web components even if open) + composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) { + return node === element; + }); + }); + }; + + /** + * Gets the node for the given option, which is expected to be an option that + * can be either a DOM node, a string that is a selector to get a node, `false` + * (if a node is explicitly NOT given), or a function that returns any of these + * values. + * @param {string} optionName + * @param {Object} options + * @param {boolean} [options.hasFallback] True if the option could be a selector string + * and the option allows for a fallback scenario in the case where the selector is + * valid but does not match a node (i.e. the queried node doesn't exist in the DOM). + * @param {Array} [options.params] Params to pass to the option if it's a function. + * @returns {undefined | null | false | HTMLElement | SVGElement} Returns + * `undefined` if the option is not specified; `null` if the option didn't resolve + * to a node but `options.hasFallback=true`, `false` if the option resolved to `false` + * (node explicitly not given); otherwise, the resolved DOM node. + * @throws {Error} If the option is set, not `false`, and is not, or does not + * resolve to a node, unless the option is a selector string and `options.hasFallback=true`. + */ + var getNodeForOption = function getNodeForOption(optionName) { + var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref2$hasFallback = _ref2.hasFallback, + hasFallback = _ref2$hasFallback === void 0 ? false : _ref2$hasFallback, + _ref2$params = _ref2.params, + params = _ref2$params === void 0 ? [] : _ref2$params; + var optionValue = config[optionName]; + if (typeof optionValue === 'function') { + optionValue = optionValue.apply(void 0, _toConsumableArray(params)); + } + if (optionValue === true) { + optionValue = undefined; // use default value + } + if (!optionValue) { + if (optionValue === undefined || optionValue === false) { + return optionValue; + } + // else, empty string (invalid), null (invalid), 0 (invalid) + + throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node")); + } + var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point + + if (typeof optionValue === 'string') { + try { + node = doc.querySelector(optionValue); // resolve to node, or null if fails + } catch (err) { + throw new Error("`".concat(optionName, "` appears to be an invalid selector; error=\"").concat(err.message, "\"")); + } + if (!node) { + if (!hasFallback) { + throw new Error("`".concat(optionName, "` as selector refers to no known node")); + } + // else, `node` MUST be `null` because that's what `Document.querySelector()` returns + // if the selector is valid but doesn't match anything + } + } + return node; + }; + var getInitialFocusNode = function getInitialFocusNode() { + var node = getNodeForOption('initialFocus', { + hasFallback: true + }); + + // false explicitly indicates we want no initialFocus at all + if (node === false) { + return false; + } + if (node === undefined || node && !tabbable.isFocusable(node, config.tabbableOptions)) { + // option not specified nor focusable: use fallback options + if (findContainerIndex(doc.activeElement) >= 0) { + node = doc.activeElement; + } else { + var firstTabbableGroup = state.tabbableGroups[0]; + var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; + + // NOTE: `fallbackFocus` option function cannot return `false` (not supported) + node = firstTabbableNode || getNodeForOption('fallbackFocus'); + } + } else if (node === null) { + // option is a VALID selector string that doesn't yield a node: use the `fallbackFocus` + // option instead of the default behavior when the option isn't specified at all + node = getNodeForOption('fallbackFocus'); + } + if (!node) { + throw new Error('Your focus-trap needs to have at least one focusable element'); + } + return node; + }; + var updateTabbableNodes = function updateTabbableNodes() { + state.containerGroups = state.containers.map(function (container) { + var tabbableNodes = tabbable.tabbable(container, config.tabbableOptions); + + // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes + // are a superset of tabbable nodes since nodes with negative `tabindex` attributes + // are focusable but not tabbable + var focusableNodes = tabbable.focusable(container, config.tabbableOptions); + var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined; + var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined; + var firstDomTabbableNode = focusableNodes.find(function (node) { + return tabbable.isTabbable(node); + }); + var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) { + return tabbable.isTabbable(node); + }); + var posTabIndexesFound = !!tabbableNodes.find(function (node) { + return tabbable.getTabIndex(node) > 0; + }); + return { + container: container, + tabbableNodes: tabbableNodes, + focusableNodes: focusableNodes, + /** True if at least one node with positive `tabindex` was found in this container. */ + posTabIndexesFound: posTabIndexesFound, + /** First tabbable node in container, __tabindex__ order; `undefined` if none. */ + firstTabbableNode: firstTabbableNode, + /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */ + lastTabbableNode: lastTabbableNode, + // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out + // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition + // because that API doesn't work with Shadow DOM as well as it should (@see + // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far, + // to address an edge case related to positive tabindex support, this seems like a much easier, + // "close enough most of the time" alternative for positive tabindexes which should generally + // be avoided anyway... + /** First tabbable node in container, __DOM__ order; `undefined` if none. */ + firstDomTabbableNode: firstDomTabbableNode, + /** Last tabbable node in container, __DOM__ order; `undefined` if none. */ + lastDomTabbableNode: lastDomTabbableNode, + /** + * Finds the __tabbable__ node that follows the given node in the specified direction, + * in this container, if any. + * @param {HTMLElement} node + * @param {boolean} [forward] True if going in forward tab order; false if going + * in reverse. + * @returns {HTMLElement|undefined} The next tabbable node, if any. + */ + nextTabbableNode: function nextTabbableNode(node) { + var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var nodeIdx = tabbableNodes.indexOf(node); + if (nodeIdx < 0) { + // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex): + // since `node` should at least have been focusable, we assume that's the case and mimic + // what browsers do, which is set focus to the next node in __document position order__, + // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE + // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to + // basic DOM order + if (forward) { + return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) { + return tabbable.isTabbable(el); + }); + } + return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) { + return tabbable.isTabbable(el); + }); + } + return tabbableNodes[nodeIdx + (forward ? 1 : -1)]; + } + }; + }); + state.tabbableGroups = state.containerGroups.filter(function (group) { + return group.tabbableNodes.length > 0; + }); + + // throw if no groups have tabbable nodes and we don't have a fallback focus node either + if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option + ) { + throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times'); + } + + // NOTE: Positive tabindexes are only properly supported in single-container traps because + // doing it across multiple containers where tabindexes could be all over the place + // would require Tabbable to support multiple containers, would require additional + // specialized Shadow DOM support, and would require Tabbable's multi-container support + // to look at those containers in document position order rather than user-provided + // order (as they are treated in Focus-trap, for legacy reasons). See discussion on + // https://github.com/focus-trap/focus-trap/issues/375 for more details. + if (state.containerGroups.find(function (g) { + return g.posTabIndexesFound; + }) && state.containerGroups.length > 1) { + throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps."); + } + }; + + /** + * Gets the current activeElement. If it's a web-component and has open shadow-root + * it will recursively search inside shadow roots for the "true" activeElement. + * + * @param {Document | ShadowRoot} el + * + * @returns {HTMLElement} The element that currently has the focus + **/ + var _getActiveElement = function getActiveElement(el) { + var activeElement = el.activeElement; + if (!activeElement) { + return; + } + if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) { + return _getActiveElement(activeElement.shadowRoot); + } + return activeElement; + }; + var _tryFocus = function tryFocus(node) { + if (node === false) { + return; + } + if (node === _getActiveElement(document)) { + return; + } + if (!node || !node.focus) { + _tryFocus(getInitialFocusNode()); + return; + } + node.focus({ + preventScroll: !!config.preventScroll + }); + // NOTE: focus() API does not trigger focusIn event so set MRU node manually + state.mostRecentlyFocusedNode = node; + if (isSelectableInput(node)) { + node.select(); + } + }; + var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) { + var node = getNodeForOption('setReturnFocus', { + params: [previousActiveElement] + }); + return node ? node : node === false ? false : previousActiveElement; + }; + + /** + * Finds the next node (in either direction) where focus should move according to a + * keyboard focus-in event. + * @param {Object} params + * @param {Node} [params.target] Known target __from which__ to navigate, if any. + * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event + * will be used to determine the `target`). Ignored if `target` is specified. + * @param {boolean} [params.isBackward] True if focus should move backward. + * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be + * determined given the current state of the trap. + */ + var findNextNavNode = function findNextNavNode(_ref3) { + var target = _ref3.target, + event = _ref3.event, + _ref3$isBackward = _ref3.isBackward, + isBackward = _ref3$isBackward === void 0 ? false : _ref3$isBackward; + target = target || getActualTarget(event); + updateTabbableNodes(); + var destinationNode = null; + if (state.tabbableGroups.length > 0) { + // make sure the target is actually contained in a group + // NOTE: the target may also be the container itself if it's focusable + // with tabIndex='-1' and was given initial focus + var containerIndex = findContainerIndex(target, event); + var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined; + if (containerIndex < 0) { + // target not found in any group: quite possible focus has escaped the trap, + // so bring it back into... + if (isBackward) { + // ...the last node in the last group + destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode; + } else { + // ...the first node in the first group + destinationNode = state.tabbableGroups[0].firstTabbableNode; + } + } else if (isBackward) { + // REVERSE + + // is the target the first tabbable node in a group? + var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) { + var firstTabbableNode = _ref4.firstTabbableNode; + return target === firstTabbableNode; + }); + if (startOfGroupIndex < 0 && (containerGroup.container === target || tabbable.isFocusable(target, config.tabbableOptions) && !tabbable.isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) { + // an exception case where the target is either the container itself, or + // a non-tabbable node that was given focus (i.e. tabindex is negative + // and user clicked on it or node was programmatically given focus) + // and is not followed by any other tabbable node, in which + // case, we should handle shift+tab as if focus were on the container's + // first tabbable node, and go to the last tabbable node of the LAST group + startOfGroupIndex = containerIndex; + } + if (startOfGroupIndex >= 0) { + // YES: then shift+tab should go to the last tabbable node in the + // previous group (and wrap around to the last tabbable node of + // the LAST group if it's the first tabbable node of the FIRST group) + var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1; + var destinationGroup = state.tabbableGroups[destinationGroupIndex]; + destinationNode = tabbable.getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode; + } else if (!isTabEvent(event)) { + // user must have customized the nav keys so we have to move focus manually _within_ + // the active group: do this based on the order determined by tabbable() + destinationNode = containerGroup.nextTabbableNode(target, false); + } + } else { + // FORWARD + + // is the target the last tabbable node in a group? + var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref5) { + var lastTabbableNode = _ref5.lastTabbableNode; + return target === lastTabbableNode; + }); + if (lastOfGroupIndex < 0 && (containerGroup.container === target || tabbable.isFocusable(target, config.tabbableOptions) && !tabbable.isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) { + // an exception case where the target is the container itself, or + // a non-tabbable node that was given focus (i.e. tabindex is negative + // and user clicked on it or node was programmatically given focus) + // and is not followed by any other tabbable node, in which + // case, we should handle tab as if focus were on the container's + // last tabbable node, and go to the first tabbable node of the FIRST group + lastOfGroupIndex = containerIndex; + } + if (lastOfGroupIndex >= 0) { + // YES: then tab should go to the first tabbable node in the next + // group (and wrap around to the first tabbable node of the FIRST + // group if it's the last tabbable node of the LAST group) + var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1; + var _destinationGroup = state.tabbableGroups[_destinationGroupIndex]; + destinationNode = tabbable.getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode; + } else if (!isTabEvent(event)) { + // user must have customized the nav keys so we have to move focus manually _within_ + // the active group: do this based on the order determined by tabbable() + destinationNode = containerGroup.nextTabbableNode(target); + } + } + } else { + // no groups available + // NOTE: the fallbackFocus option does not support returning false to opt-out + destinationNode = getNodeForOption('fallbackFocus'); + } + return destinationNode; + }; + + // This needs to be done on mousedown and touchstart instead of click + // so that it precedes the focus event. + var checkPointerDown = function checkPointerDown(e) { + var target = getActualTarget(e); + if (findContainerIndex(target, e) >= 0) { + // allow the click since it ocurred inside the trap + return; + } + if (valueOrHandler(config.clickOutsideDeactivates, e)) { + // immediately deactivate the trap + trap.deactivate({ + // NOTE: by setting `returnFocus: false`, deactivate() will do nothing, + // which will result in the outside click setting focus to the node + // that was clicked (and if not focusable, to "nothing"); by setting + // `returnFocus: true`, we'll attempt to re-focus the node originally-focused + // on activation (or the configured `setReturnFocus` node), whether the + // outside click was on a focusable node or not + returnFocus: config.returnFocusOnDeactivate + }); + return; + } + + // This is needed for mobile devices. + // (If we'll only let `click` events through, + // then on mobile they will be blocked anyways if `touchstart` is blocked.) + if (valueOrHandler(config.allowOutsideClick, e)) { + // allow the click outside the trap to take place + return; + } + + // otherwise, prevent the click + e.preventDefault(); + }; + + // In case focus escapes the trap for some strange reason, pull it back in. + // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected + // scrolling if the node that got focused was out of view; there's nothing we can do to + // prevent that from happening by the time we discover that focus escaped + var checkFocusIn = function checkFocusIn(event) { + var target = getActualTarget(event); + var targetContained = findContainerIndex(target, event) >= 0; + + // In Firefox when you Tab out of an iframe the Document is briefly focused. + if (targetContained || target instanceof Document) { + if (targetContained) { + state.mostRecentlyFocusedNode = target; + } + } else { + // escaped! pull it back in to where it just left + event.stopImmediatePropagation(); + + // focus will escape if the MRU node had a positive tab index and user tried to nav forward; + // it will also escape if the MRU node had a 0 tab index and user tried to nav backward + // toward a node with a positive tab index + var nextNode; // next node to focus, if we find one + var navAcrossContainers = true; + if (state.mostRecentlyFocusedNode) { + if (tabbable.getTabIndex(state.mostRecentlyFocusedNode) > 0) { + // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node... + var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode); + // there MAY not be any tabbable nodes in the container if there are at least 2 containers + // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container + // with at least one tabbable node in order to function, so this could be the other container + // with nothing tabbable in it) + var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes; + if (tabbableNodes.length > 0) { + // MRU tab index MAY not be found if the MRU node is focusable but not tabbable + var mruTabIdx = tabbableNodes.findIndex(function (node) { + return node === state.mostRecentlyFocusedNode; + }); + if (mruTabIdx >= 0) { + if (config.isKeyForward(state.recentNavEvent)) { + if (mruTabIdx + 1 < tabbableNodes.length) { + nextNode = tabbableNodes[mruTabIdx + 1]; + navAcrossContainers = false; + } + // else, don't wrap within the container as focus should move to next/previous + // container + } else { + if (mruTabIdx - 1 >= 0) { + nextNode = tabbableNodes[mruTabIdx - 1]; + navAcrossContainers = false; + } + // else, don't wrap within the container as focus should move to next/previous + // container + } + // else, don't find in container order without considering direction too + } + } + // else, no tabbable nodes in that container (which means we must have at least one other + // container with at least one tabbable node in it, otherwise focus-trap would've thrown + // an error the last time updateTabbableNodes() was run): find next node among all known + // containers + } else { + // check to see if there's at least one tabbable node with a positive tab index inside + // the trap because focus seems to escape when navigating backward from a tabbable node + // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with + // the greatest positive tab index like it should) + if (!state.containerGroups.some(function (g) { + return g.tabbableNodes.some(function (n) { + return tabbable.getTabIndex(n) > 0; + }); + })) { + // no containers with tabbable nodes with positive tab indexes which means the focus + // escaped for some other reason and we should just execute the fallback to the + // MRU node or initial focus node, if any + navAcrossContainers = false; + } + } + } else { + // no MRU node means we're likely in some initial condition when the trap has just + // been activated and initial focus hasn't been given yet, in which case we should + // fall through to trying to focus the initial focus node, which is what should + // happen below at this point in the logic + navAcrossContainers = false; + } + if (navAcrossContainers) { + nextNode = findNextNavNode({ + // move FROM the MRU node, not event-related node (which will be the node that is + // outside the trap causing the focus escape we're trying to fix) + target: state.mostRecentlyFocusedNode, + isBackward: config.isKeyBackward(state.recentNavEvent) + }); + } + if (nextNode) { + _tryFocus(nextNode); + } else { + _tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode()); + } + } + state.recentNavEvent = undefined; // clear + }; + + // Hijack key nav events on the first and last focusable nodes of the trap, + // in order to prevent focus from escaping. If it escapes for even a + // moment it can end up scrolling the page and causing confusion so we + // kind of need to capture the action at the keydown phase. + var checkKeyNav = function checkKeyNav(event) { + var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + state.recentNavEvent = event; + var destinationNode = findNextNavNode({ + event: event, + isBackward: isBackward + }); + if (destinationNode) { + if (isTabEvent(event)) { + // since tab natively moves focus, we wouldn't have a destination node unless we + // were on the edge of a container and had to move to the next/previous edge, in + // which case we want to prevent default to keep the browser from moving focus + // to where it normally would + event.preventDefault(); + } + _tryFocus(destinationNode); + } + // else, let the browser take care of [shift+]tab and move the focus + }; + var checkTabKey = function checkTabKey(event) { + if (config.isKeyForward(event) || config.isKeyBackward(event)) { + checkKeyNav(event, config.isKeyBackward(event)); + } + }; + + // we use a different event phase for the Escape key to allow canceling the event and checking for this in escapeDeactivates + var checkEscapeKey = function checkEscapeKey(event) { + if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) { + event.preventDefault(); + trap.deactivate(); + } + }; + var checkClick = function checkClick(e) { + var target = getActualTarget(e); + if (findContainerIndex(target, e) >= 0) { + return; + } + if (valueOrHandler(config.clickOutsideDeactivates, e)) { + return; + } + if (valueOrHandler(config.allowOutsideClick, e)) { + return; + } + e.preventDefault(); + e.stopImmediatePropagation(); + }; + + // + // EVENT LISTENERS + // + + var addListeners = function addListeners() { + if (!state.active) { + return; + } + + // There can be only one listening focus trap at a time + activeFocusTraps.activateTrap(trapStack, trap); + + // Delay ensures that the focused element doesn't capture the event + // that caused the focus trap activation. + state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () { + _tryFocus(getInitialFocusNode()); + }) : _tryFocus(getInitialFocusNode()); + doc.addEventListener('focusin', checkFocusIn, true); + doc.addEventListener('mousedown', checkPointerDown, { + capture: true, + passive: false + }); + doc.addEventListener('touchstart', checkPointerDown, { + capture: true, + passive: false + }); + doc.addEventListener('click', checkClick, { + capture: true, + passive: false + }); + doc.addEventListener('keydown', checkTabKey, { + capture: true, + passive: false + }); + doc.addEventListener('keydown', checkEscapeKey); + return trap; + }; + var removeListeners = function removeListeners() { + if (!state.active) { + return; + } + doc.removeEventListener('focusin', checkFocusIn, true); + doc.removeEventListener('mousedown', checkPointerDown, true); + doc.removeEventListener('touchstart', checkPointerDown, true); + doc.removeEventListener('click', checkClick, true); + doc.removeEventListener('keydown', checkTabKey, true); + doc.removeEventListener('keydown', checkEscapeKey); + return trap; + }; + + // + // MUTATION OBSERVER + // + + var checkDomRemoval = function checkDomRemoval(mutations) { + var isFocusedNodeRemoved = mutations.some(function (mutation) { + var removedNodes = Array.from(mutation.removedNodes); + return removedNodes.some(function (node) { + return node === state.mostRecentlyFocusedNode; + }); + }); + + // If the currently focused is removed then browsers will move focus to the + // element. If this happens, try to move focus back into the trap. + if (isFocusedNodeRemoved) { + _tryFocus(getInitialFocusNode()); + } + }; + + // Use MutationObserver - if supported - to detect if focused node is removed + // from the DOM. + var mutationObserver = typeof window !== 'undefined' && 'MutationObserver' in window ? new MutationObserver(checkDomRemoval) : undefined; + var updateObservedNodes = function updateObservedNodes() { + if (!mutationObserver) { + return; + } + mutationObserver.disconnect(); + if (state.active && !state.paused) { + state.containers.map(function (container) { + mutationObserver.observe(container, { + subtree: true, + childList: true + }); + }); + } + }; + + // + // TRAP DEFINITION + // + + trap = { + get active() { + return state.active; + }, + get paused() { + return state.paused; + }, + activate: function activate(activateOptions) { + if (state.active) { + return this; + } + var onActivate = getOption(activateOptions, 'onActivate'); + var onPostActivate = getOption(activateOptions, 'onPostActivate'); + var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap'); + if (!checkCanFocusTrap) { + updateTabbableNodes(); + } + state.active = true; + state.paused = false; + state.nodeFocusedBeforeActivation = doc.activeElement; + onActivate === null || onActivate === void 0 || onActivate(); + var finishActivation = function finishActivation() { + if (checkCanFocusTrap) { + updateTabbableNodes(); + } + addListeners(); + updateObservedNodes(); + onPostActivate === null || onPostActivate === void 0 || onPostActivate(); + }; + if (checkCanFocusTrap) { + checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation); + return this; + } + finishActivation(); + return this; + }, + deactivate: function deactivate(deactivateOptions) { + if (!state.active) { + return this; + } + var options = _objectSpread2({ + onDeactivate: config.onDeactivate, + onPostDeactivate: config.onPostDeactivate, + checkCanReturnFocus: config.checkCanReturnFocus + }, deactivateOptions); + clearTimeout(state.delayInitialFocusTimer); // noop if undefined + state.delayInitialFocusTimer = undefined; + removeListeners(); + state.active = false; + state.paused = false; + updateObservedNodes(); + activeFocusTraps.deactivateTrap(trapStack, trap); + var onDeactivate = getOption(options, 'onDeactivate'); + var onPostDeactivate = getOption(options, 'onPostDeactivate'); + var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus'); + var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate'); + onDeactivate === null || onDeactivate === void 0 || onDeactivate(); + var finishDeactivation = function finishDeactivation() { + delay(function () { + if (returnFocus) { + _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)); + } + onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate(); + }); + }; + if (returnFocus && checkCanReturnFocus) { + checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation); + return this; + } + finishDeactivation(); + return this; + }, + pause: function pause(pauseOptions) { + if (state.paused || !state.active) { + return this; + } + var onPause = getOption(pauseOptions, 'onPause'); + var onPostPause = getOption(pauseOptions, 'onPostPause'); + state.paused = true; + onPause === null || onPause === void 0 || onPause(); + removeListeners(); + updateObservedNodes(); + onPostPause === null || onPostPause === void 0 || onPostPause(); + return this; + }, + unpause: function unpause(unpauseOptions) { + if (!state.paused || !state.active) { + return this; + } + var onUnpause = getOption(unpauseOptions, 'onUnpause'); + var onPostUnpause = getOption(unpauseOptions, 'onPostUnpause'); + state.paused = false; + onUnpause === null || onUnpause === void 0 || onUnpause(); + updateTabbableNodes(); + addListeners(); + updateObservedNodes(); + onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause(); + return this; + }, + updateContainerElements: function updateContainerElements(containerElements) { + var elementsAsArray = [].concat(containerElements).filter(Boolean); + state.containers = elementsAsArray.map(function (element) { + return typeof element === 'string' ? doc.querySelector(element) : element; + }); + if (state.active) { + updateTabbableNodes(); + } + updateObservedNodes(); + return this; + } + }; + + // initialize container elements + trap.updateContainerElements(elements); + return trap; +}; + +exports.createFocusTrap = createFocusTrap; + + +},{"tabbable":36}],15:[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; +}; + +},{}],16:[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; }; + +},{}],17:[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 printWarning = function() {}; + +if ("production" !== 'production') { + var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); + var loggedTypeFailures = {}; + var has = require('./lib/has'); + + printWarning = function(text) { + var message = 'Warning: ' + text; + 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) { /**/ } + }; +} + +/** + * 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 ("production" !== 'production') { + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, 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. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error( + (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.' + ); + err.name = 'Invariant Violation'; + throw err; + } + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + if (error && !(error instanceof Error)) { + printWarning( + (componentName || 'React class') + ': type specification of ' + + location + ' `' + typeSpecName + '` is invalid; the type checker ' + + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + + 'You may have forgotten to pass an argument to the type checker ' + + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + + 'shape all require an argument).' + ); + } + 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() : ''; + + printWarning( + 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') + ); + } + } + } + } +} + +/** + * Resets warning cache when testing. + * + * @private + */ +checkPropTypes.resetWarningCache = function() { + if ("production" !== 'production') { + loggedTypeFailures = {}; + } +} + +module.exports = checkPropTypes; + +},{"./lib/ReactPropTypesSecret":21,"./lib/has":22}],18:[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 = require('./lib/ReactPropTypesSecret'); + +function emptyFunction() {} +function emptyFunctionWithReset() {} +emptyFunctionWithReset.resetWarningCache = emptyFunction; + +module.exports = function() { + function shim(props, propName, componentName, location, propFullName, secret) { + if (secret === ReactPropTypesSecret) { + // It is still safe when called from React. + return; + } + var err = new Error( + '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' + ); + err.name = 'Invariant Violation'; + throw err; + }; + shim.isRequired = shim; + function getShim() { + return shim; + }; + // Important! + // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. + var ReactPropTypes = { + array: shim, + bigint: shim, + bool: shim, + func: shim, + number: shim, + object: shim, + string: shim, + symbol: shim, + + any: shim, + arrayOf: getShim, + element: shim, + elementType: shim, + instanceOf: getShim, + node: shim, + objectOf: getShim, + oneOf: getShim, + oneOfType: getShim, + shape: getShim, + exact: getShim, + + checkPropTypes: emptyFunctionWithReset, + resetWarningCache: emptyFunction + }; + + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; + +},{"./lib/ReactPropTypesSecret":21}],19:[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 ReactIs = require('react-is'); +var assign = require('object-assign'); + +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); +var has = require('./lib/has'); +var checkPropTypes = require('./checkPropTypes'); + +var printWarning = function() {}; + +if ("production" !== 'production') { + printWarning = function(text) { + var message = 'Warning: ' + text; + 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) {} + }; +} + +function emptyFunctionThatReturnsNull() { + return null; +} + +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'), + bigint: createPrimitiveTypeChecker('bigint'), + bool: createPrimitiveTypeChecker('boolean'), + func: createPrimitiveTypeChecker('function'), + number: createPrimitiveTypeChecker('number'), + object: createPrimitiveTypeChecker('object'), + string: createPrimitiveTypeChecker('string'), + symbol: createPrimitiveTypeChecker('symbol'), + + any: createAnyTypeChecker(), + arrayOf: createArrayOfTypeChecker, + element: createElementTypeChecker(), + elementType: createElementTypeTypeChecker(), + 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, data) { + this.message = message; + this.data = data && typeof data === 'object' ? data: {}; + this.stack = ''; + } + // Make `instanceof Error` still work for returned errors. + PropTypeError.prototype = Error.prototype; + + function createChainableTypeChecker(validate) { + if ("production" !== '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 + var err = new Error( + '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' + ); + err.name = 'Invariant Violation'; + throw err; + } else if ("production" !== '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 + ) { + printWarning( + 'You are manually calling a React.PropTypes validation ' + + 'function for the `' + propFullName + '` prop on `' + componentName + '`. 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.' + ); + 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 + '`.'), + {expectedType: expectedType} + ); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createAnyTypeChecker() { + return createChainableTypeChecker(emptyFunctionThatReturnsNull); + } + + 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 createElementTypeTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!ReactIs.isValidElementType(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); + } + 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)) { + if ("production" !== 'production') { + if (arguments.length > 1) { + printWarning( + 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' + ); + } else { + printWarning('Invalid argument supplied to oneOf, expected an array.'); + } + } + return emptyFunctionThatReturnsNull; + } + + 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, function replacer(key, value) { + var type = getPreciseType(value); + if (type === 'symbol') { + return String(value); + } + return value; + }); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(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 (has(propValue, 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)) { + "production" !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; + return emptyFunctionThatReturnsNull; + } + + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + printWarning( + 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' + ); + return emptyFunctionThatReturnsNull; + } + } + + function validate(props, propName, componentName, location, propFullName) { + var expectedTypes = []; + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret); + if (checkerResult == null) { + return null; + } + if (checkerResult.data && has(checkerResult.data, 'expectedType')) { + expectedTypes.push(checkerResult.data.expectedType); + } + } + var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': ''; + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.')); + } + 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 invalidValidatorError(componentName, location, propFullName, key, type) { + return new PropTypeError( + (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.' + ); + } + + 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 (typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + 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 (has(shapeTypes, key) && typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + 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; + } + + // falsy value can't be a Symbol + if (!propValue) { + return false; + } + + // 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.resetWarningCache = checkPropTypes.resetWarningCache; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; + +},{"./checkPropTypes":17,"./lib/ReactPropTypesSecret":21,"./lib/has":22,"object-assign":15,"react-is":25}],20:[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. + */ + +if ("production" !== 'production') { + var ReactIs = require('react-is'); + + // 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')(ReactIs.isElement, 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')(); +} + +},{"./factoryWithThrowingShims":18,"./factoryWithTypeCheckers":19,"react-is":25}],21:[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; + +},{}],22:[function(require,module,exports){ +module.exports = Function.call.bind(Object.prototype.hasOwnProperty); + +},{}],23:[function(require,module,exports){ +(function (process){(function (){ +/** @license React v16.13.1 + * react-is.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * 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") { + (function() { +'use strict'; + +// The Symbol used to tag the ReactElement-like types. If there is no native Symbol +// nor polyfill, then a plain number is used for performance. +var hasSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; +var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; +var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; +var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; +var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; +var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; +var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +// (unstable) APIs that have been removed. Can we remove the symbols? + +var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; +var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; +var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; +var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; +var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; +var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; +var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; +var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; + +function isValidElementType(type) { + return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. + type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); +} + +function typeOf(object) { + if (typeof object === 'object' && object !== null) { + var $$typeof = object.$$typeof; + + switch ($$typeof) { + case REACT_ELEMENT_TYPE: + var type = object.type; + + switch (type) { + case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: + case REACT_FRAGMENT_TYPE: + case REACT_PROFILER_TYPE: + case REACT_STRICT_MODE_TYPE: + case REACT_SUSPENSE_TYPE: + return type; + + default: + var $$typeofType = type && type.$$typeof; + + switch ($$typeofType) { + case REACT_CONTEXT_TYPE: + case REACT_FORWARD_REF_TYPE: + case REACT_LAZY_TYPE: + case REACT_MEMO_TYPE: + case REACT_PROVIDER_TYPE: + return $$typeofType; + + default: + return $$typeof; + } + + } + + case REACT_PORTAL_TYPE: + return $$typeof; + } + } + + return undefined; +} // AsyncMode is deprecated along with isAsyncMode + +var AsyncMode = REACT_ASYNC_MODE_TYPE; +var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; +var ContextConsumer = REACT_CONTEXT_TYPE; +var ContextProvider = REACT_PROVIDER_TYPE; +var Element = REACT_ELEMENT_TYPE; +var ForwardRef = REACT_FORWARD_REF_TYPE; +var Fragment = REACT_FRAGMENT_TYPE; +var Lazy = REACT_LAZY_TYPE; +var Memo = REACT_MEMO_TYPE; +var Portal = REACT_PORTAL_TYPE; +var Profiler = REACT_PROFILER_TYPE; +var StrictMode = REACT_STRICT_MODE_TYPE; +var Suspense = REACT_SUSPENSE_TYPE; +var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated + +function isAsyncMode(object) { + { + if (!hasWarnedAboutDeprecatedIsAsyncMode) { + hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint + + console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); + } + } + + return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; +} +function isConcurrentMode(object) { + return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; +} +function isContextConsumer(object) { + return typeOf(object) === REACT_CONTEXT_TYPE; +} +function isContextProvider(object) { + return typeOf(object) === REACT_PROVIDER_TYPE; +} +function isElement(object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; +} +function isForwardRef(object) { + return typeOf(object) === REACT_FORWARD_REF_TYPE; +} +function isFragment(object) { + return typeOf(object) === REACT_FRAGMENT_TYPE; +} +function isLazy(object) { + return typeOf(object) === REACT_LAZY_TYPE; +} +function isMemo(object) { + return typeOf(object) === REACT_MEMO_TYPE; +} +function isPortal(object) { + return typeOf(object) === REACT_PORTAL_TYPE; +} +function isProfiler(object) { + return typeOf(object) === REACT_PROFILER_TYPE; +} +function isStrictMode(object) { + return typeOf(object) === REACT_STRICT_MODE_TYPE; +} +function isSuspense(object) { + return typeOf(object) === REACT_SUSPENSE_TYPE; +} + +exports.AsyncMode = AsyncMode; +exports.ConcurrentMode = ConcurrentMode; +exports.ContextConsumer = ContextConsumer; +exports.ContextProvider = ContextProvider; +exports.Element = Element; +exports.ForwardRef = ForwardRef; +exports.Fragment = Fragment; +exports.Lazy = Lazy; +exports.Memo = Memo; +exports.Portal = Portal; +exports.Profiler = Profiler; +exports.StrictMode = StrictMode; +exports.Suspense = Suspense; +exports.isAsyncMode = isAsyncMode; +exports.isConcurrentMode = isConcurrentMode; +exports.isContextConsumer = isContextConsumer; +exports.isContextProvider = isContextProvider; +exports.isElement = isElement; +exports.isForwardRef = isForwardRef; +exports.isFragment = isFragment; +exports.isLazy = isLazy; +exports.isMemo = isMemo; +exports.isPortal = isPortal; +exports.isProfiler = isProfiler; +exports.isStrictMode = isStrictMode; +exports.isSuspense = isSuspense; +exports.isValidElementType = isValidElementType; +exports.typeOf = typeOf; + })(); +} + +}).call(this)}).call(this,require('_process')) +},{"_process":16}],24:[function(require,module,exports){ +/** @license React v16.13.1 + * react-is.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * 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 b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b? +Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119; +function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d; +exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isAsyncMode=function(a){return A(a)||z(a)===l};exports.isConcurrentMode=A;exports.isContextConsumer=function(a){return z(a)===k};exports.isContextProvider=function(a){return z(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return z(a)===n};exports.isFragment=function(a){return z(a)===e};exports.isLazy=function(a){return z(a)===t}; +exports.isMemo=function(a){return z(a)===r};exports.isPortal=function(a){return z(a)===d};exports.isProfiler=function(a){return z(a)===g};exports.isStrictMode=function(a){return z(a)===f};exports.isSuspense=function(a){return z(a)===p}; +exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};exports.typeOf=z; + +},{}],25:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./cjs/react-is.production.min.js'); +} else { + module.exports = require('./cjs/react-is.development.js'); +} + +}).call(this)}).call(this,require('_process')) +},{"./cjs/react-is.development.js":23,"./cjs/react-is.production.min.js":24,"_process":16}],26:[function(require,module,exports){ +/** + * @license React + * react-dom.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * 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 ("production" !== "production") { + (function() { + + 'use strict'; + +/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ +if ( + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === + 'function' +) { + __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); +} + var React = require('react'); +var Scheduler = require('scheduler'); + +var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + +var suppressWarning = false; +function setSuppressWarning(newSuppressWarning) { + { + suppressWarning = newSuppressWarning; + } +} // In DEV, calls to console.warn and console.error get replaced +// by calls to these methods by a Babel plugin. +// +// In PROD (or in packages without access to React internals), +// they are left as they are instead. + +function warn(format) { + { + if (!suppressWarning) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + printWarning('warn', format, args); + } + } +} +function error(format) { + { + if (!suppressWarning) { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + printWarning('error', format, args); + } + } +} + +function printWarning(level, format, args) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== '') { + format += '%s'; + args = args.concat([stack]); + } // eslint-disable-next-line react-internal/safe-string-coercion + + + var argsWithFormat = args.map(function (item) { + return String(item); + }); // Careful: RN currently depends on this prefix + + argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + Function.prototype.apply.call(console[level], console, argsWithFormat); + } +} + +var FunctionComponent = 0; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class + +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; +var DehydratedFragment = 18; +var SuspenseListComponent = 19; +var ScopeComponent = 21; +var OffscreenComponent = 22; +var LegacyHiddenComponent = 23; +var CacheComponent = 24; +var TracingMarkerComponent = 25; + +// ----------------------------------------------------------------------------- + +var enableClientRenderFallbackOnTextMismatch = true; // TODO: Need to review this code one more time before landing +// the react-reconciler package. + +var enableNewReconciler = false; // Support legacy Primer support on internal FB www + +var enableLazyContextPropagation = false; // FB-only usage. The new API has different semantics. + +var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber + +var enableSuspenseAvoidThisFallback = false; // Enables unstable_avoidThisFallback feature in Fizz +// React DOM Chopping Block +// +// Similar to main Chopping Block but only flags related to React DOM. These are +// grouped because we will likely batch all of them into a single major release. +// ----------------------------------------------------------------------------- +// Disable support for comment nodes as React DOM containers. Already disabled +// in open source, but www codebase still relies on it. Need to remove. + +var disableCommentsAsDOMContainers = true; // Disable javascript: URL strings in href for XSS protection. +// and client rendering, mostly to allow JSX attributes to apply to the custom +// element's object properties instead of only HTML attributes. +// https://github.com/facebook/react/issues/11347 + +var enableCustomElementPropertySupport = false; // Disables children for