react-router 4.1.2 → 4.2.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/MemoryRouter.js +8 -0
- package/Prompt.js +6 -0
- package/README.md +3 -0
- package/Redirect.js +26 -2
- package/Route.js +26 -19
- package/StaticRouter.js +8 -0
- package/Switch.js +10 -1
- package/es/MemoryRouter.js +5 -0
- package/es/Prompt.js +3 -0
- package/es/Redirect.js +19 -2
- package/es/Route.js +22 -19
- package/es/StaticRouter.js +5 -0
- package/es/Switch.js +7 -1
- package/es/matchPath.js +5 -3
- package/matchPath.js +5 -3
- package/package.json +22 -27
- package/umd/react-router.js +2591 -2191
- package/umd/react-router.min.js +1 -1
package/umd/react-router.js
CHANGED
|
@@ -1,2382 +1,2782 @@
|
|
|
1
|
-
(function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
var resolvePathname = function resolvePathname(to) {
|
|
808
|
-
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
809
|
-
|
|
810
|
-
var toParts = to && to.split('/') || [];
|
|
811
|
-
var fromParts = from && from.split('/') || [];
|
|
812
|
-
|
|
813
|
-
var isToAbs = to && isAbsolute(to);
|
|
814
|
-
var isFromAbs = from && isAbsolute(from);
|
|
815
|
-
var mustEndAbs = isToAbs || isFromAbs;
|
|
816
|
-
|
|
817
|
-
if (to && isAbsolute(to)) {
|
|
818
|
-
// to is absolute
|
|
819
|
-
fromParts = toParts;
|
|
820
|
-
} else if (toParts.length) {
|
|
821
|
-
// to is relative, drop the filename
|
|
822
|
-
fromParts.pop();
|
|
823
|
-
fromParts = fromParts.concat(toParts);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
if (!fromParts.length) return '/';
|
|
827
|
-
|
|
828
|
-
var hasTrailingSlash = void 0;
|
|
829
|
-
if (fromParts.length) {
|
|
830
|
-
var last = fromParts[fromParts.length - 1];
|
|
831
|
-
hasTrailingSlash = last === '.' || last === '..' || last === '';
|
|
832
|
-
} else {
|
|
833
|
-
hasTrailingSlash = false;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
var up = 0;
|
|
837
|
-
for (var i = fromParts.length; i >= 0; i--) {
|
|
838
|
-
var part = fromParts[i];
|
|
839
|
-
|
|
840
|
-
if (part === '.') {
|
|
841
|
-
spliceOne(fromParts, i);
|
|
842
|
-
} else if (part === '..') {
|
|
843
|
-
spliceOne(fromParts, i);
|
|
844
|
-
up++;
|
|
845
|
-
} else if (up) {
|
|
846
|
-
spliceOne(fromParts, i);
|
|
847
|
-
up--;
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
if (!mustEndAbs) for (; up--; up) {
|
|
852
|
-
fromParts.unshift('..');
|
|
853
|
-
}if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
|
|
854
|
-
|
|
855
|
-
var result = fromParts.join('/');
|
|
856
|
-
|
|
857
|
-
if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
|
|
858
|
-
|
|
859
|
-
return result;
|
|
860
|
-
};
|
|
861
|
-
|
|
862
|
-
module.exports = resolvePathname;
|
|
863
|
-
|
|
864
|
-
/***/ }),
|
|
865
|
-
/* 13 */
|
|
866
|
-
/***/ (function(module, exports) {
|
|
867
|
-
|
|
868
|
-
'use strict';
|
|
869
|
-
|
|
870
|
-
exports.__esModule = true;
|
|
871
|
-
|
|
872
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
873
|
-
|
|
874
|
-
var valueEqual = function valueEqual(a, b) {
|
|
875
|
-
if (a === b) return true;
|
|
876
|
-
|
|
877
|
-
if (a == null || b == null) return false;
|
|
878
|
-
|
|
879
|
-
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
|
|
880
|
-
return valueEqual(item, b[index]);
|
|
881
|
-
});
|
|
882
|
-
|
|
883
|
-
var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
|
|
884
|
-
var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
|
|
885
|
-
|
|
886
|
-
if (aType !== bType) return false;
|
|
887
|
-
|
|
888
|
-
if (aType === 'object') {
|
|
889
|
-
var aValue = a.valueOf();
|
|
890
|
-
var bValue = b.valueOf();
|
|
891
|
-
|
|
892
|
-
if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
|
|
893
|
-
|
|
894
|
-
var aKeys = Object.keys(a);
|
|
895
|
-
var bKeys = Object.keys(b);
|
|
896
|
-
|
|
897
|
-
if (aKeys.length !== bKeys.length) return false;
|
|
898
|
-
|
|
899
|
-
return aKeys.every(function (key) {
|
|
900
|
-
return valueEqual(a[key], b[key]);
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
return false;
|
|
905
|
-
};
|
|
906
|
-
|
|
907
|
-
exports.default = valueEqual;
|
|
908
|
-
|
|
909
|
-
/***/ }),
|
|
910
|
-
/* 14 */
|
|
911
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
912
|
-
|
|
913
|
-
'use strict';
|
|
914
|
-
|
|
915
|
-
exports.__esModule = true;
|
|
916
|
-
|
|
917
|
-
var _warning = __webpack_require__(9);
|
|
918
|
-
|
|
919
|
-
var _warning2 = _interopRequireDefault(_warning);
|
|
920
|
-
|
|
921
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
922
|
-
|
|
923
|
-
var createTransitionManager = function createTransitionManager() {
|
|
924
|
-
var prompt = null;
|
|
925
|
-
|
|
926
|
-
var setPrompt = function setPrompt(nextPrompt) {
|
|
927
|
-
(0, _warning2.default)(prompt == null, 'A history supports only one prompt at a time');
|
|
928
|
-
|
|
929
|
-
prompt = nextPrompt;
|
|
930
|
-
|
|
931
|
-
return function () {
|
|
932
|
-
if (prompt === nextPrompt) prompt = null;
|
|
933
|
-
};
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) {
|
|
937
|
-
// TODO: If another transition starts while we're still confirming
|
|
938
|
-
// the previous one, we may end up in a weird state. Figure out the
|
|
939
|
-
// best way to handle this.
|
|
940
|
-
if (prompt != null) {
|
|
941
|
-
var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
|
|
942
|
-
|
|
943
|
-
if (typeof result === 'string') {
|
|
944
|
-
if (typeof getUserConfirmation === 'function') {
|
|
945
|
-
getUserConfirmation(result, callback);
|
|
946
|
-
} else {
|
|
947
|
-
(0, _warning2.default)(false, 'A history needs a getUserConfirmation function in order to use a prompt message');
|
|
948
|
-
|
|
949
|
-
callback(true);
|
|
950
|
-
}
|
|
951
|
-
} else {
|
|
952
|
-
// Return false from a transition hook to cancel the transition.
|
|
953
|
-
callback(result !== false);
|
|
954
|
-
}
|
|
955
|
-
} else {
|
|
956
|
-
callback(true);
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
var listeners = [];
|
|
961
|
-
|
|
962
|
-
var appendListener = function appendListener(fn) {
|
|
963
|
-
var isActive = true;
|
|
964
|
-
|
|
965
|
-
var listener = function listener() {
|
|
966
|
-
if (isActive) fn.apply(undefined, arguments);
|
|
967
|
-
};
|
|
968
|
-
|
|
969
|
-
listeners.push(listener);
|
|
970
|
-
|
|
971
|
-
return function () {
|
|
972
|
-
isActive = false;
|
|
973
|
-
listeners = listeners.filter(function (item) {
|
|
974
|
-
return item !== listener;
|
|
975
|
-
});
|
|
976
|
-
};
|
|
977
|
-
};
|
|
978
|
-
|
|
979
|
-
var notifyListeners = function notifyListeners() {
|
|
980
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
981
|
-
args[_key] = arguments[_key];
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
listeners.forEach(function (listener) {
|
|
985
|
-
return listener.apply(undefined, args);
|
|
986
|
-
});
|
|
987
|
-
};
|
|
988
|
-
|
|
989
|
-
return {
|
|
990
|
-
setPrompt: setPrompt,
|
|
991
|
-
confirmTransitionTo: confirmTransitionTo,
|
|
992
|
-
appendListener: appendListener,
|
|
993
|
-
notifyListeners: notifyListeners
|
|
994
|
-
};
|
|
995
|
-
};
|
|
996
|
-
|
|
997
|
-
exports.default = createTransitionManager;
|
|
998
|
-
|
|
999
|
-
/***/ }),
|
|
1000
|
-
/* 15 */
|
|
1001
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1002
|
-
|
|
1003
|
-
'use strict';
|
|
1004
|
-
|
|
1005
|
-
exports.__esModule = true;
|
|
1006
|
-
|
|
1007
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1008
|
-
|
|
1009
|
-
var _warning = __webpack_require__(9);
|
|
1010
|
-
|
|
1011
|
-
var _warning2 = _interopRequireDefault(_warning);
|
|
1012
|
-
|
|
1013
|
-
var _invariant = __webpack_require__(16);
|
|
1014
|
-
|
|
1015
|
-
var _invariant2 = _interopRequireDefault(_invariant);
|
|
1016
|
-
|
|
1017
|
-
var _react = __webpack_require__(2);
|
|
1018
|
-
|
|
1019
|
-
var _react2 = _interopRequireDefault(_react);
|
|
1020
|
-
|
|
1021
|
-
var _propTypes = __webpack_require__(3);
|
|
1022
|
-
|
|
1023
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
1024
|
-
|
|
1025
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1026
|
-
|
|
1027
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1028
|
-
|
|
1029
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
1030
|
-
|
|
1031
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* The public API for putting history on context.
|
|
1035
|
-
*/
|
|
1036
|
-
var Router = function (_React$Component) {
|
|
1037
|
-
_inherits(Router, _React$Component);
|
|
1038
|
-
|
|
1039
|
-
function Router() {
|
|
1040
|
-
var _temp, _this, _ret;
|
|
1041
|
-
|
|
1042
|
-
_classCallCheck(this, Router);
|
|
1043
|
-
|
|
1044
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1045
|
-
args[_key] = arguments[_key];
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
|
|
1049
|
-
match: _this.computeMatch(_this.props.history.location.pathname)
|
|
1050
|
-
}, _temp), _possibleConstructorReturn(_this, _ret);
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
Router.prototype.getChildContext = function getChildContext() {
|
|
1054
|
-
return {
|
|
1055
|
-
router: _extends({}, this.context.router, {
|
|
1056
|
-
history: this.props.history,
|
|
1057
|
-
route: {
|
|
1058
|
-
location: this.props.history.location,
|
|
1059
|
-
match: this.state.match
|
|
1060
|
-
}
|
|
1061
|
-
})
|
|
1062
|
-
};
|
|
1063
|
-
};
|
|
1064
|
-
|
|
1065
|
-
Router.prototype.computeMatch = function computeMatch(pathname) {
|
|
1066
|
-
return {
|
|
1067
|
-
path: '/',
|
|
1068
|
-
url: '/',
|
|
1069
|
-
params: {},
|
|
1070
|
-
isExact: pathname === '/'
|
|
1071
|
-
};
|
|
1072
|
-
};
|
|
1073
|
-
|
|
1074
|
-
Router.prototype.componentWillMount = function componentWillMount() {
|
|
1075
|
-
var _this2 = this;
|
|
1076
|
-
|
|
1077
|
-
var _props = this.props,
|
|
1078
|
-
children = _props.children,
|
|
1079
|
-
history = _props.history;
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
!(children == null || _react2.default.Children.count(children) === 1) ? false ? (0, _invariant2.default)(false, 'A <Router> may have only one child element') : (0, _invariant2.default)(false) : void 0;
|
|
1083
|
-
|
|
1084
|
-
// Do this here so we can setState when a <Redirect> changes the
|
|
1085
|
-
// location in componentWillMount. This happens e.g. when doing
|
|
1086
|
-
// server rendering using a <StaticRouter>.
|
|
1087
|
-
this.unlisten = history.listen(function () {
|
|
1088
|
-
_this2.setState({
|
|
1089
|
-
match: _this2.computeMatch(history.location.pathname)
|
|
1090
|
-
});
|
|
1091
|
-
});
|
|
1092
|
-
};
|
|
1093
|
-
|
|
1094
|
-
Router.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
1095
|
-
false ? (0, _warning2.default)(this.props.history === nextProps.history, 'You cannot change <Router history>') : void 0;
|
|
1096
|
-
};
|
|
1097
|
-
|
|
1098
|
-
Router.prototype.componentWillUnmount = function componentWillUnmount() {
|
|
1099
|
-
this.unlisten();
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
|
-
Router.prototype.render = function render() {
|
|
1103
|
-
var children = this.props.children;
|
|
1104
|
-
|
|
1105
|
-
return children ? _react2.default.Children.only(children) : null;
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
return Router;
|
|
1109
|
-
}(_react2.default.Component);
|
|
1110
|
-
|
|
1111
|
-
Router.contextTypes = {
|
|
1112
|
-
router: _propTypes2.default.object
|
|
1113
|
-
};
|
|
1114
|
-
Router.childContextTypes = {
|
|
1115
|
-
router: _propTypes2.default.object.isRequired
|
|
1116
|
-
};
|
|
1117
|
-
exports.default = Router;
|
|
1118
|
-
|
|
1119
|
-
/***/ }),
|
|
1120
|
-
/* 16 */
|
|
1121
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1122
|
-
|
|
1123
|
-
/**
|
|
1124
|
-
* Copyright 2013-2015, Facebook, Inc.
|
|
1125
|
-
* All rights reserved.
|
|
1126
|
-
*
|
|
1127
|
-
* This source code is licensed under the BSD-style license found in the
|
|
1128
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
1129
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
1130
|
-
*/
|
|
1131
|
-
|
|
1132
|
-
'use strict';
|
|
1133
|
-
|
|
1134
|
-
/**
|
|
1135
|
-
* Use invariant() to assert state which your program assumes to be true.
|
|
1136
|
-
*
|
|
1137
|
-
* Provide sprintf-style format (only %s is supported) and arguments
|
|
1138
|
-
* to provide information about what broke and what you were
|
|
1139
|
-
* expecting.
|
|
1140
|
-
*
|
|
1141
|
-
* The invariant message will be stripped in production, but the invariant
|
|
1142
|
-
* will remain to ensure logic does not differ in production.
|
|
1143
|
-
*/
|
|
1144
|
-
|
|
1145
|
-
var invariant = function(condition, format, a, b, c, d, e, f) {
|
|
1146
|
-
if (false) {
|
|
1147
|
-
if (format === undefined) {
|
|
1148
|
-
throw new Error('invariant requires an error message argument');
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
if (!condition) {
|
|
1153
|
-
var error;
|
|
1154
|
-
if (format === undefined) {
|
|
1155
|
-
error = new Error(
|
|
1156
|
-
'Minified exception occurred; use the non-minified dev environment ' +
|
|
1157
|
-
'for the full error message and additional helpful warnings.'
|
|
1158
|
-
);
|
|
1159
|
-
} else {
|
|
1160
|
-
var args = [a, b, c, d, e, f];
|
|
1161
|
-
var argIndex = 0;
|
|
1162
|
-
error = new Error(
|
|
1163
|
-
format.replace(/%s/g, function() { return args[argIndex++]; })
|
|
1164
|
-
);
|
|
1165
|
-
error.name = 'Invariant Violation';
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
1169
|
-
throw error;
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
module.exports = invariant;
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
/***/ }),
|
|
1177
|
-
/* 17 */
|
|
1178
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1179
|
-
|
|
1180
|
-
'use strict';
|
|
1181
|
-
|
|
1182
|
-
exports.__esModule = true;
|
|
1183
|
-
|
|
1184
|
-
var _react = __webpack_require__(2);
|
|
1185
|
-
|
|
1186
|
-
var _react2 = _interopRequireDefault(_react);
|
|
1187
|
-
|
|
1188
|
-
var _propTypes = __webpack_require__(3);
|
|
1189
|
-
|
|
1190
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
4
|
+
(factory((global.ReactRouter = {}),global.React));
|
|
5
|
+
}(this, (function (exports,React) { 'use strict';
|
|
6
|
+
|
|
7
|
+
React = React && React.hasOwnProperty('default') ? React['default'] : React;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Copyright 2014-2015, Facebook, Inc.
|
|
11
|
+
* All rights reserved.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the BSD-style license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
15
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
20
|
+
* This can be used to log issues in development environments in critical
|
|
21
|
+
* paths. Removing the logging code for production environments will keep the
|
|
22
|
+
* same logic and follow the same code paths.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
var __DEV__ = "development" !== 'production';
|
|
26
|
+
|
|
27
|
+
var warning = function() {};
|
|
28
|
+
|
|
29
|
+
if (__DEV__) {
|
|
30
|
+
warning = function(condition, format, args) {
|
|
31
|
+
var len = arguments.length;
|
|
32
|
+
args = new Array(len > 2 ? len - 2 : 0);
|
|
33
|
+
for (var key = 2; key < len; key++) {
|
|
34
|
+
args[key - 2] = arguments[key];
|
|
35
|
+
}
|
|
36
|
+
if (format === undefined) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'`warning(condition, format, ...args)` requires a warning ' +
|
|
39
|
+
'message argument'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (format.length < 10 || (/^[s\W]*$/).test(format)) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
'The warning format should be able to uniquely identify this ' +
|
|
46
|
+
'warning. Please, use a more descriptive format than: ' + format
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!condition) {
|
|
51
|
+
var argIndex = 0;
|
|
52
|
+
var message = 'Warning: ' +
|
|
53
|
+
format.replace(/%s/g, function() {
|
|
54
|
+
return args[argIndex++];
|
|
55
|
+
});
|
|
56
|
+
if (typeof console !== 'undefined') {
|
|
57
|
+
console.error(message);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
61
|
+
// to find the callsite that caused this warning to fire.
|
|
62
|
+
throw new Error(message);
|
|
63
|
+
} catch(x) {}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var warning_1 = warning;
|
|
69
|
+
|
|
70
|
+
function unwrapExports (x) {
|
|
71
|
+
return x && x.__esModule ? x['default'] : x;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function createCommonjsModule(fn, module) {
|
|
75
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
80
|
+
* All rights reserved.
|
|
81
|
+
*
|
|
82
|
+
* This source code is licensed under the BSD-style license found in the
|
|
83
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
84
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
85
|
+
*
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
function makeEmptyFunction(arg) {
|
|
90
|
+
return function () {
|
|
91
|
+
return arg;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This function accepts and discards inputs; it has no side effects. This is
|
|
97
|
+
* primarily useful idiomatically for overridable function endpoints which
|
|
98
|
+
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
99
|
+
*/
|
|
100
|
+
var emptyFunction = function emptyFunction() {};
|
|
101
|
+
|
|
102
|
+
emptyFunction.thatReturns = makeEmptyFunction;
|
|
103
|
+
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
104
|
+
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
105
|
+
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
106
|
+
emptyFunction.thatReturnsThis = function () {
|
|
107
|
+
return this;
|
|
108
|
+
};
|
|
109
|
+
emptyFunction.thatReturnsArgument = function (arg) {
|
|
110
|
+
return arg;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var emptyFunction_1 = emptyFunction;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
117
|
+
* All rights reserved.
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the BSD-style license found in the
|
|
120
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
121
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
122
|
+
*
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
127
|
+
*
|
|
128
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
129
|
+
* to provide information about what broke and what you were
|
|
130
|
+
* expecting.
|
|
131
|
+
*
|
|
132
|
+
* The invariant message will be stripped in production, but the invariant
|
|
133
|
+
* will remain to ensure logic does not differ in production.
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
var validateFormat = function validateFormat(format) {};
|
|
137
|
+
|
|
138
|
+
{
|
|
139
|
+
validateFormat = function validateFormat(format) {
|
|
140
|
+
if (format === undefined) {
|
|
141
|
+
throw new Error('invariant requires an error message argument');
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function invariant(condition, format, a, b, c, d, e, f) {
|
|
147
|
+
validateFormat(format);
|
|
148
|
+
|
|
149
|
+
if (!condition) {
|
|
150
|
+
var error;
|
|
151
|
+
if (format === undefined) {
|
|
152
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
153
|
+
} else {
|
|
154
|
+
var args = [a, b, c, d, e, f];
|
|
155
|
+
var argIndex = 0;
|
|
156
|
+
error = new Error(format.replace(/%s/g, function () {
|
|
157
|
+
return args[argIndex++];
|
|
158
|
+
}));
|
|
159
|
+
error.name = 'Invariant Violation';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var invariant_1 = invariant;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
171
|
+
* This can be used to log issues in development environments in critical
|
|
172
|
+
* paths. Removing the logging code for production environments will keep the
|
|
173
|
+
* same logic and follow the same code paths.
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
var warning$2 = emptyFunction_1;
|
|
177
|
+
|
|
178
|
+
{
|
|
179
|
+
var printWarning = function printWarning(format) {
|
|
180
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
181
|
+
args[_key - 1] = arguments[_key];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
var argIndex = 0;
|
|
185
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
186
|
+
return args[argIndex++];
|
|
187
|
+
});
|
|
188
|
+
if (typeof console !== 'undefined') {
|
|
189
|
+
console.error(message);
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
// --- Welcome to debugging React ---
|
|
193
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
194
|
+
// to find the callsite that caused this warning to fire.
|
|
195
|
+
throw new Error(message);
|
|
196
|
+
} catch (x) {}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
warning$2 = function warning(condition, format) {
|
|
200
|
+
if (format === undefined) {
|
|
201
|
+
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (format.indexOf('Failed Composite propType: ') === 0) {
|
|
205
|
+
return; // Ignore CompositeComponent proptype check.
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!condition) {
|
|
209
|
+
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
210
|
+
args[_key2 - 2] = arguments[_key2];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
printWarning.apply(undefined, [format].concat(args));
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
var warning_1$1 = warning$2;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
222
|
+
* All rights reserved.
|
|
223
|
+
*
|
|
224
|
+
* This source code is licensed under the BSD-style license found in the
|
|
225
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
226
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
230
|
+
|
|
231
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
232
|
+
|
|
233
|
+
{
|
|
234
|
+
var invariant$1 = invariant_1;
|
|
235
|
+
var warning$3 = warning_1$1;
|
|
236
|
+
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
237
|
+
var loggedTypeFailures = {};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Assert that the values match with the type specs.
|
|
242
|
+
* Error messages are memorized and will only be shown once.
|
|
243
|
+
*
|
|
244
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
245
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
246
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
247
|
+
* @param {string} componentName Name of the component for error messages.
|
|
248
|
+
* @param {?Function} getStack Returns the component stack.
|
|
249
|
+
* @private
|
|
250
|
+
*/
|
|
251
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
252
|
+
{
|
|
253
|
+
for (var typeSpecName in typeSpecs) {
|
|
254
|
+
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
|
255
|
+
var error;
|
|
256
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
257
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
258
|
+
// After these have been cleaned up, we'll let them throw.
|
|
259
|
+
try {
|
|
260
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
261
|
+
// behavior as without this statement except with a better message.
|
|
262
|
+
invariant$1(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);
|
|
263
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
|
264
|
+
} catch (ex) {
|
|
265
|
+
error = ex;
|
|
266
|
+
}
|
|
267
|
+
warning$3(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
|
|
268
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
269
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
270
|
+
// same error.
|
|
271
|
+
loggedTypeFailures[error.message] = true;
|
|
272
|
+
|
|
273
|
+
var stack = getStack ? getStack() : '';
|
|
274
|
+
|
|
275
|
+
warning$3(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
var checkPropTypes_1 = checkPropTypes;
|
|
283
|
+
|
|
284
|
+
var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
285
|
+
/* global Symbol */
|
|
286
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
287
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Returns the iterator method function contained on the iterable object.
|
|
291
|
+
*
|
|
292
|
+
* Be sure to invoke the function with the iterable as context:
|
|
293
|
+
*
|
|
294
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
295
|
+
* if (iteratorFn) {
|
|
296
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
297
|
+
* ...
|
|
298
|
+
* }
|
|
299
|
+
*
|
|
300
|
+
* @param {?object} maybeIterable
|
|
301
|
+
* @return {?function}
|
|
302
|
+
*/
|
|
303
|
+
function getIteratorFn(maybeIterable) {
|
|
304
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
305
|
+
if (typeof iteratorFn === 'function') {
|
|
306
|
+
return iteratorFn;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
312
|
+
* supplied to React components. Example usage:
|
|
313
|
+
*
|
|
314
|
+
* var Props = require('ReactPropTypes');
|
|
315
|
+
* var MyArticle = React.createClass({
|
|
316
|
+
* propTypes: {
|
|
317
|
+
* // An optional string prop named "description".
|
|
318
|
+
* description: Props.string,
|
|
319
|
+
*
|
|
320
|
+
* // A required enum prop named "category".
|
|
321
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
322
|
+
*
|
|
323
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
324
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
325
|
+
* },
|
|
326
|
+
* render: function() { ... }
|
|
327
|
+
* });
|
|
328
|
+
*
|
|
329
|
+
* A more formal specification of how these methods are used:
|
|
330
|
+
*
|
|
331
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
332
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
333
|
+
*
|
|
334
|
+
* Each and every declaration produces a function with the same signature. This
|
|
335
|
+
* allows the creation of custom validation functions. For example:
|
|
336
|
+
*
|
|
337
|
+
* var MyLink = React.createClass({
|
|
338
|
+
* propTypes: {
|
|
339
|
+
* // An optional string or URI prop named "href".
|
|
340
|
+
* href: function(props, propName, componentName) {
|
|
341
|
+
* var propValue = props[propName];
|
|
342
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
343
|
+
* !(propValue instanceof URI)) {
|
|
344
|
+
* return new Error(
|
|
345
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
346
|
+
* componentName
|
|
347
|
+
* );
|
|
348
|
+
* }
|
|
349
|
+
* }
|
|
350
|
+
* },
|
|
351
|
+
* render: function() {...}
|
|
352
|
+
* });
|
|
353
|
+
*
|
|
354
|
+
* @internal
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
358
|
+
|
|
359
|
+
// Important!
|
|
360
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
361
|
+
var ReactPropTypes = {
|
|
362
|
+
array: createPrimitiveTypeChecker('array'),
|
|
363
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
364
|
+
func: createPrimitiveTypeChecker('function'),
|
|
365
|
+
number: createPrimitiveTypeChecker('number'),
|
|
366
|
+
object: createPrimitiveTypeChecker('object'),
|
|
367
|
+
string: createPrimitiveTypeChecker('string'),
|
|
368
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
369
|
+
|
|
370
|
+
any: createAnyTypeChecker(),
|
|
371
|
+
arrayOf: createArrayOfTypeChecker,
|
|
372
|
+
element: createElementTypeChecker(),
|
|
373
|
+
instanceOf: createInstanceTypeChecker,
|
|
374
|
+
node: createNodeChecker(),
|
|
375
|
+
objectOf: createObjectOfTypeChecker,
|
|
376
|
+
oneOf: createEnumTypeChecker,
|
|
377
|
+
oneOfType: createUnionTypeChecker,
|
|
378
|
+
shape: createShapeTypeChecker
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
383
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
384
|
+
*/
|
|
385
|
+
/*eslint-disable no-self-compare*/
|
|
386
|
+
function is(x, y) {
|
|
387
|
+
// SameValue algorithm
|
|
388
|
+
if (x === y) {
|
|
389
|
+
// Steps 1-5, 7-10
|
|
390
|
+
// Steps 6.b-6.e: +0 != -0
|
|
391
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
392
|
+
} else {
|
|
393
|
+
// Step 6.a: NaN == NaN
|
|
394
|
+
return x !== x && y !== y;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/*eslint-enable no-self-compare*/
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
401
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
402
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
403
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
404
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
405
|
+
*/
|
|
406
|
+
function PropTypeError(message) {
|
|
407
|
+
this.message = message;
|
|
408
|
+
this.stack = '';
|
|
409
|
+
}
|
|
410
|
+
// Make `instanceof Error` still work for returned errors.
|
|
411
|
+
PropTypeError.prototype = Error.prototype;
|
|
412
|
+
|
|
413
|
+
function createChainableTypeChecker(validate) {
|
|
414
|
+
{
|
|
415
|
+
var manualPropTypeCallCache = {};
|
|
416
|
+
var manualPropTypeWarningCount = 0;
|
|
417
|
+
}
|
|
418
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
419
|
+
componentName = componentName || ANONYMOUS;
|
|
420
|
+
propFullName = propFullName || propName;
|
|
421
|
+
|
|
422
|
+
if (secret !== ReactPropTypesSecret_1) {
|
|
423
|
+
if (throwOnDirectAccess) {
|
|
424
|
+
// New behavior only for users of `prop-types` package
|
|
425
|
+
invariant_1(
|
|
426
|
+
false,
|
|
427
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
428
|
+
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
429
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
430
|
+
);
|
|
431
|
+
} else if ("development" !== 'production' && typeof console !== 'undefined') {
|
|
432
|
+
// Old behavior for people using React.PropTypes
|
|
433
|
+
var cacheKey = componentName + ':' + propName;
|
|
434
|
+
if (
|
|
435
|
+
!manualPropTypeCallCache[cacheKey] &&
|
|
436
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
437
|
+
manualPropTypeWarningCount < 3
|
|
438
|
+
) {
|
|
439
|
+
warning_1$1(
|
|
440
|
+
false,
|
|
441
|
+
'You are manually calling a React.PropTypes validation ' +
|
|
442
|
+
'function for the `%s` prop on `%s`. This is deprecated ' +
|
|
443
|
+
'and will throw in the standalone `prop-types` package. ' +
|
|
444
|
+
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
445
|
+
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
|
|
446
|
+
propFullName,
|
|
447
|
+
componentName
|
|
448
|
+
);
|
|
449
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
450
|
+
manualPropTypeWarningCount++;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (props[propName] == null) {
|
|
455
|
+
if (isRequired) {
|
|
456
|
+
if (props[propName] === null) {
|
|
457
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
458
|
+
}
|
|
459
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
460
|
+
}
|
|
461
|
+
return null;
|
|
462
|
+
} else {
|
|
463
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
468
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
469
|
+
|
|
470
|
+
return chainedCheckType;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
474
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
475
|
+
var propValue = props[propName];
|
|
476
|
+
var propType = getPropType(propValue);
|
|
477
|
+
if (propType !== expectedType) {
|
|
478
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
479
|
+
// check, but we can offer a more precise error message here rather than
|
|
480
|
+
// 'of type `object`'.
|
|
481
|
+
var preciseType = getPreciseType(propValue);
|
|
482
|
+
|
|
483
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
|
484
|
+
}
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
return createChainableTypeChecker(validate);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function createAnyTypeChecker() {
|
|
491
|
+
return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
495
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
496
|
+
if (typeof typeChecker !== 'function') {
|
|
497
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
498
|
+
}
|
|
499
|
+
var propValue = props[propName];
|
|
500
|
+
if (!Array.isArray(propValue)) {
|
|
501
|
+
var propType = getPropType(propValue);
|
|
502
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
503
|
+
}
|
|
504
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
505
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
|
506
|
+
if (error instanceof Error) {
|
|
507
|
+
return error;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
return createChainableTypeChecker(validate);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function createElementTypeChecker() {
|
|
516
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
517
|
+
var propValue = props[propName];
|
|
518
|
+
if (!isValidElement(propValue)) {
|
|
519
|
+
var propType = getPropType(propValue);
|
|
520
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
521
|
+
}
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
524
|
+
return createChainableTypeChecker(validate);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
528
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
529
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
530
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
531
|
+
var actualClassName = getClassName(props[propName]);
|
|
532
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
533
|
+
}
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
return createChainableTypeChecker(validate);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function createEnumTypeChecker(expectedValues) {
|
|
540
|
+
if (!Array.isArray(expectedValues)) {
|
|
541
|
+
warning_1$1(false, 'Invalid argument supplied to oneOf, expected an instance of array.');
|
|
542
|
+
return emptyFunction_1.thatReturnsNull;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
546
|
+
var propValue = props[propName];
|
|
547
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
548
|
+
if (is(propValue, expectedValues[i])) {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
var valuesString = JSON.stringify(expectedValues);
|
|
554
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
555
|
+
}
|
|
556
|
+
return createChainableTypeChecker(validate);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
560
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
561
|
+
if (typeof typeChecker !== 'function') {
|
|
562
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
563
|
+
}
|
|
564
|
+
var propValue = props[propName];
|
|
565
|
+
var propType = getPropType(propValue);
|
|
566
|
+
if (propType !== 'object') {
|
|
567
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
568
|
+
}
|
|
569
|
+
for (var key in propValue) {
|
|
570
|
+
if (propValue.hasOwnProperty(key)) {
|
|
571
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
572
|
+
if (error instanceof Error) {
|
|
573
|
+
return error;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
return createChainableTypeChecker(validate);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
583
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
584
|
+
warning_1$1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.');
|
|
585
|
+
return emptyFunction_1.thatReturnsNull;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
589
|
+
var checker = arrayOfTypeCheckers[i];
|
|
590
|
+
if (typeof checker !== 'function') {
|
|
591
|
+
warning_1$1(
|
|
592
|
+
false,
|
|
593
|
+
'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' +
|
|
594
|
+
'received %s at index %s.',
|
|
595
|
+
getPostfixForTypeWarning(checker),
|
|
596
|
+
i
|
|
597
|
+
);
|
|
598
|
+
return emptyFunction_1.thatReturnsNull;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
603
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
604
|
+
var checker = arrayOfTypeCheckers[i];
|
|
605
|
+
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
611
|
+
}
|
|
612
|
+
return createChainableTypeChecker(validate);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function createNodeChecker() {
|
|
616
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
617
|
+
if (!isNode(props[propName])) {
|
|
618
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
619
|
+
}
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
return createChainableTypeChecker(validate);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
626
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
627
|
+
var propValue = props[propName];
|
|
628
|
+
var propType = getPropType(propValue);
|
|
629
|
+
if (propType !== 'object') {
|
|
630
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
631
|
+
}
|
|
632
|
+
for (var key in shapeTypes) {
|
|
633
|
+
var checker = shapeTypes[key];
|
|
634
|
+
if (!checker) {
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
638
|
+
if (error) {
|
|
639
|
+
return error;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
return createChainableTypeChecker(validate);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function isNode(propValue) {
|
|
648
|
+
switch (typeof propValue) {
|
|
649
|
+
case 'number':
|
|
650
|
+
case 'string':
|
|
651
|
+
case 'undefined':
|
|
652
|
+
return true;
|
|
653
|
+
case 'boolean':
|
|
654
|
+
return !propValue;
|
|
655
|
+
case 'object':
|
|
656
|
+
if (Array.isArray(propValue)) {
|
|
657
|
+
return propValue.every(isNode);
|
|
658
|
+
}
|
|
659
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
664
|
+
if (iteratorFn) {
|
|
665
|
+
var iterator = iteratorFn.call(propValue);
|
|
666
|
+
var step;
|
|
667
|
+
if (iteratorFn !== propValue.entries) {
|
|
668
|
+
while (!(step = iterator.next()).done) {
|
|
669
|
+
if (!isNode(step.value)) {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
} else {
|
|
674
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
675
|
+
while (!(step = iterator.next()).done) {
|
|
676
|
+
var entry = step.value;
|
|
677
|
+
if (entry) {
|
|
678
|
+
if (!isNode(entry[1])) {
|
|
679
|
+
return false;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
} else {
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
return true;
|
|
689
|
+
default:
|
|
690
|
+
return false;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function isSymbol(propType, propValue) {
|
|
695
|
+
// Native Symbol.
|
|
696
|
+
if (propType === 'symbol') {
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
701
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
702
|
+
return true;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
706
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
714
|
+
function getPropType(propValue) {
|
|
715
|
+
var propType = typeof propValue;
|
|
716
|
+
if (Array.isArray(propValue)) {
|
|
717
|
+
return 'array';
|
|
718
|
+
}
|
|
719
|
+
if (propValue instanceof RegExp) {
|
|
720
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
721
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
722
|
+
// passes PropTypes.object.
|
|
723
|
+
return 'object';
|
|
724
|
+
}
|
|
725
|
+
if (isSymbol(propType, propValue)) {
|
|
726
|
+
return 'symbol';
|
|
727
|
+
}
|
|
728
|
+
return propType;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
732
|
+
// See `createPrimitiveTypeChecker`.
|
|
733
|
+
function getPreciseType(propValue) {
|
|
734
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
735
|
+
return '' + propValue;
|
|
736
|
+
}
|
|
737
|
+
var propType = getPropType(propValue);
|
|
738
|
+
if (propType === 'object') {
|
|
739
|
+
if (propValue instanceof Date) {
|
|
740
|
+
return 'date';
|
|
741
|
+
} else if (propValue instanceof RegExp) {
|
|
742
|
+
return 'regexp';
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return propType;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
749
|
+
// For example, "undefined" or "of type array"
|
|
750
|
+
function getPostfixForTypeWarning(value) {
|
|
751
|
+
var type = getPreciseType(value);
|
|
752
|
+
switch (type) {
|
|
753
|
+
case 'array':
|
|
754
|
+
case 'object':
|
|
755
|
+
return 'an ' + type;
|
|
756
|
+
case 'boolean':
|
|
757
|
+
case 'date':
|
|
758
|
+
case 'regexp':
|
|
759
|
+
return 'a ' + type;
|
|
760
|
+
default:
|
|
761
|
+
return type;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// Returns class name of the object, if any.
|
|
766
|
+
function getClassName(propValue) {
|
|
767
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
768
|
+
return ANONYMOUS;
|
|
769
|
+
}
|
|
770
|
+
return propValue.constructor.name;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
|
774
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
775
|
+
|
|
776
|
+
return ReactPropTypes;
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
var propTypes = createCommonjsModule(function (module) {
|
|
780
|
+
/**
|
|
781
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
782
|
+
* All rights reserved.
|
|
783
|
+
*
|
|
784
|
+
* This source code is licensed under the BSD-style license found in the
|
|
785
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
786
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
787
|
+
*/
|
|
788
|
+
|
|
789
|
+
{
|
|
790
|
+
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
|
|
791
|
+
Symbol.for &&
|
|
792
|
+
Symbol.for('react.element')) ||
|
|
793
|
+
0xeac7;
|
|
794
|
+
|
|
795
|
+
var isValidElement = function(object) {
|
|
796
|
+
return typeof object === 'object' &&
|
|
797
|
+
object !== null &&
|
|
798
|
+
object.$$typeof === REACT_ELEMENT_TYPE;
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
802
|
+
// http://fb.me/prop-types-in-prod
|
|
803
|
+
var throwOnDirectAccess = true;
|
|
804
|
+
module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
|
|
805
|
+
}
|
|
806
|
+
});
|
|
1191
807
|
|
|
1192
|
-
|
|
808
|
+
var PathUtils = createCommonjsModule(function (module, exports) {
|
|
809
|
+
'use strict';
|
|
1193
810
|
|
|
1194
|
-
|
|
811
|
+
exports.__esModule = true;
|
|
812
|
+
var addLeadingSlash = exports.addLeadingSlash = function addLeadingSlash(path) {
|
|
813
|
+
return path.charAt(0) === '/' ? path : '/' + path;
|
|
814
|
+
};
|
|
1195
815
|
|
|
1196
|
-
|
|
816
|
+
var stripLeadingSlash = exports.stripLeadingSlash = function stripLeadingSlash(path) {
|
|
817
|
+
return path.charAt(0) === '/' ? path.substr(1) : path;
|
|
818
|
+
};
|
|
1197
819
|
|
|
1198
|
-
|
|
820
|
+
var hasBasename = exports.hasBasename = function hasBasename(path, prefix) {
|
|
821
|
+
return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
|
|
822
|
+
};
|
|
1199
823
|
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
*/
|
|
1204
|
-
var Prompt = function (_React$Component) {
|
|
1205
|
-
_inherits(Prompt, _React$Component);
|
|
824
|
+
var stripBasename = exports.stripBasename = function stripBasename(path, prefix) {
|
|
825
|
+
return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
|
|
826
|
+
};
|
|
1206
827
|
|
|
1207
|
-
|
|
1208
|
-
|
|
828
|
+
var stripTrailingSlash = exports.stripTrailingSlash = function stripTrailingSlash(path) {
|
|
829
|
+
return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
|
|
830
|
+
};
|
|
1209
831
|
|
|
1210
|
-
|
|
1211
|
-
|
|
832
|
+
var parsePath = exports.parsePath = function parsePath(path) {
|
|
833
|
+
var pathname = path || '/';
|
|
834
|
+
var search = '';
|
|
835
|
+
var hash = '';
|
|
1212
836
|
|
|
1213
|
-
|
|
1214
|
-
|
|
837
|
+
var hashIndex = pathname.indexOf('#');
|
|
838
|
+
if (hashIndex !== -1) {
|
|
839
|
+
hash = pathname.substr(hashIndex);
|
|
840
|
+
pathname = pathname.substr(0, hashIndex);
|
|
841
|
+
}
|
|
1215
842
|
|
|
1216
|
-
|
|
1217
|
-
|
|
843
|
+
var searchIndex = pathname.indexOf('?');
|
|
844
|
+
if (searchIndex !== -1) {
|
|
845
|
+
search = pathname.substr(searchIndex);
|
|
846
|
+
pathname = pathname.substr(0, searchIndex);
|
|
847
|
+
}
|
|
1218
848
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
849
|
+
return {
|
|
850
|
+
pathname: pathname,
|
|
851
|
+
search: search === '?' ? '' : search,
|
|
852
|
+
hash: hash === '#' ? '' : hash
|
|
853
|
+
};
|
|
854
|
+
};
|
|
1225
855
|
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
856
|
+
var createPath = exports.createPath = function createPath(location) {
|
|
857
|
+
var pathname = location.pathname,
|
|
858
|
+
search = location.search,
|
|
859
|
+
hash = location.hash;
|
|
1229
860
|
|
|
1230
|
-
Prompt.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
1231
|
-
if (nextProps.when) {
|
|
1232
|
-
if (!this.props.when || this.props.message !== nextProps.message) this.enable(nextProps.message);
|
|
1233
|
-
} else {
|
|
1234
|
-
this.disable();
|
|
1235
|
-
}
|
|
1236
|
-
};
|
|
1237
861
|
|
|
1238
|
-
|
|
1239
|
-
this.disable();
|
|
1240
|
-
};
|
|
862
|
+
var path = pathname || '/';
|
|
1241
863
|
|
|
1242
|
-
|
|
1243
|
-
return null;
|
|
1244
|
-
};
|
|
864
|
+
if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search;
|
|
1245
865
|
|
|
1246
|
-
|
|
1247
|
-
}(_react2.default.Component);
|
|
866
|
+
if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash;
|
|
1248
867
|
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
Prompt.contextTypes = {
|
|
1253
|
-
router: _propTypes2.default.shape({
|
|
1254
|
-
history: _propTypes2.default.shape({
|
|
1255
|
-
block: _propTypes2.default.func.isRequired
|
|
1256
|
-
}).isRequired
|
|
1257
|
-
}).isRequired
|
|
1258
|
-
};
|
|
1259
|
-
exports.default = Prompt;
|
|
868
|
+
return path;
|
|
869
|
+
};
|
|
870
|
+
});
|
|
1260
871
|
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
872
|
+
var PathUtils_1 = PathUtils.addLeadingSlash;
|
|
873
|
+
var PathUtils_6 = PathUtils.parsePath;
|
|
874
|
+
var PathUtils_7 = PathUtils.createPath;
|
|
1264
875
|
|
|
1265
|
-
|
|
876
|
+
function isAbsolute(pathname) {
|
|
877
|
+
return pathname.charAt(0) === '/';
|
|
878
|
+
}
|
|
1266
879
|
|
|
1267
|
-
|
|
880
|
+
// About 1.5x faster than the two-arg version of Array#splice()
|
|
881
|
+
function spliceOne(list, index) {
|
|
882
|
+
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
|
|
883
|
+
list[i] = list[k];
|
|
884
|
+
}
|
|
1268
885
|
|
|
1269
|
-
|
|
886
|
+
list.pop();
|
|
887
|
+
}
|
|
1270
888
|
|
|
1271
|
-
|
|
889
|
+
// This implementation is based heavily on node's url.parse
|
|
890
|
+
function resolvePathname(to) {
|
|
891
|
+
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
1272
892
|
|
|
1273
|
-
|
|
893
|
+
var toParts = to && to.split('/') || [];
|
|
894
|
+
var fromParts = from && from.split('/') || [];
|
|
1274
895
|
|
|
1275
|
-
|
|
896
|
+
var isToAbs = to && isAbsolute(to);
|
|
897
|
+
var isFromAbs = from && isAbsolute(from);
|
|
898
|
+
var mustEndAbs = isToAbs || isFromAbs;
|
|
1276
899
|
|
|
1277
|
-
|
|
900
|
+
if (to && isAbsolute(to)) {
|
|
901
|
+
// to is absolute
|
|
902
|
+
fromParts = toParts;
|
|
903
|
+
} else if (toParts.length) {
|
|
904
|
+
// to is relative, drop the filename
|
|
905
|
+
fromParts.pop();
|
|
906
|
+
fromParts = fromParts.concat(toParts);
|
|
907
|
+
}
|
|
1278
908
|
|
|
1279
|
-
|
|
909
|
+
if (!fromParts.length) return '/';
|
|
1280
910
|
|
|
1281
|
-
|
|
911
|
+
var hasTrailingSlash = void 0;
|
|
912
|
+
if (fromParts.length) {
|
|
913
|
+
var last = fromParts[fromParts.length - 1];
|
|
914
|
+
hasTrailingSlash = last === '.' || last === '..' || last === '';
|
|
915
|
+
} else {
|
|
916
|
+
hasTrailingSlash = false;
|
|
917
|
+
}
|
|
1282
918
|
|
|
1283
|
-
|
|
919
|
+
var up = 0;
|
|
920
|
+
for (var i = fromParts.length; i >= 0; i--) {
|
|
921
|
+
var part = fromParts[i];
|
|
1284
922
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
923
|
+
if (part === '.') {
|
|
924
|
+
spliceOne(fromParts, i);
|
|
925
|
+
} else if (part === '..') {
|
|
926
|
+
spliceOne(fromParts, i);
|
|
927
|
+
up++;
|
|
928
|
+
} else if (up) {
|
|
929
|
+
spliceOne(fromParts, i);
|
|
930
|
+
up--;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
1291
933
|
|
|
1292
|
-
|
|
1293
|
-
|
|
934
|
+
if (!mustEndAbs) for (; up--; up) {
|
|
935
|
+
fromParts.unshift('..');
|
|
936
|
+
}if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
|
|
1294
937
|
|
|
1295
|
-
|
|
1296
|
-
}
|
|
938
|
+
var result = fromParts.join('/');
|
|
1297
939
|
|
|
1298
|
-
|
|
1299
|
-
return this.context.router && this.context.router.staticContext;
|
|
1300
|
-
};
|
|
940
|
+
if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
|
|
1301
941
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
};
|
|
942
|
+
return result;
|
|
943
|
+
}
|
|
1305
944
|
|
|
1306
|
-
Redirect.prototype.componentDidMount = function componentDidMount() {
|
|
1307
|
-
if (!this.isStatic()) this.perform();
|
|
1308
|
-
};
|
|
1309
945
|
|
|
1310
|
-
Redirect.prototype.perform = function perform() {
|
|
1311
|
-
var history = this.context.router.history;
|
|
1312
|
-
var _props = this.props,
|
|
1313
|
-
push = _props.push,
|
|
1314
|
-
to = _props.to;
|
|
1315
946
|
|
|
947
|
+
var resolvePathname$2 = Object.freeze({
|
|
948
|
+
default: resolvePathname
|
|
949
|
+
});
|
|
1316
950
|
|
|
1317
|
-
|
|
1318
|
-
history.push(to);
|
|
1319
|
-
} else {
|
|
1320
|
-
history.replace(to);
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
951
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
1323
952
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
};
|
|
953
|
+
function valueEqual(a, b) {
|
|
954
|
+
if (a === b) return true;
|
|
1327
955
|
|
|
1328
|
-
|
|
1329
|
-
}(_react2.default.Component);
|
|
956
|
+
if (a == null || b == null) return false;
|
|
1330
957
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
history: _propTypes2.default.shape({
|
|
1337
|
-
push: _propTypes2.default.func.isRequired,
|
|
1338
|
-
replace: _propTypes2.default.func.isRequired
|
|
1339
|
-
}).isRequired,
|
|
1340
|
-
staticContext: _propTypes2.default.object
|
|
1341
|
-
}).isRequired
|
|
1342
|
-
};
|
|
1343
|
-
exports.default = Redirect;
|
|
958
|
+
if (Array.isArray(a)) {
|
|
959
|
+
return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
|
|
960
|
+
return valueEqual(item, b[index]);
|
|
961
|
+
});
|
|
962
|
+
}
|
|
1344
963
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
964
|
+
var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
|
|
965
|
+
var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
|
|
1348
966
|
|
|
1349
|
-
|
|
967
|
+
if (aType !== bType) return false;
|
|
1350
968
|
|
|
1351
|
-
|
|
969
|
+
if (aType === 'object') {
|
|
970
|
+
var aValue = a.valueOf();
|
|
971
|
+
var bValue = b.valueOf();
|
|
1352
972
|
|
|
1353
|
-
|
|
973
|
+
if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
|
|
1354
974
|
|
|
1355
|
-
|
|
975
|
+
var aKeys = Object.keys(a);
|
|
976
|
+
var bKeys = Object.keys(b);
|
|
1356
977
|
|
|
1357
|
-
|
|
978
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
1358
979
|
|
|
1359
|
-
|
|
980
|
+
return aKeys.every(function (key) {
|
|
981
|
+
return valueEqual(a[key], b[key]);
|
|
982
|
+
});
|
|
983
|
+
}
|
|
1360
984
|
|
|
1361
|
-
|
|
985
|
+
return false;
|
|
986
|
+
}
|
|
1362
987
|
|
|
1363
|
-
var _propTypes = __webpack_require__(3);
|
|
1364
988
|
|
|
1365
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
1366
989
|
|
|
1367
|
-
|
|
990
|
+
var valueEqual$2 = Object.freeze({
|
|
991
|
+
default: valueEqual
|
|
992
|
+
});
|
|
1368
993
|
|
|
1369
|
-
|
|
994
|
+
var _resolvePathname = ( resolvePathname$2 && resolvePathname ) || resolvePathname$2;
|
|
1370
995
|
|
|
1371
|
-
|
|
996
|
+
var _valueEqual = ( valueEqual$2 && valueEqual ) || valueEqual$2;
|
|
1372
997
|
|
|
1373
|
-
|
|
998
|
+
var LocationUtils = createCommonjsModule(function (module, exports) {
|
|
999
|
+
'use strict';
|
|
1374
1000
|
|
|
1375
|
-
|
|
1001
|
+
exports.__esModule = true;
|
|
1002
|
+
exports.locationsAreEqual = exports.createLocation = undefined;
|
|
1376
1003
|
|
|
1377
|
-
|
|
1004
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1378
1005
|
|
|
1379
|
-
/**
|
|
1380
|
-
* The public API for matching a single path and rendering.
|
|
1381
|
-
*/
|
|
1382
|
-
var Route = function (_React$Component) {
|
|
1383
|
-
_inherits(Route, _React$Component);
|
|
1384
1006
|
|
|
1385
|
-
function Route() {
|
|
1386
|
-
var _temp, _this, _ret;
|
|
1387
1007
|
|
|
1388
|
-
|
|
1008
|
+
var _resolvePathname2 = _interopRequireDefault(_resolvePathname);
|
|
1389
1009
|
|
|
1390
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1391
|
-
args[_key] = arguments[_key];
|
|
1392
|
-
}
|
|
1393
1010
|
|
|
1394
|
-
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
|
|
1395
|
-
match: _this.computeMatch(_this.props, _this.context.router)
|
|
1396
|
-
}, _temp), _possibleConstructorReturn(_this, _ret);
|
|
1397
|
-
}
|
|
1398
1011
|
|
|
1399
|
-
|
|
1400
|
-
return {
|
|
1401
|
-
router: _extends({}, this.context.router, {
|
|
1402
|
-
route: {
|
|
1403
|
-
location: this.props.location || this.context.router.route.location,
|
|
1404
|
-
match: this.state.match
|
|
1405
|
-
}
|
|
1406
|
-
})
|
|
1407
|
-
};
|
|
1408
|
-
};
|
|
1012
|
+
var _valueEqual2 = _interopRequireDefault(_valueEqual);
|
|
1409
1013
|
|
|
1410
|
-
Route.prototype.computeMatch = function computeMatch(_ref, _ref2) {
|
|
1411
|
-
var computedMatch = _ref.computedMatch,
|
|
1412
|
-
location = _ref.location,
|
|
1413
|
-
path = _ref.path,
|
|
1414
|
-
strict = _ref.strict,
|
|
1415
|
-
exact = _ref.exact;
|
|
1416
|
-
var route = _ref2.route;
|
|
1417
1014
|
|
|
1418
|
-
if (computedMatch) return computedMatch; // <Switch> already computed the match for us
|
|
1419
1015
|
|
|
1420
|
-
|
|
1016
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1421
1017
|
|
|
1422
|
-
|
|
1423
|
-
|
|
1018
|
+
var createLocation = exports.createLocation = function createLocation(path, state, key, currentLocation) {
|
|
1019
|
+
var location = void 0;
|
|
1020
|
+
if (typeof path === 'string') {
|
|
1021
|
+
// Two-arg form: push(path, state)
|
|
1022
|
+
location = (0, PathUtils.parsePath)(path);
|
|
1023
|
+
location.state = state;
|
|
1024
|
+
} else {
|
|
1025
|
+
// One-arg form: push(location)
|
|
1026
|
+
location = _extends({}, path);
|
|
1424
1027
|
|
|
1425
|
-
|
|
1426
|
-
var _props = this.props,
|
|
1427
|
-
component = _props.component,
|
|
1428
|
-
render = _props.render,
|
|
1429
|
-
children = _props.children;
|
|
1028
|
+
if (location.pathname === undefined) location.pathname = '';
|
|
1430
1029
|
|
|
1030
|
+
if (location.search) {
|
|
1031
|
+
if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
|
|
1032
|
+
} else {
|
|
1033
|
+
location.search = '';
|
|
1034
|
+
}
|
|
1431
1035
|
|
|
1432
|
-
|
|
1036
|
+
if (location.hash) {
|
|
1037
|
+
if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
|
|
1038
|
+
} else {
|
|
1039
|
+
location.hash = '';
|
|
1040
|
+
}
|
|
1433
1041
|
|
|
1434
|
-
|
|
1042
|
+
if (state !== undefined && location.state === undefined) location.state = state;
|
|
1043
|
+
}
|
|
1435
1044
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1045
|
+
try {
|
|
1046
|
+
location.pathname = decodeURI(location.pathname);
|
|
1047
|
+
} catch (e) {
|
|
1048
|
+
if (e instanceof URIError) {
|
|
1049
|
+
throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
|
|
1050
|
+
} else {
|
|
1051
|
+
throw e;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1438
1054
|
|
|
1439
|
-
|
|
1440
|
-
false ? (0, _warning2.default)(!(nextProps.location && !this.props.location), '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') : void 0;
|
|
1055
|
+
if (key) location.key = key;
|
|
1441
1056
|
|
|
1442
|
-
|
|
1057
|
+
if (currentLocation) {
|
|
1058
|
+
// Resolve incomplete/relative pathname relative to current location.
|
|
1059
|
+
if (!location.pathname) {
|
|
1060
|
+
location.pathname = currentLocation.pathname;
|
|
1061
|
+
} else if (location.pathname.charAt(0) !== '/') {
|
|
1062
|
+
location.pathname = (0, _resolvePathname2.default)(location.pathname, currentLocation.pathname);
|
|
1063
|
+
}
|
|
1064
|
+
} else {
|
|
1065
|
+
// When there is no prior location and pathname is empty, set it to /
|
|
1066
|
+
if (!location.pathname) {
|
|
1067
|
+
location.pathname = '/';
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1443
1070
|
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
});
|
|
1447
|
-
};
|
|
1071
|
+
return location;
|
|
1072
|
+
};
|
|
1448
1073
|
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
component = _props2.component,
|
|
1454
|
-
render = _props2.render;
|
|
1455
|
-
var _context$router = this.context.router,
|
|
1456
|
-
history = _context$router.history,
|
|
1457
|
-
route = _context$router.route,
|
|
1458
|
-
staticContext = _context$router.staticContext;
|
|
1074
|
+
var locationsAreEqual = exports.locationsAreEqual = function locationsAreEqual(a, b) {
|
|
1075
|
+
return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && (0, _valueEqual2.default)(a.state, b.state);
|
|
1076
|
+
};
|
|
1077
|
+
});
|
|
1459
1078
|
|
|
1460
|
-
|
|
1461
|
-
|
|
1079
|
+
var createTransitionManager_1 = createCommonjsModule(function (module, exports) {
|
|
1080
|
+
'use strict';
|
|
1462
1081
|
|
|
1463
|
-
|
|
1464
|
-
match ? _react2.default.createElement(component, props) : null : render ? // render prop is next, only called if there's a match
|
|
1465
|
-
match ? render(props) : null : children ? // children come last, always called
|
|
1466
|
-
typeof children === 'function' ? children(props) : !Array.isArray(children) || children.length ? // Preact defaults to empty children array
|
|
1467
|
-
_react2.default.Children.only(children) : null : null;
|
|
1468
|
-
};
|
|
1082
|
+
exports.__esModule = true;
|
|
1469
1083
|
|
|
1470
|
-
return Route;
|
|
1471
|
-
}(_react2.default.Component);
|
|
1472
1084
|
|
|
1473
|
-
Route.contextTypes = {
|
|
1474
|
-
router: _propTypes2.default.shape({
|
|
1475
|
-
history: _propTypes2.default.object.isRequired,
|
|
1476
|
-
route: _propTypes2.default.object.isRequired,
|
|
1477
|
-
staticContext: _propTypes2.default.object
|
|
1478
|
-
})
|
|
1479
|
-
};
|
|
1480
|
-
Route.childContextTypes = {
|
|
1481
|
-
router: _propTypes2.default.object.isRequired
|
|
1482
|
-
};
|
|
1483
|
-
exports.default = Route;
|
|
1484
|
-
|
|
1485
|
-
/***/ }),
|
|
1486
|
-
/* 20 */
|
|
1487
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1488
|
-
|
|
1489
|
-
'use strict';
|
|
1490
|
-
|
|
1491
|
-
exports.__esModule = true;
|
|
1492
|
-
|
|
1493
|
-
var _pathToRegexp = __webpack_require__(21);
|
|
1494
|
-
|
|
1495
|
-
var _pathToRegexp2 = _interopRequireDefault(_pathToRegexp);
|
|
1496
|
-
|
|
1497
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1498
|
-
|
|
1499
|
-
var patternCache = {};
|
|
1500
|
-
var cacheLimit = 10000;
|
|
1501
|
-
var cacheCount = 0;
|
|
1502
|
-
|
|
1503
|
-
var compilePath = function compilePath(pattern, options) {
|
|
1504
|
-
var cacheKey = '' + options.end + options.strict;
|
|
1505
|
-
var cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
|
|
1506
|
-
|
|
1507
|
-
if (cache[pattern]) return cache[pattern];
|
|
1508
|
-
|
|
1509
|
-
var keys = [];
|
|
1510
|
-
var re = (0, _pathToRegexp2.default)(pattern, keys, options);
|
|
1511
|
-
var compiledPattern = { re: re, keys: keys };
|
|
1512
|
-
|
|
1513
|
-
if (cacheCount < cacheLimit) {
|
|
1514
|
-
cache[pattern] = compiledPattern;
|
|
1515
|
-
cacheCount++;
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
return compiledPattern;
|
|
1519
|
-
};
|
|
1520
|
-
|
|
1521
|
-
/**
|
|
1522
|
-
* Public API for matching a URL pathname to a path pattern.
|
|
1523
|
-
*/
|
|
1524
|
-
var matchPath = function matchPath(pathname) {
|
|
1525
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1526
|
-
|
|
1527
|
-
if (typeof options === 'string') options = { path: options };
|
|
1528
|
-
|
|
1529
|
-
var _options = options,
|
|
1530
|
-
_options$path = _options.path,
|
|
1531
|
-
path = _options$path === undefined ? '/' : _options$path,
|
|
1532
|
-
_options$exact = _options.exact,
|
|
1533
|
-
exact = _options$exact === undefined ? false : _options$exact,
|
|
1534
|
-
_options$strict = _options.strict,
|
|
1535
|
-
strict = _options$strict === undefined ? false : _options$strict;
|
|
1536
|
-
|
|
1537
|
-
var _compilePath = compilePath(path, { end: exact, strict: strict }),
|
|
1538
|
-
re = _compilePath.re,
|
|
1539
|
-
keys = _compilePath.keys;
|
|
1540
|
-
|
|
1541
|
-
var match = re.exec(pathname);
|
|
1542
|
-
|
|
1543
|
-
if (!match) return null;
|
|
1544
|
-
|
|
1545
|
-
var url = match[0],
|
|
1546
|
-
values = match.slice(1);
|
|
1547
|
-
|
|
1548
|
-
var isExact = pathname === url;
|
|
1549
|
-
|
|
1550
|
-
if (exact && !isExact) return null;
|
|
1551
|
-
|
|
1552
|
-
return {
|
|
1553
|
-
path: path, // the path pattern used to match
|
|
1554
|
-
url: path === '/' && url === '' ? '/' : url, // the matched portion of the URL
|
|
1555
|
-
isExact: isExact, // whether or not we matched exactly
|
|
1556
|
-
params: keys.reduce(function (memo, key, index) {
|
|
1557
|
-
memo[key.name] = values[index];
|
|
1558
|
-
return memo;
|
|
1559
|
-
}, {})
|
|
1560
|
-
};
|
|
1561
|
-
};
|
|
1562
|
-
|
|
1563
|
-
exports.default = matchPath;
|
|
1564
|
-
|
|
1565
|
-
/***/ }),
|
|
1566
|
-
/* 21 */
|
|
1567
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1568
|
-
|
|
1569
|
-
var isarray = __webpack_require__(22)
|
|
1570
|
-
|
|
1571
|
-
/**
|
|
1572
|
-
* Expose `pathToRegexp`.
|
|
1573
|
-
*/
|
|
1574
|
-
module.exports = pathToRegexp
|
|
1575
|
-
module.exports.parse = parse
|
|
1576
|
-
module.exports.compile = compile
|
|
1577
|
-
module.exports.tokensToFunction = tokensToFunction
|
|
1578
|
-
module.exports.tokensToRegExp = tokensToRegExp
|
|
1579
|
-
|
|
1580
|
-
/**
|
|
1581
|
-
* The main path matching regexp utility.
|
|
1582
|
-
*
|
|
1583
|
-
* @type {RegExp}
|
|
1584
|
-
*/
|
|
1585
|
-
var PATH_REGEXP = new RegExp([
|
|
1586
|
-
// Match escaped characters that would otherwise appear in future matches.
|
|
1587
|
-
// This allows the user to escape special characters that won't transform.
|
|
1588
|
-
'(\\\\.)',
|
|
1589
|
-
// Match Express-style parameters and un-named parameters with a prefix
|
|
1590
|
-
// and optional suffixes. Matches appear as:
|
|
1591
|
-
//
|
|
1592
|
-
// "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
|
|
1593
|
-
// "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
|
|
1594
|
-
// "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
|
|
1595
|
-
'([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
|
|
1596
|
-
].join('|'), 'g')
|
|
1597
|
-
|
|
1598
|
-
/**
|
|
1599
|
-
* Parse a string for the raw tokens.
|
|
1600
|
-
*
|
|
1601
|
-
* @param {string} str
|
|
1602
|
-
* @param {Object=} options
|
|
1603
|
-
* @return {!Array}
|
|
1604
|
-
*/
|
|
1605
|
-
function parse (str, options) {
|
|
1606
|
-
var tokens = []
|
|
1607
|
-
var key = 0
|
|
1608
|
-
var index = 0
|
|
1609
|
-
var path = ''
|
|
1610
|
-
var defaultDelimiter = options && options.delimiter || '/'
|
|
1611
|
-
var res
|
|
1612
|
-
|
|
1613
|
-
while ((res = PATH_REGEXP.exec(str)) != null) {
|
|
1614
|
-
var m = res[0]
|
|
1615
|
-
var escaped = res[1]
|
|
1616
|
-
var offset = res.index
|
|
1617
|
-
path += str.slice(index, offset)
|
|
1618
|
-
index = offset + m.length
|
|
1619
|
-
|
|
1620
|
-
// Ignore already escaped sequences.
|
|
1621
|
-
if (escaped) {
|
|
1622
|
-
path += escaped[1]
|
|
1623
|
-
continue
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
var next = str[index]
|
|
1627
|
-
var prefix = res[2]
|
|
1628
|
-
var name = res[3]
|
|
1629
|
-
var capture = res[4]
|
|
1630
|
-
var group = res[5]
|
|
1631
|
-
var modifier = res[6]
|
|
1632
|
-
var asterisk = res[7]
|
|
1633
|
-
|
|
1634
|
-
// Push the current path onto the tokens.
|
|
1635
|
-
if (path) {
|
|
1636
|
-
tokens.push(path)
|
|
1637
|
-
path = ''
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
var partial = prefix != null && next != null && next !== prefix
|
|
1641
|
-
var repeat = modifier === '+' || modifier === '*'
|
|
1642
|
-
var optional = modifier === '?' || modifier === '*'
|
|
1643
|
-
var delimiter = res[2] || defaultDelimiter
|
|
1644
|
-
var pattern = capture || group
|
|
1645
|
-
|
|
1646
|
-
tokens.push({
|
|
1647
|
-
name: name || key++,
|
|
1648
|
-
prefix: prefix || '',
|
|
1649
|
-
delimiter: delimiter,
|
|
1650
|
-
optional: optional,
|
|
1651
|
-
repeat: repeat,
|
|
1652
|
-
partial: partial,
|
|
1653
|
-
asterisk: !!asterisk,
|
|
1654
|
-
pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
|
|
1655
|
-
})
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
// Match any characters still remaining.
|
|
1659
|
-
if (index < str.length) {
|
|
1660
|
-
path += str.substr(index)
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
// If the path exists, push it onto the end.
|
|
1664
|
-
if (path) {
|
|
1665
|
-
tokens.push(path)
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
return tokens
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
/**
|
|
1672
|
-
* Compile a string to a template function for the path.
|
|
1673
|
-
*
|
|
1674
|
-
* @param {string} str
|
|
1675
|
-
* @param {Object=} options
|
|
1676
|
-
* @return {!function(Object=, Object=)}
|
|
1677
|
-
*/
|
|
1678
|
-
function compile (str, options) {
|
|
1679
|
-
return tokensToFunction(parse(str, options))
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
/**
|
|
1683
|
-
* Prettier encoding of URI path segments.
|
|
1684
|
-
*
|
|
1685
|
-
* @param {string}
|
|
1686
|
-
* @return {string}
|
|
1687
|
-
*/
|
|
1688
|
-
function encodeURIComponentPretty (str) {
|
|
1689
|
-
return encodeURI(str).replace(/[\/?#]/g, function (c) {
|
|
1690
|
-
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
|
1691
|
-
})
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
/**
|
|
1695
|
-
* Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
|
|
1696
|
-
*
|
|
1697
|
-
* @param {string}
|
|
1698
|
-
* @return {string}
|
|
1699
|
-
*/
|
|
1700
|
-
function encodeAsterisk (str) {
|
|
1701
|
-
return encodeURI(str).replace(/[?#]/g, function (c) {
|
|
1702
|
-
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
|
1703
|
-
})
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
/**
|
|
1707
|
-
* Expose a method for transforming tokens into the path function.
|
|
1708
|
-
*/
|
|
1709
|
-
function tokensToFunction (tokens) {
|
|
1710
|
-
// Compile all the tokens into regexps.
|
|
1711
|
-
var matches = new Array(tokens.length)
|
|
1712
|
-
|
|
1713
|
-
// Compile all the patterns before compilation.
|
|
1714
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
1715
|
-
if (typeof tokens[i] === 'object') {
|
|
1716
|
-
matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
return function (obj, opts) {
|
|
1721
|
-
var path = ''
|
|
1722
|
-
var data = obj || {}
|
|
1723
|
-
var options = opts || {}
|
|
1724
|
-
var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent
|
|
1725
|
-
|
|
1726
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
1727
|
-
var token = tokens[i]
|
|
1728
|
-
|
|
1729
|
-
if (typeof token === 'string') {
|
|
1730
|
-
path += token
|
|
1731
|
-
|
|
1732
|
-
continue
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
var value = data[token.name]
|
|
1736
|
-
var segment
|
|
1737
|
-
|
|
1738
|
-
if (value == null) {
|
|
1739
|
-
if (token.optional) {
|
|
1740
|
-
// Prepend partial segment prefixes.
|
|
1741
|
-
if (token.partial) {
|
|
1742
|
-
path += token.prefix
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
continue
|
|
1746
|
-
} else {
|
|
1747
|
-
throw new TypeError('Expected "' + token.name + '" to be defined')
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
if (isarray(value)) {
|
|
1752
|
-
if (!token.repeat) {
|
|
1753
|
-
throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
if (value.length === 0) {
|
|
1757
|
-
if (token.optional) {
|
|
1758
|
-
continue
|
|
1759
|
-
} else {
|
|
1760
|
-
throw new TypeError('Expected "' + token.name + '" to not be empty')
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
for (var j = 0; j < value.length; j++) {
|
|
1765
|
-
segment = encode(value[j])
|
|
1766
|
-
|
|
1767
|
-
if (!matches[i].test(segment)) {
|
|
1768
|
-
throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
path += (j === 0 ? token.prefix : token.delimiter) + segment
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
continue
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
segment = token.asterisk ? encodeAsterisk(value) : encode(value)
|
|
1778
|
-
|
|
1779
|
-
if (!matches[i].test(segment)) {
|
|
1780
|
-
throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
path += token.prefix + segment
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
return path
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
/**
|
|
1791
|
-
* Escape a regular expression string.
|
|
1792
|
-
*
|
|
1793
|
-
* @param {string} str
|
|
1794
|
-
* @return {string}
|
|
1795
|
-
*/
|
|
1796
|
-
function escapeString (str) {
|
|
1797
|
-
return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
/**
|
|
1801
|
-
* Escape the capturing group by escaping special characters and meaning.
|
|
1802
|
-
*
|
|
1803
|
-
* @param {string} group
|
|
1804
|
-
* @return {string}
|
|
1805
|
-
*/
|
|
1806
|
-
function escapeGroup (group) {
|
|
1807
|
-
return group.replace(/([=!:$\/()])/g, '\\$1')
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
/**
|
|
1811
|
-
* Attach the keys as a property of the regexp.
|
|
1812
|
-
*
|
|
1813
|
-
* @param {!RegExp} re
|
|
1814
|
-
* @param {Array} keys
|
|
1815
|
-
* @return {!RegExp}
|
|
1816
|
-
*/
|
|
1817
|
-
function attachKeys (re, keys) {
|
|
1818
|
-
re.keys = keys
|
|
1819
|
-
return re
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
/**
|
|
1823
|
-
* Get the flags for a regexp from the options.
|
|
1824
|
-
*
|
|
1825
|
-
* @param {Object} options
|
|
1826
|
-
* @return {string}
|
|
1827
|
-
*/
|
|
1828
|
-
function flags (options) {
|
|
1829
|
-
return options.sensitive ? '' : 'i'
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
/**
|
|
1833
|
-
* Pull out keys from a regexp.
|
|
1834
|
-
*
|
|
1835
|
-
* @param {!RegExp} path
|
|
1836
|
-
* @param {!Array} keys
|
|
1837
|
-
* @return {!RegExp}
|
|
1838
|
-
*/
|
|
1839
|
-
function regexpToRegexp (path, keys) {
|
|
1840
|
-
// Use a negative lookahead to match only capturing groups.
|
|
1841
|
-
var groups = path.source.match(/\((?!\?)/g)
|
|
1842
|
-
|
|
1843
|
-
if (groups) {
|
|
1844
|
-
for (var i = 0; i < groups.length; i++) {
|
|
1845
|
-
keys.push({
|
|
1846
|
-
name: i,
|
|
1847
|
-
prefix: null,
|
|
1848
|
-
delimiter: null,
|
|
1849
|
-
optional: false,
|
|
1850
|
-
repeat: false,
|
|
1851
|
-
partial: false,
|
|
1852
|
-
asterisk: false,
|
|
1853
|
-
pattern: null
|
|
1854
|
-
})
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
return attachKeys(path, keys)
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
/**
|
|
1862
|
-
* Transform an array into a regexp.
|
|
1863
|
-
*
|
|
1864
|
-
* @param {!Array} path
|
|
1865
|
-
* @param {Array} keys
|
|
1866
|
-
* @param {!Object} options
|
|
1867
|
-
* @return {!RegExp}
|
|
1868
|
-
*/
|
|
1869
|
-
function arrayToRegexp (path, keys, options) {
|
|
1870
|
-
var parts = []
|
|
1871
|
-
|
|
1872
|
-
for (var i = 0; i < path.length; i++) {
|
|
1873
|
-
parts.push(pathToRegexp(path[i], keys, options).source)
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options))
|
|
1877
|
-
|
|
1878
|
-
return attachKeys(regexp, keys)
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
|
-
/**
|
|
1882
|
-
* Create a path regexp from string input.
|
|
1883
|
-
*
|
|
1884
|
-
* @param {string} path
|
|
1885
|
-
* @param {!Array} keys
|
|
1886
|
-
* @param {!Object} options
|
|
1887
|
-
* @return {!RegExp}
|
|
1888
|
-
*/
|
|
1889
|
-
function stringToRegexp (path, keys, options) {
|
|
1890
|
-
return tokensToRegExp(parse(path, options), keys, options)
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
/**
|
|
1894
|
-
* Expose a function for taking tokens and returning a RegExp.
|
|
1895
|
-
*
|
|
1896
|
-
* @param {!Array} tokens
|
|
1897
|
-
* @param {(Array|Object)=} keys
|
|
1898
|
-
* @param {Object=} options
|
|
1899
|
-
* @return {!RegExp}
|
|
1900
|
-
*/
|
|
1901
|
-
function tokensToRegExp (tokens, keys, options) {
|
|
1902
|
-
if (!isarray(keys)) {
|
|
1903
|
-
options = /** @type {!Object} */ (keys || options)
|
|
1904
|
-
keys = []
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
|
-
options = options || {}
|
|
1908
|
-
|
|
1909
|
-
var strict = options.strict
|
|
1910
|
-
var end = options.end !== false
|
|
1911
|
-
var route = ''
|
|
1912
|
-
|
|
1913
|
-
// Iterate over the tokens and create our regexp string.
|
|
1914
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
1915
|
-
var token = tokens[i]
|
|
1916
|
-
|
|
1917
|
-
if (typeof token === 'string') {
|
|
1918
|
-
route += escapeString(token)
|
|
1919
|
-
} else {
|
|
1920
|
-
var prefix = escapeString(token.prefix)
|
|
1921
|
-
var capture = '(?:' + token.pattern + ')'
|
|
1922
|
-
|
|
1923
|
-
keys.push(token)
|
|
1924
|
-
|
|
1925
|
-
if (token.repeat) {
|
|
1926
|
-
capture += '(?:' + prefix + capture + ')*'
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
if (token.optional) {
|
|
1930
|
-
if (!token.partial) {
|
|
1931
|
-
capture = '(?:' + prefix + '(' + capture + '))?'
|
|
1932
|
-
} else {
|
|
1933
|
-
capture = prefix + '(' + capture + ')?'
|
|
1934
|
-
}
|
|
1935
|
-
} else {
|
|
1936
|
-
capture = prefix + '(' + capture + ')'
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
route += capture
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1943
|
-
var delimiter = escapeString(options.delimiter || '/')
|
|
1944
|
-
var endsWithDelimiter = route.slice(-delimiter.length) === delimiter
|
|
1945
|
-
|
|
1946
|
-
// In non-strict mode we allow a slash at the end of match. If the path to
|
|
1947
|
-
// match already ends with a slash, we remove it for consistency. The slash
|
|
1948
|
-
// is valid at the end of a path match, not in the middle. This is important
|
|
1949
|
-
// in non-ending mode, where "/test/" shouldn't match "/test//route".
|
|
1950
|
-
if (!strict) {
|
|
1951
|
-
route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?'
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
if (end) {
|
|
1955
|
-
route += '$'
|
|
1956
|
-
} else {
|
|
1957
|
-
// In non-ending mode, we need the capturing groups to match as much as
|
|
1958
|
-
// possible by using a positive lookahead to the end or next path segment.
|
|
1959
|
-
route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)'
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
|
-
return attachKeys(new RegExp('^' + route, flags(options)), keys)
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
/**
|
|
1966
|
-
* Normalize the given path string, returning a regular expression.
|
|
1967
|
-
*
|
|
1968
|
-
* An empty array can be passed in for the keys, which will hold the
|
|
1969
|
-
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
|
|
1970
|
-
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
|
|
1971
|
-
*
|
|
1972
|
-
* @param {(string|RegExp|Array)} path
|
|
1973
|
-
* @param {(Array|Object)=} keys
|
|
1974
|
-
* @param {Object=} options
|
|
1975
|
-
* @return {!RegExp}
|
|
1976
|
-
*/
|
|
1977
|
-
function pathToRegexp (path, keys, options) {
|
|
1978
|
-
if (!isarray(keys)) {
|
|
1979
|
-
options = /** @type {!Object} */ (keys || options)
|
|
1980
|
-
keys = []
|
|
1981
|
-
}
|
|
1982
1085
|
|
|
1983
|
-
|
|
1086
|
+
var _warning2 = _interopRequireDefault(warning_1);
|
|
1984
1087
|
|
|
1985
|
-
|
|
1986
|
-
return regexpToRegexp(path, /** @type {!Array} */ (keys))
|
|
1987
|
-
}
|
|
1088
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1988
1089
|
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
}
|
|
1090
|
+
var createTransitionManager = function createTransitionManager() {
|
|
1091
|
+
var prompt = null;
|
|
1992
1092
|
|
|
1993
|
-
|
|
1994
|
-
|
|
1093
|
+
var setPrompt = function setPrompt(nextPrompt) {
|
|
1094
|
+
(0, _warning2.default)(prompt == null, 'A history supports only one prompt at a time');
|
|
1995
1095
|
|
|
1096
|
+
prompt = nextPrompt;
|
|
1996
1097
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
1098
|
+
return function () {
|
|
1099
|
+
if (prompt === nextPrompt) prompt = null;
|
|
1100
|
+
};
|
|
1101
|
+
};
|
|
2000
1102
|
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
1103
|
+
var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) {
|
|
1104
|
+
// TODO: If another transition starts while we're still confirming
|
|
1105
|
+
// the previous one, we may end up in a weird state. Figure out the
|
|
1106
|
+
// best way to handle this.
|
|
1107
|
+
if (prompt != null) {
|
|
1108
|
+
var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
|
|
2004
1109
|
|
|
1110
|
+
if (typeof result === 'string') {
|
|
1111
|
+
if (typeof getUserConfirmation === 'function') {
|
|
1112
|
+
getUserConfirmation(result, callback);
|
|
1113
|
+
} else {
|
|
1114
|
+
(0, _warning2.default)(false, 'A history needs a getUserConfirmation function in order to use a prompt message');
|
|
2005
1115
|
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
1116
|
+
callback(true);
|
|
1117
|
+
}
|
|
1118
|
+
} else {
|
|
1119
|
+
// Return false from a transition hook to cancel the transition.
|
|
1120
|
+
callback(result !== false);
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
callback(true);
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
2009
1126
|
|
|
2010
|
-
|
|
1127
|
+
var listeners = [];
|
|
2011
1128
|
|
|
2012
|
-
|
|
1129
|
+
var appendListener = function appendListener(fn) {
|
|
1130
|
+
var isActive = true;
|
|
2013
1131
|
|
|
2014
|
-
|
|
1132
|
+
var listener = function listener() {
|
|
1133
|
+
if (isActive) fn.apply(undefined, arguments);
|
|
1134
|
+
};
|
|
2015
1135
|
|
|
2016
|
-
|
|
1136
|
+
listeners.push(listener);
|
|
2017
1137
|
|
|
2018
|
-
|
|
1138
|
+
return function () {
|
|
1139
|
+
isActive = false;
|
|
1140
|
+
listeners = listeners.filter(function (item) {
|
|
1141
|
+
return item !== listener;
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1144
|
+
};
|
|
2019
1145
|
|
|
2020
|
-
|
|
1146
|
+
var notifyListeners = function notifyListeners() {
|
|
1147
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1148
|
+
args[_key] = arguments[_key];
|
|
1149
|
+
}
|
|
2021
1150
|
|
|
2022
|
-
|
|
1151
|
+
listeners.forEach(function (listener) {
|
|
1152
|
+
return listener.apply(undefined, args);
|
|
1153
|
+
});
|
|
1154
|
+
};
|
|
2023
1155
|
|
|
2024
|
-
|
|
1156
|
+
return {
|
|
1157
|
+
setPrompt: setPrompt,
|
|
1158
|
+
confirmTransitionTo: confirmTransitionTo,
|
|
1159
|
+
appendListener: appendListener,
|
|
1160
|
+
notifyListeners: notifyListeners
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
2025
1163
|
|
|
2026
|
-
|
|
1164
|
+
exports.default = createTransitionManager;
|
|
1165
|
+
});
|
|
2027
1166
|
|
|
2028
|
-
|
|
1167
|
+
var createMemoryHistory_1 = createCommonjsModule(function (module, exports) {
|
|
1168
|
+
'use strict';
|
|
2029
1169
|
|
|
2030
|
-
|
|
1170
|
+
exports.__esModule = true;
|
|
2031
1171
|
|
|
2032
|
-
|
|
1172
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
2033
1173
|
|
|
2034
|
-
|
|
1174
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
2035
1175
|
|
|
2036
|
-
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
2037
1176
|
|
|
2038
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2039
1177
|
|
|
2040
|
-
|
|
1178
|
+
var _warning2 = _interopRequireDefault(warning_1);
|
|
2041
1179
|
|
|
2042
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
2043
1180
|
|
|
2044
|
-
var normalizeLocation = function normalizeLocation(object) {
|
|
2045
|
-
var _object$pathname = object.pathname,
|
|
2046
|
-
pathname = _object$pathname === undefined ? '/' : _object$pathname,
|
|
2047
|
-
_object$search = object.search,
|
|
2048
|
-
search = _object$search === undefined ? '' : _object$search,
|
|
2049
|
-
_object$hash = object.hash,
|
|
2050
|
-
hash = _object$hash === undefined ? '' : _object$hash;
|
|
2051
1181
|
|
|
2052
1182
|
|
|
2053
|
-
return {
|
|
2054
|
-
pathname: pathname,
|
|
2055
|
-
search: search === '?' ? '' : search,
|
|
2056
|
-
hash: hash === '#' ? '' : hash
|
|
2057
|
-
};
|
|
2058
|
-
};
|
|
2059
1183
|
|
|
2060
|
-
var addBasename = function addBasename(basename, location) {
|
|
2061
|
-
if (!basename) return location;
|
|
2062
1184
|
|
|
2063
|
-
return _extends({}, location, {
|
|
2064
|
-
pathname: (0, _PathUtils.addLeadingSlash)(basename) + location.pathname
|
|
2065
|
-
});
|
|
2066
|
-
};
|
|
2067
1185
|
|
|
2068
|
-
|
|
2069
|
-
if (!basename) return location;
|
|
1186
|
+
var _createTransitionManager2 = _interopRequireDefault(createTransitionManager_1);
|
|
2070
1187
|
|
|
2071
|
-
|
|
1188
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2072
1189
|
|
|
2073
|
-
|
|
1190
|
+
var clamp = function clamp(n, lowerBound, upperBound) {
|
|
1191
|
+
return Math.min(Math.max(n, lowerBound), upperBound);
|
|
1192
|
+
};
|
|
2074
1193
|
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
1194
|
+
/**
|
|
1195
|
+
* Creates a history object that stores locations in memory.
|
|
1196
|
+
*/
|
|
1197
|
+
var createMemoryHistory = function createMemoryHistory() {
|
|
1198
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1199
|
+
var getUserConfirmation = props.getUserConfirmation,
|
|
1200
|
+
_props$initialEntries = props.initialEntries,
|
|
1201
|
+
initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries,
|
|
1202
|
+
_props$initialIndex = props.initialIndex,
|
|
1203
|
+
initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex,
|
|
1204
|
+
_props$keyLength = props.keyLength,
|
|
1205
|
+
keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;
|
|
2079
1206
|
|
|
2080
|
-
var createLocation = function createLocation(location) {
|
|
2081
|
-
return typeof location === 'string' ? (0, _PathUtils.parsePath)(location) : normalizeLocation(location);
|
|
2082
|
-
};
|
|
2083
1207
|
|
|
2084
|
-
|
|
2085
|
-
return typeof location === 'string' ? location : (0, _PathUtils.createPath)(location);
|
|
2086
|
-
};
|
|
1208
|
+
var transitionManager = (0, _createTransitionManager2.default)();
|
|
2087
1209
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
true ? false ? (0, _invariant2.default)(false, 'You cannot %s with <StaticRouter>', methodName) : (0, _invariant2.default)(false) : void 0;
|
|
2091
|
-
};
|
|
2092
|
-
};
|
|
1210
|
+
var setState = function setState(nextState) {
|
|
1211
|
+
_extends(history, nextState);
|
|
2093
1212
|
|
|
2094
|
-
|
|
1213
|
+
history.length = history.entries.length;
|
|
2095
1214
|
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
* can't actually change the current location. Instead, it just records
|
|
2099
|
-
* location changes in a context object. Useful mainly in testing and
|
|
2100
|
-
* server-rendering scenarios.
|
|
2101
|
-
*/
|
|
1215
|
+
transitionManager.notifyListeners(history.location, history.action);
|
|
1216
|
+
};
|
|
2102
1217
|
|
|
2103
|
-
|
|
2104
|
-
|
|
1218
|
+
var createKey = function createKey() {
|
|
1219
|
+
return Math.random().toString(36).substr(2, keyLength);
|
|
1220
|
+
};
|
|
2105
1221
|
|
|
2106
|
-
|
|
2107
|
-
|
|
1222
|
+
var index = clamp(initialIndex, 0, initialEntries.length - 1);
|
|
1223
|
+
var entries = initialEntries.map(function (entry) {
|
|
1224
|
+
return typeof entry === 'string' ? (0, LocationUtils.createLocation)(entry, undefined, createKey()) : (0, LocationUtils.createLocation)(entry, undefined, entry.key || createKey());
|
|
1225
|
+
});
|
|
2108
1226
|
|
|
2109
|
-
|
|
1227
|
+
// Public interface
|
|
2110
1228
|
|
|
2111
|
-
|
|
2112
|
-
args[_key] = arguments[_key];
|
|
2113
|
-
}
|
|
1229
|
+
var createHref = PathUtils.createPath;
|
|
2114
1230
|
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
}, _this.handlePush = function (location) {
|
|
2118
|
-
var _this$props = _this.props,
|
|
2119
|
-
basename = _this$props.basename,
|
|
2120
|
-
context = _this$props.context;
|
|
1231
|
+
var push = function push(path, state) {
|
|
1232
|
+
(0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
|
|
2121
1233
|
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
context.url = createURL(context.location);
|
|
2125
|
-
}, _this.handleReplace = function (location) {
|
|
2126
|
-
var _this$props2 = _this.props,
|
|
2127
|
-
basename = _this$props2.basename,
|
|
2128
|
-
context = _this$props2.context;
|
|
1234
|
+
var action = 'PUSH';
|
|
1235
|
+
var location = (0, LocationUtils.createLocation)(path, state, createKey(), history.location);
|
|
2129
1236
|
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
context.url = createURL(context.location);
|
|
2133
|
-
}, _this.handleListen = function () {
|
|
2134
|
-
return noop;
|
|
2135
|
-
}, _this.handleBlock = function () {
|
|
2136
|
-
return noop;
|
|
2137
|
-
}, _temp), _possibleConstructorReturn(_this, _ret);
|
|
2138
|
-
}
|
|
1237
|
+
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
|
1238
|
+
if (!ok) return;
|
|
2139
1239
|
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
router: {
|
|
2143
|
-
staticContext: this.props.context
|
|
2144
|
-
}
|
|
2145
|
-
};
|
|
2146
|
-
};
|
|
1240
|
+
var prevIndex = history.index;
|
|
1241
|
+
var nextIndex = prevIndex + 1;
|
|
2147
1242
|
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
1243
|
+
var nextEntries = history.entries.slice(0);
|
|
1244
|
+
if (nextEntries.length > nextIndex) {
|
|
1245
|
+
nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
|
|
1246
|
+
} else {
|
|
1247
|
+
nextEntries.push(location);
|
|
1248
|
+
}
|
|
2154
1249
|
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
goForward: staticHandler('goForward'),
|
|
2164
|
-
listen: this.handleListen,
|
|
2165
|
-
block: this.handleBlock
|
|
2166
|
-
};
|
|
1250
|
+
setState({
|
|
1251
|
+
action: action,
|
|
1252
|
+
location: location,
|
|
1253
|
+
index: nextIndex,
|
|
1254
|
+
entries: nextEntries
|
|
1255
|
+
});
|
|
1256
|
+
});
|
|
1257
|
+
};
|
|
2167
1258
|
|
|
2168
|
-
|
|
2169
|
-
|
|
1259
|
+
var replace = function replace(path, state) {
|
|
1260
|
+
(0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
|
|
2170
1261
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
StaticRouter.defaultProps = {
|
|
2175
|
-
basename: '',
|
|
2176
|
-
location: '/'
|
|
2177
|
-
};
|
|
2178
|
-
StaticRouter.childContextTypes = {
|
|
2179
|
-
router: _propTypes2.default.object.isRequired
|
|
2180
|
-
};
|
|
2181
|
-
exports.default = StaticRouter;
|
|
1262
|
+
var action = 'REPLACE';
|
|
1263
|
+
var location = (0, LocationUtils.createLocation)(path, state, createKey(), history.location);
|
|
2182
1264
|
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1265
|
+
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
|
1266
|
+
if (!ok) return;
|
|
2186
1267
|
|
|
2187
|
-
|
|
1268
|
+
history.entries[history.index] = location;
|
|
2188
1269
|
|
|
2189
|
-
|
|
1270
|
+
setState({ action: action, location: location });
|
|
1271
|
+
});
|
|
1272
|
+
};
|
|
2190
1273
|
|
|
2191
|
-
|
|
1274
|
+
var go = function go(n) {
|
|
1275
|
+
var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
|
|
2192
1276
|
|
|
2193
|
-
|
|
1277
|
+
var action = 'POP';
|
|
1278
|
+
var location = history.entries[nextIndex];
|
|
2194
1279
|
|
|
2195
|
-
|
|
1280
|
+
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
|
1281
|
+
if (ok) {
|
|
1282
|
+
setState({
|
|
1283
|
+
action: action,
|
|
1284
|
+
location: location,
|
|
1285
|
+
index: nextIndex
|
|
1286
|
+
});
|
|
1287
|
+
} else {
|
|
1288
|
+
// Mimic the behavior of DOM histories by
|
|
1289
|
+
// causing a render after a cancelled POP.
|
|
1290
|
+
setState();
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
var goBack = function goBack() {
|
|
1296
|
+
return go(-1);
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
var goForward = function goForward() {
|
|
1300
|
+
return go(1);
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
var canGo = function canGo(n) {
|
|
1304
|
+
var nextIndex = history.index + n;
|
|
1305
|
+
return nextIndex >= 0 && nextIndex < history.entries.length;
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1308
|
+
var block = function block() {
|
|
1309
|
+
var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1310
|
+
return transitionManager.setPrompt(prompt);
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
var listen = function listen(listener) {
|
|
1314
|
+
return transitionManager.appendListener(listener);
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
var history = {
|
|
1318
|
+
length: entries.length,
|
|
1319
|
+
action: 'POP',
|
|
1320
|
+
location: entries[index],
|
|
1321
|
+
index: index,
|
|
1322
|
+
entries: entries,
|
|
1323
|
+
createHref: createHref,
|
|
1324
|
+
push: push,
|
|
1325
|
+
replace: replace,
|
|
1326
|
+
go: go,
|
|
1327
|
+
goBack: goBack,
|
|
1328
|
+
goForward: goForward,
|
|
1329
|
+
canGo: canGo,
|
|
1330
|
+
block: block,
|
|
1331
|
+
listen: listen
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
return history;
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
exports.default = createMemoryHistory;
|
|
1338
|
+
});
|
|
2196
1339
|
|
|
2197
|
-
|
|
1340
|
+
var createHistory = unwrapExports(createMemoryHistory_1);
|
|
2198
1341
|
|
|
2199
|
-
|
|
1342
|
+
/**
|
|
1343
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
1344
|
+
* All rights reserved.
|
|
1345
|
+
*
|
|
1346
|
+
* This source code is licensed under the BSD-style license found in the
|
|
1347
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
1348
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
1349
|
+
*/
|
|
2200
1350
|
|
|
2201
|
-
|
|
1351
|
+
/**
|
|
1352
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
1353
|
+
*
|
|
1354
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
1355
|
+
* to provide information about what broke and what you were
|
|
1356
|
+
* expecting.
|
|
1357
|
+
*
|
|
1358
|
+
* The invariant message will be stripped in production, but the invariant
|
|
1359
|
+
* will remain to ensure logic does not differ in production.
|
|
1360
|
+
*/
|
|
2202
1361
|
|
|
2203
|
-
|
|
1362
|
+
var NODE_ENV = "development";
|
|
2204
1363
|
|
|
2205
|
-
|
|
1364
|
+
var invariant$3 = function(condition, format, a, b, c, d, e, f) {
|
|
1365
|
+
if (NODE_ENV !== 'production') {
|
|
1366
|
+
if (format === undefined) {
|
|
1367
|
+
throw new Error('invariant requires an error message argument');
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
2206
1370
|
|
|
2207
|
-
|
|
1371
|
+
if (!condition) {
|
|
1372
|
+
var error;
|
|
1373
|
+
if (format === undefined) {
|
|
1374
|
+
error = new Error(
|
|
1375
|
+
'Minified exception occurred; use the non-minified dev environment ' +
|
|
1376
|
+
'for the full error message and additional helpful warnings.'
|
|
1377
|
+
);
|
|
1378
|
+
} else {
|
|
1379
|
+
var args = [a, b, c, d, e, f];
|
|
1380
|
+
var argIndex = 0;
|
|
1381
|
+
error = new Error(
|
|
1382
|
+
format.replace(/%s/g, function() { return args[argIndex++]; })
|
|
1383
|
+
);
|
|
1384
|
+
error.name = 'Invariant Violation';
|
|
1385
|
+
}
|
|
2208
1386
|
|
|
2209
|
-
|
|
1387
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
1388
|
+
throw error;
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
2210
1391
|
|
|
2211
|
-
|
|
1392
|
+
var invariant_1$2 = invariant$3;
|
|
2212
1393
|
|
|
2213
|
-
|
|
1394
|
+
var classCallCheck = function (instance, Constructor) {
|
|
1395
|
+
if (!(instance instanceof Constructor)) {
|
|
1396
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
2214
1399
|
|
|
2215
|
-
/**
|
|
2216
|
-
* The public API for rendering the first <Route> that matches.
|
|
2217
|
-
*/
|
|
2218
|
-
var Switch = function (_React$Component) {
|
|
2219
|
-
_inherits(Switch, _React$Component);
|
|
2220
1400
|
|
|
2221
|
-
function Switch() {
|
|
2222
|
-
_classCallCheck(this, Switch);
|
|
2223
1401
|
|
|
2224
|
-
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
|
2225
|
-
}
|
|
2226
1402
|
|
|
2227
|
-
Switch.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
2228
|
-
false ? (0, _warning2.default)(!(nextProps.location && !this.props.location), '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') : void 0;
|
|
2229
1403
|
|
|
2230
|
-
false ? (0, _warning2.default)(!(!nextProps.location && this.props.location), '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') : void 0;
|
|
2231
|
-
};
|
|
2232
1404
|
|
|
2233
|
-
Switch.prototype.render = function render() {
|
|
2234
|
-
var route = this.context.router.route;
|
|
2235
|
-
var children = this.props.children;
|
|
2236
1405
|
|
|
2237
|
-
var location = this.props.location || route.location;
|
|
2238
1406
|
|
|
2239
|
-
var match = void 0,
|
|
2240
|
-
child = void 0;
|
|
2241
|
-
_react2.default.Children.forEach(children, function (element) {
|
|
2242
|
-
if (!_react2.default.isValidElement(element)) return;
|
|
2243
1407
|
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
strict = _element$props.strict,
|
|
2248
|
-
from = _element$props.from;
|
|
1408
|
+
var _extends = Object.assign || function (target) {
|
|
1409
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1410
|
+
var source = arguments[i];
|
|
2249
1411
|
|
|
2250
|
-
|
|
1412
|
+
for (var key in source) {
|
|
1413
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1414
|
+
target[key] = source[key];
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
2251
1418
|
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
match = path ? (0, _matchPath2.default)(location.pathname, { path: path, exact: exact, strict: strict }) : route.match;
|
|
2255
|
-
}
|
|
2256
|
-
});
|
|
1419
|
+
return target;
|
|
1420
|
+
};
|
|
2257
1421
|
|
|
2258
|
-
return match ? _react2.default.cloneElement(child, { location: location, computedMatch: match }) : null;
|
|
2259
|
-
};
|
|
2260
1422
|
|
|
2261
|
-
return Switch;
|
|
2262
|
-
}(_react2.default.Component);
|
|
2263
1423
|
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
};
|
|
2269
|
-
exports.default = Switch;
|
|
1424
|
+
var inherits = function (subClass, superClass) {
|
|
1425
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
1426
|
+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
1427
|
+
}
|
|
2270
1428
|
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
1429
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1430
|
+
constructor: {
|
|
1431
|
+
value: subClass,
|
|
1432
|
+
enumerable: false,
|
|
1433
|
+
writable: true,
|
|
1434
|
+
configurable: true
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
1438
|
+
};
|
|
2274
1439
|
|
|
2275
|
-
'use strict';
|
|
2276
1440
|
|
|
2277
|
-
exports.__esModule = true;
|
|
2278
1441
|
|
|
2279
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
2280
1442
|
|
|
2281
|
-
var _react = __webpack_require__(2);
|
|
2282
1443
|
|
|
2283
|
-
var _react2 = _interopRequireDefault(_react);
|
|
2284
1444
|
|
|
2285
|
-
var _propTypes = __webpack_require__(3);
|
|
2286
1445
|
|
|
2287
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
2288
1446
|
|
|
2289
|
-
var _hoistNonReactStatics = __webpack_require__(26);
|
|
2290
1447
|
|
|
2291
|
-
|
|
1448
|
+
var objectWithoutProperties = function (obj, keys) {
|
|
1449
|
+
var target = {};
|
|
2292
1450
|
|
|
2293
|
-
|
|
1451
|
+
for (var i in obj) {
|
|
1452
|
+
if (keys.indexOf(i) >= 0) continue;
|
|
1453
|
+
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
|
|
1454
|
+
target[i] = obj[i];
|
|
1455
|
+
}
|
|
2294
1456
|
|
|
2295
|
-
|
|
1457
|
+
return target;
|
|
1458
|
+
};
|
|
2296
1459
|
|
|
2297
|
-
|
|
1460
|
+
var possibleConstructorReturn = function (self, call) {
|
|
1461
|
+
if (!self) {
|
|
1462
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1463
|
+
}
|
|
2298
1464
|
|
|
2299
|
-
|
|
1465
|
+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
1466
|
+
};
|
|
2300
1467
|
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
var withRouter = function withRouter(Component) {
|
|
2305
|
-
var C = function C(props) {
|
|
2306
|
-
var wrappedComponentRef = props.wrappedComponentRef,
|
|
2307
|
-
remainingProps = _objectWithoutProperties(props, ['wrappedComponentRef']);
|
|
1468
|
+
/**
|
|
1469
|
+
* The public API for putting history on context.
|
|
1470
|
+
*/
|
|
2308
1471
|
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
} });
|
|
2312
|
-
};
|
|
1472
|
+
var Router = function (_React$Component) {
|
|
1473
|
+
inherits(Router, _React$Component);
|
|
2313
1474
|
|
|
2314
|
-
|
|
2315
|
-
|
|
1475
|
+
function Router() {
|
|
1476
|
+
var _temp, _this, _ret;
|
|
2316
1477
|
|
|
1478
|
+
classCallCheck(this, Router);
|
|
2317
1479
|
|
|
2318
|
-
|
|
2319
|
-
|
|
1480
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1481
|
+
args[_key] = arguments[_key];
|
|
1482
|
+
}
|
|
2320
1483
|
|
|
2321
|
-
|
|
1484
|
+
return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
|
|
1485
|
+
match: _this.computeMatch(_this.props.history.location.pathname)
|
|
1486
|
+
}, _temp), possibleConstructorReturn(_this, _ret);
|
|
1487
|
+
}
|
|
2322
1488
|
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
1489
|
+
Router.prototype.getChildContext = function getChildContext() {
|
|
1490
|
+
return {
|
|
1491
|
+
router: _extends({}, this.context.router, {
|
|
1492
|
+
history: this.props.history,
|
|
1493
|
+
route: {
|
|
1494
|
+
location: this.props.history.location,
|
|
1495
|
+
match: this.state.match
|
|
1496
|
+
}
|
|
1497
|
+
})
|
|
1498
|
+
};
|
|
1499
|
+
};
|
|
2326
1500
|
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
1501
|
+
Router.prototype.computeMatch = function computeMatch(pathname) {
|
|
1502
|
+
return {
|
|
1503
|
+
path: '/',
|
|
1504
|
+
url: '/',
|
|
1505
|
+
params: {},
|
|
1506
|
+
isExact: pathname === '/'
|
|
1507
|
+
};
|
|
1508
|
+
};
|
|
2332
1509
|
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
contextTypes: true,
|
|
2336
|
-
defaultProps: true,
|
|
2337
|
-
displayName: true,
|
|
2338
|
-
getDefaultProps: true,
|
|
2339
|
-
mixins: true,
|
|
2340
|
-
propTypes: true,
|
|
2341
|
-
type: true
|
|
2342
|
-
};
|
|
1510
|
+
Router.prototype.componentWillMount = function componentWillMount() {
|
|
1511
|
+
var _this2 = this;
|
|
2343
1512
|
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
prototype: true,
|
|
2348
|
-
caller: true,
|
|
2349
|
-
arguments: true,
|
|
2350
|
-
arity: true
|
|
2351
|
-
};
|
|
1513
|
+
var _props = this.props,
|
|
1514
|
+
children = _props.children,
|
|
1515
|
+
history = _props.history;
|
|
2352
1516
|
|
|
2353
|
-
var isGetOwnPropertySymbolsAvailable = typeof Object.getOwnPropertySymbols === 'function';
|
|
2354
1517
|
|
|
2355
|
-
|
|
2356
|
-
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
|
|
2357
|
-
var keys = Object.getOwnPropertyNames(sourceComponent);
|
|
1518
|
+
invariant_1$2(children == null || React.Children.count(children) === 1, 'A <Router> may have only one child element');
|
|
2358
1519
|
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
1520
|
+
// Do this here so we can setState when a <Redirect> changes the
|
|
1521
|
+
// location in componentWillMount. This happens e.g. when doing
|
|
1522
|
+
// server rendering using a <StaticRouter>.
|
|
1523
|
+
this.unlisten = history.listen(function () {
|
|
1524
|
+
_this2.setState({
|
|
1525
|
+
match: _this2.computeMatch(history.location.pathname)
|
|
1526
|
+
});
|
|
1527
|
+
});
|
|
1528
|
+
};
|
|
2363
1529
|
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
targetComponent[keys[i]] = sourceComponent[keys[i]];
|
|
2368
|
-
} catch (error) {
|
|
1530
|
+
Router.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
1531
|
+
warning_1(this.props.history === nextProps.history, 'You cannot change <Router history>');
|
|
1532
|
+
};
|
|
2369
1533
|
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
}
|
|
1534
|
+
Router.prototype.componentWillUnmount = function componentWillUnmount() {
|
|
1535
|
+
this.unlisten();
|
|
1536
|
+
};
|
|
2374
1537
|
|
|
2375
|
-
|
|
2376
|
-
|
|
1538
|
+
Router.prototype.render = function render() {
|
|
1539
|
+
var children = this.props.children;
|
|
2377
1540
|
|
|
1541
|
+
return children ? React.Children.only(children) : null;
|
|
1542
|
+
};
|
|
2378
1543
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
1544
|
+
return Router;
|
|
1545
|
+
}(React.Component);
|
|
1546
|
+
|
|
1547
|
+
Router.propTypes = {
|
|
1548
|
+
history: propTypes.object.isRequired,
|
|
1549
|
+
children: propTypes.node
|
|
1550
|
+
};
|
|
1551
|
+
Router.contextTypes = {
|
|
1552
|
+
router: propTypes.object
|
|
1553
|
+
};
|
|
1554
|
+
Router.childContextTypes = {
|
|
1555
|
+
router: propTypes.object.isRequired
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
/**
|
|
1559
|
+
* The public API for a <Router> that stores location in memory.
|
|
1560
|
+
*/
|
|
1561
|
+
|
|
1562
|
+
var MemoryRouter = function (_React$Component) {
|
|
1563
|
+
inherits(MemoryRouter, _React$Component);
|
|
1564
|
+
|
|
1565
|
+
function MemoryRouter() {
|
|
1566
|
+
var _temp, _this, _ret;
|
|
1567
|
+
|
|
1568
|
+
classCallCheck(this, MemoryRouter);
|
|
1569
|
+
|
|
1570
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1571
|
+
args[_key] = arguments[_key];
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createHistory(_this.props), _temp), possibleConstructorReturn(_this, _ret);
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
MemoryRouter.prototype.componentWillMount = function componentWillMount() {
|
|
1578
|
+
warning_1(!this.props.history, '<MemoryRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { MemoryRouter as Router }`.');
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1581
|
+
MemoryRouter.prototype.render = function render() {
|
|
1582
|
+
return React.createElement(Router, { history: this.history, children: this.props.children });
|
|
1583
|
+
};
|
|
1584
|
+
|
|
1585
|
+
return MemoryRouter;
|
|
1586
|
+
}(React.Component);
|
|
1587
|
+
|
|
1588
|
+
MemoryRouter.propTypes = {
|
|
1589
|
+
initialEntries: propTypes.array,
|
|
1590
|
+
initialIndex: propTypes.number,
|
|
1591
|
+
getUserConfirmation: propTypes.func,
|
|
1592
|
+
keyLength: propTypes.number,
|
|
1593
|
+
children: propTypes.node
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* The public API for prompting the user before navigating away
|
|
1598
|
+
* from a screen with a component.
|
|
1599
|
+
*/
|
|
1600
|
+
|
|
1601
|
+
var Prompt = function (_React$Component) {
|
|
1602
|
+
inherits(Prompt, _React$Component);
|
|
1603
|
+
|
|
1604
|
+
function Prompt() {
|
|
1605
|
+
classCallCheck(this, Prompt);
|
|
1606
|
+
return possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
Prompt.prototype.enable = function enable(message) {
|
|
1610
|
+
if (this.unblock) this.unblock();
|
|
1611
|
+
|
|
1612
|
+
this.unblock = this.context.router.history.block(message);
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
Prompt.prototype.disable = function disable() {
|
|
1616
|
+
if (this.unblock) {
|
|
1617
|
+
this.unblock();
|
|
1618
|
+
this.unblock = null;
|
|
1619
|
+
}
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
Prompt.prototype.componentWillMount = function componentWillMount() {
|
|
1623
|
+
invariant_1$2(this.context.router, 'You should not use <Prompt> outside a <Router>');
|
|
1624
|
+
|
|
1625
|
+
if (this.props.when) this.enable(this.props.message);
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
Prompt.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
1629
|
+
if (nextProps.when) {
|
|
1630
|
+
if (!this.props.when || this.props.message !== nextProps.message) this.enable(nextProps.message);
|
|
1631
|
+
} else {
|
|
1632
|
+
this.disable();
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
Prompt.prototype.componentWillUnmount = function componentWillUnmount() {
|
|
1637
|
+
this.disable();
|
|
1638
|
+
};
|
|
1639
|
+
|
|
1640
|
+
Prompt.prototype.render = function render() {
|
|
1641
|
+
return null;
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
return Prompt;
|
|
1645
|
+
}(React.Component);
|
|
1646
|
+
|
|
1647
|
+
Prompt.propTypes = {
|
|
1648
|
+
when: propTypes.bool,
|
|
1649
|
+
message: propTypes.oneOfType([propTypes.func, propTypes.string]).isRequired
|
|
1650
|
+
};
|
|
1651
|
+
Prompt.defaultProps = {
|
|
1652
|
+
when: true
|
|
1653
|
+
};
|
|
1654
|
+
Prompt.contextTypes = {
|
|
1655
|
+
router: propTypes.shape({
|
|
1656
|
+
history: propTypes.shape({
|
|
1657
|
+
block: propTypes.func.isRequired
|
|
1658
|
+
}).isRequired
|
|
1659
|
+
}).isRequired
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1662
|
+
var parsePath = function parsePath(path) {
|
|
1663
|
+
var pathname = path || '/';
|
|
1664
|
+
var search = '';
|
|
1665
|
+
var hash = '';
|
|
1666
|
+
|
|
1667
|
+
var hashIndex = pathname.indexOf('#');
|
|
1668
|
+
if (hashIndex !== -1) {
|
|
1669
|
+
hash = pathname.substr(hashIndex);
|
|
1670
|
+
pathname = pathname.substr(0, hashIndex);
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
var searchIndex = pathname.indexOf('?');
|
|
1674
|
+
if (searchIndex !== -1) {
|
|
1675
|
+
search = pathname.substr(searchIndex);
|
|
1676
|
+
pathname = pathname.substr(0, searchIndex);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
return {
|
|
1680
|
+
pathname: pathname,
|
|
1681
|
+
search: search === '?' ? '' : search,
|
|
1682
|
+
hash: hash === '#' ? '' : hash
|
|
1683
|
+
};
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
var _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1687
|
+
|
|
1688
|
+
var createLocation = function createLocation(path, state, key, currentLocation) {
|
|
1689
|
+
var location = void 0;
|
|
1690
|
+
if (typeof path === 'string') {
|
|
1691
|
+
// Two-arg form: push(path, state)
|
|
1692
|
+
location = parsePath(path);
|
|
1693
|
+
location.state = state;
|
|
1694
|
+
} else {
|
|
1695
|
+
// One-arg form: push(location)
|
|
1696
|
+
location = _extends$2({}, path);
|
|
1697
|
+
|
|
1698
|
+
if (location.pathname === undefined) location.pathname = '';
|
|
1699
|
+
|
|
1700
|
+
if (location.search) {
|
|
1701
|
+
if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
|
|
1702
|
+
} else {
|
|
1703
|
+
location.search = '';
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
if (location.hash) {
|
|
1707
|
+
if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
|
|
1708
|
+
} else {
|
|
1709
|
+
location.hash = '';
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
if (state !== undefined && location.state === undefined) location.state = state;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
try {
|
|
1716
|
+
location.pathname = decodeURI(location.pathname);
|
|
1717
|
+
} catch (e) {
|
|
1718
|
+
if (e instanceof URIError) {
|
|
1719
|
+
throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
|
|
1720
|
+
} else {
|
|
1721
|
+
throw e;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
if (key) location.key = key;
|
|
1726
|
+
|
|
1727
|
+
if (currentLocation) {
|
|
1728
|
+
// Resolve incomplete/relative pathname relative to current location.
|
|
1729
|
+
if (!location.pathname) {
|
|
1730
|
+
location.pathname = currentLocation.pathname;
|
|
1731
|
+
} else if (location.pathname.charAt(0) !== '/') {
|
|
1732
|
+
location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
|
|
1733
|
+
}
|
|
1734
|
+
} else {
|
|
1735
|
+
// When there is no prior location and pathname is empty, set it to /
|
|
1736
|
+
if (!location.pathname) {
|
|
1737
|
+
location.pathname = '/';
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
return location;
|
|
1742
|
+
};
|
|
1743
|
+
|
|
1744
|
+
var locationsAreEqual = function locationsAreEqual(a, b) {
|
|
1745
|
+
return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
|
|
1746
|
+
};
|
|
1747
|
+
|
|
1748
|
+
// eslint-disable-line no-alert
|
|
1749
|
+
|
|
1750
|
+
/**
|
|
1751
|
+
* Returns true if the HTML5 history API is supported. Taken from Modernizr.
|
|
1752
|
+
*
|
|
1753
|
+
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
|
|
1754
|
+
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
|
|
1755
|
+
* changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
|
|
1756
|
+
*/
|
|
1757
|
+
|
|
1758
|
+
|
|
1759
|
+
/**
|
|
1760
|
+
* Returns true if browser fires popstate on hash change.
|
|
1761
|
+
* IE10 and IE11 do not.
|
|
1762
|
+
*/
|
|
1763
|
+
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Returns false if using go(n) with hash history causes a full page reload.
|
|
1767
|
+
*/
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* Returns true if a given popstate event is an extraneous WebKit event.
|
|
1772
|
+
* Accounts for the fact that Chrome on iOS fires real popstate events
|
|
1773
|
+
* containing undefined state when pressing the back button.
|
|
1774
|
+
*/
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* The public API for updating the location programmatically
|
|
1778
|
+
* with a component.
|
|
1779
|
+
*/
|
|
1780
|
+
|
|
1781
|
+
var Redirect = function (_React$Component) {
|
|
1782
|
+
inherits(Redirect, _React$Component);
|
|
1783
|
+
|
|
1784
|
+
function Redirect() {
|
|
1785
|
+
classCallCheck(this, Redirect);
|
|
1786
|
+
return possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
Redirect.prototype.isStatic = function isStatic() {
|
|
1790
|
+
return this.context.router && this.context.router.staticContext;
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
Redirect.prototype.componentWillMount = function componentWillMount() {
|
|
1794
|
+
invariant_1$2(this.context.router, 'You should not use <Redirect> outside a <Router>');
|
|
1795
|
+
|
|
1796
|
+
if (this.isStatic()) this.perform();
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1799
|
+
Redirect.prototype.componentDidMount = function componentDidMount() {
|
|
1800
|
+
if (!this.isStatic()) this.perform();
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
Redirect.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
1804
|
+
var prevTo = createLocation(prevProps.to);
|
|
1805
|
+
var nextTo = createLocation(this.props.to);
|
|
1806
|
+
|
|
1807
|
+
if (locationsAreEqual(prevTo, nextTo)) {
|
|
1808
|
+
warning_1(false, 'You tried to redirect to the same route you\'re currently on: ' + ('"' + nextTo.pathname + nextTo.search + '"'));
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
this.perform();
|
|
1813
|
+
};
|
|
1814
|
+
|
|
1815
|
+
Redirect.prototype.perform = function perform() {
|
|
1816
|
+
var history = this.context.router.history;
|
|
1817
|
+
var _props = this.props,
|
|
1818
|
+
push = _props.push,
|
|
1819
|
+
to = _props.to;
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
if (push) {
|
|
1823
|
+
history.push(to);
|
|
1824
|
+
} else {
|
|
1825
|
+
history.replace(to);
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
Redirect.prototype.render = function render() {
|
|
1830
|
+
return null;
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
return Redirect;
|
|
1834
|
+
}(React.Component);
|
|
1835
|
+
|
|
1836
|
+
Redirect.propTypes = {
|
|
1837
|
+
push: propTypes.bool,
|
|
1838
|
+
from: propTypes.string,
|
|
1839
|
+
to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
|
|
1840
|
+
};
|
|
1841
|
+
Redirect.defaultProps = {
|
|
1842
|
+
push: false
|
|
1843
|
+
};
|
|
1844
|
+
Redirect.contextTypes = {
|
|
1845
|
+
router: propTypes.shape({
|
|
1846
|
+
history: propTypes.shape({
|
|
1847
|
+
push: propTypes.func.isRequired,
|
|
1848
|
+
replace: propTypes.func.isRequired
|
|
1849
|
+
}).isRequired,
|
|
1850
|
+
staticContext: propTypes.object
|
|
1851
|
+
}).isRequired
|
|
1852
|
+
};
|
|
1853
|
+
|
|
1854
|
+
var isarray = Array.isArray || function (arr) {
|
|
1855
|
+
return Object.prototype.toString.call(arr) == '[object Array]';
|
|
1856
|
+
};
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* Expose `pathToRegexp`.
|
|
1860
|
+
*/
|
|
1861
|
+
var pathToRegexp_1 = pathToRegexp;
|
|
1862
|
+
var parse_1 = parse;
|
|
1863
|
+
var compile_1 = compile;
|
|
1864
|
+
var tokensToFunction_1 = tokensToFunction;
|
|
1865
|
+
var tokensToRegExp_1 = tokensToRegExp;
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* The main path matching regexp utility.
|
|
1869
|
+
*
|
|
1870
|
+
* @type {RegExp}
|
|
1871
|
+
*/
|
|
1872
|
+
var PATH_REGEXP = new RegExp([
|
|
1873
|
+
// Match escaped characters that would otherwise appear in future matches.
|
|
1874
|
+
// This allows the user to escape special characters that won't transform.
|
|
1875
|
+
'(\\\\.)',
|
|
1876
|
+
// Match Express-style parameters and un-named parameters with a prefix
|
|
1877
|
+
// and optional suffixes. Matches appear as:
|
|
1878
|
+
//
|
|
1879
|
+
// "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
|
|
1880
|
+
// "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
|
|
1881
|
+
// "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
|
|
1882
|
+
'([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
|
|
1883
|
+
].join('|'), 'g');
|
|
1884
|
+
|
|
1885
|
+
/**
|
|
1886
|
+
* Parse a string for the raw tokens.
|
|
1887
|
+
*
|
|
1888
|
+
* @param {string} str
|
|
1889
|
+
* @param {Object=} options
|
|
1890
|
+
* @return {!Array}
|
|
1891
|
+
*/
|
|
1892
|
+
function parse (str, options) {
|
|
1893
|
+
var tokens = [];
|
|
1894
|
+
var key = 0;
|
|
1895
|
+
var index = 0;
|
|
1896
|
+
var path = '';
|
|
1897
|
+
var defaultDelimiter = options && options.delimiter || '/';
|
|
1898
|
+
var res;
|
|
1899
|
+
|
|
1900
|
+
while ((res = PATH_REGEXP.exec(str)) != null) {
|
|
1901
|
+
var m = res[0];
|
|
1902
|
+
var escaped = res[1];
|
|
1903
|
+
var offset = res.index;
|
|
1904
|
+
path += str.slice(index, offset);
|
|
1905
|
+
index = offset + m.length;
|
|
1906
|
+
|
|
1907
|
+
// Ignore already escaped sequences.
|
|
1908
|
+
if (escaped) {
|
|
1909
|
+
path += escaped[1];
|
|
1910
|
+
continue
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
var next = str[index];
|
|
1914
|
+
var prefix = res[2];
|
|
1915
|
+
var name = res[3];
|
|
1916
|
+
var capture = res[4];
|
|
1917
|
+
var group = res[5];
|
|
1918
|
+
var modifier = res[6];
|
|
1919
|
+
var asterisk = res[7];
|
|
1920
|
+
|
|
1921
|
+
// Push the current path onto the tokens.
|
|
1922
|
+
if (path) {
|
|
1923
|
+
tokens.push(path);
|
|
1924
|
+
path = '';
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
var partial = prefix != null && next != null && next !== prefix;
|
|
1928
|
+
var repeat = modifier === '+' || modifier === '*';
|
|
1929
|
+
var optional = modifier === '?' || modifier === '*';
|
|
1930
|
+
var delimiter = res[2] || defaultDelimiter;
|
|
1931
|
+
var pattern = capture || group;
|
|
1932
|
+
|
|
1933
|
+
tokens.push({
|
|
1934
|
+
name: name || key++,
|
|
1935
|
+
prefix: prefix || '',
|
|
1936
|
+
delimiter: delimiter,
|
|
1937
|
+
optional: optional,
|
|
1938
|
+
repeat: repeat,
|
|
1939
|
+
partial: partial,
|
|
1940
|
+
asterisk: !!asterisk,
|
|
1941
|
+
pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
// Match any characters still remaining.
|
|
1946
|
+
if (index < str.length) {
|
|
1947
|
+
path += str.substr(index);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
// If the path exists, push it onto the end.
|
|
1951
|
+
if (path) {
|
|
1952
|
+
tokens.push(path);
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
return tokens
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
/**
|
|
1959
|
+
* Compile a string to a template function for the path.
|
|
1960
|
+
*
|
|
1961
|
+
* @param {string} str
|
|
1962
|
+
* @param {Object=} options
|
|
1963
|
+
* @return {!function(Object=, Object=)}
|
|
1964
|
+
*/
|
|
1965
|
+
function compile (str, options) {
|
|
1966
|
+
return tokensToFunction(parse(str, options))
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Prettier encoding of URI path segments.
|
|
1971
|
+
*
|
|
1972
|
+
* @param {string}
|
|
1973
|
+
* @return {string}
|
|
1974
|
+
*/
|
|
1975
|
+
function encodeURIComponentPretty (str) {
|
|
1976
|
+
return encodeURI(str).replace(/[\/?#]/g, function (c) {
|
|
1977
|
+
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
|
1978
|
+
})
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
/**
|
|
1982
|
+
* Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
|
|
1983
|
+
*
|
|
1984
|
+
* @param {string}
|
|
1985
|
+
* @return {string}
|
|
1986
|
+
*/
|
|
1987
|
+
function encodeAsterisk (str) {
|
|
1988
|
+
return encodeURI(str).replace(/[?#]/g, function (c) {
|
|
1989
|
+
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
|
1990
|
+
})
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
/**
|
|
1994
|
+
* Expose a method for transforming tokens into the path function.
|
|
1995
|
+
*/
|
|
1996
|
+
function tokensToFunction (tokens) {
|
|
1997
|
+
// Compile all the tokens into regexps.
|
|
1998
|
+
var matches = new Array(tokens.length);
|
|
1999
|
+
|
|
2000
|
+
// Compile all the patterns before compilation.
|
|
2001
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
2002
|
+
if (typeof tokens[i] === 'object') {
|
|
2003
|
+
matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
return function (obj, opts) {
|
|
2008
|
+
var path = '';
|
|
2009
|
+
var data = obj || {};
|
|
2010
|
+
var options = opts || {};
|
|
2011
|
+
var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
|
|
2012
|
+
|
|
2013
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
2014
|
+
var token = tokens[i];
|
|
2015
|
+
|
|
2016
|
+
if (typeof token === 'string') {
|
|
2017
|
+
path += token;
|
|
2018
|
+
|
|
2019
|
+
continue
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
var value = data[token.name];
|
|
2023
|
+
var segment;
|
|
2024
|
+
|
|
2025
|
+
if (value == null) {
|
|
2026
|
+
if (token.optional) {
|
|
2027
|
+
// Prepend partial segment prefixes.
|
|
2028
|
+
if (token.partial) {
|
|
2029
|
+
path += token.prefix;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
continue
|
|
2033
|
+
} else {
|
|
2034
|
+
throw new TypeError('Expected "' + token.name + '" to be defined')
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
if (isarray(value)) {
|
|
2039
|
+
if (!token.repeat) {
|
|
2040
|
+
throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
if (value.length === 0) {
|
|
2044
|
+
if (token.optional) {
|
|
2045
|
+
continue
|
|
2046
|
+
} else {
|
|
2047
|
+
throw new TypeError('Expected "' + token.name + '" to not be empty')
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
for (var j = 0; j < value.length; j++) {
|
|
2052
|
+
segment = encode(value[j]);
|
|
2053
|
+
|
|
2054
|
+
if (!matches[i].test(segment)) {
|
|
2055
|
+
throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
path += (j === 0 ? token.prefix : token.delimiter) + segment;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
continue
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
segment = token.asterisk ? encodeAsterisk(value) : encode(value);
|
|
2065
|
+
|
|
2066
|
+
if (!matches[i].test(segment)) {
|
|
2067
|
+
throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
path += token.prefix + segment;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
return path
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
/**
|
|
2078
|
+
* Escape a regular expression string.
|
|
2079
|
+
*
|
|
2080
|
+
* @param {string} str
|
|
2081
|
+
* @return {string}
|
|
2082
|
+
*/
|
|
2083
|
+
function escapeString (str) {
|
|
2084
|
+
return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Escape the capturing group by escaping special characters and meaning.
|
|
2089
|
+
*
|
|
2090
|
+
* @param {string} group
|
|
2091
|
+
* @return {string}
|
|
2092
|
+
*/
|
|
2093
|
+
function escapeGroup (group) {
|
|
2094
|
+
return group.replace(/([=!:$\/()])/g, '\\$1')
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
* Attach the keys as a property of the regexp.
|
|
2099
|
+
*
|
|
2100
|
+
* @param {!RegExp} re
|
|
2101
|
+
* @param {Array} keys
|
|
2102
|
+
* @return {!RegExp}
|
|
2103
|
+
*/
|
|
2104
|
+
function attachKeys (re, keys) {
|
|
2105
|
+
re.keys = keys;
|
|
2106
|
+
return re
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
/**
|
|
2110
|
+
* Get the flags for a regexp from the options.
|
|
2111
|
+
*
|
|
2112
|
+
* @param {Object} options
|
|
2113
|
+
* @return {string}
|
|
2114
|
+
*/
|
|
2115
|
+
function flags (options) {
|
|
2116
|
+
return options.sensitive ? '' : 'i'
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
/**
|
|
2120
|
+
* Pull out keys from a regexp.
|
|
2121
|
+
*
|
|
2122
|
+
* @param {!RegExp} path
|
|
2123
|
+
* @param {!Array} keys
|
|
2124
|
+
* @return {!RegExp}
|
|
2125
|
+
*/
|
|
2126
|
+
function regexpToRegexp (path, keys) {
|
|
2127
|
+
// Use a negative lookahead to match only capturing groups.
|
|
2128
|
+
var groups = path.source.match(/\((?!\?)/g);
|
|
2129
|
+
|
|
2130
|
+
if (groups) {
|
|
2131
|
+
for (var i = 0; i < groups.length; i++) {
|
|
2132
|
+
keys.push({
|
|
2133
|
+
name: i,
|
|
2134
|
+
prefix: null,
|
|
2135
|
+
delimiter: null,
|
|
2136
|
+
optional: false,
|
|
2137
|
+
repeat: false,
|
|
2138
|
+
partial: false,
|
|
2139
|
+
asterisk: false,
|
|
2140
|
+
pattern: null
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
return attachKeys(path, keys)
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
/**
|
|
2149
|
+
* Transform an array into a regexp.
|
|
2150
|
+
*
|
|
2151
|
+
* @param {!Array} path
|
|
2152
|
+
* @param {Array} keys
|
|
2153
|
+
* @param {!Object} options
|
|
2154
|
+
* @return {!RegExp}
|
|
2155
|
+
*/
|
|
2156
|
+
function arrayToRegexp (path, keys, options) {
|
|
2157
|
+
var parts = [];
|
|
2158
|
+
|
|
2159
|
+
for (var i = 0; i < path.length; i++) {
|
|
2160
|
+
parts.push(pathToRegexp(path[i], keys, options).source);
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
|
|
2164
|
+
|
|
2165
|
+
return attachKeys(regexp, keys)
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* Create a path regexp from string input.
|
|
2170
|
+
*
|
|
2171
|
+
* @param {string} path
|
|
2172
|
+
* @param {!Array} keys
|
|
2173
|
+
* @param {!Object} options
|
|
2174
|
+
* @return {!RegExp}
|
|
2175
|
+
*/
|
|
2176
|
+
function stringToRegexp (path, keys, options) {
|
|
2177
|
+
return tokensToRegExp(parse(path, options), keys, options)
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* Expose a function for taking tokens and returning a RegExp.
|
|
2182
|
+
*
|
|
2183
|
+
* @param {!Array} tokens
|
|
2184
|
+
* @param {(Array|Object)=} keys
|
|
2185
|
+
* @param {Object=} options
|
|
2186
|
+
* @return {!RegExp}
|
|
2187
|
+
*/
|
|
2188
|
+
function tokensToRegExp (tokens, keys, options) {
|
|
2189
|
+
if (!isarray(keys)) {
|
|
2190
|
+
options = /** @type {!Object} */ (keys || options);
|
|
2191
|
+
keys = [];
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
options = options || {};
|
|
2195
|
+
|
|
2196
|
+
var strict = options.strict;
|
|
2197
|
+
var end = options.end !== false;
|
|
2198
|
+
var route = '';
|
|
2199
|
+
|
|
2200
|
+
// Iterate over the tokens and create our regexp string.
|
|
2201
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
2202
|
+
var token = tokens[i];
|
|
2203
|
+
|
|
2204
|
+
if (typeof token === 'string') {
|
|
2205
|
+
route += escapeString(token);
|
|
2206
|
+
} else {
|
|
2207
|
+
var prefix = escapeString(token.prefix);
|
|
2208
|
+
var capture = '(?:' + token.pattern + ')';
|
|
2209
|
+
|
|
2210
|
+
keys.push(token);
|
|
2211
|
+
|
|
2212
|
+
if (token.repeat) {
|
|
2213
|
+
capture += '(?:' + prefix + capture + ')*';
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
if (token.optional) {
|
|
2217
|
+
if (!token.partial) {
|
|
2218
|
+
capture = '(?:' + prefix + '(' + capture + '))?';
|
|
2219
|
+
} else {
|
|
2220
|
+
capture = prefix + '(' + capture + ')?';
|
|
2221
|
+
}
|
|
2222
|
+
} else {
|
|
2223
|
+
capture = prefix + '(' + capture + ')';
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
route += capture;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
var delimiter = escapeString(options.delimiter || '/');
|
|
2231
|
+
var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
|
|
2232
|
+
|
|
2233
|
+
// In non-strict mode we allow a slash at the end of match. If the path to
|
|
2234
|
+
// match already ends with a slash, we remove it for consistency. The slash
|
|
2235
|
+
// is valid at the end of a path match, not in the middle. This is important
|
|
2236
|
+
// in non-ending mode, where "/test/" shouldn't match "/test//route".
|
|
2237
|
+
if (!strict) {
|
|
2238
|
+
route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
if (end) {
|
|
2242
|
+
route += '$';
|
|
2243
|
+
} else {
|
|
2244
|
+
// In non-ending mode, we need the capturing groups to match as much as
|
|
2245
|
+
// possible by using a positive lookahead to the end or next path segment.
|
|
2246
|
+
route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
return attachKeys(new RegExp('^' + route, flags(options)), keys)
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
/**
|
|
2253
|
+
* Normalize the given path string, returning a regular expression.
|
|
2254
|
+
*
|
|
2255
|
+
* An empty array can be passed in for the keys, which will hold the
|
|
2256
|
+
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
|
|
2257
|
+
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
|
|
2258
|
+
*
|
|
2259
|
+
* @param {(string|RegExp|Array)} path
|
|
2260
|
+
* @param {(Array|Object)=} keys
|
|
2261
|
+
* @param {Object=} options
|
|
2262
|
+
* @return {!RegExp}
|
|
2263
|
+
*/
|
|
2264
|
+
function pathToRegexp (path, keys, options) {
|
|
2265
|
+
if (!isarray(keys)) {
|
|
2266
|
+
options = /** @type {!Object} */ (keys || options);
|
|
2267
|
+
keys = [];
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
options = options || {};
|
|
2271
|
+
|
|
2272
|
+
if (path instanceof RegExp) {
|
|
2273
|
+
return regexpToRegexp(path, /** @type {!Array} */ (keys))
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
if (isarray(path)) {
|
|
2277
|
+
return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
pathToRegexp_1.parse = parse_1;
|
|
2284
|
+
pathToRegexp_1.compile = compile_1;
|
|
2285
|
+
pathToRegexp_1.tokensToFunction = tokensToFunction_1;
|
|
2286
|
+
pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
|
|
2287
|
+
|
|
2288
|
+
var patternCache = {};
|
|
2289
|
+
var cacheLimit = 10000;
|
|
2290
|
+
var cacheCount = 0;
|
|
2291
|
+
|
|
2292
|
+
var compilePath = function compilePath(pattern, options) {
|
|
2293
|
+
var cacheKey = '' + options.end + options.strict + options.sensitive;
|
|
2294
|
+
var cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
|
|
2295
|
+
|
|
2296
|
+
if (cache[pattern]) return cache[pattern];
|
|
2297
|
+
|
|
2298
|
+
var keys = [];
|
|
2299
|
+
var re = pathToRegexp_1(pattern, keys, options);
|
|
2300
|
+
var compiledPattern = { re: re, keys: keys };
|
|
2301
|
+
|
|
2302
|
+
if (cacheCount < cacheLimit) {
|
|
2303
|
+
cache[pattern] = compiledPattern;
|
|
2304
|
+
cacheCount++;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
return compiledPattern;
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2310
|
+
/**
|
|
2311
|
+
* Public API for matching a URL pathname to a path pattern.
|
|
2312
|
+
*/
|
|
2313
|
+
var matchPath = function matchPath(pathname) {
|
|
2314
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2315
|
+
|
|
2316
|
+
if (typeof options === 'string') options = { path: options };
|
|
2317
|
+
|
|
2318
|
+
var _options = options,
|
|
2319
|
+
_options$path = _options.path,
|
|
2320
|
+
path = _options$path === undefined ? '/' : _options$path,
|
|
2321
|
+
_options$exact = _options.exact,
|
|
2322
|
+
exact = _options$exact === undefined ? false : _options$exact,
|
|
2323
|
+
_options$strict = _options.strict,
|
|
2324
|
+
strict = _options$strict === undefined ? false : _options$strict,
|
|
2325
|
+
_options$sensitive = _options.sensitive,
|
|
2326
|
+
sensitive = _options$sensitive === undefined ? false : _options$sensitive;
|
|
2327
|
+
|
|
2328
|
+
var _compilePath = compilePath(path, { end: exact, strict: strict, sensitive: sensitive }),
|
|
2329
|
+
re = _compilePath.re,
|
|
2330
|
+
keys = _compilePath.keys;
|
|
2331
|
+
|
|
2332
|
+
var match = re.exec(pathname);
|
|
2333
|
+
|
|
2334
|
+
if (!match) return null;
|
|
2335
|
+
|
|
2336
|
+
var url = match[0],
|
|
2337
|
+
values = match.slice(1);
|
|
2338
|
+
|
|
2339
|
+
var isExact = pathname === url;
|
|
2340
|
+
|
|
2341
|
+
if (exact && !isExact) return null;
|
|
2342
|
+
|
|
2343
|
+
return {
|
|
2344
|
+
path: path, // the path pattern used to match
|
|
2345
|
+
url: path === '/' && url === '' ? '/' : url, // the matched portion of the URL
|
|
2346
|
+
isExact: isExact, // whether or not we matched exactly
|
|
2347
|
+
params: keys.reduce(function (memo, key, index) {
|
|
2348
|
+
memo[key.name] = values[index];
|
|
2349
|
+
return memo;
|
|
2350
|
+
}, {})
|
|
2351
|
+
};
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
var isEmptyChildren = function isEmptyChildren(children) {
|
|
2355
|
+
return React.Children.count(children) === 0;
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
/**
|
|
2359
|
+
* The public API for matching a single path and rendering.
|
|
2360
|
+
*/
|
|
2361
|
+
|
|
2362
|
+
var Route = function (_React$Component) {
|
|
2363
|
+
inherits(Route, _React$Component);
|
|
2364
|
+
|
|
2365
|
+
function Route() {
|
|
2366
|
+
var _temp, _this, _ret;
|
|
2367
|
+
|
|
2368
|
+
classCallCheck(this, Route);
|
|
2369
|
+
|
|
2370
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
2371
|
+
args[_key] = arguments[_key];
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
|
|
2375
|
+
match: _this.computeMatch(_this.props, _this.context.router)
|
|
2376
|
+
}, _temp), possibleConstructorReturn(_this, _ret);
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
Route.prototype.getChildContext = function getChildContext() {
|
|
2380
|
+
return {
|
|
2381
|
+
router: _extends({}, this.context.router, {
|
|
2382
|
+
route: {
|
|
2383
|
+
location: this.props.location || this.context.router.route.location,
|
|
2384
|
+
match: this.state.match
|
|
2385
|
+
}
|
|
2386
|
+
})
|
|
2387
|
+
};
|
|
2388
|
+
};
|
|
2389
|
+
|
|
2390
|
+
Route.prototype.computeMatch = function computeMatch(_ref, router) {
|
|
2391
|
+
var computedMatch = _ref.computedMatch,
|
|
2392
|
+
location = _ref.location,
|
|
2393
|
+
path = _ref.path,
|
|
2394
|
+
strict = _ref.strict,
|
|
2395
|
+
exact = _ref.exact,
|
|
2396
|
+
sensitive = _ref.sensitive;
|
|
2397
|
+
|
|
2398
|
+
if (computedMatch) return computedMatch; // <Switch> already computed the match for us
|
|
2399
|
+
|
|
2400
|
+
invariant_1$2(router, 'You should not use <Route> or withRouter() outside a <Router>');
|
|
2401
|
+
|
|
2402
|
+
var route = router.route;
|
|
2403
|
+
|
|
2404
|
+
var pathname = (location || route.location).pathname;
|
|
2405
|
+
|
|
2406
|
+
return path ? matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }) : route.match;
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2409
|
+
Route.prototype.componentWillMount = function componentWillMount() {
|
|
2410
|
+
warning_1(!(this.props.component && this.props.render), 'You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored');
|
|
2411
|
+
|
|
2412
|
+
warning_1(!(this.props.component && this.props.children && !isEmptyChildren(this.props.children)), 'You should not use <Route component> and <Route children> in the same route; <Route children> will be ignored');
|
|
2413
|
+
|
|
2414
|
+
warning_1(!(this.props.render && this.props.children && !isEmptyChildren(this.props.children)), 'You should not use <Route render> and <Route children> in the same route; <Route children> will be ignored');
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2417
|
+
Route.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps, nextContext) {
|
|
2418
|
+
warning_1(!(nextProps.location && !this.props.location), '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.');
|
|
2419
|
+
|
|
2420
|
+
warning_1(!(!nextProps.location && this.props.location), '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.');
|
|
2421
|
+
|
|
2422
|
+
this.setState({
|
|
2423
|
+
match: this.computeMatch(nextProps, nextContext.router)
|
|
2424
|
+
});
|
|
2425
|
+
};
|
|
2426
|
+
|
|
2427
|
+
Route.prototype.render = function render() {
|
|
2428
|
+
var match = this.state.match;
|
|
2429
|
+
var _props = this.props,
|
|
2430
|
+
children = _props.children,
|
|
2431
|
+
component = _props.component,
|
|
2432
|
+
render = _props.render;
|
|
2433
|
+
var _context$router = this.context.router,
|
|
2434
|
+
history = _context$router.history,
|
|
2435
|
+
route = _context$router.route,
|
|
2436
|
+
staticContext = _context$router.staticContext;
|
|
2437
|
+
|
|
2438
|
+
var location = this.props.location || route.location;
|
|
2439
|
+
var props = { match: match, location: location, history: history, staticContext: staticContext };
|
|
2440
|
+
|
|
2441
|
+
return component ? // component prop gets first priority, only called if there's a match
|
|
2442
|
+
match ? React.createElement(component, props) : null : render ? // render prop is next, only called if there's a match
|
|
2443
|
+
match ? render(props) : null : children ? // children come last, always called
|
|
2444
|
+
typeof children === 'function' ? children(props) : !isEmptyChildren(children) ? React.Children.only(children) : null : null;
|
|
2445
|
+
};
|
|
2446
|
+
|
|
2447
|
+
return Route;
|
|
2448
|
+
}(React.Component);
|
|
2449
|
+
|
|
2450
|
+
Route.propTypes = {
|
|
2451
|
+
computedMatch: propTypes.object, // private, from <Switch>
|
|
2452
|
+
path: propTypes.string,
|
|
2453
|
+
exact: propTypes.bool,
|
|
2454
|
+
strict: propTypes.bool,
|
|
2455
|
+
sensitive: propTypes.bool,
|
|
2456
|
+
component: propTypes.func,
|
|
2457
|
+
render: propTypes.func,
|
|
2458
|
+
children: propTypes.oneOfType([propTypes.func, propTypes.node]),
|
|
2459
|
+
location: propTypes.object
|
|
2460
|
+
};
|
|
2461
|
+
Route.contextTypes = {
|
|
2462
|
+
router: propTypes.shape({
|
|
2463
|
+
history: propTypes.object.isRequired,
|
|
2464
|
+
route: propTypes.object.isRequired,
|
|
2465
|
+
staticContext: propTypes.object
|
|
2466
|
+
})
|
|
2467
|
+
};
|
|
2468
|
+
Route.childContextTypes = {
|
|
2469
|
+
router: propTypes.object.isRequired
|
|
2470
|
+
};
|
|
2471
|
+
|
|
2472
|
+
var normalizeLocation = function normalizeLocation(object) {
|
|
2473
|
+
var _object$pathname = object.pathname,
|
|
2474
|
+
pathname = _object$pathname === undefined ? '/' : _object$pathname,
|
|
2475
|
+
_object$search = object.search,
|
|
2476
|
+
search = _object$search === undefined ? '' : _object$search,
|
|
2477
|
+
_object$hash = object.hash,
|
|
2478
|
+
hash = _object$hash === undefined ? '' : _object$hash;
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
return {
|
|
2482
|
+
pathname: pathname,
|
|
2483
|
+
search: search === '?' ? '' : search,
|
|
2484
|
+
hash: hash === '#' ? '' : hash
|
|
2485
|
+
};
|
|
2486
|
+
};
|
|
2487
|
+
|
|
2488
|
+
var addBasename = function addBasename(basename, location) {
|
|
2489
|
+
if (!basename) return location;
|
|
2490
|
+
|
|
2491
|
+
return _extends({}, location, {
|
|
2492
|
+
pathname: PathUtils_1(basename) + location.pathname
|
|
2493
|
+
});
|
|
2494
|
+
};
|
|
2495
|
+
|
|
2496
|
+
var stripBasename$1 = function stripBasename(basename, location) {
|
|
2497
|
+
if (!basename) return location;
|
|
2498
|
+
|
|
2499
|
+
var base = PathUtils_1(basename);
|
|
2500
|
+
|
|
2501
|
+
if (location.pathname.indexOf(base) !== 0) return location;
|
|
2502
|
+
|
|
2503
|
+
return _extends({}, location, {
|
|
2504
|
+
pathname: location.pathname.substr(base.length)
|
|
2505
|
+
});
|
|
2506
|
+
};
|
|
2507
|
+
|
|
2508
|
+
var createLocation$1 = function createLocation(location) {
|
|
2509
|
+
return typeof location === 'string' ? PathUtils_6(location) : normalizeLocation(location);
|
|
2510
|
+
};
|
|
2511
|
+
|
|
2512
|
+
var createURL = function createURL(location) {
|
|
2513
|
+
return typeof location === 'string' ? location : PathUtils_7(location);
|
|
2514
|
+
};
|
|
2515
|
+
|
|
2516
|
+
var staticHandler = function staticHandler(methodName) {
|
|
2517
|
+
return function () {
|
|
2518
|
+
invariant_1$2(false, 'You cannot %s with <StaticRouter>', methodName);
|
|
2519
|
+
};
|
|
2520
|
+
};
|
|
2521
|
+
|
|
2522
|
+
var noop = function noop() {};
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* The public top-level API for a "static" <Router>, so-called because it
|
|
2526
|
+
* can't actually change the current location. Instead, it just records
|
|
2527
|
+
* location changes in a context object. Useful mainly in testing and
|
|
2528
|
+
* server-rendering scenarios.
|
|
2529
|
+
*/
|
|
2530
|
+
|
|
2531
|
+
var StaticRouter = function (_React$Component) {
|
|
2532
|
+
inherits(StaticRouter, _React$Component);
|
|
2533
|
+
|
|
2534
|
+
function StaticRouter() {
|
|
2535
|
+
var _temp, _this, _ret;
|
|
2536
|
+
|
|
2537
|
+
classCallCheck(this, StaticRouter);
|
|
2538
|
+
|
|
2539
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
2540
|
+
args[_key] = arguments[_key];
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.createHref = function (path) {
|
|
2544
|
+
return PathUtils_1(_this.props.basename + createURL(path));
|
|
2545
|
+
}, _this.handlePush = function (location) {
|
|
2546
|
+
var _this$props = _this.props,
|
|
2547
|
+
basename = _this$props.basename,
|
|
2548
|
+
context = _this$props.context;
|
|
2549
|
+
|
|
2550
|
+
context.action = 'PUSH';
|
|
2551
|
+
context.location = addBasename(basename, createLocation$1(location));
|
|
2552
|
+
context.url = createURL(context.location);
|
|
2553
|
+
}, _this.handleReplace = function (location) {
|
|
2554
|
+
var _this$props2 = _this.props,
|
|
2555
|
+
basename = _this$props2.basename,
|
|
2556
|
+
context = _this$props2.context;
|
|
2557
|
+
|
|
2558
|
+
context.action = 'REPLACE';
|
|
2559
|
+
context.location = addBasename(basename, createLocation$1(location));
|
|
2560
|
+
context.url = createURL(context.location);
|
|
2561
|
+
}, _this.handleListen = function () {
|
|
2562
|
+
return noop;
|
|
2563
|
+
}, _this.handleBlock = function () {
|
|
2564
|
+
return noop;
|
|
2565
|
+
}, _temp), possibleConstructorReturn(_this, _ret);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
StaticRouter.prototype.getChildContext = function getChildContext() {
|
|
2569
|
+
return {
|
|
2570
|
+
router: {
|
|
2571
|
+
staticContext: this.props.context
|
|
2572
|
+
}
|
|
2573
|
+
};
|
|
2574
|
+
};
|
|
2575
|
+
|
|
2576
|
+
StaticRouter.prototype.componentWillMount = function componentWillMount() {
|
|
2577
|
+
warning_1(!this.props.history, '<StaticRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { StaticRouter as Router }`.');
|
|
2578
|
+
};
|
|
2579
|
+
|
|
2580
|
+
StaticRouter.prototype.render = function render() {
|
|
2581
|
+
var _props = this.props,
|
|
2582
|
+
basename = _props.basename,
|
|
2583
|
+
context = _props.context,
|
|
2584
|
+
location = _props.location,
|
|
2585
|
+
props = objectWithoutProperties(_props, ['basename', 'context', 'location']);
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
var history = {
|
|
2589
|
+
createHref: this.createHref,
|
|
2590
|
+
action: 'POP',
|
|
2591
|
+
location: stripBasename$1(basename, createLocation$1(location)),
|
|
2592
|
+
push: this.handlePush,
|
|
2593
|
+
replace: this.handleReplace,
|
|
2594
|
+
go: staticHandler('go'),
|
|
2595
|
+
goBack: staticHandler('goBack'),
|
|
2596
|
+
goForward: staticHandler('goForward'),
|
|
2597
|
+
listen: this.handleListen,
|
|
2598
|
+
block: this.handleBlock
|
|
2599
|
+
};
|
|
2600
|
+
|
|
2601
|
+
return React.createElement(Router, _extends({}, props, { history: history }));
|
|
2602
|
+
};
|
|
2603
|
+
|
|
2604
|
+
return StaticRouter;
|
|
2605
|
+
}(React.Component);
|
|
2606
|
+
|
|
2607
|
+
StaticRouter.propTypes = {
|
|
2608
|
+
basename: propTypes.string,
|
|
2609
|
+
context: propTypes.object.isRequired,
|
|
2610
|
+
location: propTypes.oneOfType([propTypes.string, propTypes.object])
|
|
2611
|
+
};
|
|
2612
|
+
StaticRouter.defaultProps = {
|
|
2613
|
+
basename: '',
|
|
2614
|
+
location: '/'
|
|
2615
|
+
};
|
|
2616
|
+
StaticRouter.childContextTypes = {
|
|
2617
|
+
router: propTypes.object.isRequired
|
|
2618
|
+
};
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* The public API for rendering the first <Route> that matches.
|
|
2622
|
+
*/
|
|
2623
|
+
|
|
2624
|
+
var Switch = function (_React$Component) {
|
|
2625
|
+
inherits(Switch, _React$Component);
|
|
2626
|
+
|
|
2627
|
+
function Switch() {
|
|
2628
|
+
classCallCheck(this, Switch);
|
|
2629
|
+
return possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
Switch.prototype.componentWillMount = function componentWillMount() {
|
|
2633
|
+
invariant_1$2(this.context.router, 'You should not use <Switch> outside a <Router>');
|
|
2634
|
+
};
|
|
2635
|
+
|
|
2636
|
+
Switch.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
2637
|
+
warning_1(!(nextProps.location && !this.props.location), '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.');
|
|
2638
|
+
|
|
2639
|
+
warning_1(!(!nextProps.location && this.props.location), '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.');
|
|
2640
|
+
};
|
|
2641
|
+
|
|
2642
|
+
Switch.prototype.render = function render() {
|
|
2643
|
+
var route = this.context.router.route;
|
|
2644
|
+
var children = this.props.children;
|
|
2645
|
+
|
|
2646
|
+
var location = this.props.location || route.location;
|
|
2647
|
+
|
|
2648
|
+
var match = void 0,
|
|
2649
|
+
child = void 0;
|
|
2650
|
+
React.Children.forEach(children, function (element) {
|
|
2651
|
+
if (!React.isValidElement(element)) return;
|
|
2652
|
+
|
|
2653
|
+
var _element$props = element.props,
|
|
2654
|
+
pathProp = _element$props.path,
|
|
2655
|
+
exact = _element$props.exact,
|
|
2656
|
+
strict = _element$props.strict,
|
|
2657
|
+
sensitive = _element$props.sensitive,
|
|
2658
|
+
from = _element$props.from;
|
|
2659
|
+
|
|
2660
|
+
var path = pathProp || from;
|
|
2661
|
+
|
|
2662
|
+
if (match == null) {
|
|
2663
|
+
child = element;
|
|
2664
|
+
match = path ? matchPath(location.pathname, { path: path, exact: exact, strict: strict, sensitive: sensitive }) : route.match;
|
|
2665
|
+
}
|
|
2666
|
+
});
|
|
2667
|
+
|
|
2668
|
+
return match ? React.cloneElement(child, { location: location, computedMatch: match }) : null;
|
|
2669
|
+
};
|
|
2670
|
+
|
|
2671
|
+
return Switch;
|
|
2672
|
+
}(React.Component);
|
|
2673
|
+
|
|
2674
|
+
Switch.contextTypes = {
|
|
2675
|
+
router: propTypes.shape({
|
|
2676
|
+
route: propTypes.object.isRequired
|
|
2677
|
+
}).isRequired
|
|
2678
|
+
};
|
|
2679
|
+
Switch.propTypes = {
|
|
2680
|
+
children: propTypes.node,
|
|
2681
|
+
location: propTypes.object
|
|
2682
|
+
};
|
|
2683
|
+
|
|
2684
|
+
/**
|
|
2685
|
+
* Copyright 2015, Yahoo! Inc.
|
|
2686
|
+
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
2687
|
+
*/
|
|
2688
|
+
var REACT_STATICS = {
|
|
2689
|
+
childContextTypes: true,
|
|
2690
|
+
contextTypes: true,
|
|
2691
|
+
defaultProps: true,
|
|
2692
|
+
displayName: true,
|
|
2693
|
+
getDefaultProps: true,
|
|
2694
|
+
mixins: true,
|
|
2695
|
+
propTypes: true,
|
|
2696
|
+
type: true
|
|
2697
|
+
};
|
|
2698
|
+
|
|
2699
|
+
var KNOWN_STATICS = {
|
|
2700
|
+
name: true,
|
|
2701
|
+
length: true,
|
|
2702
|
+
prototype: true,
|
|
2703
|
+
caller: true,
|
|
2704
|
+
callee: true,
|
|
2705
|
+
arguments: true,
|
|
2706
|
+
arity: true
|
|
2707
|
+
};
|
|
2708
|
+
|
|
2709
|
+
var defineProperty$1 = Object.defineProperty;
|
|
2710
|
+
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
2711
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
2712
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
2713
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
2714
|
+
var objectPrototype = getPrototypeOf && getPrototypeOf(Object);
|
|
2715
|
+
|
|
2716
|
+
var hoistNonReactStatics = function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
|
2717
|
+
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
|
|
2718
|
+
|
|
2719
|
+
if (objectPrototype) {
|
|
2720
|
+
var inheritedComponent = getPrototypeOf(sourceComponent);
|
|
2721
|
+
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
|
2722
|
+
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
var keys = getOwnPropertyNames(sourceComponent);
|
|
2727
|
+
|
|
2728
|
+
if (getOwnPropertySymbols) {
|
|
2729
|
+
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
for (var i = 0; i < keys.length; ++i) {
|
|
2733
|
+
var key = keys[i];
|
|
2734
|
+
if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) {
|
|
2735
|
+
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
2736
|
+
try { // Avoid failures from read-only properties
|
|
2737
|
+
defineProperty$1(targetComponent, key, descriptor);
|
|
2738
|
+
} catch (e) {}
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
return targetComponent;
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
return targetComponent;
|
|
2746
|
+
};
|
|
2747
|
+
|
|
2748
|
+
/**
|
|
2749
|
+
* A public higher-order component to access the imperative API
|
|
2750
|
+
*/
|
|
2751
|
+
var withRouter = function withRouter(Component) {
|
|
2752
|
+
var C = function C(props) {
|
|
2753
|
+
var wrappedComponentRef = props.wrappedComponentRef,
|
|
2754
|
+
remainingProps = objectWithoutProperties(props, ['wrappedComponentRef']);
|
|
2755
|
+
|
|
2756
|
+
return React.createElement(Route, { render: function render(routeComponentProps) {
|
|
2757
|
+
return React.createElement(Component, _extends({}, remainingProps, routeComponentProps, { ref: wrappedComponentRef }));
|
|
2758
|
+
} });
|
|
2759
|
+
};
|
|
2760
|
+
|
|
2761
|
+
C.displayName = 'withRouter(' + (Component.displayName || Component.name) + ')';
|
|
2762
|
+
C.WrappedComponent = Component;
|
|
2763
|
+
C.propTypes = {
|
|
2764
|
+
wrappedComponentRef: propTypes.func
|
|
2765
|
+
};
|
|
2766
|
+
|
|
2767
|
+
return hoistNonReactStatics(C, Component);
|
|
2768
|
+
};
|
|
2769
|
+
|
|
2770
|
+
exports.MemoryRouter = MemoryRouter;
|
|
2771
|
+
exports.Prompt = Prompt;
|
|
2772
|
+
exports.Redirect = Redirect;
|
|
2773
|
+
exports.Route = Route;
|
|
2774
|
+
exports.Router = Router;
|
|
2775
|
+
exports.StaticRouter = StaticRouter;
|
|
2776
|
+
exports.Switch = Switch;
|
|
2777
|
+
exports.matchPath = matchPath;
|
|
2778
|
+
exports.withRouter = withRouter;
|
|
2779
|
+
|
|
2780
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2781
|
+
|
|
2782
|
+
})));
|