react-intl 2.2.0 → 2.3.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 +145 -615
- package/dist/react-intl.js.map +1 -1
- package/dist/react-intl.min.js +2 -2
- package/dist/react-intl.min.js.map +1 -1
- package/lib/index.es.js +74 -520
- package/lib/index.js +110 -556
- package/package.json +24 -20
- package/yarn.lock +4804 -0
- package/src/components/date.js +0 -46
- package/src/components/html-message.js +0 -87
- package/src/components/message.js +0 -134
- package/src/components/number.js +0 -46
- package/src/components/plural.js +0 -58
- package/src/components/provider.js +0 -176
- package/src/components/relative.js +0 -163
- package/src/components/time.js +0 -46
- package/src/define-messages.js +0 -11
- package/src/en.js +0 -2
- package/src/format.js +0 -275
- package/src/index.js +0 -12
- package/src/inject.js +0 -61
- package/src/locale-data-registry.js +0 -42
- package/src/plural.js +0 -28
- package/src/react-intl.js +0 -24
- package/src/types.js +0 -88
- package/src/utils.js +0 -93
package/lib/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2017, Yahoo Inc.
|
|
3
3
|
* Copyrights licensed under the New BSD License.
|
|
4
4
|
* See the accompanying LICENSE file for terms.
|
|
5
5
|
*/
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import allLocaleData from '../locale-data/index.js';
|
|
8
8
|
import IntlMessageFormat from 'intl-messageformat';
|
|
9
9
|
import IntlRelativeFormat from 'intl-relativeformat';
|
|
10
|
-
import
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import React, { Children, Component, createElement, isValidElement } from 'react';
|
|
11
12
|
import invariant from 'invariant';
|
|
12
13
|
import memoizeIntlConstructor from 'intl-format-cache';
|
|
13
14
|
|
|
@@ -65,257 +66,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
65
66
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
var jsx = function () {
|
|
69
|
-
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;
|
|
70
|
-
return function createRawReactElement(type, props, key, children) {
|
|
71
|
-
var defaultProps = type && type.defaultProps;
|
|
72
|
-
var childrenLength = arguments.length - 3;
|
|
73
69
|
|
|
74
|
-
if (!props && childrenLength !== 0) {
|
|
75
|
-
props = {};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (props && defaultProps) {
|
|
79
|
-
for (var propName in defaultProps) {
|
|
80
|
-
if (props[propName] === void 0) {
|
|
81
|
-
props[propName] = defaultProps[propName];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} else if (!props) {
|
|
85
|
-
props = defaultProps || {};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (childrenLength === 1) {
|
|
89
|
-
props.children = children;
|
|
90
|
-
} else if (childrenLength > 1) {
|
|
91
|
-
var childArray = Array(childrenLength);
|
|
92
|
-
|
|
93
|
-
for (var i = 0; i < childrenLength; i++) {
|
|
94
|
-
childArray[i] = arguments[i + 3];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
props.children = childArray;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
102
|
-
type: type,
|
|
103
|
-
key: key === undefined ? null : '' + key,
|
|
104
|
-
ref: null,
|
|
105
|
-
props: props,
|
|
106
|
-
_owner: null
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
}();
|
|
110
|
-
|
|
111
|
-
var asyncIterator = function (iterable) {
|
|
112
|
-
if (typeof Symbol === "function") {
|
|
113
|
-
if (Symbol.asyncIterator) {
|
|
114
|
-
var method = iterable[Symbol.asyncIterator];
|
|
115
|
-
if (method != null) return method.call(iterable);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (Symbol.iterator) {
|
|
119
|
-
return iterable[Symbol.iterator]();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
throw new TypeError("Object is not async iterable");
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
var asyncGenerator = function () {
|
|
127
|
-
function AwaitValue(value) {
|
|
128
|
-
this.value = value;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function AsyncGenerator(gen) {
|
|
132
|
-
var front, back;
|
|
133
|
-
|
|
134
|
-
function send(key, arg) {
|
|
135
|
-
return new Promise(function (resolve, reject) {
|
|
136
|
-
var request = {
|
|
137
|
-
key: key,
|
|
138
|
-
arg: arg,
|
|
139
|
-
resolve: resolve,
|
|
140
|
-
reject: reject,
|
|
141
|
-
next: null
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if (back) {
|
|
145
|
-
back = back.next = request;
|
|
146
|
-
} else {
|
|
147
|
-
front = back = request;
|
|
148
|
-
resume(key, arg);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function resume(key, arg) {
|
|
154
|
-
try {
|
|
155
|
-
var result = gen[key](arg);
|
|
156
|
-
var value = result.value;
|
|
157
|
-
|
|
158
|
-
if (value instanceof AwaitValue) {
|
|
159
|
-
Promise.resolve(value.value).then(function (arg) {
|
|
160
|
-
resume("next", arg);
|
|
161
|
-
}, function (arg) {
|
|
162
|
-
resume("throw", arg);
|
|
163
|
-
});
|
|
164
|
-
} else {
|
|
165
|
-
settle(result.done ? "return" : "normal", result.value);
|
|
166
|
-
}
|
|
167
|
-
} catch (err) {
|
|
168
|
-
settle("throw", err);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function settle(type, value) {
|
|
173
|
-
switch (type) {
|
|
174
|
-
case "return":
|
|
175
|
-
front.resolve({
|
|
176
|
-
value: value,
|
|
177
|
-
done: true
|
|
178
|
-
});
|
|
179
|
-
break;
|
|
180
70
|
|
|
181
|
-
case "throw":
|
|
182
|
-
front.reject(value);
|
|
183
|
-
break;
|
|
184
71
|
|
|
185
|
-
default:
|
|
186
|
-
front.resolve({
|
|
187
|
-
value: value,
|
|
188
|
-
done: false
|
|
189
|
-
});
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
72
|
|
|
193
|
-
front = front.next;
|
|
194
73
|
|
|
195
|
-
if (front) {
|
|
196
|
-
resume(front.key, front.arg);
|
|
197
|
-
} else {
|
|
198
|
-
back = null;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
74
|
|
|
202
|
-
this._invoke = send;
|
|
203
75
|
|
|
204
|
-
if (typeof gen.return !== "function") {
|
|
205
|
-
this.return = undefined;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
76
|
|
|
209
|
-
if (typeof Symbol === "function" && Symbol.asyncIterator) {
|
|
210
|
-
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
|
|
211
|
-
return this;
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
AsyncGenerator.prototype.next = function (arg) {
|
|
216
|
-
return this._invoke("next", arg);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
AsyncGenerator.prototype.throw = function (arg) {
|
|
220
|
-
return this._invoke("throw", arg);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
AsyncGenerator.prototype.return = function (arg) {
|
|
224
|
-
return this._invoke("return", arg);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
return {
|
|
228
|
-
wrap: function (fn) {
|
|
229
|
-
return function () {
|
|
230
|
-
return new AsyncGenerator(fn.apply(this, arguments));
|
|
231
|
-
};
|
|
232
|
-
},
|
|
233
|
-
await: function (value) {
|
|
234
|
-
return new AwaitValue(value);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
}();
|
|
238
|
-
|
|
239
|
-
var asyncGeneratorDelegate = function (inner, awaitWrap) {
|
|
240
|
-
var iter = {},
|
|
241
|
-
waiting = false;
|
|
242
|
-
|
|
243
|
-
function pump(key, value) {
|
|
244
|
-
waiting = true;
|
|
245
|
-
value = new Promise(function (resolve) {
|
|
246
|
-
resolve(inner[key](value));
|
|
247
|
-
});
|
|
248
|
-
return {
|
|
249
|
-
done: false,
|
|
250
|
-
value: awaitWrap(value)
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (typeof Symbol === "function" && Symbol.iterator) {
|
|
257
|
-
iter[Symbol.iterator] = function () {
|
|
258
|
-
return this;
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
iter.next = function (value) {
|
|
263
|
-
if (waiting) {
|
|
264
|
-
waiting = false;
|
|
265
|
-
return value;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return pump("next", value);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
if (typeof inner.throw === "function") {
|
|
272
|
-
iter.throw = function (value) {
|
|
273
|
-
if (waiting) {
|
|
274
|
-
waiting = false;
|
|
275
|
-
throw value;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return pump("throw", value);
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (typeof inner.return === "function") {
|
|
283
|
-
iter.return = function (value) {
|
|
284
|
-
return pump("return", value);
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return iter;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
var asyncToGenerator = function (fn) {
|
|
292
|
-
return function () {
|
|
293
|
-
var gen = fn.apply(this, arguments);
|
|
294
|
-
return new Promise(function (resolve, reject) {
|
|
295
|
-
function step(key, arg) {
|
|
296
|
-
try {
|
|
297
|
-
var info = gen[key](arg);
|
|
298
|
-
var value = info.value;
|
|
299
|
-
} catch (error) {
|
|
300
|
-
reject(error);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (info.done) {
|
|
305
|
-
resolve(value);
|
|
306
|
-
} else {
|
|
307
|
-
return Promise.resolve(value).then(function (value) {
|
|
308
|
-
step("next", value);
|
|
309
|
-
}, function (err) {
|
|
310
|
-
step("throw", err);
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
77
|
|
|
315
|
-
return step("next");
|
|
316
|
-
});
|
|
317
|
-
};
|
|
318
|
-
};
|
|
319
78
|
|
|
320
79
|
var classCallCheck = function (instance, Constructor) {
|
|
321
80
|
if (!(instance instanceof Constructor)) {
|
|
@@ -341,31 +100,9 @@ var createClass = function () {
|
|
|
341
100
|
};
|
|
342
101
|
}();
|
|
343
102
|
|
|
344
|
-
var defineEnumerableProperties = function (obj, descs) {
|
|
345
|
-
for (var key in descs) {
|
|
346
|
-
var desc = descs[key];
|
|
347
|
-
desc.configurable = desc.enumerable = true;
|
|
348
|
-
if ("value" in desc) desc.writable = true;
|
|
349
|
-
Object.defineProperty(obj, key, desc);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return obj;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
var defaults = function (obj, defaults) {
|
|
356
|
-
var keys = Object.getOwnPropertyNames(defaults);
|
|
357
103
|
|
|
358
|
-
for (var i = 0; i < keys.length; i++) {
|
|
359
|
-
var key = keys[i];
|
|
360
|
-
var value = Object.getOwnPropertyDescriptor(defaults, key);
|
|
361
104
|
|
|
362
|
-
if (value && value.configurable && obj[key] === undefined) {
|
|
363
|
-
Object.defineProperty(obj, key, value);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
105
|
|
|
367
|
-
return obj;
|
|
368
|
-
};
|
|
369
106
|
|
|
370
107
|
var defineProperty = function (obj, key, value) {
|
|
371
108
|
if (key in obj) {
|
|
@@ -396,30 +133,7 @@ var _extends = Object.assign || function (target) {
|
|
|
396
133
|
return target;
|
|
397
134
|
};
|
|
398
135
|
|
|
399
|
-
var get = function get(object, property, receiver) {
|
|
400
|
-
if (object === null) object = Function.prototype;
|
|
401
|
-
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
402
|
-
|
|
403
|
-
if (desc === undefined) {
|
|
404
|
-
var parent = Object.getPrototypeOf(object);
|
|
405
|
-
|
|
406
|
-
if (parent === null) {
|
|
407
|
-
return undefined;
|
|
408
|
-
} else {
|
|
409
|
-
return get(parent, property, receiver);
|
|
410
|
-
}
|
|
411
|
-
} else if ("value" in desc) {
|
|
412
|
-
return desc.value;
|
|
413
|
-
} else {
|
|
414
|
-
var getter = desc.get;
|
|
415
|
-
|
|
416
|
-
if (getter === undefined) {
|
|
417
|
-
return undefined;
|
|
418
|
-
}
|
|
419
136
|
|
|
420
|
-
return getter.call(receiver);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
137
|
|
|
424
138
|
var inherits = function (subClass, superClass) {
|
|
425
139
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -437,46 +151,13 @@ var inherits = function (subClass, superClass) {
|
|
|
437
151
|
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
438
152
|
};
|
|
439
153
|
|
|
440
|
-
var _instanceof = function (left, right) {
|
|
441
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
442
|
-
return right[Symbol.hasInstance](left);
|
|
443
|
-
} else {
|
|
444
|
-
return left instanceof right;
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
154
|
|
|
448
|
-
var interopRequireDefault = function (obj) {
|
|
449
|
-
return obj && obj.__esModule ? obj : {
|
|
450
|
-
default: obj
|
|
451
|
-
};
|
|
452
|
-
};
|
|
453
155
|
|
|
454
|
-
var interopRequireWildcard = function (obj) {
|
|
455
|
-
if (obj && obj.__esModule) {
|
|
456
|
-
return obj;
|
|
457
|
-
} else {
|
|
458
|
-
var newObj = {};
|
|
459
156
|
|
|
460
|
-
if (obj != null) {
|
|
461
|
-
for (var key in obj) {
|
|
462
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
157
|
|
|
466
|
-
newObj.default = obj;
|
|
467
|
-
return newObj;
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
158
|
|
|
471
|
-
var newArrowCheck = function (innerThis, boundThis) {
|
|
472
|
-
if (innerThis !== boundThis) {
|
|
473
|
-
throw new TypeError("Cannot instantiate an arrow function");
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
159
|
|
|
477
|
-
|
|
478
|
-
if (obj == null) throw new TypeError("Cannot destructure undefined");
|
|
479
|
-
};
|
|
160
|
+
|
|
480
161
|
|
|
481
162
|
var objectWithoutProperties = function (obj, keys) {
|
|
482
163
|
var target = {};
|
|
@@ -498,112 +179,23 @@ var possibleConstructorReturn = function (self, call) {
|
|
|
498
179
|
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
499
180
|
};
|
|
500
181
|
|
|
501
|
-
var selfGlobal = typeof global === "undefined" ? self : global;
|
|
502
182
|
|
|
503
|
-
var set = function set(object, property, value, receiver) {
|
|
504
|
-
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
505
183
|
|
|
506
|
-
if (desc === undefined) {
|
|
507
|
-
var parent = Object.getPrototypeOf(object);
|
|
508
184
|
|
|
509
|
-
if (parent !== null) {
|
|
510
|
-
set(parent, property, value, receiver);
|
|
511
|
-
}
|
|
512
|
-
} else if ("value" in desc && desc.writable) {
|
|
513
|
-
desc.value = value;
|
|
514
|
-
} else {
|
|
515
|
-
var setter = desc.set;
|
|
516
185
|
|
|
517
|
-
if (setter !== undefined) {
|
|
518
|
-
setter.call(receiver, value);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
186
|
|
|
522
|
-
return value;
|
|
523
|
-
};
|
|
524
187
|
|
|
525
|
-
var slicedToArray = function () {
|
|
526
|
-
function sliceIterator(arr, i) {
|
|
527
|
-
var _arr = [];
|
|
528
|
-
var _n = true;
|
|
529
|
-
var _d = false;
|
|
530
|
-
var _e = undefined;
|
|
531
188
|
|
|
532
|
-
try {
|
|
533
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
534
|
-
_arr.push(_s.value);
|
|
535
189
|
|
|
536
|
-
if (i && _arr.length === i) break;
|
|
537
|
-
}
|
|
538
|
-
} catch (err) {
|
|
539
|
-
_d = true;
|
|
540
|
-
_e = err;
|
|
541
|
-
} finally {
|
|
542
|
-
try {
|
|
543
|
-
if (!_n && _i["return"]) _i["return"]();
|
|
544
|
-
} finally {
|
|
545
|
-
if (_d) throw _e;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
190
|
|
|
549
|
-
return _arr;
|
|
550
|
-
}
|
|
551
191
|
|
|
552
|
-
return function (arr, i) {
|
|
553
|
-
if (Array.isArray(arr)) {
|
|
554
|
-
return arr;
|
|
555
|
-
} else if (Symbol.iterator in Object(arr)) {
|
|
556
|
-
return sliceIterator(arr, i);
|
|
557
|
-
} else {
|
|
558
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
}();
|
|
562
192
|
|
|
563
|
-
var slicedToArrayLoose = function (arr, i) {
|
|
564
|
-
if (Array.isArray(arr)) {
|
|
565
|
-
return arr;
|
|
566
|
-
} else if (Symbol.iterator in Object(arr)) {
|
|
567
|
-
var _arr = [];
|
|
568
193
|
|
|
569
|
-
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
|
570
|
-
_arr.push(_step.value);
|
|
571
194
|
|
|
572
|
-
if (i && _arr.length === i) break;
|
|
573
|
-
}
|
|
574
195
|
|
|
575
|
-
return _arr;
|
|
576
|
-
} else {
|
|
577
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
196
|
|
|
581
|
-
var taggedTemplateLiteral = function (strings, raw) {
|
|
582
|
-
return Object.freeze(Object.defineProperties(strings, {
|
|
583
|
-
raw: {
|
|
584
|
-
value: Object.freeze(raw)
|
|
585
|
-
}
|
|
586
|
-
}));
|
|
587
|
-
};
|
|
588
197
|
|
|
589
|
-
var taggedTemplateLiteralLoose = function (strings, raw) {
|
|
590
|
-
strings.raw = raw;
|
|
591
|
-
return strings;
|
|
592
|
-
};
|
|
593
198
|
|
|
594
|
-
var temporalRef = function (val, name, undef) {
|
|
595
|
-
if (val === undef) {
|
|
596
|
-
throw new ReferenceError(name + " is not defined - temporal dead zone");
|
|
597
|
-
} else {
|
|
598
|
-
return val;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
var temporalUndefined = {};
|
|
603
|
-
|
|
604
|
-
var toArray = function (arr) {
|
|
605
|
-
return Array.isArray(arr) ? arr : Array.from(arr);
|
|
606
|
-
};
|
|
607
199
|
|
|
608
200
|
var toConsumableArray = function (arr) {
|
|
609
201
|
if (Array.isArray(arr)) {
|
|
@@ -615,42 +207,6 @@ var toConsumableArray = function (arr) {
|
|
|
615
207
|
}
|
|
616
208
|
};
|
|
617
209
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
var babelHelpers$1 = Object.freeze({
|
|
621
|
-
jsx: jsx,
|
|
622
|
-
asyncIterator: asyncIterator,
|
|
623
|
-
asyncGenerator: asyncGenerator,
|
|
624
|
-
asyncGeneratorDelegate: asyncGeneratorDelegate,
|
|
625
|
-
asyncToGenerator: asyncToGenerator,
|
|
626
|
-
classCallCheck: classCallCheck,
|
|
627
|
-
createClass: createClass,
|
|
628
|
-
defineEnumerableProperties: defineEnumerableProperties,
|
|
629
|
-
defaults: defaults,
|
|
630
|
-
defineProperty: defineProperty,
|
|
631
|
-
get: get,
|
|
632
|
-
inherits: inherits,
|
|
633
|
-
interopRequireDefault: interopRequireDefault,
|
|
634
|
-
interopRequireWildcard: interopRequireWildcard,
|
|
635
|
-
newArrowCheck: newArrowCheck,
|
|
636
|
-
objectDestructuringEmpty: objectDestructuringEmpty,
|
|
637
|
-
objectWithoutProperties: objectWithoutProperties,
|
|
638
|
-
possibleConstructorReturn: possibleConstructorReturn,
|
|
639
|
-
selfGlobal: selfGlobal,
|
|
640
|
-
set: set,
|
|
641
|
-
slicedToArray: slicedToArray,
|
|
642
|
-
slicedToArrayLoose: slicedToArrayLoose,
|
|
643
|
-
taggedTemplateLiteral: taggedTemplateLiteral,
|
|
644
|
-
taggedTemplateLiteralLoose: taggedTemplateLiteralLoose,
|
|
645
|
-
temporalRef: temporalRef,
|
|
646
|
-
temporalUndefined: temporalUndefined,
|
|
647
|
-
toArray: toArray,
|
|
648
|
-
toConsumableArray: toConsumableArray,
|
|
649
|
-
typeof: _typeof,
|
|
650
|
-
extends: _extends,
|
|
651
|
-
instanceof: _instanceof
|
|
652
|
-
});
|
|
653
|
-
|
|
654
210
|
/*
|
|
655
211
|
* Copyright 2015, Yahoo Inc.
|
|
656
212
|
* Copyrights licensed under the New BSD License.
|
|
@@ -664,7 +220,7 @@ var func = PropTypes.func;
|
|
|
664
220
|
var object = PropTypes.object;
|
|
665
221
|
var oneOf = PropTypes.oneOf;
|
|
666
222
|
var shape = PropTypes.shape;
|
|
667
|
-
var
|
|
223
|
+
var any = PropTypes.any;
|
|
668
224
|
|
|
669
225
|
var localeMatcher = oneOf(['best fit', 'lookup']);
|
|
670
226
|
var narrowShortLong = oneOf(['narrow', 'short', 'long']);
|
|
@@ -675,7 +231,7 @@ var intlConfigPropTypes = {
|
|
|
675
231
|
locale: string,
|
|
676
232
|
formats: object,
|
|
677
233
|
messages: object,
|
|
678
|
-
textComponent:
|
|
234
|
+
textComponent: any,
|
|
679
235
|
|
|
680
236
|
defaultLocale: string,
|
|
681
237
|
defaultFormats: object
|
|
@@ -691,7 +247,7 @@ var intlFormatPropTypes = {
|
|
|
691
247
|
formatHTMLMessage: funcReq
|
|
692
248
|
};
|
|
693
249
|
|
|
694
|
-
var intlShape = shape(
|
|
250
|
+
var intlShape = shape(_extends({}, intlConfigPropTypes, intlFormatPropTypes, {
|
|
695
251
|
formatters: object,
|
|
696
252
|
now: funcReq
|
|
697
253
|
}));
|
|
@@ -799,7 +355,7 @@ function shallowEquals(objA, objB) {
|
|
|
799
355
|
return true;
|
|
800
356
|
}
|
|
801
357
|
|
|
802
|
-
if ((typeof objA === 'undefined' ? 'undefined' :
|
|
358
|
+
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
|
|
803
359
|
return false;
|
|
804
360
|
}
|
|
805
361
|
|
|
@@ -878,7 +434,7 @@ function injectIntl(WrappedComponent) {
|
|
|
878
434
|
}, {
|
|
879
435
|
key: 'render',
|
|
880
436
|
value: function render() {
|
|
881
|
-
return React.createElement(WrappedComponent,
|
|
437
|
+
return React.createElement(WrappedComponent, _extends({}, this.props, defineProperty({}, intlPropName, this.context.intl), {
|
|
882
438
|
ref: withRef ? 'wrappedInstance' : null
|
|
883
439
|
}));
|
|
884
440
|
}
|
|
@@ -1011,7 +567,7 @@ function formatTime(config, state, value) {
|
|
|
1011
567
|
|
|
1012
568
|
if (!filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second) {
|
|
1013
569
|
// Add default formatting options if hour, minute, or second isn't defined.
|
|
1014
|
-
filteredOptions =
|
|
570
|
+
filteredOptions = _extends({}, filteredOptions, { hour: 'numeric', minute: 'numeric' });
|
|
1015
571
|
}
|
|
1016
572
|
|
|
1017
573
|
try {
|
|
@@ -1039,7 +595,7 @@ function formatRelative(config, state, value) {
|
|
|
1039
595
|
|
|
1040
596
|
// Capture the current threshold values, then temporarily override them with
|
|
1041
597
|
// specific values just for this render.
|
|
1042
|
-
var oldThresholds =
|
|
598
|
+
var oldThresholds = _extends({}, IntlRelativeFormat.thresholds);
|
|
1043
599
|
updateRelativeFormatThresholds(RELATIVE_FORMAT_THRESHOLDS);
|
|
1044
600
|
|
|
1045
601
|
try {
|
|
@@ -1253,7 +809,7 @@ var IntlProvider = function (_Component) {
|
|
|
1253
809
|
getPluralFormat: memoizeIntlConstructor(IntlPluralFormat)
|
|
1254
810
|
} : _ref$formatters;
|
|
1255
811
|
|
|
1256
|
-
_this.state =
|
|
812
|
+
_this.state = _extends({}, formatters, {
|
|
1257
813
|
|
|
1258
814
|
// Wrapper to provide stable "now" time for initial render.
|
|
1259
815
|
now: function now() {
|
|
@@ -1298,7 +854,7 @@ var IntlProvider = function (_Component) {
|
|
|
1298
854
|
// The `messages` are overridden to the `defaultProps` empty object
|
|
1299
855
|
// to maintain referential equality across re-renders. It's assumed
|
|
1300
856
|
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
1301
|
-
config =
|
|
857
|
+
config = _extends({}, config, {
|
|
1302
858
|
locale: defaultLocale,
|
|
1303
859
|
formats: defaultFormats,
|
|
1304
860
|
messages: defaultProps.messages
|
|
@@ -1329,7 +885,7 @@ var IntlProvider = function (_Component) {
|
|
|
1329
885
|
|
|
1330
886
|
|
|
1331
887
|
return {
|
|
1332
|
-
intl:
|
|
888
|
+
intl: _extends({}, config, boundFormatFns, {
|
|
1333
889
|
formatters: formatters,
|
|
1334
890
|
now: now
|
|
1335
891
|
})
|
|
@@ -1365,7 +921,7 @@ IntlProvider.contextTypes = {
|
|
|
1365
921
|
IntlProvider.childContextTypes = {
|
|
1366
922
|
intl: intlShape.isRequired
|
|
1367
923
|
};
|
|
1368
|
-
process.env.NODE_ENV !== "production" ? IntlProvider.propTypes =
|
|
924
|
+
process.env.NODE_ENV !== "production" ? IntlProvider.propTypes = _extends({}, intlConfigPropTypes, {
|
|
1369
925
|
children: PropTypes.element.isRequired,
|
|
1370
926
|
initialNow: PropTypes.any
|
|
1371
927
|
}) : void 0;
|
|
@@ -1428,7 +984,7 @@ FormattedDate.displayName = 'FormattedDate';
|
|
|
1428
984
|
FormattedDate.contextTypes = {
|
|
1429
985
|
intl: intlShape
|
|
1430
986
|
};
|
|
1431
|
-
process.env.NODE_ENV !== "production" ? FormattedDate.propTypes =
|
|
987
|
+
process.env.NODE_ENV !== "production" ? FormattedDate.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
1432
988
|
value: PropTypes.any.isRequired,
|
|
1433
989
|
format: PropTypes.string,
|
|
1434
990
|
children: PropTypes.func
|
|
@@ -1492,7 +1048,7 @@ FormattedTime.displayName = 'FormattedTime';
|
|
|
1492
1048
|
FormattedTime.contextTypes = {
|
|
1493
1049
|
intl: intlShape
|
|
1494
1050
|
};
|
|
1495
|
-
process.env.NODE_ENV !== "production" ? FormattedTime.propTypes =
|
|
1051
|
+
process.env.NODE_ENV !== "production" ? FormattedTime.propTypes = _extends({}, dateTimeFormatPropTypes, {
|
|
1496
1052
|
value: PropTypes.any.isRequired,
|
|
1497
1053
|
format: PropTypes.string,
|
|
1498
1054
|
children: PropTypes.func
|
|
@@ -1582,20 +1138,24 @@ var FormattedRelative = function (_Component) {
|
|
|
1582
1138
|
value: function scheduleNextUpdate(props, state) {
|
|
1583
1139
|
var _this2 = this;
|
|
1584
1140
|
|
|
1585
|
-
|
|
1141
|
+
// Cancel and pending update because we're scheduling a new update.
|
|
1142
|
+
clearTimeout(this._timer);
|
|
1143
|
+
|
|
1144
|
+
var value = props.value,
|
|
1145
|
+
units = props.units,
|
|
1146
|
+
updateInterval = props.updateInterval;
|
|
1586
1147
|
|
|
1587
|
-
|
|
1588
|
-
// have been turned off, so we bail and skip scheduling an update.
|
|
1148
|
+
var time = new Date(value).getTime();
|
|
1589
1149
|
|
|
1590
|
-
|
|
1150
|
+
// If the `updateInterval` is falsy, including `0` or we don't have a
|
|
1151
|
+
// valid date, then auto updates have been turned off, so we bail and
|
|
1152
|
+
// skip scheduling an update.
|
|
1153
|
+
if (!updateInterval || !isFinite(time)) {
|
|
1591
1154
|
return;
|
|
1592
1155
|
}
|
|
1593
1156
|
|
|
1594
|
-
var time = new Date(props.value).getTime();
|
|
1595
1157
|
var delta = time - state.now;
|
|
1596
|
-
var
|
|
1597
|
-
|
|
1598
|
-
var unitDelay = getUnitDelay(units);
|
|
1158
|
+
var unitDelay = getUnitDelay(units || selectUnits(delta));
|
|
1599
1159
|
var unitRemainder = Math.abs(delta % unitDelay);
|
|
1600
1160
|
|
|
1601
1161
|
// We want the largest possible timer delay which will still display
|
|
@@ -1604,8 +1164,6 @@ var FormattedRelative = function (_Component) {
|
|
|
1604
1164
|
// "1 minute ago" to "2 minutes ago" when the delta is 120,000ms.
|
|
1605
1165
|
var delay = delta < 0 ? Math.max(updateInterval, unitDelay - unitRemainder) : Math.max(updateInterval, unitRemainder);
|
|
1606
1166
|
|
|
1607
|
-
clearTimeout(this._timer);
|
|
1608
|
-
|
|
1609
1167
|
this._timer = setTimeout(function () {
|
|
1610
1168
|
_this2.setState({ now: _this2.context.intl.now() });
|
|
1611
1169
|
}, delay);
|
|
@@ -1656,7 +1214,7 @@ var FormattedRelative = function (_Component) {
|
|
|
1656
1214
|
children = _props.children;
|
|
1657
1215
|
|
|
1658
1216
|
|
|
1659
|
-
var formattedRelative = formatRelative(value,
|
|
1217
|
+
var formattedRelative = formatRelative(value, _extends({}, this.props, this.state));
|
|
1660
1218
|
|
|
1661
1219
|
if (typeof children === 'function') {
|
|
1662
1220
|
return children(formattedRelative);
|
|
@@ -1679,7 +1237,7 @@ FormattedRelative.contextTypes = {
|
|
|
1679
1237
|
FormattedRelative.defaultProps = {
|
|
1680
1238
|
updateInterval: 1000 * 10
|
|
1681
1239
|
};
|
|
1682
|
-
process.env.NODE_ENV !== "production" ? FormattedRelative.propTypes =
|
|
1240
|
+
process.env.NODE_ENV !== "production" ? FormattedRelative.propTypes = _extends({}, relativeFormatPropTypes, {
|
|
1683
1241
|
value: PropTypes.any.isRequired,
|
|
1684
1242
|
format: PropTypes.string,
|
|
1685
1243
|
updateInterval: PropTypes.number,
|
|
@@ -1745,7 +1303,7 @@ FormattedNumber.displayName = 'FormattedNumber';
|
|
|
1745
1303
|
FormattedNumber.contextTypes = {
|
|
1746
1304
|
intl: intlShape
|
|
1747
1305
|
};
|
|
1748
|
-
process.env.NODE_ENV !== "production" ? FormattedNumber.propTypes =
|
|
1306
|
+
process.env.NODE_ENV !== "production" ? FormattedNumber.propTypes = _extends({}, numberFormatPropTypes, {
|
|
1749
1307
|
value: PropTypes.any.isRequired,
|
|
1750
1308
|
format: PropTypes.string,
|
|
1751
1309
|
children: PropTypes.func
|
|
@@ -1814,7 +1372,7 @@ FormattedPlural.contextTypes = {
|
|
|
1814
1372
|
FormattedPlural.defaultProps = {
|
|
1815
1373
|
style: 'cardinal'
|
|
1816
1374
|
};
|
|
1817
|
-
process.env.NODE_ENV !== "production" ? FormattedPlural.propTypes =
|
|
1375
|
+
process.env.NODE_ENV !== "production" ? FormattedPlural.propTypes = _extends({}, pluralFormatPropTypes, {
|
|
1818
1376
|
value: PropTypes.any.isRequired,
|
|
1819
1377
|
|
|
1820
1378
|
other: PropTypes.node.isRequired,
|
|
@@ -1859,7 +1417,7 @@ var FormattedMessage = function (_Component) {
|
|
|
1859
1417
|
// Since `values` has already been checked, we know they're not
|
|
1860
1418
|
// different, so the current `values` are carried over so the shallow
|
|
1861
1419
|
// equals comparison on the other props isn't affected by the `values`.
|
|
1862
|
-
var nextPropsToCheck =
|
|
1420
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
1863
1421
|
values: values
|
|
1864
1422
|
});
|
|
1865
1423
|
|
|
@@ -1891,42 +1449,40 @@ var FormattedMessage = function (_Component) {
|
|
|
1891
1449
|
|
|
1892
1450
|
var hasValues = values && Object.keys(values).length > 0;
|
|
1893
1451
|
if (hasValues) {
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
var
|
|
1900
|
-
|
|
1901
|
-
return
|
|
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
|
-
})();
|
|
1452
|
+
// Creates a token with a random UID that should not be guessable or
|
|
1453
|
+
// conflict with other parts of the `message` string.
|
|
1454
|
+
var uid = Math.floor(Math.random() * 0x10000000000).toString(16);
|
|
1455
|
+
|
|
1456
|
+
var generateToken = function () {
|
|
1457
|
+
var counter = 0;
|
|
1458
|
+
return function () {
|
|
1459
|
+
return 'ELEMENT-' + uid + '-' + (counter += 1);
|
|
1460
|
+
};
|
|
1461
|
+
}();
|
|
1462
|
+
|
|
1463
|
+
// Splitting with a delimiter to support IE8. When using a regex
|
|
1464
|
+
// with a capture group IE8 does not include the capture group in
|
|
1465
|
+
// the resulting array.
|
|
1466
|
+
tokenDelimiter = '@__' + uid + '__@';
|
|
1467
|
+
tokenizedValues = {};
|
|
1468
|
+
elements = {};
|
|
1469
|
+
|
|
1470
|
+
// Iterates over the `props` to keep track of any React Element
|
|
1471
|
+
// values so they can be represented by the `token` as a placeholder
|
|
1472
|
+
// when the `message` is formatted. This allows the formatted
|
|
1473
|
+
// message to then be broken-up into parts with references to the
|
|
1474
|
+
// React Elements inserted back in.
|
|
1475
|
+
Object.keys(values).forEach(function (name) {
|
|
1476
|
+
var value = values[name];
|
|
1477
|
+
|
|
1478
|
+
if (isValidElement(value)) {
|
|
1479
|
+
var token = generateToken();
|
|
1480
|
+
tokenizedValues[name] = tokenDelimiter + token + tokenDelimiter;
|
|
1481
|
+
elements[token] = value;
|
|
1482
|
+
} else {
|
|
1483
|
+
tokenizedValues[name] = value;
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1930
1486
|
}
|
|
1931
1487
|
|
|
1932
1488
|
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
@@ -1953,11 +1509,9 @@ var FormattedMessage = function (_Component) {
|
|
|
1953
1509
|
return children.apply(undefined, toConsumableArray(nodes));
|
|
1954
1510
|
}
|
|
1955
1511
|
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
nodes
|
|
1960
|
-
);
|
|
1512
|
+
// Needs to use `createElement()` instead of JSX, otherwise React will
|
|
1513
|
+
// warn about a missing `key` prop with rich-text message formatting.
|
|
1514
|
+
return createElement.apply(undefined, [Component$$1, null].concat(toConsumableArray(nodes)));
|
|
1961
1515
|
}
|
|
1962
1516
|
}]);
|
|
1963
1517
|
return FormattedMessage;
|
|
@@ -1970,7 +1524,7 @@ FormattedMessage.contextTypes = {
|
|
|
1970
1524
|
FormattedMessage.defaultProps = {
|
|
1971
1525
|
values: {}
|
|
1972
1526
|
};
|
|
1973
|
-
process.env.NODE_ENV !== "production" ? FormattedMessage.propTypes =
|
|
1527
|
+
process.env.NODE_ENV !== "production" ? FormattedMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
1974
1528
|
values: PropTypes.object,
|
|
1975
1529
|
tagName: PropTypes.string,
|
|
1976
1530
|
children: PropTypes.func
|
|
@@ -2008,7 +1562,7 @@ var FormattedHTMLMessage = function (_Component) {
|
|
|
2008
1562
|
// Since `values` has already been checked, we know they're not
|
|
2009
1563
|
// different, so the current `values` are carried over so the shallow
|
|
2010
1564
|
// equals comparison on the other props isn't affected by the `values`.
|
|
2011
|
-
var nextPropsToCheck =
|
|
1565
|
+
var nextPropsToCheck = _extends({}, nextProps, {
|
|
2012
1566
|
values: values
|
|
2013
1567
|
});
|
|
2014
1568
|
|
|
@@ -2063,7 +1617,7 @@ FormattedHTMLMessage.contextTypes = {
|
|
|
2063
1617
|
FormattedHTMLMessage.defaultProps = {
|
|
2064
1618
|
values: {}
|
|
2065
1619
|
};
|
|
2066
|
-
process.env.NODE_ENV !== "production" ? FormattedHTMLMessage.propTypes =
|
|
1620
|
+
process.env.NODE_ENV !== "production" ? FormattedHTMLMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
|
|
2067
1621
|
values: PropTypes.object,
|
|
2068
1622
|
tagName: PropTypes.string,
|
|
2069
1623
|
children: PropTypes.func
|