@brightspace-ui/core 2.18.7 → 2.18.8

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,7 +1,7 @@
1
1
  import { html, LitElement } from 'lit';
2
- import { LocalizeDynamicMixin } from '../../mixins/localize-dynamic-mixin.js';
2
+ import { LocalizeMixin } from '../../mixins/localize-mixin.js';
3
3
 
4
- class LocalizeTest extends LocalizeDynamicMixin(LitElement) {
4
+ class LocalizeTest extends LocalizeMixin(LitElement) {
5
5
 
6
6
  static get properties() {
7
7
  return {
@@ -11,7 +11,7 @@ class LocalizeTest extends LocalizeDynamicMixin(LitElement) {
11
11
  };
12
12
  }
13
13
 
14
- static get localizeConfig() {
14
+ static async getLocalizeResources(langs) {
15
15
  const langResources = {
16
16
  'ar': { 'hello': 'مرحبا {name}' },
17
17
  'de': { 'hello': 'Hallo {name}' },
@@ -29,15 +29,17 @@ class LocalizeTest extends LocalizeDynamicMixin(LitElement) {
29
29
  'zh-cn': { 'hello': '你好 {name}' },
30
30
  'zh-tw': { 'hello': '你好 {name}' }
31
31
  };
32
- return {
33
- importFunc: async lang => {
34
- return new Promise((resolve) => {
35
- setTimeout(() => {
36
- resolve(langResources[lang]);
37
- }, 50);
38
- });
32
+
33
+ for (let i = 0; i < langs.length; i++) {
34
+ if (langResources[langs[i]]) {
35
+ return {
36
+ language: langs[i],
37
+ resources: langResources[langs[i]]
38
+ };
39
39
  }
40
- };
40
+ }
41
+
42
+ return null;
41
43
  }
42
44
 
43
45
  render() {
@@ -163,13 +163,12 @@ export const LocalizeMixin = dedupeMixin(superclass => class extends superclass
163
163
  }
164
164
 
165
165
  static _getAllLocalizeResources(possibleLanguages, config = this.localizeConfig) {
166
- let resourcesLoadedPromises = [];
166
+ let resourcesLoadedPromises;
167
167
  const superCtor = Object.getPrototypeOf(this);
168
- // get imported terms for each config, head up the chain to get them all
169
168
  if ('_getAllLocalizeResources' in superCtor) {
170
- // eslint-disable-next-line no-prototype-builtins
171
- const superConfig = superCtor.hasOwnProperty('localizeConfig') && superCtor.localizeConfig.importFunc ? superCtor.localizeConfig : config;
172
- resourcesLoadedPromises = superCtor._getAllLocalizeResources(possibleLanguages, superConfig);
169
+ resourcesLoadedPromises = superCtor._getAllLocalizeResources(possibleLanguages, config);
170
+ } else {
171
+ resourcesLoadedPromises = [];
173
172
  }
174
173
  // eslint-disable-next-line no-prototype-builtins
175
174
  if (this.hasOwnProperty('getLocalizeResources') || this.hasOwnProperty('resources')) {
@@ -103,17 +103,6 @@ static get localizeConfig() {
103
103
  }
104
104
  ```
105
105
 
106
- **Note:** If using `LocalizeCoreElement` or a mixin that utilizes `LocalizeCoreElement` as well as `LocalizeDynamicMixin` or a mixin that uses `LocalizeDynamicMixin`, `LocalizeDynamicMixin` **must** appear before `LocalizeCoreElement` in the chain. For example:
107
-
108
- ```javascript
109
- import { LocalizeCoreElement } from '@brightspace-ui/core/helpers/localize-core-element.js';
110
- import { LocalizeDynamicMixin } from '@brightspace-ui/core/mixins/localize-dynamic-mixin.js';
111
-
112
- class MyComponent extends LocalizeDynamicMixin(LocalizeCoreElement(LitElement)) {
113
- ...
114
- }
115
- ```
116
-
117
106
  ## `localize()`
118
107
 
119
108
  Once your localization resources are available, the `localize()` method is used to localize a piece of text in your `render()` method.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.18.7",
3
+ "version": "2.18.8",
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",