@openremote/or-translate 1.8.0-snapshot.20250725070921 → 1.8.0-snapshot.20250725120000

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/lib/index.js CHANGED
@@ -1,11 +1,42 @@
1
- var __decorate=this&&this.__decorate||function(e,t,r,a){var o,n=arguments.length,i=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(i=(n<3?o(i):n>3?o(t,r,i):o(t,r))||i);return n>3&&i&&Object.defineProperty(t,r,i),i};import{translate as e}from"./translate-mixin";import t from"i18next";import{LitElement as r,html as a,css as o}from"lit";import{customElement as n,property as i}from"lit/decorators.js";let OrTranslate=class extends e(t)(r){render(){return a`
2
- ${this._getTranslatedValue()}
3
- `}_getTranslatedValue(){return this.value?t.isInitialized?t.t(this.value,this.options):this.value:""}};OrTranslate.styles=o`
4
- :host {
5
- display: inline-block;
6
- }
7
-
8
- :host([hidden]) {
9
- display: none;
10
- }
11
- `,__decorate([i({type:String})],OrTranslate.prototype,"value",void 0),__decorate([i({type:Object})],OrTranslate.prototype,"options",void 0),OrTranslate=__decorate([n("or-translate")],OrTranslate);export{t as i18next,e as translate,OrTranslate};
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, html, css } from "lit";
10
+ import { customElement, property } from "lit/decorators.js";
11
+ export { i18next };
12
+ export { translate };
13
+ let OrTranslate = class OrTranslate extends translate(i18next)(LitElement) {
14
+ render() {
15
+ return html `
16
+ ${this._getTranslatedValue()}
17
+ `;
18
+ }
19
+ _getTranslatedValue() {
20
+ return this.value ? i18next.isInitialized ? i18next.t(this.value, this.options) : this.value : "";
21
+ }
22
+ };
23
+ OrTranslate.styles = css `
24
+ :host {
25
+ display: inline-block;
26
+ }
27
+
28
+ :host([hidden]) {
29
+ display: none;
30
+ }
31
+ `;
32
+ __decorate([
33
+ property({ type: String })
34
+ ], OrTranslate.prototype, "value", void 0);
35
+ __decorate([
36
+ property({ type: Object })
37
+ ], OrTranslate.prototype, "options", void 0);
38
+ OrTranslate = __decorate([
39
+ customElement("or-translate")
40
+ ], OrTranslate);
41
+ export { OrTranslate };
42
+ //# sourceMappingURL=index.js.map
@@ -1 +1,47 @@
1
- export const translate=e=>t=>class extends t{constructor(){super(...arguments),this._i18nextJustInitialized=!1,this.initCallback=e=>{this._i18nextJustInitialized=!0,this.requestUpdate&&this.requestUpdate()},this.langChangedCallback=()=>{this.requestUpdate&&this.requestUpdate()}}connectedCallback(){e.language||e.on("initialized",this.initCallback),e.on("languageChanged",this.langChangedCallback),super.connectedCallback&&super.connectedCallback()}disconnectedCallback(){e.off("initialized",this.initCallback),e.off("languageChanged",this.langChangedCallback),super.disconnectedCallback&&super.disconnectedCallback()}shouldUpdate(e){return this._i18nextJustInitialized?(this._i18nextJustInitialized=!1,!0):super.shouldUpdate&&super.shouldUpdate(e)}};
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openremote/or-translate",
3
- "version": "1.8.0-snapshot.20250725070921",
3
+ "version": "1.8.0-snapshot.20250725120000",
4
4
  "description": "Provides a web component for translations using i18next",
5
5
  "customElements": "custom-elements.json",
6
6
  "main": "dist/umd/index.bundle.js",
@@ -22,7 +22,7 @@
22
22
  "lit": "^2.0.2"
23
23
  },
24
24
  "devDependencies": {
25
- "@openremote/util": "1.8.0-snapshot.20250725070921"
25
+ "@openremote/util": "1.8.0-snapshot.20250725120000"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"