@ni/spright-components 5.5.1 → 5.5.3

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.
@@ -11476,7 +11476,7 @@
11476
11476
  return;
11477
11477
  }
11478
11478
  if (this.control && !this.isUserInput) {
11479
- this.control.value = this.value;
11479
+ this.syncValueToInnerControl();
11480
11480
  }
11481
11481
  super.valueChanged(previous, this.value);
11482
11482
  if (previous !== undefined && !this.isUserInput) {
@@ -11551,7 +11551,7 @@
11551
11551
  super.connectedCallback();
11552
11552
  this.proxy.setAttribute("type", "number");
11553
11553
  this.validate();
11554
- this.control.value = this.value;
11554
+ this.syncValueToInnerControl();
11555
11555
  if (this.autofocus) {
11556
11556
  DOM.queueUpdate(() => {
11557
11557
  this.focus();
@@ -11578,9 +11578,9 @@
11578
11578
  * @internal
11579
11579
  */
11580
11580
  handleTextInput() {
11581
- this.control.value = this.control.value.replace(/[^0-9\-+e.]/g, "");
11581
+ this.control.value = this.sanitizeInput(this.control.value);
11582
11582
  this.isUserInput = true;
11583
- this.value = this.control.value;
11583
+ this.syncValueFromInnerControl();
11584
11584
  }
11585
11585
  /**
11586
11586
  * Change event handler for inner control.
@@ -11616,6 +11616,26 @@
11616
11616
  * @internal
11617
11617
  */
11618
11618
  handleBlur() {
11619
+ this.syncValueToInnerControl();
11620
+ }
11621
+ /**
11622
+ * Sanitizes the text input by the user.
11623
+ * @param inputText The user-input text to sanitize
11624
+ * @returns The sanitized text, containing only valid characters for a number field
11625
+ */
11626
+ sanitizeInput(inputText) {
11627
+ return inputText.replace(/[^0-9\-+e.]/g, "");
11628
+ }
11629
+ /**
11630
+ * Synchronizes the value from the input control in the shadow DOM to the host component.
11631
+ */
11632
+ syncValueFromInnerControl() {
11633
+ this.value = this.control.value;
11634
+ }
11635
+ /**
11636
+ * Synchronizes the value from the host component to the input control in the shadow DOM.
11637
+ */
11638
+ syncValueToInnerControl() {
11619
11639
  this.control.value = this.value;
11620
11640
  }
11621
11641
  };
@@ -16000,6 +16020,7 @@
16000
16020
  dividerBackgroundColor: 'divider-background-color',
16001
16021
  headerBackgroundColor: 'header-background-color',
16002
16022
  sectionBackgroundColor: 'section-background-color',
16023
+ sectionBackgroundImage: 'section-background-image',
16003
16024
  buttonFillPrimaryColor: 'button-fill-primary-color',
16004
16025
  buttonPrimaryFontColor: 'button-primary-font-color',
16005
16026
  buttonFillAccentColor: 'button-fill-accent-color',
@@ -16032,6 +16053,7 @@
16032
16053
  largePadding: 'large-padding',
16033
16054
  labelHeight: 'label-height',
16034
16055
  borderWidth: 'border-width',
16056
+ dividerWidth: 'divider-width',
16035
16057
  iconSize: 'icon-size',
16036
16058
  groupHeaderTextTransform: 'group-header-text-transform',
16037
16059
  drawerWidth: 'drawer-width',
@@ -16250,6 +16272,11 @@
16250
16272
  const applicationBackgroundColor = DesignToken.create(styleNameFromTokenName(tokenNames.applicationBackgroundColor)).withDefault((element) => getColorForTheme(element, White, Black85, ForestGreen));
16251
16273
  DesignToken.create(styleNameFromTokenName(tokenNames.headerBackgroundColor)).withDefault((element) => getColorForTheme(element, Black7, Black88, ForestGreen));
16252
16274
  DesignToken.create(styleNameFromTokenName(tokenNames.sectionBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black80, ForestGreen));
16275
+ const sectionBackgroundImage = DesignToken.create(styleNameFromTokenName(tokenNames.sectionBackgroundImage)).withDefault((element) => {
16276
+ const start = getColorForTheme(element, Black15, Black82, ForestGreen);
16277
+ const end = getColorForTheme(element, hexToRgbaCssColor(Black15, 0), hexToRgbaCssColor(Black82, 0), hexToRgbaCssColor(ForestGreen, 0));
16278
+ return `linear-gradient(${start}, ${end})`;
16279
+ });
16253
16280
  DesignToken.create(styleNameFromTokenName(tokenNames.dividerBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black80, ForestGreen));
16254
16281
  const fillSelectedColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedColor)).withDefault((element) => hexToRgbaCssColor(getFillSelectedColorForTheme(element), 0.2));
16255
16282
  const fillSelectedRgbPartialColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedRgbPartialColor)).withDefault((element) => hexToRgbPartial(getFillSelectedColorForTheme(element)));
