@ni/spright-components 1.0.34 → 1.0.36

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.
@@ -3138,18 +3138,23 @@ const fg="nimble-icon-arrow-expander-down",mg="above",gg="underline",vg="outline
3138
3138
  flex-direction: column;
3139
3139
  overflow-y: auto;
3140
3140
  width: 100%;
3141
+ --ni-private-listbox-visible-option-count: 10.5;
3142
+ --ni-private-listbox-anchor-element-gap: ${_l};
3141
3143
  --ni-private-listbox-padding: ${_l};
3142
3144
  --ni-private-listbox-filter-height: 0px;
3143
3145
  --ni-private-listbox-loading-indicator-height: 0px;
3144
3146
  max-height: min(
3145
3147
  calc(
3146
- ${_l} + 2 * ${El} + ${kl} * 10.5 +
3147
- var(--ni-private-listbox-filter-height) +
3148
- var(--ni-private-listbox-loading-indicator-height)
3148
+ var(--ni-private-listbox-anchor-element-gap) +
3149
+ 2 * ${El} +
3150
+ var(--ni-private-listbox-padding) +
3151
+ ${kl} * var(--ni-private-listbox-visible-option-count) +
3152
+ var(--ni-private-listbox-filter-height) +
3153
+ var(--ni-private-listbox-loading-indicator-height)
3149
3154
  ),
3150
3155
  calc(
3151
- var(--ni-private-listbox-available-viewport-height) -
3152
- ${_l}
3156
+ var(--ni-private-listbox-available-viewport-height) -
3157
+ var(--ni-private-listbox-anchor-element-gap)
3153
3158
  )
3154
3159
  );
3155
3160
  box-shadow: ${Ll};
@@ -7261,8 +7266,9 @@ const U_="nimble-toolbar",q_="Bold",j_="Italics",W_="Bulleted List",G_="Numbered
7261
7266
  }
7262
7267
 
7263
7268
  .listbox {
7269
+ --ni-private-listbox-visible-option-count: 5.5;
7270
+ --ni-private-listbox-anchor-element-gap: 0px;
7264
7271
  min-width: ${Fl};
7265
- max-height: calc(5.5 * ${kl});
7266
7272
  }
7267
7273
  `,Q_=Q`
7268
7274
  <template>
@@ -7283,6 +7289,8 @@ const U_="nimble-toolbar",q_="Bold",j_="Italics",W_="Bulleted List",G_="Numbered
7283
7289
  role="listbox"
7284
7290
  @click="${(t,e)=>t.clickHandler(e.event)}"
7285
7291
  ?disabled="${t=>t.disabled}"
7292
+ style="--ni-private-listbox-available-viewport-height: ${t=>t.availableViewportHeight}px;"
7293
+ ${Ut("listbox")}
7286
7294
  >
7287
7295
  <slot name="option"
7288
7296
  ${ie({filter:t=>t instanceof HTMLElement&&qn.slottedOptionFilter(t),flatten:!0,property:"slottedOptions"})}
@@ -7292,16 +7300,17 @@ const U_="nimble-toolbar",q_="Bold",j_="Italics",W_="Bulleted List",G_="Numbered
7292
7300
  </${Rh}>
7293
7301
  </template>
