@ni/nimble-components 35.5.5 → 35.5.6

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.
@@ -19445,11 +19445,17 @@ Defines an interaction area clip-path that leaves out the severity text so it is
19445
19445
  cssCustomPropertyName: null
19446
19446
  }).withDefault(coreLabelDefaults.itemRemoveLabel);
19447
19447
 
19448
+ /**
19449
+ * Orientation of steppers.
19450
+ * @public
19451
+ */
19452
+ const StepperOrientation = Orientation;
19453
+
19448
19454
  const template$M = (context, definition) => html `
19449
19455
  <template slot="step">
19450
19456
  <li class="
19451
19457
  container
19452
- ${x => (x.stepInternals.orientation === 'vertical' ? 'vertical' : '')}
19458
+ ${x => (x.stepInternals.orientation === StepperOrientation.vertical ? 'vertical' : '')}
19453
19459
  ${x => (x.stepInternals.last ? 'last' : '')}
19454
19460
  ">
19455
19461
  <a
@@ -19507,12 +19513,6 @@ Defines an interaction area clip-path that leaves out the severity text so it is
19507
19513
  </template>
19508
19514
  `;
19509
19515
 
19510
- /**
19511
- * Orientation of steppers.
19512
- * @public
19513
- */
19514
- const StepperOrientation = Orientation;
19515
-
19516
19516
  /**
19517
19517
  * Internal properties configurable for a step
19518
19518
  */
@@ -23617,6 +23617,7 @@ so this becomes the fallback color for the slot */ ''}
23617
23617
  }
23618
23618
  }
23619
23619
  registerIconSvg('icon-arrow-expander-up', IconArrowExpanderUp);
23620
+ const iconArrowExpanderUpTag = 'nimble-icon-arrow-expander-up';
23620
23621
 
23621
23622
  // AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
23622
23623
  // See generation source in nimble-components/build/generate-icons
@@ -66520,7 +66521,7 @@ ${nextLine.slice(indentLevel + 2)}`;
66520
66521
  <template slot="step">
66521
66522
  <li class="
66522
66523
  container
66523
- ${x => (x.stepInternals.orientation === 'vertical' ? 'vertical' : '')}
66524
+ ${x => (x.stepInternals.orientation === StepperOrientation.vertical ? 'vertical' : '')}
66524
66525
  ${x => (x.stepInternals.last ? 'last' : '')}
66525
66526
  ">
66526
66527
  <button
@@ -66650,15 +66651,61 @@ ${nextLine.slice(indentLevel + 2)}`;
66650
66651
 
66651
66652
  :host {
66652
66653
  border: none;
66653
- gap: ${smallPadding};
66654
66654
  }
66655
66655
 
66656
66656
  :host([orientation="vertical"]) {
66657
66657
  flex-direction: column;
66658
66658
  }
66659
66659
 
