@material/list
Advanced tools
Comparing version 0.39.0 to 0.39.1
@@ -1061,3 +1061,3 @@ /*! | ||
if (eventTarget.classList.contains(__WEBPACK_IMPORTED_MODULE_3__constants__["a" /* cssClasses */].LIST_ITEM_CLASS)) { | ||
index = this.listElements_.indexOf(eventTarget); | ||
index = this.listElements.indexOf(eventTarget); | ||
} | ||
@@ -1121,3 +1121,3 @@ | ||
this.singleSelection = true; | ||
this.selectedIndex = this.listElements_.indexOf(preselectedElement); | ||
this.selectedIndex = this.listElements.indexOf(preselectedElement); | ||
} | ||
@@ -1138,9 +1138,9 @@ } | ||
getListItemCount: function getListItemCount() { | ||
return _this2.listElements_.length; | ||
return _this2.listElements.length; | ||
}, | ||
getFocusedElementIndex: function getFocusedElementIndex() { | ||
return _this2.listElements_.indexOf(document.activeElement); | ||
return _this2.listElements.indexOf(document.activeElement); | ||
}, | ||
setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) { | ||
var element = _this2.listElements_[index]; | ||
var element = _this2.listElements[index]; | ||
if (element) { | ||
@@ -1151,3 +1151,3 @@ element.setAttribute(attr, value); | ||
removeAttributeForElementIndex: function removeAttributeForElementIndex(index, attr) { | ||
var element = _this2.listElements_[index]; | ||
var element = _this2.listElements[index]; | ||
if (element) { | ||
@@ -1158,3 +1158,3 @@ element.removeAttribute(attr); | ||
addClassForElementIndex: function addClassForElementIndex(index, className) { | ||
var element = _this2.listElements_[index]; | ||
var element = _this2.listElements[index]; | ||
if (element) { | ||
@@ -1165,3 +1165,3 @@ element.classList.add(className); | ||
removeClassForElementIndex: function removeClassForElementIndex(index, className) { | ||
var element = _this2.listElements_[index]; | ||
var element = _this2.listElements[index]; | ||
if (element) { | ||
@@ -1172,3 +1172,3 @@ element.classList.remove(className); | ||
focusItemAtIndex: function focusItemAtIndex(index) { | ||
var element = _this2.listElements_[index]; | ||
var element = _this2.listElements[index]; | ||
if (element) { | ||
@@ -1179,3 +1179,3 @@ element.focus(); | ||
setTabIndexForListItemChildren: function setTabIndexForListItemChildren(listItemIndex, tabIndexValue) { | ||
var element = _this2.listElements_[listItemIndex]; | ||
var element = _this2.listElements[listItemIndex]; | ||
var listItemChildren = [].slice.call(element.querySelectorAll(__WEBPACK_IMPORTED_MODULE_3__constants__["b" /* strings */].FOCUSABLE_CHILD_ELEMENTS)); | ||
@@ -1187,3 +1187,3 @@ listItemChildren.forEach(function (ele) { | ||
followHref: function followHref(index) { | ||
var listItem = _this2.listElements_[index]; | ||
var listItem = _this2.listElements[index]; | ||
if (listItem && listItem.href) { | ||
@@ -1204,3 +1204,3 @@ listItem.click(); | ||
}, { | ||
key: 'listElements_', | ||
key: 'listElements', | ||
get: function get() { | ||
@@ -1207,0 +1207,0 @@ return [].slice.call(this.root_.querySelectorAll(__WEBPACK_IMPORTED_MODULE_3__constants__["b" /* strings */].ENABLED_ITEMS_SELECTOR)); |
@@ -28,3 +28,3 @@ /*! | ||
*/ | ||
var i={ROOT:"mdc-list",LIST_ITEM_CLASS:"mdc-list-item",LIST_ITEM_SELECTED_CLASS:"mdc-list-item--selected",LIST_ITEM_ACTIVATED_CLASS:"mdc-list-item--activated"},o={ARIA_ORIENTATION:"aria-orientation",ARIA_ORIENTATION_HORIZONTAL:"horizontal",ARIA_SELECTED:"aria-selected",FOCUSABLE_CHILD_ELEMENTS:"."+i.LIST_ITEM_CLASS+" button:not(:disabled), ."+i.LIST_ITEM_CLASS+" a",ENABLED_ITEMS_SELECTOR:".mdc-list-item:not(.mdc-list-item--disabled)"}},20:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(0),a=(n(13),n(14)),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),c=["input","button","textarea","select"],f=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,u(t.defaultAdapter,e)));return n.wrapFocus_=!1,n.isVertical_=!0,n.isSingleSelectionList_=!1,n.selectedIndex_=-1,n.useActivatedClass_=!1,n}return r(t,e),l(t,null,[{key:"strings",get:function(){return a.b}},{key:"cssClasses",get:function(){return a.a}},{key:"defaultAdapter",get:function(){return{getListItemCount:function(){},getFocusedElementIndex:function(){},setAttributeForElementIndex:function(){},removeAttributeForElementIndex:function(){},addClassForElementIndex:function(){},removeClassForElementIndex:function(){},focusItemAtIndex:function(){},setTabIndexForListItemChildren:function(){},followHref:function(){}}}}]),l(t,[{key:"setWrapFocus",value:function(e){this.wrapFocus_=e}},{key:"setVerticalOrientation",value:function(e){this.isVertical_=e}},{key:"setSingleSelection",value:function(e){this.isSingleSelectionList_=e}},{key:"setUseActivatedClass",value:function(e){this.useActivatedClass_=e}},{key:"setSelectedIndex",value:function(e){if(e!==this.selectedIndex_){var t=this.useActivatedClass_?a.a.LIST_ITEM_ACTIVATED_CLASS:a.a.LIST_ITEM_SELECTED_CLASS;this.selectedIndex_>=0&&(this.adapter_.removeAttributeForElementIndex(this.selectedIndex_,a.b.ARIA_SELECTED),this.adapter_.removeClassForElementIndex(this.selectedIndex_,t),this.adapter_.setAttributeForElementIndex(this.selectedIndex_,"tabindex",-1)),e>=0&&this.adapter_.getListItemCount()>e&&(this.selectedIndex_=e,this.adapter_.setAttributeForElementIndex(this.selectedIndex_,a.b.ARIA_SELECTED,!0),this.adapter_.addClassForElementIndex(this.selectedIndex_,t),this.adapter_.setAttributeForElementIndex(this.selectedIndex_,"tabindex",0),0!==this.selectedIndex_&&this.adapter_.setAttributeForElementIndex(0,"tabindex",-1))}}},{key:"handleFocusIn",value:function(e,t){t>=0&&this.adapter_.setTabIndexForListItemChildren(t,0)}},{key:"handleFocusOut",value:function(e,t){t>=0&&this.adapter_.setTabIndexForListItemChildren(t,-1)}},{key:"handleKeydown",value:function(e,t,n){var i="ArrowLeft"===e.key||37===e.keyCode,o="ArrowUp"===e.key||38===e.keyCode,r="ArrowRight"===e.key||39===e.keyCode,s="ArrowDown"===e.key||40===e.keyCode,a="Home"===e.key||36===e.keyCode,u="End"===e.key||35===e.keyCode,l="Enter"===e.key||13===e.keyCode,c="Space"===e.key||32===e.keyCode,f=this.adapter_.getFocusedElementIndex();-1===f&&(f=n)<0||(this.isVertical_&&s||!this.isVertical_&&r?(this.preventDefaultEvent_(e),this.focusNextElement(f)):this.isVertical_&&o||!this.isVertical_&&i?(this.preventDefaultEvent_(e),this.focusPrevElement(f)):a?(this.preventDefaultEvent_(e),this.focusFirstElement()):u?(this.preventDefaultEvent_(e),this.focusLastElement()):this.isSingleSelectionList_&&(l||c)&&(this.preventDefaultEvent_(e),t&&(this.setSelectedIndex(f),this.adapter_.followHref(f))))}},{key:"handleClick",value:function(){var e=this.adapter_.getFocusedElementIndex();-1!==e&&this.setSelectedIndex(e)}},{key:"preventDefaultEvent_",value:function(e){var t=(""+e.target.tagName).toLowerCase();-1===c.indexOf(t)&&e.preventDefault()}},{key:"focusNextElement",value:function(e){var t=this.adapter_.getListItemCount(),n=e+1;if(n>=t){if(!this.wrapFocus_)return;n=0}this.adapter_.focusItemAtIndex(n)}},{key:"focusPrevElement",value:function(e){var t=e-1;if(t<0){if(!this.wrapFocus_)return;t=this.adapter_.getListItemCount()-1}this.adapter_.focusItemAtIndex(t)}},{key:"focusFirstElement",value:function(){this.adapter_.getListItemCount()>0&&this.adapter_.focusItemAtIndex(0)}},{key:"focusLastElement",value:function(){var e=this.adapter_.getListItemCount()-1;e>=0&&this.adapter_.focusItemAtIndex(e)}}]),t}(s.a);t.a=f},22:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"MDCList",function(){return f});var s=n(1),a=n(20),u=(n(13),n(14));n.d(t,"MDCListFoundation",function(){return a.a});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),f=function(e){function t(){var e;i(this,t);for(var n=arguments.length,r=Array(n),s=0;s<n;s++)r[s]=arguments[s];var a=o(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(r)));return a.handleKeydown_,a.handleClick_,a.focusInEventListener_,a.focusOutEventListener_,a}return r(t,e),c(t,[{key:"destroy",value:function(){this.root_.removeEventListener("keydown",this.handleKeydown_),this.root_.removeEventListener("click",this.handleClick_),this.root_.removeEventListener("focusin",this.focusInEventListener_),this.root_.removeEventListener("focusout",this.focusOutEventListener_)}},{key:"initialSyncWithDOM",value:function(){this.handleClick_=this.foundation_.handleClick.bind(this.foundation_),this.handleKeydown_=this.handleKeydownEvent_.bind(this),this.focusInEventListener_=this.handleFocusInEvent_.bind(this),this.focusOutEventListener_=this.handleFocusOutEvent_.bind(this),this.root_.addEventListener("keydown",this.handleKeydown_),this.root_.addEventListener("focusin",this.focusInEventListener_),this.root_.addEventListener("focusout",this.focusOutEventListener_),this.layout(),this.initializeListType()}},{key:"layout",value:function(){var e=this.root_.getAttribute(u.b.ARIA_ORIENTATION);this.vertical=e!==u.b.ARIA_ORIENTATION_HORIZONTAL,[].slice.call(this.root_.querySelectorAll(".mdc-list-item:not([tabindex])")).forEach(function(e){e.setAttribute("tabindex",-1)}),[].slice.call(this.root_.querySelectorAll(u.b.FOCUSABLE_CHILD_ELEMENTS)).forEach(function(e){return e.setAttribute("tabindex",-1)})}},{key:"getListItemIndex_",value:function(e){for(var t=e.target,n=-1;!t.classList.contains(u.a.LIST_ITEM_CLASS)&&!t.classList.contains(u.a.ROOT);)t=t.parentElement;return t.classList.contains(u.a.LIST_ITEM_CLASS)&&(n=this.listElements_.indexOf(t)),n}},{key:"handleFocusInEvent_",value:function(e){var t=this.getListItemIndex_(e);this.foundation_.handleFocusIn(e,t)}},{key:"handleFocusOutEvent_",value:function(e){var t=this.getListItemIndex_(e);this.foundation_.handleFocusOut(e,t)}},{key:"handleKeydownEvent_",value:function(e){var t=this.getListItemIndex_(e);t>=0&&this.foundation_.handleKeydown(e,e.target.classList.contains(u.a.LIST_ITEM_CLASS),t)}},{key:"initializeListType",value:function(){var e=this.root_.querySelector("."+u.a.LIST_ITEM_ACTIVATED_CLASS+", ."+u.a.LIST_ITEM_SELECTED_CLASS);e&&(e.classList.contains(u.a.LIST_ITEM_ACTIVATED_CLASS)&&this.foundation_.setUseActivatedClass(!0),this.singleSelection=!0,this.selectedIndex=this.listElements_.indexOf(e))}},{key:"getDefaultFoundation",value:function(){var e=this;return new a.a(l({getListItemCount:function(){return e.listElements_.length},getFocusedElementIndex:function(){return e.listElements_.indexOf(document.activeElement)},setAttributeForElementIndex:function(t,n,i){var o=e.listElements_[t];o&&o.setAttribute(n,i)},removeAttributeForElementIndex:function(t,n){var i=e.listElements_[t];i&&i.removeAttribute(n)},addClassForElementIndex:function(t,n){var i=e.listElements_[t];i&&i.classList.add(n)},removeClassForElementIndex:function(t,n){var i=e.listElements_[t];i&&i.classList.remove(n)},focusItemAtIndex:function(t){var n=e.listElements_[t];n&&n.focus()},setTabIndexForListItemChildren:function(t,n){var i=e.listElements_[t];[].slice.call(i.querySelectorAll(u.b.FOCUSABLE_CHILD_ELEMENTS)).forEach(function(e){return e.setAttribute("tabindex",n)})},followHref:function(t){var n=e.listElements_[t];n&&n.href&&n.click()}}))}},{key:"vertical",set:function(e){this.foundation_.setVerticalOrientation(e)}},{key:"listElements_",get:function(){return[].slice.call(this.root_.querySelectorAll(u.b.ENABLED_ITEMS_SELECTOR))}},{key:"wrapFocus",set:function(e){this.foundation_.setWrapFocus(e)}},{key:"singleSelection",set:function(e){e?this.root_.addEventListener("click",this.handleClick_):this.root_.removeEventListener("click",this.handleClick_),this.foundation_.setSingleSelection(e)}},{key:"selectedIndex",set:function(e){this.foundation_.setSelectedIndex(e)}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(s.a)}})}); | ||
var i={ROOT:"mdc-list",LIST_ITEM_CLASS:"mdc-list-item",LIST_ITEM_SELECTED_CLASS:"mdc-list-item--selected",LIST_ITEM_ACTIVATED_CLASS:"mdc-list-item--activated"},o={ARIA_ORIENTATION:"aria-orientation",ARIA_ORIENTATION_HORIZONTAL:"horizontal",ARIA_SELECTED:"aria-selected",FOCUSABLE_CHILD_ELEMENTS:"."+i.LIST_ITEM_CLASS+" button:not(:disabled), ."+i.LIST_ITEM_CLASS+" a",ENABLED_ITEMS_SELECTOR:".mdc-list-item:not(.mdc-list-item--disabled)"}},20:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(0),a=(n(13),n(14)),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),c=["input","button","textarea","select"],f=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,u(t.defaultAdapter,e)));return n.wrapFocus_=!1,n.isVertical_=!0,n.isSingleSelectionList_=!1,n.selectedIndex_=-1,n.useActivatedClass_=!1,n}return r(t,e),l(t,null,[{key:"strings",get:function(){return a.b}},{key:"cssClasses",get:function(){return a.a}},{key:"defaultAdapter",get:function(){return{getListItemCount:function(){},getFocusedElementIndex:function(){},setAttributeForElementIndex:function(){},removeAttributeForElementIndex:function(){},addClassForElementIndex:function(){},removeClassForElementIndex:function(){},focusItemAtIndex:function(){},setTabIndexForListItemChildren:function(){},followHref:function(){}}}}]),l(t,[{key:"setWrapFocus",value:function(e){this.wrapFocus_=e}},{key:"setVerticalOrientation",value:function(e){this.isVertical_=e}},{key:"setSingleSelection",value:function(e){this.isSingleSelectionList_=e}},{key:"setUseActivatedClass",value:function(e){this.useActivatedClass_=e}},{key:"setSelectedIndex",value:function(e){if(e!==this.selectedIndex_){var t=this.useActivatedClass_?a.a.LIST_ITEM_ACTIVATED_CLASS:a.a.LIST_ITEM_SELECTED_CLASS;this.selectedIndex_>=0&&(this.adapter_.removeAttributeForElementIndex(this.selectedIndex_,a.b.ARIA_SELECTED),this.adapter_.removeClassForElementIndex(this.selectedIndex_,t),this.adapter_.setAttributeForElementIndex(this.selectedIndex_,"tabindex",-1)),e>=0&&this.adapter_.getListItemCount()>e&&(this.selectedIndex_=e,this.adapter_.setAttributeForElementIndex(this.selectedIndex_,a.b.ARIA_SELECTED,!0),this.adapter_.addClassForElementIndex(this.selectedIndex_,t),this.adapter_.setAttributeForElementIndex(this.selectedIndex_,"tabindex",0),0!==this.selectedIndex_&&this.adapter_.setAttributeForElementIndex(0,"tabindex",-1))}}},{key:"handleFocusIn",value:function(e,t){t>=0&&this.adapter_.setTabIndexForListItemChildren(t,0)}},{key:"handleFocusOut",value:function(e,t){t>=0&&this.adapter_.setTabIndexForListItemChildren(t,-1)}},{key:"handleKeydown",value:function(e,t,n){var i="ArrowLeft"===e.key||37===e.keyCode,o="ArrowUp"===e.key||38===e.keyCode,r="ArrowRight"===e.key||39===e.keyCode,s="ArrowDown"===e.key||40===e.keyCode,a="Home"===e.key||36===e.keyCode,u="End"===e.key||35===e.keyCode,l="Enter"===e.key||13===e.keyCode,c="Space"===e.key||32===e.keyCode,f=this.adapter_.getFocusedElementIndex();-1===f&&(f=n)<0||(this.isVertical_&&s||!this.isVertical_&&r?(this.preventDefaultEvent_(e),this.focusNextElement(f)):this.isVertical_&&o||!this.isVertical_&&i?(this.preventDefaultEvent_(e),this.focusPrevElement(f)):a?(this.preventDefaultEvent_(e),this.focusFirstElement()):u?(this.preventDefaultEvent_(e),this.focusLastElement()):this.isSingleSelectionList_&&(l||c)&&(this.preventDefaultEvent_(e),t&&(this.setSelectedIndex(f),this.adapter_.followHref(f))))}},{key:"handleClick",value:function(){var e=this.adapter_.getFocusedElementIndex();-1!==e&&this.setSelectedIndex(e)}},{key:"preventDefaultEvent_",value:function(e){var t=(""+e.target.tagName).toLowerCase();-1===c.indexOf(t)&&e.preventDefault()}},{key:"focusNextElement",value:function(e){var t=this.adapter_.getListItemCount(),n=e+1;if(n>=t){if(!this.wrapFocus_)return;n=0}this.adapter_.focusItemAtIndex(n)}},{key:"focusPrevElement",value:function(e){var t=e-1;if(t<0){if(!this.wrapFocus_)return;t=this.adapter_.getListItemCount()-1}this.adapter_.focusItemAtIndex(t)}},{key:"focusFirstElement",value:function(){this.adapter_.getListItemCount()>0&&this.adapter_.focusItemAtIndex(0)}},{key:"focusLastElement",value:function(){var e=this.adapter_.getListItemCount()-1;e>=0&&this.adapter_.focusItemAtIndex(e)}}]),t}(s.a);t.a=f},22:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"MDCList",function(){return f});var s=n(1),a=n(20),u=(n(13),n(14));n.d(t,"MDCListFoundation",function(){return a.a});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),f=function(e){function t(){var e;i(this,t);for(var n=arguments.length,r=Array(n),s=0;s<n;s++)r[s]=arguments[s];var a=o(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(r)));return a.handleKeydown_,a.handleClick_,a.focusInEventListener_,a.focusOutEventListener_,a}return r(t,e),c(t,[{key:"destroy",value:function(){this.root_.removeEventListener("keydown",this.handleKeydown_),this.root_.removeEventListener("click",this.handleClick_),this.root_.removeEventListener("focusin",this.focusInEventListener_),this.root_.removeEventListener("focusout",this.focusOutEventListener_)}},{key:"initialSyncWithDOM",value:function(){this.handleClick_=this.foundation_.handleClick.bind(this.foundation_),this.handleKeydown_=this.handleKeydownEvent_.bind(this),this.focusInEventListener_=this.handleFocusInEvent_.bind(this),this.focusOutEventListener_=this.handleFocusOutEvent_.bind(this),this.root_.addEventListener("keydown",this.handleKeydown_),this.root_.addEventListener("focusin",this.focusInEventListener_),this.root_.addEventListener("focusout",this.focusOutEventListener_),this.layout(),this.initializeListType()}},{key:"layout",value:function(){var e=this.root_.getAttribute(u.b.ARIA_ORIENTATION);this.vertical=e!==u.b.ARIA_ORIENTATION_HORIZONTAL,[].slice.call(this.root_.querySelectorAll(".mdc-list-item:not([tabindex])")).forEach(function(e){e.setAttribute("tabindex",-1)}),[].slice.call(this.root_.querySelectorAll(u.b.FOCUSABLE_CHILD_ELEMENTS)).forEach(function(e){return e.setAttribute("tabindex",-1)})}},{key:"getListItemIndex_",value:function(e){for(var t=e.target,n=-1;!t.classList.contains(u.a.LIST_ITEM_CLASS)&&!t.classList.contains(u.a.ROOT);)t=t.parentElement;return t.classList.contains(u.a.LIST_ITEM_CLASS)&&(n=this.listElements.indexOf(t)),n}},{key:"handleFocusInEvent_",value:function(e){var t=this.getListItemIndex_(e);this.foundation_.handleFocusIn(e,t)}},{key:"handleFocusOutEvent_",value:function(e){var t=this.getListItemIndex_(e);this.foundation_.handleFocusOut(e,t)}},{key:"handleKeydownEvent_",value:function(e){var t=this.getListItemIndex_(e);t>=0&&this.foundation_.handleKeydown(e,e.target.classList.contains(u.a.LIST_ITEM_CLASS),t)}},{key:"initializeListType",value:function(){var e=this.root_.querySelector("."+u.a.LIST_ITEM_ACTIVATED_CLASS+", ."+u.a.LIST_ITEM_SELECTED_CLASS);e&&(e.classList.contains(u.a.LIST_ITEM_ACTIVATED_CLASS)&&this.foundation_.setUseActivatedClass(!0),this.singleSelection=!0,this.selectedIndex=this.listElements.indexOf(e))}},{key:"getDefaultFoundation",value:function(){var e=this;return new a.a(l({getListItemCount:function(){return e.listElements.length},getFocusedElementIndex:function(){return e.listElements.indexOf(document.activeElement)},setAttributeForElementIndex:function(t,n,i){var o=e.listElements[t];o&&o.setAttribute(n,i)},removeAttributeForElementIndex:function(t,n){var i=e.listElements[t];i&&i.removeAttribute(n)},addClassForElementIndex:function(t,n){var i=e.listElements[t];i&&i.classList.add(n)},removeClassForElementIndex:function(t,n){var i=e.listElements[t];i&&i.classList.remove(n)},focusItemAtIndex:function(t){var n=e.listElements[t];n&&n.focus()},setTabIndexForListItemChildren:function(t,n){var i=e.listElements[t];[].slice.call(i.querySelectorAll(u.b.FOCUSABLE_CHILD_ELEMENTS)).forEach(function(e){return e.setAttribute("tabindex",n)})},followHref:function(t){var n=e.listElements[t];n&&n.href&&n.click()}}))}},{key:"vertical",set:function(e){this.foundation_.setVerticalOrientation(e)}},{key:"listElements",get:function(){return[].slice.call(this.root_.querySelectorAll(u.b.ENABLED_ITEMS_SELECTOR))}},{key:"wrapFocus",set:function(e){this.foundation_.setWrapFocus(e)}},{key:"singleSelection",set:function(e){e?this.root_.addEventListener("click",this.handleClick_):this.root_.removeEventListener("click",this.handleClick_),this.foundation_.setSingleSelection(e)}},{key:"selectedIndex",set:function(e){this.foundation_.setSelectedIndex(e)}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(s.a)}})}); | ||
//# sourceMappingURL=mdc.list.min.js.map |
24
index.js
@@ -106,3 +106,3 @@ /** | ||
if (eventTarget.classList.contains(cssClasses.LIST_ITEM_CLASS)) { | ||
index = this.listElements_.indexOf(eventTarget); | ||
index = this.listElements.indexOf(eventTarget); | ||
} | ||
@@ -157,3 +157,3 @@ | ||
this.singleSelection = true; | ||
this.selectedIndex = this.listElements_.indexOf(preselectedElement); | ||
this.selectedIndex = this.listElements.indexOf(preselectedElement); | ||
} | ||
@@ -168,3 +168,3 @@ } | ||
/** @return Array<!Element>*/ | ||
get listElements_() { | ||
get listElements() { | ||
return [].slice.call(this.root_.querySelectorAll(strings.ENABLED_ITEMS_SELECTOR)); | ||
@@ -197,6 +197,6 @@ } | ||
return new MDCListFoundation(/** @type {!MDCListAdapter} */ (Object.assign({ | ||
getListItemCount: () => this.listElements_.length, | ||
getFocusedElementIndex: () => this.listElements_.indexOf(document.activeElement), | ||
getListItemCount: () => this.listElements.length, | ||
getFocusedElementIndex: () => this.listElements.indexOf(document.activeElement), | ||
setAttributeForElementIndex: (index, attr, value) => { | ||
const element = this.listElements_[index]; | ||
const element = this.listElements[index]; | ||
if (element) { | ||
@@ -207,3 +207,3 @@ element.setAttribute(attr, value); | ||
removeAttributeForElementIndex: (index, attr) => { | ||
const element = this.listElements_[index]; | ||
const element = this.listElements[index]; | ||
if (element) { | ||
@@ -214,3 +214,3 @@ element.removeAttribute(attr); | ||
addClassForElementIndex: (index, className) => { | ||
const element = this.listElements_[index]; | ||
const element = this.listElements[index]; | ||
if (element) { | ||
@@ -221,3 +221,3 @@ element.classList.add(className); | ||
removeClassForElementIndex: (index, className) => { | ||
const element = this.listElements_[index]; | ||
const element = this.listElements[index]; | ||
if (element) { | ||
@@ -228,3 +228,3 @@ element.classList.remove(className); | ||
focusItemAtIndex: (index) => { | ||
const element = this.listElements_[index]; | ||
const element = this.listElements[index]; | ||
if (element) { | ||
@@ -235,3 +235,3 @@ element.focus(); | ||
setTabIndexForListItemChildren: (listItemIndex, tabIndexValue) => { | ||
const element = this.listElements_[listItemIndex]; | ||
const element = this.listElements[listItemIndex]; | ||
const listItemChildren = [].slice.call(element.querySelectorAll(strings.FOCUSABLE_CHILD_ELEMENTS)); | ||
@@ -241,3 +241,3 @@ listItemChildren.forEach((ele) => ele.setAttribute('tabindex', tabIndexValue)); | ||
followHref: (index) => { | ||
const listItem = this.listElements_[index]; | ||
const listItem = this.listElements[index]; | ||
if (listItem && listItem.href) { | ||
@@ -244,0 +244,0 @@ listItem.click(); |
{ | ||
"name": "@material/list", | ||
"description": "The Material Components for the web list component", | ||
"version": "0.39.0", | ||
"version": "0.39.1", | ||
"license": "MIT", | ||
@@ -17,7 +17,7 @@ "keywords": [ | ||
"@material/base": "^0.39.0", | ||
"@material/ripple": "^0.39.0", | ||
"@material/rtl": "^0.39.0", | ||
"@material/theme": "^0.39.0", | ||
"@material/ripple": "^0.39.1", | ||
"@material/rtl": "^0.39.1", | ||
"@material/theme": "^0.39.1", | ||
"@material/typography": "^0.39.0" | ||
} | ||
} |
121
README.md
@@ -43,5 +43,11 @@ <!--docs: | ||
<ul class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item">Single-line item</li> | ||
<li class="mdc-list-item">Single-line item</li> | ||
<li class="mdc-list-item">Single-line item</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
</ul> | ||
@@ -91,12 +97,23 @@ ``` | ||
<ul class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item">line item</li> | ||
<li class="mdc-list-item">line item</li> | ||
<li class="mdc-list-item">line item</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">line item</span> | ||
</li> | ||
</ul> | ||
<h3 class="mdc-list-group__subheader">List 2</h3> | ||
<ul class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item">line item</li> | ||
<li class="mdc-list-item">line item</li> | ||
<li class="mdc-list-item">line item</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">line item</span> | ||
</li> | ||
</ul> | ||
@@ -112,7 +129,15 @@ </div> | ||
<ul class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item">Item 1 - Division 1</li> | ||
<li class="mdc-list-item">Item 2 - Division 1</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 1 - Division 1</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 2 - Division 1</span> | ||
</li> | ||
<li role="separator" class="mdc-list-divider"></li> | ||
<li class="mdc-list-item">Item 1 - Division 2</li> | ||
<li class="mdc-list-item">Item 2 - Division 2</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 1 - Division 2</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 2 - Division 2</span> | ||
</li> | ||
</ul> | ||
@@ -127,9 +152,17 @@ ``` | ||
<ul class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item">Item 1 - List 1</li> | ||
<li class="mdc-list-item">Item 2 - List 1</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 1 - List 1</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 2 - List 1</span> | ||
</li> | ||
</ul> | ||
<hr class="mdc-list-divider"> | ||
<ul class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item">Item 1 - List 2</li> | ||
<li class="mdc-list-item">Item 2 - List 2</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 1 - List 2</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Item 2 - List 2</span> | ||
</li> | ||
</ul> | ||
@@ -145,5 +178,11 @@ ``` | ||
<ul id="my-list" class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item" tabindex="0">Single-line item</li> | ||
<li class="mdc-list-item">Single-line item</li> | ||
<li class="mdc-list-item">Single-line item</li> | ||
<li class="mdc-list-item" tabindex="0"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
</ul> | ||
@@ -166,5 +205,11 @@ ``` | ||
<ul id="my-list" class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item">Single-line item</li> | ||
<li class="mdc-list-item mdc-list-item--selected" aria-selected="true" tabindex="0">Single-line item</li> | ||
<li class="mdc-list-item">Single-line item</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item mdc-list-item--selected" aria-selected="true" tabindex="0"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
</ul> | ||
@@ -191,3 +236,3 @@ ``` | ||
`mdc-list-item` | Mandatory, for the list item element. | ||
`mdc-list-item__text` | Optional, wrapper for two line list item text content (displayed as middle column of the list item). | ||
`mdc-list-item__text` | Mandatory. Wrapper for list item text content (displayed as middle column of the list item). | ||
`mdc-list-item__primary-text` | Optional, primary text for the list item. Should be the child of `mdc-list-item__text`. | ||
@@ -270,5 +315,12 @@ `mdc-list-item__secondary-text` | Optional, secondary text for the list item. Displayed below the primary text. Should be the child of `mdc-list-item__text`. | ||
<ul id="my-list" class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item" tabindex="0">Single-line item<button tabindex="-1"></button></li> | ||
<li class="mdc-list-item" tabindex="-1">Single-line item</li> | ||
<li class="mdc-list-item" tabindex="-1">Single-line item</li> | ||
<li class="mdc-list-item" tabindex="0"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
<button tabindex="-1"></button> | ||
</li> | ||
<li class="mdc-list-item" tabindex="-1"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item" tabindex="-1"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
</ul> | ||
@@ -287,5 +339,12 @@ ``` | ||
<ul id="my-list" class="mdc-list" aria-orientation="vertical"> | ||
<li class="mdc-list-item" tabindex="-1">Single-line item<button tabindex="-1"></button></li> | ||
<li class="mdc-list-item mdc-list-item--selected" aria-selected="true" tabindex="0">Single-line item</li> | ||
<li class="mdc-list-item" tabindex="-1">Single-line item</li> | ||
<li class="mdc-list-item" tabindex="-1"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
<button tabindex="-1"></button> | ||
</li> | ||
<li class="mdc-list-item mdc-list-item--selected" aria-selected="true" tabindex="0"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
<li class="mdc-list-item" tabindex="-1"> | ||
<span class="mdc-list-item__text">Single-line item</span> | ||
</li> | ||
</ul> | ||
@@ -292,0 +351,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144226
2195
375
Updated@material/ripple@^0.39.1
Updated@material/rtl@^0.39.1
Updated@material/theme@^0.39.1