@brightspace-ui/core 2.135.0 → 2.136.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.
@@ -329,17 +329,21 @@ class InputText extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMixin(
329
329
  if (this.hasAttribute('aria-label')) {
330
330
  this.labelRequired = false;
331
331
  }
332
+ this.addEventListener('mouseover', this._handleMouseEnter);
333
+ this.addEventListener('mouseout', this._handleMouseLeave);
334
+ this.addEventListener('click', this._handleClick);
332
335
  }
333
336
 
334
337
  disconnectedCallback() {
335
338
  super.disconnectedCallback();
336
339
  if (this._intersectionObserver) this._intersectionObserver.disconnect();
337
340
  const container = this.shadowRoot && this.shadowRoot.querySelector('.d2l-input-text-container');
341
+ this.removeEventListener('mouseover', this._handleMouseEnter);
342
+ this.removeEventListener('mouseout', this._handleMouseLeave);
343
+ this.removeEventListener('click', this._handleClick);
338
344
  if (!container) return;
339
345
  container.removeEventListener('blur', this._handleBlur, true);
340
346
  container.removeEventListener('focus', this._handleFocus, true);
341
- container.removeEventListener('mouseover', this._handleMouseEnter);
342
- container.removeEventListener('mouseout', this._handleMouseLeave);
343
347
  }
344
348
 
345
349
  firstUpdated(changedProperties) {
@@ -352,8 +356,6 @@ class InputText extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMixin(
352
356
  if (!container) return;
353
357
  container.addEventListener('blur', this._handleBlur, true);
354
358
  container.addEventListener('focus', this._handleFocus, true);
355
- container.addEventListener('mouseover', this._handleMouseEnter);
356
- container.addEventListener('mouseout', this._handleMouseLeave);
357
359
 
358
360
  // if initially hidden then update layout when it becomes visible
359
361
  if (typeof(IntersectionObserver) === 'function') {
@@ -542,6 +544,12 @@ class InputText extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMixin(
542
544
  ));
543
545
  }
544
546
 
547
+ _handleClick(e) {
548
+ const input = this.shadowRoot?.querySelector('.d2l-input');
549
+ if (!input || e.composedPath()[0] !== this) return;
550
+ input.focus();
551
+ }
552
+
545
553
  _handleFocus() {
546
554
  this._focused = true;
547
555
  }
@@ -1,5 +1,6 @@
1
1
  import '../tooltip/tooltip.js';
2
2
  import { css, html, LitElement } from 'lit';
3
+ import { classMap } from 'lit-html/directives/class-map.js';
3
4
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
4
5
  import { formatNumber } from '@brightspace-ui/intl/lib/number.js';
5
6
  import { FormElementMixin } from '../form/form-element-mixin.js';
@@ -86,7 +87,8 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
86
87
  * Value of the input
87
88
  * @type {string}
88
89
  */
89
- value: { type: String }
90
+ value: { type: String },
91
+ _hovered: { state: true }
90
92
  };
91
93
  }
92
94
 
@@ -157,6 +159,7 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
157
159
  this.value = '';
158
160
 
159
161
  this._descriptionId = getUniqueId();
162
+ this._hovered = false;
160
163
  this._textareaId = getUniqueId();
161
164
  }
162
165
 
@@ -192,6 +195,16 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
192
195
  if (this.hasAttribute('aria-label')) {
193
196
  this.labelRequired = false;
194
197
  }
198
+ this.addEventListener('mouseover', this._handleMouseEnter);
199
+ this.addEventListener('mouseout', this._handleMouseLeave);
200
+ this.addEventListener('click', this._handleClick);
201
+ }
202
+
203
+ disconnectedCallback() {
204
+ super.disconnectedCallback();
205
+ this.removeEventListener('mouseover', this._handleMouseEnter);
206
+ this.removeEventListener('mouseout', this._handleMouseLeave);
207
+ this.removeEventListener('click', this._handleClick);
195
208
  }
196
209
 
197
210
  render() {
@@ -211,6 +224,11 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
211
224
  if (this.rows > 0) mirrorStyles.minHeight = `calc(${this.rows + 1}rem + 2px)`;
212
225
  if (this.maxRows > 0) mirrorStyles.maxHeight = `calc(${this.maxRows + 1}rem + 2px)`;
213
226
 
227
+ const inputClasses = {
228
+ 'd2l-input': true,
229
+ 'd2l-input-focus': !this.disabled && this._hovered
230
+ };
231
+
214
232
  const textarea = html`
215
233
  <div class="d2l-input-textarea-container d2l-skeletize">
216
234
  <div class="d2l-input d2l-input-textarea-mirror" style="${styleMap(mirrorStyles)}" aria-invalid="${ifDefined(ariaInvalid)}">
@@ -222,7 +240,7 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
222
240
  aria-required="${ifDefined(ariaRequired)}"
223
241
  @blur="${this._handleBlur}"
224
242
  @change="${this._handleChange}"
225
- class="d2l-input"
243
+ class=${classMap(inputClasses)}
226
244
  ?disabled="${disabled}"
227
245
  id="${this._textareaId}"
228
246
  @input="${this._handleInput}"
@@ -307,6 +325,12 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
307
325
  ));
308
326
  }
309
327
 
328
+ _handleClick(e) {
329
+ const input = this.shadowRoot && this.shadowRoot.querySelector('textarea');
330
+ if (!input || e.composedPath()[0] !== this) return;
331
+ input.focus();
332
+ }
333
+
310
334
  _handleInput(e) {
311
335
  this.value = e.target.value;
312
336
  return true;
@@ -316,6 +340,14 @@ class InputTextArea extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMi
316
340
  e.preventDefault();
317
341
  }
318
342
 
343
+ _handleMouseEnter() {
344
+ this._hovered = true;
345
+ }
346
+
347
+ _handleMouseLeave() {
348
+ this._hovered = false;
349
+ }
350
+
319
351
  }
320
352
 
321
353
  customElements.define('d2l-input-textarea', InputTextArea);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.135.0",
3
+ "version": "2.136.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",
@@ -19,9 +19,9 @@
19
19
  "lint:style": "stylelint \"**/*.{js,html}\" --ignore-path .gitignore",
20
20
  "start": "web-dev-server --node-resolve --watch --open",
21
21
  "test": "npm run lint && npm run test:translations && npm run test:headless && npm run test:axe",
22
- "test:axe": "web-test-runner --group aXe",
23
- "test:headless": "web-test-runner --group unit",
24
- "test:headless:watch": "web-test-runner --group unit --watch",
22
+ "test:axe": "d2l-test-runner aXe",
23
+ "test:headless": "d2l-test-runner",
24
+ "test:headless:watch": "d2l-test-runner --watch",
25
25
  "test:translations": "mfv -e -s en -p ./lang/ -i untranslated"
26
26
  },
27
27
  "files": [
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@babel/eslint-parser": "^7",
47
47
  "@brightspace-ui/stylelint-config": "^0.8",
48
- "@brightspace-ui/testing": "^0.15",
48
+ "@brightspace-ui/testing": "^0.18",
49
49
  "@open-wc/semantic-dom-diff": "^0.20",
50
50
  "@rollup/plugin-dynamic-import-vars": "^2",
51
51
  "@rollup/plugin-node-resolve": "^15",