@brightspace-ui/core 3.45.0 → 3.46.0

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.
@@ -47,13 +47,6 @@
47
47
  </template>
48
48
  </d2l-demo-snippet>
49
49
 
50
- <h2>Empty Text</h2>
51
- <d2l-demo-snippet>
52
- <template>
53
- <d2l-input-date label="Reminder Date" empty-text="No reminder date ever entered"></d2l-input-date>
54
- </template>
55
- </d2l-demo-snippet>
56
-
57
50
  <h2>Required</h2>
58
51
  <d2l-demo-snippet>
59
52
  <template>
@@ -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>
@@ -47,7 +47,6 @@ Note: All `*value` properties should be in ISO 8601 calendar date format (`YYYY-
47
47
  |--|--|--|
48
48
  | `label` | String, **required** | Accessible label for the input |
49
49
  | `disabled` | Boolean | Disables the input |
50
- | `empty-text` | String | Text to reassure users that they can choose not to provide a value in this field (usually not necessary) |
51
50
  | `label-hidden` | Boolean | Hides the label visually (moves it to the input's `aria-label` attribute) |
52
51
  | `labelled-by` | String | HTML id of an element in the same shadow root which acts as the input's label |
53
52
  | `max-value` | String | Maximum valid date that could be selected by a user. |
@@ -38,11 +38,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
38
38
  * @type {boolean}
39
39
  */
40
40
  disabled: { type: Boolean },
41
- /**
42
- * ADVANCED: Text that appears as a placeholder in the input to reassure users that they can choose not to provide a value (usually not necessary)
43
- * @type {string}
44
- */
45
- emptyText: { type: String, attribute: 'empty-text' },
46
41
  /**
47
42
  * @ignore
48
43
  * Optionally add a 'Now' button to be used in date-time pickers only.
@@ -149,7 +144,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
149
144
  super();
150
145
 
151
146
  this.disabled = false;
152
- this.emptyText = '';
153
147
  /** @ignore */
154
148
  this.hasNow = false;
155
149
  this.labelHidden = false;
@@ -224,8 +218,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
224
218
  this.updateComplete.then(() => tryUpdateHiddenContentWidth());
225
219
  });
226
220
 
227
- this._formattedValue = this.emptyText ? this.emptyText : '';
228
-
229
221
  await (document.fonts ? document.fonts.ready : Promise.resolve());
230
222
 
231
223
  // resize observer needed to handle case where it's initially hidden
@@ -283,7 +275,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
283
275
  <div aria-hidden="true" class="d2l-input-date-hidden-text">
284
276
  <div>${formattedWideDate}</div>
285
277
  <div>${shortDateFormat}</div>
286
- <div>${this.emptyText}</div>
287
278
  </div>
288
279
  ${errorTooltip}
289
280
  <d2l-dropdown ?disabled="${this.disabled || this.skeleton}" no-auto-open ?prefer-fixed-positioning="${this.preferFixedPositioning}">
@@ -294,7 +285,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
294
285
  @change="${this._handleChange}"
295
286
  class="d2l-dropdown-opener vdiff-target"
296
287
  instructions="${ifDefined((this._showInfoTooltip && !errorTooltip && !this.invalid && this.childErrors.size === 0 && this._inputTextFocusShowTooltip) ? this.localize(`${this._namespace}.openInstructions`, { format: shortDateFormat }) : undefined)}"
297
- description="${ifDefined(this.emptyText ? this.emptyText : undefined)}"
298
288
  ?disabled="${this.disabled}"
299
289
  @focus="${this._handleInputTextFocus}"
300
290
  @keydown="${this._handleKeydown}"
@@ -361,7 +351,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
361
351
 
362
352
  _handleBlur() {
363
353
  this._showInfoTooltip = true;
364
- this._setFormattedValue(); // needed for case with empty text click on input-text then blur
365
354
  this.requestValidate(true);
366
355
  }
367
356
 
@@ -528,7 +517,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
528
517
  }
529
518
 
530
519
  _setFormattedValue() {
531
- this._formattedValue = this._shownValue ? formatISODateInUserCalDescriptor(this._shownValue) : (this.emptyText ? this.emptyText : '');
520
+ this._formattedValue = this._shownValue ? formatISODateInUserCalDescriptor(this._shownValue) : '';
532
521
  }
533
522
 
534
523
  async _updateValueDispatchEvent(dateInISO, setToNow) {
@@ -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
  }
@@ -5961,12 +5961,6 @@
5961
5961
  "type": "boolean",
5962
5962
  "default": "false"
5963
5963
  },
5964
- {
5965
- "name": "empty-text",
5966
- "description": "ADVANCED: Text that appears as a placeholder in the input to reassure users that they can choose not to provide a value (usually not necessary)",
5967
- "type": "string",
5968
- "default": "\"\""
5969
- },
5970
5964
  {
5971
5965
  "name": "label-hidden",
5972
5966
  "description": "Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label.",
@@ -6032,13 +6026,6 @@
6032
6026
  "type": "boolean",
6033
6027
  "default": "false"
6034
6028
  },
6035
- {
6036
- "name": "emptyText",
6037
- "attribute": "empty-text",
6038
- "description": "ADVANCED: Text that appears as a placeholder in the input to reassure users that they can choose not to provide a value (usually not necessary)",
6039
- "type": "string",
6040
- "default": "\"\""
6041
- },
6042
6029
  {
6043
6030
  "name": "labelHidden",
6044
6031
  "attribute": "label-hidden",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.45.0",
3
+ "version": "3.46.0",
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",
@@ -49,7 +49,7 @@
49
49
  "@brightspace-ui/testing": "^1",
50
50
  "@rollup/plugin-dynamic-import-vars": "^2",
51
51
  "@rollup/plugin-node-resolve": "^15",
52
- "@rollup/plugin-replace": "^5",
52
+ "@rollup/plugin-replace": "^6",
53
53
  "@web/dev-server": "^0.4",
54
54
  "chalk": "^5",
55
55
  "eslint": "^8",