Socket
Socket
Sign inDemoInstall

@material/list

Package Overview
Dependencies
Maintainers
13
Versions
1698
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@material/list - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

4

adapter.d.ts

@@ -31,2 +31,6 @@ /**

export interface MDCListAdapter {
/**
* Returns the attribute value of list item at given `index`.
*/
getAttributeForElementIndex(index: number, attr: string): string | null;
getListItemCount(): number;

@@ -33,0 +37,0 @@ getFocusedElementIndex(): number;

@@ -146,2 +146,3 @@ /**

},
getAttributeForElementIndex: function (index, attr) { return _this.listElements[index].getAttribute(attr); },
getFocusedElementIndex: function () { return _this.listElements.indexOf(document.activeElement); },

@@ -148,0 +149,0 @@ getListItemCount: function () { return _this.listElements.length; },

@@ -34,2 +34,3 @@ /**

ARIA_CHECKED_RADIO_SELECTOR: string;
ARIA_CURRENT: string;
ARIA_ORIENTATION: string;

@@ -46,2 +47,5 @@ ARIA_ORIENTATION_HORIZONTAL: string;

};
export { strings, cssClasses };
declare const numbers: {
UNSET_INDEX: number;
};
export { strings, cssClasses, numbers };

@@ -34,2 +34,3 @@ /**

ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
ARIA_CURRENT: 'aria-current',
ARIA_ORIENTATION: 'aria-orientation',

@@ -46,3 +47,6 @@ ARIA_ORIENTATION_HORIZONTAL: 'horizontal',

};
export { strings, cssClasses };
var numbers = {
UNSET_INDEX: -1,
};
export { strings, cssClasses, numbers };
//# sourceMappingURL=constants.js.map

@@ -44,2 +44,6 @@ // Generated by dts-bundle v0.7.3

export interface MDCListAdapter {
/**
* Returns the attribute value of list item at given `index`.
*/
getAttributeForElementIndex(index: number, attr: string): string | null;
getListItemCount(): number;

@@ -163,2 +167,3 @@ getFocusedElementIndex(): number;

ARIA_CHECKED_RADIO_SELECTOR: string;
ARIA_CURRENT: string;
ARIA_ORIENTATION: string;

@@ -181,2 +186,5 @@ ARIA_ORIENTATION_HORIZONTAL: string;

};
static readonly numbers: {
UNSET_INDEX: number;
};
static readonly defaultAdapter: MDCListAdapter;

@@ -183,0 +191,0 @@ constructor(adapter?: Partial<MDCListAdapter>);

@@ -380,5 +380,6 @@ /*!

_this.isSingleSelectionList_ = false;
_this.selectedIndex_ = -1;
_this.focusedItemIndex_ = -1;
_this.selectedIndex_ = constants_1.numbers.UNSET_INDEX;
_this.focusedItemIndex_ = constants_1.numbers.UNSET_INDEX;
_this.useActivatedClass_ = false;
_this.ariaCurrentAttrValue_ = null;
_this.isCheckboxList_ = false;

@@ -402,2 +403,9 @@ _this.isRadioList_ = false;

});
Object.defineProperty(MDCListFoundation, "numbers", {
get: function get() {
return constants_1.numbers;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCListFoundation, "defaultAdapter", {

@@ -412,2 +420,5 @@ get: function get() {

},
getAttributeForElementIndex: function getAttributeForElementIndex() {
return null;
},
getFocusedElementIndex: function getFocusedElementIndex() {

@@ -539,4 +550,4 @@ return 0;

var currentIndex = this.adapter_.getFocusedElementIndex();
var nextIndex = -1;
if (currentIndex === -1) {
var nextIndex = constants_1.numbers.UNSET_INDEX;
if (currentIndex === constants_1.numbers.UNSET_INDEX) {
currentIndex = listItemIndex;

@@ -585,3 +596,3 @@ if (currentIndex < 0) {

MDCListFoundation.prototype.handleClick = function (index, toggleCheckbox) {
if (index === -1) {
if (index === constants_1.numbers.UNSET_INDEX) {
return;

@@ -650,2 +661,5 @@ }

MDCListFoundation.prototype.setSingleSelectionAtIndex_ = function (index) {
if (this.selectedIndex_ === index) {
return;
}
var selectedClassName = constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS;

@@ -655,11 +669,26 @@ if (this.useActivatedClass_) {

}
if (this.selectedIndex_ >= 0 && this.selectedIndex_ !== index) {
if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
this.adapter_.removeClassForElementIndex(this.selectedIndex_, selectedClassName);
this.adapter_.setAttributeForElementIndex(this.selectedIndex_, constants_1.strings.ARIA_SELECTED, 'false');
}
this.adapter_.addClassForElementIndex(index, selectedClassName);
this.adapter_.setAttributeForElementIndex(index, constants_1.strings.ARIA_SELECTED, 'true');
this.setAriaForSingleSelectionAtIndex_(index);
this.selectedIndex_ = index;
};
/**
* Sets aria attribute for single selection at given index.
*/
MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex_ = function (index) {
// Detect the presence of aria-current and get the value only during list initialization when it is in unset state.
if (this.selectedIndex_ === constants_1.numbers.UNSET_INDEX) {
this.ariaCurrentAttrValue_ = this.adapter_.getAttributeForElementIndex(index, constants_1.strings.ARIA_CURRENT);
}
var isAriaCurrent = this.ariaCurrentAttrValue_ !== null;
var ariaAttribute = isAriaCurrent ? constants_1.strings.ARIA_CURRENT : constants_1.strings.ARIA_SELECTED;
if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
this.adapter_.setAttributeForElementIndex(this.selectedIndex_, ariaAttribute, 'false');
}
var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue_ : 'true';
this.adapter_.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
};
/**
* Toggles radio at give index. Radio doesn't change the checked state if it is already checked.

@@ -669,3 +698,3 @@ */

this.adapter_.setCheckedCheckboxOrRadioAtIndex(index, true);
if (this.selectedIndex_ >= 0) {
if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
this.adapter_.setAttributeForElementIndex(this.selectedIndex_, constants_1.strings.ARIA_CHECKED, 'false');

@@ -688,3 +717,3 @@ }

