@lingui/react 4.8.0-next.1 → 4.10.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/dist/server.d.ts CHANGED
@@ -1,45 +1,44 @@
1
- import React, { ComponentType } from 'react';
2
- import { MessageOptions, I18n } from '@lingui/core';
1
+ export { c as TransNoContext, T as TransProps, b as TransRenderCallbackOrComponent, a as TransRenderProps } from './shared/react.a673be03.js';
2
+ import { I18n } from '@lingui/core';
3
+ import 'react';
3
4
 
4
- type TransRenderProps = {
5
- id: string;
6
- translation: React.ReactNode;
7
- children: React.ReactNode;
8
- message?: string | null;
9
- /**
10
- * @deprecated isTranslated prop is undocumented and buggy. It'll be removed in v5 release.
11
- * */
12
- isTranslated: boolean;
13
- };
14
- type TransRenderCallbackOrComponent = {
15
- component?: undefined;
16
- render?: ((props: TransRenderProps) => React.ReactElement<any, any>) | null;
17
- } | {
18
- component?: React.ComponentType<TransRenderProps> | null;
19
- render?: undefined;
20
- };
21
- type TransProps = {
22
- id: string;
23
- message?: string;
24
- values?: Record<string, unknown>;
25
- components?: {
26
- [key: string]: React.ElementType | any;
27
- };
28
- formats?: MessageOptions["formats"];
29
- comment?: string;
30
- children?: React.ReactNode;
31
- } & TransRenderCallbackOrComponent;
32
5
  /**
33
- * Version of `<Trans>` component without using a Provider/Context React feature.
34
- * Primarily made for support React Server Components (RSC)
6
+ * This is an entry point for React Server Components (RSC)
35
7
  *
36
- * @experimental the api of this component is not stabilized yet.
8
+ * The RSC uses a static analysis to find any non-valid function calls in the import graph.
9
+ * That means this entry point and it's children should not have any Provider/Context calls.
37
10
  */
38
- declare function TransNoContext(props: TransProps & {
39
- lingui: {
40
- i18n: I18n;
41
- defaultComponent?: ComponentType<TransRenderProps>;
42
- };
43
- }): React.ReactElement<any, any> | null;
44
11
 
