@ni/nimble-components 19.4.2 → 19.4.4

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.
Files changed (41) hide show
  1. package/dist/all-components-bundle.js +135 -64
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +518 -525
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/src/table-column/anchor/cell-view/index.d.ts +1 -3
  6. package/dist/esm/src/table-column/base/index.d.ts +1 -3
  7. package/dist/esm/src/table-column/text/cell-view/index.d.ts +2 -3
  8. package/dist/esm/src/table-column/text/group-header-view/index.d.ts +2 -3
  9. package/dist/esm/src/table-column/text-base/cell-view/index.d.ts +7 -15
  10. package/dist/esm/src/table-column/text-base/group-header-view/index.d.ts +6 -18
  11. package/dist/esm/src/utilities/directive/overflow.d.ts +36 -0
  12. package/dist/esm/table-column/anchor/cell-view/index.d.ts +1 -3
  13. package/dist/esm/table-column/anchor/cell-view/index.js +2 -2
  14. package/dist/esm/table-column/anchor/cell-view/index.js.map +1 -1
  15. package/dist/esm/table-column/anchor/cell-view/template.js +5 -15
  16. package/dist/esm/table-column/anchor/cell-view/template.js.map +1 -1
  17. package/dist/esm/table-column/base/index.d.ts +1 -3
  18. package/dist/esm/table-column/base/index.js +2 -2
  19. package/dist/esm/table-column/base/index.js.map +1 -1
  20. package/dist/esm/table-column/base/template.js +3 -9
  21. package/dist/esm/table-column/base/template.js.map +1 -1
  22. package/dist/esm/table-column/text/cell-view/index.d.ts +2 -3
  23. package/dist/esm/table-column/text/cell-view/index.js +11 -7
  24. package/dist/esm/table-column/text/cell-view/index.js.map +1 -1
  25. package/dist/esm/table-column/text/group-header-view/index.d.ts +2 -3
  26. package/dist/esm/table-column/text/group-header-view/index.js +11 -7
  27. package/dist/esm/table-column/text/group-header-view/index.js.map +1 -1
  28. package/dist/esm/table-column/text-base/cell-view/index.d.ts +7 -15
  29. package/dist/esm/table-column/text-base/cell-view/index.js +23 -2
  30. package/dist/esm/table-column/text-base/cell-view/index.js.map +1 -1
  31. package/dist/esm/table-column/text-base/cell-view/template.js +4 -9
  32. package/dist/esm/table-column/text-base/cell-view/template.js.map +1 -1
  33. package/dist/esm/table-column/text-base/group-header-view/index.d.ts +6 -18
  34. package/dist/esm/table-column/text-base/group-header-view/index.js +21 -8
  35. package/dist/esm/table-column/text-base/group-header-view/index.js.map +1 -1
  36. package/dist/esm/table-column/text-base/group-header-view/template.js +3 -4
  37. package/dist/esm/table-column/text-base/group-header-view/template.js.map +1 -1
  38. package/dist/esm/utilities/directive/overflow.d.ts +36 -0
  39. package/dist/esm/utilities/directive/overflow.js +56 -0
  40. package/dist/esm/utilities/directive/overflow.js.map +1 -0
  41. package/package.json +1 -1
@@ -16232,7 +16232,7 @@
16232
16232
 
16233
16233
  /**
16234
16234
  * Do not edit directly
16235
- * Generated on Wed, 28 Jun 2023 13:18:12 GMT
16235
+ * Generated on Fri, 30 Jun 2023 15:45:58 GMT
16236
16236
  */
16237
16237
  const Information100DarkUi = "#a46eff";
16238
16238
  const Information100LightUi = "#804ad9";
@@ -28253,7 +28253,7 @@
28253
28253
  this.sortDirection = TableColumnSortDirection.none;
28254
28254
  this.sortingDisabled = false;
28255
28255
  /** @internal */
28256
- this.isValidContentAndHasOverflow = false;
28256
+ this.hasOverflow = false;
28257
28257
  }
28258
28258
  checkValidity() {
28259
28259
  return this.columnInternals.validConfiguration;
@@ -28312,7 +28312,7 @@
28312
28312
  ], TableColumn.prototype, "sortingDisabled", void 0);
28313
28313
  __decorate$1([
28314
28314
  observable
28315
- ], TableColumn.prototype, "isValidContentAndHasOverflow", void 0);
28315
+ ], TableColumn.prototype, "hasOverflow", void 0);
28316
28316
 