@@ -16313,6 +16340,7 @@
16313
16340
  const largePadding = DesignToken.create(styleNameFromTokenName(tokenNames.largePadding)).withDefault('24px');
16314
16341
  DesignToken.create(styleNameFromTokenName(tokenNames.labelHeight)).withDefault('16px');
16315
16342
  const borderWidth = DesignToken.create(styleNameFromTokenName(tokenNames.borderWidth)).withDefault('1px');
16343
+ DesignToken.create(styleNameFromTokenName(tokenNames.dividerWidth)).withDefault('2px');
16316
16344
  const iconSize = DesignToken.create(styleNameFromTokenName(tokenNames.iconSize)).withDefault('16px');
16317
16345
  const drawerWidth = DesignToken.create(styleNameFromTokenName(tokenNames.drawerWidth)).withDefault('784px');
16318
16346
  const dialogSmallWidth = DesignToken.create(styleNameFromTokenName(tokenNames.dialogSmallWidth)).withDefault('400px');
@@ -93482,6 +93510,8 @@ focus outline in that case.
93482
93510
 
93483
93511
  :host {
93484
93512
  flex-direction: column;
93513
+ background: ${applicationBackgroundColor};
93514
+ border: ${borderWidth} solid ${applicationBackgroundColor};
93485
93515
  }
93486
93516
 
93487
93517
  .messages {
@@ -93490,24 +93520,52 @@ focus outline in that case.
93490
93520
  flex-direction: column;
93491
93521
  justify-content: flex-start;
93492
93522
  row-gap: 32px;
93493
- padding: ${mediumPadding};
93494
- background: ${applicationBackgroundColor};
93523
+ padding: ${mediumPadding} ${standardPadding} ${mediumPadding}
93524
+ ${standardPadding};
93525
+ background: ${sectionBackgroundImage};
93495
93526
  overflow-y: auto;
93496
93527
  }
93528
+
93529
+ .input {
93530
+ padding: ${borderWidth} ${standardPadding} ${standardPadding}
93531
+ ${standardPadding};
93532
+ }
93533
+
93534
+ .input.input-empty {
93535
+ padding: 0px ${standardPadding} 0px ${standardPadding};
93536
+ }
93497
93537
  `;
93498
93538
 
93499
93539
  /* eslint-disable @typescript-eslint/indent */
93500
93540
  // prettier-ignore
93501
93541
  const template$3 = html `
93502
93542
  <div class="messages"><slot></slot></div>
93503
- <div class="input"><slot name="input"></slot></div>`;
93543
+ <div class="input ${x => (x.inputEmpty ? 'input-empty' : '')}">
93544
+ <slot name="input" ${slotted({ property: 'slottedInputElements' })}>
93545
+ </slot>
93546
+ </div>
93547
+ `;
93504
93548
  /* eslint-enable @typescript-eslint/indent */
93505
93549
 
93506
93550
  /**
93507
93551
  * A Spright component for displaying a series of chat messages
93508
93552
  */
93509
93553
  class ChatConversation extends FoundationElement {
93554
+ constructor() {
93555
+ super(...arguments);
93556
+ /** @internal */
93557
+ this.inputEmpty = true;
93558
+ }
93559
+ slottedInputElementsChanged(_prev, next) {
93560
+ this.inputEmpty = !next?.length;
93561
+ }
93510
93562
  }
93563
+ __decorate([
93564
+ observable
93565
+ ], ChatConversation.prototype, "inputEmpty", void 0);
93566
+ __decorate([
93567
+ observable
93568
+ ], ChatConversation.prototype, "slottedInputElements", void 0);
93511
93569
  const sprightChatConversation = ChatConversation.compose({
93512
93570
  baseName: 'chat-conversation',
93513
93571
  template: template$3,