@openremote/or-translate 1.0.3 → 1.2.0-snapshot.20240512155407

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/dist/index.js DELETED
@@ -1,41 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { translate } from "./translate-mixin";
8
- import i18next from "i18next";
9
- import { LitElement, customElement, property, html, css } from "lit-element";
10
- export { i18next };
11
- export { translate };
12
- let OrTranslate = class OrTranslate extends translate(i18next)(LitElement) {
13
- render() {
14
- return html `
15
- ${this._getTranslatedValue()}
16
- `;
17
- }
18
- _getTranslatedValue() {
19
- return this.value ? i18next.isInitialized ? i18next.t(this.value, this.options) : this.value : "";
20
- }
21
- };
22
- OrTranslate.styles = css `
23
- :host {
24
- display: inline;
25
- }
26
-
27
- :host([hidden]) {
28
- display: none;
29
- }
30
- `;
31
- __decorate([
32
- property({ type: String })
33
- ], OrTranslate.prototype, "value", void 0);
34
- __decorate([
35
- property({ type: Object })
36
- ], OrTranslate.prototype, "options", void 0);
37
- OrTranslate = __decorate([
38
- customElement("or-translate")
39
- ], OrTranslate);
40
- export { OrTranslate };
41
- //# sourceMappingURL=index.js.map
@@ -1,47 +0,0 @@
1
- // TODO: Can't currently export declaration files with explicit LitElement type (see https://github.com/Microsoft/TypeScript/issues/17293)
2
- export const translate = (i18next) => (base) => class extends base {
3
- constructor() {
4
- super(...arguments);
5
- this._i18nextJustInitialized = false;
6
- this.initCallback = (options) => {
7
- this._i18nextJustInitialized = true;
8
- // @ts-ignore
9
- if (this.requestUpdate) {
10
- // @ts-ignore
11
- this.requestUpdate();
12
- }
13
- };
14
- this.langChangedCallback = () => {
15
- // @ts-ignore
16
- if (this.requestUpdate) {
17
- // @ts-ignore
18
- this.requestUpdate();
19
- }
20
- };
21
- }
22
- connectedCallback() {
23
- if (!i18next.language) {
24
- i18next.on("initialized", this.initCallback);
25
- }
26
- i18next.on("languageChanged", this.langChangedCallback);
27
- if (super.connectedCallback) {
28
- super.connectedCallback();
29
- }
30
- }
31
- disconnectedCallback() {
32
- i18next.off("initialized", this.initCallback);
33
- i18next.off("languageChanged", this.langChangedCallback);
34
- if (super.disconnectedCallback) {
35
- super.disconnectedCallback();
36
- }
37
- }
38
- shouldUpdate(changedProps) {
39
- if (this._i18nextJustInitialized) {
40
- this._i18nextJustInitialized = false;
41
- return true;
42
- }
43
- // @ts-ignore
44
- return super.shouldUpdate && super.shouldUpdate(changedProps);
45
- }
46
- };
47
- //# sourceMappingURL=translate-mixin.js.map