react-intl 2.2.1 → 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/CONTRIBUTING.md +20 -0
- package/dist/react-intl.js +1017 -1475
- 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 +983 -1428
- package/lib/index.js +990 -1435
- 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 +33 -27
- package/src/components/date.js +30 -29
- package/src/components/html-message.js +63 -62
- package/src/components/message.js +117 -114
- package/src/components/number.js +30 -29
- package/src/components/plural.js +37 -36
- package/src/components/provider.js +135 -134
- package/src/components/relative.js +128 -120
- package/src/components/time.js +30 -29
- package/src/define-messages.js +3 -3
- package/src/en.js +1 -1
- package/src/format.js +209 -208
- package/src/inject.js +38 -40
- package/src/locale-data-registry.js +21 -21
- package/src/plural.js +9 -9
- package/src/types.js +58 -48
- package/src/utils.js +65 -55
- package/yarn.lock +4832 -0
package/lib/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2017, Yahoo Inc.
|
|
3
3
|
* Copyrights licensed under the New BSD License.
|
|
4
4
|
* See the accompanying LICENSE file for terms.
|
|
5
5
|
*/
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import allLocaleData from '../locale-data/index.js';
|
|
8
8
|
import IntlMessageFormat from 'intl-messageformat';
|
|
9
9
|
import IntlRelativeFormat from 'intl-relativeformat';
|
|
10
|
-
import
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import React, { Children, Component, createElement, isValidElement } from 'react';
|
|
11
12
|
import invariant from 'invariant';
|
|
12
13
|
import memoizeIntlConstructor from 'intl-format-cache';
|
|
13
14
|
|
|
@@ -18,7 +19,7 @@ var defaultLocaleData = { "locale": "en", "pluralRuleFunction": function pluralR
|
|
|
18
19
|
t0 = Number(s[0]) == n,
|
|
19
20
|
n10 = t0 && s[0].slice(-1),
|
|
20
21
|
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";
|
|
21
|
-
}, "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" } } } } };
|
|
22
|
+
}, "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" } } } } };
|
|
22
23
|
|
|
23
24
|
/*
|
|
24
25
|
* Copyright 2015, Yahoo Inc.
|
|
@@ -27,36 +28,36 @@ var defaultLocaleData = { "locale": "en", "pluralRuleFunction": function pluralR
|
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
function addLocaleData() {
|
|
30
|
-
|
|
31
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
var locales = Array.isArray(data) ? data : [data];
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
locales.forEach(function (localeData) {
|
|
36
|
+
if (localeData && localeData.locale) {
|
|
37
|
+
IntlMessageFormat.__addLocaleData(localeData);
|
|
38
|
+
IntlRelativeFormat.__addLocaleData(localeData);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
function hasLocaleData(locale) {
|
|
43
|
-
|
|
44
|
+
var localeParts = (locale || '').split('-');
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
localeParts.pop();
|
|
46
|
+
while (localeParts.length > 0) {
|
|
47
|
+
if (hasIMFAndIRFLocaleData(localeParts.join('-'))) {
|
|
48
|
+
return true;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
localeParts.pop();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
function hasIMFAndIRFLocaleData(locale) {
|
|
57
|
-
|
|
58
|
+
var normalizedLocale = locale && locale.toLowerCase();
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
return !!(IntlMessageFormat.__localeData__[normalizedLocale] && IntlRelativeFormat.__localeData__[normalizedLocale]);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
@@ -65,257 +66,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
65
66
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
var jsx = function () {
|
|
69
|
-
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;
|
|
70
|
-
return function createRawReactElement(type, props, key, children) {
|
|
71
|
-
var defaultProps = type && type.defaultProps;
|
|
72
|
-
var childrenLength = arguments.length - 3;
|
|
73
|
-
|
|
74
|
-
if (!props && childrenLength !== 0) {
|
|
75
|
-
props = {};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (props && defaultProps) {
|
|
79
|
-
for (var propName in defaultProps) {
|
|
80
|
-
if (props[propName] === void 0) {
|
|
81
|
-
props[propName] = defaultProps[propName];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} else if (!props) {
|
|
85
|
-
props = defaultProps || {};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (childrenLength === 1) {
|
|
89
|
-
props.children = children;
|
|
90
|
-
} else if (childrenLength > 1) {
|
|
91
|
-
var childArray = Array(childrenLength);
|
|
92
|
-
|
|
93
|
-
for (var i = 0; i < childrenLength; i++) {
|
|
94
|
-
childArray[i] = arguments[i + 3];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
props.children = childArray;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
102
|
-
type: type,
|
|
103
|
-
key: key === undefined ? null : '' + key,
|
|
104
|
-
ref: null,
|
|
105
|
-
props: props,
|
|
106
|
-
_owner: null
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
}();
|
|
110
|
-
|
|
111
|
-
var asyncIterator = function (iterable) {
|
|
112
|
-
if (typeof Symbol === "function") {
|
|
113
|
-
if (Symbol.asyncIterator) {
|
|
114
|
-
var method = iterable[Symbol.asyncIterator];
|
|
115
|
-
if (method != null) return method.call(iterable);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (Symbol.iterator) {
|
|
119
|
-
return iterable[Symbol.iterator]();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
throw new TypeError("Object is not async iterable");
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
var asyncGenerator = function () {
|
|
127
|
-
function AwaitValue(value) {
|
|
128
|
-
this.value = value;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function AsyncGenerator(gen) {
|
|
132
|
-
var front, back;
|
|
133
|
-
|
|
134
|
-
function send(key, arg) {
|
|
135
|
-
return new Promise(function (resolve, reject) {
|
|
136
|
-
var request = {
|
|
137
|
-
key: key,
|
|
138
|
-
arg: arg,
|
|
139
|
-
resolve: resolve,
|
|
140
|
-
reject: reject,
|
|
141
|
-
next: null
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if (back) {
|
|
145
|
-
back = back.next = request;
|
|
146
|
-
} else {
|
|
147
|
-
front = back = request;
|
|
148
|
-
resume(key, arg);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function resume(key, arg) {
|
|
154
|
-
try {
|
|
155
|
-
var result = gen[key](arg);
|
|
156
|
-
var value = result.value;
|
|
157
|
-
|
|
158
|
-
if (value instanceof AwaitValue) {
|
|
159
|
-
Promise.resolve(value.value).then(function (arg) {
|
|
160
|
-
resume("next", arg);
|
|
161
|
-
}, function (arg) {
|
|
162
|
-
resume("throw", arg);
|
|
163
|
-
});
|
|
164
|
-
} else {
|
|
165
|
-
settle(result.done ? "return" : "normal", result.value);
|
|
166
|
-
}
|
|
167
|
-
} catch (err) {
|
|
168
|
-
settle("throw", err);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function settle(type, value) {
|
|
173
|
-
switch (type) {
|
|
174
|
-
case "return":
|
|
175
|
-
front.resolve({
|
|
176
|
-
value: value,
|
|
177
|
-
done: true
|
|
178
|
-
});
|
|
179
|
-
break;
|
|
180
|
-
|
|
181
|
-
case "throw":
|
|
182
|
-
front.reject(value);
|
|
183
|
-
break;
|
|
184
|
-
|
|
185
|
-
default:
|
|
186
|
-
front.resolve({
|
|
187
|
-
value: value,
|
|
188
|
-
done: false
|
|
189
|
-
});
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
front = front.next;
|
|
194
|
-
|
|
195
|
-
if (front) {
|
|
196
|
-
resume(front.key, front.arg);
|
|
197
|
-
} else {
|
|
198
|
-
back = null;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
this._invoke = send;
|
|
203
|
-
|
|
204
|
-
if (typeof gen.return !== "function") {
|
|
205
|
-
this.return = undefined;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (typeof Symbol === "function" && Symbol.asyncIterator) {
|
|
210
|
-
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
|
|
211
|
-
return this;
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
AsyncGenerator.prototype.next = function (arg) {
|
|
216
|
-
return this._invoke("next", arg);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
AsyncGenerator.prototype.throw = function (arg) {
|
|
220
|
-
return this._invoke("throw", arg);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
AsyncGenerator.prototype.return = function (arg) {
|
|
224
|
-
return this._invoke("return", arg);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
return {
|
|
228
|
-
wrap: function (fn) {
|
|
229
|
-
return function () {
|
|
230
|
-
return new AsyncGenerator(fn.apply(this, arguments));
|
|
231
|
-
};
|
|
232
|
-
},
|
|
233
|
-
await: function (value) {
|
|
234
|
-
return new AwaitValue(value);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
}();
|
|
238
|
-
|
|
239
|
-
var asyncGeneratorDelegate = function (inner, awaitWrap) {
|
|
240
|
-
var iter = {},
|
|
241
|
-
waiting = false;
|
|
242
69
|
|
|
243
|
-
function pump(key, value) {
|
|
244
|
-
waiting = true;
|
|
245
|
-
value = new Promise(function (resolve) {
|
|
246
|
-
resolve(inner[key](value));
|
|
247
|
-
});
|
|
248
|
-
return {
|
|
249
|
-
done: false,
|
|
250
|
-
value: awaitWrap(value)
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
70
|
|
|
254
|
-
|
|
255
71
|
|
|
256
|
-
if (typeof Symbol === "function" && Symbol.iterator) {
|
|
257
|
-
iter[Symbol.iterator] = function () {
|
|
258
|
-
return this;
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
72
|
|
|
262
|
-
iter.next = function (value) {
|
|
263
|
-
if (waiting) {
|
|
264
|
-
waiting = false;
|
|
265
|
-
return value;
|
|
266
|
-
}
|
|
267
73
|
|
|
268
|
-
return pump("next", value);
|
|
269
|
-
};
|
|
270
74
|
|
|
271
|
-
if (typeof inner.throw === "function") {
|
|
272
|
-
iter.throw = function (value) {
|
|
273
|
-
if (waiting) {
|
|
274
|
-
waiting = false;
|
|
275
|
-
throw value;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return pump("throw", value);
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (typeof inner.return === "function") {
|
|
283
|
-
iter.return = function (value) {
|
|
284
|
-
return pump("return", value);
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return iter;
|
|
289
|
-
};
|
|
290
75
|
|
|
291
|
-
var asyncToGenerator = function (fn) {
|
|
292
|
-
return function () {
|
|
293
|
-
var gen = fn.apply(this, arguments);
|
|
294
|
-
return new Promise(function (resolve, reject) {
|
|
295
|
-
function step(key, arg) {
|
|
296
|
-
try {
|
|
297
|
-
var info = gen[key](arg);
|
|
298
|
-
var value = info.value;
|
|
299
|
-
} catch (error) {
|
|
300
|
-
reject(error);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
76
|
|
|
304
|
-
if (info.done) {
|
|
305
|
-
resolve(value);
|
|
306
|
-
} else {
|
|
307
|
-
return Promise.resolve(value).then(function (value) {
|
|
308
|
-
step("next", value);
|
|
309
|
-
}, function (err) {
|
|
310
|
-
step("throw", err);
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
77
|
|
|
315
|
-
return step("next");
|
|
316
|
-
});
|
|
317
|
-
};
|
|
318
|
-
};
|
|
319
78
|
|
|
320
79
|
var classCallCheck = function (instance, Constructor) {
|
|
321
80
|
if (!(instance instanceof Constructor)) {
|
|
@@ -341,31 +100,9 @@ var createClass = function () {
|
|
|
341
100
|
};
|
|
342
101
|
}();
|
|
343
102
|
|
|
344
|
-
var defineEnumerableProperties = function (obj, descs) {
|
|
345
|
-
for (var key in descs) {
|
|
346
|
-
var desc = descs[key];
|
|
347
|
-
desc.configurable = desc.enumerable = true;
|
|
348
|
-
if ("value" in desc) desc.writable = true;
|
|
349
|
-
Object.defineProperty(obj, key, desc);
|
|
350
|
-
}
|
|
351
103
|
|
|
352
|
-
return obj;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
var defaults = function (obj, defaults) {
|
|
356
|
-
var keys = Object.getOwnPropertyNames(defaults);
|
|
357
104
|
|
|
358
|
-
for (var i = 0; i < keys.length; i++) {
|
|
359
|
-
var key = keys[i];
|
|
360
|
-
var value = Object.getOwnPropertyDescriptor(defaults, key);
|
|
361
|
-
|
|
362
|
-
if (value && value.configurable && obj[key] === undefined) {
|
|
363
|
-
Object.defineProperty(obj, key, value);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
105
|
|
|
367
|
-
return obj;
|
|
368
|
-
};
|
|
369
106
|
|
|
370
107
|
var defineProperty = function (obj, key, value) {
|
|
371
108
|
if (key in obj) {
|
|
@@ -396,30 +133,7 @@ var _extends = Object.assign || function (target) {
|
|
|
396
133
|
return target;
|
|
397
134
|
};
|
|
398
135
|
|
|
399
|
-
var get = function get(object, property, receiver) {
|
|
400
|
-
if (object === null) object = Function.prototype;
|
|
401
|
-
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
402
136
|
|
|
403
|
-
if (desc === undefined) {
|
|
404
|
-
var parent = Object.getPrototypeOf(object);
|
|
405
|
-
|
|
406
|
-
if (parent === null) {
|
|
407
|
-
return undefined;
|
|
408
|
-
} else {
|
|
409
|
-
return get(parent, property, receiver);
|
|
410
|
-
}
|
|
411
|
-
} else if ("value" in desc) {
|
|
412
|
-
return desc.value;
|
|
413
|
-
} else {
|
|
414
|
-
var getter = desc.get;
|
|
415
|
-
|
|
416
|
-
if (getter === undefined) {
|
|
417
|
-
return undefined;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return getter.call(receiver);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
137
|
|
|
424
138
|
var inherits = function (subClass, superClass) {
|
|
425
139
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -437,46 +151,13 @@ var inherits = function (subClass, superClass) {
|
|
|
437
151
|
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
438
152
|
};
|
|
439
153
|
|
|
440
|
-
var _instanceof = function (left, right) {
|
|
441
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
442
|
-
return right[Symbol.hasInstance](left);
|
|
443
|
-
} else {
|
|
444
|
-
return left instanceof right;
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
154
|
|
|
448
|
-
var interopRequireDefault = function (obj) {
|
|
449
|
-
return obj && obj.__esModule ? obj : {
|
|
450
|
-
default: obj
|
|
451
|
-
};
|
|
452
|
-
};
|
|
453
155
|
|
|
454
|
-
var interopRequireWildcard = function (obj) {
|
|
455
|
-
if (obj && obj.__esModule) {
|
|
456
|
-
return obj;
|
|
457
|
-
} else {
|
|
458
|
-
var newObj = {};
|
|
459
156
|
|
|
460
|
-
if (obj != null) {
|
|
461
|
-
for (var key in obj) {
|
|
462
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
157
|
|
|
466
|
-
newObj.default = obj;
|
|
467
|
-
return newObj;
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
158
|
|
|
471
|
-
var newArrowCheck = function (innerThis, boundThis) {
|
|
472
|
-
if (innerThis !== boundThis) {
|
|
473
|
-
throw new TypeError("Cannot instantiate an arrow function");
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
159
|
|
|
477
|
-
|
|
478
|
-
if (obj == null) throw new TypeError("Cannot destructure undefined");
|
|
479
|
-
};
|
|
160
|
+
|
|
480
161
|
|
|
481
162
|
var objectWithoutProperties = function (obj, keys) {
|
|
482
163
|
var target = {};
|
|
@@ -498,112 +179,23 @@ var possibleConstructorReturn = function (self, call) {
|
|
|
498
179
|
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
499
180
|
};
|
|
500
181
|
|
|
501
|
-
var selfGlobal = typeof global === "undefined" ? self : global;
|
|
502
|
-
|
|
503
|
-
var set = function set(object, property, value, receiver) {
|
|
504
|
-
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
505
182
|
|
|
506
|
-
if (desc === undefined) {
|
|
507
|
-
var parent = Object.getPrototypeOf(object);
|
|
508
183
|
|
|
509
|
-
if (parent !== null) {
|
|
510
|
-
set(parent, property, value, receiver);
|
|
511
|
-
}
|
|
512
|
-
} else if ("value" in desc && desc.writable) {
|
|
513
|
-
desc.value = value;
|
|
514
|
-
} else {
|
|
515
|
-
var setter = desc.set;
|
|
516
184
|
|
|
517
|
-
if (setter !== undefined) {
|
|
518
|
-
setter.call(receiver, value);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
185
|
|
|
522
|
-
return value;
|
|
523
|
-
};
|
|
524
186
|
|
|
525
|
-
var slicedToArray = function () {
|
|
526
|
-
function sliceIterator(arr, i) {
|
|
527
|
-
var _arr = [];
|
|
528
|
-
var _n = true;
|
|
529
|
-
var _d = false;
|
|
530
|
-
var _e = undefined;
|
|
531
187
|
|
|
532
|
-
try {
|
|
533
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
534
|
-
_arr.push(_s.value);
|
|
535
188
|
|
|
536
|
-
if (i && _arr.length === i) break;
|
|
537
|
-
}
|
|
538
|
-
} catch (err) {
|
|
539
|
-
_d = true;
|
|
540
|
-
_e = err;
|
|
541
|
-
} finally {
|
|
542
|
-
try {
|
|
543
|
-
if (!_n && _i["return"]) _i["return"]();
|
|
544
|
-
} finally {
|
|
545
|
-
if (_d) throw _e;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
return _arr;
|
|
550
|
-
}
|
|
551
189
|
|
|
552
|
-
return function (arr, i) {
|
|
553
|
-
if (Array.isArray(arr)) {
|
|
554
|
-
return arr;
|
|
555
|
-
} else if (Symbol.iterator in Object(arr)) {
|
|
556
|
-
return sliceIterator(arr, i);
|
|
557
|
-
} else {
|
|
558
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
}();
|
|
562
190
|
|
|
563
|
-
var slicedToArrayLoose = function (arr, i) {
|
|
564
|
-
if (Array.isArray(arr)) {
|
|
565
|
-
return arr;
|
|
566
|
-
} else if (Symbol.iterator in Object(arr)) {
|
|
567
|
-
var _arr = [];
|
|
568
191
|
|
|
569
|
-
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
|
570
|
-
_arr.push(_step.value);
|
|
571
192
|
|
|
572
|
-
if (i && _arr.length === i) break;
|
|
573
|
-
}
|
|
574
193
|
|
|
575
|
-
return _arr;
|
|
576
|
-
} else {
|
|
577
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
194
|
|
|
581
|
-
var taggedTemplateLiteral = function (strings, raw) {
|
|
582
|
-
return Object.freeze(Object.defineProperties(strings, {
|
|
583
|
-
raw: {
|
|
584
|
-
value: Object.freeze(raw)
|
|
585
|
-
}
|
|
586
|
-
}));
|
|
587
|
-
};
|
|
588
195
|
|
|
589
|
-
var taggedTemplateLiteralLoose = function (strings, raw) {
|
|
590
|
-
strings.raw = raw;
|
|
591
|
-
return strings;
|
|
592
|
-
};
|
|
593
196
|
|
|
594
|
-
var temporalRef = function (val, name, undef) {
|
|
595
|
-
if (val === undef) {
|
|
596
|
-
throw new ReferenceError(name + " is not defined - temporal dead zone");
|
|
597
|
-
} else {
|
|
598
|
-
return val;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
197
|
|
|
602
|
-
var temporalUndefined = {};
|
|
603
198
|
|
|
604
|
-
var toArray = function (arr) {
|
|
605
|
-
return Array.isArray(arr) ? arr : Array.from(arr);
|
|
606
|
-
};
|
|
607
199
|
|
|
608
200
|
var toConsumableArray = function (arr) {
|
|
609
201
|
if (Array.isArray(arr)) {
|
|
@@ -615,42 +207,6 @@ var toConsumableArray = function (arr) {
|
|
|
615
207
|
}
|
|
616
208
|
};
|
|
617
209
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
var babelHelpers$1 = Object.freeze({
|
|
621
|
-
jsx: jsx,
|
|
622
|
-
asyncIterator: asyncIterator,
|
|
623
|
-
asyncGenerator: asyncGenerator,
|
|
624
|
-
asyncGeneratorDelegate: asyncGeneratorDelegate,
|
|
625
|
-
asyncToGenerator: asyncToGenerator,
|
|
626
|
-
classCallCheck: classCallCheck,
|
|
627
|
-
createClass: createClass,
|
|
628
|
-
defineEnumerableProperties: defineEnumerableProperties,
|
|
629
|
-
defaults: defaults,
|
|
630
|
-
defineProperty: defineProperty,
|
|
631
|
-
get: get,
|
|
632
|
-
inherits: inherits,
|
|
633
|
-
interopRequireDefault: interopRequireDefault,
|
|
634
|
-
interopRequireWildcard: interopRequireWildcard,
|
|
635
|
-
newArrowCheck: newArrowCheck,
|
|
636
|
-
objectDestructuringEmpty: objectDestructuringEmpty,
|
|
637
|
-
objectWithoutProperties: objectWithoutProperties,
|
|
638
|
-
possibleConstructorReturn: possibleConstructorReturn,
|
|
639
|
-
selfGlobal: selfGlobal,
|
|
640
|
-
set: set,
|
|
641
|
-
slicedToArray: slicedToArray,
|
|
642
|
-
slicedToArrayLoose: slicedToArrayLoose,
|
|
643
|
-
taggedTemplateLiteral: taggedTemplateLiteral,
|
|
644
|
-
taggedTemplateLiteralLoose: taggedTemplateLiteralLoose,
|
|
645
|
-
temporalRef: temporalRef,
|
|
646
|
-
temporalUndefined: temporalUndefined,
|
|
647
|
-
toArray: toArray,
|
|
648
|
-
toConsumableArray: toConsumableArray,
|
|
649
|
-
typeof: _typeof,
|
|
650
|
-
extends: _extends,
|
|
651
|
-
instanceof: _instanceof
|
|
652
|
-
});
|
|
653
|
-
|
|
654
210
|
/*
|
|
655
211
|
* Copyright 2015, Yahoo Inc.
|
|
656
212
|
* Copyrights licensed under the New BSD License.
|
|
@@ -665,6 +221,7 @@ var object = PropTypes.object;
|
|
|
665
221
|
var oneOf = PropTypes.oneOf;
|
|
666
222
|
var shape = PropTypes.shape;
|
|
667
223
|
var any = PropTypes.any;
|
|
224
|
+
var oneOfType = PropTypes.oneOfType;
|
|
668
225
|
|
|
669
226
|
var localeMatcher = oneOf(['best fit', 'lookup']);
|
|
670
227
|
var narrowShortLong = oneOf(['narrow', 'short', 'long']);
|
|
@@ -672,76 +229,76 @@ var numeric2digit = oneOf(['numeric', '2-digit']);
|
|
|
672
229
|
var funcReq = func.isRequired;
|
|
673
230
|
|
|
674
231
|
var intlConfigPropTypes = {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
232
|
+
locale: string,
|
|
233
|
+
formats: object,
|
|
234
|
+
messages: object,
|
|
235
|
+
textComponent: any,
|
|
679
236
|
|
|
680
|
-
|
|
681
|
-
|
|
237
|
+
defaultLocale: string,
|
|
238
|
+
defaultFormats: object
|
|
682
239
|
};
|
|
683
240
|
|
|
684
241
|
var intlFormatPropTypes = {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
242
|
+
formatDate: funcReq,
|
|
243
|
+
formatTime: funcReq,
|
|
244
|
+
formatRelative: funcReq,
|
|
245
|
+
formatNumber: funcReq,
|
|
246
|
+
formatPlural: funcReq,
|
|
247
|
+
formatMessage: funcReq,
|
|
248
|
+
formatHTMLMessage: funcReq
|
|
692
249
|
};
|
|
693
250
|
|
|
694
|
-
var intlShape = shape(
|
|
695
|
-
|
|
696
|
-
|
|
251
|
+
var intlShape = shape(_extends({}, intlConfigPropTypes, intlFormatPropTypes, {
|
|
252
|
+
formatters: object,
|
|
253
|
+
now: funcReq
|
|
697
254
|
}));
|
|
698
255
|
|
|
699
256
|
var messageDescriptorPropTypes = {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
257
|
+
id: string.isRequired,
|
|
258
|
+
description: oneOfType([string, object]),
|
|
259
|
+
defaultMessage: string
|
|
703
260
|
};
|
|
704
261
|
|
|
705
262
|
var dateTimeFormatPropTypes = {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
263
|
+
localeMatcher: localeMatcher,
|
|
264
|
+
formatMatcher: oneOf(['basic', 'best fit']),
|
|
265
|
+
|
|
266
|
+
timeZone: string,
|
|
267
|
+
hour12: bool,
|
|
268
|
+
|
|
269
|
+
weekday: narrowShortLong,
|
|
270
|
+
era: narrowShortLong,
|
|
271
|
+
year: numeric2digit,
|
|
272
|
+
month: oneOf(['numeric', '2-digit', 'narrow', 'short', 'long']),
|
|
273
|
+
day: numeric2digit,
|
|
274
|
+
hour: numeric2digit,
|
|
275
|
+
minute: numeric2digit,
|
|
276
|
+
second: numeric2digit,
|
|
277
|
+
timeZoneName: oneOf(['short', 'long'])
|
|
721
278
|
};
|
|
722
279
|
|
|
723
280
|
var numberFormatPropTypes = {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
281
|
+
localeMatcher: localeMatcher,
|
|
282
|
+
|
|
283
|
+
style: oneOf(['decimal', 'currency', 'percent']),
|
|
284
|
+
currency: string,
|
|
285
|
+
currencyDisplay: oneOf(['symbol', 'code', 'name']),
|
|
286
|
+
useGrouping: bool,
|
|
287
|
+
|
|
288
|
+
minimumIntegerDigits: number,
|
|
289
|
+
minimumFractionDigits: number,
|
|
290
|
+
maximumFractionDigits: number,
|
|
291
|
+
minimumSignificantDigits: number,
|
|
292
|
+
maximumSignificantDigits: number
|
|
736
293
|
};
|
|
737
294
|
|
|
738
295
|
var relativeFormatPropTypes = {
|
|
739
|
-
|
|
740
|
-
|
|
296
|
+
style: oneOf(['best fit', 'numeric']),
|
|
297
|
+
units: oneOf(['second', 'minute', 'hour', 'day', 'month', 'year'])
|
|
741
298
|
};
|
|
742
299
|
|
|
743
300
|
var pluralFormatPropTypes = {
|
|
744
|
-
|
|
301
|
+
style: oneOf(['cardinal', 'ordinal'])
|
|
745
302
|
};
|
|
746
303
|
|
|
747
304
|
/*
|
|
@@ -758,82 +315,82 @@ file in the root directory of React's source tree.
|
|
|
758
315
|
var intlConfigPropNames = Object.keys(intlConfigPropTypes);
|
|
759
316
|
|
|
760
317
|
var ESCAPED_CHARS = {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
318
|
+
'&': '&',
|
|
319
|
+
'>': '>',
|
|
320
|
+
'<': '<',
|
|
321
|
+
'"': '"',
|
|
322
|
+
"'": '''
|
|
766
323
|
};
|
|
767
324
|
|
|
768
325
|
var UNSAFE_CHARS_REGEX = /[&><"']/g;
|
|
769
326
|
|
|
770
327
|
function escape(str) {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
328
|
+
return ('' + str).replace(UNSAFE_CHARS_REGEX, function (match) {
|
|
329
|
+
return ESCAPED_CHARS[match];
|
|
330
|
+
});
|
|
774
331
|
}
|
|
775
332
|
|
|
776
333
|
function filterProps(props, whitelist) {
|
|
777
|
-
|
|
334
|
+
var defaults$$1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
778
335
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
336
|
+
return whitelist.reduce(function (filtered, name) {
|
|
337
|
+
if (props.hasOwnProperty(name)) {
|
|
338
|
+
filtered[name] = props[name];
|
|
339
|
+
} else if (defaults$$1.hasOwnProperty(name)) {
|
|
340
|
+
filtered[name] = defaults$$1[name];
|
|
341
|
+
}
|
|
785
342
|
|
|
786
|
-
|
|
787
|
-
|
|
343
|
+
return filtered;
|
|
344
|
+
}, {});
|
|
788
345
|
}
|
|
789
346
|
|
|
790
347
|
function invariantIntlContext() {
|
|
791
|
-
|
|
792
|
-
|
|
348
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
349
|
+
intl = _ref.intl;
|
|
793
350
|
|
|
794
|
-
|
|
351
|
+
invariant(intl, '[React Intl] Could not find required `intl` object. ' + '<IntlProvider> needs to exist in the component ancestry.');
|
|
795
352
|
}
|
|
796
353
|
|
|
797
354
|
function shallowEquals(objA, objB) {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
355
|
+
if (objA === objB) {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
801
358
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
359
|
+
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
805
362
|
|
|
806
|
-
|
|
807
|
-
|
|
363
|
+
var keysA = Object.keys(objA);
|
|
364
|
+
var keysB = Object.keys(objB);
|
|
808
365
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
366
|
+
if (keysA.length !== keysB.length) {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
812
369
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
370
|
+
// Test for A's keys different from B.
|
|
371
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
372
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
373
|
+
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
|
|
374
|
+
return false;
|
|
819
375
|
}
|
|
376
|
+
}
|
|
820
377
|
|
|
821
|
-
|
|
378
|
+
return true;
|
|
822
379
|
}
|
|
823
380
|
|
|
824
381
|
function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
382
|
+
var props = _ref2.props,
|
|
383
|
+
state = _ref2.state,
|
|
384
|
+
_ref2$context = _ref2.context,
|
|
385
|
+
context = _ref2$context === undefined ? {} : _ref2$context;
|
|
386
|
+
var nextContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
387
|
+
var _context$intl = context.intl,
|
|
388
|
+
intl = _context$intl === undefined ? {} : _context$intl;
|
|
389
|
+
var _nextContext$intl = nextContext.intl,
|
|
390
|
+
nextIntl = _nextContext$intl === undefined ? {} : _nextContext$intl;
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
return !shallowEquals(nextProps, props) || !shallowEquals(nextState, state) || !(nextIntl === intl || shallowEquals(filterProps(nextIntl, intlConfigPropNames), filterProps(intl, intlConfigPropNames)));
|
|
837
394
|
}
|
|
838
395
|
|
|
839
396
|
/*
|
|
@@ -846,54 +403,54 @@ function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
|
|
|
846
403
|
// https://github.com/rackt/react-redux
|
|
847
404
|
|
|
848
405
|
function getDisplayName(Component$$1) {
|
|
849
|
-
|
|
406
|
+
return Component$$1.displayName || Component$$1.name || 'Component';
|
|
850
407
|
}
|
|
851
408
|
|
|
852
409
|
function injectIntl(WrappedComponent) {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
var InjectIntl = function (_Component) {
|
|
860
|
-
inherits(InjectIntl, _Component);
|
|
410
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
411
|
+
var _options$intlPropName = options.intlPropName,
|
|
412
|
+
intlPropName = _options$intlPropName === undefined ? 'intl' : _options$intlPropName,
|
|
413
|
+
_options$withRef = options.withRef,
|
|
414
|
+
withRef = _options$withRef === undefined ? false : _options$withRef;
|
|
861
415
|
|
|
862
|
-
|
|
863
|
-
|
|
416
|
+
var InjectIntl = function (_Component) {
|
|
417
|
+
inherits(InjectIntl, _Component);
|
|
864
418
|
|
|
865
|
-
|
|
419
|
+
function InjectIntl(props, context) {
|
|
420
|
+
classCallCheck(this, InjectIntl);
|
|
866
421
|
|
|
867
|
-
|
|
868
|
-
return _this;
|
|
869
|
-
}
|
|
422
|
+
var _this = possibleConstructorReturn(this, (InjectIntl.__proto__ || Object.getPrototypeOf(InjectIntl)).call(this, props, context));
|
|
870
423
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
invariant(withRef, '[React Intl] To access the wrapped instance, ' + 'the `{withRef: true}` option must be set when calling: ' + '`injectIntl()`');
|
|
875
|
-
|
|
876
|
-
return this.refs.wrappedInstance;
|
|
877
|
-
}
|
|
878
|
-
}, {
|
|
879
|
-
key: 'render',
|
|
880
|
-
value: function render() {
|
|
881
|
-
return React.createElement(WrappedComponent, babelHelpers$1['extends']({}, this.props, defineProperty({}, intlPropName, this.context.intl), {
|
|
882
|
-
ref: withRef ? 'wrappedInstance' : null
|
|
883
|
-
}));
|
|
884
|
-
}
|
|
885
|
-
}]);
|
|
886
|
-
return InjectIntl;
|
|
887
|
-
}(Component);
|
|
888
|
-
|
|
889
|
-
InjectIntl.displayName = 'InjectIntl(' + getDisplayName(WrappedComponent) + ')';
|
|
890
|
-
InjectIntl.contextTypes = {
|
|
891
|
-
intl: intlShape
|
|
892
|
-
};
|
|
893
|
-
InjectIntl.WrappedComponent = WrappedComponent;
|
|
424
|
+
invariantIntlContext(context);
|
|
425
|
+
return _this;
|
|
426
|
+
}
|
|
894
427
|
|
|
428
|
+
createClass(InjectIntl, [{
|
|
429
|
+
key: 'getWrappedInstance',
|
|
430
|
+
value: function getWrappedInstance() {
|
|
431
|
+
invariant(withRef, '[React Intl] To access the wrapped instance, ' + 'the `{withRef: true}` option must be set when calling: ' + '`injectIntl()`');
|
|
895
432
|
|
|
433
|
+
return this.refs.wrappedInstance;
|
|
434
|
+
}
|
|
435
|
+
}, {
|
|
436
|
+
key: 'render',
|
|
437
|
+
value: function render() {
|
|
438
|
+
return React.createElement(WrappedComponent, _extends({}, this.props, defineProperty({}, intlPropName, this.context.intl), {
|
|
439
|
+
ref: withRef ? 'wrappedInstance' : null
|
|
440
|
+
}));
|
|
441
|
+
}
|
|
442
|
+
}]);
|
|
896
443
|
return InjectIntl;
|
|
444
|
+
}(Component);
|
|
445
|
+
|
|
446
|
+
InjectIntl.displayName = 'InjectIntl(' + getDisplayName(WrappedComponent) + ')';
|
|
447
|
+
InjectIntl.contextTypes = {
|
|
448
|
+
intl: intlShape
|
|
449
|
+
};
|
|
450
|
+
InjectIntl.WrappedComponent = WrappedComponent;
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
return InjectIntl;
|
|
897
454
|
}
|
|
898
455
|
|
|
899
456
|
/*
|
|
@@ -917,25 +474,25 @@ function defineMessages(messageDescriptors) {
|
|
|
917
474
|
// This is a "hack" until a proper `intl-pluralformat` package is created.
|
|
918
475
|
|
|
919
476
|
function resolveLocale(locales) {
|
|
920
|
-
|
|
921
|
-
|
|
477
|
+
// IntlMessageFormat#_resolveLocale() does not depend on `this`.
|
|
478
|
+
return IntlMessageFormat.prototype._resolveLocale(locales);
|
|
922
479
|
}
|
|
923
480
|
|
|
924
481
|
function findPluralFunction(locale) {
|
|
925
|
-
|
|
926
|
-
|
|
482
|
+
// IntlMessageFormat#_findPluralFunction() does not depend on `this`.
|
|
483
|
+
return IntlMessageFormat.prototype._findPluralRuleFunction(locale);
|
|
927
484
|
}
|
|
928
485
|
|
|
929
486
|
var IntlPluralFormat = function IntlPluralFormat(locales) {
|
|
930
|
-
|
|
931
|
-
|
|
487
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
488
|
+
classCallCheck(this, IntlPluralFormat);
|
|
932
489
|
|
|
933
|
-
|
|
934
|
-
|
|
490
|
+
var useOrdinal = options.style === 'ordinal';
|
|
491
|
+
var pluralFn = findPluralFunction(resolveLocale(locales));
|
|
935
492
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
493
|
+
this.format = function (value) {
|
|
494
|
+
return pluralFn(value, useOrdinal);
|
|
495
|
+
};
|
|
939
496
|
};
|
|
940
497
|
|
|
941
498
|
/*
|
|
@@ -950,234 +507,234 @@ var RELATIVE_FORMAT_OPTIONS = Object.keys(relativeFormatPropTypes);
|
|
|
950
507
|
var PLURAL_FORMAT_OPTIONS = Object.keys(pluralFormatPropTypes);
|
|
951
508
|
|
|
952
509
|
var RELATIVE_FORMAT_THRESHOLDS = {
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
510
|
+
second: 60, // seconds to minute
|
|
511
|
+
minute: 60, // minutes to hour
|
|
512
|
+
hour: 24, // hours to day
|
|
513
|
+
day: 30, // days to month
|
|
514
|
+
month: 12 // months to year
|
|
515
|
+
};
|
|
958
516
|
|
|
959
517
|
function updateRelativeFormatThresholds(newThresholds) {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
518
|
+
var thresholds = IntlRelativeFormat.thresholds;
|
|
519
|
+
thresholds.second = newThresholds.second;
|
|
520
|
+
thresholds.minute = newThresholds.minute;
|
|
521
|
+
thresholds.hour = newThresholds.hour;
|
|
522
|
+
thresholds.day = newThresholds.day;
|
|
523
|
+
thresholds.month = newThresholds.month;
|
|
966
524
|
}
|
|
967
525
|
|
|
968
526
|
function getNamedFormat(formats, type, name) {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
527
|
+
var format = formats && formats[type] && formats[type][name];
|
|
528
|
+
if (format) {
|
|
529
|
+
return format;
|
|
530
|
+
}
|
|
973
531
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
532
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
533
|
+
console.error('[React Intl] No ' + type + ' format named: ' + name);
|
|
534
|
+
}
|
|
977
535
|
}
|
|
978
536
|
|
|
979
537
|
function formatDate(config, state, value) {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
538
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
539
|
+
var locale = config.locale,
|
|
540
|
+
formats = config.formats;
|
|
541
|
+
var format = options.format;
|
|
984
542
|
|
|
985
543
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
544
|
+
var date = new Date(value);
|
|
545
|
+
var defaults$$1 = format && getNamedFormat(formats, 'date', format);
|
|
546
|
+
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
989
547
|
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
}
|
|
548
|
+
try {
|
|
549
|
+
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
550
|
+
} catch (e) {
|
|
551
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
552
|
+
console.error('[React Intl] Error formatting date.\n' + e);
|
|
996
553
|
}
|
|
554
|
+
}
|
|
997
555
|
|
|
998
|
-
|
|
556
|
+
return String(date);
|
|
999
557
|
}
|
|
1000
558
|
|
|
1001
559
|
function formatTime(config, state, value) {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
560
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
561
|
+
var locale = config.locale,
|
|
562
|
+
formats = config.formats;
|
|
563
|
+
var format = options.format;
|
|
1006
564
|
|
|
1007
565
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
566
|
+
var date = new Date(value);
|
|
567
|
+
var defaults$$1 = format && getNamedFormat(formats, 'time', format);
|
|
568
|
+
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);
|
|
1011
569
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
570
|
+
if (!filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second) {
|
|
571
|
+
// Add default formatting options if hour, minute, or second isn't defined.
|
|
572
|
+
filteredOptions = _extends({}, filteredOptions, { hour: 'numeric', minute: 'numeric' });
|
|
573
|
+
}
|
|
1016
574
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
}
|
|
575
|
+
try {
|
|
576
|
+
return state.getDateTimeFormat(locale, filteredOptions).format(date);
|
|
577
|
+
} catch (e) {
|
|
578
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
579
|
+
console.error('[React Intl] Error formatting time.\n' + e);
|
|
1023
580
|
}
|
|
581
|
+
}
|
|
1024
582
|
|
|
1025
|
-
|
|
583
|
+
return String(date);
|
|
1026
584
|
}
|
|
1027
585
|
|
|
1028
586
|
function formatRelative(config, state, value) {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
587
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
588
|
+
var locale = config.locale,
|
|
589
|
+
formats = config.formats;
|
|
590
|
+
var format = options.format;
|
|
1033
591
|
|
|
1034
592
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
593
|
+
var date = new Date(value);
|
|
594
|
+
var now = new Date(options.now);
|
|
595
|
+
var defaults$$1 = format && getNamedFormat(formats, 'relative', format);
|
|
596
|
+
var filteredOptions = filterProps(options, RELATIVE_FORMAT_OPTIONS, defaults$$1);
|
|
1039
597
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
598
|
+
// Capture the current threshold values, then temporarily override them with
|
|
599
|
+
// specific values just for this render.
|
|
600
|
+
var oldThresholds = _extends({}, IntlRelativeFormat.thresholds);
|
|
601
|
+
updateRelativeFormatThresholds(RELATIVE_FORMAT_THRESHOLDS);
|
|
1044
602
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
}
|
|
1053
|
-
} finally {
|
|
1054
|
-
updateRelativeFormatThresholds(oldThresholds);
|
|
603
|
+
try {
|
|
604
|
+
return state.getRelativeFormat(locale, filteredOptions).format(date, {
|
|
605
|
+
now: isFinite(now) ? now : state.now()
|
|
606
|
+
});
|
|
607
|
+
} catch (e) {
|
|
608
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
609
|
+
console.error('[React Intl] Error formatting relative time.\n' + e);
|
|
1055
610
|
}
|
|
611
|
+
} finally {
|
|
612
|
+
updateRelativeFormatThresholds(oldThresholds);
|
|
613
|
+
}
|
|
1056
614
|
|
|
1057
|
-
|
|
615
|
+
return String(date);
|
|
1058
616
|
}
|
|
1059
617
|
|
|
1060
618
|
function formatNumber(config, state, value) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
619
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
620
|
+
var locale = config.locale,
|
|
621
|
+
formats = config.formats;
|
|
622
|
+
var format = options.format;
|
|
1065
623
|
|
|
1066
624
|
|
|
1067
|
-
|
|
1068
|
-
|
|
625
|
+
var defaults$$1 = format && getNamedFormat(formats, 'number', format);
|
|
626
|
+
var filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults$$1);
|
|
1069
627
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
}
|
|
628
|
+
try {
|
|
629
|
+
return state.getNumberFormat(locale, filteredOptions).format(value);
|
|
630
|
+
} catch (e) {
|
|
631
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
632
|
+
console.error('[React Intl] Error formatting number.\n' + e);
|
|
1076
633
|
}
|
|
634
|
+
}
|
|
1077
635
|
|
|
1078
|
-
|
|
636
|
+
return String(value);
|
|
1079
637
|
}
|
|
1080
638
|
|
|
1081
639
|
function formatPlural(config, state, value) {
|
|
1082
|
-
|
|
1083
|
-
|
|
640
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
641
|
+
var locale = config.locale;
|
|
1084
642
|
|
|
1085
643
|
|
|
1086
|
-
|
|
644
|
+
var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
1087
645
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
}
|
|
646
|
+
try {
|
|
647
|
+
return state.getPluralFormat(locale, filteredOptions).format(value);
|
|
648
|
+
} catch (e) {
|
|
649
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
650
|
+
console.error('[React Intl] Error formatting plural.\n' + e);
|
|
1094
651
|
}
|
|
652
|
+
}
|
|
1095
653
|
|
|
1096
|
-
|
|
654
|
+
return 'other';
|
|
1097
655
|
}
|
|
1098
656
|
|
|
1099
657
|
function formatMessage(config, state) {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
var formattedMessage = void 0;
|
|
658
|
+
var messageDescriptor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
659
|
+
var values = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
660
|
+
var locale = config.locale,
|
|
661
|
+
formats = config.formats,
|
|
662
|
+
messages = config.messages,
|
|
663
|
+
defaultLocale = config.defaultLocale,
|
|
664
|
+
defaultFormats = config.defaultFormats;
|
|
665
|
+
var id = messageDescriptor.id,
|
|
666
|
+
defaultMessage = messageDescriptor.defaultMessage;
|
|
667
|
+
|
|
668
|
+
// `id` is a required field of a Message Descriptor.
|
|
669
|
+
|
|
670
|
+
invariant(id, '[React Intl] An `id` must be provided to format a message.');
|
|
671
|
+
|
|
672
|
+
var message = messages && messages[id];
|
|
673
|
+
var hasValues = Object.keys(values).length > 0;
|
|
674
|
+
|
|
675
|
+
// Avoid expensive message formatting for simple messages without values. In
|
|
676
|
+
// development messages will always be formatted in case of missing values.
|
|
677
|
+
if (!hasValues && process.env.NODE_ENV === 'production') {
|
|
678
|
+
return message || defaultMessage || id;
|
|
679
|
+
}
|
|
1124
680
|
|
|
1125
|
-
|
|
1126
|
-
try {
|
|
1127
|
-
var formatter = state.getMessageFormat(message, locale, formats);
|
|
681
|
+
var formattedMessage = void 0;
|
|
1128
682
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
} else {
|
|
1136
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1137
|
-
// This prevents warnings from littering the console in development
|
|
1138
|
-
// when no `messages` are passed into the <IntlProvider> for the
|
|
1139
|
-
// default locale, and a default message is in the source.
|
|
1140
|
-
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
683
|
+
if (message) {
|
|
684
|
+
try {
|
|
685
|
+
var formatter = state.getMessageFormat(message, locale, formats);
|
|
1141
686
|
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
687
|
+
formattedMessage = formatter.format(values);
|
|
688
|
+
} catch (e) {
|
|
689
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
690
|
+
console.error('[React Intl] Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '') + ('\n' + e));
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
} else {
|
|
694
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
695
|
+
// This prevents warnings from littering the console in development
|
|
696
|
+
// when no `messages` are passed into the <IntlProvider> for the
|
|
697
|
+
// default locale, and a default message is in the source.
|
|
698
|
+
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
699
|
+
console.error('[React Intl] Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''));
|
|
700
|
+
}
|
|
1145
701
|
}
|
|
702
|
+
}
|
|
1146
703
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
704
|
+
if (!formattedMessage && defaultMessage) {
|
|
705
|
+
try {
|
|
706
|
+
var _formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats);
|
|
1150
707
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
}
|
|
708
|
+
formattedMessage = _formatter.format(values);
|
|
709
|
+
} catch (e) {
|
|
710
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
711
|
+
console.error('[React Intl] Error formatting the default message for: "' + id + '"' + ('\n' + e));
|
|
712
|
+
}
|
|
1157
713
|
}
|
|
714
|
+
}
|
|
1158
715
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
}
|
|
716
|
+
if (!formattedMessage) {
|
|
717
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
718
|
+
console.error('[React Intl] Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.'));
|
|
1163
719
|
}
|
|
720
|
+
}
|
|
1164
721
|
|
|
1165
|
-
|
|
722
|
+
return formattedMessage || message || defaultMessage || id;
|
|
1166
723
|
}
|
|
1167
724
|
|
|
1168
725
|
function formatHTMLMessage(config, state, messageDescriptor) {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
726
|
+
var rawValues = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
727
|
+
|
|
728
|
+
// Process all the values before they are used when formatting the ICU
|
|
729
|
+
// Message string. Since the formatted message might be injected via
|
|
730
|
+
// `innerHTML`, all String-based values need to be HTML-escaped.
|
|
731
|
+
var escapedValues = Object.keys(rawValues).reduce(function (escaped, name) {
|
|
732
|
+
var value = rawValues[name];
|
|
733
|
+
escaped[name] = typeof value === 'string' ? escape(value) : value;
|
|
734
|
+
return escaped;
|
|
735
|
+
}, {});
|
|
736
|
+
|
|
737
|
+
return formatMessage(config, state, messageDescriptor, escapedValues);
|
|
1181
738
|
}
|
|
1182
739
|
|
|
1183
740
|
|
|
@@ -1204,170 +761,170 @@ var intlFormatPropNames = Object.keys(intlFormatPropTypes);
|
|
|
1204
761
|
// These are not a static property on the `IntlProvider` class so the intl
|
|
1205
762
|
// config values can be inherited from an <IntlProvider> ancestor.
|
|
1206
763
|
var defaultProps = {
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
764
|
+
formats: {},
|
|
765
|
+
messages: {},
|
|
766
|
+
textComponent: 'span',
|
|
1210
767
|
|
|
1211
|
-
|
|
1212
|
-
|
|
768
|
+
defaultLocale: 'en',
|
|
769
|
+
defaultFormats: {}
|
|
1213
770
|
};
|
|
1214
771
|
|
|
1215
772
|
var IntlProvider = function (_Component) {
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
function IntlProvider(props) {
|
|
1219
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1220
|
-
classCallCheck(this, IntlProvider);
|
|
773
|
+
inherits(IntlProvider, _Component);
|
|
1221
774
|
|
|
1222
|
-
|
|
775
|
+
function IntlProvider(props) {
|
|
776
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
777
|
+
classCallCheck(this, IntlProvider);
|
|
1223
778
|
|
|
1224
|
-
|
|
779
|
+
var _this = possibleConstructorReturn(this, (IntlProvider.__proto__ || Object.getPrototypeOf(IntlProvider)).call(this, props, context));
|
|
1225
780
|
|
|
1226
|
-
|
|
781
|
+
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/');
|
|
1227
782
|
|
|
1228
|
-
|
|
1229
|
-
// all relative times use the same reference "now" time.
|
|
783
|
+
var intlContext = context.intl;
|
|
1230
784
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
initialNow = Number(props.initialNow);
|
|
1234
|
-
} else {
|
|
1235
|
-
// When an `initialNow` isn't provided via `props`, look to see an
|
|
1236
|
-
// <IntlProvider> exists in the ancestry and call its `now()`
|
|
1237
|
-
// function to propagate its value for "now".
|
|
1238
|
-
initialNow = intlContext ? intlContext.now() : Date.now();
|
|
1239
|
-
}
|
|
785
|
+
// Used to stabilize time when performing an initial rendering so that
|
|
786
|
+
// all relative times use the same reference "now" time.
|
|
1240
787
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
getDateTimeFormat: memoizeIntlConstructor(Intl.DateTimeFormat),
|
|
1250
|
-
getNumberFormat: memoizeIntlConstructor(Intl.NumberFormat),
|
|
1251
|
-
getMessageFormat: memoizeIntlConstructor(IntlMessageFormat),
|
|
1252
|
-
getRelativeFormat: memoizeIntlConstructor(IntlRelativeFormat),
|
|
1253
|
-
getPluralFormat: memoizeIntlConstructor(IntlPluralFormat)
|
|
1254
|
-
} : _ref$formatters;
|
|
1255
|
-
|
|
1256
|
-
_this.state = babelHelpers$1['extends']({}, formatters, {
|
|
1257
|
-
|
|
1258
|
-
// Wrapper to provide stable "now" time for initial render.
|
|
1259
|
-
now: function now() {
|
|
1260
|
-
return _this._didDisplay ? Date.now() : initialNow;
|
|
1261
|
-
}
|
|
1262
|
-
});
|
|
1263
|
-
return _this;
|
|
788
|
+
var initialNow = void 0;
|
|
789
|
+
if (isFinite(props.initialNow)) {
|
|
790
|
+
initialNow = Number(props.initialNow);
|
|
791
|
+
} else {
|
|
792
|
+
// When an `initialNow` isn't provided via `props`, look to see an
|
|
793
|
+
// <IntlProvider> exists in the ancestry and call its `now()`
|
|
794
|
+
// function to propagate its value for "now".
|
|
795
|
+
initialNow = intlContext ? intlContext.now() : Date.now();
|
|
1264
796
|
}
|
|
1265
797
|
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1293
|
-
console.error('[React Intl] Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'));
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
// Since there's no registered locale data for `locale`, this will
|
|
1297
|
-
// fallback to the `defaultLocale` to make sure things can render.
|
|
1298
|
-
// The `messages` are overridden to the `defaultProps` empty object
|
|
1299
|
-
// to maintain referential equality across re-renders. It's assumed
|
|
1300
|
-
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
1301
|
-
config = babelHelpers$1['extends']({}, config, {
|
|
1302
|
-
locale: defaultLocale,
|
|
1303
|
-
formats: defaultFormats,
|
|
1304
|
-
messages: defaultProps.messages
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
return config;
|
|
1309
|
-
}
|
|
1310
|
-
}, {
|
|
1311
|
-
key: 'getBoundFormatFns',
|
|
1312
|
-
value: function getBoundFormatFns(config, state) {
|
|
1313
|
-
return intlFormatPropNames.reduce(function (boundFormatFns, name) {
|
|
1314
|
-
boundFormatFns[name] = format[name].bind(null, config, state);
|
|
1315
|
-
return boundFormatFns;
|
|
1316
|
-
}, {});
|
|
1317
|
-
}
|
|
1318
|
-
}, {
|
|
1319
|
-
key: 'getChildContext',
|
|
1320
|
-
value: function getChildContext() {
|
|
1321
|
-
var config = this.getConfig();
|
|
798
|
+
// Creating `Intl*` formatters is expensive. If there's a parent
|
|
799
|
+
// `<IntlProvider>`, then its formatters will be used. Otherwise, this
|
|
800
|
+
// memoize the `Intl*` constructors and cache them for the lifecycle of
|
|
801
|
+
// this IntlProvider instance.
|
|
802
|
+
|
|
803
|
+
var _ref = intlContext || {},
|
|
804
|
+
_ref$formatters = _ref.formatters,
|
|
805
|
+
formatters = _ref$formatters === undefined ? {
|
|
806
|
+
getDateTimeFormat: memoizeIntlConstructor(Intl.DateTimeFormat),
|
|
807
|
+
getNumberFormat: memoizeIntlConstructor(Intl.NumberFormat),
|
|
808
|
+
getMessageFormat: memoizeIntlConstructor(IntlMessageFormat),
|
|
809
|
+
getRelativeFormat: memoizeIntlConstructor(IntlRelativeFormat),
|
|
810
|
+
getPluralFormat: memoizeIntlConstructor(IntlPluralFormat)
|
|
811
|
+
} : _ref$formatters;
|
|
812
|
+
|
|
813
|
+
_this.state = _extends({}, formatters, {
|
|
814
|
+
|
|
815
|
+
// Wrapper to provide stable "now" time for initial render.
|
|
816
|
+
now: function now() {
|
|
817
|
+
return _this._didDisplay ? Date.now() : initialNow;
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
return _this;
|
|
821
|
+
}
|
|
1322
822
|
|
|
1323
|
-
|
|
1324
|
-
|
|
823
|
+
createClass(IntlProvider, [{
|
|
824
|
+
key: 'getConfig',
|
|
825
|
+
value: function getConfig() {
|
|
826
|
+
var intlContext = this.context.intl;
|
|
1325
827
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
formatters = objectWithoutProperties(_state, ['now']);
|
|
828
|
+
// Build a whitelisted config object from `props`, defaults, and
|
|
829
|
+
// `context.intl`, if an <IntlProvider> exists in the ancestry.
|
|
1329
830
|
|
|
831
|
+
var config = filterProps(this.props, intlConfigPropNames$1, intlContext);
|
|
1330
832
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
833
|
+
// Apply default props. This must be applied last after the props have
|
|
834
|
+
// been resolved and inherited from any <IntlProvider> in the ancestry.
|
|
835
|
+
// This matches how React resolves `defaultProps`.
|
|
836
|
+
for (var propName in defaultProps) {
|
|
837
|
+
if (config[propName] === undefined) {
|
|
838
|
+
config[propName] = defaultProps[propName];
|
|
1337
839
|
}
|
|
1338
|
-
|
|
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
|
-
}
|
|
840
|
+
}
|
|
1344
841
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
value: function render() {
|
|
1355
|
-
return Children.only(this.props.children);
|
|
842
|
+
if (!hasLocaleData(config.locale)) {
|
|
843
|
+
var _config = config,
|
|
844
|
+
locale = _config.locale,
|
|
845
|
+
defaultLocale = _config.defaultLocale,
|
|
846
|
+
defaultFormats = _config.defaultFormats;
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
850
|
+
console.error('[React Intl] Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'));
|
|
1356
851
|
}
|
|
1357
|
-
|
|
1358
|
-
|
|
852
|
+
|
|
853
|
+
// Since there's no registered locale data for `locale`, this will
|
|
854
|
+
// fallback to the `defaultLocale` to make sure things can render.
|
|
855
|
+
// The `messages` are overridden to the `defaultProps` empty object
|
|
856
|
+
// to maintain referential equality across re-renders. It's assumed
|
|
857
|
+
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
858
|
+
config = _extends({}, config, {
|
|
859
|
+
locale: defaultLocale,
|
|
860
|
+
formats: defaultFormats,
|
|
861
|
+
messages: defaultProps.messages
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
return config;
|
|
866
|
+
}
|
|
867
|
+
}, {
|
|
868
|
+
key: 'getBoundFormatFns',
|
|
869
|
+
value: function getBoundFormatFns(config, state) {
|
|
870
|
+
return intlFormatPropNames.reduce(function (boundFormatFns, name) {
|
|
871
|
+
boundFormatFns[name] = format[name].bind(null, config, state);
|
|
872
|
+
return boundFormatFns;
|
|
873
|
+
}, {});
|
|
874
|
+
}
|
|
875
|
+
}, {
|
|
876
|
+
key: 'getChildContext',
|
|
877
|
+
value: function getChildContext() {
|
|
878
|
+
var config = this.getConfig();
|
|
879
|
+
|
|
880
|
+
// Bind intl factories and current config to the format functions.
|
|
881
|
+
var boundFormatFns = this.getBoundFormatFns(config, this.state);
|
|
882
|
+
|
|
883
|
+
var _state = this.state,
|
|
884
|
+
now = _state.now,
|
|
885
|
+
formatters = objectWithoutProperties(_state, ['now']);
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
return {
|
|
889
|
+
intl: _extends({}, config, boundFormatFns, {
|
|
890
|
+
formatters: formatters,
|
|
891
|
+
now: now
|
|
892
|
+
})
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
}, {
|
|
896
|
+
key: 'shouldComponentUpdate',
|
|
897
|
+
value: function shouldComponentUpdate() {
|
|
898
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
899
|
+
next[_key] = arguments[_key];
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
903
|
+
}
|
|
904
|
+
}, {
|
|
905
|
+
key: 'componentDidMount',
|
|
906
|
+
value: function componentDidMount() {
|
|
907
|
+
this._didDisplay = true;
|
|
908
|
+
}
|
|
909
|
+
}, {
|
|
910
|
+
key: 'render',
|
|
911
|
+
value: function render() {
|
|
912
|
+
return Children.only(this.props.children);
|
|
913
|
+
}
|
|
914
|
+
}]);
|
|
915
|
+
return IntlProvider;
|
|
1359
916
|
}(Component);
|
|
1360
917
|
|
|
1361
918
|
IntlProvider.displayName = 'IntlProvider';
|
|
1362
919
|
IntlProvider.contextTypes = {
|
|
1363
|
-
|
|
920
|
+
intl: intlShape
|
|
1364
921
|
};
|
|
1365
922
|
IntlProvider.childContextTypes = {
|
|
1366
|
-
|
|
923
|
+
intl: intlShape.isRequired
|
|
1367
924
|
};
|
|
1368
|
-
process.env.NODE_ENV !== "production" ? IntlProvider.propTypes =
|
|
1369
|
-
|
|
1370
|
-
|
|
925
|
+
process.env.NODE_ENV !== "production" ? IntlProvider.propTypes = _extends({}, intlConfigPropTypes, {
|
|
926
|
+
children: PropTypes.element.isRequired,
|
|
927
|
+
initialNow: PropTypes.any
|
|
1371
928
|
}) : void 0;
|
|
1372
929
|
|
|
1373
930
|
/*
|
|
@@ -1377,61 +934,61 @@ process.env.NODE_ENV !== "production" ? IntlProvider.propTypes = babelHelpers$1[
|
|
|
1377
934
|
*/
|
|
1378
935
|
|
|
1379
936
|
var FormattedDate = function (_Component) {
|
|
1380
|
-
|
|
937
|
+
inherits(FormattedDate, _Component);
|
|
1381
938
|
|
|
1382
|
-
|
|
1383
|
-
|
|
939
|
+
function FormattedDate(props, context) {
|
|
940
|
+
classCallCheck(this, FormattedDate);
|
|
1384
941
|
|
|
1385
|
-
|
|
942
|
+
var _this = possibleConstructorReturn(this, (FormattedDate.__proto__ || Object.getPrototypeOf(FormattedDate)).call(this, props, context));
|
|
1386
943
|
|
|
1387
|
-
|
|
1388
|
-
|
|
944
|
+
invariantIntlContext(context);
|
|
945
|
+
return _this;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
createClass(FormattedDate, [{
|
|
949
|
+
key: 'shouldComponentUpdate',
|
|
950
|
+
value: function shouldComponentUpdate() {
|
|
951
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
952
|
+
next[_key] = arguments[_key];
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1389
956
|
}
|
|
957
|
+
}, {
|
|
958
|
+
key: 'render',
|
|
959
|
+
value: function render() {
|
|
960
|
+
var _context$intl = this.context.intl,
|
|
961
|
+
formatDate = _context$intl.formatDate,
|
|
962
|
+
Text = _context$intl.textComponent;
|
|
963
|
+
var _props = this.props,
|
|
964
|
+
value = _props.value,
|
|
965
|
+
children = _props.children;
|
|
1390
966
|
|
|
1391
|
-
createClass(FormattedDate, [{
|
|
1392
|
-
key: 'shouldComponentUpdate',
|
|
1393
|
-
value: function shouldComponentUpdate() {
|
|
1394
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1395
|
-
next[_key] = arguments[_key];
|
|
1396
|
-
}
|
|
1397
967
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
if (typeof children === 'function') {
|
|
1414
|
-
return children(formattedDate);
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
return React.createElement(
|
|
1418
|
-
Text,
|
|
1419
|
-
null,
|
|
1420
|
-
formattedDate
|
|
1421
|
-
);
|
|
1422
|
-
}
|
|
1423
|
-
}]);
|
|
1424
|
-
return FormattedDate;
|
|
968
|
+
var formattedDate = formatDate(value, this.props);
|
|
969
|
+
|
|
970
|
+
if (typeof children === 'function') {
|
|
971
|
+
return children(formattedDate);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
return React.createElement(
|
|
975
|
+
Text,
|
|
976
|
+
null,
|
|
977
|
+
formattedDate
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
}]);
|
|
981
|
+
return FormattedDate;
|
|
1425
982
|
}(Component);
|
|
1426
983
|
|
|
1427
984
|
FormattedDate.displayName = 'FormattedDate';
|
|
1428
985
|
FormattedDate.contextTypes = {
|
|
1429
|
-
|
|
986
|
+
intl: intlShape
|
|
1430
987
|
};
|
|
1431
|
-
process.env.NODE_ENV !== "production" ? FormattedDate.propTypes =
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
988
|
+
process.env.NODE_ENV !== "production" ? FormattedDate.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
989
|
+
value: PropTypes.any.isRequired,
|
|
990
|
+
format: PropTypes.string,
|
|
991
|
+
children: PropTypes.func
|
|
1435
992
|
}) : void 0;
|
|
1436
993
|
|
|
1437
994
|
/*
|
|
@@ -1441,61 +998,61 @@ process.env.NODE_ENV !== "production" ? FormattedDate.propTypes = babelHelpers$1
|
|
|
1441
998
|
*/
|
|
1442
999
|
|
|
1443
1000
|
var FormattedTime = function (_Component) {
|
|
1444
|
-
|
|
1001
|
+
inherits(FormattedTime, _Component);
|
|
1445
1002
|
|
|
1446
|
-
|
|
1447
|
-
|
|
1003
|
+
function FormattedTime(props, context) {
|
|
1004
|
+
classCallCheck(this, FormattedTime);
|
|
1448
1005
|
|
|
1449
|
-
|
|
1006
|
+
var _this = possibleConstructorReturn(this, (FormattedTime.__proto__ || Object.getPrototypeOf(FormattedTime)).call(this, props, context));
|
|
1450
1007
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1008
|
+
invariantIntlContext(context);
|
|
1009
|
+
return _this;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
createClass(FormattedTime, [{
|
|
1013
|
+
key: 'shouldComponentUpdate',
|
|
1014
|
+
value: function shouldComponentUpdate() {
|
|
1015
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1016
|
+
next[_key] = arguments[_key];
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1453
1020
|
}
|
|
1021
|
+
}, {
|
|
1022
|
+
key: 'render',
|
|
1023
|
+
value: function render() {
|
|
1024
|
+
var _context$intl = this.context.intl,
|
|
1025
|
+
formatTime = _context$intl.formatTime,
|
|
1026
|
+
Text = _context$intl.textComponent;
|
|
1027
|
+
var _props = this.props,
|
|
1028
|
+
value = _props.value,
|
|
1029
|
+
children = _props.children;
|
|
1454
1030
|
|
|
1455
|
-
createClass(FormattedTime, [{
|
|
1456
|
-
key: 'shouldComponentUpdate',
|
|
1457
|
-
value: function shouldComponentUpdate() {
|
|
1458
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1459
|
-
next[_key] = arguments[_key];
|
|
1460
|
-
}
|
|
1461
1031
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
if (typeof children === 'function') {
|
|
1478
|
-
return children(formattedTime);
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
return React.createElement(
|
|
1482
|
-
Text,
|
|
1483
|
-
null,
|
|
1484
|
-
formattedTime
|
|
1485
|
-
);
|
|
1486
|
-
}
|
|
1487
|
-
}]);
|
|
1488
|
-
return FormattedTime;
|
|
1032
|
+
var formattedTime = formatTime(value, this.props);
|
|
1033
|
+
|
|
1034
|
+
if (typeof children === 'function') {
|
|
1035
|
+
return children(formattedTime);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
return React.createElement(
|
|
1039
|
+
Text,
|
|
1040
|
+
null,
|
|
1041
|
+
formattedTime
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
}]);
|
|
1045
|
+
return FormattedTime;
|
|
1489
1046
|
}(Component);
|
|
1490
1047
|
|
|
1491
1048
|
FormattedTime.displayName = 'FormattedTime';
|
|
1492
1049
|
FormattedTime.contextTypes = {
|
|
1493
|
-
|
|
1050
|
+
intl: intlShape
|
|
1494
1051
|
};
|
|
1495
|
-
process.env.NODE_ENV !== "production" ? FormattedTime.propTypes =
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1052
|
+
process.env.NODE_ENV !== "production" ? FormattedTime.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
1053
|
+
value: PropTypes.any.isRequired,
|
|
1054
|
+
format: PropTypes.string,
|
|
1055
|
+
children: PropTypes.func
|
|
1499
1056
|
}) : void 0;
|
|
1500
1057
|
|
|
1501
1058
|
/*
|
|
@@ -1514,177 +1071,179 @@ var DAY = 1000 * 60 * 60 * 24;
|
|
|
1514
1071
|
var MAX_TIMER_DELAY = 2147483647;
|
|
1515
1072
|
|
|
1516
1073
|
function selectUnits(delta) {
|
|
1517
|
-
|
|
1074
|
+
var absDelta = Math.abs(delta);
|
|
1518
1075
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1076
|
+
if (absDelta < MINUTE) {
|
|
1077
|
+
return 'second';
|
|
1078
|
+
}
|
|
1522
1079
|
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1080
|
+
if (absDelta < HOUR) {
|
|
1081
|
+
return 'minute';
|
|
1082
|
+
}
|
|
1526
1083
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1084
|
+
if (absDelta < DAY) {
|
|
1085
|
+
return 'hour';
|
|
1086
|
+
}
|
|
1530
1087
|
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1088
|
+
// The maximum scheduled delay will be measured in days since the maximum
|
|
1089
|
+
// timer delay is less than the number of milliseconds in 25 days.
|
|
1090
|
+
return 'day';
|
|
1534
1091
|
}
|
|
1535
1092
|
|
|
1536
1093
|
function getUnitDelay(units) {
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1094
|
+
switch (units) {
|
|
1095
|
+
case 'second':
|
|
1096
|
+
return SECOND;
|
|
1097
|
+
case 'minute':
|
|
1098
|
+
return MINUTE;
|
|
1099
|
+
case 'hour':
|
|
1100
|
+
return HOUR;
|
|
1101
|
+
case 'day':
|
|
1102
|
+
return DAY;
|
|
1103
|
+
default:
|
|
1104
|
+
return MAX_TIMER_DELAY;
|
|
1105
|
+
}
|
|
1549
1106
|
}
|
|
1550
1107
|
|
|
1551
1108
|
function isSameDate(a, b) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1109
|
+
if (a === b) {
|
|
1110
|
+
return true;
|
|
1111
|
+
}
|
|
1555
1112
|
|
|
1556
|
-
|
|
1557
|
-
|
|
1113
|
+
var aTime = new Date(a).getTime();
|
|
1114
|
+
var bTime = new Date(b).getTime();
|
|
1558
1115
|
|
|
1559
|
-
|
|
1116
|
+
return isFinite(aTime) && isFinite(bTime) && aTime === bTime;
|
|
1560
1117
|
}
|
|
1561
1118
|
|
|
1562
1119
|
var FormattedRelative = function (_Component) {
|
|
1563
|
-
|
|
1120
|
+
inherits(FormattedRelative, _Component);
|
|
1564
1121
|
|
|
1565
|
-
|
|
1566
|
-
|
|
1122
|
+
function FormattedRelative(props, context) {
|
|
1123
|
+
classCallCheck(this, FormattedRelative);
|
|
1567
1124
|
|
|
1568
|
-
|
|
1125
|
+
var _this = possibleConstructorReturn(this, (FormattedRelative.__proto__ || Object.getPrototypeOf(FormattedRelative)).call(this, props, context));
|
|
1569
1126
|
|
|
1570
|
-
|
|
1127
|
+
invariantIntlContext(context);
|
|
1571
1128
|
|
|
1572
|
-
|
|
1129
|
+
var now = isFinite(props.initialNow) ? Number(props.initialNow) : context.intl.now();
|
|
1573
1130
|
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1131
|
+
// `now` is stored as state so that `render()` remains a function of
|
|
1132
|
+
// props + state, instead of accessing `Date.now()` inside `render()`.
|
|
1133
|
+
_this.state = { now: now };
|
|
1134
|
+
return _this;
|
|
1135
|
+
}
|
|
1579
1136
|
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1137
|
+
createClass(FormattedRelative, [{
|
|
1138
|
+
key: 'scheduleNextUpdate',
|
|
1139
|
+
value: function scheduleNextUpdate(props, state) {
|
|
1140
|
+
var _this2 = this;
|
|
1584
1141
|
|
|
1585
|
-
|
|
1142
|
+
// Cancel and pending update because we're scheduling a new update.
|
|
1143
|
+
clearTimeout(this._timer);
|
|
1586
1144
|
|
|
1587
|
-
|
|
1588
|
-
|
|
1145
|
+
var value = props.value,
|
|
1146
|
+
units = props.units,
|
|
1147
|
+
updateInterval = props.updateInterval;
|
|
1589
1148
|
|
|
1590
|
-
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1149
|
+
var time = new Date(value).getTime();
|
|
1593
1150
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1151
|
+
// If the `updateInterval` is falsy, including `0` or we don't have a
|
|
1152
|
+
// valid date, then auto updates have been turned off, so we bail and
|
|
1153
|
+
// skip scheduling an update.
|
|
1154
|
+
if (!updateInterval || !isFinite(time)) {
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1597
1157
|
|
|
1598
|
-
|
|
1599
|
-
|
|
1158
|
+
var delta = time - state.now;
|
|
1159
|
+
var unitDelay = getUnitDelay(units || selectUnits(delta));
|
|
1160
|
+
var unitRemainder = Math.abs(delta % unitDelay);
|
|
1600
1161
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1162
|
+
// We want the largest possible timer delay which will still display
|
|
1163
|
+
// accurate information while reducing unnecessary re-renders. The delay
|
|
1164
|
+
// should be until the next "interesting" moment, like a tick from
|
|
1165
|
+
// "1 minute ago" to "2 minutes ago" when the delta is 120,000ms.
|
|
1166
|
+
var delay = delta < 0 ? Math.max(updateInterval, unitDelay - unitRemainder) : Math.max(updateInterval, unitRemainder);
|
|
1606
1167
|
|
|
1607
|
-
|
|
1168
|
+
this._timer = setTimeout(function () {
|
|
1169
|
+
_this2.setState({ now: _this2.context.intl.now() });
|
|
1170
|
+
}, delay);
|
|
1171
|
+
}
|
|
1172
|
+
}, {
|
|
1173
|
+
key: 'componentDidMount',
|
|
1174
|
+
value: function componentDidMount() {
|
|
1175
|
+
this.scheduleNextUpdate(this.props, this.state);
|
|
1176
|
+
}
|
|
1177
|
+
}, {
|
|
1178
|
+
key: 'componentWillReceiveProps',
|
|
1179
|
+
value: function componentWillReceiveProps(_ref) {
|
|
1180
|
+
var nextValue = _ref.value;
|
|
1181
|
+
|
|
1182
|
+
// When the `props.value` date changes, `state.now` needs to be updated,
|
|
1183
|
+
// and the next update can be rescheduled.
|
|
1184
|
+
if (!isSameDate(nextValue, this.props.value)) {
|
|
1185
|
+
this.setState({ now: this.context.intl.now() });
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}, {
|
|
1189
|
+
key: 'shouldComponentUpdate',
|
|
1190
|
+
value: function shouldComponentUpdate() {
|
|
1191
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1192
|
+
next[_key] = arguments[_key];
|
|
1193
|
+
}
|
|
1608
1194
|
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
key: 'shouldComponentUpdate',
|
|
1631
|
-
value: function shouldComponentUpdate() {
|
|
1632
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1633
|
-
next[_key] = arguments[_key];
|
|
1634
|
-
}
|
|
1195
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1196
|
+
}
|
|
1197
|
+
}, {
|
|
1198
|
+
key: 'componentWillUpdate',
|
|
1199
|
+
value: function componentWillUpdate(nextProps, nextState) {
|
|
1200
|
+
this.scheduleNextUpdate(nextProps, nextState);
|
|
1201
|
+
}
|
|
1202
|
+
}, {
|
|
1203
|
+
key: 'componentWillUnmount',
|
|
1204
|
+
value: function componentWillUnmount() {
|
|
1205
|
+
clearTimeout(this._timer);
|
|
1206
|
+
}
|
|
1207
|
+
}, {
|
|
1208
|
+
key: 'render',
|
|
1209
|
+
value: function render() {
|
|
1210
|
+
var _context$intl = this.context.intl,
|
|
1211
|
+
formatRelative = _context$intl.formatRelative,
|
|
1212
|
+
Text = _context$intl.textComponent;
|
|
1213
|
+
var _props = this.props,
|
|
1214
|
+
value = _props.value,
|
|
1215
|
+
children = _props.children;
|
|
1635
1216
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
var _context$intl = this.context.intl,
|
|
1652
|
-
formatRelative = _context$intl.formatRelative,
|
|
1653
|
-
Text = _context$intl.textComponent;
|
|
1654
|
-
var _props = this.props,
|
|
1655
|
-
value = _props.value,
|
|
1656
|
-
children = _props.children;
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
var formattedRelative = formatRelative(value, babelHelpers$1['extends']({}, this.props, this.state));
|
|
1660
|
-
|
|
1661
|
-
if (typeof children === 'function') {
|
|
1662
|
-
return children(formattedRelative);
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
return React.createElement(
|
|
1666
|
-
Text,
|
|
1667
|
-
null,
|
|
1668
|
-
formattedRelative
|
|
1669
|
-
);
|
|
1670
|
-
}
|
|
1671
|
-
}]);
|
|
1672
|
-
return FormattedRelative;
|
|
1217
|
+
|
|
1218
|
+
var formattedRelative = formatRelative(value, _extends({}, this.props, this.state));
|
|
1219
|
+
|
|
1220
|
+
if (typeof children === 'function') {
|
|
1221
|
+
return children(formattedRelative);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
return React.createElement(
|
|
1225
|
+
Text,
|
|
1226
|
+
null,
|
|
1227
|
+
formattedRelative
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
}]);
|
|
1231
|
+
return FormattedRelative;
|
|
1673
1232
|
}(Component);
|
|
1674
1233
|
|
|
1675
1234
|
FormattedRelative.displayName = 'FormattedRelative';
|
|
1676
1235
|
FormattedRelative.contextTypes = {
|
|
1677
|
-
|
|
1236
|
+
intl: intlShape
|
|
1678
1237
|
};
|
|
1679
1238
|
FormattedRelative.defaultProps = {
|
|
1680
|
-
|
|
1239
|
+
updateInterval: 1000 * 10
|
|
1681
1240
|
};
|
|
1682
|
-
process.env.NODE_ENV !== "production" ? FormattedRelative.propTypes =
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1241
|
+
process.env.NODE_ENV !== "production" ? FormattedRelative.propTypes = _extends({}, relativeFormatPropTypes, {
|
|
1242
|
+
value: PropTypes.any.isRequired,
|
|
1243
|
+
format: PropTypes.string,
|
|
1244
|
+
updateInterval: PropTypes.number,
|
|
1245
|
+
initialNow: PropTypes.any,
|
|
1246
|
+
children: PropTypes.func
|
|
1688
1247
|
}) : void 0;
|
|
1689
1248
|
|
|
1690
1249
|
/*
|
|
@@ -1694,61 +1253,61 @@ process.env.NODE_ENV !== "production" ? FormattedRelative.propTypes = babelHelpe
|
|
|
1694
1253
|
*/
|
|
1695
1254
|
|
|
1696
1255
|
var FormattedNumber = function (_Component) {
|
|
1697
|
-
|
|
1256
|
+
inherits(FormattedNumber, _Component);
|
|
1698
1257
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1258
|
+
function FormattedNumber(props, context) {
|
|
1259
|
+
classCallCheck(this, FormattedNumber);
|
|
1701
1260
|
|
|
1702
|
-
|
|
1261
|
+
var _this = possibleConstructorReturn(this, (FormattedNumber.__proto__ || Object.getPrototypeOf(FormattedNumber)).call(this, props, context));
|
|
1262
|
+
|
|
1263
|
+
invariantIntlContext(context);
|
|
1264
|
+
return _this;
|
|
1265
|
+
}
|
|
1703
1266
|
|
|
1704
|
-
|
|
1705
|
-
|
|
1267
|
+
createClass(FormattedNumber, [{
|
|
1268
|
+
key: 'shouldComponentUpdate',
|
|
1269
|
+
value: function shouldComponentUpdate() {
|
|
1270
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1271
|
+
next[_key] = arguments[_key];
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1706
1275
|
}
|
|
1276
|
+
}, {
|
|
1277
|
+
key: 'render',
|
|
1278
|
+
value: function render() {
|
|
1279
|
+
var _context$intl = this.context.intl,
|
|
1280
|
+
formatNumber = _context$intl.formatNumber,
|
|
1281
|
+
Text = _context$intl.textComponent;
|
|
1282
|
+
var _props = this.props,
|
|
1283
|
+
value = _props.value,
|
|
1284
|
+
children = _props.children;
|
|
1707
1285
|
|
|
1708
|
-
createClass(FormattedNumber, [{
|
|
1709
|
-
key: 'shouldComponentUpdate',
|
|
1710
|
-
value: function shouldComponentUpdate() {
|
|
1711
|
-
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1712
|
-
next[_key] = arguments[_key];
|
|
1713
|
-
}
|
|
1714
1286
|
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
if (typeof children === 'function') {
|
|
1731
|
-
return children(formattedNumber);
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
return React.createElement(
|
|
1735
|
-
Text,
|
|
1736
|
-
null,
|
|
1737
|
-
formattedNumber
|
|
1738
|
-
);
|
|
1739
|
-
}
|
|
1740
|
-
}]);
|
|
1741
|
-
return FormattedNumber;
|
|
1287
|
+
var formattedNumber = formatNumber(value, this.props);
|
|
1288
|
+
|
|
1289
|
+
if (typeof children === 'function') {
|
|
1290
|
+
return children(formattedNumber);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
return React.createElement(
|
|
1294
|
+
Text,
|
|
1295
|
+
null,
|
|
1296
|
+
formattedNumber
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
}]);
|
|
1300
|
+
return FormattedNumber;
|
|
1742
1301
|
}(Component);
|
|
1743
1302
|
|
|
1744
1303
|
FormattedNumber.displayName = 'FormattedNumber';
|
|
1745
1304
|
FormattedNumber.contextTypes = {
|
|
1746
|
-
|
|
1305
|
+
intl: intlShape
|
|
1747
1306
|
};
|
|
1748
|
-
process.env.NODE_ENV !== "production" ? FormattedNumber.propTypes =
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1307
|
+
process.env.NODE_ENV !== "production" ? FormattedNumber.propTypes = _extends({}, numberFormatPropTypes, {
|
|
1308
|
+
value: PropTypes.any.isRequired,
|
|
1309
|
+
format: PropTypes.string,
|
|
1310
|
+
children: PropTypes.func
|
|
1752
1311
|
}) : void 0;
|
|
1753
1312
|
|
|
1754
1313
|
/*
|
|
@@ -1758,73 +1317,73 @@ process.env.NODE_ENV !== "production" ? FormattedNumber.propTypes = babelHelpers
|
|
|
1758
1317
|
*/
|
|
1759
1318
|
|
|
1760
1319
|
var FormattedPlural = function (_Component) {
|
|
1761
|
-
|
|
1320
|
+
inherits(FormattedPlural, _Component);
|
|
1762
1321
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1322
|
+
function FormattedPlural(props, context) {
|
|
1323
|
+
classCallCheck(this, FormattedPlural);
|
|
1765
1324
|
|
|
1766
|
-
|
|
1325
|
+
var _this = possibleConstructorReturn(this, (FormattedPlural.__proto__ || Object.getPrototypeOf(FormattedPlural)).call(this, props, context));
|
|
1767
1326
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1327
|
+
invariantIntlContext(context);
|
|
1328
|
+
return _this;
|
|
1329
|
+
}
|
|
1771
1330
|
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1331
|
+
createClass(FormattedPlural, [{
|
|
1332
|
+
key: 'shouldComponentUpdate',
|
|
1333
|
+
value: function shouldComponentUpdate() {
|
|
1334
|
+
for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1335
|
+
next[_key] = arguments[_key];
|
|
1336
|
+
}
|
|
1778
1337
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1338
|
+
return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
|
|
1339
|
+
}
|
|
1340
|
+
}, {
|
|
1341
|
+
key: 'render',
|
|
1342
|
+
value: function render() {
|
|
1343
|
+
var _context$intl = this.context.intl,
|
|
1344
|
+
formatPlural = _context$intl.formatPlural,
|
|
1345
|
+
Text = _context$intl.textComponent;
|
|
1346
|
+
var _props = this.props,
|
|
1347
|
+
value = _props.value,
|
|
1348
|
+
other = _props.other,
|
|
1349
|
+
children = _props.children;
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
var pluralCategory = formatPlural(value, this.props);
|
|
1353
|
+
var formattedPlural = this.props[pluralCategory] || other;
|
|
1354
|
+
|
|
1355
|
+
if (typeof children === 'function') {
|
|
1356
|
+
return children(formattedPlural);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
return React.createElement(
|
|
1360
|
+
Text,
|
|
1361
|
+
null,
|
|
1362
|
+
formattedPlural
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
}]);
|
|
1366
|
+
return FormattedPlural;
|
|
1808
1367
|
}(Component);
|
|
1809
1368
|
|
|
1810
1369
|
FormattedPlural.displayName = 'FormattedPlural';
|
|
1811
1370
|
FormattedPlural.contextTypes = {
|
|
1812
|
-
|
|
1371
|
+
intl: intlShape
|
|
1813
1372
|
};
|
|
1814
1373
|
FormattedPlural.defaultProps = {
|
|
1815
|
-
|
|
1374
|
+
style: 'cardinal'
|
|
1816
1375
|
};
|
|
1817
|
-
process.env.NODE_ENV !== "production" ? FormattedPlural.propTypes =
|
|
1818
|
-
|
|
1376
|
+
process.env.NODE_ENV !== "production" ? FormattedPlural.propTypes = _extends({}, pluralFormatPropTypes, {
|
|
1377
|
+
value: PropTypes.any.isRequired,
|
|
1819
1378
|
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1379
|
+
other: PropTypes.node.isRequired,
|
|
1380
|
+
zero: PropTypes.node,
|
|
1381
|
+
one: PropTypes.node,
|
|
1382
|
+
two: PropTypes.node,
|
|
1383
|
+
few: PropTypes.node,
|
|
1384
|
+
many: PropTypes.node,
|
|
1826
1385
|
|
|
1827
|
-
|
|
1386
|
+
children: PropTypes.func
|
|
1828
1387
|
}) : void 0;
|
|
1829
1388
|
|
|
1830
1389
|
/*
|
|
@@ -1834,146 +1393,142 @@ process.env.NODE_ENV !== "production" ? FormattedPlural.propTypes = babelHelpers
|
|
|
1834
1393
|
*/
|
|
1835
1394
|
|
|
1836
1395
|
var FormattedMessage = function (_Component) {
|
|
1837
|
-
|
|
1396
|
+
inherits(FormattedMessage, _Component);
|
|
1838
1397
|
|
|
1839
|
-
|
|
1840
|
-
|
|
1398
|
+
function FormattedMessage(props, context) {
|
|
1399
|
+
classCallCheck(this, FormattedMessage);
|
|
1841
1400
|
|
|
1842
|
-
|
|
1401
|
+
var _this = possibleConstructorReturn(this, (FormattedMessage.__proto__ || Object.getPrototypeOf(FormattedMessage)).call(this, props, context));
|
|
1843
1402
|
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1403
|
+
invariantIntlContext(context);
|
|
1404
|
+
return _this;
|
|
1405
|
+
}
|
|
1847
1406
|
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1407
|
+
createClass(FormattedMessage, [{
|
|
1408
|
+
key: 'shouldComponentUpdate',
|
|
1409
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
1410
|
+
var values = this.props.values;
|
|
1411
|
+
var nextValues = nextProps.values;
|
|
1853
1412
|
|
|
1854
1413
|
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1414
|
+
if (!shallowEquals(nextValues, values)) {
|
|
1415
|
+
return true;
|
|
1416
|
+
}
|
|
1858
1417
|
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1418
|
+
// Since `values` has already been checked, we know they're not
|
|
1419
|
+
// different, so the current `values` are carried over so the shallow
|
|
1420
|
+
// equals comparison on the other props isn't affected by the `values`.
|
|
1421
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
1422
|
+
values: values
|
|
1423
|
+
});
|
|
1865
1424
|
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1425
|
+
for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1426
|
+
next[_key - 1] = arguments[_key];
|
|
1427
|
+
}
|
|
1869
1428
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
);
|
|
1961
|
-
}
|
|
1962
|
-
}]);
|
|
1963
|
-
return FormattedMessage;
|
|
1429
|
+
return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
|
|
1430
|
+
}
|
|
1431
|
+
}, {
|
|
1432
|
+
key: 'render',
|
|
1433
|
+
value: function render() {
|
|
1434
|
+
var _context$intl = this.context.intl,
|
|
1435
|
+
formatMessage = _context$intl.formatMessage,
|
|
1436
|
+
Text = _context$intl.textComponent;
|
|
1437
|
+
var _props = this.props,
|
|
1438
|
+
id = _props.id,
|
|
1439
|
+
description = _props.description,
|
|
1440
|
+
defaultMessage = _props.defaultMessage,
|
|
1441
|
+
values = _props.values,
|
|
1442
|
+
_props$tagName = _props.tagName,
|
|
1443
|
+
Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
|
|
1444
|
+
children = _props.children;
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
var tokenDelimiter = void 0;
|
|
1448
|
+
var tokenizedValues = void 0;
|
|
1449
|
+
var elements = void 0;
|
|
1450
|
+
|
|
1451
|
+
var hasValues = values && Object.keys(values).length > 0;
|
|
1452
|
+
if (hasValues) {
|
|
1453
|
+
// Creates a token with a random UID that should not be guessable or
|
|
1454
|
+
// conflict with other parts of the `message` string.
|
|
1455
|
+
var uid = Math.floor(Math.random() * 0x10000000000).toString(16);
|
|
1456
|
+
|
|
1457
|
+
var generateToken = function () {
|
|
1458
|
+
var counter = 0;
|
|
1459
|
+
return function () {
|
|
1460
|
+
return 'ELEMENT-' + uid + '-' + (counter += 1);
|
|
1461
|
+
};
|
|
1462
|
+
}();
|
|
1463
|
+
|
|
1464
|
+
// Splitting with a delimiter to support IE8. When using a regex
|
|
1465
|
+
// with a capture group IE8 does not include the capture group in
|
|
1466
|
+
// the resulting array.
|
|
1467
|
+
tokenDelimiter = '@__' + uid + '__@';
|
|
1468
|
+
tokenizedValues = {};
|
|
1469
|
+
elements = {};
|
|
1470
|
+
|
|
1471
|
+
// Iterates over the `props` to keep track of any React Element
|
|
1472
|
+
// values so they can be represented by the `token` as a placeholder
|
|
1473
|
+
// when the `message` is formatted. This allows the formatted
|
|
1474
|
+
// message to then be broken-up into parts with references to the
|
|
1475
|
+
// React Elements inserted back in.
|
|
1476
|
+
Object.keys(values).forEach(function (name) {
|
|
1477
|
+
var value = values[name];
|
|
1478
|
+
|
|
1479
|
+
if (isValidElement(value)) {
|
|
1480
|
+
var token = generateToken();
|
|
1481
|
+
tokenizedValues[name] = tokenDelimiter + token + tokenDelimiter;
|
|
1482
|
+
elements[token] = value;
|
|
1483
|
+
} else {
|
|
1484
|
+
tokenizedValues[name] = value;
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
1490
|
+
var formattedMessage = formatMessage(descriptor, tokenizedValues || values);
|
|
1491
|
+
|
|
1492
|
+
var nodes = void 0;
|
|
1493
|
+
|
|
1494
|
+
var hasElements = elements && Object.keys(elements).length > 0;
|
|
1495
|
+
if (hasElements) {
|
|
1496
|
+
// Split the message into parts so the React Element values captured
|
|
1497
|
+
// above can be inserted back into the rendered message. This
|
|
1498
|
+
// approach allows messages to render with React Elements while
|
|
1499
|
+
// keeping React's virtual diffing working properly.
|
|
1500
|
+
nodes = formattedMessage.split(tokenDelimiter).filter(function (part) {
|
|
1501
|
+
return !!part;
|
|
1502
|
+
}).map(function (part) {
|
|
1503
|
+
return elements[part] || part;
|
|
1504
|
+
});
|
|
1505
|
+
} else {
|
|
1506
|
+
nodes = [formattedMessage];
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
if (typeof children === 'function') {
|
|
1510
|
+
return children.apply(undefined, toConsumableArray(nodes));
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
// Needs to use `createElement()` instead of JSX, otherwise React will
|
|
1514
|
+
// warn about a missing `key` prop with rich-text message formatting.
|
|
1515
|
+
return createElement.apply(undefined, [Component$$1, null].concat(toConsumableArray(nodes)));
|
|
1516
|
+
}
|
|
1517
|
+
}]);
|
|
1518
|
+
return FormattedMessage;
|
|
1964
1519
|
}(Component);
|
|
1965
1520
|
|
|
1966
1521
|
FormattedMessage.displayName = 'FormattedMessage';
|
|
1967
1522
|
FormattedMessage.contextTypes = {
|
|
1968
|
-
|
|
1523
|
+
intl: intlShape
|
|
1969
1524
|
};
|
|
1970
1525
|
FormattedMessage.defaultProps = {
|
|
1971
|
-
|
|
1526
|
+
values: {}
|
|
1972
1527
|
};
|
|
1973
|
-
process.env.NODE_ENV !== "production" ? FormattedMessage.propTypes =
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1528
|
+
process.env.NODE_ENV !== "production" ? FormattedMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
1529
|
+
values: PropTypes.object,
|
|
1530
|
+
tagName: PropTypes.string,
|
|
1531
|
+
children: PropTypes.func
|
|
1977
1532
|
}) : void 0;
|
|
1978
1533
|
|
|
1979
1534
|
/*
|
|
@@ -1983,90 +1538,90 @@ process.env.NODE_ENV !== "production" ? FormattedMessage.propTypes = babelHelper
|
|
|
1983
1538
|
*/
|
|
1984
1539
|
|
|
1985
1540
|
var FormattedHTMLMessage = function (_Component) {
|
|
1986
|
-
|
|
1541
|
+
inherits(FormattedHTMLMessage, _Component);
|
|
1987
1542
|
|
|
1988
|
-
|
|
1989
|
-
|
|
1543
|
+
function FormattedHTMLMessage(props, context) {
|
|
1544
|
+
classCallCheck(this, FormattedHTMLMessage);
|
|
1990
1545
|
|
|
1991
|
-
|
|
1546
|
+
var _this = possibleConstructorReturn(this, (FormattedHTMLMessage.__proto__ || Object.getPrototypeOf(FormattedHTMLMessage)).call(this, props, context));
|
|
1992
1547
|
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1548
|
+
invariantIntlContext(context);
|
|
1549
|
+
return _this;
|
|
1550
|
+
}
|
|
1996
1551
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
1552
|
+
createClass(FormattedHTMLMessage, [{
|
|
1553
|
+
key: 'shouldComponentUpdate',
|
|
1554
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
1555
|
+
var values = this.props.values;
|
|
1556
|
+
var nextValues = nextProps.values;
|
|
2002
1557
|
|
|
2003
1558
|
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
1559
|
+
if (!shallowEquals(nextValues, values)) {
|
|
1560
|
+
return true;
|
|
1561
|
+
}
|
|
2007
1562
|
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
1563
|
+
// Since `values` has already been checked, we know they're not
|
|
1564
|
+
// different, so the current `values` are carried over so the shallow
|
|
1565
|
+
// equals comparison on the other props isn't affected by the `values`.
|
|
1566
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
1567
|
+
values: values
|
|
1568
|
+
});
|
|
2014
1569
|
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
1570
|
+
for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1571
|
+
next[_key - 1] = arguments[_key];
|
|
1572
|
+
}
|
|
2018
1573
|
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
1574
|
+
return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
|
|
1575
|
+
}
|
|
1576
|
+
}, {
|
|
1577
|
+
key: 'render',
|
|
1578
|
+
value: function render() {
|
|
1579
|
+
var _context$intl = this.context.intl,
|
|
1580
|
+
formatHTMLMessage = _context$intl.formatHTMLMessage,
|
|
1581
|
+
Text = _context$intl.textComponent;
|
|
1582
|
+
var _props = this.props,
|
|
1583
|
+
id = _props.id,
|
|
1584
|
+
description = _props.description,
|
|
1585
|
+
defaultMessage = _props.defaultMessage,
|
|
1586
|
+
rawValues = _props.values,
|
|
1587
|
+
_props$tagName = _props.tagName,
|
|
1588
|
+
Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
|
|
1589
|
+
children = _props.children;
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
1593
|
+
var formattedHTMLMessage = formatHTMLMessage(descriptor, rawValues);
|
|
1594
|
+
|
|
1595
|
+
if (typeof children === 'function') {
|
|
1596
|
+
return children(formattedHTMLMessage);
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
// Since the message presumably has HTML in it, we need to set
|
|
1600
|
+
// `innerHTML` in order for it to be rendered and not escaped by React.
|
|
1601
|
+
// To be safe, all string prop values were escaped when formatting the
|
|
1602
|
+
// message. It is assumed that the message is not UGC, and came from the
|
|
1603
|
+
// developer making it more like a template.
|
|
1604
|
+
//
|
|
1605
|
+
// Note: There's a perf impact of using this component since there's no
|
|
1606
|
+
// way for React to do its virtual DOM diffing.
|
|
1607
|
+
var html = { __html: formattedHTMLMessage };
|
|
1608
|
+
return React.createElement(Component$$1, { dangerouslySetInnerHTML: html });
|
|
1609
|
+
}
|
|
1610
|
+
}]);
|
|
1611
|
+
return FormattedHTMLMessage;
|
|
2057
1612
|
}(Component);
|
|
2058
1613
|
|
|
2059
1614
|
FormattedHTMLMessage.displayName = 'FormattedHTMLMessage';
|
|
2060
1615
|
FormattedHTMLMessage.contextTypes = {
|
|
2061
|
-
|
|
1616
|
+
intl: intlShape
|
|
2062
1617
|
};
|
|
2063
1618
|
FormattedHTMLMessage.defaultProps = {
|
|
2064
|
-
|
|
1619
|
+
values: {}
|
|
2065
1620
|
};
|
|
2066
|
-
process.env.NODE_ENV !== "production" ? FormattedHTMLMessage.propTypes =
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
1621
|
+
process.env.NODE_ENV !== "production" ? FormattedHTMLMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
1622
|
+
values: PropTypes.object,
|
|
1623
|
+
tagName: PropTypes.string,
|
|
1624
|
+
children: PropTypes.func
|
|
2070
1625
|
}) : void 0;
|
|
2071
1626
|
|
|
2072
1627
|
/*
|