45
- export { TransNoContext, type TransProps, type TransRenderCallbackOrComponent, type TransRenderProps };
12
+ /**
13
+ * Set Lingui's i18n instance for later use in RSC Components
14
+ *
15
+ * Example:
16
+ *
17
+ * ```js
18
+ * import { setupI18n } from "@lingui/core";
19
+ *
20
+ * const i18n = setupI18n({
21
+ * locale,
22
+ * messages: { [locale]: messages },
23
+ * })
24
+ *
25
+ * setI18n(i18n);
26
+ * ```
27
+ */
28
+ declare function setI18n(i18n: I18n): void;
29
+ /**
30
+ * Get Lingui's i18n instance saved for RSC
31
+ *
32
+ * ```js
33
+ * export function generateMetadata() {
34
+ * const i18n = getI18n()
35
+ *
36
+ * return {
37
+ * title: t(i18n)`Translation Demo`,
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ declare function getI18n(): I18n | null;
43
+
44
+ export { getI18n, setI18n };
package/dist/server.mjs CHANGED
@@ -1,133 +1,20 @@
1
+ export { T as TransNoContext } from './shared/react.1d406965.mjs';
1
2
  import React from 'react';
2
3
 
3
- const tagRe = /<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/;
4
- const nlRe = /(?:\r\n|\r|\n)/g;
5
- const voidElementTags = {
6
- area: true,
7
- base: true,
8
- br: true,
9
- col: true,
10
- embed: true,
11
- hr: true,
12
- img: true,
13
- input: true,
14
- keygen: true,
15
- link: true,
16
- meta: true,
17
- param: true,
18
- source: true,
19
- track: true,
20
- wbr: true,
21
- menuitem: true
22
- };
23
- function formatElements(value, elements = {}) {
24
- const uniqueId = makeCounter(0, "$lingui$");
25
- const parts = value.replace(nlRe, "").split(tagRe);
26
- if (parts.length === 1)
27
- return value;
28
- const tree = [];
29
- const before = parts.shift();
30
- if (before)
31
- tree.push(before);
32
- for (const [index, children, after] of getElements(parts)) {
33
- let element = typeof index !== "undefined" ? elements[index] : void 0;
34
- if (!element || voidElementTags[element.type] && children) {
35
- if (!element) {
36
- console.error(
37
- `Can't use element at index '${index}' as it is not declared in the original translation`
38
- );
39
- } else {
40
- console.error(
41
- `${element.type} is a void element tag therefore it must have no children`
42
- );
43
- }
44
- element = React.createElement(React.Fragment);
45
- }
46
- if (Array.isArray(element)) {
47
- element = React.createElement(React.Fragment, {}, element);
48
- }
49
- tree.push(
50
- React.cloneElement(
51
- element,
52
- { key: uniqueId() },
53
- // format children for pair tags
54
- // unpaired tags might have children if it's a component passed as a variable
55
- children ? formatElements(children, elements) : element.props.children
56
- )
57
- );
58
- if (after)
59
- tree.push(after);
4
+ let cache = null;
5
+ const getLinguiCache = () => {
6
+ if (!cache) {
7
+ cache = React.cache(() => ({
8
+ current: null
9
+ }));
60
10
  }
61
- return tree;
11
+ return cache();
12
+ };
13
+ function setI18n(i18n) {
14
+ getLinguiCache().current = i18n;
62
15
  }
63
- function getElements(parts) {
64
- if (!parts.length)
65
- return [];
66
- const [paired, children, unpaired, after] = parts.slice(0, 4);
67
- const triple = [paired || unpaired, children || "", after];
68
- return [triple].concat(getElements(parts.slice(4, parts.length)));
16
+ function getI18n() {
17
+ return getLinguiCache().current;
69
18
  }
70
- const makeCounter = (count = 0, prefix = "") => () => `${prefix}_${count++}`;
71
-
72
- function TransNoContext(props) {
73
- const {
74
- render,
75
- component,
76
- id,
77
- message,
78
- formats,
79
- lingui: { i18n, defaultComponent }
80
- } = props;
81
- const values = { ...props.values };
82
- const components = { ...props.components };
83
- if (values) {
84
- Object.keys(values).forEach((key) => {
85
- const value = values[key];
86
- const valueIsReactEl = React.isValidElement(value) || Array.isArray(value) && value.every(React.isValidElement);
87
- if (!valueIsReactEl)
88
- return;
89
- const index = Object.keys(components).length;
90
- components[index] = value;
91
- values[key] = `<${index}/>`;
92
- });
93
- }
94
- const _translation = i18n && typeof i18n._ === "function" ? i18n._(id, values, { message, formats }) : id;
95
- const translation = _translation ? formatElements(_translation, components) : null;
96
- if (render === null || component === null) {
97
- return translation;
98
- }
99
- const FallbackComponent = defaultComponent || RenderFragment;
100
- const i18nProps = {
101
- id,
102
- message,
103
- translation,
104
- // TODO vonovak - remove isTranslated prop in v5 release
105
- isTranslated: id !== translation && message !== translation,
106
- children: translation
107
- // for type-compatibility with `component` prop
108
- };
109
- if (render && component) {
110
- console.error(
111
- "You can't use both `component` and `render` prop at the same time. `component` is ignored."
112
- );
113
- } else if (render && typeof render !== "function") {
114
- console.error(
115
- `Invalid value supplied to prop \`render\`. It must be a function, provided ${render}`
116
- );
117
- } else if (component && typeof component !== "function") {
118
- console.error(
119
- `Invalid value supplied to prop \`component\`. It must be a React component, provided ${component}`
120
- );
121
- return React.createElement(FallbackComponent, i18nProps, translation);
122
- }
123
- if (typeof render === "function") {
124
- return render(i18nProps);
125
- }
126
- const Component = component || FallbackComponent;
127
- return React.createElement(Component, i18nProps, translation);
128
- }
129
- const RenderFragment = ({ children }) => {
130
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
131
- };
132
19
 
133
- export { TransNoContext };
20
+ export { getI18n, setI18n };
@@ -0,0 +1,17 @@
1
+ import React, { ComponentType, FunctionComponent } from 'react';
2
+ import { I18n } from '@lingui/core';
3
+ import { a as TransRenderProps } from './react.a673be03.mjs';
4
+
5
+ type I18nContext = {
6
+ i18n: I18n;
7
+ _: I18n["_"];
8
+ defaultComponent?: ComponentType<TransRenderProps>;
9
+ };
10
+ type I18nProviderProps = Omit<I18nContext, "_"> & {
11
+ children?: React.ReactNode;
12
+ };
13
+ declare const LinguiContext: React.Context<I18nContext | null>;
14
+ declare function useLingui(): I18nContext;
15
+ declare const I18nProvider: FunctionComponent<I18nProviderProps>;
16
+
17
+ export { I18nProvider as I, LinguiContext as L, type I18nProviderProps as a, type I18nContext as b, useLingui as u };
@@ -0,0 +1,133 @@
1
+ import React from 'react';
2
+
3
+ const tagRe = /<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/;
4
+ const nlRe = /(?:\r\n|\r|\n)/g;
5
+ const voidElementTags = {
6
+ area: true,
7
+ base: true,
8
+ br: true,
9
+ col: true,
10
+ embed: true,
11
+ hr: true,
12
+ img: true,
13
+ input: true,
14
+ keygen: true,
15
+ link: true,
16
+ meta: true,
17
+ param: true,
18
+ source: true,
19
+ track: true,
20
+ wbr: true,
21
+ menuitem: true
22
+ };
23
+ function formatElements(value, elements = {}) {
24
+ const uniqueId = makeCounter(0, "$lingui$");
25
+ const parts = value.replace(nlRe, "").split(tagRe);
26
+ if (parts.length === 1)
27
+ return value;
28
+ const tree = [];
29
+ const before = parts.shift();
30
+ if (before)
31
+ tree.push(before);
32
+ for (const [index, children, after] of getElements(parts)) {
33
+ let element = typeof index !== "undefined" ? elements[index] : void 0;
34
+ if (!element || voidElementTags[element.type] && children) {
35
+ if (!element) {
36
+ console.error(
37
+ `Can't use element at index '${index}' as it is not declared in the original translation`
38
+ );
39
+ } else {
40
+ console.error(
41
+ `${element.type} is a void element tag therefore it must have no children`
42
+ );
43
+ }
44
+ element = React.createElement(React.Fragment);
45
+ }
46
+ if (Array.isArray(element)) {
47
+ element = React.createElement(React.Fragment, {}, element);
48
+ }
49
+ tree.push(
50
+ React.cloneElement(
51
+ element,
52
+ { key: uniqueId() },
53
+ // format children for pair tags
54
+ // unpaired tags might have children if it's a component passed as a variable
55
+ children ? formatElements(children, elements) : element.props.children
56
+ )
57
+ );
58
+ if (after)
59
+ tree.push(after);
60
+ }
61
+ return tree;
62
+ }
63
+ function getElements(parts) {
64
+ if (!parts.length)
65
+ return [];
66
+ const [paired, children, unpaired, after] = parts.slice(0, 4);
67
+ const triple = [paired || unpaired, children || "", after];
68
+ return [triple].concat(getElements(parts.slice(4, parts.length)));
69
+ }
70
+ const makeCounter = (count = 0, prefix = "") => () => `${prefix}_${count++}`;
71
+
72
+ function TransNoContext(props) {
73
+ const {
74
+ render,
75
+ component,
76
+ id,
77
+ message,
78
+ formats,
79
+ lingui: { i18n, defaultComponent }
80
+ } = props;
81
+ const values = { ...props.values };
82
+ const components = { ...props.components };
83
+ if (values) {
84
+ Object.keys(values).forEach((key) => {
85
+ const value = values[key];
86
+ const valueIsReactEl = React.isValidElement(value) || Array.isArray(value) && value.every(React.isValidElement);
87
+ if (!valueIsReactEl)
88
+ return;
89
+ const index = Object.keys(components).length;
90
+ components[index] = value;
91
+ values[key] = `<${index}/>`;
92
+ });
93
+ }
94
+ const _translation = i18n && typeof i18n._ === "function" ? i18n._(id, values, { message, formats }) : id;
95
+ const translation = _translation ? formatElements(_translation, components) : null;
96
+ if (render === null || component === null) {
97
+ return translation;
98
+ }
99
+ const FallbackComponent = defaultComponent || RenderFragment;
100
+ const i18nProps = {
101
+ id,
102
+ message,
103
+ translation,
104
+ // TODO vonovak - remove isTranslated prop in v5 release
105
+ isTranslated: id !== translation && message !== translation,
106
+ children: translation
107
+ // for type-compatibility with `component` prop
108
+ };
109
+ if (render && component) {
110
+ console.error(
111
+ "You can't use both `component` and `render` prop at the same time. `component` is ignored."
112
+ );
113
+ } else if (render && typeof render !== "function") {
114
+ console.error(
115
+ `Invalid value supplied to prop \`render\`. It must be a function, provided ${render}`
116
+ );
117
+ } else if (component && typeof component !== "function") {
118
+ console.error(
119
+ `Invalid value supplied to prop \`component\`. It must be a React component, provided ${component}`
120
+ );
121
+ return React.createElement(FallbackComponent, i18nProps, translation);
122
+ }
123
+ if (typeof render === "function") {
124
+ return render(i18nProps);
125
+ }
126
+ const Component = component || FallbackComponent;
127
+ return React.createElement(Component, i18nProps, translation);
128
+ }
129
+ const RenderFragment = ({ children }) => {
130
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
131
+ };
132
+
133
+ export { TransNoContext as T };
@@ -0,0 +1,139 @@
1
+ 'use strict';
2
+
3
+ const React = require('react');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
6
+
7
+ const React__default = /*#__PURE__*/_interopDefaultCompat(React);
8
+
9
+ const tagRe = /<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/;
10
+ const nlRe = /(?:\r\n|\r|\n)/g;
11
+ const voidElementTags = {
12
+ area: true,
13
+ base: true,
14
+ br: true,
15
+ col: true,
16
+ embed: true,
17
+ hr: true,
18
+ img: true,
19
+ input: true,
20
+ keygen: true,
21
+ link: true,
22
+ meta: true,
23
+ param: true,
24
+ source: true,
25
+ track: true,
26
+ wbr: true,
27
+ menuitem: true
28
+ };
29
+ function formatElements(value, elements = {}) {
30
+ const uniqueId = makeCounter(0, "$lingui$");
31
+ const parts = value.replace(nlRe, "").split(tagRe);
32
+ if (parts.length === 1)
33
+ return value;
34
+ const tree = [];
35
+ const before = parts.shift();
36
+ if (before)
37
+ tree.push(before);
38
+ for (const [index, children, after] of getElements(parts)) {
39
+ let element = typeof index !== "undefined" ? elements[index] : void 0;
40
+ if (!element || voidElementTags[element.type] && children) {
41
+ if (!element) {
42
+ console.error(
43
+ `Can't use element at index '${index}' as it is not declared in the original translation`
44
+ );
45
+ } else {
46
+ console.error(
47
+ `${element.type} is a void element tag therefore it must have no children`
48
+ );
49
+ }
50
+ element = React__default.createElement(React__default.Fragment);
51
+ }
52
+ if (Array.isArray(element)) {
53
+ element = React__default.createElement(React__default.Fragment, {}, element);
54
+ }
55
+ tree.push(
56
+ React__default.cloneElement(
57
+ element,
58
+ { key: uniqueId() },
59
+ // format children for pair tags
60
+ // unpaired tags might have children if it's a component passed as a variable
61
+ children ? formatElements(children, elements) : element.props.children
62
+ )
63
+ );
64
+ if (after)
65
+ tree.push(after);
66
+ }
67
+ return tree;
68
+ }
69
+ function getElements(parts) {
70
+ if (!parts.length)
71
+ return [];
72
+ const [paired, children, unpaired, after] = parts.slice(0, 4);
73
+ const triple = [paired || unpaired, children || "", after];
74
+ return [triple].concat(getElements(parts.slice(4, parts.length)));
75
+ }
76
+ const makeCounter = (count = 0, prefix = "") => () => `${prefix}_${count++}`;
77
+
78
+ function TransNoContext(props) {
79
+ const {
80
+ render,
81
+ component,
82
+ id,
83
+ message,
84
+ formats,
85
+ lingui: { i18n, defaultComponent }
86
+ } = props;
87
+ const values = { ...props.values };
88
+ const components = { ...props.components };
89
+ if (values) {
90
+ Object.keys(values).forEach((key) => {
91
+ const value = values[key];
92
+ const valueIsReactEl = React__default.isValidElement(value) || Array.isArray(value) && value.every(React__default.isValidElement);
93
+ if (!valueIsReactEl)
94
+ return;
95
+ const index = Object.keys(components).length;
96
+ components[index] = value;
97
+ values[key] = `<${index}/>`;
98
+ });
99
+ }
100
+ const _translation = i18n && typeof i18n._ === "function" ? i18n._(id, values, { message, formats }) : id;
101
+ const translation = _translation ? formatElements(_translation, components) : null;
102
+ if (render === null || component === null) {
103
+ return translation;
104
+ }
105
+ const FallbackComponent = defaultComponent || RenderFragment;
106
+ const i18nProps = {
107
+ id,
108
+ message,
109
+ translation,
110
+ // TODO vonovak - remove isTranslated prop in v5 release
111
+ isTranslated: id !== translation && message !== translation,
112
+ children: translation
113
+ // for type-compatibility with `component` prop
114
+ };
115
+ if (render && component) {
116
+ console.error(
117
+ "You can't use both `component` and `render` prop at the same time. `component` is ignored."
118
+ );
119
+ } else if (render && typeof render !== "function") {
120
+ console.error(
121
+ `Invalid value supplied to prop \`render\`. It must be a function, provided ${render}`
122
+ );
123
+ } else if (component && typeof component !== "function") {
124
+ console.error(
125
+ `Invalid value supplied to prop \`component\`. It must be a React component, provided ${component}`
126
+ );
127
+ return React__default.createElement(FallbackComponent, i18nProps, translation);
128
+ }
129
+ if (typeof render === "function") {
130
+ return render(i18nProps);
131
+ }
132
+ const Component = component || FallbackComponent;
133
+ return React__default.createElement(Component, i18nProps, translation);
134
+ }
135
+ const RenderFragment = ({ children }) => {
136
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children);
137
+ };
138
+
139
+ exports.TransNoContext = TransNoContext;
@@ -0,0 +1,17 @@
1
+ import React, { ComponentType, FunctionComponent } from 'react';
2
+ import { I18n } from '@lingui/core';
3
+ import { a as TransRenderProps } from './react.a673be03.js';
4
+
5
+ type I18nContext = {
6
+ i18n: I18n;
7
+ _: I18n["_"];
8
+ defaultComponent?: ComponentType<TransRenderProps>;
9
+ };
10
+ type I18nProviderProps = Omit<I18nContext, "_"> & {
11
+ children?: React.ReactNode;
12
+ };
13
+ declare const LinguiContext: React.Context<I18nContext | null>;
14
+ declare function useLingui(): I18nContext;
15
+ declare const I18nProvider: FunctionComponent<I18nProviderProps>;
16
+
17
+ export { I18nProvider as I, LinguiContext as L, type I18nProviderProps as a, type I18nContext as b, useLingui as u };
@@ -0,0 +1,45 @@
1
+ import React, { ComponentType } from 'react';
2
+ import { MessageOptions, I18n } from '@lingui/core';
3
+
4
+ type TransRenderProps = {
5
+ id: string;
6
+ translation: React.ReactNode;
7
+ children: React.ReactNode;
8
+ message?: string | null;
9
+ /**
10
+ * @deprecated isTranslated prop is undocumented and buggy. It'll be removed in v5 release.
11
+ * */
12
+ isTranslated: boolean;
13
+ };
14
+ type TransRenderCallbackOrComponent = {
15
+ component?: undefined;
16
+ render?: ((props: TransRenderProps) => React.ReactElement<any, any>) | null;
17
+ } | {
18
+ component?: React.ComponentType<TransRenderProps> | null;
19
+ render?: undefined;
20
+ };
21
+ type TransProps = {
22
+ id: string;
23
+ message?: string;
24
+ values?: Record<string, unknown>;
25
+ components?: {
26
+ [key: string]: React.ElementType | any;
27
+ };
28
+ formats?: MessageOptions["formats"];
29
+ comment?: string;
30
+ children?: React.ReactNode;
31
+ } & TransRenderCallbackOrComponent;
32
+ /**
33
+ * Version of `<Trans>` component without using a Provider/Context React feature.
34
+ * Primarily made for support React Server Components (RSC)
35
+ *
36
+ * @experimental the api of this component is not stabilized yet.
37
+ */
38
+ declare function TransNoContext(props: TransProps & {
39
+ lingui: {
40
+ i18n: I18n;
41
+ defaultComponent?: ComponentType<TransRenderProps>;
42
+ };
43
+ }): React.ReactElement<any, any> | null;
44
+
45
+ export { type TransProps as T, type TransRenderProps as a, type TransRenderCallbackOrComponent as b, TransNoContext as c };
@@ -0,0 +1,45 @@
1
+ import React, { ComponentType } from 'react';
2
+ import { MessageOptions, I18n } from '@lingui/core';
3
+
4
+ type TransRenderProps = {
5
+ id: string;
6
+ translation: React.ReactNode;
7
+ children: React.ReactNode;
8
+ message?: string | null;
9
+ /**
10
+ * @deprecated isTranslated prop is undocumented and buggy. It'll be removed in v5 release.
11
+ * */
12
+ isTranslated: boolean;
13
+ };
14
+ type TransRenderCallbackOrComponent = {
15
+ component?: undefined;
16
+ render?: ((props: TransRenderProps) => React.ReactElement<any, any>) | null;
17
+ } | {
18
+ component?: React.ComponentType<TransRenderProps> | null;
19
+ render?: undefined;
20
+ };
21
+ type TransProps = {
22
+ id: string;
23
+ message?: string;
24
+ values?: Record<string, unknown>;
25
+ components?: {
26
+ [key: string]: React.ElementType | any;
27
+ };
28
+ formats?: MessageOptions["formats"];
29
+ comment?: string;
30
+ children?: React.ReactNode;
31
+ } & TransRenderCallbackOrComponent;
32
+ /**
33
+ * Version of `<Trans>` component without using a Provider/Context React feature.
34
+ * Primarily made for support React Server Components (RSC)
35
+ *
36
+ * @experimental the api of this component is not stabilized yet.
37
+ */
38
+ declare function TransNoContext(props: TransProps & {
39
+ lingui: {
40
+ i18n: I18n;
41
+ defaultComponent?: ComponentType<TransRenderProps>;
42
+ };
43
+ }): React.ReactElement<any, any> | null;
44
+
45
+ export { type TransProps as T, type TransRenderProps as a, type TransRenderCallbackOrComponent as b, TransNoContext as c };
@@ -0,0 +1,45 @@
1
+ import React, { ComponentType } from 'react';
2
+ import { MessageOptions, I18n } from '@lingui/core';
3
+
4
+ type TransRenderProps = {
5
+ id: string;
6
+ translation: React.ReactNode;
7
+ children: React.ReactNode;
8
+ message?: string | null;
9
+ /**
10
+ * @deprecated isTranslated prop is undocumented and buggy. It'll be removed in v5 release.
11
+ * */
12
+ isTranslated: boolean;
13
+ };
14
+ type TransRenderCallbackOrComponent = {
15
+ component?: undefined;
16
+ render?: ((props: TransRenderProps) => React.ReactElement<any, any>) | null;
17
+ } | {
18
+ component?: React.ComponentType<TransRenderProps> | null;
19
+ render?: undefined;
20
+ };
21
+ type TransProps = {
22
+ id: string;
23
+ message?: string;
24
+ values?: Record<string, unknown>;
25
+ components?: {
26
+ [key: string]: React.ElementType | any;
27
+ };
28
+ formats?: MessageOptions["formats"];
29
+ comment?: string;
30
+ children?: React.ReactNode;
31
+ } & TransRenderCallbackOrComponent;
32
+ /**
33
+ * Version of `<Trans>` component without using a Provider/Context React feature.
34
+ * Primarily made for support React Server Components (RSC)
35
+ *
36
+ * @experimental the api of this component is not stabilized yet.
37
+ */
38
+ declare function TransNoContext(props: TransProps & {
39
+ lingui: {
40
+ i18n: I18n;
41
+ defaultComponent?: ComponentType<TransRenderProps>;
42
+ };
43
+ }): React.ReactElement<any, any> | null;
44
+
45
+ export { type TransProps as T, type TransRenderProps as a, type TransRenderCallbackOrComponent as b, TransNoContext as c };
@@ -0,0 +1,17 @@
1
+ import React, { ComponentType, FunctionComponent } from 'react';
2
+ import { I18n } from '@lingui/core';
3
+ import { a as TransRenderProps } from './react.a673be03.cjs';
4
+
5
+ type I18nContext = {
6
+ i18n: I18n;
7
+ _: I18n["_"];
8
+ defaultComponent?: ComponentType<TransRenderProps>;
9
+ };
10
+ type I18nProviderProps = Omit<I18nContext, "_"> & {
11
+ children?: React.ReactNode;
12
+ };
13
+ declare const LinguiContext: React.Context<I18nContext | null>;
14
+ declare function useLingui(): I18nContext;
15
+ declare const I18nProvider: FunctionComponent<I18nProviderProps>;
16
+
17
+ export { I18nProvider as I, LinguiContext as L, type I18nProviderProps as a, type I18nContext as b, useLingui as u };