@ni/ok-components 0.3.9 → 0.3.11

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.
@@ -1412,9 +1412,6 @@
1412
1412
  };
1413
1413
  }
1414
1414
 
1415
- // A singleton Range instance used to efficiently remove ranges of DOM nodes.
1416
- // See the implementation of HTMLView below for further details.
1417
- const range$1 = document.createRange();
1418
1415
  /**
1419
1416
  * The standard View implementation, which also implements ElementView and SyntheticView.
1420
1417
  * @public
@@ -1549,23 +1546,16 @@
1549
1546
  this.source = null;
1550
1547
  }
1551
1548
  /**
1552
- * Efficiently disposes of a contiguous range of synthetic view instances.
1549
+ * Disposes of a contiguous range of synthetic view instances.
1553
1550
  * @param views - A contiguous range of views to be disposed.
1554
1551
  */
1555
1552
  static disposeContiguousBatch(views) {
1556
1553
  if (views.length === 0) {
1557
1554
  return;
1558
1555
  }
1559
- range$1.setStartBefore(views[0].firstChild);
1560
- range$1.setEndAfter(views[views.length - 1].lastChild);
1561
- range$1.deleteContents();
1562
1556
  for (let i = 0, ii = views.length; i < ii; ++i) {
1563
1557
  const view = views[i];
1564
- const behaviors = view.behaviors;
1565
- const oldSource = view.source;
1566
- for (let j = 0, jj = behaviors.length; j < jj; ++j) {
1567
- behaviors[j].unbind(oldSource);
1568
- }
1558
+ view.dispose();
1569
1559
  }
1570
1560
  }
1571
1561
  }
@@ -19445,11 +19435,17 @@ Defines an interaction area clip-path that leaves out the severity text so it is
19445
19435
  cssCustomPropertyName: null
19446
19436
  }).withDefault(coreLabelDefaults.itemRemoveLabel);
19447
19437
 
19438
+ /**
19439
+ * Orientation of steppers.
19440
+ * @public
19441
+ */
19442
+ const StepperOrientation = Orientation;
19443
+
19448
19444
  const template$V = (context, definition) => html `
19449
19445
  <template slot="step">
19450
19446
  <li class="
19451
19447
  container
19452
- ${x => (x.stepInternals.orientation === 'vertical' ? 'vertical' : '')}
19448
+ ${x => (x.stepInternals.orientation === StepperOrientation.vertical ? 'vertical' : '')}
19453
19449
  ${x => (x.stepInternals.last ? 'last' : '')}
19454
19450
  ">
19455
19451
  <a
@@ -19507,12 +19503,6 @@ Defines an interaction area clip-path that leaves out the severity text so it is
19507
19503
  </template>
19508
19504
  `;
19509
19505
 
19510
- /**
19511
- * Orientation of steppers.
19512
- * @public
19513
- */
19514
- const StepperOrientation = Orientation;
19515
-
19516
19506
  /**
19517
19507
  * Internal properties configurable for a step
19518
19508
  */
@@ -23617,6 +23607,7 @@ so this becomes the fallback color for the slot */ ''}
23617
23607
  }
23618
23608
  }
23619
23609
  registerIconSvg('icon-arrow-expander-up', IconArrowExpanderUp);
23610
+ const iconArrowExpanderUpTag = 'nimble-icon-arrow-expander-up';
23620
23611
 
23621
23612
  // AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
23622
23613
  // See generation source in nimble-components/build/generate-icons
@@ -66522,7 +66513,7 @@ ${nextLine.slice(indentLevel + 2)}`;
66522
66513
  <template slot="step">
66523
66514
  <li class="
66524
66515
  container
66525
- ${x => (x.stepInternals.orientation === 'vertical' ? 'vertical' : '')}
66516
+ ${x => (x.stepInternals.orientation === StepperOrientation.vertical ? 'vertical' : '')}
66526
66517
  ${x => (x.stepInternals.last ? 'last' : '')}
66527
66518
  ">
66528
66519
  <button
@@ -66652,15 +66643,61 @@ ${nextLine.slice(indentLevel + 2)}`;
66652
66643
 
66653
66644
  :host {
66654
66645
  border: none;
66655
- gap: ${smallPadding};
66656
66646
  }
66657
66647
 
66658
66648
  :host([orientation="vertical"]) {
66659
66649
  flex-direction: column;
66660
66650
  }
66661
66651
 
