@lingui/react 5.1.2 → 5.3.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const server = require('./server.cjs');
4
- const TransNoContext = require('./shared/react.3eab4fb8.cjs');
4
+ const TransNoContext = require('./shared/react.9788d7fd.cjs');
5
5
  const React = require('react');
6
6
 
7
7
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -1,5 +1,5 @@
1
- import { T as TransProps, b as I18nContext } from './shared/react.b2b749a9.cjs';
2
- export { d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.b2b749a9.cjs';
1
+ import { T as TransProps, b as I18nContext } from './shared/react.db1293d4.cjs';
2
+ export { d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.db1293d4.cjs';
3
3
  import React from 'react';
4
4
  import '@lingui/core';
5
5
 
@@ -1,5 +1,5 @@
1
- import { T as TransProps, b as I18nContext } from './shared/react.b2b749a9.mjs';
2
- export { d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.b2b749a9.mjs';
1
+ import { T as TransProps, b as I18nContext } from './shared/react.db1293d4.mjs';
2
+ export { d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.db1293d4.mjs';
3
3
  import React from 'react';
4
4
  import '@lingui/core';
5
5
 
@@ -1,5 +1,5 @@
1
- import { T as TransProps, b as I18nContext } from './shared/react.b2b749a9.js';
2
- export { d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.b2b749a9.js';
1
+ import { T as TransProps, b as I18nContext } from './shared/react.db1293d4.js';
2
+ export { d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.db1293d4.js';
3
3
  import React from 'react';
4
4
  import '@lingui/core';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { getI18n } from './server.mjs';
2
- import { T as TransNoContext } from './shared/react.1807f7b5.mjs';
2
+ import { T as TransNoContext } from './shared/react.31c3b5fa.mjs';
3
3
  import React from 'react';
4
4
 
5
5
  function TransRsc(props) {
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  const React = require('react');
5
- const TransNoContext = require('./shared/react.3eab4fb8.cjs');
5
+ const TransNoContext = require('./shared/react.9788d7fd.cjs');
6
6
 
7
7
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
8
8
 
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TransProps } from './shared/react.b2b749a9.cjs';
2
- export { b as I18nContext, I as I18nProvider, a as I18nProviderProps, L as LinguiContext, d as TransRenderCallbackOrComponent, c as TransRenderProps, u as useLingui } from './shared/react.b2b749a9.cjs';
1
+ import { T as TransProps } from './shared/react.db1293d4.cjs';
2
+ export { b as I18nContext, I as I18nProvider, a as I18nProviderProps, L as LinguiContext, d as TransRenderCallbackOrComponent, c as TransRenderProps, u as useLingui } from './shared/react.db1293d4.cjs';
3
3
  import React from 'react';
4
4
  import '@lingui/core';
5
5
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TransProps } from './shared/react.b2b749a9.mjs';
2
- export { b as I18nContext, I as I18nProvider, a as I18nProviderProps, L as LinguiContext, d as TransRenderCallbackOrComponent, c as TransRenderProps, u as useLingui } from './shared/react.b2b749a9.mjs';
1
+ import { T as TransProps } from './shared/react.db1293d4.mjs';
2
+ export { b as I18nContext, I as I18nProvider, a as I18nProviderProps, L as LinguiContext, d as TransRenderCallbackOrComponent, c as TransRenderProps, u as useLingui } from './shared/react.db1293d4.mjs';
3
3
  import React from 'react';
4
4
  import '@lingui/core';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TransProps } from './shared/react.b2b749a9.js';
2
- export { b as I18nContext, I as I18nProvider, a as I18nProviderProps, L as LinguiContext, d as TransRenderCallbackOrComponent, c as TransRenderProps, u as useLingui } from './shared/react.b2b749a9.js';
1
+ import { T as TransProps } from './shared/react.db1293d4.js';
2
+ export { b as I18nContext, I as I18nProvider, a as I18nProviderProps, L as LinguiContext, d as TransRenderCallbackOrComponent, c as TransRenderProps, u as useLingui } from './shared/react.db1293d4.js';
3
3
  import React from 'react';
4
4
  import '@lingui/core';
5
5
 
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
- import { T as TransNoContext } from './shared/react.1807f7b5.mjs';
3
+ import { T as TransNoContext } from './shared/react.31c3b5fa.mjs';
4
4
 
5
5
  const LinguiContext = React.createContext(null);
6
6
  const useLinguiInternal = (devErrorMessage) => {
package/dist/server.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const TransNoContext = require('./shared/react.3eab4fb8.cjs');
3
+ const TransNoContext = require('./shared/react.9788d7fd.cjs');
4
4
  const React = require('react');
5
5
 
6
6
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
package/dist/server.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as I18nContext } from './shared/react.b2b749a9.cjs';
2
- export { e as TransNoContext, T as TransProps, d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.b2b749a9.cjs';
1
+ import { b as I18nContext } from './shared/react.db1293d4.cjs';
2
+ export { e as TransNoContext, T as TransProps, d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.db1293d4.cjs';
3
3
  import { I18n } from '@lingui/core';
4
4
  import 'react';
5
5
 
package/dist/server.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as I18nContext } from './shared/react.b2b749a9.mjs';
2
- export { e as TransNoContext, T as TransProps, d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.b2b749a9.mjs';
1
+ import { b as I18nContext } from './shared/react.db1293d4.mjs';
2
+ export { e as TransNoContext, T as TransProps, d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.db1293d4.mjs';
3
3
  import { I18n } from '@lingui/core';
4
4
  import 'react';
5
5
 
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as I18nContext } from './shared/react.b2b749a9.js';
2
- export { e as TransNoContext, T as TransProps, d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.b2b749a9.js';
1
+ import { b as I18nContext } from './shared/react.db1293d4.js';
2
+ export { e as TransNoContext, T as TransProps, d as TransRenderCallbackOrComponent, c as TransRenderProps } from './shared/react.db1293d4.js';
3
3
  import { I18n } from '@lingui/core';
4
4
  import 'react';
5
5
 
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { T as TransNoContext } from './shared/react.1807f7b5.mjs';
1
+ export { T as TransNoContext } from './shared/react.31c3b5fa.mjs';
2
2
  import React from 'react';
3
3
 
4
4
  let cache = null;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- const tagRe = /<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/;
4
- const nlRe = /(?:\r\n|\r|\n)/g;
3
+ const tagRe = /<([a-zA-Z0-9]+)>([\s\S]*?)<\/\1>|<([a-zA-Z0-9]+)\/>/;
5
4
  const voidElementTags = {
6
5
  area: true,
7
6
  base: true,
@@ -22,7 +21,7 @@ const voidElementTags = {
22
21
  };
23
22
  function formatElements(value, elements = {}) {
24
23
  const uniqueId = makeCounter(0, "$lingui$");
25
- const parts = value.replace(nlRe, "").split(tagRe);
24
+ const parts = value.split(tagRe);
26
25
  if (parts.length === 1)
27
26
  return value;
28
27
  const tree = [];
@@ -6,8 +6,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
6
6
 
7
7
  const React__default = /*#__PURE__*/_interopDefaultCompat(React);
8
8
 
9
- const tagRe = /<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/;
10
- const nlRe = /(?:\r\n|\r|\n)/g;
9
+ const tagRe = /<([a-zA-Z0-9]+)>([\s\S]*?)<\/\1>|<([a-zA-Z0-9]+)\/>/;
11
10
  const voidElementTags = {
12
11
  area: true,
13
12
  base: true,
@@ -28,7 +27,7 @@ const voidElementTags = {
28
27
  };
29
28
  function formatElements(value, elements = {}) {
30
29
  const uniqueId = makeCounter(0, "$lingui$");
31
- const parts = value.replace(nlRe, "").split(tagRe);
30
+ const parts = value.split(tagRe);
32
31
  if (parts.length === 1)
33
32
  return value;
34
33
  const tree = [];
@@ -23,7 +23,6 @@ type TransProps = {
23
23
  };
24
24
  formats?: MessageOptions["formats"];
25
25
  comment?: string;
26
- children?: React.ReactNode;
27
26
  } & TransRenderCallbackOrComponent;
28
27
  /**
29
28
  * Version of `<Trans>` component without using a Provider/Context React feature.
@@ -23,7 +23,6 @@ type TransProps = {
23
23
  };
24
24
  formats?: MessageOptions["formats"];
25
25
  comment?: string;
26
- children?: React.ReactNode;
27
26
  } & TransRenderCallbackOrComponent;
28
27
  /**
29
28
  * Version of `<Trans>` component without using a Provider/Context React feature.
@@ -23,7 +23,6 @@ type TransProps = {
23
23
  };
24
24
  formats?: MessageOptions["formats"];
25
25
  comment?: string;
26
- children?: React.ReactNode;
27
26
  } & TransRenderCallbackOrComponent;
28
27
  /**
29
28
  * Version of `<Trans>` component without using a Provider/Context React feature.
package/macro/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { ReactNode, VFC, FC } from "react"
2
2
  import type { TransRenderCallbackOrComponent, I18nContext } from "@lingui/react"
3
- import type { MacroMessageDescriptor } from "@lingui/core/macro"
3
+ import type {
4
+ MacroMessageDescriptor,
5
+ LabeledExpression,
6
+ } from "@lingui/core/macro"
4
7
 
5
8
  type CommonProps = TransRenderCallbackOrComponent & {
6
9
  id?: string
@@ -8,12 +11,13 @@ type CommonProps = TransRenderCallbackOrComponent & {
8
11
  context?: string
9
12
  }
10
13
 
14
+ type TransChildren = ReactNode | LabeledExpression<string | number>
11
15
  type TransProps = {
12
- children: ReactNode
16
+ children: TransChildren | TransChildren[]
13
17
  } & CommonProps
14
18
 
15
19
  type PluralChoiceProps = {
16
- value: string | number
20
+ value: string | number | LabeledExpression<string | number>
17
21
  /** Offset of value when calculating plural forms */
18
22
  offset?: number
19
23
  zero?: ReactNode
@@ -29,7 +33,7 @@ type PluralChoiceProps = {
29
33
  } & CommonProps
30
34
 
31
35
  type SelectChoiceProps = {
32
- value: string
36
+ value: string | LabeledExpression<string | number>
33
37
  /** Catch-all option */
34
38
  other: ReactNode
35
39
  [option: `_${string}`]: ReactNode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/react",
3
- "version": "5.1.2",
3
+ "version": "5.3.0",
4
4
  "sideEffects": false,
5
5
  "description": "React components for translations",
6
6
  "main": "./dist/index.cjs",
@@ -77,7 +77,7 @@
77
77
  "macro/index.js"
78
78
  ],
79
79
  "peerDependencies": {
80
- "@lingui/babel-plugin-lingui-macro": "5.1.2",
80
+ "@lingui/babel-plugin-lingui-macro": "5.3.0",
81
81
  "babel-plugin-macros": "2 || 3",
82
82
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
83
83
  },
@@ -91,10 +91,10 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@babel/runtime": "^7.20.13",
94
- "@lingui/core": "^5.1.2"
94
+ "@lingui/core": "5.3.0"
95
95
  },
96
96
  "devDependencies": {
97
- "@lingui/jest-mocks": "^3.0.3",
97
+ "@lingui/jest-mocks": "*",
98
98
  "@testing-library/react": "^14.0.0",
99
99
  "@types/react": "^18.2.13",
100
100
  "eslint-plugin-react": "^7.32.2",
@@ -104,5 +104,5 @@
104
104
  "tsd": "^0.26.1",
105
105
  "unbuild": "2.0.0"
106
106
  },
107
- "gitHead": "e45a2af5dfc1c88131fa8196d596e0f0f25678ea"
107
+ "gitHead": "ed491cce7e5209378922327e0e7b802fb7b5873d"
108
108
  }