@ni/ok-components 1.7.0 → 1.8.0

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.
@@ -108400,6 +108400,25 @@ focus outline in that case.
108400
108400
  display: none;
108401
108401
  }
108402
108402
 
108403
+ :host([size='compact']) .summary-item-container {
108404
+ flex-wrap: nowrap;
108405
+ box-sizing: border-box;
108406
+ overflow-x: auto;
108407
+ overflow-y: hidden;
108408
+ gap: ${mediumPadding};
108409
+ padding: calc(${standardPadding} - ${smallPadding});
108410
+ scrollbar-width: none;
108411
+ }
108412
+
108413
+ :host([size='compact']) .summary-item-container.has-overflow {
108414
+ -webkit-mask-image: linear-gradient(to right, black calc(100% - 48px), transparent);
108415
+ mask-image: linear-gradient(to right, black calc(100% - 48px), transparent);
108416
+ }
108417
+
108418
+ :host([size='compact']) .summary-item-container::-webkit-scrollbar {
108419
+ display: none;
108420
+ }
108421
+
108403
108422
  .edit-items-button {
108404
108423
  align-self: start;
108405
108424
  justify-self: end;
@@ -108423,7 +108442,12 @@ focus outline in that case.
108423
108442
 
108424
108443
  const template$6 = html `
108425
108444
  <section class="summary-panel" part="panel">
108426
- <div class="summary-item-container" part="items">
108445
+ <div
108446
+ ${ref('summaryItems')}
108447
+ class="summary-item-container"
108448
+ part="items"
108449
+ @scroll="${x => x.handleItemsScroll()}"
108450
+ >
108427
108451
  <slot @slotchange="${x => x.handleItemsSlotChange()}"></slot>
108428
108452
  </div>
108429
108453
  ${when(x => x.showEditItemsButton, html `
@@ -108446,25 +108470,48 @@ focus outline in that case.
108446
108470
  </section>
108447
108471
  `;
108448
108472
 
108473
+ const FvSummaryPanelSize = {
108474
+ default: 'default',
108475
+ compact: 'compact'
108476
+ };
108477
+
108449
108478
  /**
108450
108479
  * A layout container for summary tiles with an optional edit-items affordance.
108451
108480
  */
108452
108481
  class FvSummaryPanel extends FoundationElement {
108453
108482
  constructor() {
108454
- super(...arguments);
108483
+ super();
108455
108484
  this.showEditItemsButton = false;
108456
108485
  this.legacyStyle = false;
108486
+ this.size = FvSummaryPanelSize.default;
108487
+ /** @internal */
108488
+ this.hasOverflow = false;
108457
108489
  this.editItemsButtonLabel = 'Configure';
108490
+ this.summaryItemsResizeObserver = new ResizeObserver(() => this.updateOverflow());
108458
108491
  }
108459
108492
  /** @internal */
108460
108493
  connectedCallback() {
108461
108494
  super.connectedCallback();
108462
- this.syncTileLegacyStyle();
108495
+ this.syncTileAttributes();
108496
+ this.observeSummaryItems();
108497
+ }
108498
+ /** @internal */
108499
+ disconnectedCallback() {
108500
+ super.disconnectedCallback();
108501
+ this.summaryItemsResizeObserver.disconnect();
108463
108502
  }
108464
108503
  /** @internal */
108465
108504
  legacyStyleChanged() {
108466
108505
  if (this.$fastController.isConnected) {
108467
- this.syncTileLegacyStyle();
108506
+ this.syncTileAttributes();
108507
+ this.updateOverflow();
108508
+ }
108509
+ }
108510
+ /** @internal */
108511
+ sizeChanged() {
108512
+ if (this.$fastController.isConnected) {
108513
+ this.syncTileAttributes();
108514
+ this.updateOverflow();
108468
108515
  }
108469
108516
  }
108470
108517
  /** @internal */
@@ -108476,9 +108523,31 @@ focus outline in that case.
108476
108523
  }
108477
108524
  /** @internal */
108478
108525
  handleItemsSlotChange() {
108479
- this.syncTileLegacyStyle();
108526
+ this.syncTileAttributes();
108527
+ this.observeSummaryItems();
108480
108528
  }
108481
- syncTileLegacyStyle() {
108529
+ /** @internal */
108530
+ handleItemsScroll() {
108531
+ this.updateOverflow();
108532
+ }
108533
+ observeSummaryItems() {
108534
+ this.summaryItemsResizeObserver.disconnect();
108535
+ this.summaryItemsResizeObserver.observe(this.summaryItems);
108536
+ for (const element of this.shadowRoot?.querySelector('slot')?.assignedElements({ flatten: true }) ?? []) {
108537
+ this.summaryItemsResizeObserver.observe(element);
108538
+ }
108539
+ this.updateOverflow();
108540
+ }
108541
+ updateOverflow() {
108542
+ const maxScrollDistance = this.summaryItems.scrollWidth - this.summaryItems.clientWidth;
108543
+ const scrollPosition = getComputedStyle(this.summaryItems).direction === 'rtl'
108544
+ ? Math.abs(this.summaryItems.scrollLeft)
108545
+ : this.summaryItems.scrollLeft;
108546
+ this.hasOverflow = this.size === FvSummaryPanelSize.compact
108547
+ && maxScrollDistance - scrollPosition > 0;
108548
+ this.summaryItems.classList.toggle('has-overflow', this.hasOverflow);
108549
+ }
108550
+ syncTileAttributes() {
108482
108551
  for (const element of this.shadowRoot?.querySelector('slot')?.assignedElements({ flatten: true }) ?? []) {
108483
108552
  if (element.localName !== 'ok-fv-summary-panel-tile') {
108484
108553
  continue;
@@ -108489,6 +108558,12 @@ focus outline in that case.
108489
108558
  else {
108490
108559
  element.removeAttribute('legacy-style');
108491
108560
  }
108561
+ if (this.size === FvSummaryPanelSize.compact) {
108562
+ element.setAttribute('size', FvSummaryPanelSize.compact);
108563
+ }
108564
+ else {
108565
+ element.removeAttribute('size');
108566
+ }
108492
108567
  }
108493
108568
  }
108494
108569
  }
@@ -108498,6 +108573,12 @@ focus outline in that case.
108498
108573
  __decorate([
108499
108574
  attr({ attribute: 'legacy-style', mode: 'boolean' })
108500
108575
  ], FvSummaryPanel.prototype, "legacyStyle", void 0);
108576
+ __decorate([
108577
+ attr
108578
+ ], FvSummaryPanel.prototype, "size", void 0);
108579
+ __decorate([
108580
+ observable
108581
+ ], FvSummaryPanel.prototype, "hasOverflow", void 0);
108501
108582
  __decorate([
108502
108583
  attr({ attribute: 'edit-items-button-label' })
108503
108584
  ], FvSummaryPanel.prototype, "editItemsButtonLabel", void 0);
@@ -108584,6 +108665,24 @@ focus outline in that case.
108584
108665
  text-transform: uppercase;
108585
108666
  white-space: nowrap;
108586
108667
  }
108668
+
108669
+ :host([size='compact']) .summary-panel-tile-content {
108670
+ gap: 6px;
108671
+ margin: 10px 14px;
108672
+ }
108673
+
108674
+ :host([size='compact']) .count {
108675
+ font-size: 24px;
108676
+ line-height: normal;
108677
+ }
108678
+
108679
+ :host([size='compact']) .summary-panel-tile-content.beside .count {
108680
+ padding-right: 0;
108681
+ }
108682
+
108683
+ :host([size='compact']) .label {
108684
+ font-size: 11px;
108685
+ }
108587
108686
  }
108588
108687
 
108589
108688
  @layer hover {
@@ -108667,6 +108766,7 @@ focus outline in that case.
108667
108766
  this.count = '';
108668
108767
  this.label = '';
108669
108768
  this.legacyStyle = false;
108769
+ this.size = FvSummaryPanelSize.default;
108670
108770
  this.selected = false;
108671
108771
  this.textPosition = FvSummaryPanelTileTextPosition.beside;
108672
108772
  }
@@ -108697,6 +108797,9 @@ focus outline in that case.
108697
108797
  __decorate([
108698
108798
  attr({ attribute: 'legacy-style', mode: 'boolean' })
108699
108799
  ], FvSummaryPanelTile.prototype, "legacyStyle", void 0);
108800
+ __decorate([
108801
+ attr
108802
+ ], FvSummaryPanelTile.prototype, "size", void 0);
108700
108803
  __decorate([
108701
108804
  attr({ mode: 'boolean' })
108702
108805
  ], FvSummaryPanelTile.prototype, "selected", void 0);