7294
7302
  `,tM=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()
7295
- class eM extends Fi{constructor(){super(...arguments),this.filter="",this.filteredOptions=[],this.anchorElementIntersectionObserver=new IntersectionObserver((t=>{t[0]?.isIntersecting||this.setOpen(!1)}),{threshold:1,root:document})}close(){this.setOpen(!1)}get options(){return x.track(this,"options"),this.filteredOptions?.length?this.filteredOptions:[]}set options(t){this._options=t,x.notify(this,"options")}show(t){this.filter=t.filter,this.anchorElement=t.anchorNode,this.setOpen(!0),this.filterOptions()}keydownHandler(t){if(!this.open)return!1
7303
+ class eM extends Fi{constructor(){super(...arguments),this.availableViewportHeight=0,this.filter="",this.filteredOptions=[],this.anchorElementIntersectionObserver=new IntersectionObserver((t=>{t[0]?.isIntersecting||this.setOpen(!1)}),{threshold:1,root:document})}close(){this.setOpen(!1)}get options(){return x.track(this,"options"),this.filteredOptions?.length?this.filteredOptions:[]}set options(t){this._options=t,x.notify(this,"options")}show(t){const e=t.anchorNode.getBoundingClientRect().bottom
7304
+ this.availableViewportHeight=Math.trunc(window.innerHeight-e),this.filter=t.filter,this.anchorElement=t.anchorNode,this.setOpen(!0),this.filterOptions()}keydownHandler(t){if(!this.open)return!1
7296
7305
  switch(t.key){case Pa:case Ta:{if(!this.hasSelectableOptions)return!1
7297
7306
  const t={href:this.firstSelectedOption.value,displayName:this.firstSelectedOption.text}
7298
- return this.emitMentionSelected(t),!0}case Oa:return this.setOpen(!1),!1
7307
+ return this.$emit("mention-selected",t),this.setOpen(!1),!0}case Oa:return this.setOpen(!1),!1
7299
7308
  default:return super.keydownHandler(t),!1}}filterOptions(){if(this.filter){const t=tM(this.filter)
7300
7309
  this.filteredOptions=this._options.filter((e=>tM(e.text).includes(t)))}else this.filteredOptions=this._options
7301
7310
  this._options.forEach((t=>{t.hidden=!this.filteredOptions.includes(t)})),this.filteredOptions.length?(this.selectedOptions=[this.filteredOptions[0]],this.selectedIndex=this.options.indexOf(this.firstSelectedOption)):(this.selectedOptions=[],this.selectedIndex=-1)}slottedOptionsChanged(t,e){super.slottedOptionsChanged(t,e),this.filterOptions()}clickHandler(t){const e=t.target.closest("option,[role=option]")
7302
7311
  if(!e||e.disabled)return!1
7303
7312
  const n={href:e.value,displayName:e.text}
7304
- return this.emitMentionSelected(n),!0}anchorElementChanged(t,e){t&&this.anchorElementIntersectionObserver.unobserve(t),this.region&&this.anchorElement&&(this.region.anchorElement=this.anchorElement,this.region.update(),this.anchorElementIntersectionObserver.observe(e))}regionChanged(){this.regionNotifier&&this.regionNotifier.unsubscribe(this),this.regionNotifier=x.getNotifier(this.region),this.regionNotifier.subscribe(this)}handleChange(t,e){super.handleChange(t,e),"initialLayoutComplete"===e&&this.focusAndScrollOptionIntoView()}focusAndScrollOptionIntoView(){this.open&&this.firstSelectedOption&&requestAnimationFrame((()=>{this.firstSelectedOption?.scrollIntoView({block:"nearest"})}))}emitMentionSelected(t){this.$emit("mention-selected",t),this.setOpen(!1)}setOpen(t){this.open=t}}t([C],eM.prototype,"open",void 0),t([C],eM.prototype,"region",void 0),t([C],eM.prototype,"anchorElement",void 0)
7313
+ return this.$emit("mention-selected",n),this.setOpen(!1),!0}anchorElementChanged(t,e){t&&this.anchorElementIntersectionObserver.unobserve(t),this.region&&this.anchorElement&&(this.region.anchorElement=this.anchorElement,this.region.update(),this.anchorElementIntersectionObserver.observe(e))}regionChanged(){this.regionNotifier&&this.regionNotifier.unsubscribe(this),this.regionNotifier=x.getNotifier(this.region),this.regionNotifier.subscribe(this)}handleChange(t,e){super.handleChange(t,e),"initialLayoutComplete"===e&&this.focusAndScrollOptionIntoView()}focusAndScrollOptionIntoView(){this.open&&this.firstSelectedOption&&requestAnimationFrame((()=>{this.firstSelectedOption?.scrollIntoView({block:"nearest"})}))}setOpen(t){this.open=t}}t([C],eM.prototype,"open",void 0),t([C],eM.prototype,"region",void 0),t([C],eM.prototype,"availableViewportHeight",void 0),t([C],eM.prototype,"anchorElement",void 0)
7305
7314
  const nM=eM.compose({baseName:"rich-text-mention-listbox",template:Q_,styles:J_})
7306
7315
  _i.getOrCreate().withPrefix("nimble").register(nM())
7307
7316
  const iM="nimble-rich-text-mention-listbox",sM=Q`
