-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp-0ae4d844.entry.js
5 lines (5 loc) · 15.5 KB
/
p-0ae4d844.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r as t,c as o,w as e,h as i,H as r,g as c}from"./p-0e3693b5.js";import{v as a}from"./p-21e654a9.js";import{D as s}from"./p-5440a118.js";import{h as n}from"./p-3e9fe89f.js";import{D as h,a as d,b as l}from"./p-539a6785.js";import{S as b}from"./p-6a502b3f.js";import"./p-58156e74.js";import"./p-5119ef20.js";let p=0;const w=class{constructor(e){t(this,e),this.basisChangedEvent=o(this,"dwc-changed",7),this.validatedEvent=o(this,"dwc-validated",7),this.listId="list-button-"+ ++p,this.validationExpressionEngine=new s("BBjListButton<dwc-choicebox> Validation",["x","value","text","component","control"]),this.loaded=!1,this.alignment="default",this.autoValidate=!0,this.autoValidateOnLoad=!1,this.autoWasValidated=!1,this.buttonHeight="",this.disabled=!1,this.distance=3,this.expanse="m",this.hasFocus=!1,this.helperText=void 0,this.items=[],this.itemValue="",this.itemLabel="",this.invalid=!1,this.invalidMessage=void 0,this.label=void 0,this.maxRowCount=void 0,this.opened=!1,this.openWidth="",this.openHeight="",this.placement="bottom-start",this.readonly=!1,this.renderItemPrefix=!1,this.selected=void 0,this.skidding=0,this.tickMark=!1,this.typeToSelect=!0,this.typeToSelectTimeout=1e3,this.typeToSelectCaseSensitive=!1,this.validator=void 0,this.validationIcon="dwc:info",this.validationPopoverDistance=6,this.validationPopoverSkidding=0,this.validationPopoverPlacement="bottom",this.validationStyle="popover",this.valid=!1,this.theme="default",this.type="choicebox"}onButtonHeightChanged(t){this.el.style.setProperty("--__dwc-choicebox-button-height",t)}onValueOrLabelChanged(){this.loaded&&this.autoValidate&&this.validate()}onOpenedChanged(t){t?this.open():this.close()}onSelectedChanged(t){if(this.loaded&&this.autoValidate&&this.validate(),!Number.isInteger(t))return this.itemLabel="",void(this.itemValue="");if(this.items.length){const o=this.items[t];o&&(this.itemLabel=o.label.trim(),this.itemValue=o.value)}}connectedCallback(){var t;this.handleButtonFocus=this.handleButtonFocus.bind(this),this.handleButtonBlur=this.handleButtonBlur.bind(this),this.handleDocumentKeydown=this.handleDocumentKeydown.bind(this),this.handleDropdownItemSelected=this.handleDropdownItemSelected.bind(this),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleMenuOpen=this.handleMenuOpen.bind(this),this.handleLabelClick=this.handleLabelClick.bind(this),null===(t=this.slotsObserver)||void 0===t||t.connect()}disconnectedCallback(){var t;null===(t=this.slotsObserver)||void 0===t||t.disconnect()}componentWillLoad(){if(this.slotsObserver=new b(this.el,"helper-text"),!isNaN(this.selected)&&this.items.length&&!this.itemValue&&this.items.length){const t=this.items[this.selected];t&&(this.itemLabel=t.label.trim(),this.itemValue=t.value)}}componentDidLoad(){this.loaded=!0,this.onButtonHeightChanged(this.buttonHeight),this.opened&&this.open(),this.autoValidateOnLoad&&e((()=>this.validate()))}async setFocus(){return this.$button.disabled=this.disabled,this.$button.setFocus()}async removeFocus(){this.$button.removeFocus()}async open(){if(!this.disabled)return document.addEventListener("keydown",this.handleDocumentKeydown,{capture:!0}),this.$dropdown.open()}async close(){return document.removeEventListener("keydown",this.handleDocumentKeydown),this.$dropdown.close()}async toggle(){return this.$dropdown.toggle()}async validate(){let t=!0;if(this.validator){const o=this.itemValue,e=this.el;t=this.validationExpressionEngine.evaluate(this.validator,{x:o,value:o,text:o,component:e,control:e})}return this.invalid=!t,this.validatedEvent.emit(t),this.invalid&&(this.valid=!1),!this.invalid&&this.autoWasValidated&&(this.valid=!0),t}async getPart(t){let o;switch(t){case"button":o=this.$button;break;case"icon":o=this.icon;break;default:o=this.el.querySelector(`[part="${t}"]`)}return new Promise((t=>{t(o)}))}handleDocumentKeydown(t){"Enter"===t.key&&"dwc-listbox"===t.target.nodeName.toLowerCase()&&this.el.shadowRoot.activeElement===this.$button&&(t.preventDefault(),t.stopPropagation(),this.close(),this.setFocus())}handleButtonBlur(){this.hasFocus=!1}handleButtonFocus(){this.hasFocus=!0}handleMenuOpen(t){this.disabled?t.preventDefault():this.opened=!0}handleMenuClose(){this.opened=!1}handleDropdownItemSelected(t){const o=[].concat(t.detail);if(o.length){const t=o[0];if(!t.item)return;this.selected=t.index,this.fireChangedEvent()}}handleLabelClick(){this.setFocus()}fireChangedEvent(){this.basisChangedEvent.emit({index:this.selected,item:this.items[this.selected]})}render(){var t,o,e;const c=this.invalid&&!!(this.invalidMessage&&this.invalidMessage.trim().length>0),a=[].concat(this.selected).filter((t=>"number"==typeof t)),s=Number.isInteger(this.selected)&&(null===(t=this.items[this.selected])||void 0===t?void 0:t.prefix)||"",b=(null===(o=this.helperText)||void 0===o?void 0:o.trim().length)>0||this.slotsObserver.hasContent("helper-text");return i(r,{key:"e4ae52ac963b2fdb1666ac5f07eda2c3ef037060",class:n({BBjControl:!0,BBjListButton:!0,"bbj-disabled":this.disabled,"bbj-focused":this.hasFocus,"bbj-readonly":this.readonly,"bbj-valid":this.valid,"bbj-invalid":this.invalid})},i("div",{key:"de51c21fb9c4155fa2a22360f115399f918ccd20",part:"control"},this.label&&i("div",{key:"1088ed5255a4fcfe7c55967f6b66c572a1cb2ceb",part:"label",id:this.listId,onClick:this.handleLabelClick,innerHTML:this.label}),i("dwc-dropdown",{key:"88174d4c778036697569fc0cb3c3126974b81963",ref:t=>this.$dropdown=t,part:"dropdown",exportparts:"control: dropdown-control, handler:dropdown-handler",alignment:"default"==this.alignment?"left":this.alignment,opened:this.opened,toggleOnClick:!0,toggleOnEnter:!0,openOnArrow:!1,allowDeselection:!1,multiSelection:!1,disabled:this.disabled,readonly:this.readonly,typeToSelect:this.typeToSelect,typeToSelectTimeout:this.typeToSelectTimeout,typeToSelectCaseSensitive:this.typeToSelectCaseSensitive,selected:a,items:this.items,expanse:this.expanse,placement:this.placement,distance:this.distance,skidding:this.skidding,openWidth:this.openWidth,openHeight:this.openHeight,maxRowCount:this.maxRowCount,tickMark:this.tickMark,type:this.type,"onDwc-opened":this.handleMenuOpen,"onDwc-closed":this.handleMenuClose,"onDwc-selected":this.handleDropdownItemSelected},i("dwc-button",{key:"05c2c4a27b34107535da9785fdd040d762ab2d3f",ref:t=>this.$button=t,alignment:"default"==this.alignment?"center":this.alignment,part:"button",exportparts:"control: button-control, label:button-label, suffix:button-suffix, prefix:button-prefix",style:{height:"var(--dwc-choicebox-button-height, var(--__dwc-choicebox-button-height))"},expanse:this.expanse,theme:this.theme,onBlur:this.handleButtonBlur,onFocus:this.handleButtonFocus,"aria-labelledby":this.listId,"aria-describedby":"helper-text",disabled:this.disabled,"data-alignment":this.alignment},this.renderItemPrefix&&s.length>0&&i("div",{key:"af9622f93335176ddd95da801facce7f7f347240",part:"suffix",slot:"left-edge",innerHTML:s}),i("slot",{key:"c1c52375edade77bf0f0e8632a106531c79ca928",name:"prefix",slot:"prefix"}),i("slot",{key:"240ea4fdbcef92895b8f2d69b9e506ed6af652a0",name:"suffix",slot:"suffix"}),i("div",{key:"a424cc96f73d47fa79edc94ab32112f1dcc59ef5",ref:t=>this.icon=t,part:"suffix",slot:"right-edge"},i("span",{key:"29e102efbfcad1d9af58c380100bfbd4f28e2f4a",part:"suffix-separator"}),i("dwc-icon",{key:"a7b2876af8ed651a24e0b963e267e38c0f5fd13f",part:"suffix-icon",pool:"dwc",name:"chevron-down","aria-hidden":"true"})),i("div",{key:"d28526ffa71044420581b8bed21018060433b285",part:"button-label",innerHTML:(null===(e=this.itemLabel)||void 0===e?void 0:e.length)>0?this.itemLabel:String.fromCharCode(65279)})),"popover"===this.validationStyle&&c&&i(l,{key:"4906d080c7a13ee730d086a85b7f386c2e721ec1",invalidMessage:this.invalidMessage,icon:this.validationIcon,hasFocus:this.hasFocus,popoverDistance:this.validationPopoverDistance,popoverPlacement:this.validationPopoverPlacement,popoverSkidding:this.validationPopoverSkidding}))),i(d,{key:"daa7e8fbe7e77862d3f796057bd5332358e7292b",helperText:this.helperText,visible:b}),"inline"===this.validationStyle&&c&&i(h,{key:"39ec04eeb0a75121f82ffbd8ed26e414a6ee4b21",invalidMessage:this.invalidMessage,icon:this.validationIcon}))}get el(){return c(this)}static get watchers(){return{buttonHeight:["onButtonHeightChanged"],itemValue:["onValueOrLabelChanged"],itemLabel:["onValueOrLabelChanged"],opened:["onOpenedChanged"],selected:["onSelectedChanged"]}}};(function(t,o,e,i){var r,c=arguments.length,a=c<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(c<3?r(a):c>3?r(o,e,a):r(o,e))||a);c>3&&a&&Object.defineProperty(o,e,a)})([a(50)],w.prototype,"fireChangedEvent",null),w.style="@media (prefers-reduced-motion: reduce){*,::before,::after{animation-delay:-1ms !important;animation-duration:1ms !important;animation-iteration-count:1 !important;background-attachment:initial !important;scroll-behavior:auto !important;transition-delay:0s !important;transition-duration:0s !important}}:host{box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:relative;-webkit-tap-highlight-color:transparent;text-size-adjust:100%}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{display:inline-block;height:auto;width:inherit}:host([disabled]){cursor:var(--dwc-disabled-cursor);opacity:var(--dwc-disabled-opacity);user-select:none;pointer-events:none}:host([disabled]) *{cursor:var(--dwc-disabled-cursor);user-select:none;pointer-events:none}[part=label]{align-items:center;color:var(--dwc-choicebox-label-color, var(--dwc-color-body-text));cursor:var(--dwc-cursor-click);display:flex;font-size:90%;font-weight:var(--dwc-choicebox-label-font-weight, var(--dwc-font-weight-semibold));gap:0.3rem;height:auto;margin:0;margin-bottom:var(--dwc-space-s);text-align:left;transition:var(--dwc-transition) color}[part=button]{text-align:inherit;width:100%}[part=button]::part(right-edge){padding:0}[part=button]::part(label-wrapper){padding-left:var(--dwc-space-xs);padding-right:var(--dwc-space-xs)}[part=suffix]{align-items:center;align-self:stretch;box-sizing:border-box;cursor:var(--dwc-cursor-click);display:flex;flex-shrink:0;height:100%;width:100%}[part=suffix-icon]{box-sizing:border-box !important;display:flex;padding:var(--dwc-space-xs);transform-origin:center;transition:color var(--dwc-transition) linear, transform var(--dwc-transition)}[part=suffix-separator]{align-self:stretch;background-color:var(--dwc-choicebox-separator-color, var(--dwc-color-default-dark));margin:var(--dwc-space-xs) 0;width:1px}:host([opened]) [part=suffix-icon]{transform:rotate(-180deg)}:host([has-focus]) [part=label],:host([opened]) [part=control] [part=label]{color:var(--dwc-choicebox-label-hover-color, var(--dwc-color-primary-text-light))}dwc-alert{--dwc-alert-padding:var(--dwc-space-s) 0;text-align:left}dwc-alert{--dwc-alert-padding:var(--dwc-space-s) 0;margin-left:calc(var(--dwc-border-radius) / 4 + var(--dwc-border-width) * 2);text-align:left}:host([valid]),:host([invalid]){--dwc-icon-button-color:var(--dwc-input-color);--dwc-icon-button-hover-color:var(--dwc-icon-button-color);--dwc-icon-button-active-color:var(--dwc-icon-button-color)}:host([valid]:not([valid=false])){--dwc-input-label-color:var(--dwc-color-success-text);--dwc-input-label-hover-color:var(--dwc-color-success-text-light);--dwc-input-border-color:var(--dwc-color-success);--dwc-input-hover-border-color:var(--dwc-input-border-color);--dwc-input-focus-ring:var(--dwc-focus-ring-success);--dwc-input-placeholder-color:var(--dwc-color-gray-30);--dwc-input-selection-background:var(--dwc-color-success-light);--dwc-input-selection-color:var(--dwc-color-on-success-text-light);--dwc-input-required-field-indicator-color:var(--dwc-input-label-color)}:host([invalid]:not([invalid=false])){--dwc-input-label-color:var(--dwc-color-danger-text);--dwc-input-label-hover-color:var(--dwc-color-danger-text-light);--dwc-input-border-color:var(--dwc-color-danger);--dwc-input-hover-border-color:var(--dwc-input-border-color);--dwc-input-focus-ring:var(--dwc-focus-ring-danger);--dwc-input-placeholder-color:var(--dwc-color-gray-30);--dwc-input-selection-background:var(--dwc-color-danger-light);--dwc-input-selection-color:var(--dwc-color-on-danger-text-light);--dwc-alert-color:var(--dwc-input-label-color);--dwc-alert-icon-color:var(--dwc-alert-color);--dwc-input-required-field-indicator-color:var(--dwc-input-label-color)}[part=helper-text-wrapper],[part=helper-text-wrapper] ::slotted([slot=helper-text]){color:var(--dwc-color-gray-text-light);cursor:var(--dwc-cursor-text);font-size:var(--dwc-font-size-s);font-weight:var(--dwc-font-weight-normal);line-height:var(--dwc-font-line-height-s);text-align:left;transition:color 0.2s}[part=helper-text-wrapper][data-visible]{margin-left:calc(var(--dwc-border-radius) / 4 + var(--dwc-border-width) * 2);padding-top:var(--dwc-space-s)}:host([theme=primary]),:host([theme=outlined-primary]){--dwc-choicebox-label-hover-color:var(--dwc-color-primary-text-light);--dwc-choicebox-separator-color:var(--dwc-color-primary-dark)}:host([theme=success]),:host([theme=outlined-success]){--dwc-choicebox-label-hover-color:var(--dwc-color-success-text-light);--dwc-choicebox-separator-color:var(--dwc-color-success-dark)}:host([theme=warning]),:host([theme=outlined-warning]){--dwc-choicebox-label-hover-color:var(--dwc-color-warning-text-light);--dwc-choicebox-separator-color:var(--dwc-color-warning-dark)}:host([theme=danger]),:host([theme=outlined-danger]){--dwc-choicebox-label-hover-color:var(--dwc-color-danger-text-light);--dwc-choicebox-separator-color:var(--dwc-color-danger-dark)}:host([theme=gray]),:host([theme=outlined-gray]){--dwc-choicebox-label-hover-color:var(--dwc-color-gray-text-light);--dwc-choicebox-separator-color:var(--dwc-color-gray-dark)}:host([theme=info]),:host([theme=outlined-info]){--dwc-choicebox-label-hover-color:var(--dwc-color-info-text-light);--dwc-choicebox-separator-color:var(--dwc-color-info-dark)}:host([invalid]){--dwc-alert-color:var(--dwc-color-danger-text);--dwc-alert-icon-color:var(--dwc-alert-color);--dwc-choicebox-label-color:var(--dwc-alert-color);--dwc-choicebox-label-hover-color:var(--dwc-choicebox-label-color)}:host([invalid]) [part=button]{--dwc-button-border-color:var(--dwc-color-danger);--dwc-button-hover-border-color:var(--dwc-button-border-color);--dwc-button-focus-border-color:var(--dwc-button-border-color);--dwc-button-outlined-border-color:var(--dwc-button-border-color);--dwc-button-focus-ring:var(--dwc-focus-ring-danger)}:host([expanse=xl]) [part=control]{font-size:var(--dwc-font-size-xl)}:host([expanse=xl]) [part=button]::part(control){height:var(--dwc-choicebox-button-height, var(--__dwc-choicebox-button-height, var(--dwc-size-xl)))}:host([expanse=l]) [part=control]{font-size:var(--dwc-font-size-l)}:host([expanse=l]) [part=button]::part(control){height:var(--dwc-choicebox-button-height, var(--__dwc-choicebox-button-height, var(--dwc-size-l)))}:host([expanse=m]) [part=control]{font-size:var(--dwc-font-size-m)}:host([expanse=m]) [part=button]::part(control){height:var(--dwc-choicebox-button-height, var(--__dwc-choicebox-button-height, var(--dwc-size-m)))}:host([expanse=s]) [part=control]{font-size:var(--dwc-font-size-s)}:host([expanse=s]) [part=button]::part(control){height:var(--dwc-choicebox-button-height, var(--__dwc-choicebox-button-height, var(--dwc-size-s)))}:host([expanse=xs]) [part=control]{font-size:var(--dwc-font-size-xs)}:host([expanse=xs]) [part=button]::part(control){height:var(--dwc-choicebox-button-height, var(--__dwc-choicebox-button-height, var(--dwc-size-xs)))}:host([alignment=right]) [part=label]{justify-content:flex-end}";export{w as dwc_choicebox}