1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
4 | import _inherits from 'babel-runtime/helpers/inherits';
|
5 |
|
6 | var _class, _temp;
|
7 |
|
8 | import React from 'react';
|
9 | import PropTypes from 'prop-types';
|
10 | import classNames from 'classnames';
|
11 | import Overlay from '../overlay';
|
12 | import ConfigProvider from '../config-provider';
|
13 | import { obj, func } from '../util';
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var Loading = (_temp = _class = function (_React$Component) {
|
19 | _inherits(Loading, _React$Component);
|
20 |
|
21 | function Loading() {
|
22 | _classCallCheck(this, Loading);
|
23 |
|
24 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
25 | }
|
26 |
|
27 | Loading.prototype.render = function render() {
|
28 | var _classNames2, _classNames3, _classNames4;
|
29 |
|
30 | var _props = this.props,
|
31 | tip = _props.tip,
|
32 | visible = _props.visible,
|
33 | children = _props.children,
|
34 | className = _props.className,
|
35 | style = _props.style,
|
36 | indicator = _props.indicator,
|
37 | color = _props.color,
|
38 | prefix = _props.prefix,
|
39 | fullScreen = _props.fullScreen,
|
40 | disableScroll = _props.disableScroll,
|
41 | onVisibleChange = _props.onVisibleChange,
|
42 | tipAlign = _props.tipAlign,
|
43 | size = _props.size,
|
44 | inline = _props.inline,
|
45 | rtl = _props.rtl,
|
46 | safeNode = _props.safeNode;
|
47 |
|
48 |
|
49 | var indicatorDom = null;
|
50 | var dotCls = prefix + 'loading-dot';
|
51 |
|
52 | if (indicator) {
|
53 | indicatorDom = indicator;
|
54 | } else {
|
55 | var _classNames;
|
56 |
|
57 | var backgroundColor = color;
|
58 | var fusionReactorCls = classNames((_classNames = {}, _classNames[prefix + 'loading-fusion-reactor'] = true, _classNames[prefix + 'loading-medium-fusion-reactor'] = size === 'medium', _classNames));
|
59 | indicatorDom = React.createElement(
|
60 | 'div',
|
61 | { className: fusionReactorCls, dir: rtl ? 'rtl' : undefined },
|
62 | React.createElement('span', { className: dotCls, style: { backgroundColor: backgroundColor } }),
|
63 | React.createElement('span', { className: dotCls, style: { backgroundColor: backgroundColor } }),
|
64 | React.createElement('span', { className: dotCls, style: { backgroundColor: backgroundColor } }),
|
65 | React.createElement('span', { className: dotCls, style: { backgroundColor: backgroundColor } })
|
66 | );
|
67 | }
|
68 |
|
69 | var loadingCls = classNames((_classNames2 = {}, _classNames2[prefix + 'loading'] = true, _classNames2[prefix + 'open'] = visible, _classNames2[prefix + 'loading-inline'] = inline, _classNames2[className] = className, _classNames2));
|
70 |
|
71 | var tipCls = classNames((_classNames3 = {}, _classNames3[prefix + 'loading-tip'] = true, _classNames3[prefix + 'loading-tip-fullscreen'] = fullScreen, _classNames3[prefix + 'loading-right-tip'] = tipAlign === 'right', _classNames3));
|
72 |
|
73 | var others = obj.pickOthers(Loading.propTypes, this.props);
|
74 |
|
75 | var contentCls = classNames((_classNames4 = {}, _classNames4[prefix + 'loading-component'] = visible, _classNames4[prefix + 'loading-wrap'] = true, _classNames4));
|
76 |
|
77 | return fullScreen ? [children, React.createElement(
|
78 | Overlay,
|
79 | _extends({
|
80 | key: 'overlay',
|
81 | hasMask: true,
|
82 | align: 'cc cc',
|
83 | safeNode: safeNode,
|
84 | disableScroll: disableScroll
|
85 | }, others, {
|
86 | className: className,
|
87 | style: style,
|
88 | visible: visible,
|
89 | onRequestClose: onVisibleChange
|
90 | }),
|
91 | React.createElement(
|
92 | 'div',
|
93 | { className: tipCls },
|
94 | React.createElement(
|
95 | 'div',
|
96 | { className: prefix + 'loading-indicator' },
|
97 | indicatorDom
|
98 | ),
|
99 | React.createElement(
|
100 | 'div',
|
101 | { className: prefix + 'loading-tip-content' },
|
102 | tip
|
103 | ),
|
104 | React.createElement(
|
105 | 'div',
|
106 | { className: prefix + 'loading-tip-placeholder' },
|
107 | tip
|
108 | )
|
109 | )
|
110 | )] : React.createElement(
|
111 | 'div',
|
112 | _extends({ className: loadingCls, style: style }, others),
|
113 | visible ? React.createElement(
|
114 | 'div',
|
115 | { className: tipCls },
|
116 | React.createElement(
|
117 | 'div',
|
118 | { className: prefix + 'loading-indicator' },
|
119 | indicatorDom
|
120 | ),
|
121 | React.createElement(
|
122 | 'div',
|
123 | { className: prefix + 'loading-tip-content' },
|
124 | tip
|
125 | ),
|
126 | React.createElement(
|
127 | 'div',
|
128 | { className: prefix + 'loading-tip-placeholder' },
|
129 | tip
|
130 | )
|
131 | ) : null,
|
132 | React.createElement(
|
133 | 'div',
|
134 | { className: contentCls },
|
135 | visible ? React.createElement('div', { className: prefix + 'loading-masker' }) : null,
|
136 | children
|
137 | )
|
138 | );
|
139 | };
|
140 |
|
141 | return Loading;
|
142 | }(React.Component), _class.propTypes = _extends({}, ConfigProvider.propTypes, {
|
143 | |
144 |
|
145 |
|
146 | prefix: PropTypes.string,
|
147 | |
148 |
|
149 |
|
150 | tip: PropTypes.any,
|
151 | |
152 |
|
153 |
|
154 |
|
155 | tipAlign: PropTypes.oneOf(['right', 'bottom']),
|
156 | |
157 |
|
158 |
|
159 | visible: PropTypes.bool,
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 | onVisibleChange: PropTypes.func,
|
166 | |
167 |
|
168 |
|
169 | className: PropTypes.string,
|
170 | |
171 |
|
172 |
|
173 | style: PropTypes.object,
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 | size: PropTypes.oneOf(['large', 'medium']),
|
180 | |
181 |
|
182 |
|
183 | indicator: PropTypes.any,
|
184 | |
185 |
|
186 |
|
187 | color: PropTypes.string,
|
188 | |
189 |
|
190 |
|
191 | fullScreen: PropTypes.bool,
|
192 | |
193 |
|
194 |
|
195 |
|
196 |
|
197 | disableScroll: PropTypes.bool,
|
198 | |
199 |
|
200 |
|
201 | safeNode: PropTypes.any,
|
202 | |
203 |
|
204 |
|
205 | children: PropTypes.any,
|
206 | inline: PropTypes.bool,
|
207 | rtl: PropTypes.bool
|
208 | }), _class.defaultProps = {
|
209 | prefix: 'next-',
|
210 | visible: true,
|
211 | onVisibleChange: func.noop,
|
212 | animate: null,
|
213 | tipAlign: 'bottom',
|
214 | size: 'large',
|
215 | inline: true,
|
216 | disableScroll: false
|
217 | }, _temp);
|
218 | Loading.displayName = 'Loading';
|
219 |
|
220 |
|
221 | export default ConfigProvider.config(Loading); |
\ | No newline at end of file |