-
Notifications
You must be signed in to change notification settings - Fork 0
/
p-da7ae81e.entry.js
5 lines (5 loc) · 18.7 KB
/
p-da7ae81e.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r as t,c as i,h as e,H as r,g as o}from"./p-00e3df8e.js";import{D as a}from"./p-5440a118.js";import{D as s}from"./p-d533ee6a.js";import{h as n}from"./p-3e9fe89f.js";import{D as c,a as d,b as h}from"./p-b9ac3f72.js";import{S as l}from"./p-7ccdab1d.js";import{D as p}from"./p-bcdbf8e6.js";let u=0;const w=class{constructor(e){t(this,e),this.modifiedEvent=i(this,"dwc-modified",7),this.focusedEvent=i(this,"dwc-focused",7),this.blurredEvent=i(this,"dwc-blurred",7),this.spunUpEvent=i(this,"dwc-spun-up",7),this.spunDownEvent=i(this,"dwc-spun-down",7),this.validatedEvent=i(this,"dwc-validated",7),this.spinnerRequiredPropsChangedEvent=i(this,"dwc-spinner-required-props",7),this.inputId="field-"+ ++u,this.isMouseInComponent=!1,this.lastSelectionStart=0,this.lastSelectionEnd=0,this.validationExpressionEngine=new a("BBjEditbox<dwc-field> Validation",["x","value","text","component","control"]),this.isPasswordVisible=!1,this.builtinInvalidMessage="",this.accept="",this.autoValidate=!0,this.autoValidateOnLoad=!1,this.autoWasValidated=!1,this.autocomplete="off",this.autofocus=!1,this.autocorrect="off",this.disabled=!1,this.expanse="m",this.hasFocus=!1,this.helperText=void 0,this.highlightBehaviors=[],this.invalid=!1,this.invalidMessage="",this.label=void 0,this.max=void 0,this.maxlength=void 0,this.min=void 0,this.minlength=void 0,this.multiple=void 0,this.name=void 0,this.pattern=void 0,this.placeholder=void 0,this.passwordReveal=!0,this.readonly=!1,this.required=!1,this.size=void 0,this.spellcheck=!1,this.step=void 0,this.showSpinners=!1,this.spinnable=!1,this.tabTraversable=0,this.type="text",this.validator=void 0,this.validationIcon="dwc:info",this.validationPopoverDistance=6,this.validationPopoverSkidding=0,this.validationPopoverPlacement="bottom",this.validationStyle="popover",this.valid=!1,this.value=""}onValueChanged(){this.autoValidate&&this.validate()}onSpinnerRequiredPropsChanged(){this.spinnerRequiredPropsChangedEvent.emit({disabled:this.disabled,readonly:this.readonly})}connectedCallback(){var t;this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleInput=this.handleInput.bind(this),this.handleSpinUp=this.handleSpinUp.bind(this),this.handleSpinDown=this.handleSpinDown.bind(this),this.handlePasswordToggle=this.handlePasswordToggle.bind(this),null===(t=this.slotsObserver)||void 0===t||t.connect()}disconnectedCallback(){var t;null===(t=this.slotsObserver)||void 0===t||t.disconnect()}componentWillLoad(){this.slotsObserver=new l(this.el,"helper-text")}componentDidLoad(){null!=window.applyFocusVisiblePolyfill&&window.applyFocusVisiblePolyfill(this.el.shadowRoot),this.autoValidateOnLoad&&requestAnimationFrame((()=>this.validate()))}onWindowKeyup(t){9===(t.keyCode?t.keyCode:t.which)&&this.hasFocus&&(this.highlightBehaviors||[]).indexOf(s.KEY)>-1&&this.selectAll()}handleKeyUp(t){switch(t.key){case"ArrowUp":t.preventDefault(),this.spin(!0);break;case"ArrowDown":t.preventDefault(),this.spin(!1)}}handleWheel(t){if(!this.hasFocus)return;let i;if(t.preventDefault(),"touchmove"===t.type){const e=t.touches[0].clientY;i=e<this.lastTouchY?"up":"down",this.lastTouchY=e}else"wheel"!==t.type&&"mousewheel"!==t.type||(i=t.deltaY<0?"up":"down");this.spin("up"===i)}async spin(t){!this.spinnable||this.disabled||this.readonly||(t?this.spunUpEvent.emit():this.spunDownEvent.emit())}async setFocus(){if(this.el.shadowRoot.activeElement!==this.$input){this.$input.disabled=this.disabled,this.$input.focus();try{this.$input.setSelectionRange(this.lastSelectionStart,this.lastSelectionEnd)}catch(t){}!this.isMouseInComponent&&(this.highlightBehaviors||[]).indexOf(s.REQUEST)>-1&&this.selectAll()}}async removeFocus(){this.$input.blur(),this.isMouseInComponent=!1}async selectAll(){if(!this.disabled&&!this.readonly)try{this.$input.setSelectionRange(0,this.$input.value.length)}catch(t){}}async setSelectionRange(t,i){if(!this.disabled&&!this.readonly)try{this.$input.setSelectionRange(t,i)}catch(t){}}async getSelectionRange(){return this.disabled||this.readonly?{start:0,end:0}:{start:this.$input.selectionStart,end:this.$input.selectionEnd}}async setCursorPos(t){if(!this.disabled&&!this.readonly)try{this.$input.setSelectionRange(t,t+1)}catch(t){}}async getCursorPos(){return this.disabled&&this.readonly||!this.hasFocus?0:this.$input.selectionStart}async getPart(t){return new Promise((i=>{i(this.el.shadowRoot.querySelector(`[part="${t}"]`))}))}async validate(){let t=!0;if(this.validator){const i=this.value,e=this.el;t=this.validationExpressionEngine.evaluate(this.validator,{x:i,value:i,text:i,component:e,control:e})}else try{t=this.$input.checkValidity(),this.builtinInvalidMessage=this.$input.validationMessage}catch(t){}return this.invalid=!t,this.validatedEvent.emit(t),this.invalid&&(this.valid=!1),!this.invalid&&this.autoWasValidated&&(this.valid=!0),t}handleMouseEnter(){this.isMouseInComponent=!0}handleMouseLeave(){this.isMouseInComponent=!1}handleFocus(){this.hasFocus=!0;try{this.$input.setSelectionRange(this.lastSelectionStart,this.lastSelectionEnd)}catch(t){}this.isMouseInComponent&&(this.highlightBehaviors||[]).indexOf(s.MOUSE)>-1&&this.selectAll(),this.focusedEvent.emit()}handleBlur(){this.lastSelectionStart=this.$input.selectionStart,this.lastSelectionEnd=this.$input.selectionEnd,this.hasFocus=!1,this.blurredEvent.emit()}handleInput(t){this.value=t.target.value,this.fireModifiedEvent()}handleSpinUp(){this.spin(!0)}handleSpinDown(){this.spin(!1)}handlePasswordToggle(){this.isPasswordVisible=!this.isPasswordVisible}fireModifiedEvent(){this.readonly||this.disabled||requestAnimationFrame((()=>{this.modifiedEvent.emit(this.value)}))}render(){var t,i;const o=!this.validator,a=(null===(t=this.invalidMessage)||void 0===t?void 0:t.trim().length)>0,s=o?a?this.invalidMessage:this.builtinInvalidMessage:a?this.invalidMessage:"",l=this.invalid&&(null==s?void 0:s.trim().length)>0,u=(this.label||"").trim(),w=this.label&&this.label.length>0,b=(null===(i=this.helperText)||void 0===i?void 0:i.trim().length)>0||this.slotsObserver.hasContent("helper-text");return e(r,{key:"63c371035a780571881585beceab3a261a928009","data-has-label":w,class:n({BBjControl:!0,BBjEditBox:!0,"bbj-disabled":this.disabled,"bbj-focused":this.hasFocus,"bbj-readonly":this.readonly,"bbj-hasLabel":w,"bbj-valid":this.valid,"bbj-invalid":this.invalid,"bbj-password":"password"===this.type,"bbj-required":this.required})},e("div",{key:"9fca367bc5036692854f9000e0c215c9c6d63310",part:"control"},u.length>0&&e("label",{key:"f3a05fbb35fd249f2a1b6a4cb99cf9389afd34d9",part:"label",htmlFor:this.inputId,innerHTML:this.label}),e("div",{key:"22f5ebc8805d88bc0367f8ccb70a53ec173c506a",part:"input-wrapper"},e("span",{key:"961a8a39cf254d47cffb27d6ae00e2d4e9538493",part:"prefix"},e("slot",{key:"0dc7be19793cd3653ca308cd3297ebeb33998362",name:"prefix"})),e("input",{key:"eff01c46a339ca6784ba1dfba66d9c4e80193c48",id:this.inputId,ref:t=>this.$input=t,part:"input",accept:this.accept,autocomplete:this.autocomplete,autocorrect:this.autocorrect,autocapitalize:"off",autoFocus:this.autofocus,disabled:this.disabled,max:this.max,maxlength:this.maxlength,min:this.min,minlength:this.minlength,multiple:this.multiple,name:this.name,pattern:this.pattern,placeholder:this.placeholder,readonly:this.readonly,required:this.required,size:this.size,spellcheck:this.spellcheck,step:this.step,type:"password"===this.type&&this.isPasswordVisible?"text":this.type,value:this.value,tabIndex:this.disabled?-1:this.tabTraversable,"aria-describedby":"helper-text",onFocus:this.handleFocus,onBlur:this.handleBlur,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onInput:this.handleInput}),e("span",{key:"c57dda04911443be698a0a426f8d8e5e7e1bbde4",part:"suffix"},e("slot",{key:"6fdad80b26ab0ac0cdd63c71c713aa055288f903",name:"suffix"})),e(p,{key:"41ab938467f90ec2195e43c7624c6f9de91b0c4d",visible:this.showSpinners,disabled:this.disabled||this.readonly,onSpinUp:this.handleSpinUp,onSpinDown:this.handleSpinDown}),this.passwordReveal&&"password"===this.type.toLowerCase()&&e("span",{key:"6a27a3bfd30cb1e611a31013b19e28e52639efb8",part:"password-reveal"},e("dwc-icon-button",this.isPasswordVisible?{part:"eye-icon",pool:"dwc",name:"eye-off",focusVisible:!1,onClick:this.handlePasswordToggle}:{part:"eye-off-icon",pool:"dwc",name:"eye",focusVisible:!1,onClick:this.handlePasswordToggle}))),"popover"===this.validationStyle&&l&&e(h,{key:"37158a5ed3b38e3661d38610de7b0400782dea63",invalidMessage:s,icon:this.validationIcon,hasFocus:this.hasFocus,popoverDistance:this.validationPopoverDistance,popoverPlacement:this.validationPopoverPlacement,popoverSkidding:this.validationPopoverSkidding})),e(d,{key:"95dece45baad48d1a67b4ba6c1f149b0e763e2f5",helperText:this.helperText,visible:b}),"inline"===this.validationStyle&&l&&e(c,{key:"82d5eb3320075a2c098f96331888fa8f08e17bd7",invalidMessage:s,icon:this.validationIcon}))}get el(){return o(this)}static get watchers(){return{value:["onValueChanged"],disabled:["onSpinnerRequiredPropsChanged"],readonly:["onSpinnerRequiredPropsChanged"]}}};w.style='@charset "UTF-8";@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{--dwc-icon-size:1.3em;display:inline-block}:host(:focus),:host(:active){outline:none}: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=control]{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;height:inherit;width:100%}[part=label]{align-items:center;color:var(--dwc-input-label-color, var(--dwc-color-body-text));cursor:var(--dwc-cursor-click);display:none;font-size:90%;font-weight:var(--dwc-input-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=label]::after{color:var(--dwc-input-required-field-indicator-color, var(--dwc-color-primary-text));opacity:0;padding:0 var(--dwc-space-xs);text-align:center;transition:opacity var(--dwc-transition);width:1em}:host([required]) [part=label]::after{content:var(--dwc-input-required-field-indicator, "•");opacity:1}:host([data-has-label]) [part=label]{display:flex}[part=input-wrapper]{align-items:center;background:var(--dwc-input-background, var(--dwc-color-default-light));border:var(--dwc-input-border-width, var(--dwc-border-width)) var(--dwc-input-border-style, var(--dwc-border-style)) var(--dwc-input-border-color, var(--dwc-color-default-dark));border-radius:var(--dwc-border-radius);display:inline-flex;flex:1 1 auto;font-weight:var(--dwc-input-font-weight, var(--dwc-font-weight-semibold));height:100%;justify-content:start;overflow:hidden;position:relative;transition:var(--dwc-transition) background-color, var(--dwc-transition) color, var(--dwc-transition) border-color, var(--dwc-transition) box-shadow;vertical-align:middle;width:100%}:host(:not([disabled]):not([readonly])) [part=input-wrapper]:hover,:host(:not([disabled]):not([readonly])) [part=input-wrapper]:focus,:host(:not([disabled])) [part=input-wrapper]:hover,:host(:not([disabled])) [part=input-wrapper]:focus{background-color:var(--dwc-input-hover-background, var(--dwc-color-default-light));border-color:var(--dwc-input-hover-border-color, var(--dwc-color-primary));color:var(--dwc-input-hover-color, var(--dwc-color-on-default-text-light))}:host([has-focus]:not([disabled])) [part=input-wrapper],:host(.focus-visible:not([disabled])) [part=input-wrapper]{background-color:var(--dwc-input-hover-background, var(--dwc-color-default-light));border-color:var(--dwc-input-hover-border-color, var(--dwc-color-primary));color:var(--dwc-input-hover-color, var(--dwc-color-on-default-text-light))}:host(.focus-visible:not([disabled])) [part=input-wrapper]{box-shadow:var(--dwc-input-focus-ring, var(--dwc-focus-ring-default))}[part~=input]{appearance:none;background:none;border:unset;box-shadow:none;color:var(--dwc-input-color, currentColor);cursor:var(--dwc-cursor-text);flex:1 1 auto;font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;height:100%;line-height:inherit;margin:0;min-width:0;padding:var(--dwc-space);text-align:inherit}[part~=input]::placeholder{color:var(--dwc-input-placeholder-color, var(--dwc-color-gray-60));user-select:none}[part~=input]:focus{outline:none}[part~=input]:-webkit-autofill,[part~=input]:-webkit-autofill:hover,[part~=input]:-webkit-autofill:focus,[part~=input]:-webkit-autofill:active{box-shadow:0 0 0 30px transparent inset !important}[part~=input]::selection{background:var(--dwc-input-selection-background, var(--dwc-color-primary-light));color:var(--dwc-input-selection-color, var(--dwc-color-on-primary-text-light))}:host([has-focus]:not([disabled])) [part=label]{color:var(--dwc-input-label-hover-color, var(--dwc-color-primary-text-light))}[part=prefix],[part=suffix]{cursor:default;flex:0 0 auto;text-align:center;user-select:none}[part=prefix] ::slotted(dwc-icon),[part=prefix] ::slotted(dwc-icon-button),[part=suffix] ::slotted(dwc-icon),[part=suffix] ::slotted(dwc-icon-button){display:inline-flex}[part=prefix] ::slotted(dwc-icon),[part=prefix] ::slotted(dwc-icon-button),[part=prefix] ::slotted(img){padding-left:var(--dwc-space-xs)}[part=suffix] ::slotted(dwc-icon),[part=suffix] ::slotted(dwc-icon-button),[part=suffix] ::slotted(img){padding-right:var(--dwc-space-xs)}:host ::slotted(img[slot=prefix]),:host ::slotted(img[slot=suffix]){align-items:center;display:inline-flex;flex:0 0 auto;height:var(--dwc-icon-size);vertical-align:middle;width:var(--dwc-icon-size)}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([readonly]:not([data-editable])){--dwc-input-background:transparent;--dwc-input-border-color:var(--dwc-color-default-30);--dwc-input-border-style:dashed;--dwc-input-hover-background:var(--dwc-input-background);--dwc-input-hover-color:var(--dwc-input-color);--dwc-input-hover-border-color:var(--dwc-input-border-color)}:host(.bbj-transparent) [part=input-wrapper]{background:transparent !important}:host(.bbj-noborder) [part=input-wrapper]{border-color:transparent !important}:host([data-align-left]){text-align:left}:host([data-align-right]){text-align:right}:host([data-align-center]){text-align:center}:host([data-align-right]) [part=label]{justify-content:flex-end}[hidden]{display:none !important}[part=spinners]{--dwc-icon-size:1em;align-items:stretch;box-sizing:border-box;display:flex;flex-direction:column;height:100%;justify-content:center}[part=spinners]:not([hidden]){margin:var(--dwc-space-xs)}[part=spinners] dwc-icon-button{align-items:center;background:transparent;border:unset;box-sizing:border-box;display:flex;height:50%;margin:0;outline:none;padding:0;width:100%}:host([expanse=xl]){font-size:var(--dwc-font-size-xl)}:host([expanse=xl]) [part=input-wrapper]{height:var(--dwc-size-xl)}:host([expanse=l]){font-size:var(--dwc-font-size-l)}:host([expanse=l]) [part=input-wrapper]{height:var(--dwc-size-l)}:host([expanse=m]){font-size:var(--dwc-font-size-m)}:host([expanse=m]) [part=input-wrapper]{height:var(--dwc-size-m)}:host([expanse=s]){font-size:var(--dwc-font-size-s)}:host([expanse=s]) [part=input-wrapper]{height:var(--dwc-size-s)}:host([expanse=xs]){font-size:var(--dwc-font-size-xs)}:host([expanse=xs]) [part=input-wrapper]{height:var(--dwc-size-xs)}:host([type=text]) [part=input],:host([type=date]) [part=input],:host([type=datetime-local]) [part=input],:host([type=email]) [part=input],:host([type=file]) [part=input],:host([type=month]) [part=input],:host([type=number]) [part=input],:host([type=password]) [part=input],:host([type=search]) [part=input],:host([type=tel]) [part=input],:host([type=time]) [part=input],:host([type=url]) [part=input],:host([type=week]) [part=input]{appearance:none}:host([type=range]) [part=input]{appearance:auto;cursor:var(--dwc-cursor-grab)}:host([type=color]) [part=input]{-moz-appearance:none;-webkit-appearance:none;appearance:none;background-color:transparent;border:0;cursor:var(--dwc-cursor-click);padding:0}:host([type=color]) [part=input]::-webkit-color-swatch{border:0;border-radius:var(--dwc-border-radius)}:host([type=color]) [part=input]::-moz-color-swatch{border:0;border-radius:var(--dwc-border-radius)}:host([type=password]) [part=input]::-ms-reveal{display:none}[part=password-reveal]{align-items:center;cursor:default;display:inline-flex;flex:0 0 auto;height:inherit;padding-right:var(--dwc-space-xs);text-align:center;user-select:none}';export{w as dwc_field}