@limetech/lime-elements
Version:
134 lines • 33.2 kB
JavaScript
import{_ as t,a as i,M as e,m as n,d as r,b as s}from"./p-9f722992.js";
/**
* @license
* Copyright 2018 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/var u,a;var f={LIST_ITEM_ACTIVATED_CLASS:"mdc-list-item--activated",LIST_ITEM_CLASS:"mdc-list-item",LIST_ITEM_DISABLED_CLASS:"mdc-list-item--disabled",LIST_ITEM_SELECTED_CLASS:"mdc-list-item--selected",LIST_ITEM_TEXT_CLASS:"mdc-list-item__text",LIST_ITEM_PRIMARY_TEXT_CLASS:"mdc-list-item__primary-text",ROOT:"mdc-list"};var h=(u={},u[""+f.LIST_ITEM_ACTIVATED_CLASS]="mdc-list-item--activated",u[""+f.LIST_ITEM_CLASS]="mdc-list-item",u[""+f.LIST_ITEM_DISABLED_CLASS]="mdc-list-item--disabled",u[""+f.LIST_ITEM_SELECTED_CLASS]="mdc-list-item--selected",u[""+f.LIST_ITEM_PRIMARY_TEXT_CLASS]="mdc-list-item__primary-text",u[""+f.ROOT]="mdc-list",u);var o=(a={},a[""+f.LIST_ITEM_ACTIVATED_CLASS]="mdc-deprecated-list-item--activated",a[""+f.LIST_ITEM_CLASS]="mdc-deprecated-list-item",a[""+f.LIST_ITEM_DISABLED_CLASS]="mdc-deprecated-list-item--disabled",a[""+f.LIST_ITEM_SELECTED_CLASS]="mdc-deprecated-list-item--selected",a[""+f.LIST_ITEM_TEXT_CLASS]="mdc-deprecated-list-item__text",a[""+f.LIST_ITEM_PRIMARY_TEXT_CLASS]="mdc-deprecated-list-item__primary-text",a[""+f.ROOT]="mdc-deprecated-list",a);var c={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_DISABLED:"aria-disabled",ARIA_ORIENTATION:"aria-orientation",ARIA_ORIENTATION_HORIZONTAL:"horizontal",ARIA_ROLE_CHECKBOX_SELECTOR:'[role="checkbox"]',ARIA_SELECTED:"aria-selected",ARIA_INTERACTIVE_ROLES_SELECTOR:'[role="listbox"], [role="menu"]',ARIA_MULTI_SELECTABLE_SELECTOR:'[aria-multiselectable="true"]',CHECKBOX_RADIO_SELECTOR:'input[type="checkbox"], input[type="radio"]',CHECKBOX_SELECTOR:'input[type="checkbox"]',CHILD_ELEMENTS_TO_TOGGLE_TABINDEX:"\n ."+f.LIST_ITEM_CLASS+" button:not(:disabled),\n ."+f.LIST_ITEM_CLASS+" a,\n ."+o[f.LIST_ITEM_CLASS]+" button:not(:disabled),\n ."+o[f.LIST_ITEM_CLASS]+" a\n ",DEPRECATED_SELECTOR:".mdc-deprecated-list",FOCUSABLE_CHILD_ELEMENTS:"\n ."+f.LIST_ITEM_CLASS+" button:not(:disabled),\n ."+f.LIST_ITEM_CLASS+" a,\n ."+f.LIST_ITEM_CLASS+' input[type="radio"]:not(:disabled),\n .'+f.LIST_ITEM_CLASS+' input[type="checkbox"]:not(:disabled),\n .'+o[f.LIST_ITEM_CLASS]+" button:not(:disabled),\n ."+o[f.LIST_ITEM_CLASS]+" a,\n ."+o[f.LIST_ITEM_CLASS]+' input[type="radio"]:not(:disabled),\n .'+o[f.LIST_ITEM_CLASS]+' input[type="checkbox"]:not(:disabled)\n ',RADIO_SELECTOR:'input[type="radio"]',SELECTED_ITEM_SELECTOR:'[aria-selected="true"], [aria-current="true"]'};var d={UNSET_INDEX:-1,TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS:300};var l="evolution";
/**
* @license
* Copyright 2020 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/var v={UNKNOWN:"Unknown",BACKSPACE:"Backspace",ENTER:"Enter",SPACEBAR:"Spacebar",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",END:"End",HOME:"Home",ARROW_LEFT:"ArrowLeft",ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown",DELETE:"Delete",ESCAPE:"Escape",TAB:"Tab"};var E=new Set;E.add(v.BACKSPACE);E.add(v.ENTER);E.add(v.SPACEBAR);E.add(v.PAGE_UP);E.add(v.PAGE_DOWN);E.add(v.END);E.add(v.HOME);E.add(v.ARROW_LEFT);E.add(v.ARROW_UP);E.add(v.ARROW_RIGHT);E.add(v.ARROW_DOWN);E.add(v.DELETE);E.add(v.ESCAPE);E.add(v.TAB);var A={BACKSPACE:8,ENTER:13,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40,DELETE:46,ESCAPE:27,TAB:9};var I=new Map;I.set(A.BACKSPACE,v.BACKSPACE);I.set(A.ENTER,v.ENTER);I.set(A.SPACEBAR,v.SPACEBAR);I.set(A.PAGE_UP,v.PAGE_UP);I.set(A.PAGE_DOWN,v.PAGE_DOWN);I.set(A.END,v.END);I.set(A.HOME,v.HOME);I.set(A.ARROW_LEFT,v.ARROW_LEFT);I.set(A.ARROW_UP,v.ARROW_UP);I.set(A.ARROW_RIGHT,v.ARROW_RIGHT);I.set(A.ARROW_DOWN,v.ARROW_DOWN);I.set(A.DELETE,v.DELETE);I.set(A.ESCAPE,v.ESCAPE);I.set(A.TAB,v.TAB);var m=new Set;m.add(v.PAGE_UP);m.add(v.PAGE_DOWN);m.add(v.END);m.add(v.HOME);m.add(v.ARROW_LEFT);m.add(v.ARROW_UP);m.add(v.ARROW_RIGHT);m.add(v.ARROW_DOWN);function b(t){var i=t.key;if(E.has(i)){return i}var e=I.get(t.keyCode);if(e){return e}return v.UNKNOWN}
/**
* @license
* Copyright 2020 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/var x=["input","button","textarea","select"];var C=function(t){var i=t.target;if(!i){return}var e=(""+i.tagName).toLowerCase();if(x.indexOf(e)===-1){t.preventDefault()}};
/**
* @license
* Copyright 2020 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/function _(){var t={bufferClearTimeout:0,currentFirstChar:"",sortedIndexCursor:0,typeaheadBuffer:""};return t}function T(t,i){var e=new Map;for(var n=0;n<t;n++){var r=i(n).trim();if(!r){continue}var s=r[0].toLowerCase();if(!e.has(s)){e.set(s,[])}e.get(s).push({text:r.toLowerCase(),index:n})}e.forEach((function(t){t.sort((function(t,i){return t.index-i.index}))}));return e}function R(t,i){var e=t.nextChar,n=t.focusItemAtIndex,r=t.sortedIndexByFirstChar,s=t.focusedItemIndex,u=t.skipFocus,a=t.isItemAtIndexDisabled;clearTimeout(i.bufferClearTimeout);i.bufferClearTimeout=setTimeout((function(){S(i)}),d.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);i.typeaheadBuffer=i.typeaheadBuffer+e;var f;if(i.typeaheadBuffer.length===1){f=O(r,s,a,i)}else{f=p(r,a,i)}if(f!==-1&&!u){n(f)}return f}function O(t,i,e,n){var r=n.typeaheadBuffer[0];var s=t.get(r);if(!s){return-1}if(r===n.currentFirstChar&&s[n.sortedIndexCursor].index===i){n.sortedIndexCursor=(n.sortedIndexCursor+1)%s.length;var u=s[n.sortedIndexCursor].index;if(!e(u)){return u}}n.currentFirstChar=r;var a=-1;var f;for(f=0;f<s.length;f++){if(!e(s[f].index)){a=f;break}}for(;f<s.length;f++){if(s[f].index>i&&!e(s[f].index)){a=f;break}}if(a!==-1){n.sortedIndexCursor=a;return s[n.sortedIndexCursor].index}return-1}function p(t,i,e){var n=e.typeaheadBuffer[0];var r=t.get(n);if(!r){return-1}var s=r[e.sortedIndexCursor];if(s.text.lastIndexOf(e.typeaheadBuffer,0)===0&&!i(s.index)){return s.index}var u=(e.sortedIndexCursor+1)%r.length;var a=-1;while(u!==e.sortedIndexCursor){var f=r[u];var h=f.text.lastIndexOf(e.typeaheadBuffer,0)===0;var o=!i(f.index);if(h&&o){a=u;break}u=(u+1)%r.length}if(a!==-1){e.sortedIndexCursor=a;return r[e.sortedIndexCursor].index}return-1}function L(t){return t.typeaheadBuffer.length>0}function S(t){t.typeaheadBuffer=""}function D(t,i){var e=t.event,n=t.isTargetListItem,r=t.focusedItemIndex,s=t.focusItemAtIndex,u=t.sortedIndexByFirstChar,a=t.isItemAtIndexDisabled;var f=b(e)==="ArrowLeft";var h=b(e)==="ArrowUp";var o=b(e)==="ArrowRight";var c=b(e)==="ArrowDown";var d=b(e)==="Home";var l=b(e)==="End";var v=b(e)==="Enter";var E=b(e)==="Spacebar";if(e.ctrlKey||e.metaKey||f||h||o||c||d||l||v){return-1}var A=!E&&e.key.length===1;if(A){C(e);var I={focusItemAtIndex:s,focusedItemIndex:r,nextChar:e.key.toLowerCase(),sortedIndexByFirstChar:u,skipFocus:false,isItemAtIndexDisabled:a};return R(I,i)}if(!E){return-1}if(n){C(e)}var m=n&&L(i);if(m){var I={focusItemAtIndex:s,focusedItemIndex:r,nextChar:" ",sortedIndexByFirstChar:u,skipFocus:false,isItemAtIndexDisabled:a};return R(I,i)}return-1}
/**
* @license
* Copyright 2018 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/function y(t){return t instanceof Array}var g=function(e){t(n,e);function n(t){var r=e.call(this,i(i({},n.defaultAdapter),t))||this;r.wrapFocus=false;r.isVertical=true;r.isSingleSelectionList=false;r.selectedIndex=d.UNSET_INDEX;r.focusedItemIndex=d.UNSET_INDEX;r.useActivatedClass=false;r.useSelectedAttr=false;r.ariaCurrentAttrValue=null;r.isCheckboxList=false;r.isRadioList=false;r.hasTypeahead=false;r.typeaheadState=_();r.sortedIndexByFirstChar=new Map;return r}Object.defineProperty(n,"strings",{get:function(){return c},enumerable:false,configurable:true});Object.defineProperty(n,"cssClasses",{get:function(){return f},enumerable:false,configurable:true});Object.defineProperty(n,"numbers",{get:function(){return d},enumerable:false,configurable:true});Object.defineProperty(n,"defaultAdapter",{get:function(){return{addClassForElementIndex:function(){return undefined},focusItemAtIndex:function(){return undefined},getAttributeForElementIndex:function(){return null},getFocusedElementIndex:function(){return 0},getListItemCount:function(){return 0},hasCheckboxAtIndex:function(){return false},hasRadioAtIndex:function(){return false},isCheckboxCheckedAtIndex:function(){return false},isFocusInsideList:function(){return false},isRootFocused:function(){return false},listItemAtIndexHasClass:function(){return false},notifyAction:function(){return undefined},removeClassForElementIndex:function(){return undefined},setAttributeForElementIndex:function(){return undefined},setCheckedCheckboxOrRadioAtIndex:function(){return undefined},setTabIndexForListItemChildren:function(){return undefined},getPrimaryTextAtIndex:function(){return""}}},enumerable:false,configurable:true});n.prototype.layout=function(){if(this.adapter.getListItemCount()===0){return}if(this.adapter.hasCheckboxAtIndex(0)){this.isCheckboxList=true}else if(this.adapter.hasRadioAtIndex(0)){this.isRadioList=true}else{this.maybeInitializeSingleSelection()}if(this.hasTypeahead){this.sortedIndexByFirstChar=this.typeaheadInitSortedIndex()}};n.prototype.getFocusedItemIndex=function(){return this.focusedItemIndex};n.prototype.setWrapFocus=function(t){this.wrapFocus=t};n.prototype.setVerticalOrientation=function(t){this.isVertical=t};n.prototype.setSingleSelection=function(t){this.isSingleSelectionList=t;if(t){this.maybeInitializeSingleSelection();this.selectedIndex=this.getSelectedIndexFromDOM()}};n.prototype.maybeInitializeSingleSelection=function(){var t=this.getSelectedIndexFromDOM();if(t===d.UNSET_INDEX)return;var i=this.adapter.listItemAtIndexHasClass(t,f.LIST_ITEM_ACTIVATED_CLASS);if(i){this.setUseActivatedClass(true)}this.isSingleSelectionList=true;this.selectedIndex=t};n.prototype.getSelectedIndexFromDOM=function(){var t=d.UNSET_INDEX;var i=this.adapter.getListItemCount();for(var e=0;e<i;e++){var n=this.adapter.listItemAtIndexHasClass(e,f.LIST_ITEM_SELECTED_CLASS);var r=this.adapter.listItemAtIndexHasClass(e,f.LIST_ITEM_ACTIVATED_CLASS);if(!(n||r)){continue}t=e;break}return t};n.prototype.setHasTypeahead=function(t){this.hasTypeahead=t;if(t){this.sortedIndexByFirstChar=this.typeaheadInitSortedIndex()}};n.prototype.isTypeaheadInProgress=function(){return this.hasTypeahead&&L(this.typeaheadState)};n.prototype.setUseActivatedClass=function(t){this.useActivatedClass=t};n.prototype.setUseSelectedAttribute=function(t){this.useSelectedAttr=t};n.prototype.getSelectedIndex=function(){return this.selectedIndex};n.prototype.setSelectedIndex=function(t,i){var e=i===void 0?{}:i,n=e.forceUpdate;if(!this.isIndexValid(t)){return}if(this.isCheckboxList){this.setCheckboxAtIndex(t)}else if(this.isRadioList){this.setRadioAtIndex(t)}else{this.setSingleSelectionAtIndex(t,{forceUpdate:n})}};n.prototype.handleFocusIn=function(t){if(t>=0){this.focusedItemIndex=t;this.adapter.setAttributeForElementIndex(t,"tabindex","0");this.adapter.setTabIndexForListItemChildren(t,"0")}};n.prototype.handleFocusOut=function(t){var i=this;if(t>=0){this.adapter.setAttributeForElementIndex(t,"tabindex","-1");this.adapter.setTabIndexForListItemChildren(t,"-1")}setTimeout((function(){if(!i.adapter.isFocusInsideList()){i.setTabindexToFirstSelectedOrFocusedItem()}}),0)};n.prototype.handleKeydown=function(t,i,e){var n=this;var r=b(t)==="ArrowLeft";var s=b(t)==="ArrowUp";var u=b(t)==="ArrowRight";var a=b(t)==="ArrowDown";var h=b(t)==="Home";var o=b(t)==="End";var c=b(t)==="Enter";var l=b(t)==="Spacebar";var v=t.key==="A"||t.key==="a";if(this.adapter.isRootFocused()){if(s||o){t.preventDefault();this.focusLastElement()}else if(a||h){t.preventDefault();this.focusFirstElement()}if(this.hasTypeahead){var E={event:t,focusItemAtIndex:function(t){n.focusItemAtIndex(t)},focusedItemIndex:-1,isTargetListItem:i,sortedIndexByFirstChar:this.sortedIndexByFirstChar,isItemAtIndexDisabled:function(t){return n.adapter.listItemAtIndexHasClass(t,f.LIST_ITEM_DISABLED_CLASS)}};D(E,this.typeaheadState)}return}var A=this.adapter.getFocusedElementIndex();if(A===-1){A=e;if(A<0){return}}if(this.isVertical&&a||!this.isVertical&&u){C(t);this.focusNextElement(A)}else if(this.isVertical&&s||!this.isVertical&&r){C(t);this.focusPrevElement(A)}else if(h){C(t);this.focusFirstElement()}else if(o){C(t);this.focusLastElement()}else if(v&&t.ctrlKey&&this.isCheckboxList){t.preventDefault();this.toggleAll(this.selectedIndex===d.UNSET_INDEX?[]:this.selectedIndex)}else if(c||l){if(i){var I=t.target;if(I&&I.tagName==="A"&&c){return}C(t);if(this.adapter.listItemAtIndexHasClass(A,f.LIST_ITEM_DISABLED_CLASS)){return}if(!this.isTypeaheadInProgress()){if(this.isSelectableList()){this.setSelectedIndexOnAction(A)}this.adapter.notifyAction(A)}}}if(this.hasTypeahead){var E={event:t,focusItemAtIndex:function(t){n.focusItemAtIndex(t)},focusedItemIndex:this.focusedItemIndex,isTargetListItem:i,sortedIndexByFirstChar:this.sortedIndexByFirstChar,isItemAtIndexDisabled:function(t){return n.adapter.listItemAtIndexHasClass(t,f.LIST_ITEM_DISABLED_CLASS)}};D(E,this.typeaheadState)}};n.prototype.handleClick=function(t,i){if(t===d.UNSET_INDEX){return}if(this.adapter.listItemAtIndexHasClass(t,f.LIST_ITEM_DISABLED_CLASS)){return}if(this.isSelectableList()){this.setSelectedIndexOnAction(t,i)}this.adapter.notifyAction(t)};n.prototype.focusNextElement=function(t){var i=this.adapter.getListItemCount();var e=t+1;if(e>=i){if(this.wrapFocus){e=0}else{return t}}this.focusItemAtIndex(e);return e};n.prototype.focusPrevElement=function(t){var i=t-1;if(i<0){if(this.wrapFocus){i=this.adapter.getListItemCount()-1}else{return t}}this.focusItemAtIndex(i);return i};n.prototype.focusFirstElement=function(){this.focusItemAtIndex(0);return 0};n.prototype.focusLastElement=function(){var t=this.adapter.getListItemCount()-1;this.focusItemAtIndex(t);return t};n.prototype.focusInitialElement=function(){var t=this.getFirstSelectedOrFocusedItemIndex();this.focusItemAtIndex(t);return t};n.prototype.setEnabled=function(t,i){if(!this.isIndexValid(t)){return}if(i){this.adapter.removeClassForElementIndex(t,f.LIST_ITEM_DISABLED_CLASS);this.adapter.setAttributeForElementIndex(t,c.ARIA_DISABLED,"false")}else{this.adapter.addClassForElementIndex(t,f.LIST_ITEM_DISABLED_CLASS);this.adapter.setAttributeForElementIndex(t,c.ARIA_DISABLED,"true")}};n.prototype.setSingleSelectionAtIndex=function(t,i){var e=i===void 0?{}:i,n=e.forceUpdate;if(this.selectedIndex===t&&!n){return}var r=f.LIST_ITEM_SELECTED_CLASS;if(this.useActivatedClass){r=f.LIST_ITEM_ACTIVATED_CLASS}if(this.selectedIndex!==d.UNSET_INDEX){this.adapter.removeClassForElementIndex(this.selectedIndex,r)}this.setAriaForSingleSelectionAtIndex(t);this.setTabindexAtIndex(t);if(t!==d.UNSET_INDEX){this.adapter.addClassForElementIndex(t,r)}this.selectedIndex=t};n.prototype.setAriaForSingleSelectionAtIndex=function(t){if(this.selectedIndex===d.UNSET_INDEX){this.ariaCurrentAttrValue=this.adapter.getAttributeForElementIndex(t,c.ARIA_CURRENT)}var i=this.ariaCurrentAttrValue!==null;var e=i?c.ARIA_CURRENT:c.ARIA_SELECTED;if(this.selectedIndex!==d.UNSET_INDEX){this.adapter.setAttributeForElementIndex(this.selectedIndex,e,"false")}if(t!==d.UNSET_INDEX){var n=i?this.ariaCurrentAttrValue:"true";this.adapter.setAttributeForElementIndex(t,e,n)}};n.prototype.getSelectionAttribute=function(){return this.useSelectedAttr?c.ARIA_SELECTED:c.ARIA_CHECKED};n.prototype.setRadioAtIndex=function(t){var i=this.getSelectionAttribute();this.adapter.setCheckedCheckboxOrRadioAtIndex(t,true);if(this.selectedIndex!==d.UNSET_INDEX){this.adapter.setAttributeForElementIndex(this.selectedIndex,i,"false")}this.adapter.setAttributeForElementIndex(t,i,"true");this.selectedIndex=t};n.prototype.setCheckboxAtIndex=function(t){var i=this.getSelectionAttribute();for(var e=0;e<this.adapter.getListItemCount();e++){var n=false;if(t.indexOf(e)>=0){n=true}this.adapter.setCheckedCheckboxOrRadioAtIndex(e,n);this.adapter.setAttributeForElementIndex(e,i,n?"true":"false")}this.selectedIndex=t};n.prototype.setTabindexAtIndex=function(t){if(this.focusedItemIndex===d.UNSET_INDEX&&t!==0){this.adapter.setAttributeForElementIndex(0,"tabindex","-1")}else if(this.focusedItemIndex>=0&&this.focusedItemIndex!==t){this.adapter.setAttributeForElementIndex(this.focusedItemIndex,"tabindex","-1")}if(!(this.selectedIndex instanceof Array)&&this.selectedIndex!==t){this.adapter.setAttributeForElementIndex(this.selectedIndex,"tabindex","-1")}if(t!==d.UNSET_INDEX){this.adapter.setAttributeForElementIndex(t,"tabindex","0")}};n.prototype.isSelectableList=function(){return this.isSingleSelectionList||this.isCheckboxList||this.isRadioList};n.prototype.setTabindexToFirstSelectedOrFocusedItem=function(){var t=this.getFirstSelectedOrFocusedItemIndex();this.setTabindexAtIndex(t)};n.prototype.getFirstSelectedOrFocusedItemIndex=function(){if(!this.isSelectableList()){return Math.max(this.focusedItemIndex,0)}if(typeof this.selectedIndex==="number"&&this.selectedIndex!==d.UNSET_INDEX){return this.selectedIndex}if(y(this.selectedIndex)&&this.selectedIndex.length>0){return this.selectedIndex.reduce((function(t,i){return Math.min(t,i)}))}return 0};n.prototype.isIndexValid=function(t){var i=this;if(t instanceof Array){if(!this.isCheckboxList){throw new Error("MDCListFoundation: Array of index is only supported for checkbox based list")}if(t.length===0){return true}else{return t.some((function(t){return i.isIndexInRange(t)}))}}else if(typeof t==="number"){if(this.isCheckboxList){throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: "+t)}return this.isIndexInRange(t)||this.isSingleSelectionList&&t===d.UNSET_INDEX}else{return false}};n.prototype.isIndexInRange=function(t){var i=this.adapter.getListItemCount();return t>=0&&t<i};n.prototype.setSelectedIndexOnAction=function(t,i){if(i===void 0){i=true}if(this.isCheckboxList){this.toggleCheckboxAtIndex(t,i)}else{this.setSelectedIndex(t)}};n.prototype.toggleCheckboxAtIndex=function(t,i){var e=this.getSelectionAttribute();var n=this.adapter.isCheckboxCheckedAtIndex(t);if(i){n=!n;this.adapter.setCheckedCheckboxOrRadioAtIndex(t,n)}this.adapter.setAttributeForElementIndex(t,e,n?"true":"false");var r=this.selectedIndex===d.UNSET_INDEX?[]:this.selectedIndex.slice();if(n){r.push(t)}else{r=r.filter((function(i){return i!==t}))}this.selectedIndex=r};n.prototype.focusItemAtIndex=function(t){this.adapter.focusItemAtIndex(t);this.focusedItemIndex=t};n.prototype.toggleAll=function(t){var i=this.adapter.getListItemCount();if(t.length===i){this.setCheckboxAtIndex([])}else{var e=[];for(var n=0;n<i;n++){if(!this.adapter.listItemAtIndexHasClass(n,f.LIST_ITEM_DISABLED_CLASS)||t.indexOf(n)>-1){e.push(n)}}this.setCheckboxAtIndex(e)}};n.prototype.typeaheadMatchItem=function(t,i,e){var n=this;if(e===void 0){e=false}var r={focusItemAtIndex:function(t){n.focusItemAtIndex(t)},focusedItemIndex:i?i:this.focusedItemIndex,nextChar:t,sortedIndexByFirstChar:this.sortedIndexByFirstChar,skipFocus:e,isItemAtIndexDisabled:function(t){return n.adapter.listItemAtIndexHasClass(t,f.LIST_ITEM_DISABLED_CLASS)}};return R(r,this.typeaheadState)};n.prototype.typeaheadInitSortedIndex=function(){return T(this.adapter.getListItemCount(),this.adapter.getPrimaryTextAtIndex)};n.prototype.clearTypeaheadBuffer=function(){S(this.typeaheadState)};return n}(e);
/**
* @license
* Copyright 2018 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/var k=function(i){t(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}Object.defineProperty(e.prototype,"vertical",{set:function(t){this.foundation.setVerticalOrientation(t)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"listElements",{get:function(){return Array.from(this.root.querySelectorAll("."+this.classNameMap[f.LIST_ITEM_CLASS]))},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"wrapFocus",{set:function(t){this.foundation.setWrapFocus(t)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"typeaheadInProgress",{get:function(){return this.foundation.isTypeaheadInProgress()},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"hasTypeahead",{set:function(t){this.foundation.setHasTypeahead(t)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"singleSelection",{set:function(t){this.foundation.setSingleSelection(t)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"selectedIndex",{get:function(){return this.foundation.getSelectedIndex()},set:function(t){this.foundation.setSelectedIndex(t)},enumerable:false,configurable:true});e.attachTo=function(t){return new e(t)};e.prototype.initialSyncWithDOM=function(){this.isEvolutionEnabled=l in this.root.dataset;if(this.isEvolutionEnabled){this.classNameMap=h}else if(n(this.root,c.DEPRECATED_SELECTOR)){this.classNameMap=o}else{this.classNameMap=Object.values(f).reduce((function(t,i){t[i]=i;return t}),{})}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();this.ensureFocusable()};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(c.ARIA_ORIENTATION);this.vertical=t!==c.ARIA_ORIENTATION_HORIZONTAL;var i="."+this.classNameMap[f.LIST_ITEM_CLASS]+":not([tabindex])";var e=c.FOCUSABLE_CHILD_ELEMENTS;var n=this.root.querySelectorAll(i);if(n.length){Array.prototype.forEach.call(n,(function(t){t.setAttribute("tabindex","-1")}))}var r=this.root.querySelectorAll(e);if(r.length){Array.prototype.forEach.call(r,(function(t){t.setAttribute("tabindex","-1")}))}if(this.isEvolutionEnabled){this.foundation.setUseSelectedAttribute(true)}this.foundation.layout()};e.prototype.getPrimaryText=function(t){var i;var e=t.querySelector("."+this.classNameMap[f.LIST_ITEM_PRIMARY_TEXT_CLASS]);if(this.isEvolutionEnabled||e){return(i=e===null||e===void 0?void 0:e.textContent)!==null&&i!==void 0?i:""}var n=t.querySelector("."+this.classNameMap[f.LIST_ITEM_TEXT_CLASS]);return n&&n.textContent||""};e.prototype.initializeListType=function(){var t=this;this.isInteractive=n(this.root,c.ARIA_INTERACTIVE_ROLES_SELECTOR);if(this.isEvolutionEnabled&&this.isInteractive){var i=Array.from(this.root.querySelectorAll(c.SELECTED_ITEM_SELECTOR),(function(i){return t.listElements.indexOf(i)}));if(n(this.root,c.ARIA_MULTI_SELECTABLE_SELECTOR)){this.selectedIndex=i}else if(i.length>0){this.selectedIndex=i[0]}return}var e=this.root.querySelectorAll(c.ARIA_ROLE_CHECKBOX_SELECTOR);var r=this.root.querySelector(c.ARIA_CHECKED_RADIO_SELECTOR);if(e.length){var s=this.root.querySelectorAll(c.ARIA_CHECKED_CHECKBOX_SELECTOR);this.selectedIndex=Array.from(s,(function(i){return t.listElements.indexOf(i)}))}else if(r){this.selectedIndex=this.listElements.indexOf(r)}};e.prototype.setEnabled=function(t,i){this.foundation.setEnabled(t,i)};e.prototype.typeaheadMatchItem=function(t,i){return this.foundation.typeaheadMatchItem(t,i,true)};e.prototype.getDefaultFoundation=function(){var t=this;var i={addClassForElementIndex:function(i,e){var n=t.listElements[i];if(n){n.classList.add(t.classNameMap[e])}},focusItemAtIndex:function(i){var e=t.listElements[i];if(e){e.focus()}},getAttributeForElementIndex:function(i,e){return t.listElements[i].getAttribute(e)},getFocusedElementIndex:function(){return t.listElements.indexOf(document.activeElement)},getListItemCount:function(){return t.listElements.length},getPrimaryTextAtIndex:function(i){return t.getPrimaryText(t.listElements[i])},hasCheckboxAtIndex:function(i){var e=t.listElements[i];return!!e.querySelector(c.CHECKBOX_SELECTOR)},hasRadioAtIndex:function(i){var e=t.listElements[i];return!!e.querySelector(c.RADIO_SELECTOR)},isCheckboxCheckedAtIndex:function(i){var e=t.listElements[i];var n=e.querySelector(c.CHECKBOX_SELECTOR);return n.checked},isFocusInsideList:function(){return t.root!==document.activeElement&&t.root.contains(document.activeElement)},isRootFocused:function(){return document.activeElement===t.root},listItemAtIndexHasClass:function(i,e){return t.listElements[i].classList.contains(t.classNameMap[e])},notifyAction:function(i){t.emit(c.ACTION_EVENT,{index:i},true)},removeClassForElementIndex:function(i,e){var n=t.listElements[i];if(n){n.classList.remove(t.classNameMap[e])}},setAttributeForElementIndex:function(i,e,n){var r=t.listElements[i];if(r){r.setAttribute(e,n)}},setCheckedCheckboxOrRadioAtIndex:function(i,e){var n=t.listElements[i];var r=n.querySelector(c.CHECKBOX_RADIO_SELECTOR);r.checked=e;var s=document.createEvent("Event");s.initEvent("change",true,true);r.dispatchEvent(s)},setTabIndexForListItemChildren:function(i,e){var n=t.listElements[i];var r=c.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;Array.prototype.forEach.call(n.querySelectorAll(r),(function(t){t.setAttribute("tabindex",e)}))}};return new g(i)};e.prototype.ensureFocusable=function(){if(this.isEvolutionEnabled&&this.isInteractive){if(!this.root.querySelector("."+this.classNameMap[f.LIST_ITEM_CLASS]+'[tabindex="0"]')){var t=this.initialFocusIndex();if(t!==-1){this.listElements[t].tabIndex=0}}}};e.prototype.initialFocusIndex=function(){if(this.selectedIndex instanceof Array&&this.selectedIndex.length>0){return this.selectedIndex[0]}if(typeof this.selectedIndex==="number"&&this.selectedIndex!==d.UNSET_INDEX){return this.selectedIndex}var t=this.root.querySelector("."+this.classNameMap[f.LIST_ITEM_CLASS]+":not(."+this.classNameMap[f.LIST_ITEM_DISABLED_CLASS]+")");if(t===null){return-1}return this.getListItemIndex(t)};e.prototype.getListItemIndex=function(t){var i=r(t,"."+this.classNameMap[f.LIST_ITEM_CLASS]+", ."+this.classNameMap[f.ROOT]);if(i&&n(i,"."+this.classNameMap[f.LIST_ITEM_CLASS])){return this.listElements.indexOf(i)}return-1};e.prototype.handleFocusInEvent=function(t){var i=this.getListItemIndex(t.target);this.foundation.handleFocusIn(i)};e.prototype.handleFocusOutEvent=function(t){var i=this.getListItemIndex(t.target);this.foundation.handleFocusOut(i)};e.prototype.handleKeydownEvent=function(t){var i=this.getListItemIndex(t.target);var e=t.target;this.foundation.handleKeydown(t,e.classList.contains(this.classNameMap[f.LIST_ITEM_CLASS]),i)};e.prototype.handleClickEvent=function(t){var i=this.getListItemIndex(t.target);var e=t.target;var r=!n(e,c.CHECKBOX_RADIO_SELECTOR);this.foundation.handleClick(i,r)};return e}(s);export{g as M,k as a,f as c,d as n,c as s};
//# sourceMappingURL=p-c4cd23ca.js.map