@brightspace-ui/core 3.45.0 → 3.45.1

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.
@@ -5,7 +5,9 @@
5
5
  <meta charset="UTF-8">
6
6
  <link rel="stylesheet" href="../../demo/styles.css" type="text/css">
7
7
  <script type="module">
8
+ import '../../button/button-icon.js';
8
9
  import '../../demo/demo-page.js';
10
+ import '../../icons/icon.js';
9
11
  import '../input-number.js';
10
12
  </script>
11
13
  </head>
@@ -8,6 +8,7 @@ import { ifDefined } from 'lit/directives/if-defined.js';
8
8
  import { LabelledMixin } from '../../mixins/labelled/labelled-mixin.js';
9
9
  import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
10
10
  import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
11
+ import { styleMap } from 'lit/directives/style-map.js';
11
12
 
12
13
  const HINT_TYPES = {
13
14
  NONE: 0,
@@ -178,8 +179,9 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
178
179
  * @ignore
179
180
  */
180
181
  valueTrailingZeroes: { type: String, attribute: 'value-trailing-zeroes' },
181
- _hintType: { type: Number },
182
- _formattedValue: { type: String }
182
+ _afterSlotWidth: { state: true },
183
+ _hintType: { state: true },
184
+ _formattedValue: { state: true }
183
185
  };
184
186
  }
185
187
 
@@ -218,6 +220,7 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
218
220
  this._trailingZeroes = false;
219
221
  this._valueTrailingZeroes = '';
220
222
  this._descriptor = getNumberDescriptor();
223
+ this._afterSlotWidth = 0;
221
224
  }
222
225
 
223
226
  get maxFractionDigits() {
@@ -337,6 +340,11 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
337
340
 
338
341
  render() {
339
342
  const valueAlign = (this.valueAlign === 'end') ? 'end' : 'start';
343
+ const hasRelativeInputWidth = this.inputWidth.includes('%');
344
+ const inputWidthStyle = {
345
+ width : '100%',
346
+ maxWidth: `calc(${this.inputWidth} + ${this._afterSlotWidth}px)`
347
+ };
340
348
  return html`
341
349
  <d2l-input-text
342
350
  autocomplete="${ifDefined(this.autocomplete)}"
@@ -351,7 +359,7 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
351
359
  .forceInvalid="${this.invalid}"
352
360
  ?hide-invalid-icon="${this.hideInvalidIcon}"
353
361
  id="${this._inputId}"
354
- input-width="${this.inputWidth}"
362
+ input-width="${hasRelativeInputWidth ? 'none' : this.inputWidth}"
355
363
  @invalid-change="${this._handleInvalidChange}"
356
364
  label="${ifDefined(this.label)}"
357
365
  ?label-hidden="${this.labelHidden || this.labelledBy}"
@@ -360,13 +368,14 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
360
368
  placeholder="${ifDefined(this.placeholder)}"
361
369
  ?required="${this.required}"
362
370
  ?skeleton="${this.skeleton}"
371
+ style="${ifDefined(hasRelativeInputWidth ? styleMap(inputWidthStyle) : undefined)}"
363
372
  unit="${ifDefined(this.unit)}"
364
373
  unit-label="${ifDefined(this.unitLabel)}"
365
374
  .value="${this._formattedValue}"
366
375
  value-align="${valueAlign}">
367
376
  <slot slot="left" name="left"></slot>
368
377
  <slot slot="right" name="right"></slot>
369
- <slot slot="after" name="after"></slot>
378
+ <slot slot="after" name="after" @slotchange=${this._handleAfterSlotChange}></slot>
370
379
  <slot slot="inline-help" name="inline-help"></slot>
371
380
  </d2l-input-text>
372
381
  ${this._getTooltip()}
@@ -439,6 +448,13 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
439
448
  }
440
449
  }
441
450
 
451
+ async _handleAfterSlotChange(e) {
452
+ const nodes = e.target.assignedNodes();
453
+ const inputTextElem = this.shadowRoot.querySelector('d2l-input-text');
454
+ await inputTextElem.updateComplete;
455
+ this._afterSlotWidth = nodes.reduce((width, ele) => width + ele.clientWidth, 0);
456
+ }
457
+
442
458
  _handleBlur() {
443
459
  this._hintType = HINT_TYPES.NONE;
444
460
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.45.0",
3
+ "version": "3.45.1",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",