28317
28317
  /**
28318
28318
  * Helper class for the nimble-table to validate that the table's configuration
@@ -31361,20 +31361,68 @@
31361
31361
  }
31362
31362
  `;
31363
31363
 
31364
+ /**
31365
+ * The runtime behavior for template overflow detection.
31366
+ * @public
31367
+ */
31368
+ class OverflowBehavior {
31369
+ /**
31370
+ * Creates an instance of OverflowBehavior.
31371
+ * @param target - The element to check for overflow.
31372
+ * @param propertyName - The name of the property to assign the overflow state to.
31373
+ */
31374
+ constructor(target, propertyName) {
31375
+ this.target = target;
31376
+ this.propertyName = propertyName;
31377
+ }
31378
+ /**
31379
+ * Bind this behavior to the source.
31380
+ * @param source - The source to bind to.
31381
+ * @param context - The execution context that the binding is operating within.
31382
+ */
31383
+ bind(source) {
31384
+ this.source = source;
31385
+ this.setSourceValue(false);
31386
+ this.mouseOverHandler = () => {
31387
+ const hasOverflow = this.target.offsetWidth < this.target.scrollWidth;
31388
+ this.setSourceValue(hasOverflow);
31389
+ };
31390
+ this.mouseOutHandler = () => {
31391
+ this.setSourceValue(false);
31392
+ };
31393
+ this.target.addEventListener('mouseover', this.mouseOverHandler);
31394
+ this.target.addEventListener('mouseout', this.mouseOutHandler);
31395
+ }
31396
+ /**
31397
+ * Unbinds this behavior from the source.
31398
+ * @param source - The source to unbind from.
31399
+ */
31400
+ unbind() {
31401
+ this.source = undefined;
31402
+ this.target.removeEventListener('mouseover', this.mouseOverHandler);
31403
+ this.target.removeEventListener('mouseout', this.mouseOutHandler);
31404
+ }
31405
+ setSourceValue(value) {
31406
+ // @ts-expect-error set property on source
31407
+ this.source[this.propertyName] = value;
31408
+ }
31409
+ }
31410
+ /**
31411
+ * A directive that observes if an element has overflow and sets a flag.
31412
+ * @param propertyName - The name of the property to assign the overflow flag.
31413
+ * @public
31414
+ */
31415
+ function overflow(propertyName) {
31416
+ return new AttachedBehaviorHTMLDirective('nimble-overflow', OverflowBehavior, propertyName);
31417
+ }
31418
+
31364
31419
  // prettier-ignore
31365
31420
  const template$8 = html `
31366
31421
  <template slot="${x => x.columnInternals.uniqueId}">
31367
31422
  <span
31368
- ${ref('headerSpan')}
31423
+ ${overflow('hasOverflow')}
31369
31424
  class="header-content"
31370
- @mouseover="${x => {
31371
- x.isValidContentAndHasOverflow = !!x.headerTextContent
31372
- && x.headerSpan.offsetWidth < x.headerSpan.scrollWidth;
31373
- }}"
31374
- @mouseout="${x => {
31375
- x.isValidContentAndHasOverflow = false;
31376
- }}"
31377
- title=${x => (x.isValidContentAndHasOverflow ? x.headerTextContent : null)}
31425
+ title=${x => (x.hasOverflow && x.headerTextContent ? x.headerTextContent : null)}
31378
31426
  >
31379
31427
  <slot ${ref('contentSlot')}></slot>
31380
31428
  </span>
@@ -31490,6 +31538,7 @@
31490
31538
  ${when(x => typeof x.cellRecord.href === 'string', html `
31491
31539
  <${anchorTag}
31492
31540
  ${ref('anchor')}
31541
+ ${overflow('hasOverflow')}
31493
31542
  href="${x => x.cellRecord.href}"
31494
31543
  hreflang="${x => x.columnConfig.hreflang}"
31495
31544
  ping="${x => x.columnConfig.ping}"
@@ -31500,27 +31549,15 @@
31500
31549
  download="${x => x.columnConfig.download}"
31501
31550
  underline-hidden="${x => x.columnConfig.underlineHidden}"
31502
31551
  appearance="${x => x.columnConfig.appearance}"
31503
- title=${x => (x.isValidContentAndHasOverflow ? x.content : null)}
31504
- @mouseover="${x => {
31505
- x.isValidContentAndHasOverflow = !!x.content && x.anchor.offsetWidth < x.anchor.scrollWidth;
31506
- }}"
31507
- @mouseout="${x => {
31508
- x.isValidContentAndHasOverflow = false;
31509
- }}"
31552
+ title=${x => (x.hasOverflow && x.content ? x.content : null)}
31510
31553
  >
31511
31554
  ${x => x.content}
