@brightspace-ui/core 1.242.2 → 2.0.2

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.
@@ -30,11 +30,7 @@ class CodeView extends LitElement {
30
30
  if (Prism.languages[language]) {
31
31
  this._dependenciesPromise = Promise.resolve();
32
32
  } else {
33
- /* Current, non-relative imports don't appear to work with Polymer dev server
34
- for FF, Edge, IE11. Use of non-default languages is limited to dev with this approach.
35
- https://github.com/Polymer/tools/issues/3402 */
36
- const path = `/node_modules/prismjs/components/prism-${language}.min.js`;
37
- this._dependenciesPromise = import(path);
33
+ this._dependenciesPromise = import(`./node_modules/prismjs/components/prism-${language}.min.js`);
38
34
  }
39
35
  if (this.shadowRoot) this._updateCode(this.shadowRoot.querySelector('slot'));
40
36
  super.attributeChangedCallback(name, oldval, newval);
@@ -157,16 +157,6 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
157
157
  return 'd2l-dropdown-button-subtle';
158
158
  }
159
159
 
160
- connectedCallback() {
161
- super.connectedCallback();
162
- this._activeFiltersSubscribers.hostConnected();
163
- }
164
-
165
- disconnectedCallback() {
166
- super.disconnectedCallback();
167
- this._activeFiltersSubscribers.hostDisconnected();
168
- }
169
-
170
160
  firstUpdated(changedProperties) {
171
161
  super.firstUpdated(changedProperties);
172
162
  this.addEventListener('d2l-filter-dimension-data-change', this._handleDimensionDataChange);
@@ -174,7 +174,6 @@ class HtmlBlock extends RtlMixin(LitElement) {
174
174
 
175
175
  connectedCallback() {
176
176
  super.connectedCallback();
177
- if (this._contextObserverController) this._contextObserverController.hostConnected();
178
177
 
179
178
  if (!this._contentObserver || this.noDeferredRendering) return;
180
179
 
@@ -188,7 +187,6 @@ class HtmlBlock extends RtlMixin(LitElement) {
188
187
 
189
188
  disconnectedCallback() {
190
189
  super.disconnectedCallback();
191
- if (this._contextObserverController) this._contextObserverController.hostDisconnected();
192
190
  if (this._contentObserver) this._contentObserver.disconnect();
193
191
  }
194
192
 
@@ -14,6 +14,7 @@ export class HtmlAttributeObserverController {
14
14
  );
15
15
 
16
16
  this._host = host;
17
+ host.addController(this);
17
18
  this._attributes = attributes;
18
19
  this.values = new Map();
19
20
  }
@@ -136,24 +136,7 @@ An example of what this could look like altogether:
136
136
  <younger-viewer for="rogers"></younger-viewer>
137
137
  ```
138
138
 
139
- NOTE: Until we are on Lit 2, the controller lifecycle events will need to be manually called:
140
- ```js
141
- connectedCallback() {
142
- super.connectedCallback();
143
- if (this._subscriptionController) this._subscriptionController.hostConnected();
144
- }
145
-
146
- disconnectedCallback() {
147
- super.disconnectedCallback();
148
- if (this._subscriptionController) this._subscriptionController.hostDisconnected();
149
- }
150
-
151
- updated(changedProperties) {
152
- super.updated(changedProperties);
153
- if (this._subscriptionController) this._subscriptionController.hostUpdated(changedProperties);
154
- }
155
- ```
156
-
139
+ As of the Lit 2 upgrade, the lifecycle methods `hostConnected`, `hostDisconnected`, and `hostUpdated` will be called automatically.
157
140
  ## Available Callbacks
158
141
 
159
142
  ### SubscriberRegistryController
@@ -4,6 +4,7 @@ export class SubscriberRegistryController {
4
4
 
5
5
  constructor(host, callbacks, options) {
6
6
  this._host = host;
7
+ host.addController(this);
7
8
  this._callbacks = callbacks || {};
8
9
  this._eventName = options && options.eventName;
9
10
  this._subscribers = new Map();
@@ -60,6 +61,7 @@ export class EventSubscriberController {
60
61
 
61
62
  constructor(host, callbacks, options) {
62
63
  this._host = host;
64
+ host.addController(this);
63
65
  this._callbacks = callbacks || {};
64
66
  this._eventName = options && options.eventName;
65
67
  this._controllerId = options && options.controllerId;
@@ -99,8 +101,10 @@ export class IdSubscriberController {
99
101
 
100
102
  constructor(host, callbacks, options) {
101
103
  this._host = host;
104
+ host.addController(this);
102
105
  this._callbacks = callbacks || {};
103
106
  this._idPropertyName = options && options.idPropertyName;
107
+ this._idPropertyValue = this._idPropertyName ? this._host[this._idPropertyName] : undefined;
104
108
  this._controllerId = options && options.controllerId;
105
109
  this._registries = new Map();
106
110
  this._timeouts = new Set();
@@ -118,8 +122,11 @@ export class IdSubscriberController {
118
122
  });
119
123
  }
120
124
 
121
- hostUpdated(changedProperties) {
122
- if (!changedProperties.has(this._idPropertyName)) return;
125
+ hostUpdated() {
126
+ const propertyValue = this._host[this._idPropertyName];
127
+ if (propertyValue === this._idPropertyValue) return;
128
+
129
+ this._idPropertyValue = propertyValue;
123
130
 
124
131
  if (this._registryObserver) this._registryObserver.disconnect();
125
132
  this._registries.forEach(registry => {
@@ -9302,11 +9302,11 @@
9302
9302
  "properties": [
9303
9303
  {
9304
9304
  "name": "offIcon",
9305
- "type": "TemplateResult"
9305
+ "type": "TemplateResult<1>"
9306
9306
  },
9307
9307
  {
9308
9308
  "name": "onIcon",
9309
- "type": "TemplateResult"
9309
+ "type": "TemplateResult<1>"
9310
9310
  },
9311
9311
  {
9312
9312
  "name": "text",
@@ -9391,11 +9391,11 @@
9391
9391
  "properties": [
9392
9392
  {
9393
9393
  "name": "offIcon",
9394
- "type": "TemplateResult"
9394
+ "type": "TemplateResult<1>"
9395
9395
  },
9396
9396
  {
9397
9397
  "name": "onIcon",
9398
- "type": "TemplateResult"
9398
+ "type": "TemplateResult<1>"
9399
9399
  },
9400
9400
  {
9401
9401
  "name": "text",
@@ -12,14 +12,14 @@ If the elements are known up-front and are in the element's local DOM scope, sim
12
12
  import { ArrowKeysMixin } from '@brightspace-ui/core/mixins/arrow-keys-mixin.js';
13
13
  class MyElement extends ArrowKeysMixin(LitElement) {
14
14
  render() {
15
- return html`
15
+ return this.arrowKeysContainer(html`
16
16
  <div>
17
17
  ...
18
18
  <a href="..." class="d2l-arrowkeys-focusable">link 1</a>
19
19
  <a href="..." class="d2l-arrowkeys-focusable">link 2</a>
20
20
  ...
21
21
  </div>
22
- `;
22
+ `);
23
23
  }
24
24
  }
25
25
  customElements.define('my-element', MyElement);
@@ -31,14 +31,14 @@ If the elements are not known up front, or the elements cannot be simply queried
31
31
  import { ArrowKeysMixin } from '@brightspace-ui/core/mixins/arrow-keys-mixin.js';
32
32
  class MyElement extends ArrowKeysMixin(LitElement) {
33
33
  render() {
34
- return html`
34
+ return this.arrowKeysContainer(html`
35
35
  <div>
36
36
  ...
37
37
  <a href="...">link 1</a>
38
38
  <a href="...">link 2</a>
39
39
  ...
40
40
  </div>
41
- `;
41
+ `);
42
42
  }
43
43
  async arrowKeysFocusablesProvider() {
44
44
  return [ /* array containing focusable elements */]
@@ -51,4 +51,8 @@ customElements.define('my-element', MyElement);
51
51
 
52
52
  - `arrowKeysDirection` (String): Indicates which arrow keys are allowed (default is leftright)
53
53
  - `arrowKeysNoWrap` (Boolean): Whether focus should wrap from end-to-start and start-to-end
54
- - `arrowKeysBeforeFocus` (Function): Async callback invoked before focus us applied
54
+
55
+ **Methods:**
56
+ - `arrowKeysContainer(innerHtmlTemplate)`: Hooks up the event listener, to be used in your `render` function to wrap the focusable elements
57
+ - `async arrowKeysFocusablesProvider()` (Array): Optional - Override to provide the focusable elements if necessary (see above)
58
+ - `async arrowKeysOnBeforeFocus(elemToBeFocused)`: Optional - Override to provide an async callback invoked before focus is applied
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.242.2",
3
+ "version": "2.0.2",
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",
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@babel/eslint-parser": "^7",
47
47
  "@brightspace-ui/stylelint-config": "^0.4",
48
- "@open-wc/testing": "^2",
48
+ "@open-wc/testing": "^3",
49
49
  "@web/dev-server": "^0.1",
50
50
  "@web/test-runner": "^0.13",
51
51
  "@web/test-runner-playwright": "^0.8",
@@ -70,8 +70,8 @@
70
70
  "focus-visible": "^5",
71
71
  "ifrau": "^0.39",
72
72
  "intl-messageformat": "^7",
73
- "lit-element": "^2",
74
- "lit-html": "^1",
73
+ "lit-element": "^3",
74
+ "lit-html": "^2",
75
75
  "prismjs": "^1",
76
76
  "resize-observer-polyfill": "^1"
77
77
  }