@webiny/i18n-react 6.0.0-alpha.5 β†’ 6.0.0-rc.0

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
@@ -1,19 +1,11 @@
1
1
  # @webiny/i18n-react
2
- [![](https://img.shields.io/npm/dw/@webiny/i18n-react.svg)](https://www.npmjs.com/package/@webiny/i18n-react)
3
- [![](https://img.shields.io/npm/v/@webiny/i18n-react.svg)](https://www.npmjs.com/package/@webiny/i18n-react)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
2
 
7
- A simple [webiny-i18n](./../webiny-i18n) processor, recommended for
8
- React apps.
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
9
6
 
10
- ## Install
11
- ```
12
- npm install --save @webiny/i18n-react
13
- ```
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
14
8
 
15
- Or if you prefer yarn:
16
- ```
17
- yarn add @webiny/i18n-react
18
- ```
9
+ ---
19
10
 
11
+ _This README file is automatically generated during the publish process._
package/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
- import type { Processor } from "@webiny/i18n/types";
3
- declare global {
2
+ import type { Processor } from "@webiny/i18n/types.js";
3
+ declare module "react" {
4
4
  namespace JSX {
5
5
  interface IntrinsicElements {
6
6
  "i18n-text": {
7
+ default?: string;
7
8
  children?: React.ReactNode;
8
9
  };
9
10
  "i18n-text-part": {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import lodashTrim from "lodash/trim";
2
+ import lodashTrim from "lodash/trim.js";
3
3
  const processTextPart = (part, values, modifiers) => {
4
4
  if (part.startsWith("{") === false) {
5
5
  return part;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["React","lodashTrim","processTextPart","part","values","modifiers","startsWith","parts","split","variable","modifier","value","parameters","name","shift","execute","processor","canExecute","data","key","isValidElement","translation","createElement","map","index","String","i18n"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport lodashTrim from \"lodash/trim\";\nimport type { I18NDataValues, Modifier, Processor } from \"@webiny/i18n/types\";\n\ndeclare global {\n // eslint-disable-next-line\n namespace JSX {\n interface IntrinsicElements {\n \"i18n-text\": {\n children?: React.ReactNode;\n };\n\n \"i18n-text-part\": {\n key?: string;\n children?: React.ReactNode;\n };\n }\n }\n}\n\nconst processTextPart = (\n part: string,\n values: I18NDataValues,\n modifiers: Record<string, Modifier>\n): string => {\n if (part.startsWith(\"{\") === false) {\n return part;\n }\n\n part = lodashTrim(part, \"{}\");\n\n const parts: string[] = part.split(\"|\");\n\n const [variable, modifier] = parts;\n\n if (!values[variable]) {\n return variable;\n }\n\n let value = values[variable];\n if (modifier) {\n const parameters = modifier.split(\":\");\n const name = parameters.shift();\n if (!name) {\n return value;\n }\n if (modifiers[name]) {\n const modifier = modifiers[name];\n value = modifier.execute(value, parameters);\n }\n }\n\n return value;\n};\n\nconst processor: Processor = {\n name: \"react\",\n canExecute(data) {\n for (const key in data.values) {\n const value = data.values[key];\n if (React.isValidElement(value)) {\n return true;\n }\n }\n\n return false;\n },\n execute(data) {\n const parts = data.translation.split(/({.*?})/);\n return (\n <i18n-text>\n {parts.map((part, index) => (\n <i18n-text-part key={String(index)}>\n {processTextPart(part, data.values, data.i18n.modifiers)}\n </i18n-text-part>\n ))}\n </i18n-text>\n );\n }\n};\nexport default processor;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,aAAa;AAmBpC,MAAMC,eAAe,GAAGA,CACpBC,IAAY,EACZC,MAAsB,EACtBC,SAAmC,KAC1B;EACT,IAAI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C,oBACIR,KAAA,CAAAsB,aAAA,oBACKf,KAAK,CAACgB,GAAG,CAAC,CAACpB,IAAI,EAAEqB,KAAK,kBACnBxB,KAAA,CAAAsB,aAAA;MAAgBH,GAAG,EAAEM,MAAM,CAACD,KAAK;IAAE,GAC9BtB,eAAe,CAACC,IAAI,EAAEe,IAAI,CAACd,MAAM,EAAEc,IAAI,CAACQ,IAAI,CAACrB,SAAS,CAC3C,CACnB,CACM,CAAC;EAEpB;AACJ,CAAC;AACD,eAAeW,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["React","lodashTrim","processTextPart","part","values","modifiers","startsWith","parts","split","variable","modifier","value","parameters","name","shift","execute","processor","canExecute","data","key","isValidElement","translation","createElement","map","index","String","i18n"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport lodashTrim from \"lodash/trim.js\";\nimport type { I18NDataValues, Modifier, Processor } from \"@webiny/i18n/types.js\";\n\ndeclare module \"react\" {\n namespace JSX {\n interface IntrinsicElements {\n \"i18n-text\": {\n default?: string;\n children?: React.ReactNode;\n };\n \"i18n-text-part\": {\n key?: string;\n children?: React.ReactNode;\n };\n }\n }\n}\n\nconst processTextPart = (\n part: string,\n values: I18NDataValues,\n modifiers: Record<string, Modifier>\n): string => {\n if (part.startsWith(\"{\") === false) {\n return part;\n }\n\n part = lodashTrim(part, \"{}\");\n\n const parts: string[] = part.split(\"|\");\n\n const [variable, modifier] = parts;\n\n if (!values[variable]) {\n return variable;\n }\n\n let value = values[variable];\n if (modifier) {\n const parameters = modifier.split(\":\");\n const name = parameters.shift();\n if (!name) {\n return value;\n }\n if (modifiers[name]) {\n const modifier = modifiers[name];\n value = modifier.execute(value, parameters);\n }\n }\n\n return value;\n};\n\nconst processor: Processor = {\n name: \"react\",\n canExecute(data) {\n for (const key in data.values) {\n const value = data.values[key];\n if (React.isValidElement(value)) {\n return true;\n }\n }\n\n return false;\n },\n execute(data) {\n const parts = data.translation.split(/({.*?})/);\n return (\n <i18n-text>\n {parts.map((part, index) => (\n <i18n-text-part key={String(index)}>\n {processTextPart(part, data.values, data.i18n.modifiers)}\n </i18n-text-part>\n ))}\n </i18n-text>\n );\n }\n};\nexport default processor;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,gBAAgB;AAkBvC,MAAMC,eAAe,GAAGA,CACpBC,IAAY,EACZC,MAAsB,EACtBC,SAAmC,KAC1B;EACT,IAAIF,IAAI,CAACG,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE;IAChC,OAAOH,IAAI;EACf;EAEAA,IAAI,GAAGF,UAAU,CAACE,IAAI,EAAE,IAAI,CAAC;EAE7B,MAAMI,KAAe,GAAGJ,IAAI,CAACK,KAAK,CAAC,GAAG,CAAC;EAEvC,MAAM,CAACC,QAAQ,EAAEC,QAAQ,CAAC,GAAGH,KAAK;EAElC,IAAI,CAACH,MAAM,CAACK,QAAQ,CAAC,EAAE;IACnB,OAAOA,QAAQ;EACnB;EAEA,IAAIE,KAAK,GAAGP,MAAM,CAACK,QAAQ,CAAC;EAC5B,IAAIC,QAAQ,EAAE;IACV,MAAME,UAAU,GAAGF,QAAQ,CAACF,KAAK,CAAC,GAAG,CAAC;IACtC,MAAMK,IAAI,GAAGD,UAAU,CAACE,KAAK,CAAC,CAAC;IAC/B,IAAI,CAACD,IAAI,EAAE;MACP,OAAOF,KAAK;IAChB;IACA,IAAIN,SAAS,CAACQ,IAAI,CAAC,EAAE;MACjB,MAAMH,QAAQ,GAAGL,SAAS,CAACQ,IAAI,CAAC;MAChCF,KAAK,GAAGD,QAAQ,CAACK,OAAO,CAACJ,KAAK,EAAEC,UAAU,CAAC;IAC/C;EACJ;EAEA,OAAOD,KAAK;AAChB,CAAC;AAED,MAAMK,SAAoB,GAAG;EACzBH,IAAI,EAAE,OAAO;EACbI,UAAUA,CAACC,IAAI,EAAE;IACb,KAAK,MAAMC,GAAG,IAAID,IAAI,CAACd,MAAM,EAAE;MAC3B,MAAMO,KAAK,GAAGO,IAAI,CAACd,MAAM,CAACe,GAAG,CAAC;MAC9B,iBAAInB,KAAK,CAACoB,cAAc,CAACT,KAAK,CAAC,EAAE;QAC7B,OAAO,IAAI;MACf;IACJ;IAEA,OAAO,KAAK;EAChB,CAAC;EACDI,OAAOA,CAACG,IAAI,EAAE;IACV,MAAMX,KAAK,GAAGW,IAAI,CAACG,WAAW,CAACb,KAAK,CAAC,SAAS,CAAC;IAC/C,oBACIR,KAAA,CAAAsB,aAAA,oBACKf,KAAK,CAACgB,GAAG,CAAC,CAACpB,IAAI,EAAEqB,KAAK,kBACnBxB,KAAA,CAAAsB,aAAA;MAAgBH,GAAG,EAAEM,MAAM,CAACD,KAAK;IAAE,GAC9BtB,eAAe,CAACC,IAAI,EAAEe,IAAI,CAACd,MAAM,EAAEc,IAAI,CAACQ,IAAI,CAACrB,SAAS,CAC3C,CACnB,CACM,CAAC;EAEpB;AACJ,CAAC;AACD,eAAeW,SAAS","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/i18n-react",
3
- "version": "6.0.0-alpha.5",
3
+ "version": "6.0.0-rc.0",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -14,13 +15,13 @@
14
15
  ],
15
16
  "license": "MIT",
16
17
  "dependencies": {
17
- "@webiny/i18n": "6.0.0-alpha.5",
18
- "lodash": "4.17.21"
18
+ "@webiny/i18n": "6.0.0-rc.0",
19
+ "lodash": "4.17.23"
19
20
  },
20
21
  "devDependencies": {
21
- "@webiny/project-utils": "6.0.0-alpha.5",
22
- "rimraf": "6.0.1",
23
- "typescript": "5.3.3"
22
+ "@webiny/build-tools": "6.0.0-rc.0",
23
+ "rimraf": "6.1.3",
24
+ "typescript": "5.9.3"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "react": "18.2.0"
@@ -29,9 +30,5 @@
29
30
  "access": "public",
30
31
  "directory": "dist"
31
32
  },
32
- "scripts": {
33
- "build": "node ../cli/bin.js run build",
34
- "watch": "node ../cli/bin.js run watch"
35
- },
36
- "gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
33
+ "gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
37
34
  }