@brightspace-ui/core 2.155.1 → 2.156.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.
package/README.md CHANGED
@@ -110,15 +110,23 @@ npm run lint:style
110
110
 
111
111
  ### Testing
112
112
 
113
+ To run the full suite of tests:
114
+
113
115
  ```shell
114
- # lint, unit tests and axe tests
115
116
  npm test
117
+ ```
116
118
 
119
+ Alternatively, tests can be selectively run:
120
+
121
+ ```shell
117
122
  # unit tests
118
- npm run test:headless
123
+ npm run test:unit
119
124
 
120
- # debug or run a subset of local unit tests
121
- npm run test:headless:watch
125
+ # aXe accessibility tests
126
+ npm run test:axe
127
+
128
+ # translations tests
129
+ npm run test:translations
122
130
  ```
123
131
 
124
132
  Note: The axe tests require `prefers-reduced-motion` emulation to be turned on in the dev console if debugging in a local browser.
@@ -133,44 +141,11 @@ npm run test:vdiff
133
141
  npm run test:vdiff golden
134
142
  ```
135
143
 
136
- ## Versioning & Releasing
137
-
138
- > TL;DR: Commits prefixed with `fix:` and `feat:` will trigger patch and minor releases when merged to `main`. Read on for more details...
139
-
140
- The [semantic-release GitHub Action](https://github.com/BrightspaceUI/actions/tree/main/semantic-release) is called from the `release.yml` GitHub Action workflow to handle version changes and releasing.
141
-
142
- ### Version Changes
143
-
144
- All version changes should obey [semantic versioning](https://semver.org/) rules:
145
- 1. **MAJOR** version when you make incompatible API changes,
146
- 2. **MINOR** version when you add functionality in a backwards compatible manner, and
147
- 3. **PATCH** version when you make backwards compatible bug fixes.
148
-
149
- The next version number will be determined from the commit messages since the previous release. Our semantic-release configuration uses the [Angular convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular) when analyzing commits:
150
- * Commits which are prefixed with `fix:` or `perf:` will trigger a `patch` release. Example: `fix: validate input before using`
151
- * Commits which are prefixed with `feat:` will trigger a `minor` release. Example: `feat: add toggle() method`
152
- * To trigger a MAJOR release, include `BREAKING CHANGE:` with a space or two newlines in the footer of the commit message
153
- * Other suggested prefixes which will **NOT** trigger a release: `build:`, `ci:`, `docs:`, `style:`, `refactor:` and `test:`. Example: `docs: adding README for new component`
154
-
155
- To revert a change, add the `revert:` prefix to the original commit message. This will cause the reverted change to be omitted from the release notes. Example: `revert: fix: validate input before using`.
156
-
157
- ### Releases
158
-
159
- When a release is triggered, it will:
160
- * Update the version in `package.json`
161
- * Tag the commit
162
- * Create a GitHub release (including release notes)
163
- * Deploy a new package to NPM
164
-
165
- ### Releasing from Maintenance Branches
166
-
167
- Occasionally you'll want to backport a feature or bug fix to an older release. `semantic-release` refers to these as [maintenance branches](https://semantic-release.gitbook.io/semantic-release/usage/workflow-configuration#maintenance-branches).
144
+ ### Versioning and Releasing
168
145
 
169
- Maintenance branch names should be of the form: `+([0-9])?(.{+([0-9]),x}).x`.
146
+ This repo is configured to use `semantic-release`. Commits prefixed with `fix:` and `feat:` will trigger patch and minor releases when merged to `main`.
170
147
 
171
- Regular expressions are complicated, but this essentially means branch names should look like:
172
- * `1.15.x` for patch releases on top of the `1.15` release (after version `1.16` exists)
173
- * `2.x` for feature releases on top of the `2` release (after version `3` exists)
148
+ To learn how to create major releases and release from maintenance branches, refer to the [semantic-release GitHub Action](https://github.com/BrightspaceUI/actions/tree/main/semantic-release) documentation.
174
149
 
175
150
  ## Future Enhancements
176
151
 
@@ -89,7 +89,7 @@ Examples are provided to display how user-authored math can be embedded within y
89
89
 
90
90
  ### Add Context Automatically to Demos and Tests
91
91
 
92
- You can automatically set-up the `mathjax` context for demo pages and unit tests when using `@web/dev-server` and `@web/test-runner` by adding the following plugin to your configuration.
92
+ You can automatically set-up the `mathjax` context for demo pages and unit tests when using `@web/dev-server` by adding the following plugin to your configuration.
93
93
 
94
94
  ```javascript