66660
- ol {
66661
- display: contents;
66660
+ .scroll-button.start {
66661
+ width: ${controlHeight};
66662
+ height: ${controlHeight};
66663
+ margin-right: ${smallPadding};
66664
+ margin-bottom: 0px;
66665
+ }
66666
+
66667
+ :host([orientation="vertical"]) .scroll-button.start {
66668
+ margin-right: 0px;
66669
+ margin-bottom: ${smallPadding};
66670
+ }
66671
+
66672
+ .list {
66673
+ flex-grow: 1;
66674
+ display: inline-flex;
66675
+ gap: ${smallPadding};
66676
+ scrollbar-width: none;
66677
+ padding: 0;
66678
+ margin: 0;
66679
+
66680
+ flex-direction: row;
66681
+ overflow-x: scroll;
66682
+ overflow-y: hidden;
66683
+ width: max-content;
66684
+ max-width: 100%;
66685
+ height: auto;
66686
+ max-height: none;
66687
+ }
66688
+
66689
+ :host([orientation="vertical"]) .list {
66690
+ flex-direction: column;
66691
+ overflow-x: hidden;
66692
+ overflow-y: scroll;
66693
+ width: auto;
66694
+ max-width: none;
66695
+ height: max-content;
66696
+ max-height: 100%;
66697
+ }
66698
+
66699
+ .scroll-button.end {
66700
+ width: ${controlHeight};
66701
+ height: ${controlHeight};
66702
+ margin-left: ${smallPadding};
66703
+ margin-top: 0px;
66704
+ }
66705
+
66706
+ :host([orientation="vertical"]) .scroll-button.end {
66707
+ margin-left: 0px;
66708
+ margin-top: ${smallPadding};
66662
66709
  }
66663
66710
 
66664
66711
  slot[name="step"]::slotted(*) {
@@ -66670,10 +66717,35 @@ ${nextLine.slice(indentLevel + 2)}`;
66670
66717
  }
66671
66718
  `;
66672
66719
 
66673
- const template$n = html `<ol><slot
66674
- name="step"
66675
- ${slotted('steps')}
66676
- ></slot></ol>`;
66720
+ const template$n = html `
66721
+ ${when(x => x.showScrollButtons, html `
66722
+ <${buttonTag}
66723
+ content-hidden
66724
+ class="scroll-button start"
66725
+ appearance="${ButtonAppearance.ghost}"
66726
+ @click="${x => x.onScrollStartClick()}"
66727
+ ${ref('startScrollButton')}
66728
+ >
66729
+ ${x => scrollForwardLabel.getValueFor(x)}
66730
+ ${when(x => x.isHorizontal(), html `<${iconArrowExpanderLeftTag} slot="start"></${iconArrowExpanderLeftTag}>`, html `<${iconArrowExpanderUpTag} slot="start"></${iconArrowExpanderUpTag}>`)}
66731
+ </${buttonTag}>
66732
+ `)}
66733
+ <ol ${ref('list')} class="list"><slot
66734
+ name="step"
66735
+ ${slotted('steps')}
66736
+ ></slot></ol>
66737
+ ${when(x => x.showScrollButtons, html `
66738
+ <${buttonTag}
66739
+ content-hidden
66740
+ class="scroll-button end"
66741
+ appearance="${ButtonAppearance.ghost}"
66742
+ @click="${x => x.onScrollEndClick()}"
66743
+ >
66744
+ ${x => scrollBackwardLabel.getValueFor(x)}
66745
+ ${when(x => x.isHorizontal(), html `<${iconArrowExpanderRightTag} slot="start"></${iconArrowExpanderRightTag}>`, html `<${iconArrowExpanderDownTag} slot="start"></${iconArrowExpanderDownTag}>`)}
66746
+ </${buttonTag}>
66747
+ `)}
66748
+ `;
66677
66749
 
66678
66750
  /**
66679
66751
  * A nimble-styled stepper
@@ -66682,12 +66754,70 @@ ${nextLine.slice(indentLevel + 2)}`;
66682
66754
  constructor() {
66683
66755
  super(...arguments);
66684
66756
  this.orientation = StepperOrientation.horizontal;
66757
+ /** @internal */
66758
+ this.showScrollButtons = false;
66759
+ }
66760
+ /** @internal */
66761
+ onScrollStartClick() {
66762
+ if (this.isHorizontal()) {
66763
+ this.list.scrollBy({
66764
+ left: -this.list.clientWidth,
66765
+ behavior: 'smooth'
66766
+ });
66767
+ }
66768
+ else {
66769
+ this.list.scrollBy({
66770
+ top: -this.list.clientHeight,
66771
+ behavior: 'smooth'
66772
+ });
66773
+ }
66774
+ }
66775
+ /** @internal */
66776
+ onScrollEndClick() {
66777
+ if (this.isHorizontal()) {
66778
+ this.list.scrollBy({
66779
+ left: this.list.clientWidth,
66780
+ behavior: 'smooth'
66781
+ });
66782
+ }
66783
+ else {
66784
+ this.list.scrollBy({
66785
+ top: this.list.clientHeight,
66786
+ behavior: 'smooth'
66787
+ });
66788
+ }
66789
+ }
66790
+ /** @internal */
66791
+ connectedCallback() {
66792
+ super.connectedCallback();
66793
+ // Steps fill parent container so can't rely on a resize observer to track their space usage.
66794
+ // Instead directly track each step's occlusion with intersection observer which is more compute intensive.
66795
+ // When available can switch to container scroll state queries, see: https://github.com/ni/nimble/issues/2922
66796
+ this.listIntersectionObserver = new IntersectionObserver(_ => {
66797
+ this.handleListOverflow();
66798
+ }, {
66799
+ root: this.list,
66800
+ threshold: 1.0
66801
+ });
66802
+ }
66803
+ /** @internal */
66804
+ disconnectedCallback() {
66805
+ super.disconnectedCallback();
66806
+ this.listIntersectionObserver?.disconnect();
66807
+ }
66808
+ /** @internal */
66809
+ isHorizontal() {
66810
+ return this.orientation !== StepperOrientation.vertical;
66685
66811
  }
66686
66812
  orientationChanged() {
66687
66813
  this.updateStepInternals();
66688
66814
  }
66689
66815
  stepsChanged() {
66690
66816
  this.updateStepInternals();
66817
+ this.listIntersectionObserver?.disconnect();
66818
+ if (this.steps) {
66819
+ this.steps.forEach(step => this.listIntersectionObserver?.observe(step));
66820
+ }
66691
66821
  }
66692
66822
  updateStepInternals() {
66693
66823
  if (!this.steps) {
@@ -66695,15 +66825,38 @@ ${nextLine.slice(indentLevel + 2)}`;
66695
66825
  }
66696
66826
  const lastIndex = this.steps.length - 1;
66697
66827
  this.steps.forEach((step, index) => {
66698
- step.stepInternals.orientation = this.orientation;
66828
+ step.stepInternals.orientation = this.isHorizontal()
66829
+ ? StepperOrientation.horizontal
66830
+ : StepperOrientation.vertical;
66699
66831
  step.stepInternals.last = index === lastIndex;
66700
66832
  step.stepInternals.position = index + 1;
66701
66833
  });
66702
66834
  }
66835
+ handleListOverflow() {
66836
+ let listVisibleSize = this.isHorizontal()
66837
+ ? this.list.clientWidth
66838
+ : this.list.clientHeight;
66839
+ if (listVisibleSize !== undefined) {
66840
+ const buttonSize = this.isHorizontal()
66841
+ ? this.startScrollButton?.clientWidth ?? 0
66842
+ : this.startScrollButton?.clientHeight ?? 0;
66843
+ listVisibleSize = Math.ceil(listVisibleSize);
66844
+ if (this.showScrollButtons) {
66845
+ listVisibleSize += buttonSize * 2;
66846
+ }
66847
+ const listScrollSize = this.isHorizontal()
66848
+ ? this.list.scrollWidth
66849
+ : this.list.scrollHeight;
66850
+ this.showScrollButtons = listVisibleSize < listScrollSize;
66851
+ }
66852
+ }
66703
66853
  }
66704
66854
  __decorate([
66705
66855
  attr
66706
66856
  ], Stepper.prototype, "orientation", void 0);
66857
+ __decorate([
66858
+ observable
66859
+ ], Stepper.prototype, "showScrollButtons", void 0);
66707
66860
  __decorate([
66708
66861
  observable
66709
66862
  ], Stepper.prototype, "steps", void 0);