Skip to content

Commit

Permalink
chore: run build
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDJM committed Jun 25, 2024
1 parent 7dbb17e commit 5ee6aeb
Show file tree
Hide file tree
Showing 15 changed files with 645 additions and 574 deletions.
4 changes: 2 additions & 2 deletions dist/accessible-menu.cjs.js

Large diffs are not rendered by default.

467 changes: 237 additions & 230 deletions dist/accessible-menu.es.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/accessible-menu.iife.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/disclosure-menu.cjs.js

Large diffs are not rendered by default.

153 changes: 86 additions & 67 deletions dist/disclosure-menu.es.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/disclosure-menu.iife.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/menubar.cjs.js

Large diffs are not rendered by default.

143 changes: 81 additions & 62 deletions dist/menubar.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function g(n, e) {
};
}
}
function c(n, e) {
function m(n, e) {
try {
if (typeof e != "object") {
const t = typeof e;
Expand Down Expand Up @@ -206,7 +206,7 @@ function S(n) {
}
}
function V(n, e) {
if (c("string", { tagName: n }).status && g(HTMLElement, e).status) {
if (m("string", { tagName: n }).status && g(HTMLElement, e).status) {
const t = n.toLowerCase();
let s = !0;
for (const i in e)
Expand Down Expand Up @@ -348,7 +348,7 @@ class D {
return this._open;
}
set isOpen(e) {
c("boolean", { value: e }), this._open = e;
m("boolean", { value: e }), this._open = e;
}
/**
* Sets unique IDs for the toggle and controlled menu.
Expand Down Expand Up @@ -409,7 +409,7 @@ class D {
*/
_expand(e = !0) {
const { closeClass: t, openClass: s, transitionClass: i } = this.elements.controlledMenu;
this.dom.toggle.setAttribute("aria-expanded", "true"), i !== "" ? (d(i, this.elements.controlledMenu.dom.menu), requestAnimationFrame(() => {
this.dom.toggle.setAttribute("aria-expanded", "true"), this.elements.controlledMenu.elements.rootMenu.hasOpened = !0, i !== "" ? (d(i, this.elements.controlledMenu.dom.menu), requestAnimationFrame(() => {
t !== "" && f(t, this.elements.controlledMenu.dom.menu), requestAnimationFrame(() => {
s !== "" && d(s, this.elements.controlledMenu.dom.menu), requestAnimationFrame(() => {
f(i, this.elements.controlledMenu.dom.menu);
Expand Down Expand Up @@ -685,17 +685,17 @@ class M {
submenuItemSelector: i = "li:has(ul)",
submenuToggleSelector: r = "a",
submenuSelector: l = "ul",
controllerElement: m = null,
controllerElement: c = null,
containerElement: a = null,
openClass: h = "show",
closeClass: C = "hide",
transitionClass: b = "transitioning",
closeClass: b = "hide",
transitionClass: C = "transitioning",
isTopLevel: y = !0,
parentMenu: E = null,
hoverType: T = "off",
hoverDelay: v = 250,
enterDelay: w = -1,
leaveDelay: I = -1
hoverDelay: w = 250,
enterDelay: I = -1,
leaveDelay: v = -1
}) {
/**
* The class to use when generating submenus.
Expand Down Expand Up @@ -882,6 +882,14 @@ class M {
* @type {?Function}
*/
o(this, "_hoverTimeout", null);
/**
* A flag to check if the menu can dynamically hover based on if a menu has been opened already.
*
* @protected
*
* @type {boolean}
*/
o(this, "_hasOpened", !1);
/**
* An array of error messages generated by the menu.
*
Expand All @@ -890,7 +898,7 @@ class M {
* @type {string[]}
*/
o(this, "_errors", []);
this._dom.menu = e, this._dom.controller = m, this._dom.container = a, this._selectors.menuItems = t, this._selectors.menuLinks = s, this._selectors.submenuItems = i, this._selectors.submenuToggles = r, this._selectors.submenus = l, this._elements.menuItems = [], this._elements.submenuToggles = [], this._elements.controller = null, this._elements.parentMenu = E, this._elements.rootMenu = y ? this : null, this._openClass = h || "", this._closeClass = C || "", this._transitionClass = b || "", this._root = y, this._hoverType = T, this._hoverDelay = v, this._enterDelay = w, this._leaveDelay = I;
this._dom.menu = e, this._dom.controller = c, this._dom.container = a, this._selectors.menuItems = t, this._selectors.menuLinks = s, this._selectors.submenuItems = i, this._selectors.submenuToggles = r, this._selectors.submenus = l, this._elements.menuItems = [], this._elements.submenuToggles = [], this._elements.controller = null, this._elements.parentMenu = E, this._elements.rootMenu = y ? this : null, this._openClass = h || "", this._closeClass = b || "", this._transitionClass = C || "", this._root = y, this._hoverType = T, this._hoverDelay = w, this._enterDelay = I, this._leaveDelay = v;
}
/**
* Initializes the menu.
Expand Down Expand Up @@ -1140,6 +1148,19 @@ class M {
let e = !1;
return (this.currentEvent === "keyboard" || this.currentEvent === "character") && (e = !0), this.currentEvent === "mouse" && this.hoverType === "dynamic" && (e = !0), e;
}
/**
* A flag to check if the menu can dynamically hover.
*
* This functions differently for root vs. submenus.
* Submenus will always inherit their root menu's hasOpened.
*
* @type {boolean}
*
* @see _hasOpened
*/
get hasOpened() {
return this._root ? this._hasOpened : this.elements.rootMenu.hasOpened;
}
/**
* An array of error messages generated by the menu.
*
Expand All @@ -1162,13 +1183,13 @@ class M {
p({ transitionClass: e }), this._transitionClass !== e && (this._transitionClass = e);
}
set currentChild(e) {
c("number", { value: e });
m("number", { value: e });
function t(s) {
if (["mouse", "character"].includes(s.currentEvent) && s.elements.parentMenu) {
let r = 0, l = !1;
for (; !l && r < s.elements.parentMenu.elements.menuItems.length; ) {
const m = s.elements.parentMenu.elements.menuItems[r];
m.isSubmenuItem && m.elements.toggle.elements.controlledMenu === s && (l = !0, s.elements.parentMenu.currentEvent = s.currentEvent, s.elements.parentMenu.currentChild = r), r++;
const c = s.elements.parentMenu.elements.menuItems[r];
c.isSubmenuItem && c.elements.toggle.elements.controlledMenu === s && (l = !0, s.elements.parentMenu.currentEvent = s.currentEvent, s.elements.parentMenu.currentChild = r), r++;
}
}
}
Expand All @@ -1188,13 +1209,16 @@ class M {
S({ value: e }), this._hoverType !== e && (this._hoverType = e);
}
set hoverDelay(e) {
c("number", { value: e }), this._hoverDelay !== e && (this._hoverDelay = e);
m("number", { value: e }), this._hoverDelay !== e && (this._hoverDelay = e);
}
set enterDelay(e) {
c("number", { value: e }), this._enterDelay !== e && (this._enterDelay = e);
m("number", { value: e }), this._enterDelay !== e && (this._enterDelay = e);
}
set leaveDelay(e) {
c("number", { value: e }), this._leaveDelay !== e && (this._leaveDelay = e);
m("number", { value: e }), this._leaveDelay !== e && (this._leaveDelay = e);
}
set hasOpened(e) {
m("boolean", { value: e }), this._hasOpened !== e && (this._hasOpened = e);
}
/**
* Validates all aspects of the menu to ensure proper functionality.
Expand Down Expand Up @@ -1238,7 +1262,7 @@ class M {
});
h.status || (this._errors.push(h.error.message), e = !1);
}
const i = c("boolean", { isTopLevel: this._root });
const i = m("boolean", { isTopLevel: this._root });
if (i.status || (this._errors.push(i.error.message), e = !1), this._elements.parentMenu !== null) {
const h = g(M, {
parentMenu: this._elements.parentMenu
Expand All @@ -1247,15 +1271,15 @@ class M {
}
const r = S({ hoverType: this._hoverType });
r.status || (this._errors.push(r.error.message), e = !1);
const l = c("number", {
const l = m("number", {
hoverDelay: this._hoverDelay
});
l.status || (this._errors.push(l.error.message), e = !1);
const m = c("number", {
const c = m("number", {
enterDelay: this._enterDelay
});
m.status || (this._errors.push(m.error.message), e = !1);
const a = c("number", {
c.status || (this._errors.push(c.error.message), e = !1);
const a = m("number", {
leaveDelay: this._leaveDelay
});
return a.status || (this._errors.push(a.error.message), e = !1), e;
Expand Down Expand Up @@ -1408,7 +1432,7 @@ class M {
* @param {number} delay - The delay time in milliseconds.
*/
_setTimeout(e, t) {
c("function", { callback: e }), c("number", { delay: t }), this._hoverTimeout = setTimeout(e, t);
m("function", { callback: e }), m("number", { delay: t }), this._hoverTimeout = setTimeout(e, t);
}
/**
* Handles focus events throughout the menu for proper menu use.
Expand Down Expand Up @@ -1462,7 +1486,11 @@ class M {
(t) => {
this.currentEvent = "mouse", e(this, this.elements.controller, t);
}
);
), document.addEventListener("pointerup", (t) => {
this.focusState !== "none" && (this.currentEvent = "mouse", !this.dom.menu.contains(t.target) && !this.dom.menu !== t.target && (this.elements.rootMenu.hasOpened = this.elements.submenuToggles.some(
(s) => s.isOpen
)));
});
}
/**
* Handles hover events throughout the menu for proper use.
Expand Down Expand Up @@ -1512,28 +1540,19 @@ class M {
_handleHover() {
this.elements.menuItems.forEach((e, t) => {
e.dom.link.addEventListener("pointerenter", (s) => {
if (!(s.pointerType === "pen" || s.pointerType === "touch")) {
if (this.hoverType === "on")
this.currentEvent = "mouse", this.elements.rootMenu.blurChildren(), this.focusChild(t), e.isSubmenuItem && (this.enterDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
e.elements.toggle.preview();
}, this.enterDelay)) : e.elements.toggle.preview());
else if (this.hoverType === "dynamic") {
const i = this.elements.submenuToggles.some(
(r) => r.isOpen
);
this.currentChild = t, (!this.isTopLevel || this.focusState !== "none") && (this.currentEvent = "mouse", this.elements.rootMenu.blurChildren(), this.focusCurrentChild()), (!this.isTopLevel || i) && (this.currentEvent = "mouse", this.elements.rootMenu.blurChildren(), this.focusCurrentChild(), e.isSubmenuItem ? this.enterDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
e.elements.toggle.preview();
}, this.enterDelay)) : e.elements.toggle.preview() : this.enterDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
this.closeChildren();
}, this.enterDelay)) : this.closeChildren());
}
}
s.pointerType === "pen" || s.pointerType === "touch" || (this.hoverType === "on" ? (this.currentEvent = "mouse", this.elements.rootMenu.blurChildren(), this.focusChild(t), e.isSubmenuItem && (this.enterDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
e.elements.toggle.preview();
}, this.enterDelay)) : e.elements.toggle.preview())) : this.hoverType === "dynamic" && (this.currentChild = t, (!this.isTopLevel || this.focusState !== "none") && (this.currentEvent = "mouse", this.elements.rootMenu.blurChildren(), this.focusCurrentChild()), (!this.isTopLevel || this.hasOpened) && (this.currentEvent = "mouse", this.elements.rootMenu.blurChildren(), this.focusCurrentChild(), e.isSubmenuItem ? this.enterDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
e.elements.toggle.preview();
}, this.enterDelay)) : e.elements.toggle.preview() : this.enterDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
this.closeChildren();
}, this.enterDelay)) : this.closeChildren())));
}), e.isSubmenuItem && (e.dom.item.addEventListener("pointerleave", (s) => {
s.pointerType === "pen" || s.pointerType === "touch" || (this.hoverType === "on" ? this.leaveDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
this.currentEvent = "mouse", e.elements.toggle.close();
}, this.leaveDelay)) : (this.currentEvent = "mouse", e.elements.toggle.close()) : this.hoverType === "dynamic" && (this.isTopLevel || (this.leaveDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
this.currentEvent = "mouse", e.elements.toggle.close(), this.focusCurrentChild();
}, this.leaveDelay)) : (this.currentEvent = "mouse", e.elements.toggle.close(), this.focusCurrentChild()))));
}, this.leaveDelay)) : (this.currentEvent = "mouse", e.elements.toggle.close()) : this.hoverType === "dynamic" && (this.leaveDelay > 0 ? (this._clearTimeout(), this._setTimeout(() => {
this.currentEvent = "mouse";
}, this.leaveDelay)) : this.currentEvent = "mouse"));
}), e.dom.item.addEventListener("pointerenter", (s) => {
s.pointerType === "pen" || s.pointerType === "touch" || e.isSubmenuItem && (this.hoverType === "on" || this.hoverType === "dynamic") && this.leaveDelay > 0 && this._clearTimeout();
}));
Expand Down Expand Up @@ -1711,7 +1730,7 @@ class z extends A {
isSubmenuItem: i = !1,
childMenu: r = null,
toggle: l = null,
initialize: m = !0
initialize: c = !0
}) {
super({
menuItemElement: e,
Expand All @@ -1720,7 +1739,7 @@ class z extends A {
isSubmenuItem: i,
childMenu: r,
toggle: l
}), m && this.initialize();
}), c && this.initialize();
}
/**
* Initialize the menu item.
Expand Down Expand Up @@ -1849,38 +1868,38 @@ class L extends M {
menuLinkSelector: i = "a",
submenuItemSelector: r = "li:has(ul)",
submenuToggleSelector: l = "a",
submenuSelector: m = "ul",
submenuSelector: c = "ul",
controllerElement: a = null,
containerElement: h = null,
openClass: C = "show",
closeClass: b = "hide",
openClass: b = "show",
closeClass: C = "hide",
transitionClass: y = "transitioning",
isTopLevel: E = !0,
parentMenu: T = null,
hoverType: v = "off",
hoverDelay: w = 250,
enterDelay: I = -1,
leaveDelay: $ = -1,
initialize: O = !0
hoverType: w = "off",
hoverDelay: I = 250,
enterDelay: v = -1,
leaveDelay: O = -1,
initialize: $ = !0
}) {
super({
menuElement: t,
menuItemSelector: s,
menuLinkSelector: i,
submenuItemSelector: r,
submenuToggleSelector: l,
submenuSelector: m,
submenuSelector: c,
controllerElement: a,
containerElement: h,
openClass: C,
closeClass: b,
openClass: b,
closeClass: C,
transitionClass: y,
isTopLevel: E,
parentMenu: T,
hoverType: v,
hoverDelay: w,
enterDelay: I,
leaveDelay: $
hoverType: w,
hoverDelay: I,
enterDelay: v,
leaveDelay: O
});
/**
* The class to use when generating submenus.
Expand All @@ -1907,7 +1926,7 @@ class L extends M {
* @type {typeof MenubarToggle}
*/
o(this, "_MenuToggleType", H);
O && this.initialize();
$ && this.initialize();
}
/**
* Initializes the menu.
Expand Down Expand Up @@ -1946,7 +1965,7 @@ class L extends M {
*/
_handleClick() {
super._handleClick(), document.addEventListener("pointerup", (t) => {
this.focusState !== "none" && (this.currentEvent = "mouse", !this.dom.menu.contains(t.target) && !this.dom.menu !== t.target && (this.closeChildren(), this.blur(), this.elements.controller && this.elements.controller.close()));
this.focusState !== "none" && (this.currentEvent = "mouse", !this.dom.menu.contains(t.target) && !this.dom.menu !== t.target && (this.closeChildren(), this.blur(), this.elements.controller && this.elements.controller.close(), this.elements.rootMenu.hasOpened = !1));
});
}
/**
Expand Down
Loading

0 comments on commit 5ee6aeb

Please sign in to comment.