@brightspace-ui/core 2.18.4 → 2.18.7
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.
|
@@ -683,7 +683,7 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
|
683
683
|
|
|
684
684
|
const centerDelta = contentRect.width - targetRect.width;
|
|
685
685
|
const position = this._getPosition(spaceAround, centerDelta);
|
|
686
|
-
if (position) {
|
|
686
|
+
if (position !== null) {
|
|
687
687
|
this._position = position;
|
|
688
688
|
}
|
|
689
689
|
|
|
@@ -8,6 +8,10 @@ import { SwitchMixin } from './switch-mixin.js';
|
|
|
8
8
|
*/
|
|
9
9
|
class VisibilitySwitch extends LocalizeCoreElement(SwitchMixin(LitElement)) {
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The text that is displayed for the switch label.
|
|
13
|
+
* @default "Visibility"
|
|
14
|
+
*/
|
|
11
15
|
get text() {
|
|
12
16
|
return (this._text ? this._text : this.localize('components.switch.visibility'));
|
|
13
17
|
}
|
package/custom-elements.json
CHANGED
|
@@ -9354,8 +9354,9 @@
|
|
|
9354
9354
|
"attributes": [
|
|
9355
9355
|
{
|
|
9356
9356
|
"name": "text",
|
|
9357
|
-
"description": "
|
|
9358
|
-
"type": "string"
|
|
9357
|
+
"description": "The text that is displayed for the switch label.",
|
|
9358
|
+
"type": "string",
|
|
9359
|
+
"default": "\"\\\"Visibility\\\"\""
|
|
9359
9360
|
},
|
|
9360
9361
|
{
|
|
9361
9362
|
"name": "tooltip",
|
|
@@ -9393,8 +9394,9 @@
|
|
|
9393
9394
|
{
|
|
9394
9395
|
"name": "text",
|
|
9395
9396
|
"attribute": "text",
|
|
9396
|
-
"description": "
|
|
9397
|
-
"type": "string"
|
|
9397
|
+
"description": "The text that is displayed for the switch label.",
|
|
9398
|
+
"type": "string",
|
|
9399
|
+
"default": "\"\\\"Visibility\\\"\""
|
|
9398
9400
|
},
|
|
9399
9401
|
{
|
|
9400
9402
|
"name": "tooltip",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { html, LitElement } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { LocalizeDynamicMixin } from '../../mixins/localize-dynamic-mixin.js';
|
|
3
3
|
|
|
4
|
-
class LocalizeTest extends
|
|
4
|
+
class LocalizeTest extends LocalizeDynamicMixin(LitElement) {
|
|
5
5
|
|
|
6
6
|
static get properties() {
|
|
7
7
|
return {
|
|
@@ -11,7 +11,7 @@ class LocalizeTest extends LocalizeMixin(LitElement) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
static
|
|
14
|
+
static get localizeConfig() {
|
|
15
15
|
const langResources = {
|
|
16
16
|
'ar': { 'hello': 'مرحبا {name}' },
|
|
17
17
|
'de': { 'hello': 'Hallo {name}' },
|
|
@@ -29,17 +29,15 @@ class LocalizeTest extends LocalizeMixin(LitElement) {
|
|
|
29
29
|
'zh-cn': { 'hello': '你好 {name}' },
|
|
30
30
|
'zh-tw': { 'hello': '你好 {name}' }
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
32
|
+
return {
|
|
33
|
+
importFunc: async lang => {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
resolve(langResources[lang]);
|
|
37
|
+
}, 50);
|
|
38
|
+
});
|
|
39
39
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return null;
|
|
40
|
+
};
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
render() {
|
package/mixins/localize-mixin.js
CHANGED
|
@@ -163,12 +163,13 @@ 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
|
|
168
169
|
if ('_getAllLocalizeResources' in superCtor) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
resourcesLoadedPromises =
|
|
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);
|
|
172
173
|
}
|
|
173
174
|
// eslint-disable-next-line no-prototype-builtins
|
|
174
175
|
if (this.hasOwnProperty('getLocalizeResources') || this.hasOwnProperty('resources')) {
|
package/mixins/localize-mixin.md
CHANGED
|
@@ -103,6 +103,17 @@ 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
|
+
|
|
106
117
|
## `localize()`
|
|
107
118
|
|
|
108
119
|
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.
|
|
3
|
+
"version": "2.18.7",
|
|
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",
|