@brightspace-ui/core 2.57.0 → 2.59.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.
@@ -56,6 +56,7 @@ For text searches use `<d2l-input-search>`, which wraps the native `<input type=
56
56
  | Property | Type | Description |
57
57
  |---|---|---|
58
58
  | `label` | String, required | Accessible label for the input |
59
+ | `description` | String | Additional information communicated in the `aria-describedby` on the input |
59
60
  | `disabled` | Boolean | Disables the input |
60
61
  | `maxlength` | Number | Imposes an upper character limit |
61
62
  | `no-clear` | Boolean | Prevents the "clear" button from appearing |
@@ -82,4 +83,5 @@ To make your usage of `d2l-input-search` accessible, use the following property
82
83
 
83
84
  | Attribute | Description |
84
85
  |---|---|
86
+ | `description` | Use when label on input does not provide enough context. |
85
87
  | label | **REQUIRED** [Acts as a primary label on the input](https://www.w3.org/WAI/tutorials/forms/labels/). Not visible. |
@@ -16,6 +16,11 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
16
16
 
17
17
  static get properties() {
18
18
  return {
19
+ /**
20
+ * Additional information communicated in the aria-describedby on the input
21
+ * @type {string}
22
+ */
23
+ description: { type: String, reflect: true },
19
24
  /**
20
25
  * Disables the input
21
26
  * @type {boolean}
@@ -115,6 +120,7 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
115
120
  <d2l-input-text
116
121
  label="${ifDefined(this.label)}"
117
122
  label-hidden
123
+ description="${this.description}"
118
124
  ?disabled="${this.disabled}"
119
125
  @input="${this._handleInput}"
120
126
  @keypress="${this._handleInputKeyPress}"
@@ -28,9 +28,14 @@ export const SelectionObserverMixin = superclass => class extends superclass {
28
28
 
29
29
  connectedCallback() {
30
30
  super.connectedCallback();
31
+ this.addEventListener('d2l-selection-observer-subscribe', this._handleSelectionObserverSubscribe);
32
+
31
33
  // delay subscription otherwise import/upgrade order can cause selection mixin to miss event
32
34
  requestAnimationFrame(() => {
33
- if (this.selectionFor) return;
35
+ if (this.selectionFor) {
36
+ this._handleSelectionFor();
37
+ return this._provider?.subscribeObserver(this);
38
+ }
34
39
 
35
40
  const evt = new CustomEvent('d2l-selection-observer-subscribe', {
36
41
  bubbles: true,
@@ -44,34 +49,57 @@ export const SelectionObserverMixin = superclass => class extends superclass {
44
49
 
45
50
  disconnectedCallback() {
46
51
  super.disconnectedCallback();
47
- if (this._selectionForObserver) this._selectionForObserver.disconnect();
48
- if (this._provider) this._provider.unsubscribeObserver(this);
52
+ this._disconnectSelectionForObserver();
53
+ this._disconnectProvider();
54
+ this.removeEventListener('d2l-selection-observer-subscribe', this._handleSelectionObserverSubscribe);
49
55
  }
50
56
 
51
57
  updated(changedProperties) {
52
58
  super.updated(changedProperties);
53
59
 
54
- if (!changedProperties.has('selectionFor')) return;
60
+ if (changedProperties.has('selectionFor')) this._handleSelectionFor();
61
+ }
62
+
63
+ _disconnectProvider() {
64
+ if (!this._provider) return;
65
+ this._provider.unsubscribeObserver(this);
66
+ this._provider = undefined;
67
+ }
55
68
 
56
- if (this._selectionForObserver) this._selectionForObserver.disconnect();
57
- if (this._provider) this._provider.unsubscribeObserver(this);
69
+ _disconnectSelectionForObserver() {
70
+ if (!this._selectionForObserver) return;
71
+ this._selectionForObserver.disconnect();
72
+ this._selectionForObserver = undefined;
73
+ }
58
74
 
75
+ _handleSelectionFor() {
76
+ this._disconnectSelectionForObserver();
59
77
  this._updateProvider();
60
78
 
61
- this._selectionForObserver = new MutationObserver(() => {
62
- this._updateProvider();
63
- });
79
+ if (this.selectionFor) {
80
+ this._selectionForObserver = new MutationObserver(() => this._updateProvider());
64
81
 
65
- this._selectionForObserver.observe(this.getRootNode(), {
66
- childList: true,
67
- subtree: true
68
- });
82
+ this._selectionForObserver.observe(this.getRootNode(), {
83
+ childList: true,
84
+ subtree: true
85
+ });
86
+ }
87
+ }
88
+
89
+ _handleSelectionObserverSubscribe(e) {
90
+ if (e.target !== this && this._provider) {
91
+ e.stopPropagation();
92
+ e.detail.provider = this._provider;
93
+ const target = e.composedPath()[0];
94
+ this._provider.subscribeObserver(target);
95
+ }
69
96
  }
70
97
 
71
98
  _updateProvider() {
72
- const selectionComponent = this.getRootNode().querySelector(`#${cssEscape(this.selectionFor)}`);
99
+ const selectionComponent = this.selectionFor ? this.getRootNode().querySelector(`#${cssEscape(this.selectionFor)}`) : undefined;
73
100
  if (this._provider === selectionComponent) return;
74
101
 
102
+ this._disconnectProvider();
75
103
  this._provider = selectionComponent;
76
104
  if (this._provider) {
77
105
  this._provider.subscribeObserver(this);
@@ -5797,6 +5797,11 @@
5797
5797
  "path": "./components/inputs/input-search.js",
5798
5798
  "description": "This component wraps the native \"<input type=\"search\">\"\" element and is for text searching.",
5799
5799
  "attributes": [
5800
+ {
5801
+ "name": "description",
5802
+ "description": "Additional information communicated in the aria-describedby on the input",
5803
+ "type": "string"
5804
+ },
5800
5805
  {
5801
5806
  "name": "label",
5802
5807
  "description": "REQUIRED: Accessible label for the input",
@@ -5832,6 +5837,12 @@
5832
5837
  }
5833
5838
  ],
5834
5839
  "properties": [
5840
+ {
5841
+ "name": "description",
5842
+ "attribute": "description",
5843
+ "description": "Additional information communicated in the aria-describedby on the input",
5844
+ "type": "string"
5845
+ },
5835
5846
  {
5836
5847
  "name": "label",
5837
5848
  "attribute": "label",
@@ -9990,6 +10001,37 @@
9990
10001
  }
9991
10002
  ]
9992
10003
  },
10004
+ {
10005
+ "name": "d2l-test-selection-observer",
10006
+ "path": "./components/selection/test/selection-component.js",
10007
+ "attributes": [
10008
+ {
10009
+ "name": "selection-for",
10010
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
10011
+ "type": "string"
10012
+ }
10013
+ ],
10014
+ "properties": [
10015
+ {
10016
+ "name": "selectionFor",
10017
+ "attribute": "selection-for",
10018
+ "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
10019
+ "type": "string"
10020
+ },
10021
+ {
10022
+ "name": "selectionInfo"
10023
+ }
10024
+ ],
10025
+ "events": [
10026
+ {
10027
+ "name": "d2l-selection-observer-subscribe"
10028
+ }
10029
+ ]
10030
+ },
10031
+ {
10032
+ "name": "d2l-test-selection-observer-shadow",
10033
+ "path": "./components/selection/test/selection-component.js"
10034
+ },
9993
10035
  {
9994
10036
  "name": "d2l-test-skeleton-box",
9995
10037
  "path": "./components/skeleton/demo/skeleton-test-box.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.57.0",
3
+ "version": "2.59.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",