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