-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunk.9.a8010a5021f02176a2be.js
55 lines (54 loc) · 14.1 KB
/
chunk.9.a8010a5021f02176a2be.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(window.webpackJsonp_ember_auto_import_=window.webpackJsonp_ember_auto_import_||[]).push([[9],{101:function(e,t,s){"use strict"
function i(e){const t=e.closest("form")
if(t){const e=t.querySelector('[type="submit"]:not(disabled)')
e&&e.click()}}s.d(t,"a",(function(){return i}))},46:function(e,t,s){"use strict"
s.r(t),s.d(t,"market_select",(function(){return a}))
var i=s(9),o=s(101),l=s(104)
const a=class{constructor(e){Object(i.g)(this,e),this.marketSelectValueDidChange=Object(i.c)(this,"marketSelectValueDidChange",7),this.marketSelectOpened=Object(i.c)(this,"marketSelectOpened",7),this.marketSelectClosed=Object(i.c)(this,"marketSelectClosed",7),this.value="",this.readonly=!1,this.disabled=!1,this.focused=!1,this.invalid=!1,this.multiselect=!1,this.popoverPlacement="bottom",this.popoverStrategy="absolute",this.listIsActive=!1,this.focusedRowIndex=-1,this.rowsInnerText=[],this.keypresses=[],this.debounceDelay=250,this.setFocusOnMatch=((e,t)=>{let s
return(...i)=>{clearTimeout(s),s=setTimeout((()=>{s=null,e.apply(void 0,i)}),t)}})((()=>{const e=this.keypresses.join(""),t=[...this.rowsInnerText.slice(this.focusedRowIndex+1),...this.rowsInnerText.slice(0,this.focusedRowIndex+1)].find((t=>t.startsWith(e))),s=this.rowsInnerText.findIndex((e=>e.startsWith(t))),i=this.rows[s]
i&&!i.hasAttribute("disabled")&&(this.focusedRowIndex=s,i.click()),this.keypresses=[]}),this.debounceDelay),this.popperInstance=null}valueWatcher(){this.propagateValue()}listSelectionsDidChangeEventHandler({detail:{currentSelectionValues:e,currentSelections:t,newDeselection:s,newSelection:i}}){const o=e.join(",")
if(this.value=o,this.multiselect){const e=t[t.length-1]
this.displaySelectedRow(i||e),this.setFocusedRow(s||i)}else this.displaySelectedRow(i),this.setFocusedRow(i)
this.marketSelectValueDidChange.emit({value:o,newSelectedOption:i,newDeselectedOption:s,currentSelectedOptions:t})}marketListSlotChangeEventHandler(){this.propagateValue()}windowClick(e){this.focused&&!this.el.contains(e.target)&&(this.listIsActive=!1,this.focused=!1,this.marketSelectClosed.emit())}getValues(){return Array.isArray(this.value)?new Set(this.value):new Set(this.multiselect?this.value.split(","):[this.value])}getValuesCount(){return this.getValues().size}get hasMultipleSelections(){return this.multiselect&&this.getValues().size>1}getMultiselectDisplayValue(){const e=this.getValues()
return e.size>1?e.size+" selected":""}displaySelectedRow(e){var t
const s=this.getDisplayedSelectionRow()
if(s&&s.remove(),this.hasMultipleSelections){const e=document.createElement("market-row")
e.setAttribute("slot","displayed-selection"),e.innerText=this.getValuesCount().toLocaleString()+" "
const s=document.createElement("slot")
s.setAttribute("name","selected-translation")
const i=this.el.querySelector('[slot="selected-translation"]')
s.innerHTML=null!==(t=null==i?void 0:i.innerHTML)&&void 0!==t?t:"selected",e.appendChild(s),i&&new MutationObserver((()=>{s.innerHTML=null==i?void 0:i.innerHTML})).observe(i,{characterData:!0,subtree:!0}),this.el.append(e)}else{if(!e)return
const t=e.cloneNode(!0)
t.interactive=!1,t.setAttribute("slot","displayed-selection"),this.el.append(t)}}getDisplayedSelectionRow(){return this.el.querySelector('market-row[slot="displayed-selection"]')}propagateValue(){var e
this.el.querySelector("market-list").value=this.value
const t=this.getValues(),s=this.getDisplayedSelectionRow()
if(!this.value)return void(null===(e=null==s?void 0:s.remove)||void 0===e||e.call(s))
const i=[...this.el.querySelectorAll("market-list market-row")].filter((e=>t.has(e.value)))
this.multiselect&&i.length>1?this.displaySelectedRow():s?s.value!==this.value&&(1===i.length?this.displaySelectedRow(i[0]):s.remove()):1===i.length&&this.displaySelectedRow(i[0])}initRowObservers(){const e=e=>{const t=this.getDisplayedSelectionRow()
!this.multiselect&&t&&t.value===e.value&&(t.innerHTML=e.innerHTML)}
this.el.querySelectorAll("market-list market-row").forEach((t=>{new MutationObserver((()=>e(t))).observe(t,{characterData:!0,subtree:!0})}))}setFocusedRow(e){this.focusedRowIndex=Array.prototype.indexOf.call(this.rows,e)}async toggleList(){this.listIsActive=!this.listIsActive,this.resetFocusedRowIndex(),this.listIsActive?this.marketSelectOpened.emit():this.marketSelectClosed.emit(),this.popperInstance&&await this.popperInstance.update()}async closeList(){this.listIsActive=!1,this.resetFocusedRowIndex(),this.marketSelectClosed.emit()}resetFocusedRowIndex(){this.listIsActive&&!this.getDisplayedSelectionRow()&&(this.focusedRowIndex=-1)}handleKeyDown(e){switch(e.key){case"ArrowDown":this.handleArrowDown(e)
break
case"ArrowUp":this.handleArrowUp(e)
break
case"Enter":this.handleEnter()
break
case"Escape":this.handleEscape()
break
case"Tab":this.handleTab(e)
break
case" ":this.handleSpacebar(e)
break
default:this.typeaheadHandler(e)}e.stopPropagation()}handleArrowDown(e){if(this.listIsActive){let e=1
for(;this.focusedRowIndex+e<this.rows.length;){if(!this.rows[this.focusedRowIndex+e].disabled){this.focusedRowIndex=this.focusedRowIndex+e,this.rows[this.focusedRowIndex].focus()
break}e++}}else this.toggleList()
e.preventDefault()}handleArrowUp(e){if(this.listIsActive){let e=1
for(;this.focusedRowIndex-e<this.rows.length&&this.focusedRowIndex-e>-1;){if(!this.rows[this.focusedRowIndex-e].disabled){this.focusedRowIndex=this.focusedRowIndex-e,this.rows[this.focusedRowIndex].focus()
break}e++}}else this.toggleList()
e.preventDefault()}handleEnter(){this.listIsActive?this.focusedRowIndex>-1?this.multiselect?this.rows[this.focusedRowIndex].focus():(this.toggleList(),this.el.focus()):(this.toggleList(),this.multiselect||this.el.focus()):Object(o.a)(this.el)}handleEscape(){this.listIsActive&&(this.closeList(),this.el.focus())}handleTab(e){this.listIsActive?e.preventDefault():this.focused=!1}handleSpacebar(e){this.listIsActive?this.handleEnter():this.toggleList(),e.preventDefault()}typeaheadHandler(e){this.multiselect||e.key.length>1||e.key.toUpperCase()===e.key.toLowerCase()||(this.storeKeypresses(e),this.setFocusOnMatch())}storeKeypresses(e){this.keypresses=[...this.keypresses,e.key]}handleFocus(){this.readonly||this.disabled||(this.focused=!0)}async handleClick(e){if("MARKET-TOOLTIP"!==e.target.tagName&&!(this.disabled||this.keypresses.length>0)){if(this.multiselect){const t=this.el.querySelector("market-list");(null==t?void 0:t.contains(e.target))||this.toggleList()}else this.toggleList()
this.listIsActive?this.focused=!0:this.el.focus()}}initPopper(){if(null===this.popperInstance){const{popoverPlacement:e,popoverStrategy:t}=this,s=this.el,i=this.el.shadowRoot.querySelector("market-popover")
if(null===i)throw new Error("Could not find popover element")
this.popperInstance=Object(l.a)(s,i,{placement:e,modifiers:[{name:"offset",options:{offset:[0,8]}}],strategy:t})}}componentWillLoad(){const e=this.el.querySelector("market-list")
e.interactive=!0,e.multiselect=this.multiselect,this.propagateValue(),this.rows=this.el.querySelectorAll("market-row"),this.rowsInnerText=[...this.rows].filter((e=>e&&e.innerText)).map((e=>e.innerText.trim().toLowerCase()))}componentDidRender(){this.listIsActive&&this.focusedRowIndex>-1&&this.rows[this.focusedRowIndex].focus()}componentDidLoad(){this.initPopper(),this.initRowObservers()}disconnectedCallback(){this.el.isConnected||this.popperInstance&&(this.popperInstance.destroy(),this.popperInstance=null)}render(){const e=this.disabled?null:"0"
return Object(i.e)(i.a,{role:"listbox","aria-expanded":this.listIsActive,"aria-controls":"popover","aria-haspopup":"true",tabindex:e,onClick:e=>{this.handleClick(e)},onFocus:()=>{this.handleFocus()},onKeyDown:e=>{this.handleKeyDown(e)}},Object(i.e)("div",{class:"label-input-container"},Object(i.e)("slot",null),Object(i.e)("slot",{name:"displayed-selection"})),Object(i.e)("market-popover",{part:"popover",tabindex:e},Object(i.e)("slot",{name:"list",onSlotchange:()=>this.propagateValue()})),Object(i.e)("slot",{name:"trailing-accessory"}),this.listIsActive?Object(i.e)("svg",{class:"caret",width:"12",height:"8",viewBox:"0 0 12 8",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(i.e)("path",{d:"M11 7L6 2L1 7",stroke:"black","stroke-width":"2"})):Object(i.e)("svg",{class:"caret",width:"12",height:"8",viewBox:"0 0 12 8",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(i.e)("path",{d:"M1 1L6 6L11 1",stroke:"black","stroke-width":"2"})))}get el(){return Object(i.d)(this)}static get watchers(){return{value:["valueWatcher"]}}}
a.style=':host,::slotted(*),*{box-sizing:border-box}:host([disabled]){cursor:not-allowed !important}:host([disabled]) *,:host([disabled]) ::slotted(*){cursor:not-allowed !important;pointer-events:none !important}:host{--animation-speed:0.2s;--horizontal-input-buffer:calc(var(--field-empty-phase-horizontal-padding-size) * 2);border-radius:var(--field-border-radius);border-style:solid;border-width:var(--field-border-size);display:block;cursor:pointer;background-color:var(--field-normal-state-background-color);color:var(--field-normal-state-input-color);border-color:var(--field-normal-state-normal-validity-border-color);}:host([invalid]){border-color:var(--field-normal-state-invalid-validity-border-color)}:host(:hover){background-color:var(--field-hover-state-background-color);color:var(--field-hover-state-input-color);border-color:var(--field-hover-state-normal-validity-border-color)}:host{}:host([invalid]:hover){border-color:var(--field-hover-state-invalid-validity-border-color)}:host([focused]){color:var(--field-focus-state-input-color);border-color:var(--field-focus-state-normal-validity-border-color);box-shadow:inset 0 0 0 calc(var(--field-focus-state-border-size) - var(--field-border-size))\n var(--field-focus-state-normal-validity-border-color)}:host{}:host(:focus){outline:none}:host{}:host([focused][invalid]){border-color:var(--field-focus-state-invalid-validity-border-color)}:host{}:host([disabled]){background-color:var(--field-disabled-state-background-color) !important;border-color:var(--field-disabled-state-border-color) !important;color:var(--field-disabled-state-input-color) !important;cursor:not-allowed !important}:host{}:host .label-input-container{flex-grow:1;--bottom-float-padding:calc(\n var(--field-input-leading) + var(--field-float-phase-vertical-padding-size) +\n var(--field-float-phase-label-margin-bottom-size) - calc(var(--field-border-size) * 2)\n );--field-empty-phase-label-text-size-unitless:16;--field-float-phase-label-text-size-unitless:14;--right-float-padding:calc(\n (var(--field-empty-phase-label-text-size-unitless) - var(--field-float-phase-label-text-size-unitless)) /\n var(--field-empty-phase-label-text-size-unitless) * 100%\n );transition:padding var(--animation-speed);padding:var(--field-float-phase-vertical-padding-size) var(--right-float-padding) var(--bottom-float-padding)\n var(--field-float-phase-horizontal-padding-size);position:relative}:host{font-size:var(--field-input-size);font-weight:var(--field-input-weight);line-height:var(--field-input-tracking)}:host([value=""]:not([focused]):not([autofilled])) .label-input-container{padding:calc(var(--field-empty-phase-vertical-padding-size) - var(--field-border-size))\n var(--field-float-phase-horizontal-padding-size)}:host{}:host ::slotted(label){display:block;font-size:var(--field-empty-phase-label-text-size);font-weight:var(--field-empty-phase-label-text-weight);line-height:var(--field-empty-phase-label-text-leading);min-height:var(--field-empty-phase-label-text-leading);transform:scale(1);transform-origin:top left;transition:all var(--animation-speed)}:host(:not([value=""])) ::slotted(label),:host([value=""]:not([focused])[autofilled]) ::slotted(label),:host([focused]) ::slotted(label){position:relative;font-size:var(--field-float-phase-label-text-size);font-weight:var(--field-float-phase-label-text-weight);line-height:var(--field-float-phase-label-text-leading);min-height:var(--field-float-phase-label-text-leading);letter-spacing:var(--field-float-phase-label-text-tracking);margin:0}:host{}:host([value=""]) ::slotted(label){color:var(--field-normal-state-empty-phase-label-color)}:host{}:host(:not([value=""])) ::slotted(label),:host([value=""][autofilled]) ::slotted(label){color:var(--field-normal-state-float-phase-label-color)}:host{}:host(:hover) ::slotted(label){color:var(--field-hover-state-empty-phase-label-color)}:host{}:host(:not([value=""]):hover) ::slotted(label),:host([value=""][autofilled]:hover) ::slotted(label){color:var(--field-hover-state-float-phase-label-color)}:host{}:host([focused]) ::slotted(label){color:var(--field-focus-state-float-phase-label-color)}:host{}:host([value=""][disabled]) ::slotted(label){color:var(--field-disabled-state-empty-phase-label-color);cursor:not-allowed !important}:host{}:host(:not([value=""])[disabled]) ::slotted(label),:host([value=""][autofilled][disabled]) ::slotted(label){color:var(--field-disabled-state-float-phase-label-color)}:host input,:host ::slotted(input){background-color:transparent;border:none;bottom:var(--field-float-phase-vertical-padding-size);height:var(--field-input-leading);padding:0;position:absolute;width:calc(100% - var(--horizontal-input-buffer));font-family:inherit;font-size:inherit;font-weight:inherit;color:inherit}:host input:focus,:host ::slotted(input:focus){outline:none}:host input:disabled,:host ::slotted(input:disabled){cursor:not-allowed !important}:host{display:flex;align-items:center;position:relative}market-popover{visibility:hidden;width:100%;min-width:200px;max-height:464px;z-index:1;line-height:var(--row-medium-size-text-leading)}:host([aria-expanded]) market-popover{visibility:visible}.caret{margin-right:var(--field-float-phase-horizontal-padding-size)}.caret path{stroke:var(--select-caret-color)}::slotted(label){cursor:pointer}::slotted(market-row[slot="displayed-selection"]){bottom:var(--field-float-phase-vertical-padding-size);cursor:pointer;min-height:var(--field-input-leading);position:absolute;width:calc(100% - calc(var(--field-empty-phase-horizontal-padding-size) * 2));white-space:nowrap;overflow:hidden;text-overflow:ellipsis\n\n }::slotted(market-row[slot="displayed-selection"])::before,::slotted(market-row[slot="displayed-selection"])::after{display:none}market-row::part(container){padding:0}::slotted(market-row){margin:0}'}}])
//# sourceMappingURL=https://multipassui-production-c.squarecdn.com/assets/chunk.9.a8010a5021f02176a2be-e7e94069ebb610d36713f82b90e09985.map