31512
31555
  </${anchorTag}>`)}
31513
31556
  ${when(x => typeof x.cellRecord.href !== 'string', html `
31514
31557
  <span
31515
- ${ref('textSpan')}
31558
+ ${overflow('hasOverflow')}
31516
31559
  class="${x => (typeof x.cellRecord.label === 'string' ? '' : 'placeholder')}"
31517
- title=${x => (x.isValidContentAndHasOverflow ? x.content : null)}
31518
- @mouseover="${x => {
31519
- x.isValidContentAndHasOverflow = !!x.content && x.textSpan.offsetWidth < x.textSpan.scrollWidth;
31520
- }}"
31521
- @mouseout="${x => {
31522
- x.isValidContentAndHasOverflow = false;
31523
- }}"
31560
+ title=${x => (x.hasOverflow && x.content ? x.content : null)}
31524
31561
  >
31525
31562
  ${x => x.content}
31526
31563
  </span>`)}
@@ -31534,7 +31571,7 @@
31534
31571
  constructor() {
31535
31572
  super(...arguments);
31536
31573
  /** @internal */
31537
- this.isValidContentAndHasOverflow = false;
31574
+ this.hasOverflow = false;
31538
31575
  }
31539
31576
  get content() {
31540
31577
  if (typeof this.cellRecord.label === 'string') {
@@ -31551,7 +31588,7 @@
31551
31588
  }
31552
31589
  __decorate$1([
31553
31590
  observable
31554
- ], TableColumnAnchorCellView.prototype, "isValidContentAndHasOverflow", void 0);
31591
+ ], TableColumnAnchorCellView.prototype, "hasOverflow", void 0);
31555
31592
  __decorate$1([
31556
31593
  volatile
31557
31594
  ], TableColumnAnchorCellView.prototype, "content", null);
@@ -31571,32 +31608,43 @@
31571
31608
  super(...arguments);
31572
31609
  /** @internal */
31573
31610
  this.hasOverflow = false;
31611
+ /**
31612
+ * Text to render in the cell when it contains a valid value (i.e. when shouldUsePlaceholder is false).
31613
+ */
31614
+ this.text = '';
31615
+ /**
31616
+ * Text to render in the cell when it contains an invalid value (i.e. when shouldUsePlaceholder is true).
31617
+ */
31618
+ this.placeholder = '';
31619
+ /**
31620
+ * Returns whether to display the placeholder value or the text value
31621
+ */
31622
+ this.shouldUsePlaceholder = true;
31574
31623
  }
31575
31624
  get content() {
31576
31625
  return this.shouldUsePlaceholder ? this.placeholder : this.text;
31577
31626
  }
31578
- /** @internal */
31579
- updateTitleOverflow() {
31580
- this.hasOverflow = this.textSpan.offsetWidth < this.textSpan.scrollWidth;
31581
- }
31582
- /** @internal */
31583
- clearTitleOverflow() {
31584
- this.hasOverflow = false;
31585
- }
31586
31627
  }
31587
31628
  __decorate$1([
31588
31629
  observable
31589
31630
  ], TableColumnTextGroupHeaderViewBase.prototype, "hasOverflow", void 0);
31631
+ __decorate$1([
31632
+ observable
31633
+ ], TableColumnTextGroupHeaderViewBase.prototype, "text", void 0);
31634
+ __decorate$1([
31635
+ observable
31636
+ ], TableColumnTextGroupHeaderViewBase.prototype, "placeholder", void 0);
31637
+ __decorate$1([
31638
+ observable
31639
+ ], TableColumnTextGroupHeaderViewBase.prototype, "shouldUsePlaceholder", void 0);
31590
31640
  __decorate$1([
31591
31641
  volatile
31592
31642
  ], TableColumnTextGroupHeaderViewBase.prototype, "content", null);
31593
31643
 
31594
31644
  const template$6 = html `
31595
31645
  <span
31596
- ${ref('textSpan')}
31646
+ ${overflow('hasOverflow')}
31597
31647
  class="${x => (x.shouldUsePlaceholder ? 'placeholder' : '')}"
31598
- @mouseover="${x => x.updateTitleOverflow()}"
31599
- @mouseout="${x => x.clearTitleOverflow()}"
31600
31648
  title="${x => (x.hasOverflow && x.content ? x.content : undefined)}"
31601
31649
  >
31602
31650
  ${x => x.content}
@@ -31621,14 +31669,18 @@
31621
31669
  * The group header view for displaying string fields as text.
31622
31670
  */
