@ni/ok-components 1.18.0 → 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.
@@ -21323,6 +21323,10 @@ const Rtt=It`
21323
21323
  box-shadow: ${ed};
21324
21324
  }
21325
21325
 
21326
+ .anchored-region.top .popup {
21327
+ flex-direction: column-reverse;
21328
+ }
21329
+
21326
21330
  .filter-field {
21327
21331
  flex-shrink: 0;
21328
21332
  display: flex;
@@ -21332,6 +21336,10 @@ const Rtt=It`
21332
21336
  box-shadow: 0 2px rgba(${hc}, 0.1);
21333
21337
  }
21334
21338
 
21339
+ .anchored-region.top .filter-field {
21340
+ box-shadow: 0 -2px rgba(${hc}, 0.1);
21341
+ }
21342
+
21335
21343
  .filter-icon {
21336
21344
  flex-shrink: 0;
21337
21345
  margin-left: ${Vc};
@@ -21357,16 +21365,31 @@ const Rtt=It`
21357
21365
  .listbox {
21358
21366
  min-height: 0;
21359
21367
  max-height: 240px;
21368
+ box-sizing: border-box;
21369
+ padding: ${Vc};
21370
+ padding-top: calc(${Vc} + 2px);
21371
+ scroll-padding: calc(${Vc} + 2px) ${Vc} ${Vc};
21360
21372
  overflow-y: auto;
21361
21373
  outline: none;
21362
21374
  }
21363
21375
 
21376
+ .anchored-region.top .filter-field + .listbox:has(.option) {
21377
+ padding-top: ${Vc};
21378
+ padding-bottom: calc(${Vc} + 2px);
21379
+ scroll-padding-top: ${Vc};
21380
+ scroll-padding-bottom: calc(${Vc} + 2px);
21381
+ }
21382
+
21383
+ .popup:has(.empty) .listbox {
21384
+ padding: 0;
21385
+ }
21386
+
21364
21387
  .option {
21365
21388
  display: flex;
21366
21389
  align-items: center;
21367
21390
  gap: ${Vc};
21368
21391
  min-height: ${Bc};
21369
- padding: 0 ${Hc};
21392
+ padding: 0 ${zc};
21370
21393
  cursor: pointer;
21371
21394
  }
21372
21395
 
@@ -21386,11 +21409,8 @@ const Rtt=It`
21386
21409
  }
21387
21410
 
21388
21411
  .keyboard-navigation .option.active {
21389
- background: ${rc};
21390
- }
21391
-
21392
- .keyboard-navigation .option.active:hover {
21393
- background: ${lc};
21412
+ outline: 2px solid ${vc};
21413
+ outline-offset: -2px;
21394
21414
  }
21395
21415
 
21396
21416
  :host(:is([disabled], :disabled)) .control-field,
@@ -21406,10 +21426,16 @@ const Rtt=It`
21406
21426
 
21407
21427
  .empty {
21408
21428
  flex-shrink: 0;
21409
- padding: ${Hc};
21429
+ display: flex;
21430
+ align-items: center;
21431
+ box-sizing: border-box;
21432
+ height: ${Bc};
21433
+ padding: ${Vc} ${zc};
21410
21434
  }
21411
21435
  `.withBehaviors(Rh(Go,It`
21412
- .filter-field {
21436
+ .filter-field,
21437
+ .listbox,
21438
+ .empty {
21413
21439
  background: rgba(255, 255, 255, 0.15);
21414
21440
  }
21415
21441
  `)),Ftt=Q`
@@ -21539,7 +21565,7 @@ const Rtt=It`
21539
21565
  `
21540
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)
21541
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)
21542
- 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))
21543
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()
21544
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
21545
21571
  if("Escape"===t.key||"Tab"===t.key)return this.open=!1,y.processUpdates(),this.control.focus(),"Tab"===t.key