87 lines
68 KiB
JavaScript
87 lines
68 KiB
JavaScript
|
import{u as e,v as t,M as i,_ as c,i as l,e as d,t as o,w as n,$ as a,o as s,j as r,x as m,y as p,k as h,r as u}from"./main-ad130be7.js";import{f,l as g}from"./c.3f859915.js";import{C as b,F as _}from"./c.9b92f489.js";import{n as x,a as v,K as y}from"./c.82eccc94.js";import{o as w}from"./c.8e28b461.js";var I=["input","button","textarea","select"],E=function(e){var t=e.target;if(t){var i=(""+t.tagName).toLowerCase();-1===I.indexOf(i)&&e.preventDefault()}};function C(e,t){for(var i=new Map,c=0;c<e;c++){var l=t(c).trim();if(l){var d=l[0].toLowerCase();i.has(d)||i.set(d,[]),i.get(d).push({text:l.toLowerCase(),index:c})}}return i.forEach((function(e){e.sort((function(e,t){return e.index-t.index}))})),i}function A(e,t){var i,c=e.nextChar,l=e.focusItemAtIndex,d=e.sortedIndexByFirstChar,o=e.focusedItemIndex,n=e.skipFocus,a=e.isItemAtIndexDisabled;return clearTimeout(t.bufferClearTimeout),t.bufferClearTimeout=setTimeout((function(){!function(e){e.typeaheadBuffer=""}(t)}),x.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS),t.typeaheadBuffer=t.typeaheadBuffer+c,i=1===t.typeaheadBuffer.length?function(e,t,i,c){var l=c.typeaheadBuffer[0],d=e.get(l);if(!d)return-1;if(l===c.currentFirstChar&&d[c.sortedIndexCursor].index===t){c.sortedIndexCursor=(c.sortedIndexCursor+1)%d.length;var o=d[c.sortedIndexCursor].index;if(!i(o))return o}c.currentFirstChar=l;var n,a=-1;for(n=0;n<d.length;n++)if(!i(d[n].index)){a=n;break}for(;n<d.length;n++)if(d[n].index>t&&!i(d[n].index)){a=n;break}if(-1!==a)return c.sortedIndexCursor=a,d[c.sortedIndexCursor].index;return-1}(d,o,a,t):function(e,t,i){var c=i.typeaheadBuffer[0],l=e.get(c);if(!l)return-1;var d=l[i.sortedIndexCursor];if(0===d.text.lastIndexOf(i.typeaheadBuffer,0)&&!t(d.index))return d.index;var o=(i.sortedIndexCursor+1)%l.length,n=-1;for(;o!==i.sortedIndexCursor;){var a=l[o],s=0===a.text.lastIndexOf(i.typeaheadBuffer,0),r=!t(a.index);if(s&&r){n=o;break}o=(o+1)%l.length}if(-1!==n)return i.sortedIndexCursor=n,l[i.sortedIndexCursor].index;return-1}(d,a,t),-1===i||n||l(i),i}function k(e){return e.typeaheadBuffer.length>0}var S={ACTIVATED:"mdc-select--activated",DISABLED:"mdc-select--disabled",FOCUSED:"mdc-select--focused",INVALID:"mdc-select--invalid",MENU_INVALID:"mdc-select__menu--invalid",OUTLINED:"mdc-select--outlined",REQUIRED:"mdc-select--required",ROOT:"mdc-select",WITH_LEADING_ICON:"mdc-select--with-leading-icon"},T={ARIA_CONTROLS:"aria-controls",ARIA_DESCRIBEDBY:"aria-describedby",ARIA_SELECTED_ATTR:"aria-selected",CHANGE_EVENT:"MDCSelect:change",HIDDEN_INPUT_SELECTOR:'input[type="hidden"]',LABEL_SELECTOR:".mdc-floating-label",LEADING_ICON_SELECTOR:".mdc-select__icon",LINE_RIPPLE_SELECTOR:".mdc-line-ripple",MENU_SELECTOR:".mdc-select__menu",OUTLINE_SELECTOR:".mdc-notched-outline",SELECTED_TEXT_SELECTOR:".mdc-select__selected-text",SELECT_ANCHOR_SELECTOR:".mdc-select__anchor",VALUE_ATTR:"data-value"},O={LABEL_SCALE:.75,UNSET_INDEX:-1,CLICK_DEBOUNCE_TIMEOUT_MS:330},R=function(i){function c(e,l){void 0===l&&(l={});var d=i.call(this,t(t({},c.defaultAdapter),e))||this;return d.disabled=!1,d.isMenuOpen=!1,d.useDefaultValidation=!0,d.customValidity=!0,d.lastSelectedIndex=O.UNSET_INDEX,d.clickDebounceTimeout=0,d.recentlyClicked=!1,d.leadingIcon=l.leadingIcon,d.helperText=l.helperText,d}return e(c,i),Object.defineProperty(c,"cssClasses",{get:function(){return S},enumerable:!1,configurable:!0}),Object.defineProperty(c,"numbers",{get:function(){return O},enumerable:!1,configurable:!0}),Object.defineProperty(c,"strings",{get:function(){return T},enumerable:!1,configurable:!0}),Object.defineProperty(c,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},activateBottomLine:function(){},deactivateBottomLine:function(){},getSelectedIndex:function(){return-1},setSelectedIndex:function(){},hasLabel:function(){return!1},floatLabel:function(){},getLabelWidth:function(){return 0},setLabelRequired:function(){},hasOutline:function(){return!1},notchOutline:function(){},closeOutline:function(){},setRippleCenter:function(){},notifyChange:function(){},setSelectedText:fun
|
||
|
<div
|
||
|
class="mdc-select ${s(e)}">
|
||
|
<input
|
||
|
class="formElement"
|
||
|
name="${this.name}"
|
||
|
.value="${this.value}"
|
||
|
hidden
|
||
|
?disabled="${this.disabled}"
|
||
|
?required=${this.required}>
|
||
|
<!-- @ts-ignore -->
|
||
|
<div class="mdc-select__anchor"
|
||
|
aria-autocomplete="none"
|
||
|
role="combobox"
|
||
|
aria-expanded=${this.menuOpen}
|
||
|
aria-invalid=${!this.isUiValid}
|
||
|
aria-haspopup="listbox"
|
||
|
aria-labelledby=${r(i)}
|
||
|
aria-required=${this.required}
|
||
|
aria-describedby=${r(c)}
|
||
|
@click=${this.onClick}
|
||
|
@focus=${this.onFocus}
|
||
|
@blur=${this.onBlur}
|
||
|
@keydown=${this.onKeydown}>
|
||
|
${this.renderRipple()}
|
||
|
${this.outlined?this.renderOutline():this.renderLabel()}
|
||
|
${this.renderLeadingIcon()}
|
||
|
<span class="mdc-select__selected-text-container">
|
||
|
<span class="mdc-select__selected-text">${this.selectedText}</span>
|
||
|
</span>
|
||
|
<span class="mdc-select__dropdown-icon">
|
||
|
<svg
|
||
|
class="mdc-select__dropdown-icon-graphic"
|
||
|
viewBox="7 10 10 5"
|
||
|
focusable="false">
|
||
|
<polygon
|
||
|
class="mdc-select__dropdown-icon-inactive"
|
||
|
stroke="none"
|
||
|
fill-rule="evenodd"
|
||
|
points="7 10 12 15 17 10">
|
||
|
</polygon>
|
||
|
<polygon
|
||
|
class="mdc-select__dropdown-icon-active"
|
||
|
stroke="none"
|
||
|
fill-rule="evenodd"
|
||
|
points="7 15 12 10 17 15">
|
||
|
</polygon>
|
||
|
</svg>
|
||
|
</span>
|
||
|
${this.renderLineRipple()}
|
||
|
</div>
|
||
|
<mwc-menu
|
||
|
innerRole="listbox"
|
||
|
wrapFocus
|
||
|
class="mdc-select__menu mdc-menu mdc-menu-surface ${s(t)}"
|
||
|
activatable
|
||
|
.fullwidth=${!this.fixedMenuPosition&&!this.naturalMenuWidth}
|
||
|
.open=${this.menuOpen}
|
||
|
.anchor=${this.anchorElement}
|
||
|
.fixed=${this.fixedMenuPosition}
|
||
|
@selected=${this.onSelected}
|
||
|
@opened=${this.onOpened}
|
||
|
@closed=${this.onClosed}
|
||
|
@items-updated=${this.onItemsUpdated}
|
||
|
@keydown=${this.handleTypeahead}>
|
||
|
<slot></slot>
|
||
|
</mwc-menu>
|
||
|
</div>
|
||
|
${this.renderHelperText()}`}renderRipple(){return this.outlined?m:a`
|
||
|
<span class="mdc-select__ripple"></span>
|
||
|
`}renderOutline(){return this.outlined?a`
|
||
|
<mwc-notched-outline
|
||
|
.width=${this.outlineWidth}
|
||
|
.open=${this.outlineOpen}
|
||
|
class="mdc-notched-outline">
|
||
|
${this.renderLabel()}
|
||
|
</mwc-notched-outline>`:m}renderLabel(){return this.label?a`
|
||
|
<span
|
||
|
.floatingLabelFoundation=${f(this.label)}
|
||
|
id="label">${this.label}</span>
|
||
|
`:m}renderLeadingIcon(){return this.icon?a`<mwc-icon class="mdc-select__icon"><div>${this.icon}</div></mwc-icon>`:m}renderLineRipple(){return this.outlined?m:a`
|
||
|
<span .lineRippleFoundation=${g()}></span>
|
||
|
`}renderHelperText(){if(!this.shouldRenderHelperText)return m;const e=this.validationMessage&&!this.isUiValid;return a`
|
||
|
<p
|
||
|
class="mdc-select-helper-text ${s({"mdc-select-helper-text--validation-msg":e})}"
|
||
|
id="helper-text">${e?this.validationMessage:this.helper}</p>`}createAdapter(){return Object.assign(Object.assign({},p(this.mdcRoot)),{activateBottomLine:()=>{this.lineRippleElement&&this.lineRippleElement.lineRippleFoundation.activate()},deactivateBottomLine:()=>{this.lineRippleElement&&this.lineRippleElement.lineRippleFoundation.deactivate()},hasLabel:()=>!!this.label,floatLabel:e=>{this.labelElement&&this.labelElement.floatingLabelFoundation.float(e)},getLabelWidth:()=>this.labelElement?this.labelElement.floatingLabelFoundation.getWidth():0,setLabelRequired:e=>{this.labelElement&&this.labelElement.floatingLabelFoundation.setRequired(e)},hasOutline:()=>this.outlined,notchOutline:e=>{this.outlineElement&&!this.outlineOpen&&(this.outlineWidth=e,this.outlineOpen=!0)},closeOutline:()=>{this.outlineElement&&(this.outlineOpen=!1)},setRippleCenter:e=>{if(this.lineRippleElement){this.lineRippleElement.lineRippleFoundation.setRippleCenter(e)}},notifyChange:async e=>{if(!this.valueSetDirectly&&e===this.value)return;this.valueSetDirectly=!1,this.value=e,await this.updateComplete;const t=new Event("change",{bubbles:!0});this.dispatchEvent(t)},setSelectedText:e=>this.selectedText=e,isSelectAnchorFocused:()=>{const e=this.anchorElement;if(!e)return!1;return e.getRootNode().activeElement===e},getSelectAnchorAttr:e=>{const t=this.anchorElement;return t?t.getAttribute(e):null},setSelectAnchorAttr:(e,t)=>{const i=this.anchorElement;i&&i.setAttribute(e,t)},removeSelectAnchorAttr:e=>{const t=this.anchorElement;t&&t.removeAttribute(e)},openMenu:()=>{this.menuOpen=!0},closeMenu:()=>{this.menuOpen=!1},addMenuClass:()=>{},removeMenuClass:()=>{},getAnchorElement:()=>this.anchorElement,setMenuAnchorElement:()=>{},setMenuAnchorCorner:()=>{const e=this.menuElement;e&&(e.corner="BOTTOM_START")},setMenuWrapFocus:e=>{const t=this.menuElement;t&&(t.wrapFocus=e)},focusMenuItemAtIndex:e=>{const t=this.menuElement;if(!t)return;const i=t.items[e];i&&i.focus()},getMenuItemCount:()=>{const e=this.menuElement;return e?e.items.length:0},getMenuItemValues:()=>{const e=this.menuElement;if(!e)return[];return e.items.map((e=>e.value))},getMenuItemTextAtIndex:e=>{const t=this.menuElement;if(!t)return"";const i=t.items[e];return i?i.text:""},getSelectedIndex:()=>this.index,setSelectedIndex:()=>{},isTypeaheadInProgress:()=>k(this.typeaheadState),typeaheadMatchItem:(e,t)=>{if(!this.menuElement)return-1;const i={focusItemAtIndex:e=>{this.menuElement.focusItemAtIndex(e)},focusedItemIndex:t||this.menuElement.getFocusedItemIndex(),nextChar:e,sortedIndexByFirstChar:this.sortedIndexByFirstChar,skipFocus:!1,isItemAtIndexDisabled:e=>this.items[e].disabled},c=A(i,this.typeaheadState);return-1!==c&&this.select(c),c}})}checkValidity(){const e=this._checkValidity(this.value);if(!e){const e=new Event("invalid",{bubbles:!1,cancelable:!0});this.dispatchEvent(e)}return e}reportValidity(){const e=this.checkValidity();return this.isUiValid=e,e}_checkValidity(e){const t=this.formElement.validity;let i=D(t);if(this.validityTransform){const t=this.validityTransform(e,i);i=Object.assign(Object.assign({},i),t)}return this._validity=i,this._validity.valid}setCustomValidity(e){this.validationMessage=e,this.formElement.setCustomValidity(e)}async getUpdateComplete(){await this._menuUpdateComplete;return await super.getUpdateComplete()}async firstUpdated(){const e=this.menuElement;if(e&&(this._menuUpdateComplete=e.updateComplete,await this._menuUpdateComplete),super.firstUpdated(),this.mdcFoundation.isValid=()=>!0,this.mdcFoundation.setValid=()=>{},this.mdcFoundation.setDisabled(this.disabled),this.validateOnInitialRender&&this.reportValidity(),!this.selected){!this.items.length&&this.slotElement&&this.slotElement.assignedNodes({flatten:!0}).length&&(await new Promise((e=>requestAnimationFrame(e))),await this.layout());const e=this.items.length&&""===this.items[0].value;if(!this.value&&e)return void this.select(0);this.selectByValue(this.value)}this.sortedIndexByFirstChar=C(this.items.length,(e=>this.items[e].text))}onItemsUpdated(){this.sortedIndexByFirstChar=C(this.items.length,(e=
|