@ni/nimble-components 29.7.7 → 29.7.9

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.
@@ -16333,7 +16333,7 @@
16333
16333
 
16334
16334
  /**
16335
16335
  * Do not edit directly
16336
- * Generated on Mon, 08 Jul 2024 20:22:42 GMT
16336
+ * Generated on Wed, 10 Jul 2024 15:33:57 GMT
16337
16337
  */
16338
16338
 
16339
16339
  const Information100DarkUi = "#a46eff";
@@ -20747,6 +20747,7 @@ so this becomes the fallback color for the slot */ ''}
20747
20747
  block: 'block'
20748
20748
  };
20749
20749
 
20750
+ // prettier-ignore
20750
20751
  const styles$J = css `
20751
20752
  ${display('inline-flex')}
20752
20753
 
@@ -20858,18 +20859,23 @@ so this becomes the fallback color for the slot */ ''}
20858
20859
  flex-direction: column;
20859
20860
  overflow-y: auto;
20860
20861
  width: 100%;
20862
+ --ni-private-listbox-visible-option-count: 10.5;
20863
+ --ni-private-listbox-anchor-element-gap: ${smallPadding};
20861
20864
  --ni-private-listbox-padding: ${smallPadding};
20862
20865
  --ni-private-listbox-filter-height: 0px;
20863
20866
  --ni-private-listbox-loading-indicator-height: 0px;
20864
20867
  max-height: min(
20865
20868
  calc(
20866
- ${smallPadding} + 2 * ${borderWidth} + ${controlHeight} * 10.5 +
20867
- var(--ni-private-listbox-filter-height) +
20868
- var(--ni-private-listbox-loading-indicator-height)
20869
+ var(--ni-private-listbox-anchor-element-gap) +
20870
+ 2 * ${borderWidth} +
20871
+ var(--ni-private-listbox-padding) +
20872
+ ${controlHeight} * var(--ni-private-listbox-visible-option-count) +
20873
+ var(--ni-private-listbox-filter-height) +
20874
+ var(--ni-private-listbox-loading-indicator-height)
20869
20875
  ),
20870
20876
  calc(
20871
- var(--ni-private-listbox-available-viewport-height) -
20872
- ${smallPadding}
20877
+ var(--ni-private-listbox-available-viewport-height) -
20878
+ var(--ni-private-listbox-anchor-element-gap)
20873
20879
  )
20874
20880
  );
20875
20881
  box-shadow: ${elevation2BoxShadow};
@@ -44176,8 +44182,9 @@ img.ProseMirror-separator {
44176
44182
  }
44177
44183
 
44178
44184
  .listbox {
44185
+ --ni-private-listbox-visible-option-count: 5.5;
44186
+ --ni-private-listbox-anchor-element-gap: 0px;
44179
44187
  min-width: ${menuMinWidth};
44180
- max-height: calc(5.5 * ${controlHeight});
44181
44188
  }
44182
44189
  `;
44183
44190
 
