makeup-active-descendant
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -7,73 +7,42 @@ 'use strict'; | ||
exports.createLinear = createLinear; | ||
var NavigationEmitter = _interopRequireWildcard(require("makeup-navigation-emitter")); | ||
var _makeupNextId = _interopRequireDefault(require("makeup-next-id")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } | ||
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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, 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 defaultOptions = { | ||
activeDescendantClassName: 'active-descendant', | ||
autoInit: -1, | ||
autoReset: -1, | ||
autoInit: 'none', | ||
autoReset: 'none', | ||
autoScroll: false, | ||
axis: 'both', | ||
ignoreButtons: false | ||
wrap: false | ||
}; | ||
function onModelMutation() { | ||
var options = this._options; | ||
var modelIndex = this._navigationEmitter.model.index; | ||
this.filteredItems.forEach(function (item, index) { | ||
(0, _makeupNextId.default)(item); | ||
if (index !== modelIndex) { | ||
item.classList.remove(options.activeDescendantClassName); | ||
} else { | ||
item.classList.add(options.activeDescendantClassName); | ||
} | ||
}); | ||
function onModelInit(e) { | ||
var { | ||
items, | ||
toIndex | ||
} = e.detail; | ||
var itemEl = items[toIndex]; | ||
if (itemEl) { | ||
itemEl.classList.add(this._options.activeDescendantClassName); | ||
this._focusEl.setAttribute('aria-activedescendant', itemEl.id); | ||
} | ||
this._el.dispatchEvent(new CustomEvent('activeDescendantInit', { | ||
detail: e.detail | ||
})); | ||
} | ||
function onModelChange(e) { | ||
var fromItem = this.filteredItems[e.detail.fromIndex]; | ||
var toItem = this.filteredItems[e.detail.toIndex]; | ||
var { | ||
fromIndex, | ||
toIndex | ||
} = e.detail; | ||
var fromItem = this.items[fromIndex]; | ||
var toItem = this.items[toIndex]; | ||
if (fromItem) { | ||
fromItem.classList.remove(this._options.activeDescendantClassName); | ||
} | ||
if (toItem) { | ||
toItem.classList.add(this._options.activeDescendantClassName); | ||
this._focusEl.setAttribute('aria-activedescendant', toItem.id); | ||
if (this._options.autoScroll && this._containerEl) { | ||
@@ -83,22 +52,15 @@ this._containerEl.scrollTop = toItem.offsetTop - this._containerEl.offsetHeight / 2; | ||
} | ||
this._el.dispatchEvent(new CustomEvent('activeDescendantChange', { | ||
detail: { | ||
fromIndex: e.detail.fromIndex, | ||
toIndex: e.detail.toIndex | ||
} | ||
detail: e.detail | ||
})); | ||
} | ||
function onModelReset(e) { | ||
var toIndex = e.detail.toIndex; | ||
var activeClassName = this._options.activeDescendantClassName; | ||
this.filteredItems.forEach(function (el) { | ||
this.items.forEach(function (el) { | ||
el.classList.remove(activeClassName); | ||
}); | ||
if (toIndex > -1) { | ||
var itemEl = this.filteredItems[toIndex]; | ||
if (toIndex !== null && toIndex !== -1) { | ||
var itemEl = this.items[toIndex]; | ||
itemEl.classList.add(activeClassName); | ||
this._focusEl.setAttribute('aria-activedescendant', itemEl.id); | ||
@@ -108,8 +70,25 @@ } else { | ||
} | ||
this._el.dispatchEvent(new CustomEvent('activeDescendantReset', { | ||
detail: e.detail | ||
})); | ||
} | ||
var ActiveDescendant = /*#__PURE__*/function () { | ||
function ActiveDescendant(el) { | ||
_classCallCheck(this, ActiveDescendant); | ||
function onModelMutation(e) { | ||
var { | ||
toIndex | ||
} = e.detail; | ||
var activeDescendantClassName = this.options.activeDescendantClassName; | ||
this.items.forEach(function (item, index) { | ||
(0, _makeupNextId.default)(item); | ||
if (index !== toIndex) { | ||
item.classList.remove(activeDescendantClassName); | ||
} else { | ||
item.classList.add(activeDescendantClassName); | ||
} | ||
}); | ||
this._el.dispatchEvent(new CustomEvent('activeDescendantMutation', { | ||
detail: e.detail | ||
})); | ||
} | ||
class ActiveDescendant { | ||
constructor(el) { | ||
this._el = el; | ||
@@ -119,113 +98,67 @@ this._onMutationListener = onModelMutation.bind(this); | ||
this._onResetListener = onModelReset.bind(this); | ||
this._onInitListener = onModelInit.bind(this); | ||
this._el.addEventListener('navigationModelMutation', this._onMutationListener); | ||
this._el.addEventListener('navigationModelChange', this._onChangeListener); | ||
this._el.addEventListener('navigationModelReset', this._onResetListener); | ||
this._el.addEventListener('navigationModelInit', this._onInitListener); | ||
} | ||
destroy() { | ||
this._el.removeEventListener('navigationModelMutation', this._onMutationListener); | ||
this._el.removeEventListener('navigationModelChange', this._onChangeListener); | ||
this._el.removeEventListener('navigationModelReset', this._onResetListener); | ||
this._el.removeEventListener('navigationModelInit', this._onInitListener); | ||
} | ||
} | ||
class LinearActiveDescendant extends ActiveDescendant { | ||
constructor(el, focusEl, itemContainerEl, itemSelector, selectedOptions) { | ||
super(el); | ||
this._options = Object.assign({}, defaultOptions, selectedOptions); | ||
this._focusEl = focusEl; | ||
this._itemContainerEl = itemContainerEl; | ||
this._itemSelector = itemSelector; | ||
_createClass(ActiveDescendant, [{ | ||
key: "destroy", | ||
value: function destroy() { | ||
this._el.removeEventListener('navigationModelMutation', this._onMutationListener); | ||
// ensure container has an id | ||
(0, _makeupNextId.default)(this._itemContainerEl); | ||
this._el.removeEventListener('navigationModelChange', this._onChangeListener); | ||
this._el.removeEventListener('navigationModelReset', this._onResetListener); | ||
// if programmatic relationship set aria-owns | ||
if (this._itemContainerEl !== this._focusEl) { | ||
focusEl.setAttribute('aria-owns', this._itemContainerEl.id); | ||
} | ||
}]); | ||
return ActiveDescendant; | ||
}(); | ||
var LinearActiveDescendant = /*#__PURE__*/function (_ActiveDescendant) { | ||
_inherits(LinearActiveDescendant, _ActiveDescendant); | ||
var _super = _createSuper(LinearActiveDescendant); | ||
function LinearActiveDescendant(el, focusEl, containerEl, itemSelector, selectedOptions) { | ||
var _this; | ||
_classCallCheck(this, LinearActiveDescendant); | ||
_this = _super.call(this, el); | ||
_this._options = Object.assign({}, defaultOptions, selectedOptions); | ||
_this._navigationEmitter = NavigationEmitter.createLinear(el, itemSelector, { | ||
autoInit: _this._options.autoInit, | ||
autoReset: _this._options.autoReset, | ||
axis: _this._options.axis, | ||
ignoreButtons: _this._options.ignoreButtons | ||
this._navigationEmitter = NavigationEmitter.createLinear(el, itemSelector, { | ||
autoInit: this._options.autoInit, | ||
autoReset: this._options.autoReset, | ||
axis: this._options.axis, | ||
ignoreByDelegateSelector: this._options.ignoreByDelegateSelector, | ||
wrap: this._options.wrap | ||
}); | ||
_this._focusEl = focusEl; | ||
_this._containerEl = containerEl; | ||
_this._itemSelector = itemSelector; // ensure container has an id | ||
(0, _makeupNextId.default)(containerEl); // if DOM hierarchy cannot be determined, | ||
// focus element must programatically 'own' the container of descendant items | ||
if (containerEl !== focusEl) { | ||
focusEl.setAttribute('aria-owns', containerEl.id); | ||
} // ensure each item has an id | ||
_this.items.forEach(function (itemEl) { | ||
// ensure each item has an id | ||
this.items.forEach(function (itemEl) { | ||
(0, _makeupNextId.default)(itemEl); | ||
}); | ||
if (_this._options.autoInit > -1) { | ||
var itemEl = _this.filteredItems[_this._options.autoInit]; | ||
itemEl.classList.add(_this._options.activeDescendantClassName); | ||
_this._focusEl.setAttribute('aria-activedescendant', itemEl.id); | ||
} | ||
return _this; | ||
} | ||
get index() { | ||
return this._navigationEmitter.model.index; | ||
} | ||
set index(newIndex) { | ||
this._navigationEmitter.model.index = newIndex; | ||
} | ||
reset() { | ||
this._navigationEmitter.model.reset(); | ||
} | ||
get currentItem() { | ||
return this._navigationEmitter.model.currentItem; | ||
} | ||
get items() { | ||
return this._navigationEmitter.model.items; | ||
} | ||
set wrap(newWrap) { | ||
this._navigationEmitter.model.options.wrap = newWrap; | ||
} | ||
destroy() { | ||
super.destroy(); | ||
this._navigationEmitter.destroy(); | ||
} | ||
} | ||
_createClass(LinearActiveDescendant, [{ | ||
key: "index", | ||
get: function get() { | ||
return this._navigationEmitter.model.index; | ||
}, | ||
set: function set(newIndex) { | ||
this._navigationEmitter.model.index = newIndex; | ||
} | ||
}, { | ||
key: "reset", | ||
value: function reset() { | ||
this._navigationEmitter.model.reset(); | ||
} | ||
}, { | ||
key: "filteredItems", | ||
get: function get() { | ||
return this._navigationEmitter.model.filteredItems; | ||
} | ||
}, { | ||
key: "items", | ||
get: function get() { | ||
return this._navigationEmitter.model.items; | ||
} // backwards compat | ||
}, { | ||
key: "_items", | ||
get: function get() { | ||
return this.items; | ||
} | ||
}, { | ||
key: "wrap", | ||
set: function set(newWrap) { | ||
this._navigationEmitter.model.options.wrap = newWrap; | ||
} | ||
}, { | ||
key: "destroy", | ||
value: function destroy() { | ||
_get(_getPrototypeOf(LinearActiveDescendant.prototype), "destroy", this).call(this); | ||
this._navigationEmitter.destroy(); | ||
} | ||
}]); | ||
return LinearActiveDescendant; | ||
}(ActiveDescendant); | ||
/* | ||
@@ -239,5 +172,4 @@ class GridActiveDescendant extends ActiveDescendant { | ||
function createLinear(el, focusEl, containerEl, itemSelector, selectedOptions) { | ||
return new LinearActiveDescendant(el, focusEl, containerEl, itemSelector, selectedOptions); | ||
function createLinear(el, focusEl, itemContainerEl, itemSelector, selectedOptions) { | ||
return new LinearActiveDescendant(el, focusEl, itemContainerEl, itemSelector, selectedOptions); | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
import * as NavigationEmitter from "makeup-navigation-emitter"; | ||
@@ -6,23 +5,21 @@ import nextID from "makeup-next-id"; | ||
activeDescendantClassName: "active-descendant", | ||
autoInit: -1, | ||
autoReset: -1, | ||
autoInit: "none", | ||
autoReset: "none", | ||
autoScroll: false, | ||
axis: "both", | ||
ignoreButtons: false | ||
wrap: false | ||
}; | ||
function onModelMutation() { | ||
const options = this._options; | ||
const modelIndex = this._navigationEmitter.model.index; | ||
this.filteredItems.forEach(function(item, index) { | ||
nextID(item); | ||
if (index !== modelIndex) { | ||
item.classList.remove(options.activeDescendantClassName); | ||
} else { | ||
item.classList.add(options.activeDescendantClassName); | ||
} | ||
}); | ||
function onModelInit(e) { | ||
const { items, toIndex } = e.detail; | ||
const itemEl = items[toIndex]; | ||
if (itemEl) { | ||
itemEl.classList.add(this._options.activeDescendantClassName); | ||
this._focusEl.setAttribute("aria-activedescendant", itemEl.id); | ||
} | ||
this._el.dispatchEvent(new CustomEvent("activeDescendantInit", { detail: e.detail })); | ||
} | ||
function onModelChange(e) { | ||
const fromItem = this.filteredItems[e.detail.fromIndex]; | ||
const toItem = this.filteredItems[e.detail.toIndex]; | ||
const { fromIndex, toIndex } = e.detail; | ||
const fromItem = this.items[fromIndex]; | ||
const toItem = this.items[toIndex]; | ||
if (fromItem) { | ||
@@ -38,8 +35,3 @@ fromItem.classList.remove(this._options.activeDescendantClassName); | ||
} | ||
this._el.dispatchEvent(new CustomEvent("activeDescendantChange", { | ||
detail: { | ||
fromIndex: e.detail.fromIndex, | ||
toIndex: e.detail.toIndex | ||
} | ||
})); | ||
this._el.dispatchEvent(new CustomEvent("activeDescendantChange", { detail: e.detail })); | ||
} | ||
@@ -49,7 +41,7 @@ function onModelReset(e) { | ||
const activeClassName = this._options.activeDescendantClassName; | ||
this.filteredItems.forEach(function(el) { | ||
this.items.forEach(function(el) { | ||
el.classList.remove(activeClassName); | ||
}); | ||
if (toIndex > -1) { | ||
const itemEl = this.filteredItems[toIndex]; | ||
if (toIndex !== null && toIndex !== -1) { | ||
const itemEl = this.items[toIndex]; | ||
itemEl.classList.add(activeClassName); | ||
@@ -60,3 +52,17 @@ this._focusEl.setAttribute("aria-activedescendant", itemEl.id); | ||
} | ||
this._el.dispatchEvent(new CustomEvent("activeDescendantReset", { detail: e.detail })); | ||
} | ||
function onModelMutation(e) { | ||
const { toIndex } = e.detail; | ||
const activeDescendantClassName = this.options.activeDescendantClassName; | ||
this.items.forEach(function(item, index) { | ||
nextID(item); | ||
if (index !== toIndex) { | ||
item.classList.remove(activeDescendantClassName); | ||
} else { | ||
item.classList.add(activeDescendantClassName); | ||
} | ||
}); | ||
this._el.dispatchEvent(new CustomEvent("activeDescendantMutation", { detail: e.detail })); | ||
} | ||
class ActiveDescendant { | ||
@@ -68,5 +74,7 @@ constructor(el) { | ||
this._onResetListener = onModelReset.bind(this); | ||
this._onInitListener = onModelInit.bind(this); | ||
this._el.addEventListener("navigationModelMutation", this._onMutationListener); | ||
this._el.addEventListener("navigationModelChange", this._onChangeListener); | ||
this._el.addEventListener("navigationModelReset", this._onResetListener); | ||
this._el.addEventListener("navigationModelInit", this._onInitListener); | ||
} | ||
@@ -77,8 +85,16 @@ destroy() { | ||
this._el.removeEventListener("navigationModelReset", this._onResetListener); | ||
this._el.removeEventListener("navigationModelInit", this._onInitListener); | ||
} | ||
} | ||
class LinearActiveDescendant extends ActiveDescendant { | ||
constructor(el, focusEl, containerEl, itemSelector, selectedOptions) { | ||
constructor(el, focusEl, itemContainerEl, itemSelector, selectedOptions) { | ||
super(el); | ||
this._options = Object.assign({}, defaultOptions, selectedOptions); | ||
this._focusEl = focusEl; | ||
this._itemContainerEl = itemContainerEl; | ||
this._itemSelector = itemSelector; | ||
nextID(this._itemContainerEl); | ||
if (this._itemContainerEl !== this._focusEl) { | ||
focusEl.setAttribute("aria-owns", this._itemContainerEl.id); | ||
} | ||
this._navigationEmitter = NavigationEmitter.createLinear(el, itemSelector, { | ||
@@ -88,19 +104,8 @@ autoInit: this._options.autoInit, | ||
axis: this._options.axis, | ||
ignoreButtons: this._options.ignoreButtons | ||
ignoreByDelegateSelector: this._options.ignoreByDelegateSelector, | ||
wrap: this._options.wrap | ||
}); | ||
this._focusEl = focusEl; | ||
this._containerEl = containerEl; | ||
this._itemSelector = itemSelector; | ||
nextID(containerEl); | ||
if (containerEl !== focusEl) { | ||
focusEl.setAttribute("aria-owns", containerEl.id); | ||
} | ||
this.items.forEach(function(itemEl) { | ||
nextID(itemEl); | ||
}); | ||
if (this._options.autoInit > -1) { | ||
const itemEl = this.filteredItems[this._options.autoInit]; | ||
itemEl.classList.add(this._options.activeDescendantClassName); | ||
this._focusEl.setAttribute("aria-activedescendant", itemEl.id); | ||
} | ||
} | ||
@@ -116,4 +121,4 @@ get index() { | ||
} | ||
get filteredItems() { | ||
return this._navigationEmitter.model.filteredItems; | ||
get currentItem() { | ||
return this._navigationEmitter.model.currentItem; | ||
} | ||
@@ -123,5 +128,2 @@ get items() { | ||
} | ||
get _items() { | ||
return this.items; | ||
} | ||
set wrap(newWrap) { | ||
@@ -135,8 +137,7 @@ this._navigationEmitter.model.options.wrap = newWrap; | ||
} | ||
function createLinear(el, focusEl, containerEl, itemSelector, selectedOptions) { | ||
return new LinearActiveDescendant(el, focusEl, containerEl, itemSelector, selectedOptions); | ||
function createLinear(el, focusEl, itemContainerEl, itemSelector, selectedOptions) { | ||
return new LinearActiveDescendant(el, focusEl, itemContainerEl, itemSelector, selectedOptions); | ||
} | ||
"use strict"; | ||
export { | ||
createLinear | ||
}; |
{ | ||
"name": "makeup-active-descendant", | ||
"description": "Implements ARIA active descendant keyboard navigation", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"main": "./dist/cjs/index.js", | ||
@@ -29,3 +29,3 @@ "module": "./dist/mjs/index.js", | ||
"dependencies": { | ||
"makeup-navigation-emitter": "~0.5.1", | ||
"makeup-navigation-emitter": "~0.6.0", | ||
"makeup-next-id": "~0.4.0" | ||
@@ -32,0 +32,0 @@ }, |
@@ -54,5 +54,5 @@ # makeup-active-descendant | ||
<ul id="widget-0-list-0"> | ||
<li id="widget-0-item-0" data-makeup-index="0">Item 1</li> | ||
<li id="widget-0-item-1" data-makeup-index="1">Item 2</li> | ||
<li id="widget-0-item-2" data-makeup-index="2">Item 3</li> | ||
<li id="widget-0-item-0">Item 1</li> | ||
<li id="widget-0-item-1">Item 2</li> | ||
<li id="widget-0-item-2">Item 3</li> | ||
</ul> | ||
@@ -68,5 +68,5 @@ </div> | ||
<ul id="widget-0-list-0"> | ||
<li class="active-descendant" id="widget-0-item-0" data-makeup-index="0">Item 1</li> | ||
<li id="widget-0-item-1" data-makeup-index="1">Item 2</li> | ||
<li id="widget-0-item-2" data-makeup-index="2">Item 3</li> | ||
<li class="active-descendant" id="widget-0-item-0">Item 1</li> | ||
<li id="widget-0-item-1">Item 2</li> | ||
<li id="widget-0-item-2">Item 3</li> | ||
</ul> | ||
@@ -128,5 +128,5 @@ </div> | ||
<ul id="widget-0-list-0" tabindex="0"> | ||
<li id="widget-0-item-0" data-makeup-index="0">Item 1</li> | ||
<li id="widget-0-item-1" data-makeup-index="1">Item 2</li> | ||
<li id="widget-0-item-2" data-makeup-index="2">Item 3</li> | ||
<li id="widget-0-item-0">Item 1</li> | ||
<li id="widget-0-item-1">Item 2</li> | ||
<li id="widget-0-item-2">Item 3</li> | ||
</ul> | ||
@@ -141,5 +141,5 @@ </div> | ||
<ul id="widget-0-list-0" aria-activedescendant="widget-0-item-0" tabindex="0"> | ||
<li class="active-descendant" id="widget-0-item-0" data-makeup-index="0">Item 1</li> | ||
<li id="widget-0-item-1" data-makeup-index="1">Item 2</li> | ||
<li id="widget-0-item-2" data-makeup-index="2">Item 3</li> | ||
<li class="active-descendant" id="widget-0-item-0">Item 1</li> | ||
<li id="widget-0-item-1">Item 2</li> | ||
<li id="widget-0-item-2">Item 3</li> | ||
</ul> | ||
@@ -160,10 +160,27 @@ </div> | ||
* `activeDescendantClassName`: the HTML class name that will be applied to the ARIA active descendant element (default: 'active-descendant') | ||
* `autoInit`: specify an integer or -1 for initial index (default: 0) (see [`makeup-navigation-emitter`](https://github.com/makeup-js/makeup-navigation-emitter#options)) | ||
* `autoReset`: specify an integer or -1 for index position when focus exits widget (default: null) (see [`makeup-navigation-emitter`](https://github.com/makeup-js/makeup-navigation-emitter#options)) | ||
* `autoInit`: declares the initial active descendant item (default: "none"). Possible values are: | ||
* "none": no index position is set (useful in programmatic active-descendant) | ||
* "interactive": first non aria-disabled or hidden element (default) | ||
* "ariaChecked": first element with aria-checked=true (useful in ARIA menu) | ||
* "ariaSelected": first element with aria-selected=true (useful in ARIA tabs) | ||
* "ariaSelectedOrInteractive": first element with aria-selected=true, falling back to "interactive" if not found (useful in ARIA listbox) | ||
* *number*: specific index position of items (throws error if non-interactive) | ||
* `autoReset`: declares the active descendant item after a reset and/or when keyboard focus exits the widget (default: "none"). Possible values are: | ||
* "none": no index position is set (useful in programmatic active-descendant) | ||
* "current": index remains current (radio button like behaviour) | ||
* "interactive": index moves to first non aria-disabled or hidden element | ||
* "ariaChecked": index moves to first element with aria-checked=true | ||
* "ariaSelected": index moves to first element with aria-selected=true | ||
* *number*: specific index position of items (throws error if non-interactive) | ||
* `autoScroll` : Specify true to scroll the container as activeDescendant changes (default: false) | ||
* `axis` : specify 'x' for left/right arrow keys, 'y' for up/down arrow keys, or 'both' (default: 'both') | ||
* `ignoreButtons`: if set to true, nested button elements will not trigger navigationModelChange events. This is useful in a combobox + button scenario, where only the textbox should trigger navigationModelChange events (default: false) | ||
* `ignoreByDelegateSelector`: CSS selector of descendant elements that will be ignored by the navigation emitters key event delegation (i.e. these elements will *not* operate the active descendant) (default: null) | ||
## Custom Events | ||
* `activeDescendantInit` | ||
* detail | ||
* items | ||
* fromIndex | ||
* toIndex | ||
* `activeDescendantChange` | ||
@@ -173,8 +190,13 @@ * detail | ||
* toIndex | ||
* `activeDescendantReset` | ||
* detail | ||
* fromIndex | ||
* toIndex | ||
## Properties | ||
* `filteredItems`: returns filtered items (e.g. non-hidden items) | ||
* `index`: the index position of the current active descendant | ||
* `items`: returns all items that match item selector | ||
* `navigableItems`: returns navigable subset of matchingItems (e.g. non-hidden & non-disabled items) | ||
* `index`: the index position of the current active descendant. A no-op on aria-disabled or hidden items. | ||
* `matchingItems`: returns all items that match item selector | ||
* `nonEmittingElementSelector`: CSS selector of nested elements that will *not* operate the navigation emitter. This is useful in a combobox + button scenario, where the nested button should not trigger navigationModelChange events (default: null) | ||
@@ -181,0 +203,0 @@ ## Methods |
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
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
24090
7
378
206
1
+ Addedmakeup-navigation-emitter@0.6.2(transitive)
- Removedmakeup-navigation-emitter@0.5.1(transitive)