1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 |
|
5 | var _extends2 = require('babel-runtime/helpers/extends');
|
6 |
|
7 | var _extends3 = _interopRequireDefault(_extends2);
|
8 |
|
9 | exports.default = getContextProps;
|
10 |
|
11 | var _zhCn = require('../locale/zh-cn.js');
|
12 |
|
13 | var _zhCn2 = _interopRequireDefault(_zhCn);
|
14 |
|
15 | var _util = require('../util');
|
16 |
|
17 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | var parseBoundary = function parseBoundary(input) {
|
25 | var obj = void 0;
|
26 | if (input === undefined || input === null) {
|
27 | return {};
|
28 | } else if (typeof input === 'boolean') {
|
29 | obj = { open: input };
|
30 | } else {
|
31 | obj = (0, _extends3.default)({ open: true }, input);
|
32 | }
|
33 |
|
34 | return obj;
|
35 | };
|
36 |
|
37 | function getContextProps(props, context, displayName) {
|
38 | var prefix = props.prefix,
|
39 | locale = props.locale,
|
40 | defaultPropsConfig = props.defaultPropsConfig,
|
41 | pure = props.pure,
|
42 | rtl = props.rtl,
|
43 | device = props.device,
|
44 | popupContainer = props.popupContainer,
|
45 | errorBoundary = props.errorBoundary;
|
46 | var nextPrefix = context.nextPrefix,
|
47 | nextLocale = context.nextLocale,
|
48 | nextDefaultPropsConfig = context.nextDefaultPropsConfig,
|
49 | nextPure = context.nextPure,
|
50 | nextWarning = context.nextWarning,
|
51 | nextRtl = context.nextRtl,
|
52 | nextDevice = context.nextDevice,
|
53 | nextPopupContainer = context.nextPopupContainer,
|
54 | nextErrorBoundary = context.nextErrorBoundary;
|
55 |
|
56 |
|
57 | var newPrefix = prefix || nextPrefix;
|
58 |
|
59 | var localeFromContext = void 0;
|
60 | var newDisplayName = displayName;
|
61 |
|
62 | switch (displayName) {
|
63 | case 'DatePicker2':
|
64 | newDisplayName = 'DatePicker';
|
65 | break;
|
66 | case 'Calendar2':
|
67 | newDisplayName = 'Calendar';
|
68 | break;
|
69 | case 'TimePicker2':
|
70 | newDisplayName = 'TimePicker';
|
71 | break;
|
72 | default:
|
73 | break;
|
74 | }
|
75 |
|
76 | if (nextLocale) {
|
77 | localeFromContext = nextLocale[newDisplayName];
|
78 | if (localeFromContext) {
|
79 | localeFromContext.momentLocale = nextLocale.momentLocale;
|
80 | }
|
81 | }
|
82 |
|
83 | var newLocale = void 0;
|
84 | if (locale) {
|
85 | newLocale = _util.obj.deepMerge({}, _zhCn2.default[newDisplayName], localeFromContext, locale);
|
86 | } else if (localeFromContext) {
|
87 | newLocale = _util.obj.deepMerge({}, _zhCn2.default[newDisplayName], localeFromContext);
|
88 | }
|
89 |
|
90 | var newPure = typeof pure === 'boolean' ? pure : nextPure;
|
91 | var newRtl = typeof rtl === 'boolean' ? rtl : nextRtl;
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | var newErrorBoundary = (0, _extends3.default)({}, parseBoundary(nextErrorBoundary), parseBoundary(errorBoundary));
|
97 |
|
98 | if (!('open' in newErrorBoundary)) {
|
99 | newErrorBoundary.open = false;
|
100 | }
|
101 |
|
102 | return {
|
103 | prefix: newPrefix,
|
104 | locale: newLocale,
|
105 | pure: newPure,
|
106 | rtl: newRtl,
|
107 | warning: nextWarning,
|
108 | defaultPropsConfig: nextDefaultPropsConfig || {},
|
109 | device: device || nextDevice || undefined,
|
110 | popupContainer: popupContainer || nextPopupContainer,
|
111 | errorBoundary: newErrorBoundary
|
112 | };
|
113 | }
|
114 | module.exports = exports['default']; |
\ | No newline at end of file |