66662
- ol {
66663
- display: contents;
66652
+ .scroll-button.start {
66653
+ width: ${controlHeight};
66654
+ height: ${controlHeight};
66655
+ margin-right: ${smallPadding};
66656
+ margin-bottom: 0px;
66657
+ }
66658
+
66659
+ :host([orientation="vertical"]) .scroll-button.start {
66660
+ margin-right: 0px;
66661
+ margin-bottom: ${smallPadding};
66662
+ }
66663
+
66664
+ .list {
66665
+ flex-grow: 1;
66666
+ display: inline-flex;
66667
+ gap: ${smallPadding};
66668
+ scrollbar-width: none;
66669
+ padding: 0;
66670
+ margin: 0;
66671
+
66672
+ flex-direction: row;
66673
+ overflow-x: scroll;
66674
+ overflow-y: hidden;
66675
+ width: max-content;
66676
+ max-width: 100%;
66677
+ height: auto;
66678
+ max-height: none;
66679
+ }
66680
+
66681
+ :host([orientation="vertical"]) .list {
66682
+ flex-direction: column;
66683
+ overflow-x: hidden;
66684
+ overflow-y: scroll;
66685
+ width: auto;
66686
+ max-width: none;
66687
+ height: max-content;
66688
+ max-height: 100%;
66689
+ }
66690
+
66691
+ .scroll-button.end {
66692
+ width: ${controlHeight};
66693
+ height: ${controlHeight};
66694
+ margin-left: ${smallPadding};
66695
+ margin-top: 0px;
66696
+ }
66697
+
66698
+ :host([orientation="vertical"]) .scroll-button.end {
66699
+ margin-left: 0px;
66700
+ margin-top: ${smallPadding};
66664
66701
  }
66665
66702
 
66666
66703
  slot[name="step"]::slotted(*) {
@@ -66672,10 +66709,35 @@ ${nextLine.slice(indentLevel + 2)}`;
66672
66709
  }
66673
66710
  `;
66674
66711
 
66675
- const template$w = html `<ol><slot
66676
- name="step"
66677
- ${slotted('steps')}
66678
- ></slot></ol>`;
66712
+ const template$w = html `
66713
+ ${when(x => x.showScrollButtons, html `
66714
+ <${buttonTag}
66715
+ content-hidden
66716
+ class="scroll-button start"
66717
+ appearance="${ButtonAppearance.ghost}"
66718
+ @click="${x => x.onScrollStartClick()}"
66719
+ ${ref('startScrollButton')}
66720
+ >
66721
+ ${x => scrollForwardLabel.getValueFor(x)}
66722
+ ${when(x => x.isHorizontal(), html `<${iconArrowExpanderLeftTag} slot="start"></${iconArrowExpanderLeftTag}>`, html `<${iconArrowExpanderUpTag} slot="start"></${iconArrowExpanderUpTag}>`)}
66723
+ </${buttonTag}>
66724
+ `)}
66725
+ <ol ${ref('list')} class="list"><slot
66726
+ name="step"
66727
+ ${slotted('steps')}
66728
+ ></slot></ol>
66729
+ ${when(x => x.showScrollButtons, html `
66730
+ <${buttonTag}
66731
+ content-hidden
66732
+ class="scroll-button end"
66733
+ appearance="${ButtonAppearance.ghost}"
66734
+ @click="${x => x.onScrollEndClick()}"
66735
+ >
66736
+ ${x => scrollBackwardLabel.getValueFor(x)}
66737
+ ${when(x => x.isHorizontal(), html `<${iconArrowExpanderRightTag} slot="start"></${iconArrowExpanderRightTag}>`, html `<${iconArrowExpanderDownTag} slot="start"></${iconArrowExpanderDownTag}>`)}
66738
+ </${buttonTag}>
66739
+ `)}
66740
+ `;
66679
66741
 
66680
66742
  /**
66681
66743
  * A nimble-styled stepper
@@ -66684,12 +66746,70 @@ ${nextLine.slice(indentLevel + 2)}`;
66684
66746
  constructor() {
66685
66747
  super(...arguments);
66686
66748
  this.orientation = StepperOrientation.horizontal;
66749
+ /** @internal */
66750
+ this.showScrollButtons = false;
66751
+ }
66752
+ /** @internal */
66753
+ onScrollStartClick() {
66754
+ if (this.isHorizontal()) {
66755
+ this.list.scrollBy({
66756
+ left: -this.list.clientWidth,
66757
+ behavior: 'smooth'
66758
+ });
66759
+ }
66760
+ else {
66761
+ this.list.scrollBy({
66762
+ top: -this.list.clientHeight,
66763
+ behavior: 'smooth'
66764
+ });
66765
+ }
66766
+ }
66767
+ /** @internal */
66768
+ onScrollEndClick() {
66769
+ if (this.isHorizontal()) {
66770
+ this.list.scrollBy({
66771
+ left: this.list.clientWidth,
66772
+ behavior: 'smooth'
66773
+ });
66774
+ }
66775
+ else {
66776
+ this.list.scrollBy({
66777
+ top: this.list.clientHeight,
66778
+ behavior: 'smooth'
66779
+ });
66780
+ }
66781
+ }
66782
+ /** @internal */
66783
+ connectedCallback() {
66784
+ super.connectedCallback();
66785
+ // Steps fill parent container so can't rely on a resize observer to track their space usage.
66786
+ // Instead directly track each step's occlusion with intersection observer which is more compute intensive.
66787
+ // When available can switch to container scroll state queries, see: https://github.com/ni/nimble/issues/2922
66788
+ this.listIntersectionObserver = new IntersectionObserver(_ => {
66789
+ this.handleListOverflow();
66790
+ }, {
66791
+ root: this.list,
66792
+ threshold: 1.0
66793
+ });
66794
+ }
66795
+ /** @internal */
66796
+ disconnectedCallback() {
66797
+ super.disconnectedCallback();
66798
+ this.listIntersectionObserver?.disconnect();
66799
+ }
66800
+ /** @internal */
66801
+ isHorizontal() {
66802
+ return this.orientation !== StepperOrientation.vertical;
66687
66803
  }
66688
66804
  orientationChanged() {
66689
66805
  this.updateStepInternals();
66690
66806
  }
66691
66807
  stepsChanged() {
66692
66808
  this.updateStepInternals();
66809
+ this.listIntersectionObserver?.disconnect();
66810
+ if (this.steps) {
66811
+ this.steps.forEach(step => this.listIntersectionObserver?.observe(step));
66812
+ }
66693
66813
  }
66694
66814
  updateStepInternals() {
66695
66815
  if (!this.steps) {
@@ -66697,15 +66817,38 @@ ${nextLine.slice(indentLevel + 2)}`;
66697
66817
  }
66698
66818
  const lastIndex = this.steps.length - 1;
66699
66819
  this.steps.forEach((step, index) => {
66700
- step.stepInternals.orientation = this.orientation;
66820
+ step.stepInternals.orientation = this.isHorizontal()
66821
+ ? StepperOrientation.horizontal
66822
+ : StepperOrientation.vertical;
66701
66823
  step.stepInternals.last = index === lastIndex;
66702
66824
  step.stepInternals.position = index + 1;
66703
66825
  });
66704
66826
  }
66827
+ handleListOverflow() {
66828
+ let listVisibleSize = this.isHorizontal()
66829
+ ? this.list.clientWidth
66830
+ : this.list.clientHeight;
66831
+ if (listVisibleSize !== undefined) {
66832
+ const buttonSize = this.isHorizontal()
66833
+ ? this.startScrollButton?.clientWidth ?? 0
66834
+ : this.startScrollButton?.clientHeight ?? 0;
66835
+ listVisibleSize = Math.ceil(listVisibleSize);
66836
+ if (this.showScrollButtons) {
66837
+ listVisibleSize += buttonSize * 2;
66838
+ }
66839
+ const listScrollSize = this.isHorizontal()
66840
+ ? this.list.scrollWidth
66841
+ : this.list.scrollHeight;
66842
+ this.showScrollButtons = listVisibleSize < listScrollSize;
66843
+ }
66844
+ }
66705
66845
  }
66706
66846
  __decorate([
66707
66847
  attr
66708
66848
  ], Stepper.prototype, "orientation", void 0);
66849
+ __decorate([
66850
+ observable
66851
+ ], Stepper.prototype, "showScrollButtons", void 0);
66709
66852
  __decorate([
66710
66853
  observable
66711
66854
  ], Stepper.prototype, "steps", void 0);
@@ -71731,11 +71874,6 @@ focus outline in that case.
71731
71874
  /** @internal */
71732
71875
  onCellActionMenuToggle(event, column) {
71733
71876
  this.menuOpen = event.detail.newState;
71734
- // Workaround for Firefox issue when action menus opened on different rows
71735
- // See: https://github.com/ni/nimble/issues/2744
71736
- if (!event.detail.newState) {
71737
- this.currentActionMenuColumn = undefined;
71738
- }
71739
71877
  this.emitActionMenuToggleEvent('row-action-menu-toggle', event.detail, column);
71740
71878
  }
71741
71879
  /** @internal */