@brightspace-ui/core 2.174.1 → 2.175.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.
@@ -175,6 +175,27 @@ To make your `d2l-button-icon` accessible, use the following properties when app
175
175
  </d2l-button-icon>
176
176
  ```
177
177
 
178
+ ## Add Button [d2l-button-add]
179
+
180
+ The `d2l-button-add` element is for quickly adding new items inline (for example in a list).
181
+
182
+ <!-- docs: demo code properties name:d2l-button-add display:block autoSize:false size:xsmall -->
183
+ ```html
184
+ <script type="module">
185
+ import '@brightspace-ui/core/components/button/button-add.js';
186
+ </script>
187
+ <d2l-button-add text="Add New Item"></d2l-button-add>
188
+ ```
189
+
190
+ <!-- docs: start hidden content -->
191
+ ### Properties
192
+
193
+ | Property | Type | Description |
194
+ |--|--|--|
195
+ | `text` | String, required | The text associated with the button. When mode is "icon-and-text", this text is displayed next to the icon. Otherwise this text is in a tooltip. |
196
+ | `mode` | String | Display mode of the component. Defaults to "icon" (plus icon is always visible). Other options are "icon-and-text" (plus icon and text are always visible), and "icon-when-interacted" (plus icon is only visible when hover or focus). |
197
+ <!-- docs: end hidden content -->
198
+
178
199
  ## Floating Buttons [d2l-floating-buttons]
179
200
 
180
201
  See [floating buttons](https://github.com/BrightspaceUI/core/tree/main/components/button/floating-buttons.md).
@@ -11,9 +11,9 @@ import { PropertyRequiredMixin } from '../../mixins/property-required/property-r
11
11
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
12
12
 
13
13
  const MODE = {
14
- ICON: 'icon',
15
- ICON_AND_TEXT: 'icon-and-text',
16
- ICON_WHEN_INTERACTED: 'icon-when-interacted'
14
+ icon: 'icon',
15
+ icon_and_text: 'icon-and-text',
16
+ icon_when_interacted: 'icon-when-interacted'
17
17
  };
18
18
 
19
19
  /**
@@ -23,12 +23,12 @@ class ButtonAdd extends RtlMixin(PropertyRequiredMixin(FocusMixin(LocalizeCoreEl
23
23
  static get properties() {
24
24
  return {
25
25
  /**
26
- * Display mode of the component. Defaults to "icon" (plus icon is always visible). Other options are "icon-and-text" (plus icon and text are always visible), and "icon-when-interacted" (plus icon is only visible when hover or focus).
26
+ * Display mode of the component. Defaults to `icon` (plus icon is always visible). Other options are `icon-and-text` (plus icon and text are always visible), and `icon-when-interacted` (plus icon is only visible when hover or focus).
27
27
  * @type {'icon'|'icon-and-text'|'icon-when-interacted'}
28
28
  */
29
29
  mode: { type: String, reflect: true },
30
30
  /**
31
- * When text-visible is true, the text to show in the button. When text-visible is false, the text to show in the tooltip.
31
+ * The text associated with the button. When mode is `icon-and-text` this text is displayed next to the icon, otherwise this text is in a tooltip.
32
32
  * @type {string}
33
33
  */
34
34
  text: { type: String, required: true }
@@ -155,7 +155,7 @@ class ButtonAdd extends RtlMixin(PropertyRequiredMixin(FocusMixin(LocalizeCoreEl
155
155
  constructor() {
156
156
  super();
157
157
 
158
- this.mode = MODE.ICON;
158
+ this.mode = MODE.icon;
159
159
 
160
160
  this._buttonId = getUniqueId();
161
161
  }
@@ -166,13 +166,13 @@ class ButtonAdd extends RtlMixin(PropertyRequiredMixin(FocusMixin(LocalizeCoreEl
166
166
 
167
167
  render() {
168
168
  const text = this.text || this.localize('components.button-add.addItem');
169
- const id = !this.mode !== MODE.ICON_AND_TEXT ? this._buttonId : undefined;
170
- const offset = this.mode === MODE.ICON_WHEN_INTERACTED ? 23 : 18;
169
+ const id = !this.mode !== MODE.icon_and_text ? this._buttonId : undefined;
170
+ const offset = this.mode === MODE.icon_when_interacted ? 23 : 18;
171
171
 
172
- const content = this.mode !== MODE.ICON_AND_TEXT
173
- ? html`<d2l-button-add-icon-text ?visible-on-ancestor="${this.mode === MODE.ICON_WHEN_INTERACTED}" animation-type="opacity"></d2l-button-add-icon-text>`
172
+ const content = this.mode !== MODE.icon_and_text
173
+ ? html`<d2l-button-add-icon-text ?visible-on-ancestor="${this.mode === MODE.icon_when_interacted}" animation-type="opacity"></d2l-button-add-icon-text>`
174
174
  : html`<d2l-button-add-icon-text text="${text}"></d2l-button-add-icon-text>`;
175
- const tooltip = this.mode !== MODE.ICON_AND_TEXT
175
+ const tooltip = this.mode !== MODE.icon_and_text
176
176
  ? html`<d2l-tooltip class="vdiff-target" delay="100" offset="${offset}" for="${this._buttonId}" for-type="label">${text}</d2l-tooltip>`
177
177
  : nothing;
178
178
 
@@ -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
 
@@ -350,29 +350,29 @@
350
350
  "attributes": [
351
351
  {
352
352
  "name": "text",
353
- "description": "When text-visible is true, the text to show in the button. When text-visible is false, the text to show in the tooltip.",
353
+ "description": "The text associated with the button. When mode is `icon-and-text` this text is displayed next to the icon, otherwise this text is in a tooltip.",
354
354
  "type": "string"
355
355
  },
356
356
  {
357
357
  "name": "mode",
358
- "description": "Display mode of the component. Defaults to \"icon\" (plus icon is always visible). Other options are \"icon-and-text\" (plus icon and text are always visible), and \"icon-when-interacted\" (plus icon is only visible when hover or focus).",
358
+ "description": "Display mode of the component. Defaults to `icon` (plus icon is always visible). Other options are `icon-and-text` (plus icon and text are always visible), and `icon-when-interacted` (plus icon is only visible when hover or focus).",
359
359
  "type": "'icon'|'icon-and-text'|'icon-when-interacted'",
360
- "default": "\"ICON\""
360
+ "default": "\"icon\""
361
361
  }
362
362
  ],
363
363
  "properties": [
364
364
  {
365
365
  "name": "text",
366
366
  "attribute": "text",
367
- "description": "When text-visible is true, the text to show in the button. When text-visible is false, the text to show in the tooltip.",
367
+ "description": "The text associated with the button. When mode is `icon-and-text` this text is displayed next to the icon, otherwise this text is in a tooltip.",
368
368
  "type": "string"
369
369
  },
370
370
  {
371
371
  "name": "mode",
372
372
  "attribute": "mode",
373
- "description": "Display mode of the component. Defaults to \"icon\" (plus icon is always visible). Other options are \"icon-and-text\" (plus icon and text are always visible), and \"icon-when-interacted\" (plus icon is only visible when hover or focus).",
373
+ "description": "Display mode of the component. Defaults to `icon` (plus icon is always visible). Other options are `icon-and-text` (plus icon and text are always visible), and `icon-when-interacted` (plus icon is only visible when hover or focus).",
374
374
  "type": "'icon'|'icon-and-text'|'icon-when-interacted'",
375
- "default": "\"ICON\""
375
+ "default": "\"icon\""
376
376
  },
377
377
  {
378
378
  "name": "documentLocaleSettings",
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.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",