@lingui/react 3.15.0 → 3.16.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/CHANGELOG.md ADDED
@@ -0,0 +1,367 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [3.16.0](https://github.com/lingui/js-lingui/compare/v3.15.0...v3.16.0) (2023-01-18)
7
+
8
+ **Note:** Version bump only for package @lingui/react
9
+
10
+
11
+
12
+
13
+
14
+ # [3.15.0](https://github.com/lingui/js-lingui/compare/v3.14.0...v3.15.0) (2022-11-07)
15
+
16
+ **Note:** Version bump only for package @lingui/react
17
+
18
+
19
+
20
+
21
+
22
+ # [3.14.0](https://github.com/lingui/js-lingui/compare/v3.13.3...v3.14.0) (2022-06-22)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Add extra package.json under `/esm` ([#1258](https://github.com/lingui/js-lingui/issues/1258)) ([80cd337](https://github.com/lingui/js-lingui/commit/80cd3378ceb5677bfa50b14f67e4e31703392298))
28
+
29
+
30
+ ### Features
31
+
32
+ * Pass props to I18nProvider.defaultComponent in Trans.render style ([#1242](https://github.com/lingui/js-lingui/issues/1242)) ([fe4cac4](https://github.com/lingui/js-lingui/commit/fe4cac4f89ae195ad8b5216fdaede73900753686))
33
+
34
+
35
+
36
+
37
+
38
+ ## [3.13.3](https://github.com/lingui/js-lingui/compare/v3.13.2...v3.13.3) (2022-04-24)
39
+
40
+
41
+ ### Bug Fixes
42
+
43
+ * @lingui/react compatible with React 18 ([2a235ba](https://github.com/lingui/js-lingui/commit/2a235baa093d668a0a029ec6c683e9dc00f68f42))
44
+ * specify children for react v18 types ([#1230](https://github.com/lingui/js-lingui/issues/1230)) ([ee69736](https://github.com/lingui/js-lingui/commit/ee69736089d4c48117d85582b56a26c09cdf82ea))
45
+
46
+
47
+
48
+
49
+
50
+ ## [3.13.2](https://github.com/lingui/js-lingui/compare/v3.13.1...v3.13.2) (2022-01-24)
51
+
52
+ **Note:** Version bump only for package @lingui/react
53
+
54
+
55
+
56
+
57
+
58
+ ## [3.13.1](https://github.com/lingui/js-lingui/compare/v3.13.0...v3.13.1) (2022-01-21)
59
+
60
+
61
+ ### Bug Fixes
62
+
63
+ * i18n.activate should load instantly new messages ([#1182](https://github.com/lingui/js-lingui/issues/1182)) ([f8f47a2](https://github.com/lingui/js-lingui/commit/f8f47a2385fe3d8dd3395c493027de2492509325))
64
+
65
+
66
+
67
+
68
+
69
+ # [3.13.0](https://github.com/lingui/js-lingui/compare/v3.12.1...v3.13.0) (2021-11-26)
70
+
71
+
72
+ ### Features
73
+
74
+ * msgctxt support ([#1094](https://github.com/lingui/js-lingui/issues/1094)) ([8ee42cb](https://github.com/lingui/js-lingui/commit/8ee42cbfe26bc6d055748dcf2713ab8ade7ec827))
75
+
76
+
77
+
78
+
79
+
80
+ ## [3.12.1](https://github.com/lingui/js-lingui/compare/v3.12.0...v3.12.1) (2021-09-28)
81
+
82
+ **Note:** Version bump only for package @lingui/react
83
+
84
+
85
+
86
+
87
+
88
+ # [3.12.0](https://github.com/lingui/js-lingui/compare/v3.11.1...v3.12.0) (2021-09-28)
89
+
90
+ **Note:** Version bump only for package @lingui/react
91
+
92
+
93
+
94
+
95
+
96
+ ## [3.11.1](https://github.com/lingui/js-lingui/compare/v3.11.0...v3.11.1) (2021-09-07)
97
+
98
+ **Note:** Version bump only for package @lingui/react
99
+
100
+
101
+
102
+
103
+
104
+ # [3.11.0](https://github.com/lingui/js-lingui/compare/v3.10.4...v3.11.0) (2021-09-07)
105
+
106
+
107
+ ### Bug Fixes
108
+
109
+ * sideEffects to false for shrinking bundle size ([#1129](https://github.com/lingui/js-lingui/issues/1129)) ([57cd2e5](https://github.com/lingui/js-lingui/commit/57cd2e576945ba30aea30d5cf5bcb27d1f77fe4c))
110
+
111
+
112
+
113
+
114
+
115
+ ## [3.10.4](https://github.com/lingui/js-lingui/compare/v3.10.3...v3.10.4) (2021-06-16)
116
+
117
+ **Note:** Version bump only for package @lingui/react
118
+
119
+
120
+
121
+
122
+
123
+ ## [3.10.3](https://github.com/lingui/js-lingui/compare/v3.10.2...v3.10.3) (2021-06-14)
124
+
125
+ **Note:** Version bump only for package @lingui/react
126
+
127
+
128
+
129
+
130
+
131
+ ## [3.10.2](https://github.com/lingui/js-lingui/compare/v3.10.1...v3.10.2) (2021-06-08)
132
+
133
+ **Note:** Version bump only for package @lingui/react
134
+
135
+
136
+
137
+
138
+
139
+ ## [3.10.1](https://github.com/lingui/js-lingui/compare/v3.10.0...v3.10.1) (2021-06-08)
140
+
141
+
142
+ ### Bug Fixes
143
+
144
+ * reverts reduce size of ESM packages ([#1066](https://github.com/lingui/js-lingui/issues/1066)) ([3a057e0](https://github.com/lingui/js-lingui/commit/3a057e0c61224b98c93203e0d88136fa48f309ba))
145
+
146
+
147
+
148
+
149
+
150
+ # [3.10.0](https://github.com/lingui/js-lingui/compare/v3.9.0...v3.10.0) (2021-06-08)
151
+
152
+
153
+ ### Bug Fixes
154
+
155
+ * reduce size of ESM packages ([#1066](https://github.com/lingui/js-lingui/issues/1066)) ([9990eba](https://github.com/lingui/js-lingui/commit/9990ebaa9d30f7e218c106a2abfd7ddbcf0e0170))
156
+
157
+
158
+
159
+
160
+
161
+ # [3.9.0](https://github.com/lingui/js-lingui/compare/v3.8.10...v3.9.0) (2021-05-18)
162
+
163
+ **Note:** Version bump only for package @lingui/react
164
+
165
+
166
+
167
+
168
+
169
+ ## [3.8.10](https://github.com/lingui/js-lingui/compare/v3.8.9...v3.8.10) (2021-04-19)
170
+
171
+ **Note:** Version bump only for package @lingui/react
172
+
173
+
174
+
175
+
176
+
177
+ ## [3.8.9](https://github.com/lingui/js-lingui/compare/v3.8.8...v3.8.9) (2021-04-09)
178
+
179
+
180
+ ### Bug Fixes
181
+
182
+ * event emitter refactor (reverted) ([#1038](https://github.com/lingui/js-lingui/issues/1038)) ([f299493](https://github.com/lingui/js-lingui/commit/f299493999299fe9a7d0e01b9045e7f0a9813c6a))
183
+
184
+
185
+
186
+
187
+
188
+ ## [3.8.8](https://github.com/lingui/js-lingui/compare/v3.8.7...v3.8.8) (2021-04-09)
189
+
190
+ **Note:** Version bump only for package @lingui/react
191
+
192
+
193
+
194
+
195
+
196
+ ## [3.8.7](https://github.com/lingui/js-lingui/compare/v3.8.6...v3.8.7) (2021-04-09)
197
+
198
+
199
+ ### Bug Fixes
200
+
201
+ * unicode chars in native environments + event emitter refactor ([#1036](https://github.com/lingui/js-lingui/issues/1036)) ([39fa90d](https://github.com/lingui/js-lingui/commit/39fa90d95c08f105f3f7feb17b65d9b8f916b73a))
202
+
203
+
204
+
205
+
206
+
207
+ ## [3.8.6](https://github.com/lingui/js-lingui/compare/v3.8.5...v3.8.6) (2021-04-08)
208
+
209
+ **Note:** Version bump only for package @lingui/react
210
+
211
+
212
+
213
+
214
+
215
+ ## [3.8.5](https://github.com/lingui/js-lingui/compare/v3.8.4...v3.8.5) (2021-04-08)
216
+
217
+ **Note:** Version bump only for package @lingui/react
218
+
219
+
220
+
221
+
222
+
223
+ ## [3.8.4](https://github.com/lingui/js-lingui/compare/v3.8.3...v3.8.4) (2021-04-08)
224
+
225
+ **Note:** Version bump only for package @lingui/react
226
+
227
+
228
+
229
+
230
+
231
+ ## [3.8.3](https://github.com/lingui/js-lingui/compare/v3.8.2...v3.8.3) (2021-04-05)
232
+
233
+ **Note:** Version bump only for package @lingui/react
234
+
235
+
236
+
237
+
238
+
239
+ ## [3.8.2](https://github.com/lingui/js-lingui/compare/v3.8.1...v3.8.2) (2021-03-31)
240
+
241
+ **Note:** Version bump only for package @lingui/react
242
+
243
+
244
+
245
+
246
+
247
+ ## [3.8.1](https://github.com/lingui/js-lingui/compare/v3.8.0...v3.8.1) (2021-03-23)
248
+
249
+ **Note:** Version bump only for package @lingui/react
250
+
251
+
252
+
253
+
254
+
255
+ # [3.8.0](https://github.com/lingui/js-lingui/compare/v3.7.2...v3.8.0) (2021-03-23)
256
+
257
+ **Note:** Version bump only for package @lingui/react
258
+
259
+
260
+
261
+
262
+
263
+ ## [3.7.2](https://github.com/lingui/js-lingui/compare/v3.7.1...v3.7.2) (2021-03-14)
264
+
265
+ **Note:** Version bump only for package @lingui/react
266
+
267
+
268
+
269
+
270
+
271
+ ## [3.7.1](https://github.com/lingui/js-lingui/compare/v3.7.0...v3.7.1) (2021-03-07)
272
+
273
+ **Note:** Version bump only for package @lingui/react
274
+
275
+
276
+
277
+
278
+
279
+ # [3.7.0](https://github.com/lingui/js-lingui/compare/v3.6.0...v3.7.0) (2021-03-04)
280
+
281
+ **Note:** Version bump only for package @lingui/react
282
+
283
+
284
+
285
+
286
+
287
+ # [3.6.0](https://github.com/lingui/js-lingui/compare/v3.5.1...v3.6.0) (2021-02-23)
288
+
289
+
290
+ ### Features
291
+
292
+ * ship universal modules with ESM ([#979](https://github.com/lingui/js-lingui/issues/979)) ([6cd5fe0](https://github.com/lingui/js-lingui/commit/6cd5fe0a71dd5cf7e0832bd3e9902a2f6ba789f6))
293
+
294
+
295
+
296
+
297
+
298
+ ## [3.5.1](https://github.com/lingui/js-lingui/compare/v3.5.0...v3.5.1) (2021-02-09)
299
+
300
+ **Note:** Version bump only for package @lingui/react
301
+
302
+
303
+
304
+
305
+
306
+ # [3.5.0](https://github.com/lingui/js-lingui/compare/v3.4.0...v3.5.0) (2021-02-02)
307
+
308
+
309
+ ### Bug Fixes
310
+
311
+ * **docs:** documentation-typos ([#955](https://github.com/lingui/js-lingui/issues/955)) ([f73cb8c](https://github.com/lingui/js-lingui/commit/f73cb8c09d9919489f5fbb9a539da30faae53004))
312
+ * I18nProvider defaultComponent typing ([#953](https://github.com/lingui/js-lingui/issues/953)) ([6b08dd3](https://github.com/lingui/js-lingui/commit/6b08dd309d1ac8e0a8dc081e097e69678e822eda))
313
+
314
+
315
+
316
+
317
+
318
+ # [3.4.0](https://github.com/lingui/js-lingui/compare/v3.3.0...v3.4.0) (2021-01-13)
319
+
320
+ **Note:** Version bump only for package @lingui/react
321
+
322
+
323
+
324
+
325
+
326
+ # [3.3.0](https://github.com/lingui/js-lingui/compare/v3.2.3...v3.3.0) (2020-12-08)
327
+
328
+ **Note:** Version bump only for package @lingui/react
329
+
330
+
331
+
332
+
333
+
334
+ ## [3.2.3](https://github.com/lingui/js-lingui/compare/v3.2.2...v3.2.3) (2020-11-22)
335
+
336
+
337
+ ### Bug Fixes
338
+
339
+ * export TransRenderProps from @lingui/react ([#877](https://github.com/lingui/js-lingui/issues/877)) ([3db9d6b](https://github.com/lingui/js-lingui/commit/3db9d6b0bfe9edae99523cd706de6826f67184ad))
340
+ * omit i18n prop in withI18n typescript interface ([#879](https://github.com/lingui/js-lingui/issues/879)) ([5927d42](https://github.com/lingui/js-lingui/commit/5927d42b256d1adfb26ed03367e521bfc8f1e2e6))
341
+
342
+
343
+
344
+
345
+
346
+ ## [3.2.2](https://github.com/lingui/js-lingui/compare/v3.2.1...v3.2.2) (2020-11-20)
347
+
348
+ **Note:** Version bump only for package @lingui/react
349
+
350
+
351
+
352
+
353
+
354
+ # [3.2.0](https://github.com/lingui/js-lingui/compare/v3.1.0...v3.2.0) (2020-11-12)
355
+
356
+ **Note:** Version bump only for package @lingui/react
357
+
358
+
359
+
360
+
361
+
362
+ # [3.1.0](https://github.com/lingui/js-lingui/compare/v3.0.3...v3.1.0) (2020-11-10)
363
+
364
+
365
+ ### Bug Fixes
366
+
367
+ * ensure render of I18nProvider in async scenarios ([#839](https://github.com/lingui/js-lingui/issues/839)) ([cd2816a](https://github.com/lingui/js-lingui/commit/cd2816a3d847042029c9b29dfb420f2ff5ae02cc))
package/build/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Tomáš Ehrlich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -1,22 +1,15 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var _extends = require('@babel/runtime/helpers/extends');
6
5
  var React = require('react');
7
6
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
8
7
 
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
12
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
14
-
15
- var LinguiContext = /*#__PURE__*/React__default['default'].createContext(null);
8
+ var LinguiContext = /*#__PURE__*/React.createContext(null);
16
9
  function useLingui() {
17
- var context = React__default['default'].useContext(LinguiContext);
10
+ var context = React.useContext(LinguiContext);
18
11
 
19
- {
12
+ if (process.env.NODE_ENV !== "production") {
20
13
  if (context == null) {
21
14
  throw new Error("useLingui hook was used without I18nProvider.");
22
15
  }
@@ -27,8 +20,8 @@ function useLingui() {
27
20
  function withI18n(o) {
28
21
  return function (WrappedComponent) {
29
22
  return function (props) {
30
- {
31
- if (typeof o === "function" || /*#__PURE__*/React__default['default'].isValidElement(o)) {
23
+ if (process.env.NODE_ENV !== "production") {
24
+ if (typeof o === "function" || /*#__PURE__*/React.isValidElement(o)) {
32
25
  throw new Error("withI18n([options]) takes options as a first argument, " + "but received React component itself. Without options, the Component " + "should be wrapped as withI18n()(Component), not withI18n(Component).");
33
26
  }
34
27
  }
@@ -36,7 +29,7 @@ function withI18n(o) {
36
29
  var _useLingui = useLingui(),
37
30
  i18n = _useLingui.i18n;
38
31
 
39
- return /*#__PURE__*/React__default['default'].createElement(WrappedComponent, Object.assign({}, props, {
32
+ return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, {
40
33
  i18n: i18n
41
34
  }));
42
35
  };
@@ -49,16 +42,16 @@ var I18nProvider = function I18nProvider(_ref) {
49
42
  forceRenderOnLocaleChange = _ref$forceRenderOnLoc === void 0 ? true : _ref$forceRenderOnLoc,
50
43
  children = _ref.children;
51
44
 
52
- /**
53
- * We can't pass `i18n` object directly through context, because even when locale
54
- * or messages are changed, i18n object is still the same. Context provider compares
55
- * reference identity and suggested workaround is create a wrapper object every time
56
- * we need to trigger re-render. See https://reactjs.org/docs/context.html#caveats.
57
- *
58
- * Due to this effect we also pass `defaultComponent` in the same context, instead
59
- * of creating a separate Provider/Consumer pair.
60
- *
61
- * We can't use useMemo hook either, because we want to recalculate value manually.
45
+ /**
46
+ * We can't pass `i18n` object directly through context, because even when locale
47
+ * or messages are changed, i18n object is still the same. Context provider compares
48
+ * reference identity and suggested workaround is create a wrapper object every time
49
+ * we need to trigger re-render. See https://reactjs.org/docs/context.html#caveats.
50
+ *
51
+ * Due to this effect we also pass `defaultComponent` in the same context, instead
52
+ * of creating a separate Provider/Consumer pair.
53
+ *
54
+ * We can't use useMemo hook either, because we want to recalculate value manually.
62
55
  */
63
56
  var makeContext = function makeContext() {
64
57
  return {
@@ -71,29 +64,29 @@ var I18nProvider = function I18nProvider(_ref) {
71
64
  return forceRenderOnLocaleChange ? i18n.locale || 'default' : 'default';
72
65
  };
73
66
 
74
- var _React$useState = React__default['default'].useState(makeContext()),
75
- _React$useState2 = _slicedToArray__default['default'](_React$useState, 2),
67
+ var _React$useState = React.useState(makeContext()),
68
+ _React$useState2 = _slicedToArray(_React$useState, 2),
76
69
  context = _React$useState2[0],
77
70
  setContext = _React$useState2[1],
78
- _React$useState3 = React__default['default'].useState(getRenderKey()),
79
- _React$useState4 = _slicedToArray__default['default'](_React$useState3, 2),
71
+ _React$useState3 = React.useState(getRenderKey()),
72
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
80
73
  renderKey = _React$useState4[0],
81
74
  setRenderKey = _React$useState4[1];
82
- /**
83
- * Subscribe for locale/message changes
84
- *
85
- * I18n object from `@lingui/core` is the single source of truth for all i18n related
86
- * data (active locale, catalogs). When new messages are loaded or locale is changed
87
- * we need to trigger re-rendering of LinguiContext.Consumers.
88
- *
89
- * We call `setContext(makeContext())` after adding the observer in case the `change`
90
- * event would already have fired between the inital renderKey calculation and the
91
- * `useEffect` hook being called. This can happen if locales are loaded/activated
92
- * async.
75
+ /**
76
+ * Subscribe for locale/message changes
77
+ *
78
+ * I18n object from `@lingui/core` is the single source of truth for all i18n related
79
+ * data (active locale, catalogs). When new messages are loaded or locale is changed
80
+ * we need to trigger re-rendering of LinguiContext.Consumers.
81
+ *
82
+ * We call `setContext(makeContext())` after adding the observer in case the `change`
83
+ * event would already have fired between the inital renderKey calculation and the
84
+ * `useEffect` hook being called. This can happen if locales are loaded/activated
85
+ * async.
93
86
  */
94
87
 
95
88
 
96
- React__default['default'].useEffect(function () {
89
+ React.useEffect(function () {
97
90
  var unsubscribe = i18n.on("change", function () {
98
91
  setContext(makeContext());
99
92
  setRenderKey(getRenderKey());
@@ -112,7 +105,7 @@ var I18nProvider = function I18nProvider(_ref) {
112
105
  };
113
106
  }, []);
114
107
  if (forceRenderOnLocaleChange && renderKey === 'default') return null;
115
- return /*#__PURE__*/React__default['default'].createElement(LinguiContext.Provider, {
108
+ return /*#__PURE__*/React.createElement(LinguiContext.Provider, {
116
109
  value: context,
117
110
  key: renderKey
118
111
  }, children);
@@ -146,12 +139,12 @@ var voidElementTags = {
146
139
  wbr: true,
147
140
  menuitem: true
148
141
  };
149
- /**
150
- * `formatElements` - parse string and return tree of react elements
151
- *
152
- * `value` is string to be formatted with <0>Paired<0/> or <0/> (unpaired)
153
- * placeholders. `elements` is a array of react elements which indexes
154
- * correspond to element indexes in formatted string
142
+ /**
143
+ * `formatElements` - parse string and return tree of react elements
144
+ *
145
+ * `value` is string to be formatted with <0>Paired<0/> or <0/> (unpaired)
146
+ * placeholders. `elements` is a array of react elements which indexes
147
+ * correspond to element indexes in formatted string
155
148
  */
156
149
 
157
150
  function formatElements(value) {
@@ -169,7 +162,7 @@ function formatElements(value) {
169
162
 
170
163
  try {
171
164
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
172
- var _step$value = _slicedToArray__default['default'](_step.value, 3),
165
+ var _step$value = _slicedToArray(_step.value, 3),
173
166
  index = _step$value[0],
174
167
  children = _step$value[1],
175
168
  after = _step$value[2];
@@ -184,10 +177,10 @@ function formatElements(value) {
184
177
  } // ignore problematic element but push its children and elements after it
185
178
 
186
179
 
187
- element = /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment);
180
+ element = /*#__PURE__*/React.createElement(React.Fragment);
188
181
  }
189
182
 
190
- tree.push( /*#__PURE__*/React__default['default'].cloneElement(element, {
183
+ tree.push( /*#__PURE__*/React.cloneElement(element, {
191
184
  key: uniqueId()
192
185
  }, // format children for pair tags
193
186
  // unpaired tags might have children if it's a component passed as a variable
@@ -202,19 +195,19 @@ function formatElements(value) {
202
195
 
203
196
  return tree;
204
197
  }
205
- /*
206
- * `getElements` - return array of element indexes and element childrens
207
- *
208
- * `parts` is array of [pairedIndex, children, unpairedIndex, textAfter, ...]
209
- * where:
210
- * - `pairedIndex` is index of paired element (undef for unpaired)
211
- * - `children` are children of paired element (undef for unpaired)
212
- * - `unpairedIndex` is index of unpaired element (undef for paired)
213
- * - `textAfter` is string after all elements (empty string, if there's nothing)
214
- *
215
- * `parts` length is always multiply of 4
216
- *
217
- * Returns: Array<[elementIndex, children, after]>
198
+ /*
199
+ * `getElements` - return array of element indexes and element childrens
200
+ *
201
+ * `parts` is array of [pairedIndex, children, unpairedIndex, textAfter, ...]
202
+ * where:
203
+ * - `pairedIndex` is index of paired element (undef for unpaired)
204
+ * - `children` are children of paired element (undef for unpaired)
205
+ * - `unpairedIndex` is index of unpaired element (undef for paired)
206
+ * - `textAfter` is string after all elements (empty string, if there's nothing)
207
+ *
208
+ * `parts` length is always multiply of 4
209
+ *
210
+ * Returns: Array<[elementIndex, children, after]>
218
211
  */
219
212
 
220
213
 
@@ -222,7 +215,7 @@ function getElements(parts) {
222
215
  if (!parts.length) return [];
223
216
 
224
217
  var _parts$slice = parts.slice(0, 4),
225
- _parts$slice2 = _slicedToArray__default['default'](_parts$slice, 4),
218
+ _parts$slice2 = _slicedToArray(_parts$slice, 4),
226
219
  paired = _parts$slice2[0],
227
220
  children = _parts$slice2[1],
228
221
  unpaired = _parts$slice2[2],
@@ -241,7 +234,7 @@ var makeCounter = function makeCounter() {
241
234
 
242
235
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
243
236
 
244
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
237
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
245
238
  function Trans(props) {
246
239
  var _useLingui = useLingui(),
247
240
  i18n = _useLingui.i18n,
@@ -258,18 +251,18 @@ function Trans(props) {
258
251
  var components = _objectSpread({}, props.components);
259
252
 
260
253
  if (values) {
261
- /*
262
- Related discussion: https://github.com/lingui/js-lingui/issues/183
263
- Values *might* contain React elements with static content.
264
- They're replaced with <INDEX /> placeholders and added to `components`.
265
- Example:
266
- Translation: Hello {name}
267
- Values: { name: <strong>Jane</strong> }
268
- It'll become "Hello <0 />" with components=[<strong>Jane</strong>]
254
+ /*
255
+ Related discussion: https://github.com/lingui/js-lingui/issues/183
256
+ Values *might* contain React elements with static content.
257
+ They're replaced with <INDEX /> placeholders and added to `components`.
258
+ Example:
259
+ Translation: Hello {name}
260
+ Values: { name: <strong>Jane</strong> }
261
+ It'll become "Hello <0 />" with components=[<strong>Jane</strong>]
269
262
  */
270
263
  Object.keys(values).forEach(function (key) {
271
264
  var value = values[key];
272
- if (! /*#__PURE__*/React__default['default'].isValidElement(value)) return;
265
+ if (! /*#__PURE__*/React.isValidElement(value)) return;
273
266
  var index = Object.keys(components).length;
274
267
  components[index] = value;
275
268
  values[key] = "<".concat(index, "/>");
@@ -290,7 +283,7 @@ function Trans(props) {
290
283
  return translation;
291
284
  }
292
285
 
293
- var FallbackComponent = defaultComponent || React__default['default'].Fragment;
286
+ var FallbackComponent = defaultComponent || React.Fragment;
294
287
  var i18nProps = {
295
288
  id: id,
296
289
  message: message,
@@ -306,7 +299,7 @@ function Trans(props) {
306
299
  // Apparently, both function components and class components are functions
307
300
  // See https://stackoverflow.com/a/41658173/1535540
308
301
  console.error("Invalid value supplied to prop `component`. It must be a React component, provided ".concat(component));
309
- return /*#__PURE__*/React__default['default'].createElement(FallbackComponent, Object.assign({}, i18nProps), translation);
302
+ return /*#__PURE__*/React.createElement(FallbackComponent, i18nProps, translation);
310
303
  } // Rendering using a render prop
311
304
 
312
305
 
@@ -318,7 +311,7 @@ function Trans(props) {
318
311
 
319
312
  var Component = component || FallbackComponent;
320
313
  var DefaultComponent = defaultComponent;
321
- return DefaultComponent && !component ? /*#__PURE__*/React__default['default'].createElement(DefaultComponent, Object.assign({}, i18nProps), translation) : /*#__PURE__*/React__default['default'].createElement(Component, null, translation);
314
+ return DefaultComponent && !component ? /*#__PURE__*/React.createElement(DefaultComponent, i18nProps, translation) : /*#__PURE__*/React.createElement(Component, null, translation);
322
315
  }
323
316
  Trans.defaultProps = {
324
317
  values: {},
@@ -329,4 +322,4 @@ exports.I18nProvider = I18nProvider;
329
322
  exports.Trans = Trans;
330
323
  exports.useLingui = useLingui;
331
324
  exports.withI18n = withI18n;
332
- //# sourceMappingURL=react.development.js.map
325
+ //# sourceMappingURL=index.js.map