@@ -9308,7 +9317,7 @@ let LT=class extends Fi{}
9308
9317
  class BT extends(An(LT)){constructor(){super(...arguments),this.proxy=document.createElement("select")}}const PT=t=>!t.visuallyHidden&&!t.disabled&&!t.hidden,zT=t=>!t.visuallyHidden&&!t.hidden
9309
9318
  class VT extends BT{constructor(){super(...arguments),this.appearance=gg,this.errorVisible=!1,this.filterMode=xg.none,this.clearable=!1,this.loadingVisible=!1,this.displayPlaceholder=!1,this.open=!1,this.listboxId=Ha("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 x.track(this,"value"),this._value}set value(t){const e=this._value
9310
9319
  let n=t
9311
- if(this.options?.length){const t=this.options.findIndex((t=>t.value===n)),e=this.options[this.selectedIndex]?.value??null,i=this.options[t]?.value??null;-1!==t&&e===i||(n="",this.selectedIndex=t),n=this.firstSelectedOption?.value??n}e===n||this.open&&this.selectedIndex<0||(this._value=n,super.valueChanged(e,n),x.notify(this,"value"),this.updateDisplayValue())}get displayValue(){return x.track(this,"displayValue"),this.firstSelectedOption?.text??""}anchoredRegionChanged(t,e){this.anchoredRegion&&this.control&&(this.anchoredRegion.anchorElement=this.control)}controlChanged(t,e){this.anchoredRegion&&this.control&&(this.anchoredRegion.anchorElement=this.control)}slottedOptionsChanged(t,e){const n=this.value
9320
+ if(this.options?.length){const t=this.options.findIndex((t=>t.value===n)),e=this.options[this.selectedIndex]?.value??null,i=this.options[t]?.value??null;-1!==t&&e===i||(n="",this.selectedIndex=t),n=this.firstSelectedOption?.value??n}e!==n&&(this._value=n,super.valueChanged(e,n),x.notify(this,"value"),this.updateDisplayValue())}get displayValue(){return x.track(this,"displayValue"),this.firstSelectedOption?.text??""}anchoredRegionChanged(t,e){this.anchoredRegion&&this.control&&(this.anchoredRegion.anchorElement=this.control)}controlChanged(t,e){this.anchoredRegion&&this.control&&(this.anchoredRegion.anchorElement=this.control)}slottedOptionsChanged(t,e){const n=this.value
9312
9321
  this.options.forEach((t=>{const e=x.getNotifier(t)
9313
9322
  e.unsubscribe(this,"value"),e.unsubscribe(this,"hidden"),e.unsubscribe(this,"disabled")})),t?.filter(NT).forEach((t=>{const e=x.getNotifier(t)
9314
9323
  e.unsubscribe(this,"hidden"),e.unsubscribe(this,"visuallyHidden"),e.unsubscribe(this,"listOptions")}))
@@ -9320,7 +9329,7 @@ e.subscribe(this,"hidden"),e.subscribe(this,"visuallyHidden"),e.subscribe(this,"
9320
9329
  let e=!1
9321
9330
  if(this.open){const n=t.target.closest("option,[role=option]")
9322
9331
  if(e=null!==n,n?.disabled)return}const n=this.selectedIndex
9323
- super.clickHandler(t),this.open=this.collapsible&&!this.open,!this.open&&this.selectedIndex!==n&&e&&this.updateValue(!0)}handleChange(t,e){const n=t
9332
+ super.clickHandler(t),this.open&&this.selectedIndex!==n&&e&&this.updateValue(!0),this.open=this.collapsible&&!this.open}handleChange(t,e){const n=t
9324
9333
  switch(e){case"value":this.updateValue()
9325
9334
  break
9326
9335
  case"selected":FT(n)&&n.selected?this.selectedIndex=this.options.indexOf(n):this.clearSelect()
@@ -9342,17 +9351,17 @@ return!this.isSameNode(e)||(this.focus(),!0)}keydownHandler(t){const e=this.sele
9342
9351
  super.keydownHandler(t)
9343
9352
  const n=t.key
9344
9353
  if(t.ctrlKey||t.shiftKey)return!0
9345
- let i=this.openActiveIndex??this.selectedIndex
9354
+ let i=this.openActiveIndex??this.selectedIndex,s=!1
9346
9355
  switch(n){case Ba:if(this.open&&this.filterMode!==xg.none)break
9347
9356
  t.preventDefault(),this.collapsible&&this.typeAheadExpired&&(this.open=!this.open),this.open||this.focus()
9348
9357
  break
9349
9358
  case Ra:case Aa:t.preventDefault()
9350
9359
  break
9351
9360
  case Ta:if(t.preventDefault(),0===this.filteredOptions.length||this.filteredOptions.every((t=>t.disabled)))return!1
9352
- this.open=!this.open,this.open||this.focus()
9361
+ this.open?s=!0:this.open=!0,s&&this.focus()
9353
9362
  break
9354
9363
  case Oa:if(!this.open){if(this.clearable)return this.clearSelect(),this.updateValue(!0),!0
9355
- break}this.collapsible&&this.open&&(t.preventDefault(),this.open=!1),i=this.selectedIndex,this.focus()}return this.open||this.selectedIndex===i||(this.selectedIndex=i),this.open||e===this.selectedIndex||this.updateValue(!0),!(n===Ia||n===Da)}selectedIndexChanged(t,e){this.setSelectedOptions(),this.open&&this.setActiveOption(this.selectedIndex),this.updateValue()}typeaheadBufferChanged(t,e){if(this.$fastController.isConnected){const t=this.getTypeaheadMatches()
9364
+ break}this.collapsible&&this.open&&(t.preventDefault(),this.open=!1),i=this.selectedIndex,this.focus()}return this.open&&!s||(this.selectedIndex!==i&&(this.selectedIndex=i),e!==this.selectedIndex&&this.updateValue(!0)),s&&(this.open=!1),!(n===Ia||n===Da)}selectedIndexChanged(t,e){this.setSelectedOptions(),this.open&&this.setActiveOption(this.selectedIndex),this.updateValue()}typeaheadBufferChanged(t,e){if(this.$fastController.isConnected){const t=this.getTypeaheadMatches()
9356
9365
  if(t.length){const e=this.options.indexOf(t[0])
9357
9366
  this.open&&this.filterMode!==xg.none||this.setActiveOption(e)}this.typeaheadExpired=!1}}disabledChanged(t,e){super.disabledChanged&&super.disabledChanged(t,e),this.ariaDisabled=this.disabled?"true":"false"}formResetCallback(){this.setProxyOptions(),super.setDefaultSelectedOption(),-1===this.selectedIndex&&(this.selectedIndex=0)}selectNextOption(){for(let t=(this.openActiveIndex??this.selectedIndex)+1;t<this.options.length;t++){const e=this.options[t]
9358
9367
  if(FT(e)&&PT(e)){this.setActiveOption(t)