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/dist/react-intl.js
CHANGED
|
@@ -25,7 +25,7 @@ var defaultLocaleData = { "locale": "en", "pluralRuleFunction": function pluralR
|
|
|
25
25
|
t0 = Number(s[0]) == n,
|
|
26
26
|
n10 = t0 && s[0].slice(-1),
|
|
27
27
|
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";
|
|
28
|
-
}, "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" } } } } };
|
|
28
|
+
}, "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" } } } } };
|
|
29
29
|
|
|
30
30
|
/*
|
|
31
31
|
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
|
|
@@ -254,7 +254,7 @@ function StringFormat(id) {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
StringFormat.prototype.format = function (value) {
|
|
257
|
-
if (!value) {
|
|
257
|
+
if (!value && typeof value !== 'number') {
|
|
258
258
|
return '';
|
|
259
259
|
}
|
|
260
260
|
|
|
@@ -1734,7 +1734,15 @@ function MessageFormat(message, locales, formats) {
|
|
|
1734
1734
|
// the other `Intl` APIs.
|
|
1735
1735
|
var messageFormat = this;
|
|
1736
1736
|
this.format = function (values) {
|
|
1737
|
-
|
|
1737
|
+
try {
|
|
1738
|
+
return messageFormat._format(pattern, values);
|
|
1739
|
+
} catch (e) {
|
|
1740
|
+
if (e.variableId) {
|
|
1741
|
+
throw new Error('The intl string context variable \'' + e.variableId + '\'' + ' was not provided to the string \'' + message + '\'');
|
|
1742
|
+
} else {
|
|
1743
|
+
throw e;
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1738
1746
|
};
|
|
1739
1747
|
}
|
|
1740
1748
|
|
|
@@ -1867,7 +1875,8 @@ MessageFormat.prototype._format = function (pattern, values) {
|
|
|
1867
1875
|
len,
|
|
1868
1876
|
part,
|
|
1869
1877
|
id,
|
|
1870
|
-
value
|
|
1878
|
+
value,
|
|
1879
|
+
err;
|
|
1871
1880
|
|
|
1872
1881
|
for (i = 0, len = pattern.length; i < len; i += 1) {
|
|
1873
1882
|
part = pattern[i];
|
|
@@ -1882,7 +1891,9 @@ MessageFormat.prototype._format = function (pattern, values) {
|
|
|
1882
1891
|
|
|
1883
1892
|
// Enforce that all required values are provided by the caller.
|
|
1884
1893
|
if (!(values && hop.call(values, id))) {
|
|
1885
|
-
|
|
1894
|
+
err = new Error('A value must be provided for: ' + id);
|
|
1895
|
+
err.variableId = id;
|
|
1896
|
+
throw err;
|
|
1886
1897
|
}
|
|
1887
1898
|
|
|
1888
1899
|
value = values[id];
|
|
@@ -2369,36 +2380,36 @@ RelativeFormat.defaultLocale = 'en';
|
|
|
2369
2380
|
*/
|
|
2370
2381
|
|
|
2371
2382
|
function addLocaleData() {
|
|
2372
|
-
|
|
2383
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2373
2384
|
|
|
2374
|
-
|
|
2385
|
+
var locales = Array.isArray(data) ? data : [data];
|
|
2375
2386
|
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2387
|
+
locales.forEach(function (localeData) {
|
|
2388
|
+
if (localeData && localeData.locale) {
|
|
2389
|
+
MessageFormat.__addLocaleData(localeData);
|
|
2390
|
+
RelativeFormat.__addLocaleData(localeData);
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2382
2393
|
}
|
|
2383
2394
|
|
|
2384
2395
|
function hasLocaleData(locale) {
|
|
2385
|
-
|
|
2396
|
+
var localeParts = (locale || '').split('-');
|
|
2386
2397
|
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2392
|
-
localeParts.pop();
|
|
2398
|
+
while (localeParts.length > 0) {
|
|
2399
|
+
if (hasIMFAndIRFLocaleData(localeParts.join('-'))) {
|
|
2400
|
+
return true;
|
|
2393
2401
|
}
|
|
2394
2402
|
|
|
2395
|
-
|
|
2403
|
+
localeParts.pop();
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
return false;
|
|
2396
2407
|
}
|
|
2397
2408
|
|
|
2398
2409
|
function hasIMFAndIRFLocaleData(locale) {
|
|
2399
|
-
|
|
2410
|
+
var normalizedLocale = locale && locale.toLowerCase();
|
|
2400
2411
|
|
|
2401
|
-
|
|
2412
|
+
return !!(MessageFormat.__localeData__[normalizedLocale] && RelativeFormat.__localeData__[normalizedLocale]);
|
|
2402
2413
|
}
|
|
2403
2414
|
|
|
2404
2415
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
@@ -2562,6 +2573,7 @@ var object = PropTypes.object;
|
|
|
2562
2573
|
var oneOf = PropTypes.oneOf;
|
|
2563
2574
|
var shape = PropTypes.shape;
|
|
2564
2575
|
var any = PropTypes.any;
|
|
2576
|
+
var oneOfType = PropTypes.oneOfType;
|
|
2565
2577
|
|
|
2566
2578
|
var localeMatcher = oneOf(['best fit', 'lookup']);
|
|
2567
2579
|
var narrowShortLong = oneOf(['narrow', 'short', 'long']);
|
|
@@ -2569,76 +2581,76 @@ var numeric2digit = oneOf(['numeric', '2-digit']);
|
|
|
2569
2581
|
var funcReq = func.isRequired;
|
|
2570
2582
|
|
|
2571
2583
|
var intlConfigPropTypes = {
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2584
|
+
locale: string,
|
|
2585
|
+
formats: object,
|
|
2586
|
+
messages: object,
|
|
2587
|
+
textComponent: any,
|
|
2576
2588
|
|
|
2577
|
-
|
|
2578
|
-
|
|
2589
|
+
defaultLocale: string,
|
|
2590
|
+
defaultFormats: object
|
|
2579
2591
|
};
|
|
2580
2592
|
|
|
2581
2593
|
var intlFormatPropTypes = {
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2594
|
+
formatDate: funcReq,
|
|
2595
|
+
formatTime: funcReq,
|
|
2596
|
+
formatRelative: funcReq,
|
|
2597
|
+
formatNumber: funcReq,
|
|
2598
|
+
formatPlural: funcReq,
|
|
2599
|
+
formatMessage: funcReq,
|
|
2600
|
+
formatHTMLMessage: funcReq
|
|
2589
2601
|
};
|
|
2590
2602
|
|
|
2591
2603
|
var intlShape = shape(_extends({}, intlConfigPropTypes, intlFormatPropTypes, {
|
|
2592
|
-
|
|
2593
|
-
|
|
2604
|
+
formatters: object,
|
|
2605
|
+
now: funcReq
|
|
2594
2606
|
}));
|
|
2595
2607
|
|
|
2596
2608
|
var messageDescriptorPropTypes = {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2609
|
+
id: string.isRequired,
|
|
2610
|
+
description: oneOfType([string, object]),
|
|
2611
|
+
defaultMessage: string
|
|
2600
2612
|
};
|
|
2601
2613
|
|
|
2602
2614
|
var dateTimeFormatPropTypes = {
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2615
|
+
localeMatcher: localeMatcher,
|
|
2616
|
+
formatMatcher: oneOf(['basic', 'best fit']),
|
|
2617
|
+
|
|
2618
|
+
timeZone: string,
|
|
2619
|
+
hour12: bool,
|
|
2620
|
+
|
|
2621
|
+
weekday: narrowShortLong,
|
|
2622
|
+
era: narrowShortLong,
|
|
2623
|
+
year: numeric2digit,
|
|
2624
|
+
month: oneOf(['numeric', '2-digit', 'narrow', 'short', 'long']),
|
|
2625
|
+
day: numeric2digit,
|
|
2626
|
+
hour: numeric2digit,
|
|
2627
|
+
minute: numeric2digit,
|
|
2628
|
+
second: numeric2digit,
|
|
2629
|
+
timeZoneName: oneOf(['short', 'long'])
|
|
2618
2630
|
};
|
|
2619
2631
|
|
|
2620
2632
|
var numberFormatPropTypes = {
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
+
localeMatcher: localeMatcher,
|
|
2634
|
+
|
|
2635
|
+
style: oneOf(['decimal', 'currency', 'percent']),
|
|
2636
|
+
currency: string,
|
|
2637
|
+
currencyDisplay: oneOf(['symbol', 'code', 'name']),
|
|
2638
|
+
useGrouping: bool,
|
|
2639
|
+
|
|
2640
|
+
minimumIntegerDigits: number,
|
|
2641
|
+
minimumFractionDigits: number,
|
|
2642
|
+
maximumFractionDigits: number,
|
|
2643
|
+
minimumSignificantDigits: number,
|
|
2644
|
+
maximumSignificantDigits: number
|
|
2633
2645
|
};
|
|
2634
2646
|
|
|
2635
2647
|
var relativeFormatPropTypes = {
|
|
2636
|
-
|
|
2637
|
-
|
|
2648
|
+
style: oneOf(['best fit', 'numeric']),
|
|
2649
|
+
units: oneOf(['second', 'minute', 'hour', 'day', 'month', 'year'])
|
|
2638
2650
|
};
|
|
2639
2651
|
|
|
2640
2652
|
var pluralFormatPropTypes = {
|
|
2641
|
-
|
|
2653
|
+
style: oneOf(['cardinal', 'ordinal'])
|
|
2642
2654
|
};
|
|
2643
2655
|
|
|
2644
2656
|
/**
|
|
@@ -2704,82 +2716,82 @@ file in the root directory of React's source tree.
|
|
|
2704
2716
|
var intlConfigPropNames = Object.keys(intlConfigPropTypes);
|
|
2705
2717
|
|
|
2706
2718
|
var ESCAPED_CHARS = {
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2719
|
+
'&': '&',
|
|
2720
|
+
'>': '>',
|
|
2721
|
+
'<': '<',
|
|
2722
|
+
'"': '"',
|
|
2723
|
+
"'": '''
|
|
2712
2724
|
};
|
|
2713
2725
|
|
|
2714
2726
|
var UNSAFE_CHARS_REGEX = /[&><"']/g;
|
|
2715
2727
|
|
|
2716
2728
|
function escape(str) {
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2729
|
+
return ('' + str).replace(UNSAFE_CHARS_REGEX, function (match) {
|
|
2730
|
+
return ESCAPED_CHARS[match];
|
|
2731
|
+
});
|
|
2720
2732
|
}
|
|
2721
2733
|
|
|
2722
2734
|
function filterProps(props, whitelist) {
|
|
2723
|
-
|
|
2735
|
+
var defaults$$1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2724
2736
|
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2737
|
+
return whitelist.reduce(function (filtered, name) {
|
|
2738
|
+
if (props.hasOwnProperty(name)) {
|
|
2739
|
+
filtered[name] = props[name];
|
|
2740
|
+
} else if (defaults$$1.hasOwnProperty(name)) {
|
|
2741
|
+
filtered[name] = defaults$$1[name];
|
|
2742
|
+
}
|
|
2731
2743
|
|
|
2732
|
-
|
|
2733
|
-
|
|
2744
|
+
return filtered;
|
|
2745
|
+
}, {});
|
|
2734
2746
|
}
|
|
2735
2747
|
|
|
2736
2748
|
function invariantIntlContext() {
|
|
2737
|
-
|
|
2738
|
-
|
|
2749
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2750
|
+
intl = _ref.intl;
|
|
2739
2751
|
|
|
2740
|
-
|
|
2752
|
+
invariant_1(intl, '[React Intl] Could not find required `intl` object. ' + '<IntlProvider> needs to exist in the component ancestry.');
|
|
2741
2753
|
}
|
|
2742
2754
|
|
|
2743
2755
|
function shallowEquals(objA, objB) {
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2756
|
+
if (objA === objB) {
|
|
2757
|
+
return true;
|
|
2758
|
+
}
|
|
2747
2759
|
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2760
|
+
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
|
|
2761
|
+
return false;
|
|
2762
|
+
}
|
|
2751
2763
|
|
|
2752
|
-
|
|
2753
|
-
|
|
2764
|
+
var keysA = Object.keys(objA);
|
|
2765
|
+
var keysB = Object.keys(objB);
|
|
2754
2766
|
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2767
|
+
if (keysA.length !== keysB.length) {
|
|
2768
|
+
return false;
|
|
2769
|
+
}
|
|
2758
2770
|
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
}
|
|
2771
|
+
// Test for A's keys different from B.
|
|
2772
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
2773
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
2774
|
+
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
|
|
2775
|
+
return false;
|
|
2765
2776
|
}
|
|
2777
|
+
}
|
|
2766
2778
|
|
|
2767
|
-
|
|
2779
|
+
return true;
|
|
2768
2780
|
}
|
|
2769
2781
|
|
|
2770
2782
|
function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
+
var props = _ref2.props,
|
|
2784
|
+
state = _ref2.state,
|
|
2785
|
+
_ref2$context = _ref2.context,
|
|
2786
|
+
context = _ref2$context === undefined ? {} : _ref2$context;
|
|
2787
|
+
var nextContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2788
|
+
var _context$intl = context.intl,
|
|
2789
|
+
intl = _context$intl === undefined ? {} : _context$intl;
|
|
2790
|
+
var _nextContext$intl = nextContext.intl,
|
|
2791
|
+
nextIntl = _nextContext$intl === undefined ? {} : _nextContext$intl;
|
|
2792
|
+
|
|
2793
|
+
|
|
2794
|
+
return !shallowEquals(nextProps, props) || !shallowEquals(nextState, state) || !(nextIntl === intl || shallowEquals(filterProps(nextIntl, intlConfigPropNames), filterProps(intl, intlConfigPropNames)));
|
|
2783
2795
|
}
|
|
2784
2796
|
|
|
2785
2797
|
/*
|
|
@@ -2792,54 +2804,54 @@ function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
|
2792
2804
|
// https://github.com/rackt/react-redux
|
|
2793
2805
|
|
|
2794
2806
|
function getDisplayName(Component$$1) {
|
|
2795
|
-
|
|
2807
|
+
return Component$$1.displayName || Component$$1.name || 'Component';
|
|
2796
2808
|
}
|
|
2797
2809
|
|
|
2798
2810
|
function injectIntl(WrappedComponent) {
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2811
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2812
|
+
var _options$intlPropName = options.intlPropName,
|
|
2813
|
+
intlPropName = _options$intlPropName === undefined ? 'intl' : _options$intlPropName,
|
|
2814
|
+
_options$withRef = options.withRef,
|
|
2815
|
+
withRef = _options$withRef === undefined ? false : _options$withRef;
|
|
2804
2816
|
|
|
2805
|
-
|
|
2806
|
-
|
|
2817
|
+
var InjectIntl = function (_Component) {
|
|
2818
|
+
inherits(InjectIntl, _Component);
|
|
2807
2819
|
|
|
2808
|
-
|
|
2809
|
-
|
|
2820
|
+
function InjectIntl(props, context) {
|
|
2821
|
+
classCallCheck(this, InjectIntl);
|
|
2810
2822
|
|
|
2811
|
-
|
|
2823
|
+
var _this = possibleConstructorReturn(this, (InjectIntl.__proto__ || Object.getPrototypeOf(InjectIntl)).call(this, props, context));
|
|
2812
2824
|
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2825
|
+
invariantIntlContext(context);
|
|
2826
|
+
return _this;
|
|
2827
|
+
}
|
|
2816
2828
|
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2829
|
+
createClass(InjectIntl, [{
|
|
2830
|
+
key: 'getWrappedInstance',
|
|
2831
|
+
value: function getWrappedInstance() {
|
|
2832
|
+
invariant_1(withRef, '[React Intl] To access the wrapped instance, ' + 'the `{withRef: true}` option must be set when calling: ' + '`injectIntl()`');
|
|
2821
2833
|
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
+
return this.refs.wrappedInstance;
|
|
2835
|
+
}
|
|
2836
|
+
}, {
|
|
2837
|
+
key: 'render',
|
|
2838
|
+
value: function render() {
|
|
2839
|
+
return React__default.createElement(WrappedComponent, _extends({}, this.props, defineProperty$2({}, intlPropName, this.context.intl), {
|
|
2840
|
+
ref: withRef ? 'wrappedInstance' : null
|
|
2841
|
+
}));
|
|
2842
|
+
}
|
|
2843
|
+
}]);
|
|
2844
|
+
return InjectIntl;
|
|
2845
|
+
}(React.Component);
|
|
2834
2846
|
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2847
|
+
InjectIntl.displayName = 'InjectIntl(' + getDisplayName(WrappedComponent) + ')';
|
|
2848
|
+
InjectIntl.contextTypes = {
|
|
2849
|
+
intl: intlShape
|
|
2850
|
+
};
|
|
2851
|
+
InjectIntl.WrappedComponent = WrappedComponent;
|
|
2840
2852
|
|
|
2841
2853
|
|
|
2842
|
-
|
|
2854
|
+
return InjectIntl;
|
|
2843
2855
|
}
|
|
2844
2856
|
|
|
2845
2857
|
/*
|
|
@@ -2863,25 +2875,25 @@ function defineMessages(messageDescriptors) {
|
|
|
2863
2875
|
// This is a "hack" until a proper `intl-pluralformat` package is created.
|
|
2864
2876
|
|
|
2865
2877
|
function resolveLocale(locales) {
|
|
2866
|
-
|
|
2867
|
-
|
|
2878
|
+
// IntlMessageFormat#_resolveLocale() does not depend on `this`.
|
|
2879
|
+
return MessageFormat.prototype._resolveLocale(locales);
|
|
2868
2880
|
}
|
|
2869
2881
|
|
|
2870
2882
|
function findPluralFunction(locale) {
|
|
2871
|
-
|
|
2872
|
-
|
|
2883
|
+
// IntlMessageFormat#_findPluralFunction() does not depend on `this`.
|
|
2884
|
+
return MessageFormat.prototype._findPluralRuleFunction(locale);
|
|
2873
2885
|
}
|
|
2874
2886
|
|
|
2875
2887
|
var IntlPluralFormat = function IntlPluralFormat(locales) {
|
|
2876
|
-
|
|
2877
|
-
|
|
2888
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2889
|
+
classCallCheck(this, IntlPluralFormat);
|
|
2878
2890
|
|
|
2879
|
-
|
|
2880
|
-
|
|
2891
|
+
var useOrdinal = options.style === 'ordinal';
|
|
2892
|
+
var pluralFn = findPluralFunction(resolveLocale(locales));
|
|
2881
2893
|
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2894
|
+
this.format = function (value) {
|
|
2895
|
+
return pluralFn(value, useOrdinal);
|
|
2896
|
+
};
|
|
2885
2897
|
};
|
|
2886
2898
|
|
|
2887
2899
|
/*
|
|
@@ -3048,234 +3060,234 @@ var RELATIVE_FORMAT_OPTIONS = Object.keys(relativeFormatPropTypes);
|
|
|
3048
3060
|
var PLURAL_FORMAT_OPTIONS = Object.keys(pluralFormatPropTypes);
|
|
3049
3061
|
|
|
3050
3062
|
var RELATIVE_FORMAT_THRESHOLDS = {
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3063
|
+
second: 60, // seconds to minute
|
|
3064
|
+
minute: 60, // minutes to hour
|
|
3065
|
+
hour: 24, // hours to day
|
|
3066
|
+
day: 30, // days to month
|
|
3067
|
+
month: 12 // months to year
|
|
3068
|
+
};
|
|
3056
3069
|
|
|
3057
3070
|
function updateRelativeFormatThresholds(newThresholds) {
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3071
|
+
var thresholds = RelativeFormat.thresholds;
|
|
3072
|
+
thresholds.second = newThresholds.second;
|
|
3073
|
+
thresholds.minute = newThresholds.minute;
|
|
3074
|
+
thresholds.hour = newThresholds.hour;
|
|
3075
|
+
thresholds.day = newThresholds.day;
|
|
3076
|
+
thresholds.month = newThresholds.month;
|
|
3064
3077
|
}
|
|
3065
3078
|
|
|
3066
3079
|
function getNamedFormat(formats, type, name) {
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3080
|
+
var format = formats && formats[type] && formats[type][name];
|
|
3081
|
+
if (format) {
|
|
3082
|
+
return format;
|
|
3083
|
+
}
|
|
3071
3084
|
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3085
|
+
{
|
|
3086
|
+
console.error('[React Intl] No ' + type + ' format named: ' + name);
|
|
3087
|
+
}
|
|
3075
3088
|
}
|
|
3076
3089
|
|
|
3077
3090
|
function formatDate(config, state, value) {
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3091
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3092
|
+
var locale = config.locale,
|
|
3093
|
+
formats = config.formats;
|
|
3094
|
+
var format = options.format;
|
|
3082
3095
|
|
|
3083
3096
|
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3097
|
+
var date = new Date(value);
|
|
3098
|
+
var defaults$$1 = format && getNamedFormat(formats, 'date', format);
|
|
3099
|
+
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
3087
3100
|
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
}
|
|
3101
|
+
try {
|
|
3102
|
+
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
3103
|
+
} catch (e) {
|
|
3104
|
+
{
|
|
3105
|
+
console.error('[React Intl] Error formatting date.\n' + e);
|
|
3094
3106
|
}
|
|
3107
|
+
}
|
|
3095
3108
|
|
|
3096
|
-
|
|
3109
|
+
return String(date);
|
|
3097
3110
|
}
|
|
3098
3111
|
|
|
3099
3112
|
function formatTime(config, state, value) {
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3113
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3114
|
+
var locale = config.locale,
|
|
3115
|
+
formats = config.formats;
|
|
3116
|
+
var format = options.format;
|
|
3104
3117
|
|
|
3105
3118
|
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3119
|
+
var date = new Date(value);
|
|
3120
|
+
var defaults$$1 = format && getNamedFormat(formats, 'time', format);
|
|
3121
|
+
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
3109
3122
|
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3123
|
+
if (!filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second) {
|
|
3124
|
+
// Add default formatting options if hour, minute, or second isn't defined.
|
|
3125
|
+
filteredOptions = _extends({}, filteredOptions, { hour: 'numeric', minute: 'numeric' });
|
|
3126
|
+
}
|
|
3114
3127
|
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
}
|
|
3128
|
+
try {
|
|
3129
|
+
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
3130
|
+
} catch (e) {
|
|
3131
|
+
{
|
|
3132
|
+
console.error('[React Intl] Error formatting time.\n' + e);
|
|
3121
3133
|
}
|
|
3134
|
+
}
|
|
3122
3135
|
|
|
3123
|
-
|
|
3136
|
+
return String(date);
|
|
3124
3137
|
}
|
|
3125
3138
|
|
|
3126
3139
|
function formatRelative(config, state, value) {
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3140
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3141
|
+
var locale = config.locale,
|
|
3142
|
+
formats = config.formats;
|
|
3143
|
+
var format = options.format;
|
|
3131
3144
|
|
|
3132
3145
|
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3146
|
+
var date = new Date(value);
|
|
3147
|
+
var now = new Date(options.now);
|
|
3148
|
+
var defaults$$1 = format && getNamedFormat(formats, 'relative', format);
|
|
3149
|
+
var filteredOptions = filterProps(options, RELATIVE_FORMAT_OPTIONS, defaults$$1);
|
|
3137
3150
|
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3151
|
+
// Capture the current threshold values, then temporarily override them with
|
|
3152
|
+
// specific values just for this render.
|
|
3153
|
+
var oldThresholds = _extends({}, RelativeFormat.thresholds);
|
|
3154
|
+
updateRelativeFormatThresholds(RELATIVE_FORMAT_THRESHOLDS);
|
|
3142
3155
|
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
}
|
|
3151
|
-
} finally {
|
|
3152
|
-
updateRelativeFormatThresholds(oldThresholds);
|
|
3156
|
+
try {
|
|
3157
|
+
return state.getRelativeFormat(locale, filteredOptions).format(date, {
|
|
3158
|
+
now: isFinite(now) ? now : state.now()
|
|
3159
|
+
});
|
|
3160
|
+
} catch (e) {
|
|
3161
|
+
{
|
|
3162
|
+
console.error('[React Intl] Error formatting relative time.\n' + e);
|
|
3153
3163
|
}
|
|
3164
|
+
} finally {
|
|
3165
|
+
updateRelativeFormatThresholds(oldThresholds);
|
|
3166
|
+
}
|
|
3154
3167
|
|
|
3155
|
-
|
|
3168
|
+
return String(date);
|
|
3156
3169
|
}
|
|
3157
3170
|
|
|
3158
3171
|
function formatNumber(config, state, value) {
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3172
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3173
|
+
var locale = config.locale,
|
|
3174
|
+
formats = config.formats;
|
|
3175
|
+
var format = options.format;
|
|
3163
3176
|
|
|
3164
3177
|
|
|
3165
|
-
|
|
3166
|
-
|
|
3178
|
+
var defaults$$1 = format && getNamedFormat(formats, 'number', format);
|
|
3179
|
+
var filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults$$1);
|
|
3167
3180
|
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
}
|
|
3181
|
+
try {
|
|
3182
|
+
return state.getNumberFormat(locale, filteredOptions).format(value);
|
|
3183
|
+
} catch (e) {
|
|
3184
|
+
{
|
|
3185
|
+
console.error('[React Intl] Error formatting number.\n' + e);
|
|
3174
3186
|
}
|
|
3187
|
+
}
|
|
3175
3188
|
|
|
3176
|
-
|
|
3189
|
+
return String(value);
|
|
3177
3190
|
}
|
|
3178
3191
|
|
|
3179
3192
|
function formatPlural(config, state, value) {
|
|
3180
|
-
|
|
3181
|
-
|
|
3193
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3194
|
+
var locale = config.locale;
|
|
3182
3195
|
|
|
3183
3196
|
|
|
3184
|
-
|
|
3197
|
+
var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
3185
3198
|
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
}
|
|
3199
|
+
try {
|
|
3200
|
+
return state.getPluralFormat(locale, filteredOptions).format(value);
|
|
3201
|
+
} catch (e) {
|
|
3202
|
+
{
|
|
3203
|
+
console.error('[React Intl] Error formatting plural.\n' + e);
|
|
3192
3204
|
}
|
|
3205
|
+
}
|
|
3193
3206
|
|
|
3194
|
-
|
|
3207
|
+
return 'other';
|
|
3195
3208
|
}
|
|
3196
3209
|
|
|
3197
3210
|
function formatMessage(config, state) {
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
var formattedMessage = void 0;
|
|
3211
|
+
var messageDescriptor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
3212
|
+
var values = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3213
|
+
var locale = config.locale,
|
|
3214
|
+
formats = config.formats,
|
|
3215
|
+
messages = config.messages,
|
|
3216
|
+
defaultLocale = config.defaultLocale,
|
|
3217
|
+
defaultFormats = config.defaultFormats;
|
|
3218
|
+
var id = messageDescriptor.id,
|
|
3219
|
+
defaultMessage = messageDescriptor.defaultMessage;
|
|
3220
|
+
|
|
3221
|
+
// `id` is a required field of a Message Descriptor.
|
|
3222
|
+
|
|
3223
|
+
invariant_1(id, '[React Intl] An `id` must be provided to format a message.');
|
|
3224
|
+
|
|
3225
|
+
var message = messages && messages[id];
|
|
3226
|
+
var hasValues = Object.keys(values).length > 0;
|
|
3227
|
+
|
|
3228
|
+
// Avoid expensive message formatting for simple messages without values. In
|
|
3229
|
+
// development messages will always be formatted in case of missing values.
|
|
3230
|
+
if (!hasValues && "development" === 'production') {
|
|
3231
|
+
return message || defaultMessage || id;
|
|
3232
|
+
}
|
|
3222
3233
|
|
|
3223
|
-
|
|
3224
|
-
try {
|
|
3225
|
-
var formatter = state.getMessageFormat(message, locale, formats);
|
|
3234
|
+
var formattedMessage = void 0;
|
|
3226
3235
|
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
3231
|
-
}
|
|
3232
|
-
}
|
|
3233
|
-
} else {
|
|
3234
|
-
{
|
|
3235
|
-
// This prevents warnings from littering the console in development
|
|
3236
|
-
// when no `messages` are passed into the <IntlProvider> for the
|
|
3237
|
-
// default locale, and a default message is in the source.
|
|
3238
|
-
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
3236
|
+
if (message) {
|
|
3237
|
+
try {
|
|
3238
|
+
var formatter = state.getMessageFormat(message, locale, formats);
|
|
3239
3239
|
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3240
|
+
formattedMessage = formatter.format(values);
|
|
3241
|
+
} catch (e) {
|
|
3242
|
+
{
|
|
3243
|
+
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
3244
|
+
}
|
|
3243
3245
|
}
|
|
3246
|
+
} else {
|
|
3247
|
+
{
|
|
3248
|
+
// This prevents warnings from littering the console in development
|
|
3249
|
+
// when no `messages` are passed into the <IntlProvider> for the
|
|
3250
|
+
// default locale, and a default message is in the source.
|
|
3251
|
+
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
3252
|
+
console.error('[React Intl] Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''));
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3244
3256
|
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3257
|
+
if (!formattedMessage && defaultMessage) {
|
|
3258
|
+
try {
|
|
3259
|
+
var _formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats);
|
|
3248
3260
|
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
}
|
|
3261
|
+
formattedMessage = _formatter.format(values);
|
|
3262
|
+
} catch (e) {
|
|
3263
|
+
{
|
|
3264
|
+
console.error('[React Intl] Error formatting the default message for: "' + id + '"' + ('\n' + e));
|
|
3265
|
+
}
|
|
3255
3266
|
}
|
|
3267
|
+
}
|
|
3256
3268
|
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
}
|
|
3269
|
+
if (!formattedMessage) {
|
|
3270
|
+
{
|
|
3271
|
+
console.error('[React Intl] Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.'));
|
|
3261
3272
|
}
|
|
3273
|
+
}
|
|
3262
3274
|
|
|
3263
|
-
|
|
3275
|
+
return formattedMessage || message || defaultMessage || id;
|
|
3264
3276
|
}
|
|
3265
3277
|
|
|
3266
3278
|
function formatHTMLMessage(config, state, messageDescriptor) {
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
+
var rawValues = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
3280
|
+
|
|
3281
|
+
// Process all the values before they are used when formatting the ICU
|
|
3282
|
+
// Message string. Since the formatted message might be injected via
|
|
3283
|
+
// `innerHTML`, all String-based values need to be HTML-escaped.
|
|
3284
|
+
var escapedValues = Object.keys(rawValues).reduce(function (escaped, name) {
|
|
3285
|
+
var value = rawValues[name];
|
|
3286
|
+
escaped[name] = typeof value === 'string' ? escape(value) : value;
|
|
3287
|
+
return escaped;
|
|
3288
|
+
}, {});
|
|
3289
|
+
|
|
3290
|
+
return formatMessage(config, state, messageDescriptor, escapedValues);
|
|
3279
3291
|
}
|
|
3280
3292
|
|
|
3281
3293
|
|
|
@@ -3302,170 +3314,170 @@ var intlFormatPropNames = Object.keys(intlFormatPropTypes);
|
|
|
3302
3314
|
// These are not a static property on the `IntlProvider` class so the intl
|
|
3303
3315
|
// config values can be inherited from an <IntlProvider> ancestor.
|
|
3304
3316
|
var defaultProps = {
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3317
|
+
formats: {},
|
|
3318
|
+
messages: {},
|
|
3319
|
+
textComponent: 'span',
|
|
3308
3320
|
|
|
3309
|
-
|
|
3310
|
-
|
|
3321
|
+
defaultLocale: 'en',
|
|
3322
|
+
defaultFormats: {}
|
|
3311
3323
|
};
|
|
3312
3324
|
|
|
3313
3325
|
var IntlProvider = function (_Component) {
|
|
3314
|
-
|
|
3326
|
+
inherits(IntlProvider, _Component);
|
|
3315
3327
|
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3328
|
+
function IntlProvider(props) {
|
|
3329
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3330
|
+
classCallCheck(this, IntlProvider);
|
|
3319
3331
|
|
|
3320
|
-
|
|
3332
|
+
var _this = possibleConstructorReturn(this, (IntlProvider.__proto__ || Object.getPrototypeOf(IntlProvider)).call(this, props, context));
|
|
3321
3333
|
|
|
3322
|
-
|
|
3334
|
+
invariant_1(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/');
|
|
3323
3335
|
|
|
3324
|
-
|
|
3336
|
+
var intlContext = context.intl;
|
|
3325
3337
|
|
|
3326
|
-
|
|
3327
|
-
|
|
3338
|
+
// Used to stabilize time when performing an initial rendering so that
|
|
3339
|
+
// all relative times use the same reference "now" time.
|
|
3328
3340
|
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
|
-
// Creating `Intl*` formatters is expensive. If there's a parent
|
|
3340
|
-
// `<IntlProvider>`, then its formatters will be used. Otherwise, this
|
|
3341
|
-
// memoize the `Intl*` constructors and cache them for the lifecycle of
|
|
3342
|
-
// this IntlProvider instance.
|
|
3343
|
-
|
|
3344
|
-
var _ref = intlContext || {},
|
|
3345
|
-
_ref$formatters = _ref.formatters,
|
|
3346
|
-
formatters = _ref$formatters === undefined ? {
|
|
3347
|
-
getDateTimeFormat: createFormatCache(Intl.DateTimeFormat),
|
|
3348
|
-
getNumberFormat: createFormatCache(Intl.NumberFormat),
|
|
3349
|
-
getMessageFormat: createFormatCache(MessageFormat),
|
|
3350
|
-
getRelativeFormat: createFormatCache(RelativeFormat),
|
|
3351
|
-
getPluralFormat: createFormatCache(IntlPluralFormat)
|
|
3352
|
-
} : _ref$formatters;
|
|
3353
|
-
|
|
3354
|
-
_this.state = _extends({}, formatters, {
|
|
3355
|
-
|
|
3356
|
-
// Wrapper to provide stable "now" time for initial render.
|
|
3357
|
-
now: function now() {
|
|
3358
|
-
return _this._didDisplay ? Date.now() : initialNow;
|
|
3359
|
-
}
|
|
3360
|
-
});
|
|
3361
|
-
return _this;
|
|
3341
|
+
var initialNow = void 0;
|
|
3342
|
+
if (isFinite(props.initialNow)) {
|
|
3343
|
+
initialNow = Number(props.initialNow);
|
|
3344
|
+
} else {
|
|
3345
|
+
// When an `initialNow` isn't provided via `props`, look to see an
|
|
3346
|
+
// <IntlProvider> exists in the ancestry and call its `now()`
|
|
3347
|
+
// function to propagate its value for "now".
|
|
3348
|
+
initialNow = intlContext ? intlContext.now() : Date.now();
|
|
3362
3349
|
}
|
|
3363
3350
|
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3351
|
+
// Creating `Intl*` formatters is expensive. If there's a parent
|
|
3352
|
+
// `<IntlProvider>`, then its formatters will be used. Otherwise, this
|
|
3353
|
+
// memoize the `Intl*` constructors and cache them for the lifecycle of
|
|
3354
|
+
// this IntlProvider instance.
|
|
3355
|
+
|
|
3356
|
+
var _ref = intlContext || {},
|
|
3357
|
+
_ref$formatters = _ref.formatters,
|
|
3358
|
+
formatters = _ref$formatters === undefined ? {
|
|
3359
|
+
getDateTimeFormat: createFormatCache(Intl.DateTimeFormat),
|
|
3360
|
+
getNumberFormat: createFormatCache(Intl.NumberFormat),
|
|
3361
|
+
getMessageFormat: createFormatCache(MessageFormat),
|
|
3362
|
+
getRelativeFormat: createFormatCache(RelativeFormat),
|
|
3363
|
+
getPluralFormat: createFormatCache(IntlPluralFormat)
|
|
3364
|
+
} : _ref$formatters;
|
|
3365
|
+
|
|
3366
|
+
_this.state = _extends({}, formatters, {
|
|
3367
|
+
|
|
3368
|
+
// Wrapper to provide stable "now" time for initial render.
|
|
3369
|
+
now: function now() {
|
|
3370
|
+
return _this._didDisplay ? Date.now() : initialNow;
|
|
3371
|
+
}
|
|
3372
|
+
});
|
|
3373
|
+
return _this;
|
|
3374
|
+
}
|
|
3368
3375
|
|
|
3369
|
-
|
|
3370
|
-
|
|
3376
|
+
createClass(IntlProvider, [{
|
|
3377
|
+
key: 'getConfig',
|
|
3378
|
+
value: function getConfig() {
|
|
3379
|
+
var intlContext = this.context.intl;
|
|
3371
3380
|
|
|
3372
|
-
|
|
3381
|
+
// Build a whitelisted config object from `props`, defaults, and
|
|
3382
|
+
// `context.intl`, if an <IntlProvider> exists in the ancestry.
|
|
3373
3383
|
|
|
3374
|
-
|
|
3375
|
-
// been resolved and inherited from any <IntlProvider> in the ancestry.
|
|
3376
|
-
// This matches how React resolves `defaultProps`.
|
|
3377
|
-
for (var propName in defaultProps) {
|
|
3378
|
-
if (config[propName] === undefined) {
|
|
3379
|
-
config[propName] = defaultProps[propName];
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
|
-
if (!hasLocaleData(config.locale)) {
|
|
3384
|
-
var _config = config,
|
|
3385
|
-
locale = _config.locale,
|
|
3386
|
-
defaultLocale = _config.defaultLocale,
|
|
3387
|
-
defaultFormats = _config.defaultFormats;
|
|
3384
|
+
var config = filterProps(this.props, intlConfigPropNames$1, intlContext);
|
|
3388
3385
|
|
|
3386
|
+
// Apply default props. This must be applied last after the props have
|
|
3387
|
+
// been resolved and inherited from any <IntlProvider> in the ancestry.
|
|
3388
|
+
// This matches how React resolves `defaultProps`.
|
|
3389
|
+
for (var propName in defaultProps) {
|
|
3390
|
+
if (config[propName] === undefined) {
|
|
3391
|
+
config[propName] = defaultProps[propName];
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3389
3394
|
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3395
|
+
if (!hasLocaleData(config.locale)) {
|
|
3396
|
+
var _config = config,
|
|
3397
|
+
locale = _config.locale,
|
|
3398
|
+
defaultLocale = _config.defaultLocale,
|
|
3399
|
+
defaultFormats = _config.defaultFormats;
|
|
3393
3400
|
|
|
3394
|
-
// Since there's no registered locale data for `locale`, this will
|
|
3395
|
-
// fallback to the `defaultLocale` to make sure things can render.
|
|
3396
|
-
// The `messages` are overridden to the `defaultProps` empty object
|
|
3397
|
-
// to maintain referential equality across re-renders. It's assumed
|
|
3398
|
-
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
3399
|
-
config = _extends({}, config, {
|
|
3400
|
-
locale: defaultLocale,
|
|
3401
|
-
formats: defaultFormats,
|
|
3402
|
-
messages: defaultProps.messages
|
|
3403
|
-
});
|
|
3404
|
-
}
|
|
3405
3401
|
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
}, {
|
|
3409
|
-
key: 'getBoundFormatFns',
|
|
3410
|
-
value: function getBoundFormatFns(config, state) {
|
|
3411
|
-
return intlFormatPropNames.reduce(function (boundFormatFns, name) {
|
|
3412
|
-
boundFormatFns[name] = format[name].bind(null, config, state);
|
|
3413
|
-
return boundFormatFns;
|
|
3414
|
-
}, {});
|
|
3402
|
+
{
|
|
3403
|
+
console.error('[React Intl] Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'));
|
|
3415
3404
|
}
|
|
3416
|
-
}, {
|
|
3417
|
-
key: 'getChildContext',
|
|
3418
|
-
value: function getChildContext() {
|
|
3419
|
-
var config = this.getConfig();
|
|
3420
3405
|
|
|
3421
|
-
|
|
3422
|
-
|
|
3406
|
+
// Since there's no registered locale data for `locale`, this will
|
|
3407
|
+
// fallback to the `defaultLocale` to make sure things can render.
|
|
3408
|
+
// The `messages` are overridden to the `defaultProps` empty object
|
|
3409
|
+
// to maintain referential equality across re-renders. It's assumed
|
|
3410
|
+
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
3411
|
+
config = _extends({}, config, {
|
|
3412
|
+
locale: defaultLocale,
|
|
3413
|
+
formats: defaultFormats,
|
|
3414
|
+
messages: defaultProps.messages
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3423
3417
|
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3418
|
+
return config;
|
|
3419
|
+
}
|
|
3420
|
+
}, {
|
|
3421
|
+
key: 'getBoundFormatFns',
|
|
3422
|
+
value: function getBoundFormatFns(config, state) {
|
|
3423
|
+
return intlFormatPropNames.reduce(function (boundFormatFns, name) {
|
|
3424
|
+
boundFormatFns[name] = format[name].bind(null, config, state);
|
|
3425
|
+
return boundFormatFns;
|
|
3426
|
+
}, {});
|
|
3427
|
+
}
|
|
3428
|
+
}, {
|
|
3429
|
+
key: 'getChildContext',
|
|
3430
|
+
value: function getChildContext() {
|
|
3431
|
+
var config = this.getConfig();
|
|
3427
3432
|
|
|
3433
|
+
// Bind intl factories and current config to the format functions.
|
|
3434
|
+
var boundFormatFns = this.getBoundFormatFns(config, this.state);
|
|
3428
3435
|
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
now: now
|
|
3433
|
-
})
|
|
3434
|
-
};
|
|
3435
|
-
}
|
|
3436
|
-
}, {
|
|
3437
|
-
key: 'shouldComponentUpdate',
|
|
3438
|
-
value: function shouldComponentUpdate() {
|
|
3439
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3440
|
-
next[_key] = arguments[_key];
|
|
3441
|
-
}
|
|
3436
|
+
var _state = this.state,
|
|
3437
|
+
now = _state.now,
|
|
3438
|
+
formatters = objectWithoutProperties(_state, ['now']);
|
|
3442
3439
|
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
}
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3440
|
+
|
|
3441
|
+
return {
|
|
3442
|
+
intl: _extends({}, config, boundFormatFns, {
|
|
3443
|
+
formatters: formatters,
|
|
3444
|
+
now: now
|
|
3445
|
+
})
|
|
3446
|
+
};
|
|
3447
|
+
}
|
|
3448
|
+
}, {
|
|
3449
|
+
key: 'shouldComponentUpdate',
|
|
3450
|
+
value: function shouldComponentUpdate() {
|
|
3451
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3452
|
+
next[_key] = arguments[_key];
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
3456
|
+
}
|
|
3457
|
+
}, {
|
|
3458
|
+
key: 'componentDidMount',
|
|
3459
|
+
value: function componentDidMount() {
|
|
3460
|
+
this._didDisplay = true;
|
|
3461
|
+
}
|
|
3462
|
+
}, {
|
|
3463
|
+
key: 'render',
|
|
3464
|
+
value: function render() {
|
|
3465
|
+
return React.Children.only(this.props.children);
|
|
3466
|
+
}
|
|
3467
|
+
}]);
|
|
3468
|
+
return IntlProvider;
|
|
3457
3469
|
}(React.Component);
|
|
3458
3470
|
|
|
3459
3471
|
IntlProvider.displayName = 'IntlProvider';
|
|
3460
3472
|
IntlProvider.contextTypes = {
|
|
3461
|
-
|
|
3473
|
+
intl: intlShape
|
|
3462
3474
|
};
|
|
3463
3475
|
IntlProvider.childContextTypes = {
|
|
3464
|
-
|
|
3476
|
+
intl: intlShape.isRequired
|
|
3465
3477
|
};
|
|
3466
3478
|
IntlProvider.propTypes = _extends({}, intlConfigPropTypes, {
|
|
3467
|
-
|
|
3468
|
-
|
|
3479
|
+
children: PropTypes.element.isRequired,
|
|
3480
|
+
initialNow: PropTypes.any
|
|
3469
3481
|
});
|
|
3470
3482
|
|
|
3471
3483
|
/*
|
|
@@ -3475,61 +3487,61 @@ IntlProvider.propTypes = _extends({}, intlConfigPropTypes, {
|
|
|
3475
3487
|
*/
|
|
3476
3488
|
|
|
3477
3489
|
var FormattedDate = function (_Component) {
|
|
3478
|
-
|
|
3490
|
+
inherits(FormattedDate, _Component);
|
|
3479
3491
|
|
|
3480
|
-
|
|
3481
|
-
|
|
3492
|
+
function FormattedDate(props, context) {
|
|
3493
|
+
classCallCheck(this, FormattedDate);
|
|
3482
3494
|
|
|
3483
|
-
|
|
3495
|
+
var _this = possibleConstructorReturn(this, (FormattedDate.__proto__ || Object.getPrototypeOf(FormattedDate)).call(this, props, context));
|
|
3484
3496
|
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3497
|
+
invariantIntlContext(context);
|
|
3498
|
+
return _this;
|
|
3499
|
+
}
|
|
3488
3500
|
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3501
|
+
createClass(FormattedDate, [{
|
|
3502
|
+
key: 'shouldComponentUpdate',
|
|
3503
|
+
value: function shouldComponentUpdate() {
|
|
3504
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3505
|
+
next[_key] = arguments[_key];
|
|
3506
|
+
}
|
|
3495
3507
|
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3508
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
3509
|
+
}
|
|
3510
|
+
}, {
|
|
3511
|
+
key: 'render',
|
|
3512
|
+
value: function render() {
|
|
3513
|
+
var _context$intl = this.context.intl,
|
|
3514
|
+
formatDate = _context$intl.formatDate,
|
|
3515
|
+
Text = _context$intl.textComponent;
|
|
3516
|
+
var _props = this.props,
|
|
3517
|
+
value = _props.value,
|
|
3518
|
+
children = _props.children;
|
|
3507
3519
|
|
|
3508
3520
|
|
|
3509
|
-
|
|
3521
|
+
var formattedDate = formatDate(value, this.props);
|
|
3510
3522
|
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3523
|
+
if (typeof children === 'function') {
|
|
3524
|
+
return children(formattedDate);
|
|
3525
|
+
}
|
|
3514
3526
|
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3527
|
+
return React__default.createElement(
|
|
3528
|
+
Text,
|
|
3529
|
+
null,
|
|
3530
|
+
formattedDate
|
|
3531
|
+
);
|
|
3532
|
+
}
|
|
3533
|
+
}]);
|
|
3534
|
+
return FormattedDate;
|
|
3523
3535
|
}(React.Component);
|
|
3524
3536
|
|
|
3525
3537
|
FormattedDate.displayName = 'FormattedDate';
|
|
3526
3538
|
FormattedDate.contextTypes = {
|
|
3527
|
-
|
|
3539
|
+
intl: intlShape
|
|
3528
3540
|
};
|
|
3529
3541
|
FormattedDate.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3542
|
+
value: PropTypes.any.isRequired,
|
|
3543
|
+
format: PropTypes.string,
|
|
3544
|
+
children: PropTypes.func
|
|
3533
3545
|
});
|
|
3534
3546
|
|
|
3535
3547
|
/*
|
|
@@ -3539,61 +3551,61 @@ FormattedDate.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
|
3539
3551
|
*/
|
|
3540
3552
|
|
|
3541
3553
|
var FormattedTime = function (_Component) {
|
|
3542
|
-
|
|
3554
|
+
inherits(FormattedTime, _Component);
|
|
3543
3555
|
|
|
3544
|
-
|
|
3545
|
-
|
|
3556
|
+
function FormattedTime(props, context) {
|
|
3557
|
+
classCallCheck(this, FormattedTime);
|
|
3546
3558
|
|
|
3547
|
-
|
|
3559
|
+
var _this = possibleConstructorReturn(this, (FormattedTime.__proto__ || Object.getPrototypeOf(FormattedTime)).call(this, props, context));
|
|
3548
3560
|
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3561
|
+
invariantIntlContext(context);
|
|
3562
|
+
return _this;
|
|
3563
|
+
}
|
|
3552
3564
|
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3565
|
+
createClass(FormattedTime, [{
|
|
3566
|
+
key: 'shouldComponentUpdate',
|
|
3567
|
+
value: function shouldComponentUpdate() {
|
|
3568
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3569
|
+
next[_key] = arguments[_key];
|
|
3570
|
+
}
|
|
3559
3571
|
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3572
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
3573
|
+
}
|
|
3574
|
+
}, {
|
|
3575
|
+
key: 'render',
|
|
3576
|
+
value: function render() {
|
|
3577
|
+
var _context$intl = this.context.intl,
|
|
3578
|
+
formatTime = _context$intl.formatTime,
|
|
3579
|
+
Text = _context$intl.textComponent;
|
|
3580
|
+
var _props = this.props,
|
|
3581
|
+
value = _props.value,
|
|
3582
|
+
children = _props.children;
|
|
3571
3583
|
|
|
3572
3584
|
|
|
3573
|
-
|
|
3585
|
+
var formattedTime = formatTime(value, this.props);
|
|
3574
3586
|
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3587
|
+
if (typeof children === 'function') {
|
|
3588
|
+
return children(formattedTime);
|
|
3589
|
+
}
|
|
3578
3590
|
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3591
|
+
return React__default.createElement(
|
|
3592
|
+
Text,
|
|
3593
|
+
null,
|
|
3594
|
+
formattedTime
|
|
3595
|
+
);
|
|
3596
|
+
}
|
|
3597
|
+
}]);
|
|
3598
|
+
return FormattedTime;
|
|
3587
3599
|
}(React.Component);
|
|
3588
3600
|
|
|
3589
3601
|
FormattedTime.displayName = 'FormattedTime';
|
|
3590
3602
|
FormattedTime.contextTypes = {
|
|
3591
|
-
|
|
3603
|
+
intl: intlShape
|
|
3592
3604
|
};
|
|
3593
3605
|
FormattedTime.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3606
|
+
value: PropTypes.any.isRequired,
|
|
3607
|
+
format: PropTypes.string,
|
|
3608
|
+
children: PropTypes.func
|
|
3597
3609
|
});
|
|
3598
3610
|
|
|
3599
3611
|
/*
|
|
@@ -3612,179 +3624,179 @@ var DAY = 1000 * 60 * 60 * 24;
|
|
|
3612
3624
|
var MAX_TIMER_DELAY = 2147483647;
|
|
3613
3625
|
|
|
3614
3626
|
function selectUnits(delta) {
|
|
3615
|
-
|
|
3627
|
+
var absDelta = Math.abs(delta);
|
|
3616
3628
|
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3629
|
+
if (absDelta < MINUTE) {
|
|
3630
|
+
return 'second';
|
|
3631
|
+
}
|
|
3620
3632
|
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3633
|
+
if (absDelta < HOUR) {
|
|
3634
|
+
return 'minute';
|
|
3635
|
+
}
|
|
3624
3636
|
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3637
|
+
if (absDelta < DAY) {
|
|
3638
|
+
return 'hour';
|
|
3639
|
+
}
|
|
3628
3640
|
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3641
|
+
// The maximum scheduled delay will be measured in days since the maximum
|
|
3642
|
+
// timer delay is less than the number of milliseconds in 25 days.
|
|
3643
|
+
return 'day';
|
|
3632
3644
|
}
|
|
3633
3645
|
|
|
3634
3646
|
function getUnitDelay(units) {
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
+
switch (units) {
|
|
3648
|
+
case 'second':
|
|
3649
|
+
return SECOND;
|
|
3650
|
+
case 'minute':
|
|
3651
|
+
return MINUTE;
|
|
3652
|
+
case 'hour':
|
|
3653
|
+
return HOUR;
|
|
3654
|
+
case 'day':
|
|
3655
|
+
return DAY;
|
|
3656
|
+
default:
|
|
3657
|
+
return MAX_TIMER_DELAY;
|
|
3658
|
+
}
|
|
3647
3659
|
}
|
|
3648
3660
|
|
|
3649
3661
|
function isSameDate(a, b) {
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3662
|
+
if (a === b) {
|
|
3663
|
+
return true;
|
|
3664
|
+
}
|
|
3653
3665
|
|
|
3654
|
-
|
|
3655
|
-
|
|
3666
|
+
var aTime = new Date(a).getTime();
|
|
3667
|
+
var bTime = new Date(b).getTime();
|
|
3656
3668
|
|
|
3657
|
-
|
|
3669
|
+
return isFinite(aTime) && isFinite(bTime) && aTime === bTime;
|
|
3658
3670
|
}
|
|
3659
3671
|
|
|
3660
3672
|
var FormattedRelative = function (_Component) {
|
|
3661
|
-
|
|
3673
|
+
inherits(FormattedRelative, _Component);
|
|
3662
3674
|
|
|
3663
|
-
|
|
3664
|
-
|
|
3675
|
+
function FormattedRelative(props, context) {
|
|
3676
|
+
classCallCheck(this, FormattedRelative);
|
|
3665
3677
|
|
|
3666
|
-
|
|
3678
|
+
var _this = possibleConstructorReturn(this, (FormattedRelative.__proto__ || Object.getPrototypeOf(FormattedRelative)).call(this, props, context));
|
|
3667
3679
|
|
|
3668
|
-
|
|
3680
|
+
invariantIntlContext(context);
|
|
3669
3681
|
|
|
3670
|
-
|
|
3682
|
+
var now = isFinite(props.initialNow) ? Number(props.initialNow) : context.intl.now();
|
|
3671
3683
|
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3684
|
+
// `now` is stored as state so that `render()` remains a function of
|
|
3685
|
+
// props + state, instead of accessing `Date.now()` inside `render()`.
|
|
3686
|
+
_this.state = { now: now };
|
|
3687
|
+
return _this;
|
|
3688
|
+
}
|
|
3677
3689
|
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3690
|
+
createClass(FormattedRelative, [{
|
|
3691
|
+
key: 'scheduleNextUpdate',
|
|
3692
|
+
value: function scheduleNextUpdate(props, state) {
|
|
3693
|
+
var _this2 = this;
|
|
3682
3694
|
|
|
3683
|
-
|
|
3684
|
-
|
|
3695
|
+
// Cancel and pending update because we're scheduling a new update.
|
|
3696
|
+
clearTimeout(this._timer);
|
|
3685
3697
|
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3698
|
+
var value = props.value,
|
|
3699
|
+
units = props.units,
|
|
3700
|
+
updateInterval = props.updateInterval;
|
|
3689
3701
|
|
|
3690
|
-
|
|
3702
|
+
var time = new Date(value).getTime();
|
|
3691
3703
|
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3704
|
+
// If the `updateInterval` is falsy, including `0` or we don't have a
|
|
3705
|
+
// valid date, then auto updates have been turned off, so we bail and
|
|
3706
|
+
// skip scheduling an update.
|
|
3707
|
+
if (!updateInterval || !isFinite(time)) {
|
|
3708
|
+
return;
|
|
3709
|
+
}
|
|
3698
3710
|
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3711
|
+
var delta = time - state.now;
|
|
3712
|
+
var unitDelay = getUnitDelay(units || selectUnits(delta));
|
|
3713
|
+
var unitRemainder = Math.abs(delta % unitDelay);
|
|
3702
3714
|
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3715
|
+
// We want the largest possible timer delay which will still display
|
|
3716
|
+
// accurate information while reducing unnecessary re-renders. The delay
|
|
3717
|
+
// should be until the next "interesting" moment, like a tick from
|
|
3718
|
+
// "1 minute ago" to "2 minutes ago" when the delta is 120,000ms.
|
|
3719
|
+
var delay = delta < 0 ? Math.max(updateInterval, unitDelay - unitRemainder) : Math.max(updateInterval, unitRemainder);
|
|
3708
3720
|
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3721
|
+
this._timer = setTimeout(function () {
|
|
3722
|
+
_this2.setState({ now: _this2.context.intl.now() });
|
|
3723
|
+
}, delay);
|
|
3724
|
+
}
|
|
3725
|
+
}, {
|
|
3726
|
+
key: 'componentDidMount',
|
|
3727
|
+
value: function componentDidMount() {
|
|
3728
|
+
this.scheduleNextUpdate(this.props, this.state);
|
|
3729
|
+
}
|
|
3730
|
+
}, {
|
|
3731
|
+
key: 'componentWillReceiveProps',
|
|
3732
|
+
value: function componentWillReceiveProps(_ref) {
|
|
3733
|
+
var nextValue = _ref.value;
|
|
3734
|
+
|
|
3735
|
+
// When the `props.value` date changes, `state.now` needs to be updated,
|
|
3736
|
+
// and the next update can be rescheduled.
|
|
3737
|
+
if (!isSameDate(nextValue, this.props.value)) {
|
|
3738
|
+
this.setState({ now: this.context.intl.now() });
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
}, {
|
|
3742
|
+
key: 'shouldComponentUpdate',
|
|
3743
|
+
value: function shouldComponentUpdate() {
|
|
3744
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3745
|
+
next[_key] = arguments[_key];
|
|
3746
|
+
}
|
|
3735
3747
|
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3748
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
3749
|
+
}
|
|
3750
|
+
}, {
|
|
3751
|
+
key: 'componentWillUpdate',
|
|
3752
|
+
value: function componentWillUpdate(nextProps, nextState) {
|
|
3753
|
+
this.scheduleNextUpdate(nextProps, nextState);
|
|
3754
|
+
}
|
|
3755
|
+
}, {
|
|
3756
|
+
key: 'componentWillUnmount',
|
|
3757
|
+
value: function componentWillUnmount() {
|
|
3758
|
+
clearTimeout(this._timer);
|
|
3759
|
+
}
|
|
3760
|
+
}, {
|
|
3761
|
+
key: 'render',
|
|
3762
|
+
value: function render() {
|
|
3763
|
+
var _context$intl = this.context.intl,
|
|
3764
|
+
formatRelative = _context$intl.formatRelative,
|
|
3765
|
+
Text = _context$intl.textComponent;
|
|
3766
|
+
var _props = this.props,
|
|
3767
|
+
value = _props.value,
|
|
3768
|
+
children = _props.children;
|
|
3757
3769
|
|
|
3758
3770
|
|
|
3759
|
-
|
|
3771
|
+
var formattedRelative = formatRelative(value, _extends({}, this.props, this.state));
|
|
3760
3772
|
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3773
|
+
if (typeof children === 'function') {
|
|
3774
|
+
return children(formattedRelative);
|
|
3775
|
+
}
|
|
3764
3776
|
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3777
|
+
return React__default.createElement(
|
|
3778
|
+
Text,
|
|
3779
|
+
null,
|
|
3780
|
+
formattedRelative
|
|
3781
|
+
);
|
|
3782
|
+
}
|
|
3783
|
+
}]);
|
|
3784
|
+
return FormattedRelative;
|
|
3773
3785
|
}(React.Component);
|
|
3774
3786
|
|
|
3775
3787
|
FormattedRelative.displayName = 'FormattedRelative';
|
|
3776
3788
|
FormattedRelative.contextTypes = {
|
|
3777
|
-
|
|
3789
|
+
intl: intlShape
|
|
3778
3790
|
};
|
|
3779
3791
|
FormattedRelative.defaultProps = {
|
|
3780
|
-
|
|
3792
|
+
updateInterval: 1000 * 10
|
|
3781
3793
|
};
|
|
3782
3794
|
FormattedRelative.propTypes = _extends({}, relativeFormatPropTypes, {
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3795
|
+
value: PropTypes.any.isRequired,
|
|
3796
|
+
format: PropTypes.string,
|
|
3797
|
+
updateInterval: PropTypes.number,
|
|
3798
|
+
initialNow: PropTypes.any,
|
|
3799
|
+
children: PropTypes.func
|
|
3788
3800
|
});
|
|
3789
3801
|
|
|
3790
3802
|
/*
|
|
@@ -3794,61 +3806,61 @@ FormattedRelative.propTypes = _extends({}, relativeFormatPropTypes, {
|
|
|
3794
3806
|
*/
|
|
3795
3807
|
|
|
3796
3808
|
var FormattedNumber = function (_Component) {
|
|
3797
|
-
|
|
3809
|
+
inherits(FormattedNumber, _Component);
|
|
3798
3810
|
|
|
3799
|
-
|
|
3800
|
-
|
|
3811
|
+
function FormattedNumber(props, context) {
|
|
3812
|
+
classCallCheck(this, FormattedNumber);
|
|
3801
3813
|
|
|
3802
|
-
|
|
3814
|
+
var _this = possibleConstructorReturn(this, (FormattedNumber.__proto__ || Object.getPrototypeOf(FormattedNumber)).call(this, props, context));
|
|
3803
3815
|
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3816
|
+
invariantIntlContext(context);
|
|
3817
|
+
return _this;
|
|
3818
|
+
}
|
|
3807
3819
|
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3820
|
+
createClass(FormattedNumber, [{
|
|
3821
|
+
key: 'shouldComponentUpdate',
|
|
3822
|
+
value: function shouldComponentUpdate() {
|
|
3823
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3824
|
+
next[_key] = arguments[_key];
|
|
3825
|
+
}
|
|
3814
3826
|
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3827
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
3828
|
+
}
|
|
3829
|
+
}, {
|
|
3830
|
+
key: 'render',
|
|
3831
|
+
value: function render() {
|
|
3832
|
+
var _context$intl = this.context.intl,
|
|
3833
|
+
formatNumber = _context$intl.formatNumber,
|
|
3834
|
+
Text = _context$intl.textComponent;
|
|
3835
|
+
var _props = this.props,
|
|
3836
|
+
value = _props.value,
|
|
3837
|
+
children = _props.children;
|
|
3826
3838
|
|
|
3827
3839
|
|
|
3828
|
-
|
|
3840
|
+
var formattedNumber = formatNumber(value, this.props);
|
|
3829
3841
|
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3842
|
+
if (typeof children === 'function') {
|
|
3843
|
+
return children(formattedNumber);
|
|
3844
|
+
}
|
|
3833
3845
|
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3846
|
+
return React__default.createElement(
|
|
3847
|
+
Text,
|
|
3848
|
+
null,
|
|
3849
|
+
formattedNumber
|
|
3850
|
+
);
|
|
3851
|
+
}
|
|
3852
|
+
}]);
|
|
3853
|
+
return FormattedNumber;
|
|
3842
3854
|
}(React.Component);
|
|
3843
3855
|
|
|
3844
3856
|
FormattedNumber.displayName = 'FormattedNumber';
|
|
3845
3857
|
FormattedNumber.contextTypes = {
|
|
3846
|
-
|
|
3858
|
+
intl: intlShape
|
|
3847
3859
|
};
|
|
3848
3860
|
FormattedNumber.propTypes = _extends({}, numberFormatPropTypes, {
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3861
|
+
value: PropTypes.any.isRequired,
|
|
3862
|
+
format: PropTypes.string,
|
|
3863
|
+
children: PropTypes.func
|
|
3852
3864
|
});
|
|
3853
3865
|
|
|
3854
3866
|
/*
|
|
@@ -3858,73 +3870,73 @@ FormattedNumber.propTypes = _extends({}, numberFormatPropTypes, {
|
|
|
3858
3870
|
*/
|
|
3859
3871
|
|
|
3860
3872
|
var FormattedPlural = function (_Component) {
|
|
3861
|
-
|
|
3873
|
+
inherits(FormattedPlural, _Component);
|
|
3862
3874
|
|
|
3863
|
-
|
|
3864
|
-
|
|
3875
|
+
function FormattedPlural(props, context) {
|
|
3876
|
+
classCallCheck(this, FormattedPlural);
|
|
3865
3877
|
|
|
3866
|
-
|
|
3878
|
+
var _this = possibleConstructorReturn(this, (FormattedPlural.__proto__ || Object.getPrototypeOf(FormattedPlural)).call(this, props, context));
|
|
3867
3879
|
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3880
|
+
invariantIntlContext(context);
|
|
3881
|
+
return _this;
|
|
3882
|
+
}
|
|
3871
3883
|
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3884
|
+
createClass(FormattedPlural, [{
|
|
3885
|
+
key: 'shouldComponentUpdate',
|
|
3886
|
+
value: function shouldComponentUpdate() {
|
|
3887
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3888
|
+
next[_key] = arguments[_key];
|
|
3889
|
+
}
|
|
3878
3890
|
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3891
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
3892
|
+
}
|
|
3893
|
+
}, {
|
|
3894
|
+
key: 'render',
|
|
3895
|
+
value: function render() {
|
|
3896
|
+
var _context$intl = this.context.intl,
|
|
3897
|
+
formatPlural = _context$intl.formatPlural,
|
|
3898
|
+
Text = _context$intl.textComponent;
|
|
3899
|
+
var _props = this.props,
|
|
3900
|
+
value = _props.value,
|
|
3901
|
+
other = _props.other,
|
|
3902
|
+
children = _props.children;
|
|
3903
|
+
|
|
3904
|
+
|
|
3905
|
+
var pluralCategory = formatPlural(value, this.props);
|
|
3906
|
+
var formattedPlural = this.props[pluralCategory] || other;
|
|
3907
|
+
|
|
3908
|
+
if (typeof children === 'function') {
|
|
3909
|
+
return children(formattedPlural);
|
|
3910
|
+
}
|
|
3899
3911
|
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3912
|
+
return React__default.createElement(
|
|
3913
|
+
Text,
|
|
3914
|
+
null,
|
|
3915
|
+
formattedPlural
|
|
3916
|
+
);
|
|
3917
|
+
}
|
|
3918
|
+
}]);
|
|
3919
|
+
return FormattedPlural;
|
|
3908
3920
|
}(React.Component);
|
|
3909
3921
|
|
|
3910
3922
|
FormattedPlural.displayName = 'FormattedPlural';
|
|
3911
3923
|
FormattedPlural.contextTypes = {
|
|
3912
|
-
|
|
3924
|
+
intl: intlShape
|
|
3913
3925
|
};
|
|
3914
3926
|
FormattedPlural.defaultProps = {
|
|
3915
|
-
|
|
3927
|
+
style: 'cardinal'
|
|
3916
3928
|
};
|
|
3917
3929
|
FormattedPlural.propTypes = _extends({}, pluralFormatPropTypes, {
|
|
3918
|
-
|
|
3930
|
+
value: PropTypes.any.isRequired,
|
|
3919
3931
|
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3932
|
+
other: PropTypes.node.isRequired,
|
|
3933
|
+
zero: PropTypes.node,
|
|
3934
|
+
one: PropTypes.node,
|
|
3935
|
+
two: PropTypes.node,
|
|
3936
|
+
few: PropTypes.node,
|
|
3937
|
+
many: PropTypes.node,
|
|
3926
3938
|
|
|
3927
|
-
|
|
3939
|
+
children: PropTypes.func
|
|
3928
3940
|
});
|
|
3929
3941
|
|
|
3930
3942
|
/*
|
|
@@ -3934,142 +3946,142 @@ FormattedPlural.propTypes = _extends({}, pluralFormatPropTypes, {
|
|
|
3934
3946
|
*/
|
|
3935
3947
|
|
|
3936
3948
|
var FormattedMessage = function (_Component) {
|
|
3937
|
-
|
|
3949
|
+
inherits(FormattedMessage, _Component);
|
|
3938
3950
|
|
|
3939
|
-
|
|
3940
|
-
|
|
3951
|
+
function FormattedMessage(props, context) {
|
|
3952
|
+
classCallCheck(this, FormattedMessage);
|
|
3941
3953
|
|
|
3942
|
-
|
|
3954
|
+
var _this = possibleConstructorReturn(this, (FormattedMessage.__proto__ || Object.getPrototypeOf(FormattedMessage)).call(this, props, context));
|
|
3943
3955
|
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3956
|
+
invariantIntlContext(context);
|
|
3957
|
+
return _this;
|
|
3958
|
+
}
|
|
3947
3959
|
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3960
|
+
createClass(FormattedMessage, [{
|
|
3961
|
+
key: 'shouldComponentUpdate',
|
|
3962
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
3963
|
+
var values = this.props.values;
|
|
3964
|
+
var nextValues = nextProps.values;
|
|
3953
3965
|
|
|
3954
3966
|
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3967
|
+
if (!shallowEquals(nextValues, values)) {
|
|
3968
|
+
return true;
|
|
3969
|
+
}
|
|
3958
3970
|
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3971
|
+
// Since `values` has already been checked, we know they're not
|
|
3972
|
+
// different, so the current `values` are carried over so the shallow
|
|
3973
|
+
// equals comparison on the other props isn't affected by the `values`.
|
|
3974
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
3975
|
+
values: values
|
|
3976
|
+
});
|
|
3965
3977
|
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3978
|
+
for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
3979
|
+
next[_key - 1] = arguments[_key];
|
|
3980
|
+
}
|
|
3969
3981
|
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
3982
|
+
return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
|
|
3983
|
+
}
|
|
3984
|
+
}, {
|
|
3985
|
+
key: 'render',
|
|
3986
|
+
value: function render() {
|
|
3987
|
+
var _context$intl = this.context.intl,
|
|
3988
|
+
formatMessage = _context$intl.formatMessage,
|
|
3989
|
+
Text = _context$intl.textComponent;
|
|
3990
|
+
var _props = this.props,
|
|
3991
|
+
id = _props.id,
|
|
3992
|
+
description = _props.description,
|
|
3993
|
+
defaultMessage = _props.defaultMessage,
|
|
3994
|
+
values = _props.values,
|
|
3995
|
+
_props$tagName = _props.tagName,
|
|
3996
|
+
Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
|
|
3997
|
+
children = _props.children;
|
|
3998
|
+
|
|
3999
|
+
|
|
4000
|
+
var tokenDelimiter = void 0;
|
|
4001
|
+
var tokenizedValues = void 0;
|
|
4002
|
+
var elements = void 0;
|
|
4003
|
+
|
|
4004
|
+
var hasValues = values && Object.keys(values).length > 0;
|
|
4005
|
+
if (hasValues) {
|
|
4006
|
+
// Creates a token with a random UID that should not be guessable or
|
|
4007
|
+
// conflict with other parts of the `message` string.
|
|
4008
|
+
var uid = Math.floor(Math.random() * 0x10000000000).toString(16);
|
|
4009
|
+
|
|
4010
|
+
var generateToken = function () {
|
|
4011
|
+
var counter = 0;
|
|
4012
|
+
return function () {
|
|
4013
|
+
return 'ELEMENT-' + uid + '-' + (counter += 1);
|
|
4014
|
+
};
|
|
4015
|
+
}();
|
|
4016
|
+
|
|
4017
|
+
// Splitting with a delimiter to support IE8. When using a regex
|
|
4018
|
+
// with a capture group IE8 does not include the capture group in
|
|
4019
|
+
// the resulting array.
|
|
4020
|
+
tokenDelimiter = '@__' + uid + '__@';
|
|
4021
|
+
tokenizedValues = {};
|
|
4022
|
+
elements = {};
|
|
4023
|
+
|
|
4024
|
+
// Iterates over the `props` to keep track of any React Element
|
|
4025
|
+
// values so they can be represented by the `token` as a placeholder
|
|
4026
|
+
// when the `message` is formatted. This allows the formatted
|
|
4027
|
+
// message to then be broken-up into parts with references to the
|
|
4028
|
+
// React Elements inserted back in.
|
|
4029
|
+
Object.keys(values).forEach(function (name) {
|
|
4030
|
+
var value = values[name];
|
|
4031
|
+
|
|
4032
|
+
if (React.isValidElement(value)) {
|
|
4033
|
+
var token = generateToken();
|
|
4034
|
+
tokenizedValues[name] = tokenDelimiter + token + tokenDelimiter;
|
|
4035
|
+
elements[token] = value;
|
|
4036
|
+
} else {
|
|
4037
|
+
tokenizedValues[name] = value;
|
|
4038
|
+
}
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4029
4041
|
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4042
|
+
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
4043
|
+
var formattedMessage = formatMessage(descriptor, tokenizedValues || values);
|
|
4044
|
+
|
|
4045
|
+
var nodes = void 0;
|
|
4046
|
+
|
|
4047
|
+
var hasElements = elements && Object.keys(elements).length > 0;
|
|
4048
|
+
if (hasElements) {
|
|
4049
|
+
// Split the message into parts so the React Element values captured
|
|
4050
|
+
// above can be inserted back into the rendered message. This
|
|
4051
|
+
// approach allows messages to render with React Elements while
|
|
4052
|
+
// keeping React's virtual diffing working properly.
|
|
4053
|
+
nodes = formattedMessage.split(tokenDelimiter).filter(function (part) {
|
|
4054
|
+
return !!part;
|
|
4055
|
+
}).map(function (part) {
|
|
4056
|
+
return elements[part] || part;
|
|
4057
|
+
});
|
|
4058
|
+
} else {
|
|
4059
|
+
nodes = [formattedMessage];
|
|
4060
|
+
}
|
|
4049
4061
|
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4062
|
+
if (typeof children === 'function') {
|
|
4063
|
+
return children.apply(undefined, toConsumableArray(nodes));
|
|
4064
|
+
}
|
|
4053
4065
|
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4066
|
+
// Needs to use `createElement()` instead of JSX, otherwise React will
|
|
4067
|
+
// warn about a missing `key` prop with rich-text message formatting.
|
|
4068
|
+
return React.createElement.apply(undefined, [Component$$1, null].concat(toConsumableArray(nodes)));
|
|
4069
|
+
}
|
|
4070
|
+
}]);
|
|
4071
|
+
return FormattedMessage;
|
|
4060
4072
|
}(React.Component);
|
|
4061
4073
|
|
|
4062
4074
|
FormattedMessage.displayName = 'FormattedMessage';
|
|
4063
4075
|
FormattedMessage.contextTypes = {
|
|
4064
|
-
|
|
4076
|
+
intl: intlShape
|
|
4065
4077
|
};
|
|
4066
4078
|
FormattedMessage.defaultProps = {
|
|
4067
|
-
|
|
4079
|
+
values: {}
|
|
4068
4080
|
};
|
|
4069
4081
|
FormattedMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4082
|
+
values: PropTypes.object,
|
|
4083
|
+
tagName: PropTypes.string,
|
|
4084
|
+
children: PropTypes.func
|
|
4073
4085
|
});
|
|
4074
4086
|
|
|
4075
4087
|
/*
|
|
@@ -4079,90 +4091,90 @@ FormattedMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
|
4079
4091
|
*/
|
|
4080
4092
|
|
|
4081
4093
|
var FormattedHTMLMessage = function (_Component) {
|
|
4082
|
-
|
|
4094
|
+
inherits(FormattedHTMLMessage, _Component);
|
|
4083
4095
|
|
|
4084
|
-
|
|
4085
|
-
|
|
4096
|
+
function FormattedHTMLMessage(props, context) {
|
|
4097
|
+
classCallCheck(this, FormattedHTMLMessage);
|
|
4086
4098
|
|
|
4087
|
-
|
|
4099
|
+
var _this = possibleConstructorReturn(this, (FormattedHTMLMessage.__proto__ || Object.getPrototypeOf(FormattedHTMLMessage)).call(this, props, context));
|
|
4088
4100
|
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4101
|
+
invariantIntlContext(context);
|
|
4102
|
+
return _this;
|
|
4103
|
+
}
|
|
4092
4104
|
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4105
|
+
createClass(FormattedHTMLMessage, [{
|
|
4106
|
+
key: 'shouldComponentUpdate',
|
|
4107
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
4108
|
+
var values = this.props.values;
|
|
4109
|
+
var nextValues = nextProps.values;
|
|
4098
4110
|
|
|
4099
4111
|
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4112
|
+
if (!shallowEquals(nextValues, values)) {
|
|
4113
|
+
return true;
|
|
4114
|
+
}
|
|
4103
4115
|
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4116
|
+
// Since `values` has already been checked, we know they're not
|
|
4117
|
+
// different, so the current `values` are carried over so the shallow
|
|
4118
|
+
// equals comparison on the other props isn't affected by the `values`.
|
|
4119
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
4120
|
+
values: values
|
|
4121
|
+
});
|
|
4110
4122
|
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4123
|
+
for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4124
|
+
next[_key - 1] = arguments[_key];
|
|
4125
|
+
}
|
|
4114
4126
|
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4127
|
+
return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
|
|
4128
|
+
}
|
|
4129
|
+
}, {
|
|
4130
|
+
key: 'render',
|
|
4131
|
+
value: function render() {
|
|
4132
|
+
var _context$intl = this.context.intl,
|
|
4133
|
+
formatHTMLMessage = _context$intl.formatHTMLMessage,
|
|
4134
|
+
Text = _context$intl.textComponent;
|
|
4135
|
+
var _props = this.props,
|
|
4136
|
+
id = _props.id,
|
|
4137
|
+
description = _props.description,
|
|
4138
|
+
defaultMessage = _props.defaultMessage,
|
|
4139
|
+
rawValues = _props.values,
|
|
4140
|
+
_props$tagName = _props.tagName,
|
|
4141
|
+
Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
|
|
4142
|
+
children = _props.children;
|
|
4143
|
+
|
|
4144
|
+
|
|
4145
|
+
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
4146
|
+
var formattedHTMLMessage = formatHTMLMessage(descriptor, rawValues);
|
|
4147
|
+
|
|
4148
|
+
if (typeof children === 'function') {
|
|
4149
|
+
return children(formattedHTMLMessage);
|
|
4150
|
+
}
|
|
4139
4151
|
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4152
|
+
// Since the message presumably has HTML in it, we need to set
|
|
4153
|
+
// `innerHTML` in order for it to be rendered and not escaped by React.
|
|
4154
|
+
// To be safe, all string prop values were escaped when formatting the
|
|
4155
|
+
// message. It is assumed that the message is not UGC, and came from the
|
|
4156
|
+
// developer making it more like a template.
|
|
4157
|
+
//
|
|
4158
|
+
// Note: There's a perf impact of using this component since there's no
|
|
4159
|
+
// way for React to do its virtual DOM diffing.
|
|
4160
|
+
var html = { __html: formattedHTMLMessage };
|
|
4161
|
+
return React__default.createElement(Component$$1, { dangerouslySetInnerHTML: html });
|
|
4162
|
+
}
|
|
4163
|
+
}]);
|
|
4164
|
+
return FormattedHTMLMessage;
|
|
4153
4165
|
}(React.Component);
|
|
4154
4166
|
|
|
4155
4167
|
FormattedHTMLMessage.displayName = 'FormattedHTMLMessage';
|
|
4156
4168
|
FormattedHTMLMessage.contextTypes = {
|
|
4157
|
-
|
|
4169
|
+
intl: intlShape
|
|
4158
4170
|
};
|
|
4159
4171
|
FormattedHTMLMessage.defaultProps = {
|
|
4160
|
-
|
|
4172
|
+
values: {}
|
|
4161
4173
|
};
|
|
4162
4174
|
FormattedHTMLMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4175
|
+
values: PropTypes.object,
|
|
4176
|
+
tagName: PropTypes.string,
|
|
4177
|
+
children: PropTypes.func
|
|
4166
4178
|
});
|
|
4167
4179
|
|
|
4168
4180
|
/*
|