@ni/spright-components 1.0.27 → 1.0.28

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.
@@ -3117,12 +3117,32 @@ const lg="nimble-icon-arrow-expander-down",cg="above",dg="underline",hg="outline
3117
3117
  overflow-y: auto;
3118
3118
  width: 100%;
3119
3119
  --ni-private-listbox-padding: ${yl};
3120
- max-height: calc(var(--ni-private-select-max-height) - ${yl});
3120
+ --ni-private-listbox-filter-height: 0px;
3121
+ --ni-private-listbox-loading-indicator-height: 0px;
3122
+ max-height: min(
3123
+ calc(
3124
+ ${yl} + 2 * ${kl} + ${vl} * 10.5 +
3125
+ var(--ni-private-listbox-filter-height) +
3126
+ var(--ni-private-listbox-loading-indicator-height)
3127
+ ),
3128
+ calc(
3129
+ var(--ni-private-listbox-available-viewport-height) -
3130
+ ${yl}
3131
+ )
3132
+ );
3121
3133
  box-shadow: ${Al};
3122
- border: 1px solid ${ll};
3134
+ border: ${kl} solid ${ll};
3123
3135
  background-color: ${Ka};
3124
3136
  }
3125
3137
 
3138
+ .listbox:has(.filter-field) {
3139
+ --ni-private-listbox-filter-height: ${vl};
3140
+ }
3141
+
3142
+ .listbox:has(.loading-container) {
3143
+ --ni-private-listbox-loading-indicator-height: ${vl};
3144
+ }
3145
+
3126
3146
  .listbox slot {
3127
3147
  display: block;
3128
3148
  background: transparent;
@@ -3335,7 +3355,7 @@ const lg="nimble-icon-arrow-expander-down",cg="above",dg="underline",hg="outline
3335
3355
  `))
3336
3356
  class vg{constructor(e,t){this.target=e,this.propertyName=t}bind(e){this.source=e,this.setSourceValue(!1),this.mouseOverHandler=()=>{const e=this.target.offsetWidth<this.target.scrollWidth
3337
3357
  this.setSourceValue(e)},this.mouseOutHandler=()=>{this.setSourceValue(!1)},this.target.addEventListener("mouseover",this.mouseOverHandler),this.target.addEventListener("mouseout",this.mouseOutHandler)}unbind(){this.source=void 0,this.target.removeEventListener("mouseover",this.mouseOverHandler),this.target.removeEventListener("mouseout",this.mouseOutHandler)}setSourceValue(e){this.source[this.propertyName]=e}}function bg(e){return new k("nimble-overflow",vg,e)}let yg=class extends _i{}
3338
- class wg extends($n(yg)){constructor(){super(...arguments),this.proxy=document.createElement("input")}}class xg extends wg{constructor(){super(...arguments),this.appearance=dg,this.errorVisible=!1,this.open=!1,this.filteredOptions=[],this.hasOverflow=!1,this.listboxId=Na("listbox-"),this.maxHeight=0,this.valueUpdatedByInput=!1,this._value="",this.filter="",this.forcedPosition=!1}get value(){return m.track(this,"value"),this._value}set value(e){const t=`${this._value}`
3358
+ class wg extends($n(yg)){constructor(){super(...arguments),this.proxy=document.createElement("input")}}class xg extends wg{constructor(){super(...arguments),this.appearance=dg,this.errorVisible=!1,this.open=!1,this.filteredOptions=[],this.hasOverflow=!1,this.listboxId=Na("listbox-"),this.availableViewportHeight=0,this.valueUpdatedByInput=!1,this._value="",this.filter="",this.forcedPosition=!1}get value(){return m.track(this,"value"),this._value}set value(e){const t=`${this._value}`
3339
3359
  let n=e
3340
3360
  if(this.$fastController.isConnected&&this.options){const t=this.options.findIndex((t=>t.text.toLowerCase()===e.toLowerCase())),i=this.options[this.selectedIndex]?.text,o=this.options[t]?.text
3341
3361
  this.selectedIndex=i!==o?t:this.selectedIndex,n=this.firstSelectedOption?.text||e}t!==n&&(this._value=n,super.valueChanged(t,n),m.notify(this,"value")),this.filter=e,this.filterOptions(),this.selectedIndex=this.options.map((e=>e.text)).indexOf(this.value)}get options(){return m.track(this,"options"),this.filteredOptions?.length?this.filteredOptions:this._options}set options(e){this._options=e,m.notify(this,"options")}get isAutocompleteInline(){return this.autocomplete===Un||this.isAutocompleteBoth}get isAutocompleteList(){return this.autocomplete===jn||this.isAutocompleteBoth}get isAutocompleteBoth(){return this.autocomplete===Wn}slottedOptionsChanged(e,t){const n=this.value
@@ -3365,10 +3385,10 @@ this.selectedIndex=e,!this.dirtyValue&&this.firstSelectedOption&&(this.value=thi
3365
3385
  if(n!==this.selectedIndex)return void(this.selectedIndex=n)
3366
3386
  super.selectedIndexChanged(e,n)}}disabledChanged(e,t){super.disabledChanged&&super.disabledChanged(e,t),this.ariaDisabled=this.disabled?"true":"false"}selectPreviousOption(){!this.disabled&&this.selectedIndex>=0&&(this.selectedIndex-=1)}setPositioning(){if(!this.$fastController.isConnected)return
3367
3387
  const e=this.getBoundingClientRect(),t=window.innerHeight-e.bottom
3368
- this.forcedPosition?this.position=this.positionAttribute:e.top>t?this.position=Hn:this.position=Vn,this.positionAttribute=this.forcedPosition?this.positionAttribute:this.position,this.maxHeight=this.position===Hn?Math.trunc(e.top):Math.trunc(t)}focusAndScrollOptionIntoView(){this.open&&this.contains(document.activeElement)&&(this.control.focus(),this.firstSelectedOption&&requestAnimationFrame((()=>{this.firstSelectedOption?.scrollIntoView({block:"nearest"})})))}openChanged(){this.open?(this.ariaControls=this.listboxId,this.ariaExpanded="true",this.setPositioning(),this.focusAndScrollOptionIntoView(),u.queueUpdate((()=>this.focus()))):(this.ariaControls="",this.ariaExpanded="false"),this.dropdownButton&&(this.dropdownButton.checked=this.open)}placeholderChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.placeholder=this.placeholder??"")}selectedOptionsChanged(e,t){this.$fastController.isConnected&&this._options.forEach((e=>{e.selected=t.includes(e)}))}positionChanged(e,t){this.positionAttribute=t,this.setPositioning()}regionChanged(e,t){this.region&&this.controlWrapper&&(this.region.anchorElement=this.controlWrapper)}controlWrapperChanged(e,t){this.region&&this.controlWrapper&&(this.region.anchorElement=this.controlWrapper)}ariaLabelChanged(e,t){this.updateInputAriaLabel()}maxHeightChanged(){this.updateListboxMaxHeightCssVariable()}updateValue(e){this.$fastController.isConnected&&(this.value=this.firstSelectedOption?.text||this.control.value,this.control.value=this.value),e&&this.$emit("change")}setInputToSelection(){this.firstSelectedOption&&(this.control.value=this.firstSelectedOption.text,this.control.focus())}setInlineSelection(){this.firstSelectedOption&&(this.setInputToSelection(),this.control.setSelectionRange(this.filter.length,this.control.value.length,"backward"))}clearSelectionRange(){const e=this.control.value.length
3388
+ this.forcedPosition?this.position=this.positionAttribute:e.top>t?this.position=Hn:this.position=Vn,this.positionAttribute=this.forcedPosition?this.positionAttribute:this.position,this.availableViewportHeight=this.position===Hn?Math.trunc(e.top):Math.trunc(t)}focusAndScrollOptionIntoView(){this.open&&this.contains(document.activeElement)&&(this.control.focus(),this.firstSelectedOption&&requestAnimationFrame((()=>{this.firstSelectedOption?.scrollIntoView({block:"nearest"})})))}openChanged(){this.open?(this.ariaControls=this.listboxId,this.ariaExpanded="true",this.setPositioning(),this.focusAndScrollOptionIntoView(),u.queueUpdate((()=>this.focus()))):(this.ariaControls="",this.ariaExpanded="false"),this.dropdownButton&&(this.dropdownButton.checked=this.open)}placeholderChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.placeholder=this.placeholder??"")}selectedOptionsChanged(e,t){this.$fastController.isConnected&&this._options.forEach((e=>{e.selected=t.includes(e)}))}positionChanged(e,t){this.positionAttribute=t,this.setPositioning()}regionChanged(e,t){this.region&&this.controlWrapper&&(this.region.anchorElement=this.controlWrapper)}controlWrapperChanged(e,t){this.region&&this.controlWrapper&&(this.region.anchorElement=this.controlWrapper)}ariaLabelChanged(e,t){this.updateInputAriaLabel()}updateValue(e){this.$fastController.isConnected&&(this.value=this.firstSelectedOption?.text||this.control.value,this.control.value=this.value),e&&this.$emit("change")}setInputToSelection(){this.firstSelectedOption&&(this.control.value=this.firstSelectedOption.text,this.control.focus())}setInlineSelection(){this.firstSelectedOption&&(this.setInputToSelection(),this.control.setSelectionRange(this.filter.length,this.control.value.length,"backward"))}clearSelectionRange(){const e=this.control.value.length
3369
3389
  this.control.setSelectionRange(e,e)}syncValue(){const e=this.selectedIndex>-1?this.firstSelectedOption?.text:this.control.value
3370
- this.updateValue(this.value!==e)}updateListboxMaxHeightCssVariable(){this.listbox&&this.listbox.style.setProperty("--ni-private-select-max-height",`${this.maxHeight}px`)}updateInputAriaLabel(){const e=this.shadowRoot?.querySelector(".selected-value")
3371
- this.ariaLabel?e?.setAttribute("aria-label",this.ariaLabel):e?.removeAttribute("aria-label")}emitChangeIfValueUpdated(){this.valueUpdatedByInput&&(this.value!==this.valueBeforeTextUpdate&&this.$emit("change"),this.valueUpdatedByInput=!1)}}e([le],xg.prototype,"appearance",void 0),e([le({attribute:"error-text"})],xg.prototype,"errorText",void 0),e([le({attribute:"error-visible",mode:"boolean"})],xg.prototype,"errorVisible",void 0),e([le({attribute:"autocomplete",mode:"fromView"})],xg.prototype,"autocomplete",void 0),e([le({attribute:"position"})],xg.prototype,"positionAttribute",void 0),e([le({attribute:"open",mode:"boolean"})],xg.prototype,"open",void 0),e([le],xg.prototype,"placeholder",void 0),e([g],xg.prototype,"position",void 0),e([g],xg.prototype,"region",void 0),e([g],xg.prototype,"controlWrapper",void 0),e([g],xg.prototype,"control",void 0),e([g],xg.prototype,"listbox",void 0),e([g],xg.prototype,"dropdownButton",void 0),e([g],xg.prototype,"hasOverflow",void 0),e([g],xg.prototype,"maxHeight",void 0)
3390
+ this.updateValue(this.value!==e)}updateInputAriaLabel(){const e=this.shadowRoot?.querySelector(".selected-value")
3391
+ this.ariaLabel?e?.setAttribute("aria-label",this.ariaLabel):e?.removeAttribute("aria-label")}emitChangeIfValueUpdated(){this.valueUpdatedByInput&&(this.value!==this.valueBeforeTextUpdate&&this.$emit("change"),this.valueUpdatedByInput=!1)}}e([le],xg.prototype,"appearance",void 0),e([le({attribute:"error-text"})],xg.prototype,"errorText",void 0),e([le({attribute:"error-visible",mode:"boolean"})],xg.prototype,"errorVisible",void 0),e([le({attribute:"autocomplete",mode:"fromView"})],xg.prototype,"autocomplete",void 0),e([le({attribute:"position"})],xg.prototype,"positionAttribute",void 0),e([le({attribute:"open",mode:"boolean"})],xg.prototype,"open",void 0),e([le],xg.prototype,"placeholder",void 0),e([g],xg.prototype,"position",void 0),e([g],xg.prototype,"region",void 0),e([g],xg.prototype,"controlWrapper",void 0),e([g],xg.prototype,"control",void 0),e([g],xg.prototype,"listbox",void 0),e([g],xg.prototype,"dropdownButton",void 0),e([g],xg.prototype,"hasOverflow",void 0),e([g],xg.prototype,"availableViewportHeight",void 0)
3372
3392
  const Cg=xg.compose({baseName:"combobox",baseClass:wg,template:(e,t)=>G`
3373
3393
  <template
3374
3394
  aria-disabled="${e=>e.ariaDisabled}"
@@ -3428,6 +3448,7 @@ const Cg=xg.compose({baseName:"combobox",baseClass:wg,template:(e,t)=>G`
3428
3448
  part="listbox"
3429
3449
  role="listbox"
3430
3450
  ?disabled="${e=>e.disabled}"
3451
+ style="--ni-private-listbox-available-viewport-height: ${e=>e.availableViewportHeight}px;"
3431
3452
  ${Pe("listbox")}
3432
3453
  >
3433
3454
  <slot name="option"
@@ -9257,7 +9278,7 @@ yi.getOrCreate().withPrefix("nimble").register(ED())
9257
9278
  const ID="nimble-spinner",_D=e=>e instanceof Ov,TD=e=>e instanceof Lv
9258
9279
  let AD=class extends _i{}
9259
9280
  class DD extends($n(AD)){constructor(){super(...arguments),this.proxy=document.createElement("select")}}const OD=e=>!e.visuallyHidden&&!e.disabled&&!e.hidden,RD=e=>!e.visuallyHidden&&!e.hidden
9260
- class FD extends DD{constructor(){super(...arguments),this.appearance=dg,this.errorVisible=!1,this.filterMode=mg.none,this.clearable=!1,this.loadingVisible=!1,this.displayPlaceholder=!1,this.open=!1,this.listboxId=Na("listbox-"),this.hasOverflow=!1,this.filteredOptions=[],this.filter="",this.maxHeight=0,this._value="",this.forcedPosition=!1}get collapsible(){return!(this.multiple||"number"==typeof this.size)}connectedCallback(){super.connectedCallback(),this.forcedPosition=!!this.positionAttribute,this.open&&this.initializeOpenState()}get value(){return m.track(this,"value"),this._value}set value(e){const t=this._value
9281
+ class FD extends DD{constructor(){super(...arguments),this.appearance=dg,this.errorVisible=!1,this.filterMode=mg.none,this.clearable=!1,this.loadingVisible=!1,this.displayPlaceholder=!1,this.open=!1,this.listboxId=Na("listbox-"),this.hasOverflow=!1,this.filteredOptions=[],this.filter="",this.availableViewportHeight=0,this._value="",this.forcedPosition=!1}get collapsible(){return!(this.multiple||"number"==typeof this.size)}connectedCallback(){super.connectedCallback(),this.forcedPosition=!!this.positionAttribute,this.open&&this.initializeOpenState()}get value(){return m.track(this,"value"),this._value}set value(e){const t=this._value
9261
9282
  let n=e
9262
9283
  if(this.options?.length){const e=this.options.findIndex((e=>e.value===n)),t=this.options[this.selectedIndex]?.value??null,i=this.options[e]?.value??null;-1!==e&&t===i||(n="",this.selectedIndex=e),n=this.firstSelectedOption?.value??n}t===n||this.open&&this.selectedIndex<0||(this._value=n,super.valueChanged(t,n),m.notify(this,"value"),this.updateDisplayValue())}get displayValue(){return m.track(this,"displayValue"),this.firstSelectedOption?.text??""}anchoredRegionChanged(e,t){this.anchoredRegion&&this.control&&(this.anchoredRegion.anchorElement=this.control)}controlChanged(e,t){this.anchoredRegion&&this.control&&(this.anchoredRegion.anchorElement=this.control)}slottedOptionsChanged(e,t){const n=this.value
9263
9284
  this.options.forEach((e=>{const t=m.getNotifier(e)
@@ -9332,7 +9353,7 @@ n!==e&&_D(i)&&(i.activeOption=!1),this.openActiveIndex=e,this.focusAndScrollActi
9332
9353
  this.ariaActiveDescendant=t?.id??""}focusAndScrollActiveOptionIntoView(){const e=this.options[this.openActiveIndex??this.selectedIndex]
9333
9354
  void 0!==e&&this.contains(e)&&(e.focus(),requestAnimationFrame((()=>{e.scrollIntoView({block:"nearest"})})))}getPlaceholderOption(){return this.options.find((e=>e.hidden&&e.disabled))}setPositioning(){if(!this.$fastController.isConnected)return
9334
9355
  const e=this.getBoundingClientRect(),t=window.innerHeight-e.bottom
9335
- this.forcedPosition?this.position=this.positionAttribute:e.top>t?this.position=Hn:this.position=Vn,this.positionAttribute=this.forcedPosition?this.positionAttribute:this.position,this.maxHeight=this.position===Hn?Math.trunc(e.top):Math.trunc(t),this.updateListboxMaxHeightCssVariable()}updateAdjacentSeparatorState(e){const t=this.getPreviousVisibleOptionOrGroup(e),n=this.getNextVisibleOptionOrGroup(e)
9356
+ this.forcedPosition?this.position=this.positionAttribute:e.top>t?this.position=Hn:this.position=Vn,this.positionAttribute=this.forcedPosition?this.positionAttribute:this.position,this.availableViewportHeight=this.position===Hn?Math.trunc(e.top):Math.trunc(t)}updateAdjacentSeparatorState(e){const t=this.getPreviousVisibleOptionOrGroup(e),n=this.getNextVisibleOptionOrGroup(e)
9336
9357
  if(RD(e)){const i=_D(t)
9337
9358
  this.setTopSeparatorState(e,i)
9338
9359
  const o=null!==n
@@ -9352,7 +9373,7 @@ n.forEach((t=>{t.visuallyHidden=!i&&this.isOptionHiddenOrFilteredOut(t),t.visual
9352
9373
  this.filteredOptions=e}getGroupOptions(e){return Array.from(e.children).filter((e=>_D(e))).map((t=>(e.hidden&&_D(t)&&(t.visuallyHidden=!0),t)))}updateValue(e){this.$fastController.isConnected&&(this.value=this.firstSelectedOption?.value??""),e&&(this.$emit("input"),this.$emit("change",this,{bubbles:!0,composed:void 0}))}clearSelect(){const e=this.getPlaceholderOption()
9353
9374
  this.selectedIndex=e?this.options.indexOf(e):-1}setProxyOptions(){this.proxy instanceof HTMLSelectElement&&this.options&&(this.proxy.options.length=0,this.options.forEach((e=>{const t=e.proxy||(e instanceof HTMLOptionElement?e.cloneNode():null)
9354
9375
  t&&this.proxy.options.add(t)})))}filterChanged(){this.filterOptions()}emitFilterInputEvent(){const e={filterText:this.filter}
9355
- this.$emit("filter-input",e,{bubbles:!0})}maxHeightChanged(){this.updateListboxMaxHeightCssVariable()}initializeOpenState(){this.setActiveOption(this.selectedIndex),this.ariaControls=this.listboxId,this.ariaExpanded="true",this.setPositioning(),this.focusAndScrollOptionIntoView()}updateListboxMaxHeightCssVariable(){this.listbox&&this.listbox.style.setProperty("--ni-private-select-max-height",`${this.maxHeight}px`)}}e([le],FD.prototype,"appearance",void 0),e([le({attribute:"position"})],FD.prototype,"positionAttribute",void 0),e([le({attribute:"error-text"})],FD.prototype,"errorText",void 0),e([le({attribute:"error-visible",mode:"boolean"})],FD.prototype,"errorVisible",void 0),e([le({attribute:"filter-mode"})],FD.prototype,"filterMode",void 0),e([le({attribute:"clearable",mode:"boolean"})],FD.prototype,"clearable",void 0),e([le({attribute:"loading-visible",mode:"boolean"})],FD.prototype,"loadingVisible",void 0),e([g],FD.prototype,"displayPlaceholder",void 0),e([le({attribute:"open",mode:"boolean"})],FD.prototype,"open",void 0),e([g],FD.prototype,"position",void 0),e([g],FD.prototype,"control",void 0),e([g],FD.prototype,"scrollableRegion",void 0),e([g],FD.prototype,"filterInput",void 0),e([g],FD.prototype,"anchoredRegion",void 0),e([g],FD.prototype,"hasOverflow",void 0),e([g],FD.prototype,"filteredOptions",void 0),e([g],FD.prototype,"filter",void 0),e([g],FD.prototype,"maxHeight",void 0),e([v],FD.prototype,"collapsible",null),e([v],FD.prototype,"displayValue",null)
9376
+ this.$emit("filter-input",e,{bubbles:!0})}initializeOpenState(){this.setActiveOption(this.selectedIndex),this.ariaControls=this.listboxId,this.ariaExpanded="true",this.setPositioning(),this.focusAndScrollOptionIntoView()}}e([le],FD.prototype,"appearance",void 0),e([le({attribute:"position"})],FD.prototype,"positionAttribute",void 0),e([le({attribute:"error-text"})],FD.prototype,"errorText",void 0),e([le({attribute:"error-visible",mode:"boolean"})],FD.prototype,"errorVisible",void 0),e([le({attribute:"filter-mode"})],FD.prototype,"filterMode",void 0),e([le({attribute:"clearable",mode:"boolean"})],FD.prototype,"clearable",void 0),e([le({attribute:"loading-visible",mode:"boolean"})],FD.prototype,"loadingVisible",void 0),e([g],FD.prototype,"displayPlaceholder",void 0),e([le({attribute:"open",mode:"boolean"})],FD.prototype,"open",void 0),e([g],FD.prototype,"position",void 0),e([g],FD.prototype,"control",void 0),e([g],FD.prototype,"scrollableRegion",void 0),e([g],FD.prototype,"filterInput",void 0),e([g],FD.prototype,"anchoredRegion",void 0),e([g],FD.prototype,"hasOverflow",void 0),e([g],FD.prototype,"filteredOptions",void 0),e([g],FD.prototype,"filter",void 0),e([g],FD.prototype,"availableViewportHeight",void 0),e([v],FD.prototype,"collapsible",null),e([v],FD.prototype,"displayValue",null)
9356
9377
  const ND=FD.compose({baseName:"select",baseClass:Yi,template:(e,t)=>G`
9357
9378
  <template
9358
9379
  class="${e=>[e.collapsible&&"collapsible",e.collapsible&&e.open&&"open",e.disabled&&"disabled",e.collapsible&&e.position].filter(Boolean).join(" ")}"
@@ -9427,6 +9448,7 @@ const ND=FD.compose({baseName:"select",baseClass:Yi,template:(e,t)=>G`
9427
9448
  part="listbox"
9428
9449
  role="listbox"
9429
9450
  ?disabled="${e=>e.disabled}"
9451
+ style="--ni-private-listbox-available-viewport-height: ${e=>e.availableViewportHeight}px;"
9430
9452
  ${Pe("listbox")}
9431
9453
  >
9432
9454
  ${Ve((e=>e.filterMode!==mg.none),G`