@brightspace-ui/core 2.174.1 → 2.175.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.
@@ -60,6 +60,29 @@
60
60
  <d2l-input-date label="Date" required></d2l-input-date>
61
61
  </template>
62
62
  </d2l-demo-snippet>
63
+
64
+ <h2>Inline Help</h2>
65
+ <d2l-demo-snippet>
66
+ <template>
67
+ <d2l-input-date label="Date">
68
+ <div slot="inline-help">
69
+ Help text <b>right here</b>!
70
+ </div>
71
+ </d2l-input-date>
72
+ </template>
73
+ </d2l-demo-snippet>
74
+
75
+ <h2>Inline Help (multiline)</h2>
76
+ <d2l-demo-snippet>
77
+ <template>
78
+ <d2l-input-date label="Date">
79
+ <div slot="inline-help">
80
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit,
81
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
82
+ </div>
83
+ </d2l-input-date>
84
+ </template>
85
+ </d2l-demo-snippet>
63
86
  </d2l-demo-page>
64
87
  </body>
65
88
  </html>
@@ -70,6 +70,34 @@
70
70
  </template>
71
71
  </d2l-demo-snippet>
72
72
 
73
+ <h2>Inline Help</h2>
74
+ <d2l-demo-snippet>
75
+ <template>
76
+ <d2l-input-percent label="Grade" value="92">
77
+ <div slot="inline-help">
78
+ Help text <b>right here</b>!
79
+ </div>
80
+ </d2l-input-percent>
81
+ </template>
82
+ </d2l-demo-snippet>
83
+
84
+ <h2>Inline Help (multiline)</h2>
85
+ <d2l-demo-snippet>
86
+ <template>
87
+ <d2l-input-percent label="Grade" value="92">
88
+ <div slot="inline-help">
89
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit,
90
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
91
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
92
+ nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
93
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
94
+ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
95
+ qui officia deserunt mollit anim id est laborum.
96
+ </div>
97
+ </d2l-input-percent>
98
+ </template>
99
+ </d2l-demo-snippet>
100
+
73
101
  </d2l-demo-page>
74
102
  <script>
75
103
  document.body.addEventListener('change', e => console.log(e, e.target.value));
@@ -75,6 +75,34 @@
75
75
  </template>
76
76
  </d2l-demo-snippet>
77
77
 
78
+ <h3>Inline Help</h3>
79
+ <d2l-demo-snippet>
80
+ <template>
81
+ <d2l-input-textarea label="Description">
82
+ <div slot="inline-help">
83
+ Help text <b>right here</b>!
84
+ </div>
85
+ </d2l-input-textarea>
86
+ </template>
87
+ </d2l-demo-snippet>
88
+
89
+ <h3>Inline Help (multiline)</h3>
90
+ <d2l-demo-snippet>
91
+ <template>
92
+ <d2l-input-textarea label="Description">
93
+ <div slot="inline-help">
94
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit,
95
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
96
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
97
+ nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
98
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
99
+ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
100
+ qui officia deserunt mollit anim id est laborum.
101
+ </div>
102
+ </d2l-input-textarea>
103
+ </template>
104
+ </d2l-demo-snippet>
105
+
78
106
  </d2l-demo-page>
79
107
  <script>
80
108
  document.body.addEventListener('input', e => {
@@ -300,6 +300,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
300
300
  style="${styleMap({ maxWidth: inputTextWidth })}"
301
301
  .value="${this._formattedValue}">
302
302
  ${icon}
303
+ <slot slot="inline-help" name="inline-help"></slot>
303
304
  </d2l-input-text>
304
305
  ${dropdownContent}
305
306
  </d2l-dropdown>
@@ -127,6 +127,7 @@ class InputPercent extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMix
127
127
  value="${ifDefined(this.value)}"
128
128
  value-align="end">
129
129
  <slot slot="after" name="after"></slot>
130
+ <slot slot="inline-help" name="inline-help"></slot>
130
131
  </d2l-input-number>
131
132
  `;
132
133
  }
@@ -6,6 +6,7 @@ import { formatNumber } from '@brightspace-ui/intl/lib/number.js';
6
6
  import { FormElementMixin } from '../form/form-element-mixin.js';
7
7
  import { getUniqueId } from '../../helpers/uniqueId.js';
8
8
  import { ifDefined } from 'lit/directives/if-defined.js';
9
+ import { InputInlineHelpMixin } from './input-inline-help-mixin.js';
9
10
  import { inputLabelStyles } from './input-label-styles.js';
10
11
  import { inputStyles } from './input-styles.js';
11
12
  import { LabelledMixin } from '../../mixins/labelled/labelled-mixin.js';
@@ -19,7 +20,7 @@ import { styleMap } from 'lit/directives/style-map.js';
19
20
  * @fires change - Dispatched when an alteration to the value is committed (typically after focus is lost) by the user
20
21
  * @fires input - Dispatched immediately after changes by the user
21
22
  */
22
- class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMixin(RtlMixin(LitElement))))) {
23
+ class InputTextArea extends InputInlineHelpMixin(FocusMixin(LabelledMixin(FormElementMixin(SkeletonMixin(RtlMixin(LitElement)))))) {
23
24
 
24
25
  static get properties() {
25
26
  return {
@@ -160,6 +161,7 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
160
161
 
161
162
  this._descriptionId = getUniqueId();
162
163
  this._hovered = false;
164
+ this._inlineHelpId = getUniqueId();
163
165
  this._textareaId = getUniqueId();
164
166
  }
165
167
 
@@ -217,6 +219,7 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
217
219
  const ariaInvalid = this.invalid ? 'true' : this.ariaInvalid;
218
220
  const offscreenContainer = this.description ? html`<div class="d2l-offscreen" id="${this._descriptionId}">${this.description}</div>` : null;
219
221
  const disabled = this.disabled || this.skeleton;
222
+ const ariaDescribedByIds = `${this.description ? this._descriptionId : ''} ${this._hasInlineHelp ? this._inlineHelpId : ''}`.trim();
220
223
 
221
224
  const mirrorStyles = {};
222
225
 
@@ -234,7 +237,8 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
234
237
  <div class="d2l-input d2l-input-textarea-mirror" style="${styleMap(mirrorStyles)}" aria-invalid="${ifDefined(ariaInvalid)}">
235
238
  ${lines.map(line => html`${line}<br />`)}
236
239
  </div>
237
- <textarea aria-describedby="${ifDefined(this.description ? this._descriptionId : undefined)}"
240
+ <textarea
241
+ aria-describedby="${ifDefined(ariaDescribedByIds.length > 0 ? ariaDescribedByIds : undefined)}"
238
242
  aria-invalid="${ifDefined(ariaInvalid)}"
239
243
  aria-label="${ifDefined(this._getAriaLabel())}"
240
244
  aria-required="${ifDefined(ariaRequired)}"
@@ -252,6 +256,7 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
252
256
  .value="${this.value}">${this.value}</textarea>
253
257
  ${this.validationError ? html`<d2l-tooltip for=${this._textareaId} state="error" align="start">${this.validationError}</d2l-tooltip>` : null}
254
258
  </div>
259
+ ${this._renderInlineHelp(this._inlineHelpId)}
255
260
  ${offscreenContainer}
256
261
  `;
257
262
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.174.1",
3
+ "version": "2.175.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",