31623
31671
  class TableColumnTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase {
31624
- get text() {
31625
- return this.groupHeaderValue;
31672
+ columnConfigChanged() {
31673
+ this.placeholder = this.columnConfig?.placeholder ?? '';
31626
31674
  }
31627
- get placeholder() {
31628
- return this.columnConfig?.placeholder ?? '';
31629
- }
31630
- get shouldUsePlaceholder() {
31631
- return typeof this.groupHeaderValue !== 'string';
31675
+ groupHeaderValueChanged() {
31676
+ if (typeof this.groupHeaderValue === 'string') {
31677
+ this.text = this.groupHeaderValue;
31678
+ this.shouldUsePlaceholder = false;
31679
+ }
31680
+ else {
31681
+ this.text = '';
31682
+ this.shouldUsePlaceholder = true;
31683
+ }
31632
31684
  }
31633
31685
  }
31634
31686
  const tableColumnTextGroupHeaderView = TableColumnTextGroupHeaderView.compose({
@@ -31785,15 +31837,9 @@
31785
31837
 
31786
31838
  const template$5 = html `
31787
31839
  <span
31788
- ${ref('textSpan')}
31840
+ ${overflow('hasOverflow')}
31789
31841
  class="${x => (x.shouldUsePlaceholder ? 'placeholder' : '')}"
31790
- @mouseover="${x => {
31791
- x.isValidContentAndHasOverflow = !!x.content && x.textSpan.offsetWidth < x.textSpan.scrollWidth;
31792
- }}"
31793
- @mouseout="${x => {
31794
- x.isValidContentAndHasOverflow = false;
31795
- }}"
31796
- title=${x => (x.isValidContentAndHasOverflow ? x.content : null)}
31842
+ title=${x => (x.hasOverflow && x.content ? x.content : null)}
31797
31843
  >
31798
31844
  ${x => x.content}
31799
31845
  </span>
@@ -31820,7 +31866,19 @@
31820
31866
  constructor() {
31821
31867
  super(...arguments);
31822
31868
  /** @internal */
31823
- this.isValidContentAndHasOverflow = false;
31869
+ this.hasOverflow = false;
31870
+ /**
31871
+ * Text to render in the cell when it contains a valid value (i.e. when shouldUsePlaceholder is false).
31872
+ */
31873
+ this.text = '';
31874
+ /**
31875
+ * Text to render in the cell when it contains an invalid value (i.e. when shouldUsePlaceholder is true).
31876
+ */
31877
+ this.placeholder = '';
31878
+ /**
31879
+ * Returns whether to display the placeholder value or the text value
31880
+ */
31881
+ this.shouldUsePlaceholder = true;
31824
31882
  }
31825
31883
  get content() {
31826
31884
  return this.shouldUsePlaceholder ? this.placeholder : this.text;
@@ -31828,7 +31886,16 @@
31828
31886
  }
31829
31887
  __decorate$1([
31830
31888
  observable
31831
- ], TableColumnTextCellViewBase.prototype, "isValidContentAndHasOverflow", void 0);
31889
+ ], TableColumnTextCellViewBase.prototype, "hasOverflow", void 0);
31890
+ __decorate$1([
31891
+ observable
31892
+ ], TableColumnTextCellViewBase.prototype, "text", void 0);
31893
+ __decorate$1([
31894
+ observable
31895
+ ], TableColumnTextCellViewBase.prototype, "placeholder", void 0);
31896
+ __decorate$1([
31897
+ observable
31898
+ ], TableColumnTextCellViewBase.prototype, "shouldUsePlaceholder", void 0);
31832
31899
  __decorate$1([
31833
31900
  volatile
31834
31901
  ], TableColumnTextCellViewBase.prototype, "content", null);
@@ -31837,14 +31904,18 @@
31837
31904
  * A cell view for displaying string fields as text
31838
31905
  */
31839
31906
  class TableColumnTextCellView extends TableColumnTextCellViewBase {
31840
- get text() {
31841
- return this.cellRecord.value;
31907
+ columnConfigChanged() {
31908
+ this.placeholder = this.columnConfig.placeholder;
31842
31909
  }
31843
- get placeholder() {
31844
- return this.columnConfig.placeholder;
31845
- }
31846
- get shouldUsePlaceholder() {
31847
- return typeof this.cellRecord.value !== 'string';
31910
+ cellRecordChanged() {
31911
+ if (typeof this.cellRecord.value === 'string') {
31912
+ this.text = this.cellRecord.value;
31913
+ this.shouldUsePlaceholder = false;
31914
+ }
31915
+ else {
31916
+ this.text = '';
31917
+ this.shouldUsePlaceholder = true;
31918
+ }
31848
31919
  }
31849
31920
  }
31850
31921
  const textCellView = TableColumnTextCellView.compose({