95
95
  export default {
@@ -110,3 +110,12 @@ export default {
110
110
  ...
111
111
  }
112
112
  ```
113
+
114
+ For tests using `@brightspace-ui/testing`, pass in the following option:
115
+
116
+ ```javascript
117
+ const elem = await fixture(
118
+ html`<d2l-html-block html="..."></d2l-html-block>`,
119
+ { mathjax: { renderLatex: true } }
120
+ );
121
+ ```
@@ -4,10 +4,10 @@ The `ProviderMixin` and `RequesterMixin` can be used to create a DI-like system
4
4
 
5
5
  ## Usage
6
6
 
7
- Apply the `ProviderMixin` to the component that will be responsible for providing some data to components that request it:
7
+ Apply the `ProviderMixin` to the component that will be responsible for providing some data to components that request it. Optionally, the `ProviderDelegate` class can be used to specify a function that will provide the value when requested.
8
8
 
9
9
  ```js
10
- import { ProviderMixin } from '@brightspace-ui/core/mixins/provider/provider-mixin.js';
10
+ import { ProviderMixin, ProviderDelegate } from '@brightspace-ui/core/mixins/provider/provider-mixin.js';
11
11
 
12
12
  class InterestingFactProvider extends ProviderMixin(LitElement) {
13
13
  constructor() {
@@ -15,6 +15,8 @@ class InterestingFactProvider extends ProviderMixin(LitElement) {
15
15
  this.provideInstance('d2l-interesting-fact-string', 'Olives are not the same as fish');
16
16
  this.provideInstance('d2l-interesting-fact-object', { fact: 'Olives are not the same as fish' });
17
17
  this.provideInstance('d2l-interesting-fact-function', x => `${x} are not the same as fish`);
18
+ this.provideInstance('d2l-interesting-fact-delegate', new ProviderDelegate(() => 'Olives are not the same as fish'));
19
+ this.provideInstance('d2l-interesting-fact-async-delegate', new ProviderDelegate(() => new Promise(...)));
18
20
  }
19
21
  }
20
22
  ```
@@ -1,9 +1,20 @@
1
+ export class ProviderDelegate {
2
+ constructor(delegate) {
3
+ this.delegate = delegate;
4
+ }
5
+ }
6
+
1
7
  export function provideInstance(node, key, obj) {
2
8
  if (!node._providerInstances) {
3
9
  node._providerInstances = new Map();
4
10
  node.addEventListener('d2l-request-instance', e => {
5
11
  if (node._providerInstances.has(e.detail.key)) {
6
- e.detail.instance = node._providerInstances.get(e.detail.key);
12
+ const instance = node._providerInstances.get(e.detail.key);
13
+ if (instance instanceof ProviderDelegate) {
14
+ e.detail.instance = instance.delegate();
15
+ } else {
16
+ e.detail.instance = instance;
17
+ }
7
18
  e.stopPropagation();
8
19
  }
9
20
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.155.1",
3
+ "version": "2.156.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",
@@ -18,10 +18,9 @@
18
18
  "lint:eslint": "eslint . --ext .js,.html --ignore-path .gitignore",
19
19
  "lint:style": "stylelint \"**/*.{js,html}\" --ignore-path .gitignore",
20
20
  "start": "web-dev-server --node-resolve --watch --open",
21
- "test": "npm run lint && npm run test:translations && npm run test:headless && npm run test:axe",
21
+ "test": "npm run lint && npm run test:translations && npm run test:unit && npm run test:axe",
22
22
  "test:axe": "d2l-test-runner aXe",
23
- "test:headless": "d2l-test-runner",
24
- "test:headless:watch": "d2l-test-runner --watch",
23
+ "test:unit": "d2l-test-runner",
25
24
  "test:translations": "mfv -e -s en -p ./lang/ -i untranslated",
26
25
  "test:vdiff": "d2l-test-runner vdiff"
27
26
  },
@@ -52,7 +51,6 @@
52
51
  "@rollup/plugin-node-resolve": "^15",
53
52
  "@rollup/plugin-replace": "^5",
54
53
  "@web/dev-server": "^0.2",
55
- "@web/test-runner": "^0.16",
56
54
  "axe-core": "^4",
57
55
  "chalk": "^5",
58
56
  "eslint": "^8",