@@ -44201,6 +44208,8 @@ img.ProseMirror-separator {
44201
44208
  role="listbox"
44202
44209
  @click="${(x, c) => x.clickHandler(c.event)}"
44203
44210
  ?disabled="${x => x.disabled}"
44211
+ style="--ni-private-listbox-available-viewport-height: ${x => x.availableViewportHeight}px;"
44212
+ ${ref('listbox')}
44204
44213
  >
44205
44214
  <slot name="option"
44206
44215
  ${slotted({ filter: (n) => n instanceof HTMLElement && Listbox.slottedOptionFilter(n), flatten: true, property: 'slottedOptions' })}
@@ -44230,6 +44239,12 @@ img.ProseMirror-separator {
44230
44239
  class RichTextMentionListbox extends ListboxElement {
44231
44240
  constructor() {
44232
44241
  super(...arguments);
44242
+ /**
44243
+ * The space available in the viewport for the listbox when opened.
44244
+ *
44245
+ * @internal
44246
+ */
44247
+ this.availableViewportHeight = 0;
44233
44248
  /**
44234
44249
  * @internal
44235
44250
  */
@@ -44274,6 +44289,8 @@ img.ProseMirror-separator {
44274
44289
  * @public
44275
44290
  */
44276
44291
  show(options) {
44292
+ const listboxTop = options.anchorNode.getBoundingClientRect().bottom;
44293
+ this.availableViewportHeight = Math.trunc(window.innerHeight - listboxTop);
44277
44294
  this.filter = options.filter;
44278
44295
  this.anchorElement = options.anchorNode;
44279
44296
  this.setOpen(true);
@@ -44299,7 +44316,8 @@ img.ProseMirror-separator {
44299
44316
  href: this.firstSelectedOption.value,
44300
44317
  displayName: this.firstSelectedOption.text
44301
44318
  };
44302
- this.emitMentionSelected(mentionDetail);
44319
+ this.$emit('mention-selected', mentionDetail);
44320
+ this.setOpen(false);
44303
44321
  return true;
44304
44322
  }
44305
44323
  case keyEscape: {
@@ -44366,7 +44384,8 @@ img.ProseMirror-separator {
44366
44384
  href: capturedListOption.value,
44367
44385
  displayName: capturedListOption.text
44368
44386
  };
44369
- this.emitMentionSelected(mentionDetail);
44387
+ this.$emit('mention-selected', mentionDetail);
44388
+ this.setOpen(false);
44370
44389
  return true;
44371
44390
  }
44372
44391
  /**
@@ -44424,10 +44443,6 @@ img.ProseMirror-separator {
44424
44443
  });
44425
44444
  }
44426
44445
  }
44427
- emitMentionSelected(mentionDetail) {
44428
- this.$emit('mention-selected', mentionDetail);
44429
- this.setOpen(false);
44430
- }
44431
44446
  setOpen(value) {
44432
44447
  this.open = value;
44433
44448
  }
@@ -44438,6 +44453,9 @@ img.ProseMirror-separator {
44438
44453
  __decorate$1([
44439
44454
  observable
44440
44455
  ], RichTextMentionListbox.prototype, "region", void 0);
44456
+ __decorate$1([
44457
+ observable
44458
+ ], RichTextMentionListbox.prototype, "availableViewportHeight", void 0);
44441
44459
  __decorate$1([
44442
44460
  observable
44443
44461
  ], RichTextMentionListbox.prototype, "anchorElement", void 0);
@@ -60056,7 +60074,7 @@ img.ProseMirror-separator {
60056
60074
  }
60057
60075
  newValue = this.firstSelectedOption?.value ?? newValue;
60058
60076
  }
60059
- if (prev !== newValue && !(this.open && this.selectedIndex < 0)) {
60077
+ if (prev !== newValue) {
60060
60078
  this._value = newValue;
60061
60079
  super.valueChanged(prev, newValue);
60062
60080
  Observable.notify(this, 'value');
@@ -60145,12 +60163,12 @@ img.ProseMirror-separator {
60145
60163
  }
60146
60164
  const previousSelectedIndex = this.selectedIndex;
60147
60165
  super.clickHandler(e);
60148
- this.open = this.collapsible && !this.open;
60149
- if (!this.open
60166
+ if (this.open
60150
60167
  && this.selectedIndex !== previousSelectedIndex
60151
60168
  && optionClicked) {
60152
60169
  this.updateValue(true);
60153
60170
  }
60171
+ this.open = this.collapsible && !this.open;
60154
60172
  }
60155
60173
  /**
60156
60174
  * Updates the value when an option's value changes.
@@ -60331,6 +60349,7 @@ img.ProseMirror-separator {
60331
60349
  return true;
60332
60350
  }
60333
60351
  let currentActiveIndex = this.openActiveIndex ?? this.selectedIndex;
60352
+ let commitValueThenClose = false;
60334
60353
  switch (key) {
60335
60354
  case keySpace: {
60336
60355
  // when dropdown is open allow user to enter a space for filter text
@@ -60357,8 +60376,13 @@ img.ProseMirror-separator {
60357
60376
  || this.filteredOptions.every(o => o.disabled)) {
60358
60377
  return false;
60359
60378
  }
60360
- this.open = !this.open;
60361
- if (!this.open) {
60379
+ if (this.open) {
60380
+ commitValueThenClose = true;
60381
+ }
60382
+ else {
60383
+ this.open = true;
60384
+ }
60385
+ if (commitValueThenClose) {
60362
60386
  this.focus();
60363
60387
  }
60364
60388
  break;
@@ -60381,11 +60405,16 @@ img.ProseMirror-separator {
60381
60405
  break;
60382
60406
  }
60383
60407
  }
60384
- if (!this.open && this.selectedIndex !== currentActiveIndex) {
60385
- this.selectedIndex = currentActiveIndex;
60408
+ if (!this.open || commitValueThenClose) {
60409
+ if (this.selectedIndex !== currentActiveIndex) {
60410
+ this.selectedIndex = currentActiveIndex;
60411
+ }
60412
+ if (initialSelectedIndex !== this.selectedIndex) {
60413
+ this.updateValue(true);
60414
+ }
60386
60415
  }
60387
- if (!this.open && initialSelectedIndex !== this.selectedIndex) {
60388
- this.updateValue(true);
60416
+ if (commitValueThenClose) {
60417
+ this.open = false;
60389
60418
  }
60390
60419
  return !(key === keyArrowDown || key === keyArrowUp);
60391
60420
  }