@ni/spright-components 1.0.33 → 1.0.35

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`