use-intl 2.7.1-alpha.4 → 2.7.2-alpha.1

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,675 +1,8 @@
1
- import React, { createContext, useContext, useRef, useMemo, isValidElement, cloneElement, useState, useEffect } from 'react';
2
- import { IntlMessageFormat } from 'intl-messageformat';
3
-
4
- function _extends() {
5
- _extends = Object.assign || function (target) {
6
- for (var i = 1; i < arguments.length; i++) {
7
- var source = arguments[i];
8
-
9
- for (var key in source) {
10
- if (Object.prototype.hasOwnProperty.call(source, key)) {
11
- target[key] = source[key];
12
- }
13
- }
14
- }
15
-
16
- return target;
17
- };
18
-
19
- return _extends.apply(this, arguments);
20
- }
21
-
22
- function _inheritsLoose(subClass, superClass) {
23
- subClass.prototype = Object.create(superClass.prototype);
24
- subClass.prototype.constructor = subClass;
25
-
26
- _setPrototypeOf(subClass, superClass);
27
- }
28
-
29
- function _getPrototypeOf(o) {
30
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
31
- return o.__proto__ || Object.getPrototypeOf(o);
32
- };
33
- return _getPrototypeOf(o);
34
- }
35
-
36
- function _setPrototypeOf(o, p) {
37
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
38
- o.__proto__ = p;
39
- return o;
40
- };
41
-
42
- return _setPrototypeOf(o, p);
43
- }
44
-
45
- function _isNativeReflectConstruct() {
46
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
47
- if (Reflect.construct.sham) return false;
48
- if (typeof Proxy === "function") return true;
49
-
50
- try {
51
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
52
- return true;
53
- } catch (e) {
54
- return false;
55
- }
56
- }
57
-
58
- function _construct(Parent, args, Class) {
59
- if (_isNativeReflectConstruct()) {
60
- _construct = Reflect.construct;
61
- } else {
62
- _construct = function _construct(Parent, args, Class) {
63
- var a = [null];
64
- a.push.apply(a, args);
65
- var Constructor = Function.bind.apply(Parent, a);
66
- var instance = new Constructor();
67
- if (Class) _setPrototypeOf(instance, Class.prototype);
68
- return instance;
69
- };
70
- }
71
-
72
- return _construct.apply(null, arguments);
73
- }
74
-
75
- function _isNativeFunction(fn) {
76
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
77
- }
78
-
79
- function _wrapNativeSuper(Class) {
80
- var _cache = typeof Map === "function" ? new Map() : undefined;
81
-
82
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
83
- if (Class === null || !_isNativeFunction(Class)) return Class;
84
-
85
- if (typeof Class !== "function") {
86
- throw new TypeError("Super expression must either be null or a function");
87
- }
88
-
89
- if (typeof _cache !== "undefined") {
90
- if (_cache.has(Class)) return _cache.get(Class);
91
-
92
- _cache.set(Class, Wrapper);
93
- }
94
-
95
- function Wrapper() {
96
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
97
- }
98
-
99
- Wrapper.prototype = Object.create(Class.prototype, {
100
- constructor: {
101
- value: Wrapper,
102
- enumerable: false,
103
- writable: true,
104
- configurable: true
105
- }
106
- });
107
- return _setPrototypeOf(Wrapper, Class);
108
- };
109
-
110
- return _wrapNativeSuper(Class);
111
- }
112
-
113
- function _objectWithoutPropertiesLoose(source, excluded) {
114
- if (source == null) return {};
115
- var target = {};
116
- var sourceKeys = Object.keys(source);
117
- var key, i;
118
-
119
- for (i = 0; i < sourceKeys.length; i++) {
120
- key = sourceKeys[i];
121
- if (excluded.indexOf(key) >= 0) continue;
122
- target[key] = source[key];
123
- }
124
-
125
- return target;
126
- }
127
-
128
- var IntlContext = /*#__PURE__*/createContext(undefined);
129
-
130
- var _excluded = ["children", "onError", "getMessageFallback", "messages"];
131
-
132
- function defaultGetMessageFallback(_ref) {
133
- var key = _ref.key,
134
- namespace = _ref.namespace;
135
- return [namespace, key].filter(function (part) {
136
- return part != null;
137
- }).join('.');
138
- }
139
-
140
- function defaultOnError(error) {
141
- console.error(error);
142
- }
143
-
144
- function IntlProvider(_ref2) {
145
- var children = _ref2.children,
146
- _ref2$onError = _ref2.onError,
147
- onError = _ref2$onError === void 0 ? defaultOnError : _ref2$onError,
148
- _ref2$getMessageFallb = _ref2.getMessageFallback,
149
- getMessageFallback = _ref2$getMessageFallb === void 0 ? defaultGetMessageFallback : _ref2$getMessageFallb,
150
- messages = _ref2.messages,
151
- contextValues = _objectWithoutPropertiesLoose(_ref2, _excluded);
152
-
153
- return React.createElement(IntlContext.Provider, {
154
- value: _extends({}, contextValues, {
155
- messages: messages,
156
- onError: onError,
157
- getMessageFallback: getMessageFallback
158
- })
159
- }, children);
160
- }
161
-
162
- var IntlErrorCode;
163
-
164
- (function (IntlErrorCode) {
165
- IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
166
- IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
167
- IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH";
168
- IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
169
- IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
170
- IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
171
- })(IntlErrorCode || (IntlErrorCode = {}));
172
-
173
- var IntlError = /*#__PURE__*/function (_Error) {
174
- _inheritsLoose(IntlError, _Error);
175
-
176
- function IntlError(code, originalMessage) {
177
- var _this;
178
-
179
- var message = code;
180
-
181
- if (originalMessage) {
182
- message += ': ' + originalMessage;
183
- }
184
-
185
- _this = _Error.call(this, message) || this;
186
- _this.code = void 0;
187
- _this.originalMessage = void 0;
188
- _this.code = code;
189
-
190
- if (originalMessage) {
191
- _this.originalMessage = originalMessage;
192
- }
193
-
194
- return _this;
195
- }
196
-
197
- return IntlError;
198
- }( /*#__PURE__*/_wrapNativeSuper(Error));
199
-
200
- function useIntlContext() {
201
- var context = useContext(IntlContext);
202
-
203
- if (!context) {
204
- throw new Error(process.env.NODE_ENV !== "production" ? 'No intl context found. Have you configured the provider?' : undefined);
205
- }
206
-
207
- return context;
208
- }
209
-
210
- function setTimeZoneInFormats(formats, timeZone) {
211
- if (!formats) return formats; // The only way to set a time zone with `intl-messageformat` is to merge it into the formats
212
- // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
213
-
214
- return Object.keys(formats).reduce(function (acc, key) {
215
- acc[key] = _extends({
216
- timeZone: timeZone
217
- }, formats[key]);
218
- return acc;
219
- }, {});
220
- }
221
- /**
222
- * `intl-messageformat` uses separate keys for `date` and `time`, but there's
223
- * only one native API: `Intl.DateTimeFormat`. Additionally you might want to
224
- * include both a time and a date in a value, therefore the separation doesn't
225
- * seem so useful. We offer a single `dateTime` namespace instead, but we have
226
- * to convert the format before `intl-messageformat` can be used.
227
- */
228
-
229
-
230
- function convertFormatsToIntlMessageFormat(formats, timeZone) {
231
- var formatsWithTimeZone = timeZone ? _extends({}, formats, {
232
- dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)
233
- }) : formats;
234
- return _extends({}, formatsWithTimeZone, {
235
- date: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime,
236
- time: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime
237
- });
238
- }
239
-
240
- function resolvePath(messages, idPath, namespace) {
241
- if (!messages) {
242
- throw new Error(process.env.NODE_ENV !== "production" ? "No messages available at `" + namespace + "`." : undefined);
243
- }
244
-
245
- var message = messages;
246
- idPath.split('.').forEach(function (part) {
247
- var next = message[part];
248
-
249
- if (part == null || next == null) {
250
- throw new Error(process.env.NODE_ENV !== "production" ? "Could not resolve `" + idPath + "` in " + (namespace ? "`" + namespace + "`" : 'messages') + "." : undefined);
251
- }
252
-
253
- message = next;
254
- });
255
- return message;
256
- }
257
-
258
- function prepareTranslationValues(values) {
259
- if (Object.keys(values).length === 0) return undefined; // Workaround for https://github.com/formatjs/formatjs/issues/1467
260
-
261
- var transformedValues = {};
262
- Object.keys(values).forEach(function (key) {
263
- var index = 0;
264
- var value = values[key];
265
- var transformed;
266
-
267
- if (typeof value === 'function') {
268
- transformed = function transformed(children) {
269
- var result = value(children);
270
- return isValidElement(result) ? cloneElement(result, {
271
- key: key + index++
272
- }) : result;
273
- };
274
- } else {
275
- transformed = value;
276
- }
277
-
278
- transformedValues[key] = transformed;
279
- });
280
- return transformedValues;
281
- }
282
-
283
- function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
284
- var _useIntlContext = useIntlContext(),
285
- defaultTranslationValues = _useIntlContext.defaultTranslationValues,
286
- globalFormats = _useIntlContext.formats,
287
- getMessageFallback = _useIntlContext.getMessageFallback,
288
- locale = _useIntlContext.locale,
289
- onError = _useIntlContext.onError,
290
- timeZone = _useIntlContext.timeZone; // The `namespacePrefix` is part of the type system.
291
- // See the comment in the hook invocation.
292
-
293
-
294
- allMessages = allMessages[namespacePrefix];
295
- namespace = namespace === namespacePrefix ? undefined : namespace.slice((namespacePrefix + '.').length);
296
- var cachedFormatsByLocaleRef = useRef({});
297
- var messagesOrError = useMemo(function () {
298
- try {
299
- if (!allMessages) {
300
- throw new Error(process.env.NODE_ENV !== "production" ? "No messages were configured on the provider." : undefined);
301
- }
302
-
303
- var retrievedMessages = namespace ? resolvePath(allMessages, namespace) : allMessages;
304
-
305
- if (!retrievedMessages) {
306
- throw new Error(process.env.NODE_ENV !== "production" ? "No messages for namespace `" + namespace + "` found." : undefined);
307
- }
308
-
309
- return retrievedMessages;
310
- } catch (error) {
311
- var intlError = new IntlError(IntlErrorCode.MISSING_MESSAGE, error.message);
312
- onError(intlError);
313
- return intlError;
314
- }
315
- }, [allMessages, namespace, onError]);
316
- var translate = useMemo(function () {
317
- function getFallbackFromErrorAndNotify(key, code, message) {
318
- var error = new IntlError(code, message);
319
- onError(error);
320
- return getMessageFallback({
321
- error: error,
322
- key: key,
323
- namespace: namespace
324
- });
325
- }
326
-
327
- function translateBaseFn(
328
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
329
- key,
330
- /** Key value pairs for values to interpolate into the message. */
331
- values,
332
- /** Provide custom formats for numbers, dates and times. */
333
- formats) {
334
- var _cachedFormatsByLocal;
335
-
336
- var cachedFormatsByLocale = cachedFormatsByLocaleRef.current;
337
-
338
- if (messagesOrError instanceof IntlError) {
339
- // We have already warned about this during render
340
- return getMessageFallback({
341
- error: messagesOrError,
342
- key: key,
343
- namespace: namespace
344
- });
345
- }
346
-
347
- var messages = messagesOrError;
348
- var cacheKey = [namespace, key].filter(function (part) {
349
- return part != null;
350
- }).join('.');
351
- var messageFormat;
352
-
353
- if ((_cachedFormatsByLocal = cachedFormatsByLocale[locale]) != null && _cachedFormatsByLocal[cacheKey]) {
354
- messageFormat = cachedFormatsByLocale[locale][cacheKey];
355
- } else {
356
- var message;
357
-
358
- try {
359
- message = resolvePath(messages, key, namespace);
360
- } catch (error) {
361
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
362
- }
363
-
364
- if (typeof message === 'object') {
365
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.INSUFFICIENT_PATH, process.env.NODE_ENV !== "production" ? "Insufficient path specified for `" + key + "` in `" + (namespace ? "`" + namespace + "`" : 'messages') + "`." : undefined);
366
- }
367
-
368
- try {
369
- messageFormat = new IntlMessageFormat(message, locale, convertFormatsToIntlMessageFormat(_extends({}, globalFormats, formats), timeZone));
370
- } catch (error) {
371
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, error.message);
372
- }
373
-
374
- if (!cachedFormatsByLocale[locale]) {
375
- cachedFormatsByLocale[locale] = {};
376
- }
377
-
378
- cachedFormatsByLocale[locale][cacheKey] = messageFormat;
379
- }
380
-
381
- try {
382
- var formattedMessage = messageFormat.format( // @ts-ignore `intl-messageformat` expects a different format
383
- // for rich text elements since a recent minor update. This
384
- // needs to be evaluated in detail, possibly also in regards
385
- // to be able to format to parts.
386
- prepareTranslationValues(_extends({}, defaultTranslationValues, values)));
387
-
388
- if (formattedMessage == null) {
389
- throw new Error(process.env.NODE_ENV !== "production" ? "Unable to format `" + key + "` in " + (namespace ? "namespace `" + namespace + "`" : 'messages') : undefined);
390
- } // Limit the function signature to return strings or React elements
391
-
392
-
393
- return isValidElement(formattedMessage) || // Arrays of React elements
394
- Array.isArray(formattedMessage) || typeof formattedMessage === 'string' ? formattedMessage : String(formattedMessage);
395
- } catch (error) {
396
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.FORMATTING_ERROR, error.message);
397
- }
398
- }
399
-
400
- function translateFn(
401
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
402
- key,
403
- /** Key value pairs for values to interpolate into the message. */
404
- values,
405
- /** Provide custom formats for numbers, dates and times. */
406
- formats) {
407
- var message = translateBaseFn(key, values, formats);
408
-
409
- if (typeof message !== 'string') {
410
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, process.env.NODE_ENV !== "production" ? "The message `" + key + "` in " + (namespace ? "namespace `" + namespace + "`" : 'messages') + " didn't resolve to a string. If you want to format rich text, use `t.rich` instead." : undefined);
411
- }
412
-
413
- return message;
414
- }
415
-
416
- translateFn.rich = translateBaseFn;
417
-
418
- translateFn.raw = function (
419
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
420
- key) {
421
- if (messagesOrError instanceof IntlError) {
422
- // We have already warned about this during render
423
- return getMessageFallback({
424
- error: messagesOrError,
425
- key: key,
426
- namespace: namespace
427
- });
428
- }
429
-
430
- var messages = messagesOrError;
431
-
432
- try {
433
- return resolvePath(messages, key, namespace);
434
- } catch (error) {
435
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
436
- }
437
- };
438
-
439
- return translateFn;
440
- }, [onError, getMessageFallback, namespace, messagesOrError, locale, globalFormats, timeZone, defaultTranslationValues]);
441
- return translate;
442
- }
443
-
444
- /**
445
- * Translates messages from the given namespace by using the ICU syntax.
446
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
447
- *
448
- * If no namespace is provided, all available messages are returned.
449
- * The namespace can also indicate nesting by using a dot
450
- * (e.g. `namespace.Component`).
451
- */
452
-
453
- function useTranslations(namespace) {
454
- var context = useIntlContext();
455
- var messages = context.messages;
456
-
457
- if (!messages) {
458
- var intlError = new IntlError(IntlErrorCode.MISSING_MESSAGE, process.env.NODE_ENV !== "production" ? "No messages were configured on the provider." : undefined);
459
- context.onError(intlError);
460
- throw intlError;
461
- } // We have to wrap the actual hook so the type inference for the optional
462
- // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
463
- // The prefix ("!"") is arbitrary, but we have to use some.
464
-
465
-
466
- return useTranslationsImpl({
467
- '!': messages
468
- }, // @ts-ignore
469
- namespace ? "!." + namespace : '!', '!');
470
- }
471
-
472
- var MINUTE = 60;
473
- var HOUR = MINUTE * 60;
474
- var DAY = HOUR * 24;
475
- var WEEK = DAY * 7;
476
- var MONTH = DAY * (365 / 12); // Approximation
477
-
478
- var YEAR = DAY * 365;
479
-
480
- function getRelativeTimeFormatConfig(seconds) {
481
- var absValue = Math.abs(seconds);
482
- var value, unit; // We have to round the resulting values, as `Intl.RelativeTimeFormat`
483
- // will include fractions like '2.1 hours ago'.
484
-
485
- if (absValue < MINUTE) {
486
- unit = 'second';
487
- value = Math.round(seconds);
488
- } else if (absValue < HOUR) {
489
- unit = 'minute';
490
- value = Math.round(seconds / MINUTE);
491
- } else if (absValue < DAY) {
492
- unit = 'hour';
493
- value = Math.round(seconds / HOUR);
494
- } else if (absValue < WEEK) {
495
- unit = 'day';
496
- value = Math.round(seconds / DAY);
497
- } else if (absValue < MONTH) {
498
- unit = 'week';
499
- value = Math.round(seconds / WEEK);
500
- } else if (absValue < YEAR) {
501
- unit = 'month';
502
- value = Math.round(seconds / MONTH);
503
- } else {
504
- unit = 'year';
505
- value = Math.round(seconds / YEAR);
506
- }
507
-
508
- return {
509
- value: value,
510
- unit: unit
511
- };
512
- }
513
-
514
- function useIntl() {
515
- var _useIntlContext = useIntlContext(),
516
- formats = _useIntlContext.formats,
517
- locale = _useIntlContext.locale,
518
- globalNow = _useIntlContext.now,
519
- onError = _useIntlContext.onError,
520
- timeZone = _useIntlContext.timeZone;
521
-
522
- function resolveFormatOrOptions(typeFormats, formatOrOptions) {
523
- var options;
524
-
525
- if (typeof formatOrOptions === 'string') {
526
- var formatName = formatOrOptions;
527
- options = typeFormats == null ? void 0 : typeFormats[formatName];
528
-
529
- if (!options) {
530
- var error = new IntlError(IntlErrorCode.MISSING_FORMAT, process.env.NODE_ENV !== "production" ? "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." : undefined);
531
- onError(error);
532
- throw error;
533
- }
534
- } else {
535
- options = formatOrOptions;
536
- }
537
-
538
- return options;
539
- }
540
-
541
- function getFormattedValue(value, formatOrOptions, typeFormats, formatter) {
542
- var options;
543
-
544
- try {
545
- options = resolveFormatOrOptions(typeFormats, formatOrOptions);
546
- } catch (error) {
547
- return String(value);
548
- }
549
-
550
- try {
551
- return formatter(options);
552
- } catch (error) {
553
- onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
554
- return String(value);
555
- }
556
- }
557
-
558
- function formatDateTime(
559
- /** If a number is supplied, this is interpreted as a UTC timestamp. */
560
- value,
561
- /** If a time zone is supplied, the `value` is converted to that time zone.
562
- * Otherwise the user time zone will be used. */
563
- formatOrOptions) {
564
- return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.dateTime, function (options) {
565
- var _options;
566
-
567
- if (timeZone && !((_options = options) != null && _options.timeZone)) {
568
- options = _extends({}, options, {
569
- timeZone: timeZone
570
- });
571
- }
572
-
573
- return new Intl.DateTimeFormat(locale, options).format(value);
574
- });
575
- }
576
-
577
- function formatNumber(value, formatOrOptions) {
578
- return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) {
579
- return new Intl.NumberFormat(locale, options).format(value);
580
- });
581
- }
582
-
583
- function formatRelativeTime(
584
- /** The date time that needs to be formatted. */
585
- date,
586
- /** The reference point in time to which `date` will be formatted in relation to. */
587
- now) {
588
- try {
589
- if (!now) {
590
- if (globalNow) {
591
- now = globalNow;
592
- } else {
593
- throw new Error(process.env.NODE_ENV !== "production" ? "The `now` parameter wasn't provided to `formatRelativeTime` and there was no global fallback configured on the provider." : undefined);
594
- }
595
- }
596
-
597
- var dateDate = date instanceof Date ? date : new Date(date);
598
- var nowDate = now instanceof Date ? now : new Date(now);
599
- var seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;
600
-
601
- var _getRelativeTimeForma = getRelativeTimeFormatConfig(seconds),
602
- unit = _getRelativeTimeForma.unit,
603
- value = _getRelativeTimeForma.value;
604
-
605
- return new Intl.RelativeTimeFormat(locale, {
606
- numeric: 'auto'
607
- }).format(value, unit);
608
- } catch (error) {
609
- onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
610
- return String(date);
611
- }
612
- }
613
-
614
- return {
615
- formatDateTime: formatDateTime,
616
- formatNumber: formatNumber,
617
- formatRelativeTime: formatRelativeTime
618
- };
619
- }
620
-
621
- function useLocale() {
622
- return useIntlContext().locale;
623
- }
624
-
625
- function getNow() {
626
- return new Date();
627
- }
628
- /**
629
- * Reading the current date via `new Date()` in components should be avoided, as
630
- * it causes components to be impure and can lead to flaky tests. Instead, this
631
- * hook can be used.
632
- *
633
- * By default, it returns the time when the component mounts. If `updateInterval`
634
- * is specified, the value will be updated based on the interval.
635
- *
636
- * You can however also return a static value from this hook, if you
637
- * configure the `now` parameter on the context provider. Note however,
638
- * that if `updateInterval` is configured in this case, the component
639
- * will initialize with the global value, but will afterwards update
640
- * continuously based on the interval.
641
- *
642
- * For unit tests, this can be mocked to a constant value. For end-to-end
643
- * testing, an environment parameter can be passed to the `now` parameter
644
- * of the provider to mock this to a static value.
645
- */
646
-
647
-
648
- function useNow(options) {
649
- var updateInterval = options == null ? void 0 : options.updateInterval;
650
-
651
- var _useIntlContext = useIntlContext(),
652
- globalNow = _useIntlContext.now;
653
-
654
- var _useState = useState(globalNow || getNow()),
655
- now = _useState[0],
656
- setNow = _useState[1];
657
-
658
- useEffect(function () {
659
- if (!updateInterval) return;
660
- var intervalId = setInterval(function () {
661
- setNow(getNow());
662
- }, updateInterval);
663
- return function () {
664
- clearInterval(intervalId);
665
- };
666
- }, [globalNow, updateInterval]);
667
- return now;
668
- }
669
-
670
- function useTimeZone() {
671
- return useIntlContext().timeZone;
672
- }
673
-
674
- export { IntlError, IntlErrorCode, IntlProvider, useIntl, useLocale, useNow, useTimeZone, useTranslations };
1
+ export { default as IntlProvider } from './use-intl.esm3.js';
2
+ export { default as useTranslations } from './use-intl.esm4.js';
3
+ export { default as useIntl } from './use-intl.esm2.js';
4
+ export { default as useLocale } from './use-intl.esm7.js';
5
+ export { default as useNow } from './use-intl.esm5.js';
6
+ export { default as useTimeZone } from './use-intl.esm8.js';
7
+ export { default as IntlError, IntlErrorCode } from './use-intl.esm6.js';
675
8
  //# sourceMappingURL=use-intl.esm.js.map