MDCListFoundation.prototype.setTabindexAtIndex_ = function (index) {
if (this.focusedItemIndex_ === -1 && index !== 0) {
if (this.focusedItemIndex_ === constants_1.numbers.UNSET_INDEX && index !== 0) {
// If no list item was selected set first list item's tabindex to -1.

@@ -707,3 +736,3 @@ // Generally, tabindex is set to 0 on first list item of list that has no preselected items.

if (this.isSelectableList_()) {
if (typeof this.selectedIndex_ === 'number' && this.selectedIndex_ !== -1) {
if (typeof this.selectedIndex_ === 'number' && this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
targetIndex = this.selectedIndex_;

@@ -762,3 +791,3 @@ } else if (isNumberArray(this.selectedIndex_) && this.selectedIndex_.length > 0) {

// If none of the checkbox items are selected and selectedIndex is not initialized then provide a default value.
var selectedIndexes = this.selectedIndex_ === -1 ? [] : this.selectedIndex_.slice();
var selectedIndexes = this.selectedIndex_ === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex_.slice();
if (isChecked) {

@@ -822,2 +851,3 @@ selectedIndexes.push(index);

ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
ARIA_CURRENT: 'aria-current',
ARIA_ORIENTATION: 'aria-orientation',

@@ -835,2 +865,6 @@ ARIA_ORIENTATION_HORIZONTAL: 'horizontal',

exports.strings = strings;
var numbers = {
UNSET_INDEX: -1
};
exports.numbers = numbers;

@@ -1008,2 +1042,5 @@ /***/ }),

},
getAttributeForElementIndex: function getAttributeForElementIndex(index, attr) {
return _this.listElements[index].getAttribute(attr);
},
getFocusedElementIndex: function getFocusedElementIndex() {

@@ -1010,0 +1047,0 @@ return _this.listElements.indexOf(document.activeElement);

6

dist/mdc.list.min.js

@@ -72,3 +72,3 @@ /*!

*/
var s=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},o.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),c=n(15),a=["input","button","textarea","select"],u=function(t){function e(n){var i=t.call(this,o({},e.defaultAdapter,n))||this;return i.wrapFocus_=!1,i.isVertical_=!0,i.isSingleSelectionList_=!1,i.selectedIndex_=-1,i.focusedItemIndex_=-1,i.useActivatedClass_=!1,i.isCheckboxList_=!1,i.isRadioList_=!1,i}return s(e,t),Object.defineProperty(e,"strings",{get:function(){return c.strings},enumerable:!0,configurable:!0}),Object.defineProperty(e,"cssClasses",{get:function(){return c.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClassForElementIndex:function(){},focusItemAtIndex:function(){},getFocusedElementIndex:function(){return 0},getListItemCount:function(){return 0},hasCheckboxAtIndex:function(){return!1},hasRadioAtIndex:function(){return!1},isCheckboxCheckedAtIndex:function(){return!1},isFocusInsideList:function(){return!1},notifyAction:function(){},removeClassForElementIndex:function(){},setAttributeForElementIndex:function(){},setCheckedCheckboxOrRadioAtIndex:function(){},setTabIndexForListItemChildren:function(){}}},enumerable:!0,configurable:!0}),e.prototype.layout=function(){0!==this.adapter_.getListItemCount()&&(this.adapter_.hasCheckboxAtIndex(0)?this.isCheckboxList_=!0:this.adapter_.hasRadioAtIndex(0)&&(this.isRadioList_=!0))},e.prototype.setWrapFocus=function(t){this.wrapFocus_=t},e.prototype.setVerticalOrientation=function(t){this.isVertical_=t},e.prototype.setSingleSelection=function(t){this.isSingleSelectionList_=t},e.prototype.setUseActivatedClass=function(t){this.useActivatedClass_=t},e.prototype.getSelectedIndex=function(){return this.selectedIndex_},e.prototype.setSelectedIndex=function(t){this.isIndexValid_(t)&&(this.isCheckboxList_?this.setCheckboxAtIndex_(t):this.isRadioList_?this.setRadioAtIndex_(t):this.setSingleSelectionAtIndex_(t))},e.prototype.handleFocusIn=function(t,e){e>=0&&this.adapter_.setTabIndexForListItemChildren(e,"0")},e.prototype.handleFocusOut=function(t,e){var n=this;e>=0&&this.adapter_.setTabIndexForListItemChildren(e,"-1"),setTimeout(function(){n.adapter_.isFocusInsideList()||n.setTabindexToFirstSelectedItem_()},0)},e.prototype.handleKeydown=function(t,e,n){var i="ArrowLeft"===t.key||37===t.keyCode,s="ArrowUp"===t.key||38===t.keyCode,o="ArrowRight"===t.key||39===t.keyCode,r="ArrowDown"===t.key||40===t.keyCode,c="Home"===t.key||36===t.keyCode,a="End"===t.key||35===t.keyCode,u="Enter"===t.key||13===t.keyCode,d="Space"===t.key||32===t.keyCode,l=this.adapter_.getFocusedElementIndex(),f=-1;if(!(-1===l&&(l=n)<0)){if(this.isVertical_&&r||!this.isVertical_&&o)this.preventDefaultEvent_(t),f=this.focusNextElement(l);else if(this.isVertical_&&s||!this.isVertical_&&i)this.preventDefaultEvent_(t),f=this.focusPrevElement(l);else if(c)this.preventDefaultEvent_(t),f=this.focusFirstElement();else if(a)this.preventDefaultEvent_(t),f=this.focusLastElement();else if((u||d)&&e){var _=t.target;if(_&&"A"===_.tagName&&u)return;this.preventDefaultEvent_(t),this.isSelectableList_()&&this.setSelectedIndexOnAction_(l),this.adapter_.notifyAction(l)}this.focusedItemIndex_=l,f>=0&&(this.setTabindexAtIndex_(f),this.focusedItemIndex_=f)}},e.prototype.handleClick=function(t,e){-1!==t&&(this.isSelectableList_()&&this.setSelectedIndexOnAction_(t,e),this.adapter_.notifyAction(t),this.setTabindexAtIndex_(t),this.focusedItemIndex_=t)},e.prototype.focusNextElement=function(t){var e=this.adapter_.getListItemCount(),n=t+1;if(n>=e){if(!this.wrapFocus_)return t;n=0}return this.adapter_.focusItemAtIndex(n),n},e.prototype.focusPrevElement=function(t){var e=t-1;if(e<0){if(!this.wrapFocus_)return t;e=this.adapter_.getListItemCount()-1}return this.adapter_.focusItemAtIndex(e),e},e.prototype.focusFirstElement=function(){return this.adapter_.focusItemAtIndex(0),0},e.prototype.focusLastElement=function(){var t=this.adapter_.getListItemCount()-1;return this.adapter_.focusItemAtIndex(t),t},e.prototype.preventDefaultEvent_=function(t){var e=t.target,n=(""+e.tagName).toLowerCase();-1===a.indexOf(n)&&t.preventDefault()},e.prototype.setSingleSelectionAtIndex_=function(t){var e=c.cssClasses.LIST_ITEM_SELECTED_CLASS;this.useActivatedClass_&&(e=c.cssClasses.LIST_ITEM_ACTIVATED_CLASS),this.selectedIndex_>=0&&this.selectedIndex_!==t&&(this.adapter_.removeClassForElementIndex(this.selectedIndex_,e),this.adapter_.setAttributeForElementIndex(this.selectedIndex_,c.strings.ARIA_SELECTED,"false")),this.adapter_.addClassForElementIndex(t,e),this.adapter_.setAttributeForElementIndex(t,c.strings.ARIA_SELECTED,"true"),this.selectedIndex_=t},e.prototype.setRadioAtIndex_=function(t){this.adapter_.setCheckedCheckboxOrRadioAtIndex(t,!0),this.selectedIndex_>=0&&this.adapter_.setAttributeForElementIndex(this.selectedIndex_,c.strings.ARIA_CHECKED,"false"),this.adapter_.setAttributeForElementIndex(t,c.strings.ARIA_CHECKED,"true"),this.selectedIndex_=t},e.prototype.setCheckboxAtIndex_=function(t){for(var e=0;e<this.adapter_.getListItemCount();e++){var n=!1;t.indexOf(e)>=0&&(n=!0),this.adapter_.setCheckedCheckboxOrRadioAtIndex(e,n),this.adapter_.setAttributeForElementIndex(e,c.strings.ARIA_CHECKED,n?"true":"false")}this.selectedIndex_=t},e.prototype.setTabindexAtIndex_=function(t){-1===this.focusedItemIndex_&&0!==t?this.adapter_.setAttributeForElementIndex(0,"tabindex","-1"):this.focusedItemIndex_>=0&&this.focusedItemIndex_!==t&&this.adapter_.setAttributeForElementIndex(this.focusedItemIndex_,"tabindex","-1"),this.adapter_.setAttributeForElementIndex(t,"tabindex","0")},e.prototype.isSelectableList_=function(){return this.isSingleSelectionList_||this.isCheckboxList_||this.isRadioList_},e.prototype.setTabindexToFirstSelectedItem_=function(){var t=0;this.isSelectableList_()&&("number"==typeof this.selectedIndex_&&-1!==this.selectedIndex_?t=this.selectedIndex_:i(this.selectedIndex_)&&this.selectedIndex_.length>0&&(t=this.selectedIndex_.reduce(function(t,e){return Math.min(t,e)}))),this.setTabindexAtIndex_(t)},e.prototype.isIndexValid_=function(t){var e=this;if(t instanceof Array){if(!this.isCheckboxList_)throw new Error("MDCListFoundation: Array of index is only supported for checkbox based list");return 0===t.length||t.some(function(t){return e.isIndexInRange_(t)})}if("number"==typeof t){if(this.isCheckboxList_)throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: "+t);return this.isIndexInRange_(t)}return!1},e.prototype.isIndexInRange_=function(t){var e=this.adapter_.getListItemCount();return t>=0&&t<e},e.prototype.setSelectedIndexOnAction_=function(t,e){void 0===e&&(e=!0),this.isCheckboxList_?this.toggleCheckboxAtIndex_(t,e):this.setSelectedIndex(t)},e.prototype.toggleCheckboxAtIndex_=function(t,e){var n=this.adapter_.isCheckboxCheckedAtIndex(t);e&&(n=!n,this.adapter_.setCheckedCheckboxOrRadioAtIndex(t,n)),this.adapter_.setAttributeForElementIndex(t,c.strings.ARIA_CHECKED,n?"true":"false");var i=-1===this.selectedIndex_?[]:this.selectedIndex_.slice();n?i.push(t):i=i.filter(function(e){return e!==t}),this.selectedIndex_=i},e}(r.MDCFoundation);e.MDCListFoundation=u,e.default=u},15:function(t,e,n){"use strict";/**
var s=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},o.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),u=n(15),c=["input","button","textarea","select"],a=function(t){function e(n){var i=t.call(this,o({},e.defaultAdapter,n))||this;return i.wrapFocus_=!1,i.isVertical_=!0,i.isSingleSelectionList_=!1,i.selectedIndex_=u.numbers.UNSET_INDEX,i.focusedItemIndex_=u.numbers.UNSET_INDEX,i.useActivatedClass_=!1,i.ariaCurrentAttrValue_=null,i.isCheckboxList_=!1,i.isRadioList_=!1,i}return s(e,t),Object.defineProperty(e,"strings",{get:function(){return u.strings},enumerable:!0,configurable:!0}),Object.defineProperty(e,"cssClasses",{get:function(){return u.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return u.numbers},enumerable:!0,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClassForElementIndex:function(){},focusItemAtIndex:function(){},getAttributeForElementIndex:function(){return null},getFocusedElementIndex:function(){return 0},getListItemCount:function(){return 0},hasCheckboxAtIndex:function(){return!1},hasRadioAtIndex:function(){return!1},isCheckboxCheckedAtIndex:function(){return!1},isFocusInsideList:function(){return!1},notifyAction:function(){},removeClassForElementIndex:function(){},setAttributeForElementIndex:function(){},setCheckedCheckboxOrRadioAtIndex:function(){},setTabIndexForListItemChildren:function(){}}},enumerable:!0,configurable:!0}),e.prototype.layout=function(){0!==this.adapter_.getListItemCount()&&(this.adapter_.hasCheckboxAtIndex(0)?this.isCheckboxList_=!0:this.adapter_.hasRadioAtIndex(0)&&(this.isRadioList_=!0))},e.prototype.setWrapFocus=function(t){this.wrapFocus_=t},e.prototype.setVerticalOrientation=function(t){this.isVertical_=t},e.prototype.setSingleSelection=function(t){this.isSingleSelectionList_=t},e.prototype.setUseActivatedClass=function(t){this.useActivatedClass_=t},e.prototype.getSelectedIndex=function(){return this.selectedIndex_},e.prototype.setSelectedIndex=function(t){this.isIndexValid_(t)&&(this.isCheckboxList_?this.setCheckboxAtIndex_(t):this.isRadioList_?this.setRadioAtIndex_(t):this.setSingleSelectionAtIndex_(t))},e.prototype.handleFocusIn=function(t,e){e>=0&&this.adapter_.setTabIndexForListItemChildren(e,"0")},e.prototype.handleFocusOut=function(t,e){var n=this;e>=0&&this.adapter_.setTabIndexForListItemChildren(e,"-1"),setTimeout(function(){n.adapter_.isFocusInsideList()||n.setTabindexToFirstSelectedItem_()},0)},e.prototype.handleKeydown=function(t,e,n){var i="ArrowLeft"===t.key||37===t.keyCode,s="ArrowUp"===t.key||38===t.keyCode,o="ArrowRight"===t.key||39===t.keyCode,r="ArrowDown"===t.key||40===t.keyCode,c="Home"===t.key||36===t.keyCode,a="End"===t.key||35===t.keyCode,d="Enter"===t.key||13===t.keyCode,l="Space"===t.key||32===t.keyCode,_=this.adapter_.getFocusedElementIndex(),f=u.numbers.UNSET_INDEX;if(!(_===u.numbers.UNSET_INDEX&&(_=n)<0)){if(this.isVertical_&&r||!this.isVertical_&&o)this.preventDefaultEvent_(t),f=this.focusNextElement(_);else if(this.isVertical_&&s||!this.isVertical_&&i)this.preventDefaultEvent_(t),f=this.focusPrevElement(_);else if(c)this.preventDefaultEvent_(t),f=this.focusFirstElement();else if(a)this.preventDefaultEvent_(t),f=this.focusLastElement();else if((d||l)&&e){var h=t.target;if(h&&"A"===h.tagName&&d)return;this.preventDefaultEvent_(t),this.isSelectableList_()&&this.setSelectedIndexOnAction_(_),this.adapter_.notifyAction(_)}this.focusedItemIndex_=_,f>=0&&(this.setTabindexAtIndex_(f),this.focusedItemIndex_=f)}},e.prototype.handleClick=function(t,e){t!==u.numbers.UNSET_INDEX&&(this.isSelectableList_()&&this.setSelectedIndexOnAction_(t,e),this.adapter_.notifyAction(t),this.setTabindexAtIndex_(t),this.focusedItemIndex_=t)},e.prototype.focusNextElement=function(t){var e=this.adapter_.getListItemCount(),n=t+1;if(n>=e){if(!this.wrapFocus_)return t;n=0}return this.adapter_.focusItemAtIndex(n),n},e.prototype.focusPrevElement=function(t){var e=t-1;if(e<0){if(!this.wrapFocus_)return t;e=this.adapter_.getListItemCount()-1}return this.adapter_.focusItemAtIndex(e),e},e.prototype.focusFirstElement=function(){return this.adapter_.focusItemAtIndex(0),0},e.prototype.focusLastElement=function(){var t=this.adapter_.getListItemCount()-1;return this.adapter_.focusItemAtIndex(t),t},e.prototype.preventDefaultEvent_=function(t){var e=t.target,n=(""+e.tagName).toLowerCase();-1===c.indexOf(n)&&t.preventDefault()},e.prototype.setSingleSelectionAtIndex_=function(t){if(this.selectedIndex_!==t){var e=u.cssClasses.LIST_ITEM_SELECTED_CLASS;this.useActivatedClass_&&(e=u.cssClasses.LIST_ITEM_ACTIVATED_CLASS),this.selectedIndex_!==u.numbers.UNSET_INDEX&&this.adapter_.removeClassForElementIndex(this.selectedIndex_,e),this.adapter_.addClassForElementIndex(t,e),this.setAriaForSingleSelectionAtIndex_(t),this.selectedIndex_=t}},e.prototype.setAriaForSingleSelectionAtIndex_=function(t){this.selectedIndex_===u.numbers.UNSET_INDEX&&(this.ariaCurrentAttrValue_=this.adapter_.getAttributeForElementIndex(t,u.strings.ARIA_CURRENT));var e=null!==this.ariaCurrentAttrValue_,n=e?u.strings.ARIA_CURRENT:u.strings.ARIA_SELECTED;this.selectedIndex_!==u.numbers.UNSET_INDEX&&this.adapter_.setAttributeForElementIndex(this.selectedIndex_,n,"false");var i=e?this.ariaCurrentAttrValue_:"true";this.adapter_.setAttributeForElementIndex(t,n,i)},e.prototype.setRadioAtIndex_=function(t){this.adapter_.setCheckedCheckboxOrRadioAtIndex(t,!0),this.selectedIndex_!==u.numbers.UNSET_INDEX&&this.adapter_.setAttributeForElementIndex(this.selectedIndex_,u.strings.ARIA_CHECKED,"false"),this.adapter_.setAttributeForElementIndex(t,u.strings.ARIA_CHECKED,"true"),this.selectedIndex_=t},e.prototype.setCheckboxAtIndex_=function(t){for(var e=0;e<this.adapter_.getListItemCount();e++){var n=!1;t.indexOf(e)>=0&&(n=!0),this.adapter_.setCheckedCheckboxOrRadioAtIndex(e,n),this.adapter_.setAttributeForElementIndex(e,u.strings.ARIA_CHECKED,n?"true":"false")}this.selectedIndex_=t},e.prototype.setTabindexAtIndex_=function(t){this.focusedItemIndex_===u.numbers.UNSET_INDEX&&0!==t?this.adapter_.setAttributeForElementIndex(0,"tabindex","-1"):this.focusedItemIndex_>=0&&this.focusedItemIndex_!==t&&this.adapter_.setAttributeForElementIndex(this.focusedItemIndex_,"tabindex","-1"),this.adapter_.setAttributeForElementIndex(t,"tabindex","0")},e.prototype.isSelectableList_=function(){return this.isSingleSelectionList_||this.isCheckboxList_||this.isRadioList_},e.prototype.setTabindexToFirstSelectedItem_=function(){var t=0;this.isSelectableList_()&&("number"==typeof this.selectedIndex_&&this.selectedIndex_!==u.numbers.UNSET_INDEX?t=this.selectedIndex_:i(this.selectedIndex_)&&this.selectedIndex_.length>0&&(t=this.selectedIndex_.reduce(function(t,e){return Math.min(t,e)}))),this.setTabindexAtIndex_(t)},e.prototype.isIndexValid_=function(t){var e=this;if(t instanceof Array){if(!this.isCheckboxList_)throw new Error("MDCListFoundation: Array of index is only supported for checkbox based list");return 0===t.length||t.some(function(t){return e.isIndexInRange_(t)})}if("number"==typeof t){if(this.isCheckboxList_)throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: "+t);return this.isIndexInRange_(t)}return!1},e.prototype.isIndexInRange_=function(t){var e=this.adapter_.getListItemCount();return t>=0&&t<e},e.prototype.setSelectedIndexOnAction_=function(t,e){void 0===e&&(e=!0),this.isCheckboxList_?this.toggleCheckboxAtIndex_(t,e):this.setSelectedIndex(t)},e.prototype.toggleCheckboxAtIndex_=function(t,e){var n=this.adapter_.isCheckboxCheckedAtIndex(t);e&&(n=!n,this.adapter_.setCheckedCheckboxOrRadioAtIndex(t,n)),this.adapter_.setAttributeForElementIndex(t,u.strings.ARIA_CHECKED,n?"true":"false");var i=this.selectedIndex_===u.numbers.UNSET_INDEX?[]:this.selectedIndex_.slice();n?i.push(t):i=i.filter(function(e){return e!==t}),this.selectedIndex_=i},e}(r.MDCFoundation);e.MDCListFoundation=a,e.default=a},15:function(t,e,n){"use strict";/**
* @license

@@ -95,3 +95,3 @@ * Copyright 2018 Google Inc.

*/
Object.defineProperty(e,"__esModule",{value:!0});var i={LIST_ITEM_ACTIVATED_CLASS:"mdc-list-item--activated",LIST_ITEM_CLASS:"mdc-list-item",LIST_ITEM_SELECTED_CLASS:"mdc-list-item--selected",ROOT:"mdc-list"};e.cssClasses=i;var s={ACTION_EVENT:"MDCList:action",ARIA_CHECKED:"aria-checked",ARIA_CHECKED_CHECKBOX_SELECTOR:'[role="checkbox"][aria-checked="true"]',ARIA_CHECKED_RADIO_SELECTOR:'[role="radio"][aria-checked="true"]',ARIA_ORIENTATION:"aria-orientation",ARIA_ORIENTATION_HORIZONTAL:"horizontal",ARIA_ROLE_CHECKBOX_SELECTOR:'[role="checkbox"]',ARIA_SELECTED:"aria-selected",CHECKBOX_RADIO_SELECTOR:'input[type="checkbox"]:not(:disabled), input[type="radio"]:not(:disabled)',CHECKBOX_SELECTOR:'input[type="checkbox"]:not(:disabled)',CHILD_ELEMENTS_TO_TOGGLE_TABINDEX:"\n ."+i.LIST_ITEM_CLASS+" button:not(:disabled),\n ."+i.LIST_ITEM_CLASS+" a\n ",ENABLED_ITEMS_SELECTOR:".mdc-list-item:not(.mdc-list-item--disabled)",FOCUSABLE_CHILD_ELEMENTS:"\n ."+i.LIST_ITEM_CLASS+" button:not(:disabled),\n ."+i.LIST_ITEM_CLASS+" a,\n ."+i.LIST_ITEM_CLASS+' input[type="radio"]:not(:disabled),\n .'+i.LIST_ITEM_CLASS+' input[type="checkbox"]:not(:disabled)\n ',RADIO_SELECTOR:'input[type="radio"]:not(:disabled)'};e.strings=s},22:function(t,e,n){"use strict";/**
Object.defineProperty(e,"__esModule",{value:!0});var i={LIST_ITEM_ACTIVATED_CLASS:"mdc-list-item--activated",LIST_ITEM_CLASS:"mdc-list-item",LIST_ITEM_SELECTED_CLASS:"mdc-list-item--selected",ROOT:"mdc-list"};e.cssClasses=i;var s={ACTION_EVENT:"MDCList:action",ARIA_CHECKED:"aria-checked",ARIA_CHECKED_CHECKBOX_SELECTOR:'[role="checkbox"][aria-checked="true"]',ARIA_CHECKED_RADIO_SELECTOR:'[role="radio"][aria-checked="true"]',ARIA_CURRENT:"aria-current",ARIA_ORIENTATION:"aria-orientation",ARIA_ORIENTATION_HORIZONTAL:"horizontal",ARIA_ROLE_CHECKBOX_SELECTOR:'[role="checkbox"]',ARIA_SELECTED:"aria-selected",CHECKBOX_RADIO_SELECTOR:'input[type="checkbox"]:not(:disabled), input[type="radio"]:not(:disabled)',CHECKBOX_SELECTOR:'input[type="checkbox"]:not(:disabled)',CHILD_ELEMENTS_TO_TOGGLE_TABINDEX:"\n ."+i.LIST_ITEM_CLASS+" button:not(:disabled),\n ."+i.LIST_ITEM_CLASS+" a\n ",ENABLED_ITEMS_SELECTOR:".mdc-list-item:not(.mdc-list-item--disabled)",FOCUSABLE_CHILD_ELEMENTS:"\n ."+i.LIST_ITEM_CLASS+" button:not(:disabled),\n ."+i.LIST_ITEM_CLASS+" a,\n ."+i.LIST_ITEM_CLASS+' input[type="radio"]:not(:disabled),\n .'+i.LIST_ITEM_CLASS+' input[type="checkbox"]:not(:disabled)\n ',RADIO_SELECTOR:'input[type="radio"]:not(:disabled)'};e.strings=s;var o={UNSET_INDEX:-1};e.numbers=o},22:function(t,e,n){"use strict";/**
* @license

@@ -118,3 +118,3 @@ * Copyright 2018 Google Inc.

*/
var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=n(1),o=n(3),r=n(15),c=n(11),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),Object.defineProperty(e.prototype,"vertical",{set:function(t){this.foundation_.setVerticalOrientation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"listElements",{get:function(){return[].slice.call(this.root_.querySelectorAll(r.strings.ENABLED_ITEMS_SELECTOR))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wrapFocus",{set:function(t){this.foundation_.setWrapFocus(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"singleSelection",{set:function(t){this.foundation_.setSingleSelection(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectedIndex",{get:function(){return this.foundation_.getSelectedIndex()},set:function(t){this.foundation_.setSelectedIndex(t)},enumerable:!0,configurable:!0}),e.attachTo=function(t){return new e(t)},e.prototype.initialSyncWithDOM=function(){this.handleClick_=this.handleClickEvent_.bind(this),this.handleKeydown_=this.handleKeydownEvent_.bind(this),this.focusInEventListener_=this.handleFocusInEvent_.bind(this),this.focusOutEventListener_=this.handleFocusOutEvent_.bind(this),this.listen("keydown",this.handleKeydown_),this.listen("click",this.handleClick_),this.listen("focusin",this.focusInEventListener_),this.listen("focusout",this.focusOutEventListener_),this.layout(),this.initializeListType()},e.prototype.destroy=function(){this.unlisten("keydown",this.handleKeydown_),this.unlisten("click",this.handleClick_),this.unlisten("focusin",this.focusInEventListener_),this.unlisten("focusout",this.focusOutEventListener_)},e.prototype.layout=function(){var t=this.root_.getAttribute(r.strings.ARIA_ORIENTATION);this.vertical=t!==r.strings.ARIA_ORIENTATION_HORIZONTAL,[].slice.call(this.root_.querySelectorAll(".mdc-list-item:not([tabindex])")).forEach(function(t){t.setAttribute("tabindex","-1")}),[].slice.call(this.root_.querySelectorAll(r.strings.FOCUSABLE_CHILD_ELEMENTS)).forEach(function(t){return t.setAttribute("tabindex","-1")}),this.foundation_.layout()},e.prototype.initializeListType=function(){var t=this,e=this.root_.querySelectorAll(r.strings.ARIA_ROLE_CHECKBOX_SELECTOR),n=this.root_.querySelector("\n ."+r.cssClasses.LIST_ITEM_ACTIVATED_CLASS+",\n ."+r.cssClasses.LIST_ITEM_SELECTED_CLASS+"\n "),i=this.root_.querySelector(r.strings.ARIA_CHECKED_RADIO_SELECTOR);if(e.length){var s=this.root_.querySelectorAll(r.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);this.selectedIndex=[].map.call(s,function(e){return t.listElements.indexOf(e)})}else n?(n.classList.contains(r.cssClasses.LIST_ITEM_ACTIVATED_CLASS)&&this.foundation_.setUseActivatedClass(!0),this.singleSelection=!0,this.selectedIndex=this.listElements.indexOf(n)):i&&(this.selectedIndex=this.listElements.indexOf(i))},e.prototype.getDefaultFoundation=function(){var t=this,e={addClassForElementIndex:function(e,n){var i=t.listElements[e];i&&i.classList.add(n)},focusItemAtIndex:function(e){var n=t.listElements[e];n&&n.focus()},getFocusedElementIndex:function(){return t.listElements.indexOf(document.activeElement)},getListItemCount:function(){return t.listElements.length},hasCheckboxAtIndex:function(e){return!!t.listElements[e].querySelector(r.strings.CHECKBOX_SELECTOR)},hasRadioAtIndex:function(e){return!!t.listElements[e].querySelector(r.strings.RADIO_SELECTOR)},isCheckboxCheckedAtIndex:function(e){return t.listElements[e].querySelector(r.strings.CHECKBOX_SELECTOR).checked},isFocusInsideList:function(){return t.root_.contains(document.activeElement)},notifyAction:function(e){t.emit(r.strings.ACTION_EVENT,{index:e},!0)},removeClassForElementIndex:function(e,n){var i=t.listElements[e];i&&i.classList.remove(n)},setAttributeForElementIndex:function(e,n,i){var s=t.listElements[e];s&&s.setAttribute(n,i)},setCheckedCheckboxOrRadioAtIndex:function(e,n){var i=t.listElements[e],s=i.querySelector(r.strings.CHECKBOX_RADIO_SELECTOR);s.checked=n;var o=document.createEvent("Event");o.initEvent("change",!0,!0),s.dispatchEvent(o)},setTabIndexForListItemChildren:function(e,n){var i=t.listElements[e];[].slice.call(i.querySelectorAll(r.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX)).forEach(function(t){return t.setAttribute("tabindex",n)})}};return new c.MDCListFoundation(e)},e.prototype.getListItemIndex_=function(t){var e=t.target,n=o.ponyfill.closest(e,"."+r.cssClasses.LIST_ITEM_CLASS+", ."+r.cssClasses.ROOT);return n&&o.ponyfill.matches(n,"."+r.cssClasses.LIST_ITEM_CLASS)?this.listElements.indexOf(n):-1},e.prototype.handleFocusInEvent_=function(t){var e=this.getListItemIndex_(t);this.foundation_.handleFocusIn(t,e)},e.prototype.handleFocusOutEvent_=function(t){var e=this.getListItemIndex_(t);this.foundation_.handleFocusOut(t,e)},e.prototype.handleKeydownEvent_=function(t){var e=this.getListItemIndex_(t),n=t.target;e>=0&&this.foundation_.handleKeydown(t,n.classList.contains(r.cssClasses.LIST_ITEM_CLASS),e)},e.prototype.handleClickEvent_=function(t){var e=this.getListItemIndex_(t),n=t.target,i=!o.ponyfill.matches(n,r.strings.CHECKBOX_RADIO_SELECTOR);this.foundation_.handleClick(e,i)},e}(s.MDCComponent);e.MDCList=a},28:function(t,e,n){"use strict";/**
var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=n(1),o=n(3),r=n(15),u=n(11),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),Object.defineProperty(e.prototype,"vertical",{set:function(t){this.foundation_.setVerticalOrientation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"listElements",{get:function(){return[].slice.call(this.root_.querySelectorAll(r.strings.ENABLED_ITEMS_SELECTOR))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wrapFocus",{set:function(t){this.foundation_.setWrapFocus(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"singleSelection",{set:function(t){this.foundation_.setSingleSelection(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectedIndex",{get:function(){return this.foundation_.getSelectedIndex()},set:function(t){this.foundation_.setSelectedIndex(t)},enumerable:!0,configurable:!0}),e.attachTo=function(t){return new e(t)},e.prototype.initialSyncWithDOM=function(){this.handleClick_=this.handleClickEvent_.bind(this),this.handleKeydown_=this.handleKeydownEvent_.bind(this),this.focusInEventListener_=this.handleFocusInEvent_.bind(this),this.focusOutEventListener_=this.handleFocusOutEvent_.bind(this),this.listen("keydown",this.handleKeydown_),this.listen("click",this.handleClick_),this.listen("focusin",this.focusInEventListener_),this.listen("focusout",this.focusOutEventListener_),this.layout(),this.initializeListType()},e.prototype.destroy=function(){this.unlisten("keydown",this.handleKeydown_),this.unlisten("click",this.handleClick_),this.unlisten("focusin",this.focusInEventListener_),this.unlisten("focusout",this.focusOutEventListener_)},e.prototype.layout=function(){var t=this.root_.getAttribute(r.strings.ARIA_ORIENTATION);this.vertical=t!==r.strings.ARIA_ORIENTATION_HORIZONTAL,[].slice.call(this.root_.querySelectorAll(".mdc-list-item:not([tabindex])")).forEach(function(t){t.setAttribute("tabindex","-1")}),[].slice.call(this.root_.querySelectorAll(r.strings.FOCUSABLE_CHILD_ELEMENTS)).forEach(function(t){return t.setAttribute("tabindex","-1")}),this.foundation_.layout()},e.prototype.initializeListType=function(){var t=this,e=this.root_.querySelectorAll(r.strings.ARIA_ROLE_CHECKBOX_SELECTOR),n=this.root_.querySelector("\n ."+r.cssClasses.LIST_ITEM_ACTIVATED_CLASS+",\n ."+r.cssClasses.LIST_ITEM_SELECTED_CLASS+"\n "),i=this.root_.querySelector(r.strings.ARIA_CHECKED_RADIO_SELECTOR);if(e.length){var s=this.root_.querySelectorAll(r.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);this.selectedIndex=[].map.call(s,function(e){return t.listElements.indexOf(e)})}else n?(n.classList.contains(r.cssClasses.LIST_ITEM_ACTIVATED_CLASS)&&this.foundation_.setUseActivatedClass(!0),this.singleSelection=!0,this.selectedIndex=this.listElements.indexOf(n)):i&&(this.selectedIndex=this.listElements.indexOf(i))},e.prototype.getDefaultFoundation=function(){var t=this,e={addClassForElementIndex:function(e,n){var i=t.listElements[e];i&&i.classList.add(n)},focusItemAtIndex:function(e){var n=t.listElements[e];n&&n.focus()},getAttributeForElementIndex:function(e,n){return t.listElements[e].getAttribute(n)},getFocusedElementIndex:function(){return t.listElements.indexOf(document.activeElement)},getListItemCount:function(){return t.listElements.length},hasCheckboxAtIndex:function(e){return!!t.listElements[e].querySelector(r.strings.CHECKBOX_SELECTOR)},hasRadioAtIndex:function(e){return!!t.listElements[e].querySelector(r.strings.RADIO_SELECTOR)},isCheckboxCheckedAtIndex:function(e){return t.listElements[e].querySelector(r.strings.CHECKBOX_SELECTOR).checked},isFocusInsideList:function(){return t.root_.contains(document.activeElement)},notifyAction:function(e){t.emit(r.strings.ACTION_EVENT,{index:e},!0)},removeClassForElementIndex:function(e,n){var i=t.listElements[e];i&&i.classList.remove(n)},setAttributeForElementIndex:function(e,n,i){var s=t.listElements[e];s&&s.setAttribute(n,i)},setCheckedCheckboxOrRadioAtIndex:function(e,n){var i=t.listElements[e],s=i.querySelector(r.strings.CHECKBOX_RADIO_SELECTOR);s.checked=n;var o=document.createEvent("Event");o.initEvent("change",!0,!0),s.dispatchEvent(o)},setTabIndexForListItemChildren:function(e,n){var i=t.listElements[e];[].slice.call(i.querySelectorAll(r.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX)).forEach(function(t){return t.setAttribute("tabindex",n)})}};return new u.MDCListFoundation(e)},e.prototype.getListItemIndex_=function(t){var e=t.target,n=o.ponyfill.closest(e,"."+r.cssClasses.LIST_ITEM_CLASS+", ."+r.cssClasses.ROOT);return n&&o.ponyfill.matches(n,"."+r.cssClasses.LIST_ITEM_CLASS)?this.listElements.indexOf(n):-1},e.prototype.handleFocusInEvent_=function(t){var e=this.getListItemIndex_(t);this.foundation_.handleFocusIn(t,e)},e.prototype.handleFocusOutEvent_=function(t){var e=this.getListItemIndex_(t);this.foundation_.handleFocusOut(t,e)},e.prototype.handleKeydownEvent_=function(t){var e=this.getListItemIndex_(t),n=t.target;e>=0&&this.foundation_.handleKeydown(t,n.classList.contains(r.cssClasses.LIST_ITEM_CLASS),e)},e.prototype.handleClickEvent_=function(t){var e=this.getListItemIndex_(t),n=t.target,i=!o.ponyfill.matches(n,r.strings.CHECKBOX_RADIO_SELECTOR);this.foundation_.handleClick(e,i)},e}(s.MDCComponent);e.MDCList=c},28:function(t,e,n){"use strict";/**
* @license

@@ -121,0 +121,0 @@ * Copyright 2019 Google Inc.

@@ -32,2 +32,3 @@ /**

ARIA_CHECKED_RADIO_SELECTOR: string;
ARIA_CURRENT: string;
ARIA_ORIENTATION: string;

@@ -50,2 +51,5 @@ ARIA_ORIENTATION_HORIZONTAL: string;

};
static readonly numbers: {
UNSET_INDEX: number;
};
static readonly defaultAdapter: MDCListAdapter;

@@ -58,2 +62,3 @@ private wrapFocus_;

private useActivatedClass_;
private ariaCurrentAttrValue_;
private isCheckboxList_;

@@ -114,2 +119,6 @@ private isRadioList_;

/**
* Sets aria attribute for single selection at given index.
*/
private setAriaForSingleSelectionAtIndex_;
/**
* Toggles radio at give index. Radio doesn't change the checked state if it is already checked.

@@ -116,0 +125,0 @@ */

@@ -25,3 +25,3 @@ /**

import { MDCFoundation } from '@material/base/foundation';
import { cssClasses, strings } from './constants';
import { cssClasses, numbers, strings } from './constants';
var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];

@@ -38,5 +38,6 @@ function isNumberArray(selectedIndex) {

_this.isSingleSelectionList_ = false;
_this.selectedIndex_ = -1;
_this.focusedItemIndex_ = -1;
_this.selectedIndex_ = numbers.UNSET_INDEX;
_this.focusedItemIndex_ = numbers.UNSET_INDEX;
_this.useActivatedClass_ = false;
_this.ariaCurrentAttrValue_ = null;
_this.isCheckboxList_ = false;

@@ -60,2 +61,9 @@ _this.isRadioList_ = false;

});
Object.defineProperty(MDCListFoundation, "numbers", {
get: function () {
return numbers;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCListFoundation, "defaultAdapter", {

@@ -66,2 +74,3 @@ get: function () {

focusItemAtIndex: function () { return undefined; },
getAttributeForElementIndex: function () { return null; },
getFocusedElementIndex: function () { return 0; },

@@ -174,4 +183,4 @@ getListItemCount: function () { return 0; },

var currentIndex = this.adapter_.getFocusedElementIndex();
var nextIndex = -1;
if (currentIndex === -1) {
var nextIndex = numbers.UNSET_INDEX;
if (currentIndex === numbers.UNSET_INDEX) {
currentIndex = listItemIndex;

@@ -224,3 +233,3 @@ if (currentIndex < 0) {

MDCListFoundation.prototype.handleClick = function (index, toggleCheckbox) {
if (index === -1) {
if (index === numbers.UNSET_INDEX) {
return;

@@ -291,2 +300,5 @@ }

MDCListFoundation.prototype.setSingleSelectionAtIndex_ = function (index) {
if (this.selectedIndex_ === index) {
return;
}
var selectedClassName = cssClasses.LIST_ITEM_SELECTED_CLASS;

@@ -296,11 +308,27 @@ if (this.useActivatedClass_) {

}
if (this.selectedIndex_ >= 0 && this.selectedIndex_ !== index) {
if (this.selectedIndex_ !== numbers.UNSET_INDEX) {
this.adapter_.removeClassForElementIndex(this.selectedIndex_, selectedClassName);
this.adapter_.setAttributeForElementIndex(this.selectedIndex_, strings.ARIA_SELECTED, 'false');
}
this.adapter_.addClassForElementIndex(index, selectedClassName);
this.adapter_.setAttributeForElementIndex(index, strings.ARIA_SELECTED, 'true');
this.setAriaForSingleSelectionAtIndex_(index);
this.selectedIndex_ = index;
};
/**
* Sets aria attribute for single selection at given index.
*/
MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex_ = function (index) {
// Detect the presence of aria-current and get the value only during list initialization when it is in unset state.
if (this.selectedIndex_ === numbers.UNSET_INDEX) {
this.ariaCurrentAttrValue_ =
this.adapter_.getAttributeForElementIndex(index, strings.ARIA_CURRENT);
}
var isAriaCurrent = this.ariaCurrentAttrValue_ !== null;
var ariaAttribute = isAriaCurrent ? strings.ARIA_CURRENT : strings.ARIA_SELECTED;
if (this.selectedIndex_ !== numbers.UNSET_INDEX) {
this.adapter_.setAttributeForElementIndex(this.selectedIndex_, ariaAttribute, 'false');
}
var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue_ : 'true';
this.adapter_.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
};
/**
* Toggles radio at give index. Radio doesn't change the checked state if it is already checked.

@@ -310,3 +338,3 @@ */

this.adapter_.setCheckedCheckboxOrRadioAtIndex(index, true);
if (this.selectedIndex_ >= 0) {
if (this.selectedIndex_ !== numbers.UNSET_INDEX) {
this.adapter_.setAttributeForElementIndex(this.selectedIndex_, strings.ARIA_CHECKED, 'false');

@@ -329,3 +357,3 @@ }

MDCListFoundation.prototype.setTabindexAtIndex_ = function (index) {
if (this.focusedItemIndex_ === -1 && index !== 0) {
if (this.focusedItemIndex_ === numbers.UNSET_INDEX && index !== 0) {
// If no list item was selected set first list item's tabindex to -1.

@@ -349,3 +377,3 @@ // Generally, tabindex is set to 0 on first list item of list that has no preselected items.

if (this.isSelectableList_()) {
if (typeof this.selectedIndex_ === 'number' && this.selectedIndex_ !== -1) {
if (typeof this.selectedIndex_ === 'number' && this.selectedIndex_ !== numbers.UNSET_INDEX) {
targetIndex = this.selectedIndex_;

@@ -403,3 +431,3 @@ }

// If none of the checkbox items are selected and selectedIndex is not initialized then provide a default value.
var selectedIndexes = this.selectedIndex_ === -1 ? [] : this.selectedIndex_.slice();
var selectedIndexes = this.selectedIndex_ === numbers.UNSET_INDEX ? [] : this.selectedIndex_.slice();
if (isChecked) {

@@ -406,0 +434,0 @@ selectedIndexes.push(index);

{
"name": "@material/list",
"description": "The Material Components for the web list component",
"version": "1.0.1",
"version": "1.1.0",
"license": "MIT",

@@ -21,8 +21,8 @@ "main": "dist/mdc.list.js",

"@material/base": "^1.0.0",
"@material/dom": "^1.0.1",
"@material/dom": "^1.1.0",
"@material/feature-targeting": "^0.44.1",
"@material/ripple": "^1.0.1",
"@material/ripple": "^1.1.0",
"@material/rtl": "^0.42.0",
"@material/shape": "^1.0.0",
"@material/theme": "^1.0.0",
"@material/theme": "^1.1.0",
"@material/typography": "^1.0.0",

@@ -29,0 +29,0 @@ "tslib": "^1.9.3"

@@ -55,2 +55,8 @@ <!--docs:

### Styles
```scss
@import "@material/list/mdc-list";
```
### JavaScript

@@ -216,4 +222,4 @@

When rendering the list with a pre-selected list item, the list item that needs to be selected should contain
the `mdc-list-item--selected` or `mdc-list-item--activated` class and `aria-selected="true"` attribute before
creating the list.
the `mdc-list-item--selected` or `mdc-list-item--activated` class before creating the list. Please see
[Accessibility](#Accessibility) section for appropriate aria attributes.

@@ -423,2 +429,5 @@ ```html

Single selection list supports `aria-selected` and `aria-current` attributes. List automatically detects the presence of these attributes
and sets it to next selected list item based on which ARIA attribute you use (i.e., `aria-selected` or `aria-current`). Please see WAI-ARIA [aria-current](https://www.w3.org/TR/wai-aria-1.1/#aria-current) article for recommended usage and available attribute values.
As the user navigates through the list, any `button` and `a` elements within the list will receive `tabindex="-1"` when

@@ -502,6 +511,6 @@ the list item is not focused. When the list item receives focus, the aforementioned elements will receive

When implementing a component that will use the single selection variant, the HTML should be modified to include
the `aria-selected` attribute, the `mdc-list-item--selected` or `mdc-list-item--activated` class should be added,
the `mdc-list-item--selected` or `mdc-list-item--activated` class name,
and the `tabindex` of the selected element should be `0`. The first list item should have the `tabindex` updated
to `-1`. The foundation method `setSelectedIndex()` should be called with the initially selected element immediately
after the foundation is instantiated.
after the foundation is instantiated. Please see [Accessibility](#Accessibility) section for appropriate aria attributes.

@@ -530,2 +539,3 @@ ```html

`getListItemIndex(ele: Element) => Number` | Returns the `index` value of the provided `ele` element.
`getAttributeForElementIndex(index: number, attribute: string) => string | null` | Returns the attribute value of list item at given `index`.
`setAttributeForElementIndex(index: Number, attr: String, value: String) => void` | Sets the `attr` attribute to `value` for the list item at `index`.

@@ -532,0 +542,0 @@ `addClassForElementIndex(index: Number, className: String) => void` | Adds the `className` class to the list item at `index`.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc