@vrembem/core
Advanced tools
Comparing version 3.0.19 to 3.0.20
@@ -1,3 +0,20 @@ | ||
import focusableSelectors from 'focusable-selectors'; | ||
function _classPrivateFieldLooseBase(e, t) { | ||
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); | ||
return e; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(e) { | ||
return "__private_" + id++ + "_" + e; | ||
} | ||
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 _toPrimitive(t, r) { | ||
@@ -15,31 +32,4 @@ if ("object" != typeof t || !t) return t; | ||
var i = _toPrimitive(t, "string"); | ||
return "symbol" == typeof i ? i : String(i); | ||
return "symbol" == typeof i ? i : i + ""; | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(name) { | ||
return "__private_" + id++ + "_" + name; | ||
} | ||
function _classPrivateFieldLooseBase(receiver, privateKey) { | ||
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { | ||
throw new TypeError("attempted to use private field on non-instance"); | ||
} | ||
return receiver; | ||
} | ||
@@ -70,4 +60,4 @@ var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler"); | ||
// Conditionally use addListener() for IE11 support. | ||
if (typeof this.mql.addEventListener === 'function') { | ||
this.mql.addEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.addEventListener === "function") { | ||
this.mql.addEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -86,4 +76,4 @@ this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -99,3 +89,3 @@ this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
}; | ||
_createClass(Breakpoint, [{ | ||
return _createClass(Breakpoint, [{ | ||
key: "handler", | ||
@@ -111,4 +101,4 @@ get: function get() { | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -121,3 +111,2 @@ this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
}]); | ||
return Breakpoint; | ||
}(); | ||
@@ -338,3 +327,3 @@ | ||
if (key === void 0) { | ||
key = 'id'; | ||
key = "id"; | ||
} | ||
@@ -357,3 +346,3 @@ return this.collection.find(function (item) { | ||
if (selectorFocus === void 0) { | ||
selectorFocus = '[data-focus]'; | ||
selectorFocus = "[data-focus]"; | ||
} | ||
@@ -397,4 +386,4 @@ Object.defineProperty(this, _focusable, { | ||
// Remove event listeners | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
}; | ||
@@ -425,3 +414,4 @@ _proto.focus = function focus(el, selectorFocus) { | ||
// Query for all the focusable elements. | ||
var els = el.querySelectorAll(focusableSelectors.join(',')); | ||
var selector = focusableSelectors.join(","); | ||
var els = el.querySelectorAll(selector); | ||
@@ -446,3 +436,3 @@ // Loop through all focusable elements. | ||
}; | ||
_createClass(FocusTrap, [{ | ||
return _createClass(FocusTrap, [{ | ||
key: "focusable", | ||
@@ -458,7 +448,7 @@ get: function get() { | ||
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) { | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
} else { | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
} | ||
@@ -477,7 +467,13 @@ } | ||
}]); | ||
return FocusTrap; | ||
}(); | ||
// This has been copied over from focusable-selectors package and modified. | ||
// https://github.com/KittyGiraudel/focusable-selectors | ||
var notInert = ":not([inert])"; // Previously `:not([inert]):not([inert] *)` | ||
var notNegTabIndex = ":not([tabindex^=\"-\"])"; | ||
var notDisabled = ":not(:disabled)"; | ||
var focusableSelectors = ["a[href]" + notInert + notNegTabIndex, "area[href]" + notInert + notNegTabIndex, "input:not([type=\"hidden\"]):not([type=\"radio\"])" + notInert + notNegTabIndex + notDisabled, "input[type=\"radio\"]" + notInert + notNegTabIndex + notDisabled, "select" + notInert + notNegTabIndex + notDisabled, "textarea" + notInert + notNegTabIndex + notDisabled, "button" + notInert + notNegTabIndex + notDisabled, "details" + notInert + " > summary:first-of-type" + notNegTabIndex, "iframe" + notInert + notNegTabIndex, "audio[controls]" + notInert + notNegTabIndex, "video[controls]" + notInert + notNegTabIndex, "[contenteditable]" + notInert + notNegTabIndex, "[tabindex]" + notInert + notNegTabIndex]; | ||
function handleFocusTrap(event) { | ||
// Check if the click was a tab and return if not. | ||
var isTab = event.key === 'Tab' || event.keyCode === 9; | ||
var isTab = event.key === "Tab" || event.keyCode === 9; | ||
if (!isTab) return; | ||
@@ -504,3 +500,3 @@ | ||
// Ignore the tab key by preventing default. | ||
var isTab = event.key === 'Tab' || event.keyCode === 9; | ||
var isTab = event.key === "Tab" || event.keyCode === 9; | ||
if (isTab) event.preventDefault(); | ||
@@ -510,4 +506,4 @@ } | ||
function getConfig(el, dataConfig) { | ||
var string = el.getAttribute("data-" + dataConfig) || ''; | ||
var json = string.replace(/'/g, '"'); | ||
var string = el.getAttribute("data-" + dataConfig) || ""; | ||
var json = string.replace(/'/g, "\""); | ||
return json ? JSON.parse(json) : {}; | ||
@@ -517,3 +513,3 @@ } | ||
function getPrefix() { | ||
return getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix').trim(); | ||
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(); | ||
} | ||
@@ -563,7 +559,7 @@ | ||
// If ref is a comment, set teleport type to 'after'. | ||
if (isComment) how = 'after'; | ||
if (isComment) how = "after"; | ||
// Must be a valid reference element and method. | ||
if (!where) throw new Error("Not a valid teleport reference: '" + where + "'"); | ||
if (typeof where[how] != 'function') throw new Error("Not a valid teleport method: '" + how + "'"); | ||
if (typeof where[how] != "function") throw new Error("Not a valid teleport method: '" + how + "'"); | ||
@@ -575,3 +571,3 @@ // Initial return ref is null. | ||
if (!isComment) { | ||
returnRef = document.createComment('teleported #' + what.id); | ||
returnRef = document.createComment("teleported #" + what.id); | ||
what.before(returnRef); | ||
@@ -602,3 +598,3 @@ } | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -613,3 +609,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -633,3 +629,3 @@ } else { | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -644,3 +640,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -661,5 +657,5 @@ } else { | ||
if (state) { | ||
el.style.overflow = 'hidden'; | ||
el.style.overflow = "hidden"; | ||
} else { | ||
el.style.removeProperty('overflow'); | ||
el.style.removeProperty("overflow"); | ||
} | ||
@@ -675,6 +671,6 @@ }); | ||
el.inert = true; | ||
el.setAttribute('aria-hidden', true); | ||
el.setAttribute("aria-hidden", true); | ||
} else { | ||
el.inert = null; | ||
el.removeAttribute('aria-hidden'); | ||
el.removeAttribute("aria-hidden"); | ||
} | ||
@@ -681,0 +677,0 @@ }); |
@@ -1,7 +0,20 @@ | ||
var focusableSelectors = require('focusable-selectors'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var focusableSelectors__default = /*#__PURE__*/_interopDefaultLegacy(focusableSelectors); | ||
function _classPrivateFieldLooseBase(e, t) { | ||
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); | ||
return e; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(e) { | ||
return "__private_" + id++ + "_" + e; | ||
} | ||
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 _toPrimitive(t, r) { | ||
@@ -19,31 +32,4 @@ if ("object" != typeof t || !t) return t; | ||
var i = _toPrimitive(t, "string"); | ||
return "symbol" == typeof i ? i : String(i); | ||
return "symbol" == typeof i ? i : i + ""; | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(name) { | ||
return "__private_" + id++ + "_" + name; | ||
} | ||
function _classPrivateFieldLooseBase(receiver, privateKey) { | ||
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { | ||
throw new TypeError("attempted to use private field on non-instance"); | ||
} | ||
return receiver; | ||
} | ||
@@ -74,4 +60,4 @@ var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler"); | ||
// Conditionally use addListener() for IE11 support. | ||
if (typeof this.mql.addEventListener === 'function') { | ||
this.mql.addEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.addEventListener === "function") { | ||
this.mql.addEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -90,4 +76,4 @@ this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -103,3 +89,3 @@ this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
}; | ||
_createClass(Breakpoint, [{ | ||
return _createClass(Breakpoint, [{ | ||
key: "handler", | ||
@@ -115,4 +101,4 @@ get: function get() { | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -125,3 +111,2 @@ this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
}]); | ||
return Breakpoint; | ||
}(); | ||
@@ -342,3 +327,3 @@ | ||
if (key === void 0) { | ||
key = 'id'; | ||
key = "id"; | ||
} | ||
@@ -361,3 +346,3 @@ return this.collection.find(function (item) { | ||
if (selectorFocus === void 0) { | ||
selectorFocus = '[data-focus]'; | ||
selectorFocus = "[data-focus]"; | ||
} | ||
@@ -401,4 +386,4 @@ Object.defineProperty(this, _focusable, { | ||
// Remove event listeners | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
}; | ||
@@ -429,3 +414,4 @@ _proto.focus = function focus(el, selectorFocus) { | ||
// Query for all the focusable elements. | ||
var els = el.querySelectorAll(focusableSelectors__default["default"].join(',')); | ||
var selector = focusableSelectors.join(","); | ||
var els = el.querySelectorAll(selector); | ||
@@ -450,3 +436,3 @@ // Loop through all focusable elements. | ||
}; | ||
_createClass(FocusTrap, [{ | ||
return _createClass(FocusTrap, [{ | ||
key: "focusable", | ||
@@ -462,7 +448,7 @@ get: function get() { | ||
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) { | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
} else { | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
} | ||
@@ -481,7 +467,13 @@ } | ||
}]); | ||
return FocusTrap; | ||
}(); | ||
// This has been copied over from focusable-selectors package and modified. | ||
// https://github.com/KittyGiraudel/focusable-selectors | ||
var notInert = ":not([inert])"; // Previously `:not([inert]):not([inert] *)` | ||
var notNegTabIndex = ":not([tabindex^=\"-\"])"; | ||
var notDisabled = ":not(:disabled)"; | ||
var focusableSelectors = ["a[href]" + notInert + notNegTabIndex, "area[href]" + notInert + notNegTabIndex, "input:not([type=\"hidden\"]):not([type=\"radio\"])" + notInert + notNegTabIndex + notDisabled, "input[type=\"radio\"]" + notInert + notNegTabIndex + notDisabled, "select" + notInert + notNegTabIndex + notDisabled, "textarea" + notInert + notNegTabIndex + notDisabled, "button" + notInert + notNegTabIndex + notDisabled, "details" + notInert + " > summary:first-of-type" + notNegTabIndex, "iframe" + notInert + notNegTabIndex, "audio[controls]" + notInert + notNegTabIndex, "video[controls]" + notInert + notNegTabIndex, "[contenteditable]" + notInert + notNegTabIndex, "[tabindex]" + notInert + notNegTabIndex]; | ||
function handleFocusTrap(event) { | ||
// Check if the click was a tab and return if not. | ||
var isTab = event.key === 'Tab' || event.keyCode === 9; | ||
var isTab = event.key === "Tab" || event.keyCode === 9; | ||
if (!isTab) return; | ||
@@ -508,3 +500,3 @@ | ||
// Ignore the tab key by preventing default. | ||
var isTab = event.key === 'Tab' || event.keyCode === 9; | ||
var isTab = event.key === "Tab" || event.keyCode === 9; | ||
if (isTab) event.preventDefault(); | ||
@@ -514,4 +506,4 @@ } | ||
function getConfig(el, dataConfig) { | ||
var string = el.getAttribute("data-" + dataConfig) || ''; | ||
var json = string.replace(/'/g, '"'); | ||
var string = el.getAttribute("data-" + dataConfig) || ""; | ||
var json = string.replace(/'/g, "\""); | ||
return json ? JSON.parse(json) : {}; | ||
@@ -521,3 +513,3 @@ } | ||
function getPrefix() { | ||
return getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix').trim(); | ||
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(); | ||
} | ||
@@ -567,7 +559,7 @@ | ||
// If ref is a comment, set teleport type to 'after'. | ||
if (isComment) how = 'after'; | ||
if (isComment) how = "after"; | ||
// Must be a valid reference element and method. | ||
if (!where) throw new Error("Not a valid teleport reference: '" + where + "'"); | ||
if (typeof where[how] != 'function') throw new Error("Not a valid teleport method: '" + how + "'"); | ||
if (typeof where[how] != "function") throw new Error("Not a valid teleport method: '" + how + "'"); | ||
@@ -579,3 +571,3 @@ // Initial return ref is null. | ||
if (!isComment) { | ||
returnRef = document.createComment('teleported #' + what.id); | ||
returnRef = document.createComment("teleported #" + what.id); | ||
what.before(returnRef); | ||
@@ -606,3 +598,3 @@ } | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -617,3 +609,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -637,3 +629,3 @@ } else { | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -648,3 +640,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -665,5 +657,5 @@ } else { | ||
if (state) { | ||
el.style.overflow = 'hidden'; | ||
el.style.overflow = "hidden"; | ||
} else { | ||
el.style.removeProperty('overflow'); | ||
el.style.removeProperty("overflow"); | ||
} | ||
@@ -679,6 +671,6 @@ }); | ||
el.inert = true; | ||
el.setAttribute('aria-hidden', true); | ||
el.setAttribute("aria-hidden", true); | ||
} else { | ||
el.inert = null; | ||
el.removeAttribute('aria-hidden'); | ||
el.removeAttribute("aria-hidden"); | ||
} | ||
@@ -685,0 +677,0 @@ }); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('focusable-selectors')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'focusable-selectors'], factory) : | ||
(global = global || self, factory((global.vrembem = global.vrembem || {}, global.vrembem.core = {}), global.focusableSelectors)); | ||
})(this, (function (exports, focusableSelectors) { | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var focusableSelectors__default = /*#__PURE__*/_interopDefaultLegacy(focusableSelectors); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory((global.vrembem = global.vrembem || {}, global.vrembem.core = {}))); | ||
})(this, (function (exports) { | ||
function _classPrivateFieldLooseBase(e, t) { | ||
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); | ||
return e; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(e) { | ||
return "__private_" + id++ + "_" + e; | ||
} | ||
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 _toPrimitive(t, r) { | ||
@@ -22,31 +37,4 @@ if ("object" != typeof t || !t) return t; | ||
var i = _toPrimitive(t, "string"); | ||
return "symbol" == typeof i ? i : String(i); | ||
return "symbol" == typeof i ? i : i + ""; | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(name) { | ||
return "__private_" + id++ + "_" + name; | ||
} | ||
function _classPrivateFieldLooseBase(receiver, privateKey) { | ||
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { | ||
throw new TypeError("attempted to use private field on non-instance"); | ||
} | ||
return receiver; | ||
} | ||
@@ -77,4 +65,4 @@ var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler"); | ||
// Conditionally use addListener() for IE11 support. | ||
if (typeof this.mql.addEventListener === 'function') { | ||
this.mql.addEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.addEventListener === "function") { | ||
this.mql.addEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -93,4 +81,4 @@ this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -106,3 +94,3 @@ this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
}; | ||
_createClass(Breakpoint, [{ | ||
return _createClass(Breakpoint, [{ | ||
key: "handler", | ||
@@ -118,4 +106,4 @@ get: function get() { | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
} else { | ||
@@ -128,3 +116,2 @@ this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]); | ||
}]); | ||
return Breakpoint; | ||
}(); | ||
@@ -345,3 +332,3 @@ | ||
if (key === void 0) { | ||
key = 'id'; | ||
key = "id"; | ||
} | ||
@@ -364,3 +351,3 @@ return this.collection.find(function (item) { | ||
if (selectorFocus === void 0) { | ||
selectorFocus = '[data-focus]'; | ||
selectorFocus = "[data-focus]"; | ||
} | ||
@@ -404,4 +391,4 @@ Object.defineProperty(this, _focusable, { | ||
// Remove event listeners | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
}; | ||
@@ -432,3 +419,4 @@ _proto.focus = function focus(el, selectorFocus) { | ||
// Query for all the focusable elements. | ||
var els = el.querySelectorAll(focusableSelectors__default["default"].join(',')); | ||
var selector = focusableSelectors.join(","); | ||
var els = el.querySelectorAll(selector); | ||
@@ -453,3 +441,3 @@ // Loop through all focusable elements. | ||
}; | ||
_createClass(FocusTrap, [{ | ||
return _createClass(FocusTrap, [{ | ||
key: "focusable", | ||
@@ -465,7 +453,7 @@ get: function get() { | ||
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) { | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
} else { | ||
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]); | ||
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]); | ||
} | ||
@@ -484,7 +472,13 @@ } | ||
}]); | ||
return FocusTrap; | ||
}(); | ||
// This has been copied over from focusable-selectors package and modified. | ||
// https://github.com/KittyGiraudel/focusable-selectors | ||
var notInert = ":not([inert])"; // Previously `:not([inert]):not([inert] *)` | ||
var notNegTabIndex = ":not([tabindex^=\"-\"])"; | ||
var notDisabled = ":not(:disabled)"; | ||
var focusableSelectors = ["a[href]" + notInert + notNegTabIndex, "area[href]" + notInert + notNegTabIndex, "input:not([type=\"hidden\"]):not([type=\"radio\"])" + notInert + notNegTabIndex + notDisabled, "input[type=\"radio\"]" + notInert + notNegTabIndex + notDisabled, "select" + notInert + notNegTabIndex + notDisabled, "textarea" + notInert + notNegTabIndex + notDisabled, "button" + notInert + notNegTabIndex + notDisabled, "details" + notInert + " > summary:first-of-type" + notNegTabIndex, "iframe" + notInert + notNegTabIndex, "audio[controls]" + notInert + notNegTabIndex, "video[controls]" + notInert + notNegTabIndex, "[contenteditable]" + notInert + notNegTabIndex, "[tabindex]" + notInert + notNegTabIndex]; | ||
function handleFocusTrap(event) { | ||
// Check if the click was a tab and return if not. | ||
var isTab = event.key === 'Tab' || event.keyCode === 9; | ||
var isTab = event.key === "Tab" || event.keyCode === 9; | ||
if (!isTab) return; | ||
@@ -511,3 +505,3 @@ | ||
// Ignore the tab key by preventing default. | ||
var isTab = event.key === 'Tab' || event.keyCode === 9; | ||
var isTab = event.key === "Tab" || event.keyCode === 9; | ||
if (isTab) event.preventDefault(); | ||
@@ -517,4 +511,4 @@ } | ||
function getConfig(el, dataConfig) { | ||
var string = el.getAttribute("data-" + dataConfig) || ''; | ||
var json = string.replace(/'/g, '"'); | ||
var string = el.getAttribute("data-" + dataConfig) || ""; | ||
var json = string.replace(/'/g, "\""); | ||
return json ? JSON.parse(json) : {}; | ||
@@ -524,3 +518,3 @@ } | ||
function getPrefix() { | ||
return getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix').trim(); | ||
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(); | ||
} | ||
@@ -570,7 +564,7 @@ | ||
// If ref is a comment, set teleport type to 'after'. | ||
if (isComment) how = 'after'; | ||
if (isComment) how = "after"; | ||
// Must be a valid reference element and method. | ||
if (!where) throw new Error("Not a valid teleport reference: '" + where + "'"); | ||
if (typeof where[how] != 'function') throw new Error("Not a valid teleport method: '" + how + "'"); | ||
if (typeof where[how] != "function") throw new Error("Not a valid teleport method: '" + how + "'"); | ||
@@ -582,3 +576,3 @@ // Initial return ref is null. | ||
if (!isComment) { | ||
returnRef = document.createComment('teleported #' + what.id); | ||
returnRef = document.createComment("teleported #" + what.id); | ||
what.before(returnRef); | ||
@@ -609,3 +603,3 @@ } | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -620,3 +614,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -640,3 +634,3 @@ } else { | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -651,3 +645,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -668,5 +662,5 @@ } else { | ||
if (state) { | ||
el.style.overflow = 'hidden'; | ||
el.style.overflow = "hidden"; | ||
} else { | ||
el.style.removeProperty('overflow'); | ||
el.style.removeProperty("overflow"); | ||
} | ||
@@ -682,6 +676,6 @@ }); | ||
el.inert = true; | ||
el.setAttribute('aria-hidden', true); | ||
el.setAttribute("aria-hidden", true); | ||
} else { | ||
el.inert = null; | ||
el.removeAttribute('aria-hidden'); | ||
el.removeAttribute("aria-hidden"); | ||
} | ||
@@ -688,0 +682,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import e from"focusable-selectors";function t(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function n(e,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,t(r.key),r)}}function i(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}var r=0;function o(e){return"__private_"+r+++"_"+e}function s(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var c=/*#__PURE__*/o("handler"),u=/*#__PURE__*/function(){function e(e,t){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=e,s(this,c)[c]=t,this.mql=null}var t=e.prototype;return t.mount=function(e,t){return e&&(this.value=e),t&&(s(this,c)[c]=t),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",s(this,c)[c]):this.mql.addListener(s(this,c)[c]),s(this,c)[c](this.mql),this):this},t.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",s(this,c)[c]):this.mql.removeListener(s(this,c)[c]),this.value=null,s(this,c)[c]=null,this.mql=null,this):this},i(e,[{key:"handler",get:function(){return s(this,c)[c]},set:function(e){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",s(this,c)[c]):this.mql.removeListener(s(this,c)[c])),s(this,c)[c]=e}}]),e}();function l(e,t,n){if(!e.s){if(n instanceof a){if(!n.s)return void(n.o=l.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(l.bind(null,e,t),l.bind(null,e,2));e.s=t,e.v=n;const i=e.o;i&&i(e)}}var a=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var i=new e,r=this.s;if(r){var o=1&r?t:n;if(o){try{l(i,1,o(this.v))}catch(e){l(i,2,e)}return i}return this}return this.o=function(e){try{var r=e.v;1&e.s?l(i,1,t?t(r):r):n?l(i,1,n(r)):l(i,2,r)}catch(e){l(i,2,e)}},i},e}();function f(e){return e instanceof a&&1&e.s}var h=/*#__PURE__*/function(){function e(){this.collection=[]}var t=e.prototype;return t.register=function(e){try{var t=this;return Promise.resolve(t.deregister(e)).then(function(){return t.collection.push(e),t.collection})}catch(e){return Promise.reject(e)}},t.deregister=function(e){try{var t=this,n=t.collection.findIndex(function(t){return t===e});if(n>=0){var i=t.collection[n];Object.getOwnPropertyNames(i).forEach(function(e){delete i[e]}),t.collection.splice(n,1)}return Promise.resolve(t.collection)}catch(e){return Promise.reject(e)}},t.registerCollection=function(e){try{var t=this;return Promise.resolve(Promise.all(Array.from(e,function(e){t.register(e)}))).then(function(){return t.collection})}catch(e){return Promise.reject(e)}},t.deregisterCollection=function(){try{var e=function(){return t.collection},t=this,n=function(e,t,n){for(var i;;){var r=e();if(f(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!f(o)){i=1;break}o=o.s}if(t){var s=t();if(s&&s.then&&!f(s)){i=2;break}}}var c=new a,u=l.bind(null,c,2);return(0===i?r.then(d):1===i?o.then(h):s.then(v)).then(void 0,u),c;function h(i){o=i;do{if(t&&(s=t())&&s.then&&!f(s))return void s.then(v).then(void 0,u);if(!(r=e())||f(r)&&!r.v)return void l(c,1,o);if(r.then)return void r.then(d).then(void 0,u);f(o=n())&&(o=o.v)}while(!o||!o.then);o.then(h).then(void 0,u)}function d(e){e?(o=n())&&o.then?o.then(h).then(void 0,u):h(o):l(c,1,o)}function v(){(r=e())?r.then?r.then(d).then(void 0,u):d(r):l(c,1,o)}}(function(){return t.collection.length>0},void 0,function(){return Promise.resolve(t.deregister(t.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(e):e())}catch(e){return Promise.reject(e)}},t.get=function(e,t){return void 0===t&&(t="id"),this.collection.find(function(n){return n[t]===e})},e}(),d=/*#__PURE__*/o("focusable"),v=/*#__PURE__*/o("handleFocusTrap"),m=/*#__PURE__*/o("handleFocusLock"),p=/*#__PURE__*/function(){function t(e,t){void 0===e&&(e=null),void 0===t&&(t="[data-focus]"),Object.defineProperty(this,d,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),this.el=e,this.selectorFocus=t,s(this,v)[v]=y.bind(this),s(this,m)[m]=b.bind(this)}var n=t.prototype;return n.mount=function(e,t){e&&(this.el=e),t&&(this.selectorFocus=t),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",s(this,v)[v]),document.removeEventListener("keydown",s(this,m)[m])},n.focus=function(e,t){void 0===e&&(e=this.el),void 0===t&&(t=this.selectorFocus),(e.querySelector(t)||e).focus()},n.getFocusable=function(t){void 0===t&&(t=this.el);var n=[],i=document.activeElement,r=t.scrollTop;return t.querySelectorAll(e.join(",")).forEach(function(e){e.focus(),document.activeElement===e&&n.push(e)}),t.scrollTop=r,i.focus(),n},i(t,[{key:"focusable",get:function(){return s(this,d)[d]},set:function(e){s(this,d)[d]=e,s(this,d)[d].length?(document.removeEventListener("keydown",s(this,m)[m]),document.addEventListener("keydown",s(this,v)[v])):(document.removeEventListener("keydown",s(this,v)[v]),document.addEventListener("keydown",s(this,m)[m]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),t}();function y(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(e.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(e.preventDefault(),this.focusableFirst.focus()))}function b(e){("Tab"===e.key||9===e.keyCode)&&e.preventDefault()}function g(e,t){var n=(e.getAttribute("data-"+t)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function E(){return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim()}function L(e,t){void 0===t&&(t=!0);var n=localStorage.getItem(e),i=n?JSON.parse(n):{};return{get:function(e){return e?i[e]:i},set:function(n,r){return r?i[n]=r:delete i[n],t&&localStorage.setItem(e,JSON.stringify(i)),i}}}function w(e,t,n){var i=t.nodeType===Node.COMMENT_NODE,r=t.nodeType===Node.ELEMENT_NODE;if(i&&(n="after"),!(t=i||r?t:document.querySelector(t)))throw new Error("Not a valid teleport reference: '"+t+"'");if("function"!=typeof t[n])throw new Error("Not a valid teleport method: '"+n+"'");var o=null;return i||(o=document.createComment("teleported #"+e.id),e.before(o)),t[n](e),i&&t.remove(),o}var P=function(e,t){return new Promise(function(n){t.transition?(e.classList.remove(t.stateClosed),e.classList.add(t.stateOpening),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.add(t.stateOpened),e.classList.remove(t.stateOpening),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateOpened),e.classList.remove(t.stateClosed),n(e))})},O=function(e,t){return new Promise(function(n){t.transition?(e.classList.add(t.stateClosing),e.classList.remove(t.stateOpened),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.remove(t.stateClosing),e.classList.add(t.stateClosed),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateClosed),e.classList.remove(t.stateOpened),n(e))})};function q(e,t){var n,i;n=!!e,(i=t.selectorInert)&&document.querySelectorAll(i).forEach(function(e){n?(e.inert=!0,e.setAttribute("aria-hidden",!0)):(e.inert=null,e.removeAttribute("aria-hidden"))}),function(e,t){t&&document.querySelectorAll(t).forEach(function(t){e?t.style.overflow="hidden":t.style.removeProperty("overflow")})}(!!e,t.selectorOverflow)}export{u as Breakpoint,h as Collection,p as FocusTrap,O as closeTransition,g as getConfig,E as getPrefix,L as localStore,P as openTransition,w as teleport,q as updateGlobalState}; | ||
function e(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var t=0;function n(e){return"__private_"+t+++"_"+e}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}function r(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}var s=/*#__PURE__*/n("handler"),u=/*#__PURE__*/function(){function t(t,n){Object.defineProperty(this,s,{writable:!0,value:void 0}),this.value=t,e(this,s)[s]=n,this.mql=null}var n=t.prototype;return n.mount=function(t,n){return t&&(this.value=t),n&&(e(this,s)[s]=n),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",e(this,s)[s]):this.mql.addListener(e(this,s)[s]),e(this,s)[s](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",e(this,s)[s]):this.mql.removeListener(e(this,s)[s]),this.value=null,e(this,s)[s]=null,this.mql=null,this):this},r(t,[{key:"handler",get:function(){return e(this,s)[s]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",e(this,s)[s]):this.mql.removeListener(e(this,s)[s])),e(this,s)[s]=t}}])}();function c(e,t,n){if(!e.s){if(n instanceof l){if(!n.s)return void(n.o=c.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(c.bind(null,e,t),c.bind(null,e,2));e.s=t,e.v=n;const i=e.o;i&&i(e)}}var l=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var i=new e,r=this.s;if(r){var o=1&r?t:n;if(o){try{c(i,1,o(this.v))}catch(e){c(i,2,e)}return i}return this}return this.o=function(e){try{var r=e.v;1&e.s?c(i,1,t?t(r):r):n?c(i,1,n(r)):c(i,2,r)}catch(e){c(i,2,e)}},i},e}();function a(e){return e instanceof l&&1&e.s}var f=/*#__PURE__*/function(){function e(){this.collection=[]}var t=e.prototype;return t.register=function(e){try{var t=this;return Promise.resolve(t.deregister(e)).then(function(){return t.collection.push(e),t.collection})}catch(e){return Promise.reject(e)}},t.deregister=function(e){try{var t=this,n=t.collection.findIndex(function(t){return t===e});if(n>=0){var i=t.collection[n];Object.getOwnPropertyNames(i).forEach(function(e){delete i[e]}),t.collection.splice(n,1)}return Promise.resolve(t.collection)}catch(e){return Promise.reject(e)}},t.registerCollection=function(e){try{var t=this;return Promise.resolve(Promise.all(Array.from(e,function(e){t.register(e)}))).then(function(){return t.collection})}catch(e){return Promise.reject(e)}},t.deregisterCollection=function(){try{var e=function(){return t.collection},t=this,n=function(e,t,n){for(var i;;){var r=e();if(a(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!a(o)){i=1;break}o=o.s}if(t){var s=t();if(s&&s.then&&!a(s)){i=2;break}}}var u=new l,f=c.bind(null,u,2);return(0===i?r.then(d):1===i?o.then(h):s.then(v)).then(void 0,f),u;function h(i){o=i;do{if(t&&(s=t())&&s.then&&!a(s))return void s.then(v).then(void 0,f);if(!(r=e())||a(r)&&!r.v)return void c(u,1,o);if(r.then)return void r.then(d).then(void 0,f);a(o=n())&&(o=o.v)}while(!o||!o.then);o.then(h).then(void 0,f)}function d(e){e?(o=n())&&o.then?o.then(h).then(void 0,f):h(o):c(u,1,o)}function v(){(r=e())?r.then?r.then(d).then(void 0,f):d(r):c(u,1,o)}}(function(){return t.collection.length>0},void 0,function(){return Promise.resolve(t.deregister(t.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(e):e())}catch(e){return Promise.reject(e)}},t.get=function(e,t){return void 0===t&&(t="id"),this.collection.find(function(n){return n[t]===e})},e}(),h=/*#__PURE__*/n("focusable"),d=/*#__PURE__*/n("handleFocusTrap"),v=/*#__PURE__*/n("handleFocusLock"),m=/*#__PURE__*/function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n="[data-focus]"),Object.defineProperty(this,h,{writable:!0,value:void 0}),Object.defineProperty(this,d,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=n,e(this,d)[d]=E.bind(this),e(this,v)[v]=L.bind(this)}var n=t.prototype;return n.mount=function(e,t){e&&(this.el=e),t&&(this.selectorFocus=t),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",e(this,d)[d]),document.removeEventListener("keydown",e(this,v)[v])},n.focus=function(e,t){void 0===e&&(e=this.el),void 0===t&&(t=this.selectorFocus),(e.querySelector(t)||e).focus()},n.getFocusable=function(e){void 0===e&&(e=this.el);var t=[],n=document.activeElement,i=e.scrollTop,r=g.join(",");return e.querySelectorAll(r).forEach(function(e){e.focus(),document.activeElement===e&&t.push(e)}),e.scrollTop=i,n.focus(),t},r(t,[{key:"focusable",get:function(){return e(this,h)[h]},set:function(t){e(this,h)[h]=t,e(this,h)[h].length?(document.removeEventListener("keydown",e(this,v)[v]),document.addEventListener("keydown",e(this,d)[d])):(document.removeEventListener("keydown",e(this,d)[d]),document.addEventListener("keydown",e(this,v)[v]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}])}(),p=":not([inert])",y=':not([tabindex^="-"])',b=":not(:disabled)",g=["a[href]"+p+y,"area[href]"+p+y,'input:not([type="hidden"]):not([type="radio"])'+p+y+b,'input[type="radio"]'+p+y+b,"select"+p+y+b,"textarea"+p+y+b,"button"+p+y+b,"details"+p+" > summary:first-of-type"+y,"iframe"+p+y,"audio[controls]"+p+y,"video[controls]"+p+y,"[contenteditable]"+p+y,"[tabindex]"+p+y];function E(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(e.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(e.preventDefault(),this.focusableFirst.focus()))}function L(e){("Tab"===e.key||9===e.keyCode)&&e.preventDefault()}function w(e,t){var n=(e.getAttribute("data-"+t)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function P(){return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim()}function O(e,t){void 0===t&&(t=!0);var n=localStorage.getItem(e),i=n?JSON.parse(n):{};return{get:function(e){return e?i[e]:i},set:function(n,r){return r?i[n]=r:delete i[n],t&&localStorage.setItem(e,JSON.stringify(i)),i}}}function q(e,t,n){var i=t.nodeType===Node.COMMENT_NODE,r=t.nodeType===Node.ELEMENT_NODE;if(i&&(n="after"),!(t=i||r?t:document.querySelector(t)))throw new Error("Not a valid teleport reference: '"+t+"'");if("function"!=typeof t[n])throw new Error("Not a valid teleport method: '"+n+"'");var o=null;return i||(o=document.createComment("teleported #"+e.id),e.before(o)),t[n](e),i&&t.remove(),o}var k=function(e,t){return new Promise(function(n){t.transition?(e.classList.remove(t.stateClosed),e.classList.add(t.stateOpening),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.add(t.stateOpened),e.classList.remove(t.stateOpening),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateOpened),e.classList.remove(t.stateClosed),n(e))})},j=function(e,t){return new Promise(function(n){t.transition?(e.classList.add(t.stateClosing),e.classList.remove(t.stateOpened),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.remove(t.stateClosing),e.classList.add(t.stateClosed),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateClosed),e.classList.remove(t.stateOpened),n(e))})};function C(e,t){var n,i;n=!!e,(i=t.selectorInert)&&document.querySelectorAll(i).forEach(function(e){n?(e.inert=!0,e.setAttribute("aria-hidden",!0)):(e.inert=null,e.removeAttribute("aria-hidden"))}),function(e,t){t&&document.querySelectorAll(t).forEach(function(t){e?t.style.overflow="hidden":t.style.removeProperty("overflow")})}(!!e,t.selectorOverflow)}export{u as Breakpoint,f as Collection,m as FocusTrap,j as closeTransition,w as getConfig,P as getPrefix,O as localStore,k as openTransition,q as teleport,C as updateGlobalState}; | ||
//# sourceMappingURL=scripts.esm.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=/*#__PURE__*/e(require("focusable-selectors"));function n(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var o=0;function s(e){return"__private_"+o+++"_"+e}function c(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var u=/*#__PURE__*/s("handler"),l=/*#__PURE__*/function(){function e(e,t){Object.defineProperty(this,u,{writable:!0,value:void 0}),this.value=e,c(this,u)[u]=t,this.mql=null}var t=e.prototype;return t.mount=function(e,t){return e&&(this.value=e),t&&(c(this,u)[u]=t),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",c(this,u)[u]):this.mql.addListener(c(this,u)[u]),c(this,u)[u](this.mql),this):this},t.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",c(this,u)[u]):this.mql.removeListener(c(this,u)[u]),this.value=null,c(this,u)[u]=null,this.mql=null,this):this},i(e,[{key:"handler",get:function(){return c(this,u)[u]},set:function(e){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",c(this,u)[u]):this.mql.removeListener(c(this,u)[u])),c(this,u)[u]=e}}]),e}();function a(e,t,n){if(!e.s){if(n instanceof f){if(!n.s)return void(n.o=a.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(a.bind(null,e,t),a.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}var f=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var o=1&i?t:n;if(o){try{a(r,1,o(this.v))}catch(e){a(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?a(r,1,t?t(i):i):n?a(r,1,n(i)):a(r,2,i)}catch(e){a(r,2,e)}},r},e}();function h(e){return e instanceof f&&1&e.s}var d=/*#__PURE__*/function(){function e(){this.collection=[]}var t=e.prototype;return t.register=function(e){try{var t=this;return Promise.resolve(t.deregister(e)).then(function(){return t.collection.push(e),t.collection})}catch(e){return Promise.reject(e)}},t.deregister=function(e){try{var t=this,n=t.collection.findIndex(function(t){return t===e});if(n>=0){var r=t.collection[n];Object.getOwnPropertyNames(r).forEach(function(e){delete r[e]}),t.collection.splice(n,1)}return Promise.resolve(t.collection)}catch(e){return Promise.reject(e)}},t.registerCollection=function(e){try{var t=this;return Promise.resolve(Promise.all(Array.from(e,function(e){t.register(e)}))).then(function(){return t.collection})}catch(e){return Promise.reject(e)}},t.deregisterCollection=function(){try{var e=function(){return t.collection},t=this,n=function(e,t,n){for(var r;;){var i=e();if(h(i)&&(i=i.v),!i)return o;if(i.then){r=0;break}var o=n();if(o&&o.then){if(!h(o)){r=1;break}o=o.s}if(t){var s=t();if(s&&s.then&&!h(s)){r=2;break}}}var c=new f,u=a.bind(null,c,2);return(0===r?i.then(d):1===r?o.then(l):s.then(v)).then(void 0,u),c;function l(r){o=r;do{if(t&&(s=t())&&s.then&&!h(s))return void s.then(v).then(void 0,u);if(!(i=e())||h(i)&&!i.v)return void a(c,1,o);if(i.then)return void i.then(d).then(void 0,u);h(o=n())&&(o=o.v)}while(!o||!o.then);o.then(l).then(void 0,u)}function d(e){e?(o=n())&&o.then?o.then(l).then(void 0,u):l(o):a(c,1,o)}function v(){(i=e())?i.then?i.then(d).then(void 0,u):d(i):a(c,1,o)}}(function(){return t.collection.length>0},void 0,function(){return Promise.resolve(t.deregister(t.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(e):e())}catch(e){return Promise.reject(e)}},t.get=function(e,t){return void 0===t&&(t="id"),this.collection.find(function(n){return n[t]===e})},e}(),v=/*#__PURE__*/s("focusable"),m=/*#__PURE__*/s("handleFocusTrap"),p=/*#__PURE__*/s("handleFocusLock"),y=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t="[data-focus]"),Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),this.el=e,this.selectorFocus=t,c(this,m)[m]=b.bind(this),c(this,p)[p]=g.bind(this)}var n=e.prototype;return n.mount=function(e,t){e&&(this.el=e),t&&(this.selectorFocus=t),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",c(this,m)[m]),document.removeEventListener("keydown",c(this,p)[p])},n.focus=function(e,t){void 0===e&&(e=this.el),void 0===t&&(t=this.selectorFocus),(e.querySelector(t)||e).focus()},n.getFocusable=function(e){void 0===e&&(e=this.el);var n=[],r=document.activeElement,i=e.scrollTop;return e.querySelectorAll(t.default.join(",")).forEach(function(e){e.focus(),document.activeElement===e&&n.push(e)}),e.scrollTop=i,r.focus(),n},i(e,[{key:"focusable",get:function(){return c(this,v)[v]},set:function(e){c(this,v)[v]=e,c(this,v)[v].length?(document.removeEventListener("keydown",c(this,p)[p]),document.addEventListener("keydown",c(this,m)[m])):(document.removeEventListener("keydown",c(this,m)[m]),document.addEventListener("keydown",c(this,p)[p]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),e}();function b(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(e.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(e.preventDefault(),this.focusableFirst.focus()))}function g(e){("Tab"===e.key||9===e.keyCode)&&e.preventDefault()}exports.Breakpoint=l,exports.Collection=d,exports.FocusTrap=y,exports.closeTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.add(t.stateClosing),e.classList.remove(t.stateOpened),e.addEventListener("transitionend",function r(i){i.target==e&&(e.classList.remove(t.stateClosing),e.classList.add(t.stateClosed),n(e),this.removeEventListener("transitionend",r))})):(e.classList.add(t.stateClosed),e.classList.remove(t.stateOpened),n(e))})},exports.getConfig=function(e,t){var n=(e.getAttribute("data-"+t)||"").replace(/'/g,'"');return n?JSON.parse(n):{}},exports.getPrefix=function(){return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim()},exports.localStore=function(e,t){void 0===t&&(t=!0);var n=localStorage.getItem(e),r=n?JSON.parse(n):{};return{get:function(e){return e?r[e]:r},set:function(n,i){return i?r[n]=i:delete r[n],t&&localStorage.setItem(e,JSON.stringify(r)),r}}},exports.openTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.remove(t.stateClosed),e.classList.add(t.stateOpening),e.addEventListener("transitionend",function r(i){i.target==e&&(e.classList.add(t.stateOpened),e.classList.remove(t.stateOpening),n(e),this.removeEventListener("transitionend",r))})):(e.classList.add(t.stateOpened),e.classList.remove(t.stateClosed),n(e))})},exports.teleport=function(e,t,n){var r=t.nodeType===Node.COMMENT_NODE,i=t.nodeType===Node.ELEMENT_NODE;if(r&&(n="after"),!(t=r||i?t:document.querySelector(t)))throw new Error("Not a valid teleport reference: '"+t+"'");if("function"!=typeof t[n])throw new Error("Not a valid teleport method: '"+n+"'");var o=null;return r||(o=document.createComment("teleported #"+e.id),e.before(o)),t[n](e),r&&t.remove(),o},exports.updateGlobalState=function(e,t){var n,r;n=!!e,(r=t.selectorInert)&&document.querySelectorAll(r).forEach(function(e){n?(e.inert=!0,e.setAttribute("aria-hidden",!0)):(e.inert=null,e.removeAttribute("aria-hidden"))}),function(e,t){t&&document.querySelectorAll(t).forEach(function(t){e?t.style.overflow="hidden":t.style.removeProperty("overflow")})}(!!e,t.selectorOverflow)}; | ||
function e(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var t=0;function n(e){return"__private_"+t+++"_"+e}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}function r(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}var s=/*#__PURE__*/n("handler"),c=/*#__PURE__*/function(){function t(t,n){Object.defineProperty(this,s,{writable:!0,value:void 0}),this.value=t,e(this,s)[s]=n,this.mql=null}var n=t.prototype;return n.mount=function(t,n){return t&&(this.value=t),n&&(e(this,s)[s]=n),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",e(this,s)[s]):this.mql.addListener(e(this,s)[s]),e(this,s)[s](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",e(this,s)[s]):this.mql.removeListener(e(this,s)[s]),this.value=null,e(this,s)[s]=null,this.mql=null,this):this},r(t,[{key:"handler",get:function(){return e(this,s)[s]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",e(this,s)[s]):this.mql.removeListener(e(this,s)[s])),e(this,s)[s]=t}}])}();function u(e,t,n){if(!e.s){if(n instanceof l){if(!n.s)return void(n.o=u.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,e,t),u.bind(null,e,2));e.s=t,e.v=n;const i=e.o;i&&i(e)}}var l=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var i=new e,r=this.s;if(r){var o=1&r?t:n;if(o){try{u(i,1,o(this.v))}catch(e){u(i,2,e)}return i}return this}return this.o=function(e){try{var r=e.v;1&e.s?u(i,1,t?t(r):r):n?u(i,1,n(r)):u(i,2,r)}catch(e){u(i,2,e)}},i},e}();function a(e){return e instanceof l&&1&e.s}var f=/*#__PURE__*/function(){function e(){this.collection=[]}var t=e.prototype;return t.register=function(e){try{var t=this;return Promise.resolve(t.deregister(e)).then(function(){return t.collection.push(e),t.collection})}catch(e){return Promise.reject(e)}},t.deregister=function(e){try{var t=this,n=t.collection.findIndex(function(t){return t===e});if(n>=0){var i=t.collection[n];Object.getOwnPropertyNames(i).forEach(function(e){delete i[e]}),t.collection.splice(n,1)}return Promise.resolve(t.collection)}catch(e){return Promise.reject(e)}},t.registerCollection=function(e){try{var t=this;return Promise.resolve(Promise.all(Array.from(e,function(e){t.register(e)}))).then(function(){return t.collection})}catch(e){return Promise.reject(e)}},t.deregisterCollection=function(){try{var e=function(){return t.collection},t=this,n=function(e,t,n){for(var i;;){var r=e();if(a(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!a(o)){i=1;break}o=o.s}if(t){var s=t();if(s&&s.then&&!a(s)){i=2;break}}}var c=new l,f=u.bind(null,c,2);return(0===i?r.then(d):1===i?o.then(h):s.then(v)).then(void 0,f),c;function h(i){o=i;do{if(t&&(s=t())&&s.then&&!a(s))return void s.then(v).then(void 0,f);if(!(r=e())||a(r)&&!r.v)return void u(c,1,o);if(r.then)return void r.then(d).then(void 0,f);a(o=n())&&(o=o.v)}while(!o||!o.then);o.then(h).then(void 0,f)}function d(e){e?(o=n())&&o.then?o.then(h).then(void 0,f):h(o):u(c,1,o)}function v(){(r=e())?r.then?r.then(d).then(void 0,f):d(r):u(c,1,o)}}(function(){return t.collection.length>0},void 0,function(){return Promise.resolve(t.deregister(t.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(e):e())}catch(e){return Promise.reject(e)}},t.get=function(e,t){return void 0===t&&(t="id"),this.collection.find(function(n){return n[t]===e})},e}(),h=/*#__PURE__*/n("focusable"),d=/*#__PURE__*/n("handleFocusTrap"),v=/*#__PURE__*/n("handleFocusLock"),m=/*#__PURE__*/function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n="[data-focus]"),Object.defineProperty(this,h,{writable:!0,value:void 0}),Object.defineProperty(this,d,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=n,e(this,d)[d]=E.bind(this),e(this,v)[v]=L.bind(this)}var n=t.prototype;return n.mount=function(e,t){e&&(this.el=e),t&&(this.selectorFocus=t),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",e(this,d)[d]),document.removeEventListener("keydown",e(this,v)[v])},n.focus=function(e,t){void 0===e&&(e=this.el),void 0===t&&(t=this.selectorFocus),(e.querySelector(t)||e).focus()},n.getFocusable=function(e){void 0===e&&(e=this.el);var t=[],n=document.activeElement,i=e.scrollTop,r=g.join(",");return e.querySelectorAll(r).forEach(function(e){e.focus(),document.activeElement===e&&t.push(e)}),e.scrollTop=i,n.focus(),t},r(t,[{key:"focusable",get:function(){return e(this,h)[h]},set:function(t){e(this,h)[h]=t,e(this,h)[h].length?(document.removeEventListener("keydown",e(this,v)[v]),document.addEventListener("keydown",e(this,d)[d])):(document.removeEventListener("keydown",e(this,d)[d]),document.addEventListener("keydown",e(this,v)[v]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}])}(),p=":not([inert])",y=':not([tabindex^="-"])',b=":not(:disabled)",g=["a[href]"+p+y,"area[href]"+p+y,'input:not([type="hidden"]):not([type="radio"])'+p+y+b,'input[type="radio"]'+p+y+b,"select"+p+y+b,"textarea"+p+y+b,"button"+p+y+b,"details"+p+" > summary:first-of-type"+y,"iframe"+p+y,"audio[controls]"+p+y,"video[controls]"+p+y,"[contenteditable]"+p+y,"[tabindex]"+p+y];function E(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(e.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(e.preventDefault(),this.focusableFirst.focus()))}function L(e){("Tab"===e.key||9===e.keyCode)&&e.preventDefault()}exports.Breakpoint=c,exports.Collection=f,exports.FocusTrap=m,exports.closeTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.add(t.stateClosing),e.classList.remove(t.stateOpened),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.remove(t.stateClosing),e.classList.add(t.stateClosed),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateClosed),e.classList.remove(t.stateOpened),n(e))})},exports.getConfig=function(e,t){var n=(e.getAttribute("data-"+t)||"").replace(/'/g,'"');return n?JSON.parse(n):{}},exports.getPrefix=function(){return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim()},exports.localStore=function(e,t){void 0===t&&(t=!0);var n=localStorage.getItem(e),i=n?JSON.parse(n):{};return{get:function(e){return e?i[e]:i},set:function(n,r){return r?i[n]=r:delete i[n],t&&localStorage.setItem(e,JSON.stringify(i)),i}}},exports.openTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.remove(t.stateClosed),e.classList.add(t.stateOpening),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.add(t.stateOpened),e.classList.remove(t.stateOpening),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateOpened),e.classList.remove(t.stateClosed),n(e))})},exports.teleport=function(e,t,n){var i=t.nodeType===Node.COMMENT_NODE,r=t.nodeType===Node.ELEMENT_NODE;if(i&&(n="after"),!(t=i||r?t:document.querySelector(t)))throw new Error("Not a valid teleport reference: '"+t+"'");if("function"!=typeof t[n])throw new Error("Not a valid teleport method: '"+n+"'");var o=null;return i||(o=document.createComment("teleported #"+e.id),e.before(o)),t[n](e),i&&t.remove(),o},exports.updateGlobalState=function(e,t){var n,i;n=!!e,(i=t.selectorInert)&&document.querySelectorAll(i).forEach(function(e){n?(e.inert=!0,e.setAttribute("aria-hidden",!0)):(e.inert=null,e.removeAttribute("aria-hidden"))}),function(e,t){t&&document.querySelectorAll(t).forEach(function(t){e?t.style.overflow="hidden":t.style.removeProperty("overflow")})}(!!e,t.selectorOverflow)}; | ||
//# sourceMappingURL=scripts.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("focusable-selectors")):"function"==typeof define&&define.amd?define(["exports","focusable-selectors"],t):t(((e||self).vrembem=e.vrembem||{},e.vrembem.core={}),e.focusableSelectors)}(this,function(e,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(t);function r(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var c=0;function u(e){return"__private_"+c+++"_"+e}function l(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var a=/*#__PURE__*/u("handler"),f=/*#__PURE__*/function(){function e(e,t){Object.defineProperty(this,a,{writable:!0,value:void 0}),this.value=e,l(this,a)[a]=t,this.mql=null}var t=e.prototype;return t.mount=function(e,t){return e&&(this.value=e),t&&(l(this,a)[a]=t),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",l(this,a)[a]):this.mql.addListener(l(this,a)[a]),l(this,a)[a](this.mql),this):this},t.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",l(this,a)[a]):this.mql.removeListener(l(this,a)[a]),this.value=null,l(this,a)[a]=null,this.mql=null,this):this},s(e,[{key:"handler",get:function(){return l(this,a)[a]},set:function(e){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",l(this,a)[a]):this.mql.removeListener(l(this,a)[a])),l(this,a)[a]=e}}]),e}();function h(e,t,n){if(!e.s){if(n instanceof d){if(!n.s)return void(n.o=h.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(h.bind(null,e,t),h.bind(null,e,2));e.s=t,e.v=n;const i=e.o;i&&i(e)}}var d=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var i=new e,r=this.s;if(r){var o=1&r?t:n;if(o){try{h(i,1,o(this.v))}catch(e){h(i,2,e)}return i}return this}return this.o=function(e){try{var r=e.v;1&e.s?h(i,1,t?t(r):r):n?h(i,1,n(r)):h(i,2,r)}catch(e){h(i,2,e)}},i},e}();function v(e){return e instanceof d&&1&e.s}var m=/*#__PURE__*/function(){function e(){this.collection=[]}var t=e.prototype;return t.register=function(e){try{var t=this;return Promise.resolve(t.deregister(e)).then(function(){return t.collection.push(e),t.collection})}catch(e){return Promise.reject(e)}},t.deregister=function(e){try{var t=this,n=t.collection.findIndex(function(t){return t===e});if(n>=0){var i=t.collection[n];Object.getOwnPropertyNames(i).forEach(function(e){delete i[e]}),t.collection.splice(n,1)}return Promise.resolve(t.collection)}catch(e){return Promise.reject(e)}},t.registerCollection=function(e){try{var t=this;return Promise.resolve(Promise.all(Array.from(e,function(e){t.register(e)}))).then(function(){return t.collection})}catch(e){return Promise.reject(e)}},t.deregisterCollection=function(){try{var e=function(){return t.collection},t=this,n=function(e,t,n){for(var i;;){var r=e();if(v(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!v(o)){i=1;break}o=o.s}if(t){var s=t();if(s&&s.then&&!v(s)){i=2;break}}}var c=new d,u=h.bind(null,c,2);return(0===i?r.then(a):1===i?o.then(l):s.then(f)).then(void 0,u),c;function l(i){o=i;do{if(t&&(s=t())&&s.then&&!v(s))return void s.then(f).then(void 0,u);if(!(r=e())||v(r)&&!r.v)return void h(c,1,o);if(r.then)return void r.then(a).then(void 0,u);v(o=n())&&(o=o.v)}while(!o||!o.then);o.then(l).then(void 0,u)}function a(e){e?(o=n())&&o.then?o.then(l).then(void 0,u):l(o):h(c,1,o)}function f(){(r=e())?r.then?r.then(a).then(void 0,u):a(r):h(c,1,o)}}(function(){return t.collection.length>0},void 0,function(){return Promise.resolve(t.deregister(t.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(e):e())}catch(e){return Promise.reject(e)}},t.get=function(e,t){return void 0===t&&(t="id"),this.collection.find(function(n){return n[t]===e})},e}(),p=/*#__PURE__*/u("focusable"),y=/*#__PURE__*/u("handleFocusTrap"),b=/*#__PURE__*/u("handleFocusLock"),g=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t="[data-focus]"),Object.defineProperty(this,p,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),Object.defineProperty(this,b,{writable:!0,value:void 0}),this.el=e,this.selectorFocus=t,l(this,y)[y]=E.bind(this),l(this,b)[b]=L.bind(this)}var t=e.prototype;return t.mount=function(e,t){e&&(this.el=e),t&&(this.selectorFocus=t),this.focusable=this.getFocusable(),this.focus()},t.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",l(this,y)[y]),document.removeEventListener("keydown",l(this,b)[b])},t.focus=function(e,t){void 0===e&&(e=this.el),void 0===t&&(t=this.selectorFocus),(e.querySelector(t)||e).focus()},t.getFocusable=function(e){void 0===e&&(e=this.el);var t=[],n=document.activeElement,r=e.scrollTop;return e.querySelectorAll(i.default.join(",")).forEach(function(e){e.focus(),document.activeElement===e&&t.push(e)}),e.scrollTop=r,n.focus(),t},s(e,[{key:"focusable",get:function(){return l(this,p)[p]},set:function(e){l(this,p)[p]=e,l(this,p)[p].length?(document.removeEventListener("keydown",l(this,b)[b]),document.addEventListener("keydown",l(this,y)[y])):(document.removeEventListener("keydown",l(this,y)[y]),document.addEventListener("keydown",l(this,b)[b]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),e}();function E(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(e.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(e.preventDefault(),this.focusableFirst.focus()))}function L(e){("Tab"===e.key||9===e.keyCode)&&e.preventDefault()}e.Breakpoint=f,e.Collection=m,e.FocusTrap=g,e.closeTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.add(t.stateClosing),e.classList.remove(t.stateOpened),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.remove(t.stateClosing),e.classList.add(t.stateClosed),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateClosed),e.classList.remove(t.stateOpened),n(e))})},e.getConfig=function(e,t){var n=(e.getAttribute("data-"+t)||"").replace(/'/g,'"');return n?JSON.parse(n):{}},e.getPrefix=function(){return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim()},e.localStore=function(e,t){void 0===t&&(t=!0);var n=localStorage.getItem(e),i=n?JSON.parse(n):{};return{get:function(e){return e?i[e]:i},set:function(n,r){return r?i[n]=r:delete i[n],t&&localStorage.setItem(e,JSON.stringify(i)),i}}},e.openTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.remove(t.stateClosed),e.classList.add(t.stateOpening),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.add(t.stateOpened),e.classList.remove(t.stateOpening),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateOpened),e.classList.remove(t.stateClosed),n(e))})},e.teleport=function(e,t,n){var i=t.nodeType===Node.COMMENT_NODE,r=t.nodeType===Node.ELEMENT_NODE;if(i&&(n="after"),!(t=i||r?t:document.querySelector(t)))throw new Error("Not a valid teleport reference: '"+t+"'");if("function"!=typeof t[n])throw new Error("Not a valid teleport method: '"+n+"'");var o=null;return i||(o=document.createComment("teleported #"+e.id),e.before(o)),t[n](e),i&&t.remove(),o},e.updateGlobalState=function(e,t){var n,i;n=!!e,(i=t.selectorInert)&&document.querySelectorAll(i).forEach(function(e){n?(e.inert=!0,e.setAttribute("aria-hidden",!0)):(e.inert=null,e.removeAttribute("aria-hidden"))}),function(e,t){t&&document.querySelectorAll(t).forEach(function(t){e?t.style.overflow="hidden":t.style.removeProperty("overflow")})}(!!e,t.selectorOverflow)}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e||self).vrembem=e.vrembem||{},e.vrembem.core={}))}(this,function(e){function t(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var n=0;function i(e){return"__private_"+n+++"_"+e}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,s(i.key),i)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}var c=/*#__PURE__*/i("handler"),u=/*#__PURE__*/function(){function e(e,n){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=e,t(this,c)[c]=n,this.mql=null}var n=e.prototype;return n.mount=function(e,n){return e&&(this.value=e),n&&(t(this,c)[c]=n),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",t(this,c)[c]):this.mql.addListener(t(this,c)[c]),t(this,c)[c](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",t(this,c)[c]):this.mql.removeListener(t(this,c)[c]),this.value=null,t(this,c)[c]=null,this.mql=null,this):this},o(e,[{key:"handler",get:function(){return t(this,c)[c]},set:function(e){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",t(this,c)[c]):this.mql.removeListener(t(this,c)[c])),t(this,c)[c]=e}}])}();function l(e,t,n){if(!e.s){if(n instanceof a){if(!n.s)return void(n.o=l.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(l.bind(null,e,t),l.bind(null,e,2));e.s=t,e.v=n;const i=e.o;i&&i(e)}}var a=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var i=new e,r=this.s;if(r){var o=1&r?t:n;if(o){try{l(i,1,o(this.v))}catch(e){l(i,2,e)}return i}return this}return this.o=function(e){try{var r=e.v;1&e.s?l(i,1,t?t(r):r):n?l(i,1,n(r)):l(i,2,r)}catch(e){l(i,2,e)}},i},e}();function f(e){return e instanceof a&&1&e.s}var d=/*#__PURE__*/function(){function e(){this.collection=[]}var t=e.prototype;return t.register=function(e){try{var t=this;return Promise.resolve(t.deregister(e)).then(function(){return t.collection.push(e),t.collection})}catch(e){return Promise.reject(e)}},t.deregister=function(e){try{var t=this,n=t.collection.findIndex(function(t){return t===e});if(n>=0){var i=t.collection[n];Object.getOwnPropertyNames(i).forEach(function(e){delete i[e]}),t.collection.splice(n,1)}return Promise.resolve(t.collection)}catch(e){return Promise.reject(e)}},t.registerCollection=function(e){try{var t=this;return Promise.resolve(Promise.all(Array.from(e,function(e){t.register(e)}))).then(function(){return t.collection})}catch(e){return Promise.reject(e)}},t.deregisterCollection=function(){try{var e=function(){return t.collection},t=this,n=function(e,t,n){for(var i;;){var r=e();if(f(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!f(o)){i=1;break}o=o.s}if(t){var s=t();if(s&&s.then&&!f(s)){i=2;break}}}var c=new a,u=l.bind(null,c,2);return(0===i?r.then(h):1===i?o.then(d):s.then(v)).then(void 0,u),c;function d(i){o=i;do{if(t&&(s=t())&&s.then&&!f(s))return void s.then(v).then(void 0,u);if(!(r=e())||f(r)&&!r.v)return void l(c,1,o);if(r.then)return void r.then(h).then(void 0,u);f(o=n())&&(o=o.v)}while(!o||!o.then);o.then(d).then(void 0,u)}function h(e){e?(o=n())&&o.then?o.then(d).then(void 0,u):d(o):l(c,1,o)}function v(){(r=e())?r.then?r.then(h).then(void 0,u):h(r):l(c,1,o)}}(function(){return t.collection.length>0},void 0,function(){return Promise.resolve(t.deregister(t.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(e):e())}catch(e){return Promise.reject(e)}},t.get=function(e,t){return void 0===t&&(t="id"),this.collection.find(function(n){return n[t]===e})},e}(),h=/*#__PURE__*/i("focusable"),v=/*#__PURE__*/i("handleFocusTrap"),m=/*#__PURE__*/i("handleFocusLock"),p=/*#__PURE__*/function(){function e(e,n){void 0===e&&(e=null),void 0===n&&(n="[data-focus]"),Object.defineProperty(this,h,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),this.el=e,this.selectorFocus=n,t(this,v)[v]=L.bind(this),t(this,m)[m]=w.bind(this)}var n=e.prototype;return n.mount=function(e,t){e&&(this.el=e),t&&(this.selectorFocus=t),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",t(this,v)[v]),document.removeEventListener("keydown",t(this,m)[m])},n.focus=function(e,t){void 0===e&&(e=this.el),void 0===t&&(t=this.selectorFocus),(e.querySelector(t)||e).focus()},n.getFocusable=function(e){void 0===e&&(e=this.el);var t=[],n=document.activeElement,i=e.scrollTop,r=E.join(",");return e.querySelectorAll(r).forEach(function(e){e.focus(),document.activeElement===e&&t.push(e)}),e.scrollTop=i,n.focus(),t},o(e,[{key:"focusable",get:function(){return t(this,h)[h]},set:function(e){t(this,h)[h]=e,t(this,h)[h].length?(document.removeEventListener("keydown",t(this,m)[m]),document.addEventListener("keydown",t(this,v)[v])):(document.removeEventListener("keydown",t(this,v)[v]),document.addEventListener("keydown",t(this,m)[m]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}])}(),y=":not([inert])",b=':not([tabindex^="-"])',g=":not(:disabled)",E=["a[href]"+y+b,"area[href]"+y+b,'input:not([type="hidden"]):not([type="radio"])'+y+b+g,'input[type="radio"]'+y+b+g,"select"+y+b+g,"textarea"+y+b+g,"button"+y+b+g,"details"+y+" > summary:first-of-type"+b,"iframe"+y+b,"audio[controls]"+y+b,"video[controls]"+y+b,"[contenteditable]"+y+b,"[tabindex]"+y+b];function L(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(e.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(e.preventDefault(),this.focusableFirst.focus()))}function w(e){("Tab"===e.key||9===e.keyCode)&&e.preventDefault()}e.Breakpoint=u,e.Collection=d,e.FocusTrap=p,e.closeTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.add(t.stateClosing),e.classList.remove(t.stateOpened),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.remove(t.stateClosing),e.classList.add(t.stateClosed),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateClosed),e.classList.remove(t.stateOpened),n(e))})},e.getConfig=function(e,t){var n=(e.getAttribute("data-"+t)||"").replace(/'/g,'"');return n?JSON.parse(n):{}},e.getPrefix=function(){return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim()},e.localStore=function(e,t){void 0===t&&(t=!0);var n=localStorage.getItem(e),i=n?JSON.parse(n):{};return{get:function(e){return e?i[e]:i},set:function(n,r){return r?i[n]=r:delete i[n],t&&localStorage.setItem(e,JSON.stringify(i)),i}}},e.openTransition=function(e,t){return new Promise(function(n){t.transition?(e.classList.remove(t.stateClosed),e.classList.add(t.stateOpening),e.addEventListener("transitionend",function i(r){r.target==e&&(e.classList.add(t.stateOpened),e.classList.remove(t.stateOpening),n(e),this.removeEventListener("transitionend",i))})):(e.classList.add(t.stateOpened),e.classList.remove(t.stateClosed),n(e))})},e.teleport=function(e,t,n){var i=t.nodeType===Node.COMMENT_NODE,r=t.nodeType===Node.ELEMENT_NODE;if(i&&(n="after"),!(t=i||r?t:document.querySelector(t)))throw new Error("Not a valid teleport reference: '"+t+"'");if("function"!=typeof t[n])throw new Error("Not a valid teleport method: '"+n+"'");var o=null;return i||(o=document.createComment("teleported #"+e.id),e.before(o)),t[n](e),i&&t.remove(),o},e.updateGlobalState=function(e,t){var n,i;n=!!e,(i=t.selectorInert)&&document.querySelectorAll(i).forEach(function(e){n?(e.inert=!0,e.setAttribute("aria-hidden",!0)):(e.inert=null,e.removeAttribute("aria-hidden"))}),function(e,t){t&&document.querySelectorAll(t).forEach(function(t){e?t.style.overflow="hidden":t.style.removeProperty("overflow")})}(!!e,t.selectorOverflow)}}); | ||
//# sourceMappingURL=scripts.umd.js.map |
18
index.js
@@ -1,10 +0,10 @@ | ||
export * from './src/js/Breakpoint'; | ||
export * from './src/js/Collection'; | ||
export * from './src/js/FocusTrap'; | ||
export * from "./src/js/Breakpoint"; | ||
export * from "./src/js/Collection"; | ||
export * from "./src/js/FocusTrap"; | ||
export * from './src/js/getConfig'; | ||
export * from './src/js/getPrefix'; | ||
export * from './src/js/localStore'; | ||
export * from './src/js/teleport'; | ||
export * from './src/js/transition'; | ||
export * from './src/js/updateGlobalState'; | ||
export * from "./src/js/getConfig"; | ||
export * from "./src/js/getPrefix"; | ||
export * from "./src/js/localStore"; | ||
export * from "./src/js/teleport"; | ||
export * from "./src/js/transition"; | ||
export * from "./src/js/updateGlobalState"; |
{ | ||
"name": "@vrembem/core", | ||
"description": "The core variables, functions and mixins for Vrembem components.", | ||
"version": "3.0.19", | ||
"version": "3.0.20", | ||
"license": "MIT", | ||
@@ -48,6 +48,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "44fdcf68e9744e94d6d3f9dbb587057d002ea363", | ||
"dependencies": { | ||
"focusable-selectors": "^0.8.4" | ||
} | ||
"gitHead": "04370013a5a5c2ec544c3144c820ea9876db158e" | ||
} |
@@ -18,4 +18,4 @@ export class Breakpoint { | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', this.#handler); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", this.#handler); | ||
} else { | ||
@@ -40,4 +40,4 @@ this.mql.removeListener(this.#handler); | ||
// Conditionally use addListener() for IE11 support. | ||
if (typeof this.mql.addEventListener === 'function') { | ||
this.mql.addEventListener('change', this.#handler); | ||
if (typeof this.mql.addEventListener === "function") { | ||
this.mql.addEventListener("change", this.#handler); | ||
} else { | ||
@@ -58,4 +58,4 @@ this.mql.addListener(this.#handler); | ||
// Conditionally use removeListener() for IE11 support. | ||
if (typeof this.mql.removeEventListener === 'function') { | ||
this.mql.removeEventListener('change', this.#handler); | ||
if (typeof this.mql.removeEventListener === "function") { | ||
this.mql.removeEventListener("change", this.#handler); | ||
} else { | ||
@@ -62,0 +62,0 @@ this.mql.removeListener(this.#handler); |
@@ -40,3 +40,3 @@ export class Collection { | ||
get(value, key = 'id') { | ||
get(value, key = "id") { | ||
return this.collection.find((item) => { | ||
@@ -43,0 +43,0 @@ return item[key] === value; |
@@ -1,3 +0,1 @@ | ||
import focusableSelectors from 'focusable-selectors'; | ||
export class FocusTrap { | ||
@@ -8,3 +6,3 @@ #focusable; | ||
constructor(el = null, selectorFocus = '[data-focus]') { | ||
constructor(el = null, selectorFocus = "[data-focus]") { | ||
this.el = el; | ||
@@ -26,7 +24,7 @@ this.selectorFocus = selectorFocus; | ||
if (this.#focusable.length) { | ||
document.removeEventListener('keydown', this.#handleFocusLock); | ||
document.addEventListener('keydown', this.#handleFocusTrap); | ||
document.removeEventListener("keydown", this.#handleFocusLock); | ||
document.addEventListener("keydown", this.#handleFocusTrap); | ||
} else { | ||
document.removeEventListener('keydown', this.#handleFocusTrap); | ||
document.addEventListener('keydown', this.#handleFocusLock); | ||
document.removeEventListener("keydown", this.#handleFocusTrap); | ||
document.addEventListener("keydown", this.#handleFocusLock); | ||
} | ||
@@ -63,4 +61,4 @@ } | ||
// Remove event listeners | ||
document.removeEventListener('keydown', this.#handleFocusTrap); | ||
document.removeEventListener('keydown', this.#handleFocusLock); | ||
document.removeEventListener("keydown", this.#handleFocusTrap); | ||
document.removeEventListener("keydown", this.#handleFocusLock); | ||
} | ||
@@ -84,3 +82,4 @@ | ||
// Query for all the focusable elements. | ||
const els = el.querySelectorAll(focusableSelectors.join(',')); | ||
const selector = focusableSelectors.join(","); | ||
const els = el.querySelectorAll(selector); | ||
@@ -107,5 +106,26 @@ // Loop through all focusable elements. | ||
// This has been copied over from focusable-selectors package and modified. | ||
// https://github.com/KittyGiraudel/focusable-selectors | ||
const notInert = ":not([inert])"; // Previously `:not([inert]):not([inert] *)` | ||
const notNegTabIndex = ":not([tabindex^=\"-\"])"; | ||
const notDisabled = ":not(:disabled)"; | ||
const focusableSelectors = [ | ||
`a[href]${notInert}${notNegTabIndex}`, | ||
`area[href]${notInert}${notNegTabIndex}`, | ||
`input:not([type="hidden"]):not([type="radio"])${notInert}${notNegTabIndex}${notDisabled}`, | ||
`input[type="radio"]${notInert}${notNegTabIndex}${notDisabled}`, | ||
`select${notInert}${notNegTabIndex}${notDisabled}`, | ||
`textarea${notInert}${notNegTabIndex}${notDisabled}`, | ||
`button${notInert}${notNegTabIndex}${notDisabled}`, | ||
`details${notInert} > summary:first-of-type${notNegTabIndex}`, | ||
`iframe${notInert}${notNegTabIndex}`, | ||
`audio[controls]${notInert}${notNegTabIndex}`, | ||
`video[controls]${notInert}${notNegTabIndex}`, | ||
`[contenteditable]${notInert}${notNegTabIndex}`, | ||
`[tabindex]${notInert}${notNegTabIndex}`, | ||
]; | ||
function handleFocusTrap(event) { | ||
// Check if the click was a tab and return if not. | ||
const isTab = (event.key === 'Tab' || event.keyCode === 9); | ||
const isTab = (event.key === "Tab" || event.keyCode === 9); | ||
if (!isTab) return; | ||
@@ -139,4 +159,4 @@ | ||
// Ignore the tab key by preventing default. | ||
const isTab = (event.key === 'Tab' || event.keyCode === 9); | ||
const isTab = (event.key === "Tab" || event.keyCode === 9); | ||
if (isTab) event.preventDefault(); | ||
} |
export function getConfig(el, dataConfig) { | ||
const string = el.getAttribute(`data-${dataConfig}`) || ''; | ||
const json = string.replace(/'/g, '"'); | ||
const string = el.getAttribute(`data-${dataConfig}`) || ""; | ||
const json = string.replace(/'/g, "\""); | ||
return (json) ? JSON.parse(json) : {}; | ||
} |
export function getPrefix() { | ||
return getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix').trim(); | ||
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(); | ||
} |
@@ -21,7 +21,7 @@ /** | ||
// If ref is a comment, set teleport type to 'after'. | ||
if (isComment) how = 'after'; | ||
if (isComment) how = "after"; | ||
// Must be a valid reference element and method. | ||
if (!where) throw new Error(`Not a valid teleport reference: '${where}'`); | ||
if (typeof where[how] != 'function') throw new Error(`Not a valid teleport method: '${how}'`); | ||
if (typeof where[how] != "function") throw new Error(`Not a valid teleport method: '${how}'`); | ||
@@ -33,3 +33,3 @@ // Initial return ref is null. | ||
if (!isComment) { | ||
returnRef = document.createComment('teleported #' + what.id); | ||
returnRef = document.createComment("teleported #" + what.id); | ||
what.before(returnRef); | ||
@@ -36,0 +36,0 @@ } |
@@ -10,3 +10,3 @@ export const openTransition = (el, settings) => { | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -21,3 +21,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -42,3 +42,3 @@ } else { | ||
// Add event listener for when the transition is finished. | ||
el.addEventListener('transitionend', function _f(event) { | ||
el.addEventListener("transitionend", function _f(event) { | ||
// Prevent child transition bubbling from firing this event. | ||
@@ -53,3 +53,3 @@ if (event.target != el) return; | ||
resolve(el); | ||
this.removeEventListener('transitionend', _f); | ||
this.removeEventListener("transitionend", _f); | ||
}); | ||
@@ -56,0 +56,0 @@ } else { |
@@ -6,5 +6,5 @@ function setOverflowHidden(state, selector) { | ||
if (state) { | ||
el.style.overflow = 'hidden'; | ||
el.style.overflow = "hidden"; | ||
} else { | ||
el.style.removeProperty('overflow'); | ||
el.style.removeProperty("overflow"); | ||
} | ||
@@ -21,6 +21,6 @@ }); | ||
el.inert = true; | ||
el.setAttribute('aria-hidden', true); | ||
el.setAttribute("aria-hidden", true); | ||
} else { | ||
el.inert = null; | ||
el.removeAttribute('aria-hidden'); | ||
el.removeAttribute("aria-hidden"); | ||
} | ||
@@ -27,0 +27,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
389315
0
2807
0
0
- Removedfocusable-selectors@^0.8.4
- Removedfocusable-selectors@0.8.4(transitive)