@lingui/react 4.0.0 → 4.1.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/index.cjs CHANGED
@@ -119,8 +119,8 @@ const makeCounter = (count = 0, prefix = "") => () => `${prefix}_${count++}`;
119
119
  function Trans(props) {
120
120
  const { i18n, defaultComponent } = useLingui();
121
121
  const { render, component, id, message, formats } = props;
122
- const values = { ...props.values || {} };
123
- const components = { ...props.components || {} };
122
+ const values = { ...props.values };
123
+ const components = { ...props.components };
124
124
  if (values) {
125
125
  Object.keys(values).forEach((key) => {
126
126
  const value = values[key];
@@ -164,8 +164,7 @@ function Trans(props) {
164
164
  return render(i18nProps);
165
165
  }
166
166
  const Component = component || FallbackComponent;
167
- const RenderedComponent = defaultComponent && !component ? defaultComponent : Component;
168
- return React.createElement(RenderedComponent, i18nProps, translation);
167
+ return React.createElement(Component, i18nProps, translation);
169
168
  }
170
169
  const RenderFragment = ({ children }) => {
171
170
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
package/dist/index.d.ts CHANGED
@@ -8,9 +8,13 @@ type TransRenderProps = {
8
8
  message?: string | null;
9
9
  isTranslated: boolean;
10
10
  };
11
- type MaximumOneOf<T, K extends keyof T = keyof T> = K extends keyof T ? {
12
- [P in K]?: T[K];
13
- } & Partial<Record<Exclude<keyof T, K>, never>> : never;
11
+ type TransRenderCallbackOrComponent = {
12
+ component?: undefined;
13
+ render?: (props: TransRenderProps) => React.ReactElement<any, any> | null;
14
+ } | {
15
+ component?: React.ComponentType<TransRenderProps> | null;
16
+ render?: undefined;
17
+ };
14
18
  type TransProps = {
15
19
  id: string;
16
20
  message?: string;
@@ -20,10 +24,7 @@ type TransProps = {
20
24
  };
21
25
  formats?: Record<string, unknown>;
22
26
  children?: React.ReactNode;
23
- } & MaximumOneOf<{
24
- component?: React.ComponentType<TransRenderProps>;
25
- render?: (props: TransRenderProps) => React.ReactElement<any, any> | null;
26
- }>;
27
+ } & TransRenderCallbackOrComponent;
27
28
  declare function Trans(props: TransProps): React.ReactElement<any, any> | null;
28
29
 
29
30
  type I18nContext = {
@@ -37,4 +38,4 @@ declare const LinguiContext: React.Context<I18nContext>;
37
38
  declare function useLingui(): I18nContext;
38
39
  declare const I18nProvider: FunctionComponent<I18nProviderProps>;
39
40
 
40
- export { I18nContext, I18nProvider, I18nProviderProps, LinguiContext, Trans, TransProps, TransRenderProps, useLingui };
41
+ export { I18nContext, I18nProvider, I18nProviderProps, LinguiContext, Trans, TransProps, TransRenderCallbackOrComponent, TransRenderProps, useLingui };
package/dist/index.mjs CHANGED
@@ -117,8 +117,8 @@ const makeCounter = (count = 0, prefix = "") => () => `${prefix}_${count++}`;
117
117
  function Trans(props) {
118
118
  const { i18n, defaultComponent } = useLingui();
119
119
  const { render, component, id, message, formats } = props;
120
- const values = { ...props.values || {} };
121
- const components = { ...props.components || {} };
120
+ const values = { ...props.values };
121
+ const components = { ...props.components };
122
122
  if (values) {
123
123
  Object.keys(values).forEach((key) => {
124
124
  const value = values[key];
@@ -162,8 +162,7 @@ function Trans(props) {
162
162
  return render(i18nProps);
163
163
  }
164
164
  const Component = component || FallbackComponent;
165
- const RenderedComponent = defaultComponent && !component ? defaultComponent : Component;
166
- return React.createElement(RenderedComponent, i18nProps, translation);
165
+ return React.createElement(Component, i18nProps, translation);
167
166
  }
168
167
  const RenderFragment = ({ children }) => {
169
168
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/react",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "sideEffects": false,
5
5
  "description": "React components for translations",
6
6
  "main": "./dist/index.cjs",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@babel/runtime": "^7.20.13",
61
- "@lingui/core": "4.0.0"
61
+ "@lingui/core": "4.1.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@lingui/jest-mocks": "*",
@@ -70,5 +70,5 @@
70
70
  "react-dom": "^17.0.2",
71
71
  "unbuild": "^1.1.2"
72
72
  },
73
- "gitHead": "998996381f5e5a458c2eccf650f949d8c5d8ac89"
73
+ "gitHead": "471813c5de9ade3acccf647e18922b570a804577"
74
74
  }