react-intl 2.3.0 → 2.4.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/react-intl.js +960 -948
- package/dist/react-intl.js.map +1 -1
- package/dist/react-intl.min.js +1 -2
- package/dist/react-intl.min.js.map +1 -1
- package/lib/index.es.js +971 -970
- package/lib/index.js +971 -970
- package/locale-data/af.js +1 -1
- package/locale-data/agq.js +1 -1
- package/locale-data/ak.js +1 -1
- package/locale-data/am.js +1 -1
- package/locale-data/ar.js +1 -1
- package/locale-data/ars.js +1 -0
- package/locale-data/as.js +1 -1
- package/locale-data/asa.js +1 -1
- package/locale-data/ast.js +1 -1
- package/locale-data/az.js +1 -1
- package/locale-data/bas.js +1 -1
- package/locale-data/be.js +1 -1
- package/locale-data/bem.js +1 -1
- package/locale-data/bez.js +1 -1
- package/locale-data/bg.js +1 -1
- package/locale-data/bh.js +1 -1
- package/locale-data/bm.js +1 -1
- package/locale-data/bn.js +1 -1
- package/locale-data/bo.js +1 -1
- package/locale-data/br.js +1 -1
- package/locale-data/brx.js +1 -1
- package/locale-data/bs.js +1 -1
- package/locale-data/ca.js +1 -1
- package/locale-data/ce.js +1 -1
- package/locale-data/cgg.js +1 -1
- package/locale-data/chr.js +1 -1
- package/locale-data/ckb.js +1 -1
- package/locale-data/cs.js +1 -1
- package/locale-data/cu.js +1 -1
- package/locale-data/cy.js +1 -1
- package/locale-data/da.js +1 -1
- package/locale-data/dav.js +1 -1
- package/locale-data/de.js +1 -1
- package/locale-data/dje.js +1 -1
- package/locale-data/dsb.js +1 -1
- package/locale-data/dua.js +1 -1
- package/locale-data/dv.js +1 -1
- package/locale-data/dyo.js +1 -1
- package/locale-data/dz.js +1 -1
- package/locale-data/ebu.js +1 -1
- package/locale-data/ee.js +1 -1
- package/locale-data/el.js +1 -1
- package/locale-data/en.js +1 -1
- package/locale-data/eo.js +1 -1
- package/locale-data/es.js +1 -1
- package/locale-data/et.js +1 -1
- package/locale-data/eu.js +1 -1
- package/locale-data/ewo.js +1 -1
- package/locale-data/fa.js +1 -1
- package/locale-data/ff.js +1 -1
- package/locale-data/fi.js +1 -1
- package/locale-data/fil.js +1 -1
- package/locale-data/fo.js +1 -1
- package/locale-data/fr.js +1 -1
- package/locale-data/fur.js +1 -1
- package/locale-data/fy.js +1 -1
- package/locale-data/ga.js +1 -1
- package/locale-data/gd.js +1 -1
- package/locale-data/gl.js +1 -1
- package/locale-data/gsw.js +1 -1
- package/locale-data/gu.js +1 -1
- package/locale-data/guw.js +1 -1
- package/locale-data/guz.js +1 -1
- package/locale-data/gv.js +1 -1
- package/locale-data/ha.js +1 -1
- package/locale-data/haw.js +1 -1
- package/locale-data/he.js +1 -1
- package/locale-data/hi.js +1 -1
- package/locale-data/hr.js +1 -1
- package/locale-data/hsb.js +1 -1
- package/locale-data/hu.js +1 -1
- package/locale-data/hy.js +1 -1
- package/locale-data/id.js +1 -1
- package/locale-data/ig.js +1 -1
- package/locale-data/ii.js +1 -1
- package/locale-data/in.js +1 -1
- package/locale-data/index.js +1 -10
- package/locale-data/is.js +1 -1
- package/locale-data/it.js +1 -1
- package/locale-data/iu.js +1 -1
- package/locale-data/iw.js +1 -1
- package/locale-data/ja.js +1 -1
- package/locale-data/jbo.js +1 -1
- package/locale-data/jgo.js +1 -1
- package/locale-data/ji.js +1 -1
- package/locale-data/jmc.js +1 -1
- package/locale-data/jv.js +1 -1
- package/locale-data/jw.js +1 -1
- package/locale-data/ka.js +1 -1
- package/locale-data/kab.js +1 -1
- package/locale-data/kaj.js +1 -1
- package/locale-data/kam.js +1 -1
- package/locale-data/kcg.js +1 -1
- package/locale-data/kde.js +1 -1
- package/locale-data/kea.js +1 -1
- package/locale-data/khq.js +1 -1
- package/locale-data/ki.js +1 -1
- package/locale-data/kk.js +1 -1
- package/locale-data/kkj.js +1 -1
- package/locale-data/kl.js +1 -1
- package/locale-data/kln.js +1 -1
- package/locale-data/km.js +1 -1
- package/locale-data/kn.js +1 -1
- package/locale-data/ko.js +1 -1
- package/locale-data/kok.js +1 -1
- package/locale-data/ks.js +1 -1
- package/locale-data/ksb.js +1 -1
- package/locale-data/ksf.js +1 -1
- package/locale-data/ksh.js +1 -1
- package/locale-data/ku.js +1 -1
- package/locale-data/kw.js +1 -1
- package/locale-data/ky.js +1 -1
- package/locale-data/lag.js +1 -1
- package/locale-data/lb.js +1 -1
- package/locale-data/lg.js +1 -1
- package/locale-data/lkt.js +1 -1
- package/locale-data/ln.js +1 -1
- package/locale-data/lo.js +1 -1
- package/locale-data/lrc.js +1 -1
- package/locale-data/lt.js +1 -1
- package/locale-data/lu.js +1 -1
- package/locale-data/luo.js +1 -1
- package/locale-data/luy.js +1 -1
- package/locale-data/lv.js +1 -1
- package/locale-data/mas.js +1 -1
- package/locale-data/mer.js +1 -1
- package/locale-data/mfe.js +1 -1
- package/locale-data/mg.js +1 -1
- package/locale-data/mgh.js +1 -1
- package/locale-data/mgo.js +1 -1
- package/locale-data/mk.js +1 -1
- package/locale-data/ml.js +1 -1
- package/locale-data/mn.js +1 -1
- package/locale-data/mo.js +1 -1
- package/locale-data/mr.js +1 -1
- package/locale-data/ms.js +1 -1
- package/locale-data/mt.js +1 -1
- package/locale-data/mua.js +1 -1
- package/locale-data/my.js +1 -1
- package/locale-data/mzn.js +1 -1
- package/locale-data/nah.js +1 -1
- package/locale-data/naq.js +1 -1
- package/locale-data/nb.js +1 -1
- package/locale-data/nd.js +1 -1
- package/locale-data/nds.js +1 -0
- package/locale-data/ne.js +1 -1
- package/locale-data/nl.js +1 -1
- package/locale-data/nmg.js +1 -1
- package/locale-data/nn.js +1 -1
- package/locale-data/nnh.js +1 -1
- package/locale-data/no.js +1 -1
- package/locale-data/nqo.js +1 -1
- package/locale-data/nr.js +1 -1
- package/locale-data/nso.js +1 -1
- package/locale-data/nus.js +1 -1
- package/locale-data/ny.js +1 -1
- package/locale-data/nyn.js +1 -1
- package/locale-data/om.js +1 -1
- package/locale-data/or.js +1 -1
- package/locale-data/os.js +1 -1
- package/locale-data/pa.js +1 -1
- package/locale-data/pap.js +1 -1
- package/locale-data/pl.js +1 -1
- package/locale-data/prg.js +1 -1
- package/locale-data/ps.js +1 -1
- package/locale-data/pt.js +1 -1
- package/locale-data/qu.js +1 -1
- package/locale-data/rm.js +1 -1
- package/locale-data/rn.js +1 -1
- package/locale-data/ro.js +1 -1
- package/locale-data/rof.js +1 -1
- package/locale-data/ru.js +1 -1
- package/locale-data/rw.js +1 -1
- package/locale-data/rwk.js +1 -1
- package/locale-data/sah.js +1 -1
- package/locale-data/saq.js +1 -1
- package/locale-data/sbp.js +1 -1
- package/locale-data/sdh.js +1 -1
- package/locale-data/se.js +1 -1
- package/locale-data/seh.js +1 -1
- package/locale-data/ses.js +1 -1
- package/locale-data/sg.js +1 -1
- package/locale-data/sh.js +1 -1
- package/locale-data/shi.js +1 -1
- package/locale-data/si.js +1 -1
- package/locale-data/sk.js +1 -1
- package/locale-data/sl.js +1 -1
- package/locale-data/sma.js +1 -1
- package/locale-data/smi.js +1 -1
- package/locale-data/smj.js +1 -1
- package/locale-data/smn.js +1 -1
- package/locale-data/sms.js +1 -1
- package/locale-data/sn.js +1 -1
- package/locale-data/so.js +1 -1
- package/locale-data/sq.js +1 -1
- package/locale-data/sr.js +1 -1
- package/locale-data/ss.js +1 -1
- package/locale-data/ssy.js +1 -1
- package/locale-data/st.js +1 -1
- package/locale-data/sv.js +1 -1
- package/locale-data/sw.js +1 -1
- package/locale-data/syr.js +1 -1
- package/locale-data/ta.js +1 -1
- package/locale-data/te.js +1 -1
- package/locale-data/teo.js +1 -1
- package/locale-data/th.js +1 -1
- package/locale-data/ti.js +1 -1
- package/locale-data/tig.js +1 -1
- package/locale-data/tk.js +1 -1
- package/locale-data/tl.js +1 -1
- package/locale-data/tn.js +1 -1
- package/locale-data/to.js +1 -1
- package/locale-data/tr.js +1 -1
- package/locale-data/ts.js +1 -1
- package/locale-data/twq.js +1 -1
- package/locale-data/tzm.js +1 -1
- package/locale-data/ug.js +1 -1
- package/locale-data/uk.js +1 -1
- package/locale-data/ur.js +1 -1
- package/locale-data/uz.js +1 -1
- package/locale-data/vai.js +1 -1
- package/locale-data/ve.js +1 -1
- package/locale-data/vi.js +1 -1
- package/locale-data/vo.js +1 -1
- package/locale-data/vun.js +1 -1
- package/locale-data/wa.js +1 -1
- package/locale-data/wae.js +1 -1
- package/locale-data/wo.js +1 -1
- package/locale-data/xh.js +1 -1
- package/locale-data/xog.js +1 -1
- package/locale-data/yav.js +1 -1
- package/locale-data/yi.js +1 -1
- package/locale-data/yo.js +1 -1
- package/locale-data/yue.js +1 -0
- package/locale-data/zgh.js +1 -1
- package/locale-data/zh.js +1 -1
- package/locale-data/zu.js +1 -1
- package/package.json +11 -9
- package/src/components/date.js +47 -0
- package/src/components/html-message.js +88 -0
- package/src/components/message.js +137 -0
- package/src/components/number.js +47 -0
- package/src/components/plural.js +59 -0
- package/src/components/provider.js +177 -0
- package/src/components/relative.js +171 -0
- package/src/components/time.js +47 -0
- package/src/define-messages.js +11 -0
- package/src/en.js +2 -0
- package/src/format.js +276 -0
- package/src/index.js +12 -0
- package/src/inject.js +59 -0
- package/src/locale-data-registry.js +42 -0
- package/src/plural.js +28 -0
- package/src/react-intl.js +24 -0
- package/src/types.js +98 -0
- package/src/utils.js +103 -0
- package/yarn.lock +87 -59
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var defaultLocaleData = { "locale": "en", "pluralRuleFunction": function pluralR
|
|
|
26
26
|
t0 = Number(s[0]) == n,
|
|
27
27
|
n10 = t0 && s[0].slice(-1),
|
|
28
28
|
n100 = t0 && s[0].slice(-2);if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other";return n == 1 && v0 ? "one" : "other";
|
|
29
|
-
}, "fields": { "year": { "displayName": "year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "month": { "displayName": "month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "day": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "hour", "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "minute": { "displayName": "minute", "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "second": { "displayName": "second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } } } };
|
|
29
|
+
}, "fields": { "year": { "displayName": "year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "month": { "displayName": "month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "day": { "displayName": "day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "hour", "relative": { "0": "this hour" }, "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "minute": { "displayName": "minute", "relative": { "0": "this minute" }, "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "second": { "displayName": "second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } } } };
|
|
30
30
|
|
|
31
31
|
/*
|
|
32
32
|
* Copyright 2015, Yahoo Inc.
|
|
@@ -35,36 +35,36 @@ var defaultLocaleData = { "locale": "en", "pluralRuleFunction": function pluralR
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
function addLocaleData() {
|
|
38
|
-
|
|
38
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
var locales = Array.isArray(data) ? data : [data];
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
locales.forEach(function (localeData) {
|
|
43
|
+
if (localeData && localeData.locale) {
|
|
44
|
+
IntlMessageFormat.__addLocaleData(localeData);
|
|
45
|
+
IntlRelativeFormat.__addLocaleData(localeData);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function hasLocaleData(locale) {
|
|
51
|
-
|
|
51
|
+
var localeParts = (locale || '').split('-');
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
localeParts.pop();
|
|
53
|
+
while (localeParts.length > 0) {
|
|
54
|
+
if (hasIMFAndIRFLocaleData(localeParts.join('-'))) {
|
|
55
|
+
return true;
|
|
59
56
|
}
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
localeParts.pop();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return false;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function hasIMFAndIRFLocaleData(locale) {
|
|
65
|
-
|
|
65
|
+
var normalizedLocale = locale && locale.toLowerCase();
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
return !!(IntlMessageFormat.__localeData__[normalizedLocale] && IntlRelativeFormat.__localeData__[normalizedLocale]);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
@@ -228,6 +228,7 @@ var object = PropTypes.object;
|
|
|
228
228
|
var oneOf = PropTypes.oneOf;
|
|
229
229
|
var shape = PropTypes.shape;
|
|
230
230
|
var any = PropTypes.any;
|
|
231
|
+
var oneOfType = PropTypes.oneOfType;
|
|
231
232
|
|
|
232
233
|
var localeMatcher = oneOf(['best fit', 'lookup']);
|
|
233
234
|
var narrowShortLong = oneOf(['narrow', 'short', 'long']);
|
|
@@ -235,76 +236,76 @@ var numeric2digit = oneOf(['numeric', '2-digit']);
|
|
|
235
236
|
var funcReq = func.isRequired;
|
|
236
237
|
|
|
237
238
|
var intlConfigPropTypes = {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
locale: string,
|
|
240
|
+
formats: object,
|
|
241
|
+
messages: object,
|
|
242
|
+
textComponent: any,
|
|
242
243
|
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
defaultLocale: string,
|
|
245
|
+
defaultFormats: object
|
|
245
246
|
};
|
|
246
247
|
|
|
247
248
|
var intlFormatPropTypes = {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
formatDate: funcReq,
|
|
250
|
+
formatTime: funcReq,
|
|
251
|
+
formatRelative: funcReq,
|
|
252
|
+
formatNumber: funcReq,
|
|
253
|
+
formatPlural: funcReq,
|
|
254
|
+
formatMessage: funcReq,
|
|
255
|
+
formatHTMLMessage: funcReq
|
|
255
256
|
};
|
|
256
257
|
|
|
257
258
|
var intlShape = shape(_extends({}, intlConfigPropTypes, intlFormatPropTypes, {
|
|
258
|
-
|
|
259
|
-
|
|
259
|
+
formatters: object,
|
|
260
|
+
now: funcReq
|
|
260
261
|
}));
|
|
261
262
|
|
|
262
263
|
var messageDescriptorPropTypes = {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
id: string.isRequired,
|
|
265
|
+
description: oneOfType([string, object]),
|
|
266
|
+
defaultMessage: string
|
|
266
267
|
};
|
|
267
268
|
|
|
268
269
|
var dateTimeFormatPropTypes = {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
270
|
+
localeMatcher: localeMatcher,
|
|
271
|
+
formatMatcher: oneOf(['basic', 'best fit']),
|
|
272
|
+
|
|
273
|
+
timeZone: string,
|
|
274
|
+
hour12: bool,
|
|
275
|
+
|
|
276
|
+
weekday: narrowShortLong,
|
|
277
|
+
era: narrowShortLong,
|
|
278
|
+
year: numeric2digit,
|
|
279
|
+
month: oneOf(['numeric', '2-digit', 'narrow', 'short', 'long']),
|
|
280
|
+
day: numeric2digit,
|
|
281
|
+
hour: numeric2digit,
|
|
282
|
+
minute: numeric2digit,
|
|
283
|
+
second: numeric2digit,
|
|
284
|
+
timeZoneName: oneOf(['short', 'long'])
|
|
284
285
|
};
|
|
285
286
|
|
|
286
287
|
var numberFormatPropTypes = {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
288
|
+
localeMatcher: localeMatcher,
|
|
289
|
+
|
|
290
|
+
style: oneOf(['decimal', 'currency', 'percent']),
|
|
291
|
+
currency: string,
|
|
292
|
+
currencyDisplay: oneOf(['symbol', 'code', 'name']),
|
|
293
|
+
useGrouping: bool,
|
|
294
|
+
|
|
295
|
+
minimumIntegerDigits: number,
|
|
296
|
+
minimumFractionDigits: number,
|
|
297
|
+
maximumFractionDigits: number,
|
|
298
|
+
minimumSignificantDigits: number,
|
|
299
|
+
maximumSignificantDigits: number
|
|
299
300
|
};
|
|
300
301
|
|
|
301
302
|
var relativeFormatPropTypes = {
|
|
302
|
-
|
|
303
|
-
|
|
303
|
+
style: oneOf(['best fit', 'numeric']),
|
|
304
|
+
units: oneOf(['second', 'minute', 'hour', 'day', 'month', 'year'])
|
|
304
305
|
};
|
|
305
306
|
|
|
306
307
|
var pluralFormatPropTypes = {
|
|
307
|
-
|
|
308
|
+
style: oneOf(['cardinal', 'ordinal'])
|
|
308
309
|
};
|
|
309
310
|
|
|
310
311
|
/*
|
|
@@ -321,82 +322,82 @@ file in the root directory of React's source tree.
|
|
|
321
322
|
var intlConfigPropNames = Object.keys(intlConfigPropTypes);
|
|
322
323
|
|
|
323
324
|
var ESCAPED_CHARS = {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
325
|
+
'&': '&',
|
|
326
|
+
'>': '>',
|
|
327
|
+
'<': '<',
|
|
328
|
+
'"': '"',
|
|
329
|
+
"'": '''
|
|
329
330
|
};
|
|
330
331
|
|
|
331
332
|
var UNSAFE_CHARS_REGEX = /[&><"']/g;
|
|
332
333
|
|
|
333
334
|
function escape(str) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
return ('' + str).replace(UNSAFE_CHARS_REGEX, function (match) {
|
|
336
|
+
return ESCAPED_CHARS[match];
|
|
337
|
+
});
|
|
337
338
|
}
|
|
338
339
|
|
|
339
340
|
function filterProps(props, whitelist) {
|
|
340
|
-
|
|
341
|
+
var defaults$$1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
341
342
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
343
|
+
return whitelist.reduce(function (filtered, name) {
|
|
344
|
+
if (props.hasOwnProperty(name)) {
|
|
345
|
+
filtered[name] = props[name];
|
|
346
|
+
} else if (defaults$$1.hasOwnProperty(name)) {
|
|
347
|
+
filtered[name] = defaults$$1[name];
|
|
348
|
+
}
|
|
348
349
|
|
|
349
|
-
|
|
350
|
-
|
|
350
|
+
return filtered;
|
|
351
|
+
}, {});
|
|
351
352
|
}
|
|
352
353
|
|
|
353
354
|
function invariantIntlContext() {
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
356
|
+
intl = _ref.intl;
|
|
356
357
|
|
|
357
|
-
|
|
358
|
+
invariant(intl, '[React Intl] Could not find required `intl` object. ' + '<IntlProvider> needs to exist in the component ancestry.');
|
|
358
359
|
}
|
|
359
360
|
|
|
360
361
|
function shallowEquals(objA, objB) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
if (objA === objB) {
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
364
365
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
368
369
|
|
|
369
|
-
|
|
370
|
-
|
|
370
|
+
var keysA = Object.keys(objA);
|
|
371
|
+
var keysB = Object.keys(objB);
|
|
371
372
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
if (keysA.length !== keysB.length) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
375
376
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
377
|
+
// Test for A's keys different from B.
|
|
378
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
379
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
380
|
+
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
|
|
381
|
+
return false;
|
|
382
382
|
}
|
|
383
|
+
}
|
|
383
384
|
|
|
384
|
-
|
|
385
|
+
return true;
|
|
385
386
|
}
|
|
386
387
|
|
|
387
388
|
function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
389
|
+
var props = _ref2.props,
|
|
390
|
+
state = _ref2.state,
|
|
391
|
+
_ref2$context = _ref2.context,
|
|
392
|
+
context = _ref2$context === undefined ? {} : _ref2$context;
|
|
393
|
+
var nextContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
394
|
+
var _context$intl = context.intl,
|
|
395
|
+
intl = _context$intl === undefined ? {} : _context$intl;
|
|
396
|
+
var _nextContext$intl = nextContext.intl,
|
|
397
|
+
nextIntl = _nextContext$intl === undefined ? {} : _nextContext$intl;
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
return !shallowEquals(nextProps, props) || !shallowEquals(nextState, state) || !(nextIntl === intl || shallowEquals(filterProps(nextIntl, intlConfigPropNames), filterProps(intl, intlConfigPropNames)));
|
|
400
401
|
}
|
|
401
402
|
|
|
402
403
|
/*
|
|
@@ -409,54 +410,54 @@ function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
|
409
410
|
// https://github.com/rackt/react-redux
|
|
410
411
|
|
|
411
412
|
function getDisplayName(Component$$1) {
|
|
412
|
-
|
|
413
|
+
return Component$$1.displayName || Component$$1.name || 'Component';
|
|
413
414
|
}
|
|
414
415
|
|
|
415
416
|
function injectIntl(WrappedComponent) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
417
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
418
|
+
var _options$intlPropName = options.intlPropName,
|
|
419
|
+
intlPropName = _options$intlPropName === undefined ? 'intl' : _options$intlPropName,
|
|
420
|
+
_options$withRef = options.withRef,
|
|
421
|
+
withRef = _options$withRef === undefined ? false : _options$withRef;
|
|
421
422
|
|
|
422
|
-
|
|
423
|
-
|
|
423
|
+
var InjectIntl = function (_Component) {
|
|
424
|
+
inherits(InjectIntl, _Component);
|
|
424
425
|
|
|
425
|
-
|
|
426
|
-
|
|
426
|
+
function InjectIntl(props, context) {
|
|
427
|
+
classCallCheck(this, InjectIntl);
|
|
427
428
|
|
|
428
|
-
|
|
429
|
+
var _this = possibleConstructorReturn(this, (InjectIntl.__proto__ || Object.getPrototypeOf(InjectIntl)).call(this, props, context));
|
|
429
430
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
createClass(InjectIntl, [{
|
|
435
|
-
key: 'getWrappedInstance',
|
|
436
|
-
value: function getWrappedInstance() {
|
|
437
|
-
invariant(withRef, '[React Intl] To access the wrapped instance, ' + 'the `{withRef: true}` option must be set when calling: ' + '`injectIntl()`');
|
|
438
|
-
|
|
439
|
-
return this.refs.wrappedInstance;
|
|
440
|
-
}
|
|
441
|
-
}, {
|
|
442
|
-
key: 'render',
|
|
443
|
-
value: function render() {
|
|
444
|
-
return React__default.createElement(WrappedComponent, _extends({}, this.props, defineProperty({}, intlPropName, this.context.intl), {
|
|
445
|
-
ref: withRef ? 'wrappedInstance' : null
|
|
446
|
-
}));
|
|
447
|
-
}
|
|
448
|
-
}]);
|
|
449
|
-
return InjectIntl;
|
|
450
|
-
}(React.Component);
|
|
451
|
-
|
|
452
|
-
InjectIntl.displayName = 'InjectIntl(' + getDisplayName(WrappedComponent) + ')';
|
|
453
|
-
InjectIntl.contextTypes = {
|
|
454
|
-
intl: intlShape
|
|
455
|
-
};
|
|
456
|
-
InjectIntl.WrappedComponent = WrappedComponent;
|
|
431
|
+
invariantIntlContext(context);
|
|
432
|
+
return _this;
|
|
433
|
+
}
|
|
457
434
|
|
|
435
|
+
createClass(InjectIntl, [{
|
|
436
|
+
key: 'getWrappedInstance',
|
|
437
|
+
value: function getWrappedInstance() {
|
|
438
|
+
invariant(withRef, '[React Intl] To access the wrapped instance, ' + 'the `{withRef: true}` option must be set when calling: ' + '`injectIntl()`');
|
|
458
439
|
|
|
440
|
+
return this.refs.wrappedInstance;
|
|
441
|
+
}
|
|
442
|
+
}, {
|
|
443
|
+
key: 'render',
|
|
444
|
+
value: function render() {
|
|
445
|
+
return React__default.createElement(WrappedComponent, _extends({}, this.props, defineProperty({}, intlPropName, this.context.intl), {
|
|
446
|
+
ref: withRef ? 'wrappedInstance' : null
|
|
447
|
+
}));
|
|
448
|
+
}
|
|
449
|
+
}]);
|
|
459
450
|
return InjectIntl;
|
|
451
|
+
}(React.Component);
|
|
452
|
+
|
|
453
|
+
InjectIntl.displayName = 'InjectIntl(' + getDisplayName(WrappedComponent) + ')';
|
|
454
|
+
InjectIntl.contextTypes = {
|
|
455
|
+
intl: intlShape
|
|
456
|
+
};
|
|
457
|
+
InjectIntl.WrappedComponent = WrappedComponent;
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
return InjectIntl;
|
|
460
461
|
}
|
|
461
462
|
|
|
462
463
|
/*
|
|
@@ -480,25 +481,25 @@ function defineMessages(messageDescriptors) {
|
|
|
480
481
|
// This is a "hack" until a proper `intl-pluralformat` package is created.
|
|
481
482
|
|
|
482
483
|
function resolveLocale(locales) {
|
|
483
|
-
|
|
484
|
-
|
|
484
|
+
// IntlMessageFormat#_resolveLocale() does not depend on `this`.
|
|
485
|
+
return IntlMessageFormat.prototype._resolveLocale(locales);
|
|
485
486
|
}
|
|
486
487
|
|
|
487
488
|
function findPluralFunction(locale) {
|
|
488
|
-
|
|
489
|
-
|
|
489
|
+
// IntlMessageFormat#_findPluralFunction() does not depend on `this`.
|
|
490
|
+
return IntlMessageFormat.prototype._findPluralRuleFunction(locale);
|
|
490
491
|
}
|
|
491
492
|
|
|
492
493
|
var IntlPluralFormat = function IntlPluralFormat(locales) {
|
|
493
|
-
|
|
494
|
-
|
|
494
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
495
|
+
classCallCheck(this, IntlPluralFormat);
|
|
495
496
|
|
|
496
|
-
|
|
497
|
-
|
|
497
|
+
var useOrdinal = options.style === 'ordinal';
|
|
498
|
+
var pluralFn = findPluralFunction(resolveLocale(locales));
|
|
498
499
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
500
|
+
this.format = function (value) {
|
|
501
|
+
return pluralFn(value, useOrdinal);
|
|
502
|
+
};
|
|
502
503
|
};
|
|
503
504
|
|
|
504
505
|
/*
|
|
@@ -513,234 +514,234 @@ var RELATIVE_FORMAT_OPTIONS = Object.keys(relativeFormatPropTypes);
|
|
|
513
514
|
var PLURAL_FORMAT_OPTIONS = Object.keys(pluralFormatPropTypes);
|
|
514
515
|
|
|
515
516
|
var RELATIVE_FORMAT_THRESHOLDS = {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
517
|
+
second: 60, // seconds to minute
|
|
518
|
+
minute: 60, // minutes to hour
|
|
519
|
+
hour: 24, // hours to day
|
|
520
|
+
day: 30, // days to month
|
|
521
|
+
month: 12 // months to year
|
|
522
|
+
};
|
|
521
523
|
|
|
522
524
|
function updateRelativeFormatThresholds(newThresholds) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
525
|
+
var thresholds = IntlRelativeFormat.thresholds;
|
|
526
|
+
thresholds.second = newThresholds.second;
|
|
527
|
+
thresholds.minute = newThresholds.minute;
|
|
528
|
+
thresholds.hour = newThresholds.hour;
|
|
529
|
+
thresholds.day = newThresholds.day;
|
|
530
|
+
thresholds.month = newThresholds.month;
|
|
529
531
|
}
|
|
530
532
|
|
|
531
533
|
function getNamedFormat(formats, type, name) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
534
|
+
var format = formats && formats[type] && formats[type][name];
|
|
535
|
+
if (format) {
|
|
536
|
+
return format;
|
|
537
|
+
}
|
|
536
538
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
539
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
540
|
+
console.error('[React Intl] No ' + type + ' format named: ' + name);
|
|
541
|
+
}
|
|
540
542
|
}
|
|
541
543
|
|
|
542
544
|
function formatDate(config, state, value) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
545
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
546
|
+
var locale = config.locale,
|
|
547
|
+
formats = config.formats;
|
|
548
|
+
var format = options.format;
|
|
547
549
|
|
|
548
550
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
551
|
+
var date = new Date(value);
|
|
552
|
+
var defaults$$1 = format && getNamedFormat(formats, 'date', format);
|
|
553
|
+
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
552
554
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
555
|
+
try {
|
|
556
|
+
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
557
|
+
} catch (e) {
|
|
558
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
559
|
+
console.error('[React Intl] Error formatting date.\n' + e);
|
|
559
560
|
}
|
|
561
|
+
}
|
|
560
562
|
|
|
561
|
-
|
|
563
|
+
return String(date);
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
function formatTime(config, state, value) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
567
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
568
|
+
var locale = config.locale,
|
|
569
|
+
formats = config.formats;
|
|
570
|
+
var format = options.format;
|
|
569
571
|
|
|
570
572
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
573
|
+
var date = new Date(value);
|
|
574
|
+
var defaults$$1 = format && getNamedFormat(formats, 'time', format);
|
|
575
|
+
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
574
576
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
577
|
+
if (!filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second) {
|
|
578
|
+
// Add default formatting options if hour, minute, or second isn't defined.
|
|
579
|
+
filteredOptions = _extends({}, filteredOptions, { hour: 'numeric', minute: 'numeric' });
|
|
580
|
+
}
|
|
579
581
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
582
|
+
try {
|
|
583
|
+
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
584
|
+
} catch (e) {
|
|
585
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
586
|
+
console.error('[React Intl] Error formatting time.\n' + e);
|
|
586
587
|
}
|
|
588
|
+
}
|
|
587
589
|
|
|
588
|
-
|
|
590
|
+
return String(date);
|
|
589
591
|
}
|
|
590
592
|
|
|
591
593
|
function formatRelative(config, state, value) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
594
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
595
|
+
var locale = config.locale,
|
|
596
|
+
formats = config.formats;
|
|
597
|
+
var format = options.format;
|
|
596
598
|
|
|
597
599
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
600
|
+
var date = new Date(value);
|
|
601
|
+
var now = new Date(options.now);
|
|
602
|
+
var defaults$$1 = format && getNamedFormat(formats, 'relative', format);
|
|
603
|
+
var filteredOptions = filterProps(options, RELATIVE_FORMAT_OPTIONS, defaults$$1);
|
|
602
604
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
605
|
+
// Capture the current threshold values, then temporarily override them with
|
|
606
|
+
// specific values just for this render.
|
|
607
|
+
var oldThresholds = _extends({}, IntlRelativeFormat.thresholds);
|
|
608
|
+
updateRelativeFormatThresholds(RELATIVE_FORMAT_THRESHOLDS);
|
|
607
609
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
}
|
|
616
|
-
} finally {
|
|
617
|
-
updateRelativeFormatThresholds(oldThresholds);
|
|
610
|
+
try {
|
|
611
|
+
return state.getRelativeFormat(locale, filteredOptions).format(date, {
|
|
612
|
+
now: isFinite(now) ? now : state.now()
|
|
613
|
+
});
|
|
614
|
+
} catch (e) {
|
|
615
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
616
|
+
console.error('[React Intl] Error formatting relative time.\n' + e);
|
|
618
617
|
}
|
|
618
|
+
} finally {
|
|
619
|
+
updateRelativeFormatThresholds(oldThresholds);
|
|
620
|
+
}
|
|
619
621
|
|
|
620
|
-
|
|
622
|
+
return String(date);
|
|
621
623
|
}
|
|
622
624
|
|
|
623
625
|
function formatNumber(config, state, value) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
626
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
627
|
+
var locale = config.locale,
|
|
628
|
+
formats = config.formats;
|
|
629
|
+
var format = options.format;
|
|
628
630
|
|
|
629
631
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
+
var defaults$$1 = format && getNamedFormat(formats, 'number', format);
|
|
633
|
+
var filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults$$1);
|
|
632
634
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
635
|
+
try {
|
|
636
|
+
return state.getNumberFormat(locale, filteredOptions).format(value);
|
|
637
|
+
} catch (e) {
|
|
638
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
639
|
+
console.error('[React Intl] Error formatting number.\n' + e);
|
|
639
640
|
}
|
|
641
|
+
}
|
|
640
642
|
|
|
641
|
-
|
|
643
|
+
return String(value);
|
|
642
644
|
}
|
|
643
645
|
|
|
644
646
|
function formatPlural(config, state, value) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
648
|
+
var locale = config.locale;
|
|
647
649
|
|
|
648
650
|
|
|
649
|
-
|
|
651
|
+
var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
650
652
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
653
|
+
try {
|
|
654
|
+
return state.getPluralFormat(locale, filteredOptions).format(value);
|
|
655
|
+
} catch (e) {
|
|
656
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
657
|
+
console.error('[React Intl] Error formatting plural.\n' + e);
|
|
657
658
|
}
|
|
659
|
+
}
|
|
658
660
|
|
|
659
|
-
|
|
661
|
+
return 'other';
|
|
660
662
|
}
|
|
661
663
|
|
|
662
664
|
function formatMessage(config, state) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
var formattedMessage = void 0;
|
|
665
|
+
var messageDescriptor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
666
|
+
var values = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
667
|
+
var locale = config.locale,
|
|
668
|
+
formats = config.formats,
|
|
669
|
+
messages = config.messages,
|
|
670
|
+
defaultLocale = config.defaultLocale,
|
|
671
|
+
defaultFormats = config.defaultFormats;
|
|
672
|
+
var id = messageDescriptor.id,
|
|
673
|
+
defaultMessage = messageDescriptor.defaultMessage;
|
|
674
|
+
|
|
675
|
+
// `id` is a required field of a Message Descriptor.
|
|
676
|
+
|
|
677
|
+
invariant(id, '[React Intl] An `id` must be provided to format a message.');
|
|
678
|
+
|
|
679
|
+
var message = messages && messages[id];
|
|
680
|
+
var hasValues = Object.keys(values).length > 0;
|
|
681
|
+
|
|
682
|
+
// Avoid expensive message formatting for simple messages without values. In
|
|
683
|
+
// development messages will always be formatted in case of missing values.
|
|
684
|
+
if (!hasValues && process.env.NODE_ENV === 'production') {
|
|
685
|
+
return message || defaultMessage || id;
|
|
686
|
+
}
|
|
687
687
|
|
|
688
|
-
|
|
689
|
-
try {
|
|
690
|
-
var formatter = state.getMessageFormat(message, locale, formats);
|
|
688
|
+
var formattedMessage = void 0;
|
|
691
689
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
} else {
|
|
699
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
700
|
-
// This prevents warnings from littering the console in development
|
|
701
|
-
// when no `messages` are passed into the <IntlProvider> for the
|
|
702
|
-
// default locale, and a default message is in the source.
|
|
703
|
-
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
690
|
+
if (message) {
|
|
691
|
+
try {
|
|
692
|
+
var formatter = state.getMessageFormat(message, locale, formats);
|
|
704
693
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
694
|
+
formattedMessage = formatter.format(values);
|
|
695
|
+
} catch (e) {
|
|
696
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
697
|
+
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
698
|
+
}
|
|
708
699
|
}
|
|
700
|
+
} else {
|
|
701
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
702
|
+
// This prevents warnings from littering the console in development
|
|
703
|
+
// when no `messages` are passed into the <IntlProvider> for the
|
|
704
|
+
// default locale, and a default message is in the source.
|
|
705
|
+
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
706
|
+
console.error('[React Intl] Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''));
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
709
710
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
711
|
+
if (!formattedMessage && defaultMessage) {
|
|
712
|
+
try {
|
|
713
|
+
var _formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats);
|
|
713
714
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
715
|
+
formattedMessage = _formatter.format(values);
|
|
716
|
+
} catch (e) {
|
|
717
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
718
|
+
console.error('[React Intl] Error formatting the default message for: "' + id + '"' + ('\n' + e));
|
|
719
|
+
}
|
|
720
720
|
}
|
|
721
|
+
}
|
|
721
722
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
723
|
+
if (!formattedMessage) {
|
|
724
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
725
|
+
console.error('[React Intl] Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.'));
|
|
726
726
|
}
|
|
727
|
+
}
|
|
727
728
|
|
|
728
|
-
|
|
729
|
+
return formattedMessage || message || defaultMessage || id;
|
|
729
730
|
}
|
|
730
731
|
|
|
731
732
|
function formatHTMLMessage(config, state, messageDescriptor) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
733
|
+
var rawValues = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
734
|
+
|
|
735
|
+
// Process all the values before they are used when formatting the ICU
|
|
736
|
+
// Message string. Since the formatted message might be injected via
|
|
737
|
+
// `innerHTML`, all String-based values need to be HTML-escaped.
|
|
738
|
+
var escapedValues = Object.keys(rawValues).reduce(function (escaped, name) {
|
|
739
|
+
var value = rawValues[name];
|
|
740
|
+
escaped[name] = typeof value === 'string' ? escape(value) : value;
|
|
741
|
+
return escaped;
|
|
742
|
+
}, {});
|
|
743
|
+
|
|
744
|
+
return formatMessage(config, state, messageDescriptor, escapedValues);
|
|
744
745
|
}
|
|
745
746
|
|
|
746
747
|
|
|
@@ -767,170 +768,170 @@ var intlFormatPropNames = Object.keys(intlFormatPropTypes);
|
|
|
767
768
|
// These are not a static property on the `IntlProvider` class so the intl
|
|
768
769
|
// config values can be inherited from an <IntlProvider> ancestor.
|
|
769
770
|
var defaultProps = {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
771
|
+
formats: {},
|
|
772
|
+
messages: {},
|
|
773
|
+
textComponent: 'span',
|
|
773
774
|
|
|
774
|
-
|
|
775
|
-
|
|
775
|
+
defaultLocale: 'en',
|
|
776
|
+
defaultFormats: {}
|
|
776
777
|
};
|
|
777
778
|
|
|
778
779
|
var IntlProvider = function (_Component) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
function IntlProvider(props) {
|
|
782
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
783
|
-
classCallCheck(this, IntlProvider);
|
|
780
|
+
inherits(IntlProvider, _Component);
|
|
784
781
|
|
|
785
|
-
|
|
782
|
+
function IntlProvider(props) {
|
|
783
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
784
|
+
classCallCheck(this, IntlProvider);
|
|
786
785
|
|
|
787
|
-
|
|
786
|
+
var _this = possibleConstructorReturn(this, (IntlProvider.__proto__ || Object.getPrototypeOf(IntlProvider)).call(this, props, context));
|
|
788
787
|
|
|
789
|
-
|
|
788
|
+
invariant(typeof Intl !== 'undefined', '[React Intl] The `Intl` APIs must be available in the runtime, ' + 'and do not appear to be built-in. An `Intl` polyfill should be loaded.\n' + 'See: http://formatjs.io/guides/runtime-environments/');
|
|
790
789
|
|
|
791
|
-
|
|
792
|
-
// all relative times use the same reference "now" time.
|
|
790
|
+
var intlContext = context.intl;
|
|
793
791
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
initialNow = Number(props.initialNow);
|
|
797
|
-
} else {
|
|
798
|
-
// When an `initialNow` isn't provided via `props`, look to see an
|
|
799
|
-
// <IntlProvider> exists in the ancestry and call its `now()`
|
|
800
|
-
// function to propagate its value for "now".
|
|
801
|
-
initialNow = intlContext ? intlContext.now() : Date.now();
|
|
802
|
-
}
|
|
792
|
+
// Used to stabilize time when performing an initial rendering so that
|
|
793
|
+
// all relative times use the same reference "now" time.
|
|
803
794
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
getDateTimeFormat: memoizeIntlConstructor(Intl.DateTimeFormat),
|
|
813
|
-
getNumberFormat: memoizeIntlConstructor(Intl.NumberFormat),
|
|
814
|
-
getMessageFormat: memoizeIntlConstructor(IntlMessageFormat),
|
|
815
|
-
getRelativeFormat: memoizeIntlConstructor(IntlRelativeFormat),
|
|
816
|
-
getPluralFormat: memoizeIntlConstructor(IntlPluralFormat)
|
|
817
|
-
} : _ref$formatters;
|
|
818
|
-
|
|
819
|
-
_this.state = _extends({}, formatters, {
|
|
820
|
-
|
|
821
|
-
// Wrapper to provide stable "now" time for initial render.
|
|
822
|
-
now: function now() {
|
|
823
|
-
return _this._didDisplay ? Date.now() : initialNow;
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
return _this;
|
|
795
|
+
var initialNow = void 0;
|
|
796
|
+
if (isFinite(props.initialNow)) {
|
|
797
|
+
initialNow = Number(props.initialNow);
|
|
798
|
+
} else {
|
|
799
|
+
// When an `initialNow` isn't provided via `props`, look to see an
|
|
800
|
+
// <IntlProvider> exists in the ancestry and call its `now()`
|
|
801
|
+
// function to propagate its value for "now".
|
|
802
|
+
initialNow = intlContext ? intlContext.now() : Date.now();
|
|
827
803
|
}
|
|
828
804
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
856
|
-
console.error('[React Intl] Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'));
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
// Since there's no registered locale data for `locale`, this will
|
|
860
|
-
// fallback to the `defaultLocale` to make sure things can render.
|
|
861
|
-
// The `messages` are overridden to the `defaultProps` empty object
|
|
862
|
-
// to maintain referential equality across re-renders. It's assumed
|
|
863
|
-
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
864
|
-
config = _extends({}, config, {
|
|
865
|
-
locale: defaultLocale,
|
|
866
|
-
formats: defaultFormats,
|
|
867
|
-
messages: defaultProps.messages
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
return config;
|
|
872
|
-
}
|
|
873
|
-
}, {
|
|
874
|
-
key: 'getBoundFormatFns',
|
|
875
|
-
value: function getBoundFormatFns(config, state) {
|
|
876
|
-
return intlFormatPropNames.reduce(function (boundFormatFns, name) {
|
|
877
|
-
boundFormatFns[name] = format[name].bind(null, config, state);
|
|
878
|
-
return boundFormatFns;
|
|
879
|
-
}, {});
|
|
880
|
-
}
|
|
881
|
-
}, {
|
|
882
|
-
key: 'getChildContext',
|
|
883
|
-
value: function getChildContext() {
|
|
884
|
-
var config = this.getConfig();
|
|
805
|
+
// Creating `Intl*` formatters is expensive. If there's a parent
|
|
806
|
+
// `<IntlProvider>`, then its formatters will be used. Otherwise, this
|
|
807
|
+
// memoize the `Intl*` constructors and cache them for the lifecycle of
|
|
808
|
+
// this IntlProvider instance.
|
|
809
|
+
|
|
810
|
+
var _ref = intlContext || {},
|
|
811
|
+
_ref$formatters = _ref.formatters,
|
|
812
|
+
formatters = _ref$formatters === undefined ? {
|
|
813
|
+
getDateTimeFormat: memoizeIntlConstructor(Intl.DateTimeFormat),
|
|
814
|
+
getNumberFormat: memoizeIntlConstructor(Intl.NumberFormat),
|
|
815
|
+
getMessageFormat: memoizeIntlConstructor(IntlMessageFormat),
|
|
816
|
+
getRelativeFormat: memoizeIntlConstructor(IntlRelativeFormat),
|
|
817
|
+
getPluralFormat: memoizeIntlConstructor(IntlPluralFormat)
|
|
818
|
+
} : _ref$formatters;
|
|
819
|
+
|
|
820
|
+
_this.state = _extends({}, formatters, {
|
|
821
|
+
|
|
822
|
+
// Wrapper to provide stable "now" time for initial render.
|
|
823
|
+
now: function now() {
|
|
824
|
+
return _this._didDisplay ? Date.now() : initialNow;
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
return _this;
|
|
828
|
+
}
|
|
885
829
|
|
|
886
|
-
|
|
887
|
-
|
|
830
|
+
createClass(IntlProvider, [{
|
|
831
|
+
key: 'getConfig',
|
|
832
|
+
value: function getConfig() {
|
|
833
|
+
var intlContext = this.context.intl;
|
|
888
834
|
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
formatters = objectWithoutProperties(_state, ['now']);
|
|
835
|
+
// Build a whitelisted config object from `props`, defaults, and
|
|
836
|
+
// `context.intl`, if an <IntlProvider> exists in the ancestry.
|
|
892
837
|
|
|
838
|
+
var config = filterProps(this.props, intlConfigPropNames$1, intlContext);
|
|
893
839
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
840
|
+
// Apply default props. This must be applied last after the props have
|
|
841
|
+
// been resolved and inherited from any <IntlProvider> in the ancestry.
|
|
842
|
+
// This matches how React resolves `defaultProps`.
|
|
843
|
+
for (var propName in defaultProps) {
|
|
844
|
+
if (config[propName] === undefined) {
|
|
845
|
+
config[propName] = defaultProps[propName];
|
|
900
846
|
}
|
|
901
|
-
|
|
902
|
-
key: 'shouldComponentUpdate',
|
|
903
|
-
value: function shouldComponentUpdate() {
|
|
904
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
905
|
-
next[_key] = arguments[_key];
|
|
906
|
-
}
|
|
847
|
+
}
|
|
907
848
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
value: function render() {
|
|
918
|
-
return React.Children.only(this.props.children);
|
|
849
|
+
if (!hasLocaleData(config.locale)) {
|
|
850
|
+
var _config = config,
|
|
851
|
+
locale = _config.locale,
|
|
852
|
+
defaultLocale = _config.defaultLocale,
|
|
853
|
+
defaultFormats = _config.defaultFormats;
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
857
|
+
console.error('[React Intl] Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'));
|
|
919
858
|
}
|
|
920
|
-
|
|
921
|
-
|
|
859
|
+
|
|
860
|
+
// Since there's no registered locale data for `locale`, this will
|
|
861
|
+
// fallback to the `defaultLocale` to make sure things can render.
|
|
862
|
+
// The `messages` are overridden to the `defaultProps` empty object
|
|
863
|
+
// to maintain referential equality across re-renders. It's assumed
|
|
864
|
+
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
865
|
+
config = _extends({}, config, {
|
|
866
|
+
locale: defaultLocale,
|
|
867
|
+
formats: defaultFormats,
|
|
868
|
+
messages: defaultProps.messages
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
return config;
|
|
873
|
+
}
|
|
874
|
+
}, {
|
|
875
|
+
key: 'getBoundFormatFns',
|
|
876
|
+
value: function getBoundFormatFns(config, state) {
|
|
877
|
+
return intlFormatPropNames.reduce(function (boundFormatFns, name) {
|
|
878
|
+
boundFormatFns[name] = format[name].bind(null, config, state);
|
|
879
|
+
return boundFormatFns;
|
|
880
|
+
}, {});
|
|
881
|
+
}
|
|
882
|
+
}, {
|
|
883
|
+
key: 'getChildContext',
|
|
884
|
+
value: function getChildContext() {
|
|
885
|
+
var config = this.getConfig();
|
|
886
|
+
|
|
887
|
+
// Bind intl factories and current config to the format functions.
|
|
888
|
+
var boundFormatFns = this.getBoundFormatFns(config, this.state);
|
|
889
|
+
|
|
890
|
+
var _state = this.state,
|
|
891
|
+
now = _state.now,
|
|
892
|
+
formatters = objectWithoutProperties(_state, ['now']);
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
return {
|
|
896
|
+
intl: _extends({}, config, boundFormatFns, {
|
|
897
|
+
formatters: formatters,
|
|
898
|
+
now: now
|
|
899
|
+
})
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
}, {
|
|
903
|
+
key: 'shouldComponentUpdate',
|
|
904
|
+
value: function shouldComponentUpdate() {
|
|
905
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
906
|
+
next[_key] = arguments[_key];
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
910
|
+
}
|
|
911
|
+
}, {
|
|
912
|
+
key: 'componentDidMount',
|
|
913
|
+
value: function componentDidMount() {
|
|
914
|
+
this._didDisplay = true;
|
|
915
|
+
}
|
|
916
|
+
}, {
|
|
917
|
+
key: 'render',
|
|
918
|
+
value: function render() {
|
|
919
|
+
return React.Children.only(this.props.children);
|
|
920
|
+
}
|
|
921
|
+
}]);
|
|
922
|
+
return IntlProvider;
|
|
922
923
|
}(React.Component);
|
|
923
924
|
|
|
924
925
|
IntlProvider.displayName = 'IntlProvider';
|
|
925
926
|
IntlProvider.contextTypes = {
|
|
926
|
-
|
|
927
|
+
intl: intlShape
|
|
927
928
|
};
|
|
928
929
|
IntlProvider.childContextTypes = {
|
|
929
|
-
|
|
930
|
+
intl: intlShape.isRequired
|
|
930
931
|
};
|
|
931
932
|
process.env.NODE_ENV !== "production" ? IntlProvider.propTypes = _extends({}, intlConfigPropTypes, {
|
|
932
|
-
|
|
933
|
-
|
|
933
|
+
children: PropTypes.element.isRequired,
|
|
934
|
+
initialNow: PropTypes.any
|
|
934
935
|
}) : void 0;
|
|
935
936
|
|
|
936
937
|
/*
|
|
@@ -940,61 +941,61 @@ process.env.NODE_ENV !== "production" ? IntlProvider.propTypes = _extends({}, in
|
|
|
940
941
|
*/
|
|
941
942
|
|
|
942
943
|
var FormattedDate = function (_Component) {
|
|
943
|
-
|
|
944
|
+
inherits(FormattedDate, _Component);
|
|
945
|
+
|
|
946
|
+
function FormattedDate(props, context) {
|
|
947
|
+
classCallCheck(this, FormattedDate);
|
|
944
948
|
|
|
945
|
-
|
|
946
|
-
classCallCheck(this, FormattedDate);
|
|
949
|
+
var _this = possibleConstructorReturn(this, (FormattedDate.__proto__ || Object.getPrototypeOf(FormattedDate)).call(this, props, context));
|
|
947
950
|
|
|
948
|
-
|
|
951
|
+
invariantIntlContext(context);
|
|
952
|
+
return _this;
|
|
953
|
+
}
|
|
949
954
|
|
|
950
|
-
|
|
951
|
-
|
|
955
|
+
createClass(FormattedDate, [{
|
|
956
|
+
key: 'shouldComponentUpdate',
|
|
957
|
+
value: function shouldComponentUpdate() {
|
|
958
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
959
|
+
next[_key] = arguments[_key];
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
952
963
|
}
|
|
964
|
+
}, {
|
|
965
|
+
key: 'render',
|
|
966
|
+
value: function render() {
|
|
967
|
+
var _context$intl = this.context.intl,
|
|
968
|
+
formatDate = _context$intl.formatDate,
|
|
969
|
+
Text = _context$intl.textComponent;
|
|
970
|
+
var _props = this.props,
|
|
971
|
+
value = _props.value,
|
|
972
|
+
children = _props.children;
|
|
953
973
|
|
|
954
|
-
createClass(FormattedDate, [{
|
|
955
|
-
key: 'shouldComponentUpdate',
|
|
956
|
-
value: function shouldComponentUpdate() {
|
|
957
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
958
|
-
next[_key] = arguments[_key];
|
|
959
|
-
}
|
|
960
974
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
if (typeof children === 'function') {
|
|
977
|
-
return children(formattedDate);
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
return React__default.createElement(
|
|
981
|
-
Text,
|
|
982
|
-
null,
|
|
983
|
-
formattedDate
|
|
984
|
-
);
|
|
985
|
-
}
|
|
986
|
-
}]);
|
|
987
|
-
return FormattedDate;
|
|
975
|
+
var formattedDate = formatDate(value, this.props);
|
|
976
|
+
|
|
977
|
+
if (typeof children === 'function') {
|
|
978
|
+
return children(formattedDate);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
return React__default.createElement(
|
|
982
|
+
Text,
|
|
983
|
+
null,
|
|
984
|
+
formattedDate
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
}]);
|
|
988
|
+
return FormattedDate;
|
|
988
989
|
}(React.Component);
|
|
989
990
|
|
|
990
991
|
FormattedDate.displayName = 'FormattedDate';
|
|
991
992
|
FormattedDate.contextTypes = {
|
|
992
|
-
|
|
993
|
+
intl: intlShape
|
|
993
994
|
};
|
|
994
995
|
process.env.NODE_ENV !== "production" ? FormattedDate.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
996
|
+
value: PropTypes.any.isRequired,
|
|
997
|
+
format: PropTypes.string,
|
|
998
|
+
children: PropTypes.func
|
|
998
999
|
}) : void 0;
|
|
999
1000
|
|
|
1000
1001
|
/*
|
|
@@ -1004,61 +1005,61 @@ process.env.NODE_ENV !== "production" ? FormattedDate.propTypes = _extends({}, d
|
|
|
1004
1005
|
*/
|
|
1005
1006
|
|
|
1006
1007
|
var FormattedTime = function (_Component) {
|
|
1007
|
-
|
|
1008
|
+
inherits(FormattedTime, _Component);
|
|
1008
1009
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1010
|
+
function FormattedTime(props, context) {
|
|
1011
|
+
classCallCheck(this, FormattedTime);
|
|
1011
1012
|
|
|
1012
|
-
|
|
1013
|
+
var _this = possibleConstructorReturn(this, (FormattedTime.__proto__ || Object.getPrototypeOf(FormattedTime)).call(this, props, context));
|
|
1013
1014
|
|
|
1014
|
-
|
|
1015
|
-
|
|
1015
|
+
invariantIntlContext(context);
|
|
1016
|
+
return _this;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
createClass(FormattedTime, [{
|
|
1020
|
+
key: 'shouldComponentUpdate',
|
|
1021
|
+
value: function shouldComponentUpdate() {
|
|
1022
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1023
|
+
next[_key] = arguments[_key];
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1016
1027
|
}
|
|
1028
|
+
}, {
|
|
1029
|
+
key: 'render',
|
|
1030
|
+
value: function render() {
|
|
1031
|
+
var _context$intl = this.context.intl,
|
|
1032
|
+
formatTime = _context$intl.formatTime,
|
|
1033
|
+
Text = _context$intl.textComponent;
|
|
1034
|
+
var _props = this.props,
|
|
1035
|
+
value = _props.value,
|
|
1036
|
+
children = _props.children;
|
|
1017
1037
|
|
|
1018
|
-
createClass(FormattedTime, [{
|
|
1019
|
-
key: 'shouldComponentUpdate',
|
|
1020
|
-
value: function shouldComponentUpdate() {
|
|
1021
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1022
|
-
next[_key] = arguments[_key];
|
|
1023
|
-
}
|
|
1024
1038
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
if (typeof children === 'function') {
|
|
1041
|
-
return children(formattedTime);
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
return React__default.createElement(
|
|
1045
|
-
Text,
|
|
1046
|
-
null,
|
|
1047
|
-
formattedTime
|
|
1048
|
-
);
|
|
1049
|
-
}
|
|
1050
|
-
}]);
|
|
1051
|
-
return FormattedTime;
|
|
1039
|
+
var formattedTime = formatTime(value, this.props);
|
|
1040
|
+
|
|
1041
|
+
if (typeof children === 'function') {
|
|
1042
|
+
return children(formattedTime);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
return React__default.createElement(
|
|
1046
|
+
Text,
|
|
1047
|
+
null,
|
|
1048
|
+
formattedTime
|
|
1049
|
+
);
|
|
1050
|
+
}
|
|
1051
|
+
}]);
|
|
1052
|
+
return FormattedTime;
|
|
1052
1053
|
}(React.Component);
|
|
1053
1054
|
|
|
1054
1055
|
FormattedTime.displayName = 'FormattedTime';
|
|
1055
1056
|
FormattedTime.contextTypes = {
|
|
1056
|
-
|
|
1057
|
+
intl: intlShape
|
|
1057
1058
|
};
|
|
1058
1059
|
process.env.NODE_ENV !== "production" ? FormattedTime.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1060
|
+
value: PropTypes.any.isRequired,
|
|
1061
|
+
format: PropTypes.string,
|
|
1062
|
+
children: PropTypes.func
|
|
1062
1063
|
}) : void 0;
|
|
1063
1064
|
|
|
1064
1065
|
/*
|
|
@@ -1077,179 +1078,179 @@ var DAY = 1000 * 60 * 60 * 24;
|
|
|
1077
1078
|
var MAX_TIMER_DELAY = 2147483647;
|
|
1078
1079
|
|
|
1079
1080
|
function selectUnits(delta) {
|
|
1080
|
-
|
|
1081
|
+
var absDelta = Math.abs(delta);
|
|
1081
1082
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1083
|
+
if (absDelta < MINUTE) {
|
|
1084
|
+
return 'second';
|
|
1085
|
+
}
|
|
1085
1086
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1087
|
+
if (absDelta < HOUR) {
|
|
1088
|
+
return 'minute';
|
|
1089
|
+
}
|
|
1089
1090
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1091
|
+
if (absDelta < DAY) {
|
|
1092
|
+
return 'hour';
|
|
1093
|
+
}
|
|
1093
1094
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1095
|
+
// The maximum scheduled delay will be measured in days since the maximum
|
|
1096
|
+
// timer delay is less than the number of milliseconds in 25 days.
|
|
1097
|
+
return 'day';
|
|
1097
1098
|
}
|
|
1098
1099
|
|
|
1099
1100
|
function getUnitDelay(units) {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1101
|
+
switch (units) {
|
|
1102
|
+
case 'second':
|
|
1103
|
+
return SECOND;
|
|
1104
|
+
case 'minute':
|
|
1105
|
+
return MINUTE;
|
|
1106
|
+
case 'hour':
|
|
1107
|
+
return HOUR;
|
|
1108
|
+
case 'day':
|
|
1109
|
+
return DAY;
|
|
1110
|
+
default:
|
|
1111
|
+
return MAX_TIMER_DELAY;
|
|
1112
|
+
}
|
|
1112
1113
|
}
|
|
1113
1114
|
|
|
1114
1115
|
function isSameDate(a, b) {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1116
|
+
if (a === b) {
|
|
1117
|
+
return true;
|
|
1118
|
+
}
|
|
1118
1119
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1120
|
+
var aTime = new Date(a).getTime();
|
|
1121
|
+
var bTime = new Date(b).getTime();
|
|
1121
1122
|
|
|
1122
|
-
|
|
1123
|
+
return isFinite(aTime) && isFinite(bTime) && aTime === bTime;
|
|
1123
1124
|
}
|
|
1124
1125
|
|
|
1125
1126
|
var FormattedRelative = function (_Component) {
|
|
1126
|
-
|
|
1127
|
+
inherits(FormattedRelative, _Component);
|
|
1127
1128
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1129
|
+
function FormattedRelative(props, context) {
|
|
1130
|
+
classCallCheck(this, FormattedRelative);
|
|
1130
1131
|
|
|
1131
|
-
|
|
1132
|
+
var _this = possibleConstructorReturn(this, (FormattedRelative.__proto__ || Object.getPrototypeOf(FormattedRelative)).call(this, props, context));
|
|
1132
1133
|
|
|
1133
|
-
|
|
1134
|
+
invariantIntlContext(context);
|
|
1134
1135
|
|
|
1135
|
-
|
|
1136
|
+
var now = isFinite(props.initialNow) ? Number(props.initialNow) : context.intl.now();
|
|
1136
1137
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1138
|
+
// `now` is stored as state so that `render()` remains a function of
|
|
1139
|
+
// props + state, instead of accessing `Date.now()` inside `render()`.
|
|
1140
|
+
_this.state = { now: now };
|
|
1141
|
+
return _this;
|
|
1142
|
+
}
|
|
1142
1143
|
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1144
|
+
createClass(FormattedRelative, [{
|
|
1145
|
+
key: 'scheduleNextUpdate',
|
|
1146
|
+
value: function scheduleNextUpdate(props, state) {
|
|
1147
|
+
var _this2 = this;
|
|
1147
1148
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1149
|
+
// Cancel and pending update because we're scheduling a new update.
|
|
1150
|
+
clearTimeout(this._timer);
|
|
1150
1151
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1152
|
+
var value = props.value,
|
|
1153
|
+
units = props.units,
|
|
1154
|
+
updateInterval = props.updateInterval;
|
|
1154
1155
|
|
|
1155
|
-
|
|
1156
|
+
var time = new Date(value).getTime();
|
|
1156
1157
|
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1158
|
+
// If the `updateInterval` is falsy, including `0` or we don't have a
|
|
1159
|
+
// valid date, then auto updates have been turned off, so we bail and
|
|
1160
|
+
// skip scheduling an update.
|
|
1161
|
+
if (!updateInterval || !isFinite(time)) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1163
1164
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1165
|
+
var delta = time - state.now;
|
|
1166
|
+
var unitDelay = getUnitDelay(units || selectUnits(delta));
|
|
1167
|
+
var unitRemainder = Math.abs(delta % unitDelay);
|
|
1167
1168
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1169
|
+
// We want the largest possible timer delay which will still display
|
|
1170
|
+
// accurate information while reducing unnecessary re-renders. The delay
|
|
1171
|
+
// should be until the next "interesting" moment, like a tick from
|
|
1172
|
+
// "1 minute ago" to "2 minutes ago" when the delta is 120,000ms.
|
|
1173
|
+
var delay = delta < 0 ? Math.max(updateInterval, unitDelay - unitRemainder) : Math.max(updateInterval, unitRemainder);
|
|
1173
1174
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1175
|
+
this._timer = setTimeout(function () {
|
|
1176
|
+
_this2.setState({ now: _this2.context.intl.now() });
|
|
1177
|
+
}, delay);
|
|
1178
|
+
}
|
|
1179
|
+
}, {
|
|
1180
|
+
key: 'componentDidMount',
|
|
1181
|
+
value: function componentDidMount() {
|
|
1182
|
+
this.scheduleNextUpdate(this.props, this.state);
|
|
1183
|
+
}
|
|
1184
|
+
}, {
|
|
1185
|
+
key: 'componentWillReceiveProps',
|
|
1186
|
+
value: function componentWillReceiveProps(_ref) {
|
|
1187
|
+
var nextValue = _ref.value;
|
|
1188
|
+
|
|
1189
|
+
// When the `props.value` date changes, `state.now` needs to be updated,
|
|
1190
|
+
// and the next update can be rescheduled.
|
|
1191
|
+
if (!isSameDate(nextValue, this.props.value)) {
|
|
1192
|
+
this.setState({ now: this.context.intl.now() });
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}, {
|
|
1196
|
+
key: 'shouldComponentUpdate',
|
|
1197
|
+
value: function shouldComponentUpdate() {
|
|
1198
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1199
|
+
next[_key] = arguments[_key];
|
|
1200
|
+
}
|
|
1200
1201
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1202
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1203
|
+
}
|
|
1204
|
+
}, {
|
|
1205
|
+
key: 'componentWillUpdate',
|
|
1206
|
+
value: function componentWillUpdate(nextProps, nextState) {
|
|
1207
|
+
this.scheduleNextUpdate(nextProps, nextState);
|
|
1208
|
+
}
|
|
1209
|
+
}, {
|
|
1210
|
+
key: 'componentWillUnmount',
|
|
1211
|
+
value: function componentWillUnmount() {
|
|
1212
|
+
clearTimeout(this._timer);
|
|
1213
|
+
}
|
|
1214
|
+
}, {
|
|
1215
|
+
key: 'render',
|
|
1216
|
+
value: function render() {
|
|
1217
|
+
var _context$intl = this.context.intl,
|
|
1218
|
+
formatRelative = _context$intl.formatRelative,
|
|
1219
|
+
Text = _context$intl.textComponent;
|
|
1220
|
+
var _props = this.props,
|
|
1221
|
+
value = _props.value,
|
|
1222
|
+
children = _props.children;
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
var formattedRelative = formatRelative(value, _extends({}, this.props, this.state));
|
|
1226
|
+
|
|
1227
|
+
if (typeof children === 'function') {
|
|
1228
|
+
return children(formattedRelative);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
return React__default.createElement(
|
|
1232
|
+
Text,
|
|
1233
|
+
null,
|
|
1234
|
+
formattedRelative
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
}]);
|
|
1238
|
+
return FormattedRelative;
|
|
1238
1239
|
}(React.Component);
|
|
1239
1240
|
|
|
1240
1241
|
FormattedRelative.displayName = 'FormattedRelative';
|
|
1241
1242
|
FormattedRelative.contextTypes = {
|
|
1242
|
-
|
|
1243
|
+
intl: intlShape
|
|
1243
1244
|
};
|
|
1244
1245
|
FormattedRelative.defaultProps = {
|
|
1245
|
-
|
|
1246
|
+
updateInterval: 1000 * 10
|
|
1246
1247
|
};
|
|
1247
1248
|
process.env.NODE_ENV !== "production" ? FormattedRelative.propTypes = _extends({}, relativeFormatPropTypes, {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1249
|
+
value: PropTypes.any.isRequired,
|
|
1250
|
+
format: PropTypes.string,
|
|
1251
|
+
updateInterval: PropTypes.number,
|
|
1252
|
+
initialNow: PropTypes.any,
|
|
1253
|
+
children: PropTypes.func
|
|
1253
1254
|
}) : void 0;
|
|
1254
1255
|
|
|
1255
1256
|
/*
|
|
@@ -1259,61 +1260,61 @@ process.env.NODE_ENV !== "production" ? FormattedRelative.propTypes = _extends({
|
|
|
1259
1260
|
*/
|
|
1260
1261
|
|
|
1261
1262
|
var FormattedNumber = function (_Component) {
|
|
1262
|
-
|
|
1263
|
+
inherits(FormattedNumber, _Component);
|
|
1263
1264
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1265
|
+
function FormattedNumber(props, context) {
|
|
1266
|
+
classCallCheck(this, FormattedNumber);
|
|
1266
1267
|
|
|
1267
|
-
|
|
1268
|
+
var _this = possibleConstructorReturn(this, (FormattedNumber.__proto__ || Object.getPrototypeOf(FormattedNumber)).call(this, props, context));
|
|
1268
1269
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1270
|
+
invariantIntlContext(context);
|
|
1271
|
+
return _this;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
createClass(FormattedNumber, [{
|
|
1275
|
+
key: 'shouldComponentUpdate',
|
|
1276
|
+
value: function shouldComponentUpdate() {
|
|
1277
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1278
|
+
next[_key] = arguments[_key];
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1271
1282
|
}
|
|
1283
|
+
}, {
|
|
1284
|
+
key: 'render',
|
|
1285
|
+
value: function render() {
|
|
1286
|
+
var _context$intl = this.context.intl,
|
|
1287
|
+
formatNumber = _context$intl.formatNumber,
|
|
1288
|
+
Text = _context$intl.textComponent;
|
|
1289
|
+
var _props = this.props,
|
|
1290
|
+
value = _props.value,
|
|
1291
|
+
children = _props.children;
|
|
1272
1292
|
|
|
1273
|
-
createClass(FormattedNumber, [{
|
|
1274
|
-
key: 'shouldComponentUpdate',
|
|
1275
|
-
value: function shouldComponentUpdate() {
|
|
1276
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1277
|
-
next[_key] = arguments[_key];
|
|
1278
|
-
}
|
|
1279
1293
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
if (typeof children === 'function') {
|
|
1296
|
-
return children(formattedNumber);
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
return React__default.createElement(
|
|
1300
|
-
Text,
|
|
1301
|
-
null,
|
|
1302
|
-
formattedNumber
|
|
1303
|
-
);
|
|
1304
|
-
}
|
|
1305
|
-
}]);
|
|
1306
|
-
return FormattedNumber;
|
|
1294
|
+
var formattedNumber = formatNumber(value, this.props);
|
|
1295
|
+
|
|
1296
|
+
if (typeof children === 'function') {
|
|
1297
|
+
return children(formattedNumber);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
return React__default.createElement(
|
|
1301
|
+
Text,
|
|
1302
|
+
null,
|
|
1303
|
+
formattedNumber
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
}]);
|
|
1307
|
+
return FormattedNumber;
|
|
1307
1308
|
}(React.Component);
|
|
1308
1309
|
|
|
1309
1310
|
FormattedNumber.displayName = 'FormattedNumber';
|
|
1310
1311
|
FormattedNumber.contextTypes = {
|
|
1311
|
-
|
|
1312
|
+
intl: intlShape
|
|
1312
1313
|
};
|
|
1313
1314
|
process.env.NODE_ENV !== "production" ? FormattedNumber.propTypes = _extends({}, numberFormatPropTypes, {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1315
|
+
value: PropTypes.any.isRequired,
|
|
1316
|
+
format: PropTypes.string,
|
|
1317
|
+
children: PropTypes.func
|
|
1317
1318
|
}) : void 0;
|
|
1318
1319
|
|
|
1319
1320
|
/*
|
|
@@ -1323,73 +1324,73 @@ process.env.NODE_ENV !== "production" ? FormattedNumber.propTypes = _extends({},
|
|
|
1323
1324
|
*/
|
|
1324
1325
|
|
|
1325
1326
|
var FormattedPlural = function (_Component) {
|
|
1326
|
-
|
|
1327
|
+
inherits(FormattedPlural, _Component);
|
|
1327
1328
|
|
|
1328
|
-
|
|
1329
|
-
|
|
1329
|
+
function FormattedPlural(props, context) {
|
|
1330
|
+
classCallCheck(this, FormattedPlural);
|
|
1330
1331
|
|
|
1331
|
-
|
|
1332
|
+
var _this = possibleConstructorReturn(this, (FormattedPlural.__proto__ || Object.getPrototypeOf(FormattedPlural)).call(this, props, context));
|
|
1332
1333
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1334
|
+
invariantIntlContext(context);
|
|
1335
|
+
return _this;
|
|
1336
|
+
}
|
|
1336
1337
|
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1338
|
+
createClass(FormattedPlural, [{
|
|
1339
|
+
key: 'shouldComponentUpdate',
|
|
1340
|
+
value: function shouldComponentUpdate() {
|
|
1341
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1342
|
+
next[_key] = arguments[_key];
|
|
1343
|
+
}
|
|
1343
1344
|
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1345
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1346
|
+
}
|
|
1347
|
+
}, {
|
|
1348
|
+
key: 'render',
|
|
1349
|
+
value: function render() {
|
|
1350
|
+
var _context$intl = this.context.intl,
|
|
1351
|
+
formatPlural = _context$intl.formatPlural,
|
|
1352
|
+
Text = _context$intl.textComponent;
|
|
1353
|
+
var _props = this.props,
|
|
1354
|
+
value = _props.value,
|
|
1355
|
+
other = _props.other,
|
|
1356
|
+
children = _props.children;
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
var pluralCategory = formatPlural(value, this.props);
|
|
1360
|
+
var formattedPlural = this.props[pluralCategory] || other;
|
|
1361
|
+
|
|
1362
|
+
if (typeof children === 'function') {
|
|
1363
|
+
return children(formattedPlural);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
return React__default.createElement(
|
|
1367
|
+
Text,
|
|
1368
|
+
null,
|
|
1369
|
+
formattedPlural
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
}]);
|
|
1373
|
+
return FormattedPlural;
|
|
1373
1374
|
}(React.Component);
|
|
1374
1375
|
|
|
1375
1376
|
FormattedPlural.displayName = 'FormattedPlural';
|
|
1376
1377
|
FormattedPlural.contextTypes = {
|
|
1377
|
-
|
|
1378
|
+
intl: intlShape
|
|
1378
1379
|
};
|
|
1379
1380
|
FormattedPlural.defaultProps = {
|
|
1380
|
-
|
|
1381
|
+
style: 'cardinal'
|
|
1381
1382
|
};
|
|
1382
1383
|
process.env.NODE_ENV !== "production" ? FormattedPlural.propTypes = _extends({}, pluralFormatPropTypes, {
|
|
1383
|
-
|
|
1384
|
+
value: PropTypes.any.isRequired,
|
|
1384
1385
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1386
|
+
other: PropTypes.node.isRequired,
|
|
1387
|
+
zero: PropTypes.node,
|
|
1388
|
+
one: PropTypes.node,
|
|
1389
|
+
two: PropTypes.node,
|
|
1390
|
+
few: PropTypes.node,
|
|
1391
|
+
many: PropTypes.node,
|
|
1391
1392
|
|
|
1392
|
-
|
|
1393
|
+
children: PropTypes.func
|
|
1393
1394
|
}) : void 0;
|
|
1394
1395
|
|
|
1395
1396
|
/*
|
|
@@ -1399,142 +1400,142 @@ process.env.NODE_ENV !== "production" ? FormattedPlural.propTypes = _extends({},
|
|
|
1399
1400
|
*/
|
|
1400
1401
|
|
|
1401
1402
|
var FormattedMessage = function (_Component) {
|
|
1402
|
-
|
|
1403
|
+
inherits(FormattedMessage, _Component);
|
|
1403
1404
|
|
|
1404
|
-
|
|
1405
|
-
|
|
1405
|
+
function FormattedMessage(props, context) {
|
|
1406
|
+
classCallCheck(this, FormattedMessage);
|
|
1406
1407
|
|
|
1407
|
-
|
|
1408
|
+
var _this = possibleConstructorReturn(this, (FormattedMessage.__proto__ || Object.getPrototypeOf(FormattedMessage)).call(this, props, context));
|
|
1408
1409
|
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1410
|
+
invariantIntlContext(context);
|
|
1411
|
+
return _this;
|
|
1412
|
+
}
|
|
1412
1413
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1414
|
+
createClass(FormattedMessage, [{
|
|
1415
|
+
key: 'shouldComponentUpdate',
|
|
1416
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
1417
|
+
var values = this.props.values;
|
|
1418
|
+
var nextValues = nextProps.values;
|
|
1418
1419
|
|
|
1419
1420
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1421
|
+
if (!shallowEquals(nextValues, values)) {
|
|
1422
|
+
return true;
|
|
1423
|
+
}
|
|
1423
1424
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1425
|
+
// Since `values` has already been checked, we know they're not
|
|
1426
|
+
// different, so the current `values` are carried over so the shallow
|
|
1427
|
+
// equals comparison on the other props isn't affected by the `values`.
|
|
1428
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
1429
|
+
values: values
|
|
1430
|
+
});
|
|
1430
1431
|
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1432
|
+
for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1433
|
+
next[_key - 1] = arguments[_key];
|
|
1434
|
+
}
|
|
1434
1435
|
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1436
|
+
return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
|
|
1437
|
+
}
|
|
1438
|
+
}, {
|
|
1439
|
+
key: 'render',
|
|
1440
|
+
value: function render() {
|
|
1441
|
+
var _context$intl = this.context.intl,
|
|
1442
|
+
formatMessage = _context$intl.formatMessage,
|
|
1443
|
+
Text = _context$intl.textComponent;
|
|
1444
|
+
var _props = this.props,
|
|
1445
|
+
id = _props.id,
|
|
1446
|
+
description = _props.description,
|
|
1447
|
+
defaultMessage = _props.defaultMessage,
|
|
1448
|
+
values = _props.values,
|
|
1449
|
+
_props$tagName = _props.tagName,
|
|
1450
|
+
Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
|
|
1451
|
+
children = _props.children;
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
var tokenDelimiter = void 0;
|
|
1455
|
+
var tokenizedValues = void 0;
|
|
1456
|
+
var elements = void 0;
|
|
1457
|
+
|
|
1458
|
+
var hasValues = values && Object.keys(values).length > 0;
|
|
1459
|
+
if (hasValues) {
|
|
1460
|
+
// Creates a token with a random UID that should not be guessable or
|
|
1461
|
+
// conflict with other parts of the `message` string.
|
|
1462
|
+
var uid = Math.floor(Math.random() * 0x10000000000).toString(16);
|
|
1463
|
+
|
|
1464
|
+
var generateToken = function () {
|
|
1465
|
+
var counter = 0;
|
|
1466
|
+
return function () {
|
|
1467
|
+
return 'ELEMENT-' + uid + '-' + (counter += 1);
|
|
1468
|
+
};
|
|
1469
|
+
}();
|
|
1470
|
+
|
|
1471
|
+
// Splitting with a delimiter to support IE8. When using a regex
|
|
1472
|
+
// with a capture group IE8 does not include the capture group in
|
|
1473
|
+
// the resulting array.
|
|
1474
|
+
tokenDelimiter = '@__' + uid + '__@';
|
|
1475
|
+
tokenizedValues = {};
|
|
1476
|
+
elements = {};
|
|
1477
|
+
|
|
1478
|
+
// Iterates over the `props` to keep track of any React Element
|
|
1479
|
+
// values so they can be represented by the `token` as a placeholder
|
|
1480
|
+
// when the `message` is formatted. This allows the formatted
|
|
1481
|
+
// message to then be broken-up into parts with references to the
|
|
1482
|
+
// React Elements inserted back in.
|
|
1483
|
+
Object.keys(values).forEach(function (name) {
|
|
1484
|
+
var value = values[name];
|
|
1485
|
+
|
|
1486
|
+
if (React.isValidElement(value)) {
|
|
1487
|
+
var token = generateToken();
|
|
1488
|
+
tokenizedValues[name] = tokenDelimiter + token + tokenDelimiter;
|
|
1489
|
+
elements[token] = value;
|
|
1490
|
+
} else {
|
|
1491
|
+
tokenizedValues[name] = value;
|
|
1492
|
+
}
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
1497
|
+
var formattedMessage = formatMessage(descriptor, tokenizedValues || values);
|
|
1498
|
+
|
|
1499
|
+
var nodes = void 0;
|
|
1500
|
+
|
|
1501
|
+
var hasElements = elements && Object.keys(elements).length > 0;
|
|
1502
|
+
if (hasElements) {
|
|
1503
|
+
// Split the message into parts so the React Element values captured
|
|
1504
|
+
// above can be inserted back into the rendered message. This
|
|
1505
|
+
// approach allows messages to render with React Elements while
|
|
1506
|
+
// keeping React's virtual diffing working properly.
|
|
1507
|
+
nodes = formattedMessage.split(tokenDelimiter).filter(function (part) {
|
|
1508
|
+
return !!part;
|
|
1509
|
+
}).map(function (part) {
|
|
1510
|
+
return elements[part] || part;
|
|
1511
|
+
});
|
|
1512
|
+
} else {
|
|
1513
|
+
nodes = [formattedMessage];
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
if (typeof children === 'function') {
|
|
1517
|
+
return children.apply(undefined, toConsumableArray(nodes));
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
// Needs to use `createElement()` instead of JSX, otherwise React will
|
|
1521
|
+
// warn about a missing `key` prop with rich-text message formatting.
|
|
1522
|
+
return React.createElement.apply(undefined, [Component$$1, null].concat(toConsumableArray(nodes)));
|
|
1523
|
+
}
|
|
1524
|
+
}]);
|
|
1525
|
+
return FormattedMessage;
|
|
1525
1526
|
}(React.Component);
|
|
1526
1527
|
|
|
1527
1528
|
FormattedMessage.displayName = 'FormattedMessage';
|
|
1528
1529
|
FormattedMessage.contextTypes = {
|
|
1529
|
-
|
|
1530
|
+
intl: intlShape
|
|
1530
1531
|
};
|
|
1531
1532
|
FormattedMessage.defaultProps = {
|
|
1532
|
-
|
|
1533
|
+
values: {}
|
|
1533
1534
|
};
|
|
1534
1535
|
process.env.NODE_ENV !== "production" ? FormattedMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1536
|
+
values: PropTypes.object,
|
|
1537
|
+
tagName: PropTypes.string,
|
|
1538
|
+
children: PropTypes.func
|
|
1538
1539
|
}) : void 0;
|
|
1539
1540
|
|
|
1540
1541
|
/*
|
|
@@ -1544,90 +1545,90 @@ process.env.NODE_ENV !== "production" ? FormattedMessage.propTypes = _extends({}
|
|
|
1544
1545
|
*/
|
|
1545
1546
|
|
|
1546
1547
|
var FormattedHTMLMessage = function (_Component) {
|
|
1547
|
-
|
|
1548
|
+
inherits(FormattedHTMLMessage, _Component);
|
|
1548
1549
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1550
|
+
function FormattedHTMLMessage(props, context) {
|
|
1551
|
+
classCallCheck(this, FormattedHTMLMessage);
|
|
1551
1552
|
|
|
1552
|
-
|
|
1553
|
+
var _this = possibleConstructorReturn(this, (FormattedHTMLMessage.__proto__ || Object.getPrototypeOf(FormattedHTMLMessage)).call(this, props, context));
|
|
1553
1554
|
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1555
|
+
invariantIntlContext(context);
|
|
1556
|
+
return _this;
|
|
1557
|
+
}
|
|
1557
1558
|
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1559
|
+
createClass(FormattedHTMLMessage, [{
|
|
1560
|
+
key: 'shouldComponentUpdate',
|
|
1561
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
1562
|
+
var values = this.props.values;
|
|
1563
|
+
var nextValues = nextProps.values;
|
|
1563
1564
|
|
|
1564
1565
|
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1566
|
+
if (!shallowEquals(nextValues, values)) {
|
|
1567
|
+
return true;
|
|
1568
|
+
}
|
|
1568
1569
|
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1570
|
+
// Since `values` has already been checked, we know they're not
|
|
1571
|
+
// different, so the current `values` are carried over so the shallow
|
|
1572
|
+
// equals comparison on the other props isn't affected by the `values`.
|
|
1573
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
1574
|
+
values: values
|
|
1575
|
+
});
|
|
1575
1576
|
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1577
|
+
for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1578
|
+
next[_key - 1] = arguments[_key];
|
|
1579
|
+
}
|
|
1579
1580
|
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1581
|
+
return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
|
|
1582
|
+
}
|
|
1583
|
+
}, {
|
|
1584
|
+
key: 'render',
|
|
1585
|
+
value: function render() {
|
|
1586
|
+
var _context$intl = this.context.intl,
|
|
1587
|
+
formatHTMLMessage = _context$intl.formatHTMLMessage,
|
|
1588
|
+
Text = _context$intl.textComponent;
|
|
1589
|
+
var _props = this.props,
|
|
1590
|
+
id = _props.id,
|
|
1591
|
+
description = _props.description,
|
|
1592
|
+
defaultMessage = _props.defaultMessage,
|
|
1593
|
+
rawValues = _props.values,
|
|
1594
|
+
_props$tagName = _props.tagName,
|
|
1595
|
+
Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
|
|
1596
|
+
children = _props.children;
|
|
1597
|
+
|
|
1598
|
+
|
|
1599
|
+
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
1600
|
+
var formattedHTMLMessage = formatHTMLMessage(descriptor, rawValues);
|
|
1601
|
+
|
|
1602
|
+
if (typeof children === 'function') {
|
|
1603
|
+
return children(formattedHTMLMessage);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
// Since the message presumably has HTML in it, we need to set
|
|
1607
|
+
// `innerHTML` in order for it to be rendered and not escaped by React.
|
|
1608
|
+
// To be safe, all string prop values were escaped when formatting the
|
|
1609
|
+
// message. It is assumed that the message is not UGC, and came from the
|
|
1610
|
+
// developer making it more like a template.
|
|
1611
|
+
//
|
|
1612
|
+
// Note: There's a perf impact of using this component since there's no
|
|
1613
|
+
// way for React to do its virtual DOM diffing.
|
|
1614
|
+
var html = { __html: formattedHTMLMessage };
|
|
1615
|
+
return React__default.createElement(Component$$1, { dangerouslySetInnerHTML: html });
|
|
1616
|
+
}
|
|
1617
|
+
}]);
|
|
1618
|
+
return FormattedHTMLMessage;
|
|
1618
1619
|
}(React.Component);
|
|
1619
1620
|
|
|
1620
1621
|
FormattedHTMLMessage.displayName = 'FormattedHTMLMessage';
|
|
1621
1622
|
FormattedHTMLMessage.contextTypes = {
|
|
1622
|
-
|
|
1623
|
+
intl: intlShape
|
|
1623
1624
|
};
|
|
1624
1625
|
FormattedHTMLMessage.defaultProps = {
|
|
1625
|
-
|
|
1626
|
+
values: {}
|
|
1626
1627
|
};
|
|
1627
1628
|
process.env.NODE_ENV !== "production" ? FormattedHTMLMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1629
|
+
values: PropTypes.object,
|
|
1630
|
+
tagName: PropTypes.string,
|
|
1631
|
+
children: PropTypes.func
|
|
1631
1632
|
}) : void 0;
|
|
1632
1633
|
|
|
1633
1634
|
/*
|