@ni/ok-components 1.18.1 → 1.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21565,7 +21565,7 @@ const Rtt=It`
21565
21565
  `
21566
21566
  class Ltt extends qe{}class Ptt extends(Rn(Ltt)){constructor(){super(...arguments),this.proxy=Object.assign(document.createElement("select"),{multiple:!0})}}class Btt extends Ptt{constructor(){super(...arguments),this.appearance=vb,this.label="",this.placeholder="",this.filterable=!1,this.clearable=!1,this.open=!1,this.options=[],this.selectedValues=[],this.filter="",this.activeIndex=-1,this.keyboardNavigation=!1,this.controlId=xn("ok-fv-multi-select-"),this.listboxId=`${this.controlId}-listbox`,this.formDisabled=!1,this.updatePopupLayout=()=>{if(this.open&&this.isConnected){const t=this.controlField.getBoundingClientRect(),e=Math.max(0,t.top,window.innerHeight-t.bottom)
21567
21567
  this.style.setProperty("--ok-fv-multi-select-available-height",`${e}px`),this.region.update()}},this.documentClickHandler=t=>{this.open&&!t.composedPath().includes(this)&&(this.open=!1)}}get effectiveDisabled(){return this.disabled||this.formDisabled}get visibleOptions(){const t=nO(this.filter)
21568
- return this.options.filter(e=>!this.filterable||nO(e.label).includes(t))}get displayValue(){return this.selectedValues.map(t=>this.options.find(e=>e.value===t)?.label??t).join(", ")}get activeOptionId(){return this.open&&this.activeIndex>=0?`${this.listboxId}-${this.activeIndex}`:null}connectedCallback(){this.initialSelectedValues??(this.initialSelectedValues=[...this.selectedValues]),super.connectedCallback(),this.syncFormValue(),document.addEventListener("click",this.documentClickHandler),window.addEventListener("resize",this.updatePopupLayout),window.addEventListener("scroll",this.updatePopupLayout,!0),this.resetActiveOption(),this.open&&this.openChanged()}disconnectedCallback(){document.removeEventListener("click",this.documentClickHandler),window.removeEventListener("resize",this.updatePopupLayout),window.removeEventListener("scroll",this.updatePopupLayout,!0),super.disconnectedCallback()}disabledChanged(t,e){super.disabledChanged?.(t,e),this.disabled&&(this.open=!1),this.syncFormValue()}formDisabledCallback(t){this.formDisabled=t,t&&(this.open=!1),this.syncFormValue()}selectedValuesChanged(){this.syncFormValue()}nameChanged(t,e){super.nameChanged?.(t,e),this.syncFormValue()}valueChanged(){this.syncFormValue()}validate(){this.effectiveDisabled?this.setValidity({}):super.validate(this.control)}formResetCallback(){this.open=!1,this.selectedValues=[...this.initialSelectedValues??[]]}async openChanged(){if(!this.open||!this.effectiveDisabled)return this.open?void(this.$fastController.isConnected&&(this.region.anchorElement=this.controlField,this.updatePopupLayout(),this.resetActiveOption(),await y.nextUpdate(),this.focusPopup())):(this.$fastController.isConnected&&(this.region.anchorElement=null),this.filter="",this.activeIndex=-1,void(this.keyboardNavigation=!1))
21568
+ return this.options.filter(e=>!this.filterable||nO(e.label).includes(t))}get displayValue(){return this.selectedValues.map(t=>this.options.find(e=>e.value===t)?.label??t).join(", ")}get activeOptionId(){return this.open&&this.activeIndex>=0?`${this.listboxId}-${this.activeIndex}`:null}connectedCallback(){this.initialSelectedValues??(this.initialSelectedValues=[...this.selectedValues]),super.connectedCallback(),this.syncFormValue(),document.addEventListener("click",this.documentClickHandler),window.addEventListener("resize",this.updatePopupLayout),window.addEventListener("scroll",this.updatePopupLayout,!0),this.resetActiveOption(),this.open&&this.openChanged()}disconnectedCallback(){document.removeEventListener("click",this.documentClickHandler),window.removeEventListener("resize",this.updatePopupLayout),window.removeEventListener("scroll",this.updatePopupLayout,!0),super.disconnectedCallback()}disabledChanged(t,e){super.disabledChanged?.(t,e),this.disabled&&(this.open=!1),this.syncFormValue()}formDisabledCallback(t){this.formDisabled=t,t&&(this.open=!1),this.syncFormValue()}selectedValuesChanged(){this.syncFormValue()}nameChanged(t,e){super.nameChanged?.(t,e),this.syncFormValue()}valueChanged(){this.syncFormValue()}validate(){this.effectiveDisabled?this.setValidity({}):super.validate(this.control)}formResetCallback(){this.open=!1,this.selectedValues=[...this.initialSelectedValues??[]]}async openChanged(){if(!this.open||!this.effectiveDisabled)return this.open?void(this.$fastController.isConnected&&(this.control.focus(),this.region.anchorElement=this.controlField,this.updatePopupLayout(),this.resetActiveOption(),await y.nextUpdate(),this.focusPopup())):(this.$fastController.isConnected&&(this.region.anchorElement=null),this.filter="",this.activeIndex=-1,void(this.keyboardNavigation=!1))
21569
21569
  this.open=!1}focusPopup(){this.open&&this.isConnected&&((this.filterable?this.filterInput:this.listbox)?.focus(),this.scrollActiveOptionIntoView())}optionsChanged(){this.resetActiveOption()}filterChanged(){this.resetActiveOption()}async filterableChanged(){if(this.filter="",this.open){if(this.resetActiveOption(),!this.filterable)return void this.listbox?.focus()
21570
21570
  await y.nextUpdate(),this.focusPopup()}}toggleOption(t){this.effectiveDisabled||t.disabled||(this.selectedValues=this.selectedValues.includes(t.value)?this.selectedValues.filter(e=>e!==t.value):[...this.selectedValues,t.value],this.$emit("input"),this.$emit("change"))}clearSelection(){!this.effectiveDisabled&&this.clearable&&0!==this.selectedValues.length&&(this.open=!1,this.selectedValues=[],this.control.focus(),this.$emit("input"),this.$emit("change"))}handleInput(t){this.filter=t.target.value,t.stopPropagation()}handleControlKeydown(t){return this.keyboardNavigation=!0,"Escape"!==t.key||this.open||this.clearSelection(),"ArrowDown"!==t.key&&"ArrowUp"!==t.key||(this.open=!this.effectiveDisabled,"ArrowUp"===t.key&&this.moveActiveOption(-1,!0),!1)}handlePopupKeydown(t){if(t.isComposing)return!0
21571
21571
  if("Escape"===t.key||"Tab"===t.key)return this.open=!1,y.processUpdates(),this.control.focus(),"Tab"===t.key