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

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/README.md CHANGED
@@ -39,7 +39,7 @@ If using the default namespace then the namespace prefix can be omitted:
39
39
  <or-translate value="asset" />
40
40
  ```
41
41
 
42
- It is also possible to pass an `i18next.TOptions<i18next.InitOptions>` object to the `18next.t` method by setting the
42
+ It is also possible to pass an `TOptions<InitOptions>` object to the `18next.t` method by setting the
43
43
  `options` attribute.
44
44
 
45
45
 
@@ -59,7 +59,7 @@ Internet Explorer 11 is also supported.
59
59
  [GNU AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
60
60
 
61
61
  [npm-image]: https://img.shields.io/npm/v/live-xxx.svg
62
- [npm-url]: https://npmjs.org/package/@openremote/or-input
62
+ [npm-url]: https://npmjs.org/package/@openremote/or-translate
63
63
  [travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
64
64
  [travis-url]: https://travis-ci.org/live-js/live-xxx
65
65
  [coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
@@ -1,6 +1,6 @@
1
1
  import { translate } from "./translate-mixin";
2
- import i18next from "i18next";
3
- import { LitElement } from "lit-element";
2
+ import i18next, { InitOptions, TOptions } from "i18next";
3
+ import { LitElement } from "lit";
4
4
  export { i18next };
5
5
  export { translate };
6
6
  declare const OrTranslate_base: {
@@ -8,16 +8,16 @@ declare const OrTranslate_base: {
8
8
  _i18nextJustInitialized: boolean;
9
9
  connectedCallback(): void;
10
10
  disconnectedCallback(): void;
11
- shouldUpdate(changedProps: Map<string | number | symbol, unknown>): any;
12
- initCallback: (options: i18next.InitOptions) => void;
11
+ shouldUpdate(changedProps: import("lit").PropertyValueMap<any> | Map<PropertyKey, unknown>): any;
12
+ initCallback: (options: InitOptions) => void;
13
13
  langChangedCallback: () => void;
14
14
  readonly isConnected: boolean;
15
15
  };
16
16
  } & typeof LitElement;
17
17
  export declare class OrTranslate extends OrTranslate_base {
18
- static styles: import("lit-element").CSSResult;
18
+ static styles: import("lit").CSSResult;
19
19
  value?: string;
20
- options?: i18next.TOptions<i18next.InitOptions>;
21
- protected render(): import("lit-element").TemplateResult;
20
+ options?: TOptions<InitOptions>;
21
+ protected render(): import("lit-html").TemplateResult<1>;
22
22
  protected _getTranslatedValue(): string;
23
23
  }
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
1
+ var __decorate=this&&this.__decorate||function(t,e,r,a){var o,n=arguments.length,l=n<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,r,a);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(l=(n<3?o(l):n>3?o(e,r,l):o(e,r))||l);return n>3&&l&&Object.defineProperty(e,r,l),l};import{translate}from"./translate-mixin";import i18next from"i18next";import{LitElement,html,css}from"lit";import{customElement,property}from"lit/decorators.js";export{i18next};export{translate};let OrTranslate=class extends(translate(i18next)(LitElement)){render(){return html`
2
+ ${this._getTranslatedValue()}
3
+ `}_getTranslatedValue(){return this.value?i18next.isInitialized?i18next.t(this.value,this.options):this.value:""}};OrTranslate.styles=css`
4
+ :host {
5
+ display: inline-block;
6
+ }
7
+
8
+ :host([hidden]) {
9
+ display: none;
10
+ }
11
+ `,__decorate([property({type:String})],OrTranslate.prototype,"value",void 0),__decorate([property({type:Object})],OrTranslate.prototype,"options",void 0),OrTranslate=__decorate([customElement("or-translate")],OrTranslate);export{OrTranslate};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,OAAiC,MAAM,SAAS,CAAC;AACxD,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,GAAG,EAAC,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAC,OAAO,EAAC,CAAC;AAEjB,OAAO,EAAC,SAAS,EAAC,CAAC;AAGZ,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,SAAS,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAkBjD,MAAM;QACZ,OAAO,IAAI,CAAA;cACL,IAAI,CAAC,mBAAmB,EAAE;SAC/B,CAAC;IACN,CAAC;IAES,mBAAmB;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACtG,CAAC;;AAxBa,kBAAM,GAAG,GAAG,CAAA;;;;;;;;KAQzB,AARmB,CAQlB;AAGK;IADN,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;0CACH;AAGf;IADN,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACc;AAhB9B,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA2BvB"}
@@ -1,17 +1,18 @@
1
- import i18n from "i18next";
1
+ import { PropertyValues } from "lit";
2
+ import { InitOptions, i18n } from "i18next";
2
3
  declare type Constructor<T> = new (...args: any[]) => T;
3
4
  interface CustomElement {
4
5
  connectedCallback?(): void;
5
6
  disconnectedCallback?(): void;
6
7
  readonly isConnected: boolean;
7
8
  }
8
- export declare const translate: (i18next: i18n.i18n) => <T extends Constructor<CustomElement>>(base: T) => {
9
+ export declare const translate: (i18next: i18n) => <T extends Constructor<CustomElement>>(base: T) => {
9
10
  new (...args: any[]): {
10
11
  _i18nextJustInitialized: boolean;
11
12
  connectedCallback(): void;
12
13
  disconnectedCallback(): void;
13
- shouldUpdate(changedProps: Map<string | number | symbol, unknown>): any;
14
- initCallback: (options: i18n.InitOptions) => void;
14
+ shouldUpdate(changedProps: PropertyValues): any;
15
+ initCallback: (options: InitOptions) => void;
15
16
  langChangedCallback: () => void;
16
17
  readonly isConnected: boolean;
17
18
  };
@@ -0,0 +1 @@
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)}};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate-mixin.js","sourceRoot":"","sources":["../src/translate-mixin.ts"],"names":[],"mappings":"AAWA,0IAA0I;AAC1I,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAa,EAAE,EAAE,CAAC,CAAuC,IAAO,EAAE,EAAE,CACtF,KAAM,SAAQ,IAAI;IAAlB;;QAEI,4BAAuB,GAAG,KAAK,CAAC;QAiCzB,iBAAY,GAAG,CAAC,OAAoB,EAAE,EAAE;YAC3C,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC;YACpC,aAAa;YACb,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACrB,aAAa;gBACb,IAAI,CAAC,aAAa,EAAE,CAAC;YACzB,CAAC;QACL,CAAC,CAAC;QAEK,wBAAmB,GAAG,GAAG,EAAE;YAC9B,aAAa;YACb,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACrB,aAAa;gBACb,IAAI,CAAC,aAAa,EAAE,CAAC;YACzB,CAAC;QACL,CAAC,CAAA;IACL,CAAC;IA/CG,iBAAiB;QACb,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAExD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC9B,CAAC;IACL,CAAC;IAED,oBAAoB;QAChB,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAEzD,IAAI,KAAK,CAAC,oBAAoB,EAAE,CAAC;YAC7B,KAAK,CAAC,oBAAoB,EAAE,CAAC;QACjC,CAAC;IACL,CAAC;IAED,YAAY,CAAC,YAA4B;QACrC,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC/B,IAAI,CAAC,uBAAuB,GAAG,KAAK,CAAC;YACrC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,aAAa;QACb,OAAO,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;CAkBJ,CAAC"}
package/package.json CHANGED
@@ -1,27 +1,28 @@
1
1
  {
2
2
  "name": "@openremote/or-translate",
3
- "version": "1.0.3",
3
+ "version": "1.2.0-snapshot.20240512154942",
4
4
  "description": "Provides a web component for translations using i18next",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "dist/umd/index.bundle.js",
6
+ "module": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./*": "./lib/*.js"
10
+ },
11
+ "types": "lib/index.d.ts",
7
12
  "scripts": {
8
13
  "test": "echo \"No tests\" && exit 0",
9
- "prepublishOnly": "npx tsc -b && npx webpack"
14
+ "prepublishOnly": "npx webpack"
10
15
  },
11
16
  "author": "OpenRemote",
12
17
  "license": "AGPL-3.0-or-later",
13
18
  "dependencies": {
14
- "i18next": "^15.0.9",
15
- "lit-element": "^2.4.0"
19
+ "i18next": "^21.5.3",
20
+ "lit": "^2.0.2"
16
21
  },
17
22
  "devDependencies": {
18
- "tslint": ">=5.11.0",
19
- "typescript": ">=3.4.5",
20
- "webpack": "^4.41.2",
21
- "webpack-cli": "^3.3.9"
23
+ "@openremote/util": "1.2.0-snapshot.20240512154942"
22
24
  },
23
25
  "publishConfig": {
24
26
  "access": "public"
25
- },
26
- "gitHead": "7179d443d33b88b063a76afe195b0e26ba1aadf1"
27
- }
27
+ }
28
+ }
package/.project DELETED
@@ -1,17 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <projectDescription>
3
- <name>or-translate</name>
4
- <comment>Project or-translate created by Buildship.</comment>
5
- <projects>
6
- </projects>
7
- <buildSpec>
8
- <buildCommand>
9
- <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
- <arguments>
11
- </arguments>
12
- </buildCommand>
13
- </buildSpec>
14
- <natures>
15
- <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
- </natures>
17
- </projectDescription>
@@ -1,2 +0,0 @@
1
- connection.project.dir=../../../../manager
2
- eclipse.preferences.version=1