Skip to content

Commit

Permalink
feat(menus): add default submenuItemSelector
Browse files Browse the repository at this point in the history
See #310
  • Loading branch information
NickDJM authored Jun 24, 2024
1 parent 53c9442 commit 7eea6cf
Show file tree
Hide file tree
Showing 67 changed files with 685 additions and 1,219 deletions.
1 change: 0 additions & 1 deletion demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function generateMenu(type, structure, hover, container, options = {}) {

const menu = new MenuClass({
menuElement: nav.querySelector("ul"),
submenuItemSelector: ".dropdown",
containerElement: nav,
controllerElement: nav.querySelector("button"),
hoverType: hover,
Expand Down
4 changes: 2 additions & 2 deletions dist/accessible-menu.cjs.js

Large diffs are not rendered by default.

311 changes: 188 additions & 123 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.

142 changes: 71 additions & 71 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.

122 changes: 61 additions & 61 deletions dist/menubar.es.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

162 changes: 81 additions & 81 deletions dist/top-link-disclosure-menu.es.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

249 changes: 157 additions & 92 deletions dist/treeview.es.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/treeview.iife.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/base-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The constructor populates the dom, selector, CSS class, and hover related proper
| options.menuElement | `HTMLElement` | The menu element in the DOM. | `undefined` |
| options.menuItemSelector | `string` | The query selector string for menu items. | `"li"` |
| options.menuLinkSelector | `string` | The query selector string for menu links. | `"a"` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `undefined` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `li:has(ul)` |
| options.submenuToggleSelector | `string` | The query selector string for submenu toggle buttons/links. | `"a"` |
| options.submenuSelector | `string` | The query selector string for submenus. | `"ul"` |
| options.controllerElement | `HTMLElement`, `null` | The element controlling the menu in the DOM. | `null` |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/disclosure-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The constructor will call [BaseMenu's constructor](./base-menu#constructor) with
| options.menuElement | `HTMLElement` | The menu element in the DOM. | `undefined` |
| options.menuItemSelector | `string` | The query selector string for menu items. | `"li"` |
| options.menuLinkSelector | `string` | The query selector string for menu links. | `"a"` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `undefined` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `li:has(ul)` |
| options.submenuToggleSelector | `string` | The query selector string for submenu toggle buttons/links. | `"button"` |
| options.submenuSelector | `string` | The query selector string for submenus. | `"ul"` |
| options.controllerElement | `HTMLElement`, `null` | The element controlling the menu in the DOM. | `null` |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/menubar.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The constructor will call [BaseMenu's constructor](./base-menu#constructor) with
| options.menuElement | `HTMLElement` | The menu element in the DOM. | `undefined` |
| options.menuItemSelector | `string` | The query selector string for menu items. | `"li"` |
| options.menuLinkSelector | `string` | The query selector string for menu links. | `"a"` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `undefined` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `li:has(ul)` |
| options.submenuToggleSelector | `string` | The query selector string for submenu toggle buttons/links. | `"a"` |
| options.submenuSelector | `string` | The query selector string for submenus. | `"ul"` |
| options.controllerElement | `HTMLElement`, `null` | The element controlling the menu in the DOM. | `null` |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/top-link-disclosure-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The constructor will call [BaseMenu's constructor](./base-menu#constructor) with
| options.menuElement | `HTMLElement` | The menu element in the DOM. | `undefined` |
| options.menuItemSelector | `string` | The query selector string for menu items. | `"li"` |
| options.menuLinkSelector | `string` | The query selector string for menu links. | `"a"` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `undefined` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `li:has(ul)` |
| options.submenuToggleSelector | `string` | The query selector string for submenu toggle buttons/links. | `"button"` |
| options.submenuSelector | `string` | The query selector string for submenus. | `"ul"` |
| options.submenuSubtoggleSelector | `string` | The query selector string for submenu toggle buttons/links below the top level. | `"a"` |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/treeview.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The constructor will call [BaseMenu's constructor](./base-menu#constructor) with
| options.menuElement | `HTMLElement` | The menu element in the DOM. | `undefined` |
| options.menuItemSelector | `string` | The query selector string for menu items. | `"li"` |
| options.menuLinkSelector | `string` | The query selector string for menu links. | `"a"` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `undefined` |
| options.submenuItemSelector | `string` | The query selector string for menu items containing submenus. | `li:has(ul)` |
| options.submenuToggleSelector | `string` | The query selector string for submenu toggle buttons/links. | `"a"` |
| options.submenuSelector | `string` | The query selector string for submenus. | `"ul"` |
| options.controllerElement | `HTMLElement`, `null` | The element controlling the menu in the DOM. | `null` |
Expand Down
1 change: 0 additions & 1 deletion docs/disclosure-menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const menu = document.querySelector("#creature-menu ul");

const disclosureMenu = new DisclosureMenu({
menuElement: menu,
submenuItemSelector: ".dropdown",
});
```

Expand Down
3 changes: 0 additions & 3 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ import { DisclosureMenu } from "accessible-menu";

const menu = new DisclosureMenu({
menuElement: document.querySelector("#example-menu"),
submenuItemSelector: ".dropdown",
});
```

Expand All @@ -103,7 +102,6 @@ import { Menubar } from "accessible-menu";

const menu = new Menubar({
menuElement: document.querySelector("#example-menu"),
submenuItemSelector: ".dropdown",
});
```

Expand All @@ -112,7 +110,6 @@ import { Treeview } from "accessible-menu";

const menu = new Treeview({
menuElement: document.querySelector("#example-menu"),
submenuItemSelector: ".dropdown",
});
```

Expand Down
1 change: 0 additions & 1 deletion docs/top-link-disclosure-menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const menu = document.querySelector("#creature-menu ul");

const disclosureMenu = new TopLinkDisclosureMenu({
menuElement: menu,
submenuItemSelector: ".dropdown",
});
```

Expand Down
1 change: 0 additions & 1 deletion docs/treeviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const menu = document.querySelector("#creature-menu ul");

const disclosureMenu = new Treeview({
menuElement: menu,
submenuItemSelector: ".dropdown",
});
```

Expand Down
38 changes: 19 additions & 19 deletions src/_baseMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,30 +235,30 @@ class BaseMenu {
/**
* Constructs a new `BaseMenu`.
*
* @param {object} options - The options for generating the menu.
* @param {HTMLElement} options.menuElement - The menu element in the DOM.
* @param {string} [options.menuItemSelector = li] - The query selector string for menu items.
* @param {string} [options.menuLinkSelector = a] - The query selector string for menu links.
* @param {string} [options.submenuItemSelector] - The query selector string for menu items containing submenus.
* @param {string} [options.submenuToggleSelector = a] - The query selector string for submenu toggle buttons/links.
* @param {string} [options.submenuSelector = ul] - The query selector string for submenus.
* @param {?HTMLElement} [options.controllerElement = null] - The element controlling the menu in the DOM.
* @param {?HTMLElement} [options.containerElement = null] - The element containing the menu in the DOM.
* @param {?(string|string[])} [options.openClass = show] - The class to apply when a menu is "open".
* @param {?(string|string[])} [options.closeClass = hide] - The class to apply when a menu is "closed".
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states.
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu.
* @param {?BaseMenu} [options.parentMenu = null] - The parent menu to this menu.
* @param {string} [options.hoverType = off] - The type of hoverability a menu has.
* @param {number} [options.hoverDelay = 250] - The delay for opening and closing menus if the menu is hoverable (in miliseconds).
* @param {number} [options.enterDelay = -1] - The delay for opening menus if the menu is hoverable (in miliseconds).
* @param {number} [options.leaveDelay = -1] - The delay for closing menus if the menu is hoverable (in miliseconds).
* @param {object} options - The options for generating the menu.
* @param {HTMLElement} options.menuElement - The menu element in the DOM.
* @param {string} [options.menuItemSelector = li] - The query selector string for menu items.
* @param {string} [options.menuLinkSelector = a] - The query selector string for menu links.
* @param {string} [options.submenuItemSelector = li:has(ul)] - The query selector string for menu items containing submenus.
* @param {string} [options.submenuToggleSelector = a] - The query selector string for submenu toggle buttons/links.
* @param {string} [options.submenuSelector = ul] - The query selector string for submenus.
* @param {?HTMLElement} [options.controllerElement = null] - The element controlling the menu in the DOM.
* @param {?HTMLElement} [options.containerElement = null] - The element containing the menu in the DOM.
* @param {?(string|string[])} [options.openClass = show] - The class to apply when a menu is "open".
* @param {?(string|string[])} [options.closeClass = hide] - The class to apply when a menu is "closed".
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states.
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu.
* @param {?BaseMenu} [options.parentMenu = null] - The parent menu to this menu.
* @param {string} [options.hoverType = off] - The type of hoverability a menu has.
* @param {number} [options.hoverDelay = 250] - The delay for opening and closing menus if the menu is hoverable (in miliseconds).
* @param {number} [options.enterDelay = -1] - The delay for opening menus if the menu is hoverable (in miliseconds).
* @param {number} [options.leaveDelay = -1] - The delay for closing menus if the menu is hoverable (in miliseconds).
*/
constructor({
menuElement,
menuItemSelector = "li",
menuLinkSelector = "a",
submenuItemSelector = "",
submenuItemSelector = "li:has(ul)",
submenuToggleSelector = "a",
submenuSelector = "ul",
controllerElement = null,
Expand Down
42 changes: 21 additions & 21 deletions src/disclosureMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,32 @@ class DisclosureMenu extends BaseMenu {
/**
* Constructs a new `DisclosureMenu`.
*
* @param {object} options - The options for generating the menu.
* @param {HTMLElement} options.menuElement - The menu element in the DOM.
* @param {string} [options.menuItemSelector = li] - The query selector string for menu items.
* @param {string} [options.menuLinkSelector = a] - The query selector string for menu links.
* @param {string} [options.submenuItemSelector] - The query selector string for menu items containing submenus.
* @param {string} [options.submenuToggleSelector = button] - The query selector string for submenu toggle buttons/links.
* @param {string} [options.submenuSelector = ul] - The query selector string for submenus.
* @param {?HTMLElement} [options.controllerElement = null] - The element controlling the menu in the DOM.
* @param {?HTMLElement} [options.containerElement = null] - The element containing the menu in the DOM.
* @param {?(string|string[])} [options.openClass = show] - The class to apply when a menu is "open".
* @param {?(string|string[])} [options.closeClass = hide] - The class to apply when a menu is "closed".
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states.
* @param {boolean} [options.isTopLevel = true] - A flag to mark the root menu.
* @param {?DisclosureMenu} [options.parentMenu = null] - The parent menu to this menu.
* @param {string} [options.hoverType = off] - The type of hoverability a menu has.
* @param {number} [options.hoverDelay = 250] - The delay for opening and closing menus if the menu is hoverable (in miliseconds).
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds).
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds).
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu.
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation.
* @param {object} options - The options for generating the menu.
* @param {HTMLElement} options.menuElement - The menu element in the DOM.
* @param {string} [options.menuItemSelector = li] - The query selector string for menu items.
* @param {string} [options.menuLinkSelector = a] - The query selector string for menu links.
* @param {string} [options.submenuItemSelector = li:has(ul)] - The query selector string for menu items containing submenus.
* @param {string} [options.submenuToggleSelector = button] - The query selector string for submenu toggle buttons/links.
* @param {string} [options.submenuSelector = ul] - The query selector string for submenus.
* @param {?HTMLElement} [options.controllerElement = null] - The element controlling the menu in the DOM.
* @param {?HTMLElement} [options.containerElement = null] - The element containing the menu in the DOM.
* @param {?(string|string[])} [options.openClass = show] - The class to apply when a menu is "open".
* @param {?(string|string[])} [options.closeClass = hide] - The class to apply when a menu is "closed".
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states.
* @param {boolean} [options.isTopLevel = true] - A flag to mark the root menu.
* @param {?DisclosureMenu} [options.parentMenu = null] - The parent menu to this menu.
* @param {string} [options.hoverType = off] - The type of hoverability a menu has.
* @param {number} [options.hoverDelay = 250] - The delay for opening and closing menus if the menu is hoverable (in miliseconds).
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds).
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds).
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu.
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation.
*/
constructor({
menuElement,
menuItemSelector = "li",
menuLinkSelector = "a",
submenuItemSelector = "",
submenuItemSelector = "li:has(ul)",
submenuToggleSelector = "button",
submenuSelector = "ul",
controllerElement = null,
Expand Down
Loading

0 comments on commit 7eea6cf

Please sign in to comment.