@brightspace-ui/core 2.157.0 → 2.159.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.
@@ -1,14 +1,11 @@
|
|
1
1
|
import '@formatjs/intl-pluralrules/dist-es6/polyfill-locales.js';
|
2
|
+
import { defaultLocale as fallbackLang, getDocumentLocaleSettings, supportedLangpacks } from '@brightspace-ui/intl/lib/common.js';
|
2
3
|
import { dedupeMixin } from '@open-wc/dedupe-mixin';
|
3
|
-
import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js';
|
4
4
|
import { getLocalizeOverrideResources } from '../../helpers/getLocalizeResources.js';
|
5
5
|
import { html } from 'lit';
|
6
6
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
7
7
|
import IntlMessageFormat from 'intl-messageformat';
|
8
8
|
|
9
|
-
const fallbackLang = 'en';
|
10
|
-
const supportedLangpacks = ['ar', 'cy', 'da', 'de', 'en', 'en-gb', 'es', 'es-es', 'fr', 'fr-fr', 'fr-on', 'hi', 'ja', 'ko', 'nl', 'pt', 'sv', 'tr', 'zh-cn', 'zh-tw'];
|
11
|
-
|
12
9
|
export const _LocalizeMixinBase = dedupeMixin(superclass => class LocalizeMixinClass extends superclass {
|
13
10
|
|
14
11
|
static get properties() {
|
@@ -4,7 +4,7 @@ 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. Optionally, the `ProviderDelegate` class can be used to specify a function that will provide
|
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 a cached value when requested. If `noCache: true` is passed, the value will not be cached.
|
8
8
|
|
9
9
|
```js
|
10
10
|
import { ProviderMixin, ProviderDelegate } from '@brightspace-ui/core/mixins/provider/provider-mixin.js';
|
@@ -16,6 +16,7 @@ class InterestingFactProvider extends ProviderMixin(LitElement) {
|
|
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
18
|
this.provideInstance('d2l-interesting-fact-delegate', new ProviderDelegate(() => 'Olives are not the same as fish'));
|
19
|
+
this.provideInstance('d2l-interesting-fact-delegate', new ProviderDelegate(() => 'Olives are not the same as fish', noCache));
|
19
20
|
this.provideInstance('d2l-interesting-fact-async-delegate', new ProviderDelegate(() => new Promise(...)));
|
20
21
|
}
|
21
22
|
}
|
@@ -1,6 +1,13 @@
|
|
1
1
|
export class ProviderDelegate {
|
2
|
-
constructor(delegate) {
|
3
|
-
this.
|
2
|
+
constructor(delegate, noCache) {
|
3
|
+
this._noCache = noCache;
|
4
|
+
this._delegate = delegate;
|
5
|
+
}
|
6
|
+
getValue() {
|
7
|
+
if (this._noCache || this._value === undefined) {
|
8
|
+
this._value = this._delegate();
|
9
|
+
}
|
10
|
+
return this._value;
|
4
11
|
}
|
5
12
|
}
|
6
13
|
|
@@ -11,7 +18,7 @@ export function provideInstance(node, key, obj) {
|
|
11
18
|
if (node._providerInstances.has(e.detail.key)) {
|
12
19
|
const instance = node._providerInstances.get(e.detail.key);
|
13
20
|
if (instance instanceof ProviderDelegate) {
|
14
|
-
e.detail.instance = instance.
|
21
|
+
e.detail.instance = instance.getValue();
|
15
22
|
} else {
|
16
23
|
e.detail.instance = instance;
|
17
24
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.159.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,7 +19,7 @@
|
|
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:unit && npm run test:axe",
|
22
|
-
"test:axe": "d2l-test-runner
|
22
|
+
"test:axe": "d2l-test-runner axe --chrome",
|
23
23
|
"test:unit": "d2l-test-runner",
|
24
24
|
"test:translations": "mfv -e -s en -p ./lang/ -i untranslated",
|
25
25
|
"test:vdiff": "d2l-test-runner vdiff"
|