@ni/ok-components 0.3.9 → 0.3.10

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$V = (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
@@ -66522,7 +66523,7 @@ ${nextLine.slice(indentLevel + 2)}`;
66522
66523
  <template slot="step">
66523
66524
  <li class="
66524
66525
  container
66525
- ${x => (x.stepInternals.orientation === 'vertical' ? 'vertical' : '')}
66526
+ ${x => (x.stepInternals.orientation === StepperOrientation.vertical ? 'vertical' : '')}
66526
66527
  ${x => (x.stepInternals.last ? 'last' : '')}
66527
66528
  ">
66528
66529
  <button
@@ -66652,15 +66653,61 @@ ${nextLine.slice(indentLevel + 2)}`;
66652
66653
 
66653
66654
  :host {
66654
66655
  border: none;
66655
- gap: ${smallPadding};
66656
66656
  }
66657
66657
 
66658
66658
  :host([orientation="vertical"]) {
66659
66659
  flex-direction: column;
66660
66660
  }
66661
66661
 
66662
- ol {
66663
- display: contents;
66662
+ .scroll-button.start {
66663
+ width: ${controlHeight};
66664
+ height: ${controlHeight};
66665
+ margin-right: ${smallPadding};
66666
+ margin-bottom: 0px;
66667
+ }
66668
+
66669
+ :host([orientation="vertical"]) .scroll-button.start {
66670
+ margin-right: 0px;
66671
+ margin-bottom: ${smallPadding};
66672
+ }
66673
+
66674
+ .list {
66675
+ flex-grow: 1;
66676
+ display: inline-flex;
66677
+ gap: ${smallPadding};
66678
+ scrollbar-width: none;
66679
+ padding: 0;
66680
+ margin: 0;
66681
+
66682
+ flex-direction: row;
66683
+ overflow-x: scroll;
66684
+ overflow-y: hidden;
66685
+ width: max-content;
66686
+ max-width: 100%;
66687
+ height: auto;
66688
+ max-height: none;
66689
+ }
66690
+
66691
+ :host([orientation="vertical"]) .list {
66692
+ flex-direction: column;
66693
+ overflow-x: hidden;
66694
+ overflow-y: scroll;
66695
+ width: auto;
66696
+ max-width: none;
66697
+ height: max-content;
66698
+ max-height: 100%;
66699
+ }
66700
+
66701
+ .scroll-button.end {
66702
+ width: ${controlHeight};
66703
+ height: ${controlHeight};
66704
+ margin-left: ${smallPadding};
66705
+ margin-top: 0px;
66706
+ }
66707
+
66708
+ :host([orientation="vertical"]) .scroll-button.end {
66709
+ margin-left: 0px;
66710
+ margin-top: ${smallPadding};
66664
66711
  }
66665
66712
 
66666
66713
  slot[name="step"]::slotted(*) {
@@ -66672,10 +66719,35 @@ ${nextLine.slice(indentLevel + 2)}`;
66672
66719
  }
66673
66720
  `;
66674
66721
 
66675
- const template$w = html `<ol><slot
66676
- name="step"
66677
- ${slotted('steps')}
66678
- ></slot></ol>`;
66722
+ const template$w = html `
66723
+ ${when(x => x.showScrollButtons, html `
66724
+ <${buttonTag}
66725
+ content-hidden
66726
+ class="scroll-button start"
66727
+ appearance="${ButtonAppearance.ghost}"
66728
+ @click="${x => x.onScrollStartClick()}"
66729
+ ${ref('startScrollButton')}
66730
+ >
66731
+ ${x => scrollForwardLabel.getValueFor(x)}
66732
+ ${when(x => x.isHorizontal(), html `<${iconArrowExpanderLeftTag} slot="start"></${iconArrowExpanderLeftTag}>`, html `<${iconArrowExpanderUpTag} slot="start"></${iconArrowExpanderUpTag}>`)}
66733
+ </${buttonTag}>
66734
+ `)}
66735
+ <ol ${ref('list')} class="list"><slot
66736
+ name="step"
66737
+ ${slotted('steps')}
66738
+ ></slot></ol>
66739
+ ${when(x => x.showScrollButtons, html `
66740
+ <${buttonTag}
66741
+ content-hidden
66742
+ class="scroll-button end"
66743
+ appearance="${ButtonAppearance.ghost}"
66744
+ @click="${x => x.onScrollEndClick()}"
66745
+ >
66746
+ ${x => scrollBackwardLabel.getValueFor(x)}
66747
+ ${when(x => x.isHorizontal(), html `<${iconArrowExpanderRightTag} slot="start"></${iconArrowExpanderRightTag}>`, html `<${iconArrowExpanderDownTag} slot="start"></${iconArrowExpanderDownTag}>`)}
66748
+ </${buttonTag}>
66749
+ `)}
66750
+ `;
66679
66751
 
66680
66752
  /**
66681
66753
  * A nimble-styled stepper
@@ -66684,12 +66756,70 @@ ${nextLine.slice(indentLevel + 2)}`;
66684
66756
  constructor() {
66685
66757
  super(...arguments);
66686
66758
  this.orientation = StepperOrientation.horizontal;
66759
+ /** @internal */
66760
+ this.showScrollButtons = false;
66761
+ }
66762
+ /** @internal */
66763
+ onScrollStartClick() {
66764
+ if (this.isHorizontal()) {
66765
+ this.list.scrollBy({
66766
+ left: -this.list.clientWidth,
66767
+ behavior: 'smooth'
66768
+ });
66769
+ }
66770
+ else {
66771
+ this.list.scrollBy({
66772
+ top: -this.list.clientHeight,
66773
+ behavior: 'smooth'
66774
+ });
66775
+ }
66776
+ }
66777
+ /** @internal */
66778
+ onScrollEndClick() {
66779
+ if (this.isHorizontal()) {
66780
+ this.list.scrollBy({
66781
+ left: this.list.clientWidth,
66782
+ behavior: 'smooth'
66783
+ });
66784
+ }
66785
+ else {
66786
+ this.list.scrollBy({
66787
+ top: this.list.clientHeight,
66788
+ behavior: 'smooth'
66789
+ });
66790
+ }
66791
+ }
66792
+ /** @internal */
66793
+ connectedCallback() {
66794
+ super.connectedCallback();
66795
+ // Steps fill parent container so can't rely on a resize observer to track their space usage.
66796
+ // Instead directly track each step's occlusion with intersection observer which is more compute intensive.
66797
+ // When available can switch to container scroll state queries, see: https://github.com/ni/nimble/issues/2922
66798
+ this.listIntersectionObserver = new IntersectionObserver(_ => {
66799
+ this.handleListOverflow();
66800
+ }, {
66801
+ root: this.list,
66802
+ threshold: 1.0
66803
+ });
66804
+ }
66805
+ /** @internal */
66806
+ disconnectedCallback() {
66807
+ super.disconnectedCallback();
66808
+ this.listIntersectionObserver?.disconnect();
66809
+ }
66810
+ /** @internal */
66811
+ isHorizontal() {
66812
+ return this.orientation !== StepperOrientation.vertical;
66687
66813
  }
66688
66814
  orientationChanged() {
66689
66815
  this.updateStepInternals();
66690
66816
  }
66691
66817
  stepsChanged() {
66692
66818
  this.updateStepInternals();
66819
+ this.listIntersectionObserver?.disconnect();
66820
+ if (this.steps) {
66821
+ this.steps.forEach(step => this.listIntersectionObserver?.observe(step));
66822
+ }
66693
66823
  }
66694
66824
  updateStepInternals() {
66695
66825
  if (!this.steps) {
@@ -66697,15 +66827,38 @@ ${nextLine.slice(indentLevel + 2)}`;
66697
66827
  }
66698
66828
  const lastIndex = this.steps.length - 1;
66699
66829
  this.steps.forEach((step, index) => {
66700
- step.stepInternals.orientation = this.orientation;
66830
+ step.stepInternals.orientation = this.isHorizontal()
66831
+ ? StepperOrientation.horizontal
66832
+ : StepperOrientation.vertical;
66701
66833
  step.stepInternals.last = index === lastIndex;
66702
66834
  step.stepInternals.position = index + 1;
66703
66835
  });
66704
66836
  }
66837
+ handleListOverflow() {
66838
+ let listVisibleSize = this.isHorizontal()
66839
+ ? this.list.clientWidth
66840
+ : this.list.clientHeight;
66841
+ if (listVisibleSize !== undefined) {
66842
+ const buttonSize = this.isHorizontal()
66843
+ ? this.startScrollButton?.clientWidth ?? 0
66844
+ : this.startScrollButton?.clientHeight ?? 0;
66845
+ listVisibleSize = Math.ceil(listVisibleSize);
66846
+ if (this.showScrollButtons) {
66847
+ listVisibleSize += buttonSize * 2;
66848
+ }
66849
+ const listScrollSize = this.isHorizontal()
66850
+ ? this.list.scrollWidth
66851
+ : this.list.scrollHeight;
66852
+ this.showScrollButtons = listVisibleSize < listScrollSize;
66853
+ }
66854
+ }
66705
66855
  }
66706
66856
  __decorate([
66707
66857
  attr
66708
66858
  ], Stepper.prototype, "orientation", void 0);
66859
+ __decorate([
66860
+ observable
66861
+ ], Stepper.prototype, "showScrollButtons", void 0);
66709
66862
  __decorate([
66710
66863
  observable
66711
66864
  ], Stepper.prototype, "steps", void 0);