@daoyi/nmtl-ui 2.0.1-beta.7 → 2.0.1-beta.71
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/lib/components/Autocomplete-e62927dc.js +334 -0
- package/lib/components/Autocomplete.js +13 -1
- package/lib/components/Avatar.js +53 -1
- package/lib/components/BackTop.js +109 -1
- package/lib/components/BarChart.js +762 -1
- package/lib/components/Breadcrumbs.js +122 -1
- package/lib/components/Button-4fddcd2f.js +92 -0
- package/lib/components/Button.js +6 -1
- package/lib/components/Carousel.js +4654 -1
- package/lib/components/Checkbox.js +37 -1
- package/lib/components/CollapseContent.js +179 -1
- package/lib/components/ContactModal-33f4e605.js +12020 -0
- package/lib/components/ContactModal.js +22 -3
- package/lib/components/Drawer-fb5bc1ec.js +157 -0
- package/lib/components/Drawer.js +11 -1
- package/lib/components/Dropdown.js +134 -1
- package/lib/components/Empty-e50b760e.js +45 -0
- package/lib/components/Empty.js +5 -1
- package/lib/components/ExportButton.js +112 -1
- package/lib/components/ExtraTools-a49a1d2f.js +3537 -0
- package/lib/components/ExtraTools.js +10 -22
- package/lib/components/Filter.js +782 -12
- package/lib/components/Footer.js +271 -1
- package/lib/components/ForwardLink-6a82c19d.js +106 -0
- package/lib/components/ForwardLink.js +8 -0
- package/lib/components/Header.js +187 -1
- package/lib/components/Image.js +61 -1
- package/lib/components/Input.js +82 -1
- package/lib/components/InputMethod.js +33949 -12
- package/lib/components/KeywordSearch-3af0c402.js +140 -0
- package/lib/components/KeywordSearch.js +15 -1
- package/lib/components/KeywordTicker.js +190 -1
- package/lib/components/Keywords.js +317 -1
- package/lib/components/Loading.js +28 -1
- package/lib/components/MUITheme.js +2624 -1
- package/lib/components/Modal-2c39d5b8.js +108 -0
- package/lib/components/Modal.js +9 -1
- package/lib/components/MoreButton-6b323fe4.js +110 -0
- package/lib/components/MoreButton.js +6 -1
- package/lib/components/Pagination.js +3706 -0
- package/lib/components/Radio.js +78 -1
- package/lib/components/SNA.js +1691 -22
- package/lib/components/Select-0f131640.js +115 -0
- package/lib/components/Select.js +8 -1
- package/lib/components/Spin-1741f625.js +75 -0
- package/lib/components/Spin.js +6 -1
- package/lib/components/Table.js +51 -1
- package/lib/components/Tooltip-65a21a86.js +70 -0
- package/lib/components/Tooltip.js +7 -1
- package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
- package/lib/components/_rollupPluginBabelHelpers-a52356f6.js +142 -0
- package/lib/components/createSvgIcon-d9801fb7.js +576 -0
- package/lib/components/dataExport-d55d6fa3.js +92 -0
- package/lib/components/debounce-127da66c.js +355 -0
- package/lib/components/defaultTheme-5839b9b3.js +1505 -0
- package/lib/components/globalConfig.js +175 -0
- package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
- package/lib/components/index-0be0afec.js +481 -0
- package/lib/components/index-ef96775f.js +61 -0
- package/lib/components/isObjectLike-e111475d.js +190 -0
- package/lib/components/style-inject.es-1f59c1d0.js +28 -1
- package/lib/components/transform-3a04288b.js +5475 -0
- package/lib/components/withTheme-4417822c.js +6 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/utils/_rollupPluginBabelHelpers-8dd26e1a.js +121 -0
- package/lib/utils/arrayMerge.js +4953 -1
- package/lib/utils/chunkArray.js +15 -1
- package/lib/utils/convert2HtmlEntities.js +42 -1
- package/lib/utils/domToImage.js +802 -1
- package/lib/utils/downloadGephi.js +106 -1
- package/lib/utils/exportXlsx.js +219 -1
- package/lib/utils/historyAppendSearch.js +502 -1
- package/lib/utils/isDevelopMode.js +5 -1
- package/lib/utils/parseYMD.js +36 -1
- package/lib/utils/removeDuplicateItem.js +11 -1
- package/lib/utils/sendEmail.js +39 -1
- package/lib/utils/snaDefine-6a2bcd94.js +5 -0
- package/lib/utils/snaDefine.js +1 -1
- package/lib/utils/snaPreProcess.js +84 -1
- package/package.json +17 -21
- package/lib/components/Empty-54b79907.js +0 -1
- package/lib/components/KeywordSearch-5a393f12.js +0 -1
- package/lib/components/Select-f2441b83.js +0 -1
- package/lib/components/_rollupPluginBabelHelpers-1b8c042f.js +0 -1
- package/lib/components/_rollupPluginBabelHelpers-ec4e2a53.js +0 -1
- package/lib/components/createSvgIcon-62b64929.js +0 -1
- package/lib/components/createSvgIcon-e24792d4.js +0 -1
- package/lib/components/createTheme-7fffa109.js +0 -1
- package/lib/components/dataExport-9fccd4f0.js +0 -1
- package/lib/components/debounce-c993109b.js +0 -1
- package/lib/components/hoist-non-react-statics.cjs-d6a9befd.js +0 -1
- package/lib/components/index-11391ca3.js +0 -7
- package/lib/components/index-b2745105.js +0 -7
- package/lib/components/isObjectLike-2f1983fe.js +0 -1
- package/lib/components/style-inject.es-c875d022.js +0 -1
- package/lib/components/transform-0eb2d36e.js +0 -1
- package/lib/utils/_commonjsHelpers-e2cda605.js +0 -1
- package/lib/utils/_rollupPluginBabelHelpers-928a52ce.js +0 -1
|
@@ -0,0 +1,3706 @@
|
|
|
1
|
+
import { c as _objectWithoutProperties$1 } from './_rollupPluginBabelHelpers-a52356f6.js';
|
|
2
|
+
import * as React$2 from 'react';
|
|
3
|
+
import React__default, { Children, isValidElement, cloneElement } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { d as defaultTheme, a as _objectWithoutProperties, _ as _extends, b as _objectWithoutPropertiesLoose, c as alpha, f as formatMuiErrorMessage } from './defaultTheme-5839b9b3.js';
|
|
6
|
+
import { u as useControlled, c as clsx, b as useEventCallback, w as withStyles, d as useIsFocusVisible, e as useForkRef, f as createSvgIcon, g as capitalize, h as debounce, r as requireCreateSvgIcon, i as interopRequireDefault, a as interopRequireWildcard } from './createSvgIcon-d9801fb7.js';
|
|
7
|
+
import 'react-is';
|
|
8
|
+
import { useTheme as useTheme$1 } from '@material-ui/styles';
|
|
9
|
+
import './withTheme-4417822c.js';
|
|
10
|
+
import * as ReactDOM from 'react-dom';
|
|
11
|
+
import ReactDOM__default from 'react-dom';
|
|
12
|
+
import { c as classNames } from './index-ef96775f.js';
|
|
13
|
+
import { IconButton } from '@material-ui/core';
|
|
14
|
+
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
15
|
+
import './_commonjsHelpers-70de2c37.js';
|
|
16
|
+
|
|
17
|
+
function _arrayLikeToArray(arr, len) {
|
|
18
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
19
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
20
|
+
arr2[i] = arr[i];
|
|
21
|
+
}
|
|
22
|
+
return arr2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _arrayWithoutHoles(arr) {
|
|
26
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function _iterableToArray(iter) {
|
|
30
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
34
|
+
if (!o) return;
|
|
35
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
36
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
37
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
38
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
39
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _nonIterableSpread() {
|
|
43
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function _toConsumableArray(arr) {
|
|
47
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _arrayWithHoles(arr) {
|
|
51
|
+
if (Array.isArray(arr)) return arr;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _iterableToArrayLimit(arr, i) {
|
|
55
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
56
|
+
if (_i == null) return;
|
|
57
|
+
var _arr = [];
|
|
58
|
+
var _n = true;
|
|
59
|
+
var _d = false;
|
|
60
|
+
var _s, _e;
|
|
61
|
+
try {
|
|
62
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
63
|
+
_arr.push(_s.value);
|
|
64
|
+
if (i && _arr.length === i) break;
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
_d = true;
|
|
68
|
+
_e = err;
|
|
69
|
+
} finally {
|
|
70
|
+
try {
|
|
71
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
72
|
+
} finally {
|
|
73
|
+
if (_d) throw _e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return _arr;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _nonIterableRest() {
|
|
80
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _slicedToArray(arr, i) {
|
|
84
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function useTheme() {
|
|
88
|
+
var theme = useTheme$1() || defaultTheme;
|
|
89
|
+
|
|
90
|
+
return theme;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function usePagination() {
|
|
94
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
95
|
+
|
|
96
|
+
// keep default values in sync with @default tags in Pagination.propTypes
|
|
97
|
+
var _props$boundaryCount = props.boundaryCount,
|
|
98
|
+
boundaryCount = _props$boundaryCount === void 0 ? 1 : _props$boundaryCount,
|
|
99
|
+
_props$componentName = props.componentName,
|
|
100
|
+
componentName = _props$componentName === void 0 ? 'usePagination' : _props$componentName,
|
|
101
|
+
_props$count = props.count,
|
|
102
|
+
count = _props$count === void 0 ? 1 : _props$count,
|
|
103
|
+
_props$defaultPage = props.defaultPage,
|
|
104
|
+
defaultPage = _props$defaultPage === void 0 ? 1 : _props$defaultPage,
|
|
105
|
+
_props$disabled = props.disabled,
|
|
106
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
107
|
+
_props$hideNextButton = props.hideNextButton,
|
|
108
|
+
hideNextButton = _props$hideNextButton === void 0 ? false : _props$hideNextButton,
|
|
109
|
+
_props$hidePrevButton = props.hidePrevButton,
|
|
110
|
+
hidePrevButton = _props$hidePrevButton === void 0 ? false : _props$hidePrevButton,
|
|
111
|
+
handleChange = props.onChange,
|
|
112
|
+
pageProp = props.page,
|
|
113
|
+
_props$showFirstButto = props.showFirstButton,
|
|
114
|
+
showFirstButton = _props$showFirstButto === void 0 ? false : _props$showFirstButto,
|
|
115
|
+
_props$showLastButton = props.showLastButton,
|
|
116
|
+
showLastButton = _props$showLastButton === void 0 ? false : _props$showLastButton,
|
|
117
|
+
_props$siblingCount = props.siblingCount,
|
|
118
|
+
siblingCount = _props$siblingCount === void 0 ? 1 : _props$siblingCount,
|
|
119
|
+
other = _objectWithoutProperties(props, ["boundaryCount", "componentName", "count", "defaultPage", "disabled", "hideNextButton", "hidePrevButton", "onChange", "page", "showFirstButton", "showLastButton", "siblingCount"]);
|
|
120
|
+
|
|
121
|
+
var _useControlled = useControlled({
|
|
122
|
+
controlled: pageProp,
|
|
123
|
+
default: defaultPage,
|
|
124
|
+
name: componentName,
|
|
125
|
+
state: 'page'
|
|
126
|
+
}),
|
|
127
|
+
_useControlled2 = _slicedToArray(_useControlled, 2),
|
|
128
|
+
page = _useControlled2[0],
|
|
129
|
+
setPageState = _useControlled2[1];
|
|
130
|
+
|
|
131
|
+
var handleClick = function handleClick(event, value) {
|
|
132
|
+
if (!pageProp) {
|
|
133
|
+
setPageState(value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (handleChange) {
|
|
137
|
+
handleChange(event, value);
|
|
138
|
+
}
|
|
139
|
+
}; // https://dev.to/namirsab/comment/2050
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
var range = function range(start, end) {
|
|
143
|
+
var length = end - start + 1;
|
|
144
|
+
return Array.from({
|
|
145
|
+
length: length
|
|
146
|
+
}, function (_, i) {
|
|
147
|
+
return start + i;
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
var startPages = range(1, Math.min(boundaryCount, count));
|
|
152
|
+
var endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);
|
|
153
|
+
var siblingsStart = Math.max(Math.min( // Natural start
|
|
154
|
+
page - siblingCount, // Lower boundary when page is high
|
|
155
|
+
count - boundaryCount - siblingCount * 2 - 1), // Greater than startPages
|
|
156
|
+
boundaryCount + 2);
|
|
157
|
+
var siblingsEnd = Math.min(Math.max( // Natural end
|
|
158
|
+
page + siblingCount, // Upper boundary when page is low
|
|
159
|
+
boundaryCount + siblingCount * 2 + 2), // Less than endPages
|
|
160
|
+
endPages[0] - 2); // Basic list of items to render
|
|
161
|
+
// e.g. itemList = ['first', 'previous', 1, 'ellipsis', 4, 5, 6, 'ellipsis', 10, 'next', 'last']
|
|
162
|
+
|
|
163
|
+
var itemList = [].concat(_toConsumableArray(showFirstButton ? ['first'] : []), _toConsumableArray(hidePrevButton ? [] : ['previous']), _toConsumableArray(startPages), _toConsumableArray(siblingsStart > boundaryCount + 2 ? ['start-ellipsis'] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : []), _toConsumableArray(range(siblingsStart, siblingsEnd)), _toConsumableArray(siblingsEnd < count - boundaryCount - 1 ? ['end-ellipsis'] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : []), _toConsumableArray(endPages), _toConsumableArray(hideNextButton ? [] : ['next']), _toConsumableArray(showLastButton ? ['last'] : [])); // Map the button type to its page number
|
|
164
|
+
|
|
165
|
+
var buttonPage = function buttonPage(type) {
|
|
166
|
+
switch (type) {
|
|
167
|
+
case 'first':
|
|
168
|
+
return 1;
|
|
169
|
+
|
|
170
|
+
case 'previous':
|
|
171
|
+
return page - 1;
|
|
172
|
+
|
|
173
|
+
case 'next':
|
|
174
|
+
return page + 1;
|
|
175
|
+
|
|
176
|
+
case 'last':
|
|
177
|
+
return count;
|
|
178
|
+
|
|
179
|
+
default:
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}; // Convert the basic item list to PaginationItem props objects
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
var items = itemList.map(function (item) {
|
|
186
|
+
return typeof item === 'number' ? {
|
|
187
|
+
onClick: function onClick(event) {
|
|
188
|
+
handleClick(event, item);
|
|
189
|
+
},
|
|
190
|
+
type: 'page',
|
|
191
|
+
page: item,
|
|
192
|
+
selected: item === page,
|
|
193
|
+
disabled: disabled,
|
|
194
|
+
'aria-current': item === page ? 'true' : undefined
|
|
195
|
+
} : {
|
|
196
|
+
onClick: function onClick(event) {
|
|
197
|
+
handleClick(event, buttonPage(item));
|
|
198
|
+
},
|
|
199
|
+
type: item,
|
|
200
|
+
page: buttonPage(item),
|
|
201
|
+
selected: false,
|
|
202
|
+
disabled: disabled || item.indexOf('ellipsis') === -1 && (item === 'next' || item === 'last' ? page >= count : page <= 1)
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
return _extends({
|
|
206
|
+
items: items
|
|
207
|
+
}, other);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function _setPrototypeOf(o, p) {
|
|
211
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
212
|
+
o.__proto__ = p;
|
|
213
|
+
return o;
|
|
214
|
+
};
|
|
215
|
+
return _setPrototypeOf(o, p);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function _inheritsLoose(subClass, superClass) {
|
|
219
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
220
|
+
subClass.prototype.constructor = subClass;
|
|
221
|
+
_setPrototypeOf(subClass, superClass);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Checks if a given element has a CSS class.
|
|
226
|
+
*
|
|
227
|
+
* @param element the element
|
|
228
|
+
* @param className the CSS class name
|
|
229
|
+
*/
|
|
230
|
+
function hasClass(element, className) {
|
|
231
|
+
if (element.classList) return !!className && element.classList.contains(className);
|
|
232
|
+
return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Adds a CSS class to a given element.
|
|
237
|
+
*
|
|
238
|
+
* @param element the element
|
|
239
|
+
* @param className the CSS class name
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
function addClass(element, className) {
|
|
243
|
+
if (element.classList) element.classList.add(className);else if (!hasClass(element, className)) if (typeof element.className === 'string') element.className = element.className + " " + className;else element.setAttribute('class', (element.className && element.className.baseVal || '') + " " + className);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function replaceClassName(origClass, classToRemove) {
|
|
247
|
+
return origClass.replace(new RegExp("(^|\\s)" + classToRemove + "(?:\\s|$)", 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Removes a CSS class from a given element.
|
|
251
|
+
*
|
|
252
|
+
* @param element the element
|
|
253
|
+
* @param className the CSS class name
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
function removeClass$1(element, className) {
|
|
258
|
+
if (element.classList) {
|
|
259
|
+
element.classList.remove(className);
|
|
260
|
+
} else if (typeof element.className === 'string') {
|
|
261
|
+
element.className = replaceClassName(element.className, className);
|
|
262
|
+
} else {
|
|
263
|
+
element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
var config = {
|
|
268
|
+
disabled: false
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
var TransitionGroupContext = React__default.createContext(null);
|
|
272
|
+
|
|
273
|
+
var forceReflow = function forceReflow(node) {
|
|
274
|
+
return node.scrollTop;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
var UNMOUNTED = 'unmounted';
|
|
278
|
+
var EXITED = 'exited';
|
|
279
|
+
var ENTERING = 'entering';
|
|
280
|
+
var ENTERED = 'entered';
|
|
281
|
+
var EXITING = 'exiting';
|
|
282
|
+
/**
|
|
283
|
+
* The Transition component lets you describe a transition from one component
|
|
284
|
+
* state to another _over time_ with a simple declarative API. Most commonly
|
|
285
|
+
* it's used to animate the mounting and unmounting of a component, but can also
|
|
286
|
+
* be used to describe in-place transition states as well.
|
|
287
|
+
*
|
|
288
|
+
* ---
|
|
289
|
+
*
|
|
290
|
+
* **Note**: `Transition` is a platform-agnostic base component. If you're using
|
|
291
|
+
* transitions in CSS, you'll probably want to use
|
|
292
|
+
* [`CSSTransition`](https://reactcommunity.org/react-transition-group/css-transition)
|
|
293
|
+
* instead. It inherits all the features of `Transition`, but contains
|
|
294
|
+
* additional features necessary to play nice with CSS transitions (hence the
|
|
295
|
+
* name of the component).
|
|
296
|
+
*
|
|
297
|
+
* ---
|
|
298
|
+
*
|
|
299
|
+
* By default the `Transition` component does not alter the behavior of the
|
|
300
|
+
* component it renders, it only tracks "enter" and "exit" states for the
|
|
301
|
+
* components. It's up to you to give meaning and effect to those states. For
|
|
302
|
+
* example we can add styles to a component when it enters or exits:
|
|
303
|
+
*
|
|
304
|
+
* ```jsx
|
|
305
|
+
* import { Transition } from 'react-transition-group';
|
|
306
|
+
*
|
|
307
|
+
* const duration = 300;
|
|
308
|
+
*
|
|
309
|
+
* const defaultStyle = {
|
|
310
|
+
* transition: `opacity ${duration}ms ease-in-out`,
|
|
311
|
+
* opacity: 0,
|
|
312
|
+
* }
|
|
313
|
+
*
|
|
314
|
+
* const transitionStyles = {
|
|
315
|
+
* entering: { opacity: 1 },
|
|
316
|
+
* entered: { opacity: 1 },
|
|
317
|
+
* exiting: { opacity: 0 },
|
|
318
|
+
* exited: { opacity: 0 },
|
|
319
|
+
* };
|
|
320
|
+
*
|
|
321
|
+
* const Fade = ({ in: inProp }) => (
|
|
322
|
+
* <Transition in={inProp} timeout={duration}>
|
|
323
|
+
* {state => (
|
|
324
|
+
* <div style={{
|
|
325
|
+
* ...defaultStyle,
|
|
326
|
+
* ...transitionStyles[state]
|
|
327
|
+
* }}>
|
|
328
|
+
* I'm a fade Transition!
|
|
329
|
+
* </div>
|
|
330
|
+
* )}
|
|
331
|
+
* </Transition>
|
|
332
|
+
* );
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* There are 4 main states a Transition can be in:
|
|
336
|
+
* - `'entering'`
|
|
337
|
+
* - `'entered'`
|
|
338
|
+
* - `'exiting'`
|
|
339
|
+
* - `'exited'`
|
|
340
|
+
*
|
|
341
|
+
* Transition state is toggled via the `in` prop. When `true` the component
|
|
342
|
+
* begins the "Enter" stage. During this stage, the component will shift from
|
|
343
|
+
* its current transition state, to `'entering'` for the duration of the
|
|
344
|
+
* transition and then to the `'entered'` stage once it's complete. Let's take
|
|
345
|
+
* the following example (we'll use the
|
|
346
|
+
* [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):
|
|
347
|
+
*
|
|
348
|
+
* ```jsx
|
|
349
|
+
* function App() {
|
|
350
|
+
* const [inProp, setInProp] = useState(false);
|
|
351
|
+
* return (
|
|
352
|
+
* <div>
|
|
353
|
+
* <Transition in={inProp} timeout={500}>
|
|
354
|
+
* {state => (
|
|
355
|
+
* // ...
|
|
356
|
+
* )}
|
|
357
|
+
* </Transition>
|
|
358
|
+
* <button onClick={() => setInProp(true)}>
|
|
359
|
+
* Click to Enter
|
|
360
|
+
* </button>
|
|
361
|
+
* </div>
|
|
362
|
+
* );
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* When the button is clicked the component will shift to the `'entering'` state
|
|
367
|
+
* and stay there for 500ms (the value of `timeout`) before it finally switches
|
|
368
|
+
* to `'entered'`.
|
|
369
|
+
*
|
|
370
|
+
* When `in` is `false` the same thing happens except the state moves from
|
|
371
|
+
* `'exiting'` to `'exited'`.
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
var Transition = /*#__PURE__*/function (_React$Component) {
|
|
375
|
+
_inheritsLoose(Transition, _React$Component);
|
|
376
|
+
|
|
377
|
+
function Transition(props, context) {
|
|
378
|
+
var _this;
|
|
379
|
+
|
|
380
|
+
_this = _React$Component.call(this, props, context) || this;
|
|
381
|
+
var parentGroup = context; // In the context of a TransitionGroup all enters are really appears
|
|
382
|
+
|
|
383
|
+
var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;
|
|
384
|
+
var initialStatus;
|
|
385
|
+
_this.appearStatus = null;
|
|
386
|
+
|
|
387
|
+
if (props.in) {
|
|
388
|
+
if (appear) {
|
|
389
|
+
initialStatus = EXITED;
|
|
390
|
+
_this.appearStatus = ENTERING;
|
|
391
|
+
} else {
|
|
392
|
+
initialStatus = ENTERED;
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
if (props.unmountOnExit || props.mountOnEnter) {
|
|
396
|
+
initialStatus = UNMOUNTED;
|
|
397
|
+
} else {
|
|
398
|
+
initialStatus = EXITED;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
_this.state = {
|
|
403
|
+
status: initialStatus
|
|
404
|
+
};
|
|
405
|
+
_this.nextCallback = null;
|
|
406
|
+
return _this;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {
|
|
410
|
+
var nextIn = _ref.in;
|
|
411
|
+
|
|
412
|
+
if (nextIn && prevState.status === UNMOUNTED) {
|
|
413
|
+
return {
|
|
414
|
+
status: EXITED
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return null;
|
|
419
|
+
} // getSnapshotBeforeUpdate(prevProps) {
|
|
420
|
+
// let nextStatus = null
|
|
421
|
+
// if (prevProps !== this.props) {
|
|
422
|
+
// const { status } = this.state
|
|
423
|
+
// if (this.props.in) {
|
|
424
|
+
// if (status !== ENTERING && status !== ENTERED) {
|
|
425
|
+
// nextStatus = ENTERING
|
|
426
|
+
// }
|
|
427
|
+
// } else {
|
|
428
|
+
// if (status === ENTERING || status === ENTERED) {
|
|
429
|
+
// nextStatus = EXITING
|
|
430
|
+
// }
|
|
431
|
+
// }
|
|
432
|
+
// }
|
|
433
|
+
// return { nextStatus }
|
|
434
|
+
// }
|
|
435
|
+
;
|
|
436
|
+
|
|
437
|
+
var _proto = Transition.prototype;
|
|
438
|
+
|
|
439
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
440
|
+
this.updateStatus(true, this.appearStatus);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
444
|
+
var nextStatus = null;
|
|
445
|
+
|
|
446
|
+
if (prevProps !== this.props) {
|
|
447
|
+
var status = this.state.status;
|
|
448
|
+
|
|
449
|
+
if (this.props.in) {
|
|
450
|
+
if (status !== ENTERING && status !== ENTERED) {
|
|
451
|
+
nextStatus = ENTERING;
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
if (status === ENTERING || status === ENTERED) {
|
|
455
|
+
nextStatus = EXITING;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
this.updateStatus(false, nextStatus);
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
464
|
+
this.cancelNextCallback();
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
_proto.getTimeouts = function getTimeouts() {
|
|
468
|
+
var timeout = this.props.timeout;
|
|
469
|
+
var exit, enter, appear;
|
|
470
|
+
exit = enter = appear = timeout;
|
|
471
|
+
|
|
472
|
+
if (timeout != null && typeof timeout !== 'number') {
|
|
473
|
+
exit = timeout.exit;
|
|
474
|
+
enter = timeout.enter; // TODO: remove fallback for next major
|
|
475
|
+
|
|
476
|
+
appear = timeout.appear !== undefined ? timeout.appear : enter;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return {
|
|
480
|
+
exit: exit,
|
|
481
|
+
enter: enter,
|
|
482
|
+
appear: appear
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
_proto.updateStatus = function updateStatus(mounting, nextStatus) {
|
|
487
|
+
if (mounting === void 0) {
|
|
488
|
+
mounting = false;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (nextStatus !== null) {
|
|
492
|
+
// nextStatus will always be ENTERING or EXITING.
|
|
493
|
+
this.cancelNextCallback();
|
|
494
|
+
|
|
495
|
+
if (nextStatus === ENTERING) {
|
|
496
|
+
if (this.props.unmountOnExit || this.props.mountOnEnter) {
|
|
497
|
+
var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM__default.findDOMNode(this); // https://github.com/reactjs/react-transition-group/pull/749
|
|
498
|
+
// With unmountOnExit or mountOnEnter, the enter animation should happen at the transition between `exited` and `entering`.
|
|
499
|
+
// To make the animation happen, we have to separate each rendering and avoid being processed as batched.
|
|
500
|
+
|
|
501
|
+
if (node) forceReflow(node);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
this.performEnter(mounting);
|
|
505
|
+
} else {
|
|
506
|
+
this.performExit();
|
|
507
|
+
}
|
|
508
|
+
} else if (this.props.unmountOnExit && this.state.status === EXITED) {
|
|
509
|
+
this.setState({
|
|
510
|
+
status: UNMOUNTED
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
_proto.performEnter = function performEnter(mounting) {
|
|
516
|
+
var _this2 = this;
|
|
517
|
+
|
|
518
|
+
var enter = this.props.enter;
|
|
519
|
+
var appearing = this.context ? this.context.isMounting : mounting;
|
|
520
|
+
|
|
521
|
+
var _ref2 = this.props.nodeRef ? [appearing] : [ReactDOM__default.findDOMNode(this), appearing],
|
|
522
|
+
maybeNode = _ref2[0],
|
|
523
|
+
maybeAppearing = _ref2[1];
|
|
524
|
+
|
|
525
|
+
var timeouts = this.getTimeouts();
|
|
526
|
+
var enterTimeout = appearing ? timeouts.appear : timeouts.enter; // no enter animation skip right to ENTERED
|
|
527
|
+
// if we are mounting and running this it means appear _must_ be set
|
|
528
|
+
|
|
529
|
+
if (!mounting && !enter || config.disabled) {
|
|
530
|
+
this.safeSetState({
|
|
531
|
+
status: ENTERED
|
|
532
|
+
}, function () {
|
|
533
|
+
_this2.props.onEntered(maybeNode);
|
|
534
|
+
});
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
this.props.onEnter(maybeNode, maybeAppearing);
|
|
539
|
+
this.safeSetState({
|
|
540
|
+
status: ENTERING
|
|
541
|
+
}, function () {
|
|
542
|
+
_this2.props.onEntering(maybeNode, maybeAppearing);
|
|
543
|
+
|
|
544
|
+
_this2.onTransitionEnd(enterTimeout, function () {
|
|
545
|
+
_this2.safeSetState({
|
|
546
|
+
status: ENTERED
|
|
547
|
+
}, function () {
|
|
548
|
+
_this2.props.onEntered(maybeNode, maybeAppearing);
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
_proto.performExit = function performExit() {
|
|
555
|
+
var _this3 = this;
|
|
556
|
+
|
|
557
|
+
var exit = this.props.exit;
|
|
558
|
+
var timeouts = this.getTimeouts();
|
|
559
|
+
var maybeNode = this.props.nodeRef ? undefined : ReactDOM__default.findDOMNode(this); // no exit animation skip right to EXITED
|
|
560
|
+
|
|
561
|
+
if (!exit || config.disabled) {
|
|
562
|
+
this.safeSetState({
|
|
563
|
+
status: EXITED
|
|
564
|
+
}, function () {
|
|
565
|
+
_this3.props.onExited(maybeNode);
|
|
566
|
+
});
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
this.props.onExit(maybeNode);
|
|
571
|
+
this.safeSetState({
|
|
572
|
+
status: EXITING
|
|
573
|
+
}, function () {
|
|
574
|
+
_this3.props.onExiting(maybeNode);
|
|
575
|
+
|
|
576
|
+
_this3.onTransitionEnd(timeouts.exit, function () {
|
|
577
|
+
_this3.safeSetState({
|
|
578
|
+
status: EXITED
|
|
579
|
+
}, function () {
|
|
580
|
+
_this3.props.onExited(maybeNode);
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
_proto.cancelNextCallback = function cancelNextCallback() {
|
|
587
|
+
if (this.nextCallback !== null) {
|
|
588
|
+
this.nextCallback.cancel();
|
|
589
|
+
this.nextCallback = null;
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
_proto.safeSetState = function safeSetState(nextState, callback) {
|
|
594
|
+
// This shouldn't be necessary, but there are weird race conditions with
|
|
595
|
+
// setState callbacks and unmounting in testing, so always make sure that
|
|
596
|
+
// we can cancel any pending setState callbacks after we unmount.
|
|
597
|
+
callback = this.setNextCallback(callback);
|
|
598
|
+
this.setState(nextState, callback);
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
_proto.setNextCallback = function setNextCallback(callback) {
|
|
602
|
+
var _this4 = this;
|
|
603
|
+
|
|
604
|
+
var active = true;
|
|
605
|
+
|
|
606
|
+
this.nextCallback = function (event) {
|
|
607
|
+
if (active) {
|
|
608
|
+
active = false;
|
|
609
|
+
_this4.nextCallback = null;
|
|
610
|
+
callback(event);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
this.nextCallback.cancel = function () {
|
|
615
|
+
active = false;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
return this.nextCallback;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
_proto.onTransitionEnd = function onTransitionEnd(timeout, handler) {
|
|
622
|
+
this.setNextCallback(handler);
|
|
623
|
+
var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM__default.findDOMNode(this);
|
|
624
|
+
var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;
|
|
625
|
+
|
|
626
|
+
if (!node || doesNotHaveTimeoutOrListener) {
|
|
627
|
+
setTimeout(this.nextCallback, 0);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (this.props.addEndListener) {
|
|
632
|
+
var _ref3 = this.props.nodeRef ? [this.nextCallback] : [node, this.nextCallback],
|
|
633
|
+
maybeNode = _ref3[0],
|
|
634
|
+
maybeNextCallback = _ref3[1];
|
|
635
|
+
|
|
636
|
+
this.props.addEndListener(maybeNode, maybeNextCallback);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
if (timeout != null) {
|
|
640
|
+
setTimeout(this.nextCallback, timeout);
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
_proto.render = function render() {
|
|
645
|
+
var status = this.state.status;
|
|
646
|
+
|
|
647
|
+
if (status === UNMOUNTED) {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
var _this$props = this.props,
|
|
652
|
+
children = _this$props.children;
|
|
653
|
+
_this$props.in;
|
|
654
|
+
_this$props.mountOnEnter;
|
|
655
|
+
_this$props.unmountOnExit;
|
|
656
|
+
_this$props.appear;
|
|
657
|
+
_this$props.enter;
|
|
658
|
+
_this$props.exit;
|
|
659
|
+
_this$props.timeout;
|
|
660
|
+
_this$props.addEndListener;
|
|
661
|
+
_this$props.onEnter;
|
|
662
|
+
_this$props.onEntering;
|
|
663
|
+
_this$props.onEntered;
|
|
664
|
+
_this$props.onExit;
|
|
665
|
+
_this$props.onExiting;
|
|
666
|
+
_this$props.onExited;
|
|
667
|
+
_this$props.nodeRef;
|
|
668
|
+
var childProps = _objectWithoutPropertiesLoose(_this$props, ["children", "in", "mountOnEnter", "unmountOnExit", "appear", "enter", "exit", "timeout", "addEndListener", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "nodeRef"]);
|
|
669
|
+
|
|
670
|
+
return (
|
|
671
|
+
/*#__PURE__*/
|
|
672
|
+
// allows for nested Transitions
|
|
673
|
+
React__default.createElement(TransitionGroupContext.Provider, {
|
|
674
|
+
value: null
|
|
675
|
+
}, typeof children === 'function' ? children(status, childProps) : React__default.cloneElement(React__default.Children.only(children), childProps))
|
|
676
|
+
);
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
return Transition;
|
|
680
|
+
}(React__default.Component);
|
|
681
|
+
|
|
682
|
+
Transition.contextType = TransitionGroupContext;
|
|
683
|
+
Transition.propTypes = {}; // Name the function so it is clearer in the documentation
|
|
684
|
+
|
|
685
|
+
function noop() {}
|
|
686
|
+
|
|
687
|
+
Transition.defaultProps = {
|
|
688
|
+
in: false,
|
|
689
|
+
mountOnEnter: false,
|
|
690
|
+
unmountOnExit: false,
|
|
691
|
+
appear: false,
|
|
692
|
+
enter: true,
|
|
693
|
+
exit: true,
|
|
694
|
+
onEnter: noop,
|
|
695
|
+
onEntering: noop,
|
|
696
|
+
onEntered: noop,
|
|
697
|
+
onExit: noop,
|
|
698
|
+
onExiting: noop,
|
|
699
|
+
onExited: noop
|
|
700
|
+
};
|
|
701
|
+
Transition.UNMOUNTED = UNMOUNTED;
|
|
702
|
+
Transition.EXITED = EXITED;
|
|
703
|
+
Transition.ENTERING = ENTERING;
|
|
704
|
+
Transition.ENTERED = ENTERED;
|
|
705
|
+
Transition.EXITING = EXITING;
|
|
706
|
+
|
|
707
|
+
var _addClass = function addClass$1(node, classes) {
|
|
708
|
+
return node && classes && classes.split(' ').forEach(function (c) {
|
|
709
|
+
return addClass(node, c);
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
var removeClass = function removeClass(node, classes) {
|
|
714
|
+
return node && classes && classes.split(' ').forEach(function (c) {
|
|
715
|
+
return removeClass$1(node, c);
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
/**
|
|
719
|
+
* A transition component inspired by the excellent
|
|
720
|
+
* [ng-animate](https://docs.angularjs.org/api/ngAnimate) library, you should
|
|
721
|
+
* use it if you're using CSS transitions or animations. It's built upon the
|
|
722
|
+
* [`Transition`](https://reactcommunity.org/react-transition-group/transition)
|
|
723
|
+
* component, so it inherits all of its props.
|
|
724
|
+
*
|
|
725
|
+
* `CSSTransition` applies a pair of class names during the `appear`, `enter`,
|
|
726
|
+
* and `exit` states of the transition. The first class is applied and then a
|
|
727
|
+
* second `*-active` class in order to activate the CSS transition. After the
|
|
728
|
+
* transition, matching `*-done` class names are applied to persist the
|
|
729
|
+
* transition state.
|
|
730
|
+
*
|
|
731
|
+
* ```jsx
|
|
732
|
+
* function App() {
|
|
733
|
+
* const [inProp, setInProp] = useState(false);
|
|
734
|
+
* return (
|
|
735
|
+
* <div>
|
|
736
|
+
* <CSSTransition in={inProp} timeout={200} classNames="my-node">
|
|
737
|
+
* <div>
|
|
738
|
+
* {"I'll receive my-node-* classes"}
|
|
739
|
+
* </div>
|
|
740
|
+
* </CSSTransition>
|
|
741
|
+
* <button type="button" onClick={() => setInProp(true)}>
|
|
742
|
+
* Click to Enter
|
|
743
|
+
* </button>
|
|
744
|
+
* </div>
|
|
745
|
+
* );
|
|
746
|
+
* }
|
|
747
|
+
* ```
|
|
748
|
+
*
|
|
749
|
+
* When the `in` prop is set to `true`, the child component will first receive
|
|
750
|
+
* the class `example-enter`, then the `example-enter-active` will be added in
|
|
751
|
+
* the next tick. `CSSTransition` [forces a
|
|
752
|
+
* reflow](https://github.com/reactjs/react-transition-group/blob/5007303e729a74be66a21c3e2205e4916821524b/src/CSSTransition.js#L208-L215)
|
|
753
|
+
* between before adding the `example-enter-active`. This is an important trick
|
|
754
|
+
* because it allows us to transition between `example-enter` and
|
|
755
|
+
* `example-enter-active` even though they were added immediately one after
|
|
756
|
+
* another. Most notably, this is what makes it possible for us to animate
|
|
757
|
+
* _appearance_.
|
|
758
|
+
*
|
|
759
|
+
* ```css
|
|
760
|
+
* .my-node-enter {
|
|
761
|
+
* opacity: 0;
|
|
762
|
+
* }
|
|
763
|
+
* .my-node-enter-active {
|
|
764
|
+
* opacity: 1;
|
|
765
|
+
* transition: opacity 200ms;
|
|
766
|
+
* }
|
|
767
|
+
* .my-node-exit {
|
|
768
|
+
* opacity: 1;
|
|
769
|
+
* }
|
|
770
|
+
* .my-node-exit-active {
|
|
771
|
+
* opacity: 0;
|
|
772
|
+
* transition: opacity 200ms;
|
|
773
|
+
* }
|
|
774
|
+
* ```
|
|
775
|
+
*
|
|
776
|
+
* `*-active` classes represent which styles you want to animate **to**, so it's
|
|
777
|
+
* important to add `transition` declaration only to them, otherwise transitions
|
|
778
|
+
* might not behave as intended! This might not be obvious when the transitions
|
|
779
|
+
* are symmetrical, i.e. when `*-enter-active` is the same as `*-exit`, like in
|
|
780
|
+
* the example above (minus `transition`), but it becomes apparent in more
|
|
781
|
+
* complex transitions.
|
|
782
|
+
*
|
|
783
|
+
* **Note**: If you're using the
|
|
784
|
+
* [`appear`](http://reactcommunity.org/react-transition-group/transition#Transition-prop-appear)
|
|
785
|
+
* prop, make sure to define styles for `.appear-*` classes as well.
|
|
786
|
+
*/
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
var CSSTransition = /*#__PURE__*/function (_React$Component) {
|
|
790
|
+
_inheritsLoose(CSSTransition, _React$Component);
|
|
791
|
+
|
|
792
|
+
function CSSTransition() {
|
|
793
|
+
var _this;
|
|
794
|
+
|
|
795
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
796
|
+
args[_key] = arguments[_key];
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
800
|
+
_this.appliedClasses = {
|
|
801
|
+
appear: {},
|
|
802
|
+
enter: {},
|
|
803
|
+
exit: {}
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
_this.onEnter = function (maybeNode, maybeAppearing) {
|
|
807
|
+
var _this$resolveArgument = _this.resolveArguments(maybeNode, maybeAppearing),
|
|
808
|
+
node = _this$resolveArgument[0],
|
|
809
|
+
appearing = _this$resolveArgument[1];
|
|
810
|
+
|
|
811
|
+
_this.removeClasses(node, 'exit');
|
|
812
|
+
|
|
813
|
+
_this.addClass(node, appearing ? 'appear' : 'enter', 'base');
|
|
814
|
+
|
|
815
|
+
if (_this.props.onEnter) {
|
|
816
|
+
_this.props.onEnter(maybeNode, maybeAppearing);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
_this.onEntering = function (maybeNode, maybeAppearing) {
|
|
821
|
+
var _this$resolveArgument2 = _this.resolveArguments(maybeNode, maybeAppearing),
|
|
822
|
+
node = _this$resolveArgument2[0],
|
|
823
|
+
appearing = _this$resolveArgument2[1];
|
|
824
|
+
|
|
825
|
+
var type = appearing ? 'appear' : 'enter';
|
|
826
|
+
|
|
827
|
+
_this.addClass(node, type, 'active');
|
|
828
|
+
|
|
829
|
+
if (_this.props.onEntering) {
|
|
830
|
+
_this.props.onEntering(maybeNode, maybeAppearing);
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
_this.onEntered = function (maybeNode, maybeAppearing) {
|
|
835
|
+
var _this$resolveArgument3 = _this.resolveArguments(maybeNode, maybeAppearing),
|
|
836
|
+
node = _this$resolveArgument3[0],
|
|
837
|
+
appearing = _this$resolveArgument3[1];
|
|
838
|
+
|
|
839
|
+
var type = appearing ? 'appear' : 'enter';
|
|
840
|
+
|
|
841
|
+
_this.removeClasses(node, type);
|
|
842
|
+
|
|
843
|
+
_this.addClass(node, type, 'done');
|
|
844
|
+
|
|
845
|
+
if (_this.props.onEntered) {
|
|
846
|
+
_this.props.onEntered(maybeNode, maybeAppearing);
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
_this.onExit = function (maybeNode) {
|
|
851
|
+
var _this$resolveArgument4 = _this.resolveArguments(maybeNode),
|
|
852
|
+
node = _this$resolveArgument4[0];
|
|
853
|
+
|
|
854
|
+
_this.removeClasses(node, 'appear');
|
|
855
|
+
|
|
856
|
+
_this.removeClasses(node, 'enter');
|
|
857
|
+
|
|
858
|
+
_this.addClass(node, 'exit', 'base');
|
|
859
|
+
|
|
860
|
+
if (_this.props.onExit) {
|
|
861
|
+
_this.props.onExit(maybeNode);
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
_this.onExiting = function (maybeNode) {
|
|
866
|
+
var _this$resolveArgument5 = _this.resolveArguments(maybeNode),
|
|
867
|
+
node = _this$resolveArgument5[0];
|
|
868
|
+
|
|
869
|
+
_this.addClass(node, 'exit', 'active');
|
|
870
|
+
|
|
871
|
+
if (_this.props.onExiting) {
|
|
872
|
+
_this.props.onExiting(maybeNode);
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
_this.onExited = function (maybeNode) {
|
|
877
|
+
var _this$resolveArgument6 = _this.resolveArguments(maybeNode),
|
|
878
|
+
node = _this$resolveArgument6[0];
|
|
879
|
+
|
|
880
|
+
_this.removeClasses(node, 'exit');
|
|
881
|
+
|
|
882
|
+
_this.addClass(node, 'exit', 'done');
|
|
883
|
+
|
|
884
|
+
if (_this.props.onExited) {
|
|
885
|
+
_this.props.onExited(maybeNode);
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
_this.resolveArguments = function (maybeNode, maybeAppearing) {
|
|
890
|
+
return _this.props.nodeRef ? [_this.props.nodeRef.current, maybeNode] // here `maybeNode` is actually `appearing`
|
|
891
|
+
: [maybeNode, maybeAppearing];
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
_this.getClassNames = function (type) {
|
|
895
|
+
var classNames = _this.props.classNames;
|
|
896
|
+
var isStringClassNames = typeof classNames === 'string';
|
|
897
|
+
var prefix = isStringClassNames && classNames ? classNames + "-" : '';
|
|
898
|
+
var baseClassName = isStringClassNames ? "" + prefix + type : classNames[type];
|
|
899
|
+
var activeClassName = isStringClassNames ? baseClassName + "-active" : classNames[type + "Active"];
|
|
900
|
+
var doneClassName = isStringClassNames ? baseClassName + "-done" : classNames[type + "Done"];
|
|
901
|
+
return {
|
|
902
|
+
baseClassName: baseClassName,
|
|
903
|
+
activeClassName: activeClassName,
|
|
904
|
+
doneClassName: doneClassName
|
|
905
|
+
};
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
return _this;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
var _proto = CSSTransition.prototype;
|
|
912
|
+
|
|
913
|
+
_proto.addClass = function addClass(node, type, phase) {
|
|
914
|
+
var className = this.getClassNames(type)[phase + "ClassName"];
|
|
915
|
+
|
|
916
|
+
var _this$getClassNames = this.getClassNames('enter'),
|
|
917
|
+
doneClassName = _this$getClassNames.doneClassName;
|
|
918
|
+
|
|
919
|
+
if (type === 'appear' && phase === 'done' && doneClassName) {
|
|
920
|
+
className += " " + doneClassName;
|
|
921
|
+
} // This is to force a repaint,
|
|
922
|
+
// which is necessary in order to transition styles when adding a class name.
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
if (phase === 'active') {
|
|
926
|
+
if (node) forceReflow(node);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
if (className) {
|
|
930
|
+
this.appliedClasses[type][phase] = className;
|
|
931
|
+
|
|
932
|
+
_addClass(node, className);
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
_proto.removeClasses = function removeClasses(node, type) {
|
|
937
|
+
var _this$appliedClasses$ = this.appliedClasses[type],
|
|
938
|
+
baseClassName = _this$appliedClasses$.base,
|
|
939
|
+
activeClassName = _this$appliedClasses$.active,
|
|
940
|
+
doneClassName = _this$appliedClasses$.done;
|
|
941
|
+
this.appliedClasses[type] = {};
|
|
942
|
+
|
|
943
|
+
if (baseClassName) {
|
|
944
|
+
removeClass(node, baseClassName);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
if (activeClassName) {
|
|
948
|
+
removeClass(node, activeClassName);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (doneClassName) {
|
|
952
|
+
removeClass(node, doneClassName);
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
_proto.render = function render() {
|
|
957
|
+
var _this$props = this.props;
|
|
958
|
+
_this$props.classNames;
|
|
959
|
+
var props = _objectWithoutPropertiesLoose(_this$props, ["classNames"]);
|
|
960
|
+
|
|
961
|
+
return /*#__PURE__*/React__default.createElement(Transition, _extends({}, props, {
|
|
962
|
+
onEnter: this.onEnter,
|
|
963
|
+
onEntered: this.onEntered,
|
|
964
|
+
onEntering: this.onEntering,
|
|
965
|
+
onExit: this.onExit,
|
|
966
|
+
onExiting: this.onExiting,
|
|
967
|
+
onExited: this.onExited
|
|
968
|
+
}));
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
return CSSTransition;
|
|
972
|
+
}(React__default.Component);
|
|
973
|
+
|
|
974
|
+
CSSTransition.defaultProps = {
|
|
975
|
+
classNames: ''
|
|
976
|
+
};
|
|
977
|
+
CSSTransition.propTypes = {};
|
|
978
|
+
|
|
979
|
+
function _assertThisInitialized(self) {
|
|
980
|
+
if (self === void 0) {
|
|
981
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
982
|
+
}
|
|
983
|
+
return self;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Given `this.props.children`, return an object mapping key to child.
|
|
988
|
+
*
|
|
989
|
+
* @param {*} children `this.props.children`
|
|
990
|
+
* @return {object} Mapping of key to child
|
|
991
|
+
*/
|
|
992
|
+
|
|
993
|
+
function getChildMapping(children, mapFn) {
|
|
994
|
+
var mapper = function mapper(child) {
|
|
995
|
+
return mapFn && isValidElement(child) ? mapFn(child) : child;
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
var result = Object.create(null);
|
|
999
|
+
if (children) Children.map(children, function (c) {
|
|
1000
|
+
return c;
|
|
1001
|
+
}).forEach(function (child) {
|
|
1002
|
+
// run the map function here instead so that the key is the computed one
|
|
1003
|
+
result[child.key] = mapper(child);
|
|
1004
|
+
});
|
|
1005
|
+
return result;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* When you're adding or removing children some may be added or removed in the
|
|
1009
|
+
* same render pass. We want to show *both* since we want to simultaneously
|
|
1010
|
+
* animate elements in and out. This function takes a previous set of keys
|
|
1011
|
+
* and a new set of keys and merges them with its best guess of the correct
|
|
1012
|
+
* ordering. In the future we may expose some of the utilities in
|
|
1013
|
+
* ReactMultiChild to make this easy, but for now React itself does not
|
|
1014
|
+
* directly have this concept of the union of prevChildren and nextChildren
|
|
1015
|
+
* so we implement it here.
|
|
1016
|
+
*
|
|
1017
|
+
* @param {object} prev prev children as returned from
|
|
1018
|
+
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
1019
|
+
* @param {object} next next children as returned from
|
|
1020
|
+
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
1021
|
+
* @return {object} a key set that contains all keys in `prev` and all keys
|
|
1022
|
+
* in `next` in a reasonable order.
|
|
1023
|
+
*/
|
|
1024
|
+
|
|
1025
|
+
function mergeChildMappings(prev, next) {
|
|
1026
|
+
prev = prev || {};
|
|
1027
|
+
next = next || {};
|
|
1028
|
+
|
|
1029
|
+
function getValueForKey(key) {
|
|
1030
|
+
return key in next ? next[key] : prev[key];
|
|
1031
|
+
} // For each key of `next`, the list of keys to insert before that key in
|
|
1032
|
+
// the combined list
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
var nextKeysPending = Object.create(null);
|
|
1036
|
+
var pendingKeys = [];
|
|
1037
|
+
|
|
1038
|
+
for (var prevKey in prev) {
|
|
1039
|
+
if (prevKey in next) {
|
|
1040
|
+
if (pendingKeys.length) {
|
|
1041
|
+
nextKeysPending[prevKey] = pendingKeys;
|
|
1042
|
+
pendingKeys = [];
|
|
1043
|
+
}
|
|
1044
|
+
} else {
|
|
1045
|
+
pendingKeys.push(prevKey);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
var i;
|
|
1050
|
+
var childMapping = {};
|
|
1051
|
+
|
|
1052
|
+
for (var nextKey in next) {
|
|
1053
|
+
if (nextKeysPending[nextKey]) {
|
|
1054
|
+
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
|
|
1055
|
+
var pendingNextKey = nextKeysPending[nextKey][i];
|
|
1056
|
+
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
childMapping[nextKey] = getValueForKey(nextKey);
|
|
1061
|
+
} // Finally, add the keys which didn't appear before any key in `next`
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
for (i = 0; i < pendingKeys.length; i++) {
|
|
1065
|
+
childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
return childMapping;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
function getProp(child, prop, props) {
|
|
1072
|
+
return props[prop] != null ? props[prop] : child.props[prop];
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
function getInitialChildMapping(props, onExited) {
|
|
1076
|
+
return getChildMapping(props.children, function (child) {
|
|
1077
|
+
return cloneElement(child, {
|
|
1078
|
+
onExited: onExited.bind(null, child),
|
|
1079
|
+
in: true,
|
|
1080
|
+
appear: getProp(child, 'appear', props),
|
|
1081
|
+
enter: getProp(child, 'enter', props),
|
|
1082
|
+
exit: getProp(child, 'exit', props)
|
|
1083
|
+
});
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
function getNextChildMapping(nextProps, prevChildMapping, onExited) {
|
|
1087
|
+
var nextChildMapping = getChildMapping(nextProps.children);
|
|
1088
|
+
var children = mergeChildMappings(prevChildMapping, nextChildMapping);
|
|
1089
|
+
Object.keys(children).forEach(function (key) {
|
|
1090
|
+
var child = children[key];
|
|
1091
|
+
if (!isValidElement(child)) return;
|
|
1092
|
+
var hasPrev = (key in prevChildMapping);
|
|
1093
|
+
var hasNext = (key in nextChildMapping);
|
|
1094
|
+
var prevChild = prevChildMapping[key];
|
|
1095
|
+
var isLeaving = isValidElement(prevChild) && !prevChild.props.in; // item is new (entering)
|
|
1096
|
+
|
|
1097
|
+
if (hasNext && (!hasPrev || isLeaving)) {
|
|
1098
|
+
// console.log('entering', key)
|
|
1099
|
+
children[key] = cloneElement(child, {
|
|
1100
|
+
onExited: onExited.bind(null, child),
|
|
1101
|
+
in: true,
|
|
1102
|
+
exit: getProp(child, 'exit', nextProps),
|
|
1103
|
+
enter: getProp(child, 'enter', nextProps)
|
|
1104
|
+
});
|
|
1105
|
+
} else if (!hasNext && hasPrev && !isLeaving) {
|
|
1106
|
+
// item is old (exiting)
|
|
1107
|
+
// console.log('leaving', key)
|
|
1108
|
+
children[key] = cloneElement(child, {
|
|
1109
|
+
in: false
|
|
1110
|
+
});
|
|
1111
|
+
} else if (hasNext && hasPrev && isValidElement(prevChild)) {
|
|
1112
|
+
// item hasn't changed transition states
|
|
1113
|
+
// copy over the last transition props;
|
|
1114
|
+
// console.log('unchanged', key)
|
|
1115
|
+
children[key] = cloneElement(child, {
|
|
1116
|
+
onExited: onExited.bind(null, child),
|
|
1117
|
+
in: prevChild.props.in,
|
|
1118
|
+
exit: getProp(child, 'exit', nextProps),
|
|
1119
|
+
enter: getProp(child, 'enter', nextProps)
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
return children;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
var values = Object.values || function (obj) {
|
|
1127
|
+
return Object.keys(obj).map(function (k) {
|
|
1128
|
+
return obj[k];
|
|
1129
|
+
});
|
|
1130
|
+
};
|
|
1131
|
+
|
|
1132
|
+
var defaultProps = {
|
|
1133
|
+
component: 'div',
|
|
1134
|
+
childFactory: function childFactory(child) {
|
|
1135
|
+
return child;
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
/**
|
|
1139
|
+
* The `<TransitionGroup>` component manages a set of transition components
|
|
1140
|
+
* (`<Transition>` and `<CSSTransition>`) in a list. Like with the transition
|
|
1141
|
+
* components, `<TransitionGroup>` is a state machine for managing the mounting
|
|
1142
|
+
* and unmounting of components over time.
|
|
1143
|
+
*
|
|
1144
|
+
* Consider the example below. As items are removed or added to the TodoList the
|
|
1145
|
+
* `in` prop is toggled automatically by the `<TransitionGroup>`.
|
|
1146
|
+
*
|
|
1147
|
+
* Note that `<TransitionGroup>` does not define any animation behavior!
|
|
1148
|
+
* Exactly _how_ a list item animates is up to the individual transition
|
|
1149
|
+
* component. This means you can mix and match animations across different list
|
|
1150
|
+
* items.
|
|
1151
|
+
*/
|
|
1152
|
+
|
|
1153
|
+
var TransitionGroup = /*#__PURE__*/function (_React$Component) {
|
|
1154
|
+
_inheritsLoose(TransitionGroup, _React$Component);
|
|
1155
|
+
|
|
1156
|
+
function TransitionGroup(props, context) {
|
|
1157
|
+
var _this;
|
|
1158
|
+
|
|
1159
|
+
_this = _React$Component.call(this, props, context) || this;
|
|
1160
|
+
|
|
1161
|
+
var handleExited = _this.handleExited.bind(_assertThisInitialized(_this)); // Initial children should all be entering, dependent on appear
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
_this.state = {
|
|
1165
|
+
contextValue: {
|
|
1166
|
+
isMounting: true
|
|
1167
|
+
},
|
|
1168
|
+
handleExited: handleExited,
|
|
1169
|
+
firstRender: true
|
|
1170
|
+
};
|
|
1171
|
+
return _this;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
var _proto = TransitionGroup.prototype;
|
|
1175
|
+
|
|
1176
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
1177
|
+
this.mounted = true;
|
|
1178
|
+
this.setState({
|
|
1179
|
+
contextValue: {
|
|
1180
|
+
isMounting: false
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
1186
|
+
this.mounted = false;
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
TransitionGroup.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, _ref) {
|
|
1190
|
+
var prevChildMapping = _ref.children,
|
|
1191
|
+
handleExited = _ref.handleExited,
|
|
1192
|
+
firstRender = _ref.firstRender;
|
|
1193
|
+
return {
|
|
1194
|
+
children: firstRender ? getInitialChildMapping(nextProps, handleExited) : getNextChildMapping(nextProps, prevChildMapping, handleExited),
|
|
1195
|
+
firstRender: false
|
|
1196
|
+
};
|
|
1197
|
+
} // node is `undefined` when user provided `nodeRef` prop
|
|
1198
|
+
;
|
|
1199
|
+
|
|
1200
|
+
_proto.handleExited = function handleExited(child, node) {
|
|
1201
|
+
var currentChildMapping = getChildMapping(this.props.children);
|
|
1202
|
+
if (child.key in currentChildMapping) return;
|
|
1203
|
+
|
|
1204
|
+
if (child.props.onExited) {
|
|
1205
|
+
child.props.onExited(node);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
if (this.mounted) {
|
|
1209
|
+
this.setState(function (state) {
|
|
1210
|
+
var children = _extends({}, state.children);
|
|
1211
|
+
|
|
1212
|
+
delete children[child.key];
|
|
1213
|
+
return {
|
|
1214
|
+
children: children
|
|
1215
|
+
};
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
_proto.render = function render() {
|
|
1221
|
+
var _this$props = this.props,
|
|
1222
|
+
Component = _this$props.component,
|
|
1223
|
+
childFactory = _this$props.childFactory,
|
|
1224
|
+
props = _objectWithoutPropertiesLoose(_this$props, ["component", "childFactory"]);
|
|
1225
|
+
|
|
1226
|
+
var contextValue = this.state.contextValue;
|
|
1227
|
+
var children = values(this.state.children).map(childFactory);
|
|
1228
|
+
delete props.appear;
|
|
1229
|
+
delete props.enter;
|
|
1230
|
+
delete props.exit;
|
|
1231
|
+
|
|
1232
|
+
if (Component === null) {
|
|
1233
|
+
return /*#__PURE__*/React__default.createElement(TransitionGroupContext.Provider, {
|
|
1234
|
+
value: contextValue
|
|
1235
|
+
}, children);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
return /*#__PURE__*/React__default.createElement(TransitionGroupContext.Provider, {
|
|
1239
|
+
value: contextValue
|
|
1240
|
+
}, /*#__PURE__*/React__default.createElement(Component, props, children));
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
return TransitionGroup;
|
|
1244
|
+
}(React__default.Component);
|
|
1245
|
+
|
|
1246
|
+
TransitionGroup.propTypes = {};
|
|
1247
|
+
TransitionGroup.defaultProps = defaultProps;
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* The `<ReplaceTransition>` component is a specialized `Transition` component
|
|
1251
|
+
* that animates between two children.
|
|
1252
|
+
*
|
|
1253
|
+
* ```jsx
|
|
1254
|
+
* <ReplaceTransition in>
|
|
1255
|
+
* <Fade><div>I appear first</div></Fade>
|
|
1256
|
+
* <Fade><div>I replace the above</div></Fade>
|
|
1257
|
+
* </ReplaceTransition>
|
|
1258
|
+
* ```
|
|
1259
|
+
*/
|
|
1260
|
+
|
|
1261
|
+
var ReplaceTransition = /*#__PURE__*/function (_React$Component) {
|
|
1262
|
+
_inheritsLoose(ReplaceTransition, _React$Component);
|
|
1263
|
+
|
|
1264
|
+
function ReplaceTransition() {
|
|
1265
|
+
var _this;
|
|
1266
|
+
|
|
1267
|
+
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1268
|
+
_args[_key] = arguments[_key];
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
|
|
1272
|
+
|
|
1273
|
+
_this.handleEnter = function () {
|
|
1274
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1275
|
+
args[_key2] = arguments[_key2];
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
return _this.handleLifecycle('onEnter', 0, args);
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
_this.handleEntering = function () {
|
|
1282
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1283
|
+
args[_key3] = arguments[_key3];
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
return _this.handleLifecycle('onEntering', 0, args);
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
_this.handleEntered = function () {
|
|
1290
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
1291
|
+
args[_key4] = arguments[_key4];
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
return _this.handleLifecycle('onEntered', 0, args);
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
_this.handleExit = function () {
|
|
1298
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
1299
|
+
args[_key5] = arguments[_key5];
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
return _this.handleLifecycle('onExit', 1, args);
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
_this.handleExiting = function () {
|
|
1306
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
1307
|
+
args[_key6] = arguments[_key6];
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
return _this.handleLifecycle('onExiting', 1, args);
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
_this.handleExited = function () {
|
|
1314
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
1315
|
+
args[_key7] = arguments[_key7];
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
return _this.handleLifecycle('onExited', 1, args);
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
return _this;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
var _proto = ReplaceTransition.prototype;
|
|
1325
|
+
|
|
1326
|
+
_proto.handleLifecycle = function handleLifecycle(handler, idx, originalArgs) {
|
|
1327
|
+
var _child$props;
|
|
1328
|
+
|
|
1329
|
+
var children = this.props.children;
|
|
1330
|
+
var child = React__default.Children.toArray(children)[idx];
|
|
1331
|
+
if (child.props[handler]) (_child$props = child.props)[handler].apply(_child$props, originalArgs);
|
|
1332
|
+
|
|
1333
|
+
if (this.props[handler]) {
|
|
1334
|
+
var maybeNode = child.props.nodeRef ? undefined : ReactDOM__default.findDOMNode(this);
|
|
1335
|
+
this.props[handler](maybeNode);
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
_proto.render = function render() {
|
|
1340
|
+
var _this$props = this.props,
|
|
1341
|
+
children = _this$props.children,
|
|
1342
|
+
inProp = _this$props.in,
|
|
1343
|
+
props = _objectWithoutPropertiesLoose(_this$props, ["children", "in"]);
|
|
1344
|
+
|
|
1345
|
+
var _React$Children$toArr = React__default.Children.toArray(children),
|
|
1346
|
+
first = _React$Children$toArr[0],
|
|
1347
|
+
second = _React$Children$toArr[1];
|
|
1348
|
+
|
|
1349
|
+
delete props.onEnter;
|
|
1350
|
+
delete props.onEntering;
|
|
1351
|
+
delete props.onEntered;
|
|
1352
|
+
delete props.onExit;
|
|
1353
|
+
delete props.onExiting;
|
|
1354
|
+
delete props.onExited;
|
|
1355
|
+
return /*#__PURE__*/React__default.createElement(TransitionGroup, props, inProp ? React__default.cloneElement(first, {
|
|
1356
|
+
key: 'first',
|
|
1357
|
+
onEnter: this.handleEnter,
|
|
1358
|
+
onEntering: this.handleEntering,
|
|
1359
|
+
onEntered: this.handleEntered
|
|
1360
|
+
}) : React__default.cloneElement(second, {
|
|
1361
|
+
key: 'second',
|
|
1362
|
+
onEnter: this.handleExit,
|
|
1363
|
+
onEntering: this.handleExiting,
|
|
1364
|
+
onEntered: this.handleExited
|
|
1365
|
+
}));
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
return ReplaceTransition;
|
|
1369
|
+
}(React__default.Component);
|
|
1370
|
+
|
|
1371
|
+
ReplaceTransition.propTypes = {};
|
|
1372
|
+
|
|
1373
|
+
var _leaveRenders, _enterRenders;
|
|
1374
|
+
|
|
1375
|
+
function areChildrenDifferent(oldChildren, newChildren) {
|
|
1376
|
+
if (oldChildren === newChildren) return false;
|
|
1377
|
+
|
|
1378
|
+
if (React__default.isValidElement(oldChildren) && React__default.isValidElement(newChildren) && oldChildren.key != null && oldChildren.key === newChildren.key) {
|
|
1379
|
+
return false;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
return true;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Enum of modes for SwitchTransition component
|
|
1386
|
+
* @enum { string }
|
|
1387
|
+
*/
|
|
1388
|
+
|
|
1389
|
+
|
|
1390
|
+
var modes = {
|
|
1391
|
+
out: 'out-in',
|
|
1392
|
+
in: 'in-out'
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1395
|
+
var callHook = function callHook(element, name, cb) {
|
|
1396
|
+
return function () {
|
|
1397
|
+
var _element$props;
|
|
1398
|
+
|
|
1399
|
+
element.props[name] && (_element$props = element.props)[name].apply(_element$props, arguments);
|
|
1400
|
+
cb();
|
|
1401
|
+
};
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
var leaveRenders = (_leaveRenders = {}, _leaveRenders[modes.out] = function (_ref) {
|
|
1405
|
+
var current = _ref.current,
|
|
1406
|
+
changeState = _ref.changeState;
|
|
1407
|
+
return React__default.cloneElement(current, {
|
|
1408
|
+
in: false,
|
|
1409
|
+
onExited: callHook(current, 'onExited', function () {
|
|
1410
|
+
changeState(ENTERING, null);
|
|
1411
|
+
})
|
|
1412
|
+
});
|
|
1413
|
+
}, _leaveRenders[modes.in] = function (_ref2) {
|
|
1414
|
+
var current = _ref2.current,
|
|
1415
|
+
changeState = _ref2.changeState,
|
|
1416
|
+
children = _ref2.children;
|
|
1417
|
+
return [current, React__default.cloneElement(children, {
|
|
1418
|
+
in: true,
|
|
1419
|
+
onEntered: callHook(children, 'onEntered', function () {
|
|
1420
|
+
changeState(ENTERING);
|
|
1421
|
+
})
|
|
1422
|
+
})];
|
|
1423
|
+
}, _leaveRenders);
|
|
1424
|
+
var enterRenders = (_enterRenders = {}, _enterRenders[modes.out] = function (_ref3) {
|
|
1425
|
+
var children = _ref3.children,
|
|
1426
|
+
changeState = _ref3.changeState;
|
|
1427
|
+
return React__default.cloneElement(children, {
|
|
1428
|
+
in: true,
|
|
1429
|
+
onEntered: callHook(children, 'onEntered', function () {
|
|
1430
|
+
changeState(ENTERED, React__default.cloneElement(children, {
|
|
1431
|
+
in: true
|
|
1432
|
+
}));
|
|
1433
|
+
})
|
|
1434
|
+
});
|
|
1435
|
+
}, _enterRenders[modes.in] = function (_ref4) {
|
|
1436
|
+
var current = _ref4.current,
|
|
1437
|
+
children = _ref4.children,
|
|
1438
|
+
changeState = _ref4.changeState;
|
|
1439
|
+
return [React__default.cloneElement(current, {
|
|
1440
|
+
in: false,
|
|
1441
|
+
onExited: callHook(current, 'onExited', function () {
|
|
1442
|
+
changeState(ENTERED, React__default.cloneElement(children, {
|
|
1443
|
+
in: true
|
|
1444
|
+
}));
|
|
1445
|
+
})
|
|
1446
|
+
}), React__default.cloneElement(children, {
|
|
1447
|
+
in: true
|
|
1448
|
+
})];
|
|
1449
|
+
}, _enterRenders);
|
|
1450
|
+
/**
|
|
1451
|
+
* A transition component inspired by the [vue transition modes](https://vuejs.org/v2/guide/transitions.html#Transition-Modes).
|
|
1452
|
+
* You can use it when you want to control the render between state transitions.
|
|
1453
|
+
* Based on the selected mode and the child's key which is the `Transition` or `CSSTransition` component, the `SwitchTransition` makes a consistent transition between them.
|
|
1454
|
+
*
|
|
1455
|
+
* If the `out-in` mode is selected, the `SwitchTransition` waits until the old child leaves and then inserts a new child.
|
|
1456
|
+
* If the `in-out` mode is selected, the `SwitchTransition` inserts a new child first, waits for the new child to enter and then removes the old child.
|
|
1457
|
+
*
|
|
1458
|
+
* **Note**: If you want the animation to happen simultaneously
|
|
1459
|
+
* (that is, to have the old child removed and a new child inserted **at the same time**),
|
|
1460
|
+
* you should use
|
|
1461
|
+
* [`TransitionGroup`](https://reactcommunity.org/react-transition-group/transition-group)
|
|
1462
|
+
* instead.
|
|
1463
|
+
*
|
|
1464
|
+
* ```jsx
|
|
1465
|
+
* function App() {
|
|
1466
|
+
* const [state, setState] = useState(false);
|
|
1467
|
+
* return (
|
|
1468
|
+
* <SwitchTransition>
|
|
1469
|
+
* <CSSTransition
|
|
1470
|
+
* key={state ? "Goodbye, world!" : "Hello, world!"}
|
|
1471
|
+
* addEndListener={(node, done) => node.addEventListener("transitionend", done, false)}
|
|
1472
|
+
* classNames='fade'
|
|
1473
|
+
* >
|
|
1474
|
+
* <button onClick={() => setState(state => !state)}>
|
|
1475
|
+
* {state ? "Goodbye, world!" : "Hello, world!"}
|
|
1476
|
+
* </button>
|
|
1477
|
+
* </CSSTransition>
|
|
1478
|
+
* </SwitchTransition>
|
|
1479
|
+
* );
|
|
1480
|
+
* }
|
|
1481
|
+
* ```
|
|
1482
|
+
*
|
|
1483
|
+
* ```css
|
|
1484
|
+
* .fade-enter{
|
|
1485
|
+
* opacity: 0;
|
|
1486
|
+
* }
|
|
1487
|
+
* .fade-exit{
|
|
1488
|
+
* opacity: 1;
|
|
1489
|
+
* }
|
|
1490
|
+
* .fade-enter-active{
|
|
1491
|
+
* opacity: 1;
|
|
1492
|
+
* }
|
|
1493
|
+
* .fade-exit-active{
|
|
1494
|
+
* opacity: 0;
|
|
1495
|
+
* }
|
|
1496
|
+
* .fade-enter-active,
|
|
1497
|
+
* .fade-exit-active{
|
|
1498
|
+
* transition: opacity 500ms;
|
|
1499
|
+
* }
|
|
1500
|
+
* ```
|
|
1501
|
+
*/
|
|
1502
|
+
|
|
1503
|
+
var SwitchTransition = /*#__PURE__*/function (_React$Component) {
|
|
1504
|
+
_inheritsLoose(SwitchTransition, _React$Component);
|
|
1505
|
+
|
|
1506
|
+
function SwitchTransition() {
|
|
1507
|
+
var _this;
|
|
1508
|
+
|
|
1509
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1510
|
+
args[_key] = arguments[_key];
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
1514
|
+
_this.state = {
|
|
1515
|
+
status: ENTERED,
|
|
1516
|
+
current: null
|
|
1517
|
+
};
|
|
1518
|
+
_this.appeared = false;
|
|
1519
|
+
|
|
1520
|
+
_this.changeState = function (status, current) {
|
|
1521
|
+
if (current === void 0) {
|
|
1522
|
+
current = _this.state.current;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
_this.setState({
|
|
1526
|
+
status: status,
|
|
1527
|
+
current: current
|
|
1528
|
+
});
|
|
1529
|
+
};
|
|
1530
|
+
|
|
1531
|
+
return _this;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
var _proto = SwitchTransition.prototype;
|
|
1535
|
+
|
|
1536
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
1537
|
+
this.appeared = true;
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
SwitchTransition.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
|
1541
|
+
if (props.children == null) {
|
|
1542
|
+
return {
|
|
1543
|
+
current: null
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
if (state.status === ENTERING && props.mode === modes.in) {
|
|
1548
|
+
return {
|
|
1549
|
+
status: ENTERING
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
if (state.current && areChildrenDifferent(state.current, props.children)) {
|
|
1554
|
+
return {
|
|
1555
|
+
status: EXITING
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
return {
|
|
1560
|
+
current: React__default.cloneElement(props.children, {
|
|
1561
|
+
in: true
|
|
1562
|
+
})
|
|
1563
|
+
};
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
_proto.render = function render() {
|
|
1567
|
+
var _this$props = this.props,
|
|
1568
|
+
children = _this$props.children,
|
|
1569
|
+
mode = _this$props.mode,
|
|
1570
|
+
_this$state = this.state,
|
|
1571
|
+
status = _this$state.status,
|
|
1572
|
+
current = _this$state.current;
|
|
1573
|
+
var data = {
|
|
1574
|
+
children: children,
|
|
1575
|
+
current: current,
|
|
1576
|
+
changeState: this.changeState,
|
|
1577
|
+
status: status
|
|
1578
|
+
};
|
|
1579
|
+
var component;
|
|
1580
|
+
|
|
1581
|
+
switch (status) {
|
|
1582
|
+
case ENTERING:
|
|
1583
|
+
component = enterRenders[mode](data);
|
|
1584
|
+
break;
|
|
1585
|
+
|
|
1586
|
+
case EXITING:
|
|
1587
|
+
component = leaveRenders[mode](data);
|
|
1588
|
+
break;
|
|
1589
|
+
|
|
1590
|
+
case ENTERED:
|
|
1591
|
+
component = current;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
return /*#__PURE__*/React__default.createElement(TransitionGroupContext.Provider, {
|
|
1595
|
+
value: {
|
|
1596
|
+
isMounting: !this.appeared
|
|
1597
|
+
}
|
|
1598
|
+
}, component);
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
return SwitchTransition;
|
|
1602
|
+
}(React__default.Component);
|
|
1603
|
+
|
|
1604
|
+
SwitchTransition.propTypes = {};
|
|
1605
|
+
SwitchTransition.defaultProps = {
|
|
1606
|
+
mode: modes.out
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
var useEnhancedEffect$2 = typeof window === 'undefined' ? React$2.useEffect : React$2.useLayoutEffect;
|
|
1610
|
+
/**
|
|
1611
|
+
* @ignore - internal component.
|
|
1612
|
+
*/
|
|
1613
|
+
|
|
1614
|
+
function Ripple(props) {
|
|
1615
|
+
var classes = props.classes,
|
|
1616
|
+
_props$pulsate = props.pulsate,
|
|
1617
|
+
pulsate = _props$pulsate === void 0 ? false : _props$pulsate,
|
|
1618
|
+
rippleX = props.rippleX,
|
|
1619
|
+
rippleY = props.rippleY,
|
|
1620
|
+
rippleSize = props.rippleSize,
|
|
1621
|
+
inProp = props.in,
|
|
1622
|
+
_props$onExited = props.onExited,
|
|
1623
|
+
onExited = _props$onExited === void 0 ? function () {} : _props$onExited,
|
|
1624
|
+
timeout = props.timeout;
|
|
1625
|
+
|
|
1626
|
+
var _React$useState = React$2.useState(false),
|
|
1627
|
+
leaving = _React$useState[0],
|
|
1628
|
+
setLeaving = _React$useState[1];
|
|
1629
|
+
|
|
1630
|
+
var rippleClassName = clsx(classes.ripple, classes.rippleVisible, pulsate && classes.ripplePulsate);
|
|
1631
|
+
var rippleStyles = {
|
|
1632
|
+
width: rippleSize,
|
|
1633
|
+
height: rippleSize,
|
|
1634
|
+
top: -(rippleSize / 2) + rippleY,
|
|
1635
|
+
left: -(rippleSize / 2) + rippleX
|
|
1636
|
+
};
|
|
1637
|
+
var childClassName = clsx(classes.child, leaving && classes.childLeaving, pulsate && classes.childPulsate);
|
|
1638
|
+
var handleExited = useEventCallback(onExited); // Ripple is used for user feedback (e.g. click or press) so we want to apply styles with the highest priority
|
|
1639
|
+
|
|
1640
|
+
useEnhancedEffect$2(function () {
|
|
1641
|
+
if (!inProp) {
|
|
1642
|
+
// react-transition-group#onExit
|
|
1643
|
+
setLeaving(true); // react-transition-group#onExited
|
|
1644
|
+
|
|
1645
|
+
var timeoutId = setTimeout(handleExited, timeout);
|
|
1646
|
+
return function () {
|
|
1647
|
+
clearTimeout(timeoutId);
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
return undefined;
|
|
1652
|
+
}, [handleExited, inProp, timeout]);
|
|
1653
|
+
return /*#__PURE__*/React$2.createElement("span", {
|
|
1654
|
+
className: rippleClassName,
|
|
1655
|
+
style: rippleStyles
|
|
1656
|
+
}, /*#__PURE__*/React$2.createElement("span", {
|
|
1657
|
+
className: childClassName
|
|
1658
|
+
}));
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
var DURATION = 550;
|
|
1662
|
+
var DELAY_RIPPLE = 80;
|
|
1663
|
+
var styles$7 = function styles(theme) {
|
|
1664
|
+
return {
|
|
1665
|
+
/* Styles applied to the root element. */
|
|
1666
|
+
root: {
|
|
1667
|
+
overflow: 'hidden',
|
|
1668
|
+
pointerEvents: 'none',
|
|
1669
|
+
position: 'absolute',
|
|
1670
|
+
zIndex: 0,
|
|
1671
|
+
top: 0,
|
|
1672
|
+
right: 0,
|
|
1673
|
+
bottom: 0,
|
|
1674
|
+
left: 0,
|
|
1675
|
+
borderRadius: 'inherit'
|
|
1676
|
+
},
|
|
1677
|
+
|
|
1678
|
+
/* Styles applied to the internal `Ripple` components `ripple` class. */
|
|
1679
|
+
ripple: {
|
|
1680
|
+
opacity: 0,
|
|
1681
|
+
position: 'absolute'
|
|
1682
|
+
},
|
|
1683
|
+
|
|
1684
|
+
/* Styles applied to the internal `Ripple` components `rippleVisible` class. */
|
|
1685
|
+
rippleVisible: {
|
|
1686
|
+
opacity: 0.3,
|
|
1687
|
+
transform: 'scale(1)',
|
|
1688
|
+
animation: "$enter ".concat(DURATION, "ms ").concat(theme.transitions.easing.easeInOut)
|
|
1689
|
+
},
|
|
1690
|
+
|
|
1691
|
+
/* Styles applied to the internal `Ripple` components `ripplePulsate` class. */
|
|
1692
|
+
ripplePulsate: {
|
|
1693
|
+
animationDuration: "".concat(theme.transitions.duration.shorter, "ms")
|
|
1694
|
+
},
|
|
1695
|
+
|
|
1696
|
+
/* Styles applied to the internal `Ripple` components `child` class. */
|
|
1697
|
+
child: {
|
|
1698
|
+
opacity: 1,
|
|
1699
|
+
display: 'block',
|
|
1700
|
+
width: '100%',
|
|
1701
|
+
height: '100%',
|
|
1702
|
+
borderRadius: '50%',
|
|
1703
|
+
backgroundColor: 'currentColor'
|
|
1704
|
+
},
|
|
1705
|
+
|
|
1706
|
+
/* Styles applied to the internal `Ripple` components `childLeaving` class. */
|
|
1707
|
+
childLeaving: {
|
|
1708
|
+
opacity: 0,
|
|
1709
|
+
animation: "$exit ".concat(DURATION, "ms ").concat(theme.transitions.easing.easeInOut)
|
|
1710
|
+
},
|
|
1711
|
+
|
|
1712
|
+
/* Styles applied to the internal `Ripple` components `childPulsate` class. */
|
|
1713
|
+
childPulsate: {
|
|
1714
|
+
position: 'absolute',
|
|
1715
|
+
left: 0,
|
|
1716
|
+
top: 0,
|
|
1717
|
+
animation: "$pulsate 2500ms ".concat(theme.transitions.easing.easeInOut, " 200ms infinite")
|
|
1718
|
+
},
|
|
1719
|
+
'@keyframes enter': {
|
|
1720
|
+
'0%': {
|
|
1721
|
+
transform: 'scale(0)',
|
|
1722
|
+
opacity: 0.1
|
|
1723
|
+
},
|
|
1724
|
+
'100%': {
|
|
1725
|
+
transform: 'scale(1)',
|
|
1726
|
+
opacity: 0.3
|
|
1727
|
+
}
|
|
1728
|
+
},
|
|
1729
|
+
'@keyframes exit': {
|
|
1730
|
+
'0%': {
|
|
1731
|
+
opacity: 1
|
|
1732
|
+
},
|
|
1733
|
+
'100%': {
|
|
1734
|
+
opacity: 0
|
|
1735
|
+
}
|
|
1736
|
+
},
|
|
1737
|
+
'@keyframes pulsate': {
|
|
1738
|
+
'0%': {
|
|
1739
|
+
transform: 'scale(1)'
|
|
1740
|
+
},
|
|
1741
|
+
'50%': {
|
|
1742
|
+
transform: 'scale(0.92)'
|
|
1743
|
+
},
|
|
1744
|
+
'100%': {
|
|
1745
|
+
transform: 'scale(1)'
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
};
|
|
1750
|
+
/**
|
|
1751
|
+
* @ignore - internal component.
|
|
1752
|
+
*
|
|
1753
|
+
* TODO v5: Make private
|
|
1754
|
+
*/
|
|
1755
|
+
|
|
1756
|
+
var TouchRipple = /*#__PURE__*/React$2.forwardRef(function TouchRipple(props, ref) {
|
|
1757
|
+
var _props$center = props.center,
|
|
1758
|
+
centerProp = _props$center === void 0 ? false : _props$center,
|
|
1759
|
+
classes = props.classes,
|
|
1760
|
+
className = props.className,
|
|
1761
|
+
other = _objectWithoutProperties(props, ["center", "classes", "className"]);
|
|
1762
|
+
|
|
1763
|
+
var _React$useState = React$2.useState([]),
|
|
1764
|
+
ripples = _React$useState[0],
|
|
1765
|
+
setRipples = _React$useState[1];
|
|
1766
|
+
|
|
1767
|
+
var nextKey = React$2.useRef(0);
|
|
1768
|
+
var rippleCallback = React$2.useRef(null);
|
|
1769
|
+
React$2.useEffect(function () {
|
|
1770
|
+
if (rippleCallback.current) {
|
|
1771
|
+
rippleCallback.current();
|
|
1772
|
+
rippleCallback.current = null;
|
|
1773
|
+
}
|
|
1774
|
+
}, [ripples]); // Used to filter out mouse emulated events on mobile.
|
|
1775
|
+
|
|
1776
|
+
var ignoringMouseDown = React$2.useRef(false); // We use a timer in order to only show the ripples for touch "click" like events.
|
|
1777
|
+
// We don't want to display the ripple for touch scroll events.
|
|
1778
|
+
|
|
1779
|
+
var startTimer = React$2.useRef(null); // This is the hook called once the previous timeout is ready.
|
|
1780
|
+
|
|
1781
|
+
var startTimerCommit = React$2.useRef(null);
|
|
1782
|
+
var container = React$2.useRef(null);
|
|
1783
|
+
React$2.useEffect(function () {
|
|
1784
|
+
return function () {
|
|
1785
|
+
clearTimeout(startTimer.current);
|
|
1786
|
+
};
|
|
1787
|
+
}, []);
|
|
1788
|
+
var startCommit = React$2.useCallback(function (params) {
|
|
1789
|
+
var pulsate = params.pulsate,
|
|
1790
|
+
rippleX = params.rippleX,
|
|
1791
|
+
rippleY = params.rippleY,
|
|
1792
|
+
rippleSize = params.rippleSize,
|
|
1793
|
+
cb = params.cb;
|
|
1794
|
+
setRipples(function (oldRipples) {
|
|
1795
|
+
return [].concat(_toConsumableArray(oldRipples), [/*#__PURE__*/React$2.createElement(Ripple, {
|
|
1796
|
+
key: nextKey.current,
|
|
1797
|
+
classes: classes,
|
|
1798
|
+
timeout: DURATION,
|
|
1799
|
+
pulsate: pulsate,
|
|
1800
|
+
rippleX: rippleX,
|
|
1801
|
+
rippleY: rippleY,
|
|
1802
|
+
rippleSize: rippleSize
|
|
1803
|
+
})]);
|
|
1804
|
+
});
|
|
1805
|
+
nextKey.current += 1;
|
|
1806
|
+
rippleCallback.current = cb;
|
|
1807
|
+
}, [classes]);
|
|
1808
|
+
var start = React$2.useCallback(function () {
|
|
1809
|
+
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1810
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1811
|
+
var cb = arguments.length > 2 ? arguments[2] : undefined;
|
|
1812
|
+
var _options$pulsate = options.pulsate,
|
|
1813
|
+
pulsate = _options$pulsate === void 0 ? false : _options$pulsate,
|
|
1814
|
+
_options$center = options.center,
|
|
1815
|
+
center = _options$center === void 0 ? centerProp || options.pulsate : _options$center,
|
|
1816
|
+
_options$fakeElement = options.fakeElement,
|
|
1817
|
+
fakeElement = _options$fakeElement === void 0 ? false : _options$fakeElement;
|
|
1818
|
+
|
|
1819
|
+
if (event.type === 'mousedown' && ignoringMouseDown.current) {
|
|
1820
|
+
ignoringMouseDown.current = false;
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
if (event.type === 'touchstart') {
|
|
1825
|
+
ignoringMouseDown.current = true;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
var element = fakeElement ? null : container.current;
|
|
1829
|
+
var rect = element ? element.getBoundingClientRect() : {
|
|
1830
|
+
width: 0,
|
|
1831
|
+
height: 0,
|
|
1832
|
+
left: 0,
|
|
1833
|
+
top: 0
|
|
1834
|
+
}; // Get the size of the ripple
|
|
1835
|
+
|
|
1836
|
+
var rippleX;
|
|
1837
|
+
var rippleY;
|
|
1838
|
+
var rippleSize;
|
|
1839
|
+
|
|
1840
|
+
if (center || event.clientX === 0 && event.clientY === 0 || !event.clientX && !event.touches) {
|
|
1841
|
+
rippleX = Math.round(rect.width / 2);
|
|
1842
|
+
rippleY = Math.round(rect.height / 2);
|
|
1843
|
+
} else {
|
|
1844
|
+
var _ref = event.touches ? event.touches[0] : event,
|
|
1845
|
+
clientX = _ref.clientX,
|
|
1846
|
+
clientY = _ref.clientY;
|
|
1847
|
+
|
|
1848
|
+
rippleX = Math.round(clientX - rect.left);
|
|
1849
|
+
rippleY = Math.round(clientY - rect.top);
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
if (center) {
|
|
1853
|
+
rippleSize = Math.sqrt((2 * Math.pow(rect.width, 2) + Math.pow(rect.height, 2)) / 3); // For some reason the animation is broken on Mobile Chrome if the size if even.
|
|
1854
|
+
|
|
1855
|
+
if (rippleSize % 2 === 0) {
|
|
1856
|
+
rippleSize += 1;
|
|
1857
|
+
}
|
|
1858
|
+
} else {
|
|
1859
|
+
var sizeX = Math.max(Math.abs((element ? element.clientWidth : 0) - rippleX), rippleX) * 2 + 2;
|
|
1860
|
+
var sizeY = Math.max(Math.abs((element ? element.clientHeight : 0) - rippleY), rippleY) * 2 + 2;
|
|
1861
|
+
rippleSize = Math.sqrt(Math.pow(sizeX, 2) + Math.pow(sizeY, 2));
|
|
1862
|
+
} // Touche devices
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
if (event.touches) {
|
|
1866
|
+
// check that this isn't another touchstart due to multitouch
|
|
1867
|
+
// otherwise we will only clear a single timer when unmounting while two
|
|
1868
|
+
// are running
|
|
1869
|
+
if (startTimerCommit.current === null) {
|
|
1870
|
+
// Prepare the ripple effect.
|
|
1871
|
+
startTimerCommit.current = function () {
|
|
1872
|
+
startCommit({
|
|
1873
|
+
pulsate: pulsate,
|
|
1874
|
+
rippleX: rippleX,
|
|
1875
|
+
rippleY: rippleY,
|
|
1876
|
+
rippleSize: rippleSize,
|
|
1877
|
+
cb: cb
|
|
1878
|
+
});
|
|
1879
|
+
}; // Delay the execution of the ripple effect.
|
|
1880
|
+
|
|
1881
|
+
|
|
1882
|
+
startTimer.current = setTimeout(function () {
|
|
1883
|
+
if (startTimerCommit.current) {
|
|
1884
|
+
startTimerCommit.current();
|
|
1885
|
+
startTimerCommit.current = null;
|
|
1886
|
+
}
|
|
1887
|
+
}, DELAY_RIPPLE); // We have to make a tradeoff with this value.
|
|
1888
|
+
}
|
|
1889
|
+
} else {
|
|
1890
|
+
startCommit({
|
|
1891
|
+
pulsate: pulsate,
|
|
1892
|
+
rippleX: rippleX,
|
|
1893
|
+
rippleY: rippleY,
|
|
1894
|
+
rippleSize: rippleSize,
|
|
1895
|
+
cb: cb
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
}, [centerProp, startCommit]);
|
|
1899
|
+
var pulsate = React$2.useCallback(function () {
|
|
1900
|
+
start({}, {
|
|
1901
|
+
pulsate: true
|
|
1902
|
+
});
|
|
1903
|
+
}, [start]);
|
|
1904
|
+
var stop = React$2.useCallback(function (event, cb) {
|
|
1905
|
+
clearTimeout(startTimer.current); // The touch interaction occurs too quickly.
|
|
1906
|
+
// We still want to show ripple effect.
|
|
1907
|
+
|
|
1908
|
+
if (event.type === 'touchend' && startTimerCommit.current) {
|
|
1909
|
+
event.persist();
|
|
1910
|
+
startTimerCommit.current();
|
|
1911
|
+
startTimerCommit.current = null;
|
|
1912
|
+
startTimer.current = setTimeout(function () {
|
|
1913
|
+
stop(event, cb);
|
|
1914
|
+
});
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
startTimerCommit.current = null;
|
|
1919
|
+
setRipples(function (oldRipples) {
|
|
1920
|
+
if (oldRipples.length > 0) {
|
|
1921
|
+
return oldRipples.slice(1);
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
return oldRipples;
|
|
1925
|
+
});
|
|
1926
|
+
rippleCallback.current = cb;
|
|
1927
|
+
}, []);
|
|
1928
|
+
React$2.useImperativeHandle(ref, function () {
|
|
1929
|
+
return {
|
|
1930
|
+
pulsate: pulsate,
|
|
1931
|
+
start: start,
|
|
1932
|
+
stop: stop
|
|
1933
|
+
};
|
|
1934
|
+
}, [pulsate, start, stop]);
|
|
1935
|
+
return /*#__PURE__*/React$2.createElement("span", _extends({
|
|
1936
|
+
className: clsx(classes.root, className),
|
|
1937
|
+
ref: container
|
|
1938
|
+
}, other), /*#__PURE__*/React$2.createElement(TransitionGroup, {
|
|
1939
|
+
component: null,
|
|
1940
|
+
exit: true
|
|
1941
|
+
}, ripples));
|
|
1942
|
+
});
|
|
1943
|
+
var TouchRipple$1 = withStyles(styles$7, {
|
|
1944
|
+
flip: false,
|
|
1945
|
+
name: 'MuiTouchRipple'
|
|
1946
|
+
})( /*#__PURE__*/React$2.memo(TouchRipple));
|
|
1947
|
+
|
|
1948
|
+
var styles$6 = {
|
|
1949
|
+
/* Styles applied to the root element. */
|
|
1950
|
+
root: {
|
|
1951
|
+
display: 'inline-flex',
|
|
1952
|
+
alignItems: 'center',
|
|
1953
|
+
justifyContent: 'center',
|
|
1954
|
+
position: 'relative',
|
|
1955
|
+
WebkitTapHighlightColor: 'transparent',
|
|
1956
|
+
backgroundColor: 'transparent',
|
|
1957
|
+
// Reset default value
|
|
1958
|
+
// We disable the focus ring for mouse, touch and keyboard users.
|
|
1959
|
+
outline: 0,
|
|
1960
|
+
border: 0,
|
|
1961
|
+
margin: 0,
|
|
1962
|
+
// Remove the margin in Safari
|
|
1963
|
+
borderRadius: 0,
|
|
1964
|
+
padding: 0,
|
|
1965
|
+
// Remove the padding in Firefox
|
|
1966
|
+
cursor: 'pointer',
|
|
1967
|
+
userSelect: 'none',
|
|
1968
|
+
verticalAlign: 'middle',
|
|
1969
|
+
'-moz-appearance': 'none',
|
|
1970
|
+
// Reset
|
|
1971
|
+
'-webkit-appearance': 'none',
|
|
1972
|
+
// Reset
|
|
1973
|
+
textDecoration: 'none',
|
|
1974
|
+
// So we take precedent over the style of a native <a /> element.
|
|
1975
|
+
color: 'inherit',
|
|
1976
|
+
'&::-moz-focus-inner': {
|
|
1977
|
+
borderStyle: 'none' // Remove Firefox dotted outline.
|
|
1978
|
+
|
|
1979
|
+
},
|
|
1980
|
+
'&$disabled': {
|
|
1981
|
+
pointerEvents: 'none',
|
|
1982
|
+
// Disable link interactions
|
|
1983
|
+
cursor: 'default'
|
|
1984
|
+
},
|
|
1985
|
+
'@media print': {
|
|
1986
|
+
colorAdjust: 'exact'
|
|
1987
|
+
}
|
|
1988
|
+
},
|
|
1989
|
+
|
|
1990
|
+
/* Pseudo-class applied to the root element if `disabled={true}`. */
|
|
1991
|
+
disabled: {},
|
|
1992
|
+
|
|
1993
|
+
/* Pseudo-class applied to the root element if keyboard focused. */
|
|
1994
|
+
focusVisible: {}
|
|
1995
|
+
};
|
|
1996
|
+
/**
|
|
1997
|
+
* `ButtonBase` contains as few styles as possible.
|
|
1998
|
+
* It aims to be a simple building block for creating a button.
|
|
1999
|
+
* It contains a load of style reset and some focus/ripple logic.
|
|
2000
|
+
*/
|
|
2001
|
+
|
|
2002
|
+
var ButtonBase = /*#__PURE__*/React$2.forwardRef(function ButtonBase(props, ref) {
|
|
2003
|
+
var action = props.action,
|
|
2004
|
+
buttonRefProp = props.buttonRef,
|
|
2005
|
+
_props$centerRipple = props.centerRipple,
|
|
2006
|
+
centerRipple = _props$centerRipple === void 0 ? false : _props$centerRipple,
|
|
2007
|
+
children = props.children,
|
|
2008
|
+
classes = props.classes,
|
|
2009
|
+
className = props.className,
|
|
2010
|
+
_props$component = props.component,
|
|
2011
|
+
component = _props$component === void 0 ? 'button' : _props$component,
|
|
2012
|
+
_props$disabled = props.disabled,
|
|
2013
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
2014
|
+
_props$disableRipple = props.disableRipple,
|
|
2015
|
+
disableRipple = _props$disableRipple === void 0 ? false : _props$disableRipple,
|
|
2016
|
+
_props$disableTouchRi = props.disableTouchRipple,
|
|
2017
|
+
disableTouchRipple = _props$disableTouchRi === void 0 ? false : _props$disableTouchRi,
|
|
2018
|
+
_props$focusRipple = props.focusRipple,
|
|
2019
|
+
focusRipple = _props$focusRipple === void 0 ? false : _props$focusRipple,
|
|
2020
|
+
focusVisibleClassName = props.focusVisibleClassName,
|
|
2021
|
+
onBlur = props.onBlur,
|
|
2022
|
+
onClick = props.onClick,
|
|
2023
|
+
onFocus = props.onFocus,
|
|
2024
|
+
onFocusVisible = props.onFocusVisible,
|
|
2025
|
+
onKeyDown = props.onKeyDown,
|
|
2026
|
+
onKeyUp = props.onKeyUp,
|
|
2027
|
+
onMouseDown = props.onMouseDown,
|
|
2028
|
+
onMouseLeave = props.onMouseLeave,
|
|
2029
|
+
onMouseUp = props.onMouseUp,
|
|
2030
|
+
onTouchEnd = props.onTouchEnd,
|
|
2031
|
+
onTouchMove = props.onTouchMove,
|
|
2032
|
+
onTouchStart = props.onTouchStart,
|
|
2033
|
+
onDragLeave = props.onDragLeave,
|
|
2034
|
+
_props$tabIndex = props.tabIndex,
|
|
2035
|
+
tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
|
|
2036
|
+
TouchRippleProps = props.TouchRippleProps,
|
|
2037
|
+
_props$type = props.type,
|
|
2038
|
+
type = _props$type === void 0 ? 'button' : _props$type,
|
|
2039
|
+
other = _objectWithoutProperties(props, ["action", "buttonRef", "centerRipple", "children", "classes", "className", "component", "disabled", "disableRipple", "disableTouchRipple", "focusRipple", "focusVisibleClassName", "onBlur", "onClick", "onFocus", "onFocusVisible", "onKeyDown", "onKeyUp", "onMouseDown", "onMouseLeave", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "onDragLeave", "tabIndex", "TouchRippleProps", "type"]);
|
|
2040
|
+
|
|
2041
|
+
var buttonRef = React$2.useRef(null);
|
|
2042
|
+
|
|
2043
|
+
function getButtonNode() {
|
|
2044
|
+
// #StrictMode ready
|
|
2045
|
+
return ReactDOM.findDOMNode(buttonRef.current);
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
var rippleRef = React$2.useRef(null);
|
|
2049
|
+
|
|
2050
|
+
var _React$useState = React$2.useState(false),
|
|
2051
|
+
focusVisible = _React$useState[0],
|
|
2052
|
+
setFocusVisible = _React$useState[1];
|
|
2053
|
+
|
|
2054
|
+
if (disabled && focusVisible) {
|
|
2055
|
+
setFocusVisible(false);
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
var _useIsFocusVisible = useIsFocusVisible(),
|
|
2059
|
+
isFocusVisible = _useIsFocusVisible.isFocusVisible,
|
|
2060
|
+
onBlurVisible = _useIsFocusVisible.onBlurVisible,
|
|
2061
|
+
focusVisibleRef = _useIsFocusVisible.ref;
|
|
2062
|
+
|
|
2063
|
+
React$2.useImperativeHandle(action, function () {
|
|
2064
|
+
return {
|
|
2065
|
+
focusVisible: function focusVisible() {
|
|
2066
|
+
setFocusVisible(true);
|
|
2067
|
+
buttonRef.current.focus();
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
}, []);
|
|
2071
|
+
React$2.useEffect(function () {
|
|
2072
|
+
if (focusVisible && focusRipple && !disableRipple) {
|
|
2073
|
+
rippleRef.current.pulsate();
|
|
2074
|
+
}
|
|
2075
|
+
}, [disableRipple, focusRipple, focusVisible]);
|
|
2076
|
+
|
|
2077
|
+
function useRippleHandler(rippleAction, eventCallback) {
|
|
2078
|
+
var skipRippleAction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : disableTouchRipple;
|
|
2079
|
+
return useEventCallback(function (event) {
|
|
2080
|
+
if (eventCallback) {
|
|
2081
|
+
eventCallback(event);
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
var ignore = skipRippleAction;
|
|
2085
|
+
|
|
2086
|
+
if (!ignore && rippleRef.current) {
|
|
2087
|
+
rippleRef.current[rippleAction](event);
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
return true;
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
var handleMouseDown = useRippleHandler('start', onMouseDown);
|
|
2095
|
+
var handleDragLeave = useRippleHandler('stop', onDragLeave);
|
|
2096
|
+
var handleMouseUp = useRippleHandler('stop', onMouseUp);
|
|
2097
|
+
var handleMouseLeave = useRippleHandler('stop', function (event) {
|
|
2098
|
+
if (focusVisible) {
|
|
2099
|
+
event.preventDefault();
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
if (onMouseLeave) {
|
|
2103
|
+
onMouseLeave(event);
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2106
|
+
var handleTouchStart = useRippleHandler('start', onTouchStart);
|
|
2107
|
+
var handleTouchEnd = useRippleHandler('stop', onTouchEnd);
|
|
2108
|
+
var handleTouchMove = useRippleHandler('stop', onTouchMove);
|
|
2109
|
+
var handleBlur = useRippleHandler('stop', function (event) {
|
|
2110
|
+
if (focusVisible) {
|
|
2111
|
+
onBlurVisible(event);
|
|
2112
|
+
setFocusVisible(false);
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
if (onBlur) {
|
|
2116
|
+
onBlur(event);
|
|
2117
|
+
}
|
|
2118
|
+
}, false);
|
|
2119
|
+
var handleFocus = useEventCallback(function (event) {
|
|
2120
|
+
// Fix for https://github.com/facebook/react/issues/7769
|
|
2121
|
+
if (!buttonRef.current) {
|
|
2122
|
+
buttonRef.current = event.currentTarget;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
if (isFocusVisible(event)) {
|
|
2126
|
+
setFocusVisible(true);
|
|
2127
|
+
|
|
2128
|
+
if (onFocusVisible) {
|
|
2129
|
+
onFocusVisible(event);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
if (onFocus) {
|
|
2134
|
+
onFocus(event);
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
|
|
2138
|
+
var isNonNativeButton = function isNonNativeButton() {
|
|
2139
|
+
var button = getButtonNode();
|
|
2140
|
+
return component && component !== 'button' && !(button.tagName === 'A' && button.href);
|
|
2141
|
+
};
|
|
2142
|
+
/**
|
|
2143
|
+
* IE 11 shim for https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat
|
|
2144
|
+
*/
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
var keydownRef = React$2.useRef(false);
|
|
2148
|
+
var handleKeyDown = useEventCallback(function (event) {
|
|
2149
|
+
// Check if key is already down to avoid repeats being counted as multiple activations
|
|
2150
|
+
if (focusRipple && !keydownRef.current && focusVisible && rippleRef.current && event.key === ' ') {
|
|
2151
|
+
keydownRef.current = true;
|
|
2152
|
+
event.persist();
|
|
2153
|
+
rippleRef.current.stop(event, function () {
|
|
2154
|
+
rippleRef.current.start(event);
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
if (event.target === event.currentTarget && isNonNativeButton() && event.key === ' ') {
|
|
2159
|
+
event.preventDefault();
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
if (onKeyDown) {
|
|
2163
|
+
onKeyDown(event);
|
|
2164
|
+
} // Keyboard accessibility for non interactive elements
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
if (event.target === event.currentTarget && isNonNativeButton() && event.key === 'Enter' && !disabled) {
|
|
2168
|
+
event.preventDefault();
|
|
2169
|
+
|
|
2170
|
+
if (onClick) {
|
|
2171
|
+
onClick(event);
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
var handleKeyUp = useEventCallback(function (event) {
|
|
2176
|
+
// calling preventDefault in keyUp on a <button> will not dispatch a click event if Space is pressed
|
|
2177
|
+
// https://codesandbox.io/s/button-keyup-preventdefault-dn7f0
|
|
2178
|
+
if (focusRipple && event.key === ' ' && rippleRef.current && focusVisible && !event.defaultPrevented) {
|
|
2179
|
+
keydownRef.current = false;
|
|
2180
|
+
event.persist();
|
|
2181
|
+
rippleRef.current.stop(event, function () {
|
|
2182
|
+
rippleRef.current.pulsate(event);
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
if (onKeyUp) {
|
|
2187
|
+
onKeyUp(event);
|
|
2188
|
+
} // Keyboard accessibility for non interactive elements
|
|
2189
|
+
|
|
2190
|
+
|
|
2191
|
+
if (onClick && event.target === event.currentTarget && isNonNativeButton() && event.key === ' ' && !event.defaultPrevented) {
|
|
2192
|
+
onClick(event);
|
|
2193
|
+
}
|
|
2194
|
+
});
|
|
2195
|
+
var ComponentProp = component;
|
|
2196
|
+
|
|
2197
|
+
if (ComponentProp === 'button' && other.href) {
|
|
2198
|
+
ComponentProp = 'a';
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
var buttonProps = {};
|
|
2202
|
+
|
|
2203
|
+
if (ComponentProp === 'button') {
|
|
2204
|
+
buttonProps.type = type;
|
|
2205
|
+
buttonProps.disabled = disabled;
|
|
2206
|
+
} else {
|
|
2207
|
+
if (ComponentProp !== 'a' || !other.href) {
|
|
2208
|
+
buttonProps.role = 'button';
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
buttonProps['aria-disabled'] = disabled;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
var handleUserRef = useForkRef(buttonRefProp, ref);
|
|
2215
|
+
var handleOwnRef = useForkRef(focusVisibleRef, buttonRef);
|
|
2216
|
+
var handleRef = useForkRef(handleUserRef, handleOwnRef);
|
|
2217
|
+
|
|
2218
|
+
var _React$useState2 = React$2.useState(false),
|
|
2219
|
+
mountedState = _React$useState2[0],
|
|
2220
|
+
setMountedState = _React$useState2[1];
|
|
2221
|
+
|
|
2222
|
+
React$2.useEffect(function () {
|
|
2223
|
+
setMountedState(true);
|
|
2224
|
+
}, []);
|
|
2225
|
+
var enableTouchRipple = mountedState && !disableRipple && !disabled;
|
|
2226
|
+
|
|
2227
|
+
return /*#__PURE__*/React$2.createElement(ComponentProp, _extends({
|
|
2228
|
+
className: clsx(classes.root, className, focusVisible && [classes.focusVisible, focusVisibleClassName], disabled && classes.disabled),
|
|
2229
|
+
onBlur: handleBlur,
|
|
2230
|
+
onClick: onClick,
|
|
2231
|
+
onFocus: handleFocus,
|
|
2232
|
+
onKeyDown: handleKeyDown,
|
|
2233
|
+
onKeyUp: handleKeyUp,
|
|
2234
|
+
onMouseDown: handleMouseDown,
|
|
2235
|
+
onMouseLeave: handleMouseLeave,
|
|
2236
|
+
onMouseUp: handleMouseUp,
|
|
2237
|
+
onDragLeave: handleDragLeave,
|
|
2238
|
+
onTouchEnd: handleTouchEnd,
|
|
2239
|
+
onTouchMove: handleTouchMove,
|
|
2240
|
+
onTouchStart: handleTouchStart,
|
|
2241
|
+
ref: handleRef,
|
|
2242
|
+
tabIndex: disabled ? -1 : tabIndex
|
|
2243
|
+
}, buttonProps, other), children, enableTouchRipple ?
|
|
2244
|
+
/*#__PURE__*/
|
|
2245
|
+
|
|
2246
|
+
/* TouchRipple is only needed client-side, x2 boost on the server. */
|
|
2247
|
+
React$2.createElement(TouchRipple$1, _extends({
|
|
2248
|
+
ref: rippleRef,
|
|
2249
|
+
center: centerRipple
|
|
2250
|
+
}, TouchRippleProps)) : null);
|
|
2251
|
+
});
|
|
2252
|
+
var ButtonBase$1 = withStyles(styles$6, {
|
|
2253
|
+
name: 'MuiButtonBase'
|
|
2254
|
+
})(ButtonBase);
|
|
2255
|
+
|
|
2256
|
+
/**
|
|
2257
|
+
* @ignore - internal component.
|
|
2258
|
+
*/
|
|
2259
|
+
|
|
2260
|
+
var FirstPageIcon = createSvgIcon( /*#__PURE__*/React$2.createElement("path", {
|
|
2261
|
+
d: "M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"
|
|
2262
|
+
}));
|
|
2263
|
+
|
|
2264
|
+
/**
|
|
2265
|
+
* @ignore - internal component.
|
|
2266
|
+
*/
|
|
2267
|
+
|
|
2268
|
+
var LastPageIcon = createSvgIcon( /*#__PURE__*/React$2.createElement("path", {
|
|
2269
|
+
d: "M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"
|
|
2270
|
+
}));
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* @ignore - internal component.
|
|
2274
|
+
*/
|
|
2275
|
+
|
|
2276
|
+
var NavigateBeforeIcon = createSvgIcon( /*#__PURE__*/React$2.createElement("path", {
|
|
2277
|
+
d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"
|
|
2278
|
+
}));
|
|
2279
|
+
|
|
2280
|
+
/**
|
|
2281
|
+
* @ignore - internal component.
|
|
2282
|
+
*/
|
|
2283
|
+
|
|
2284
|
+
var NavigateNextIcon = createSvgIcon( /*#__PURE__*/React$2.createElement("path", {
|
|
2285
|
+
d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"
|
|
2286
|
+
}));
|
|
2287
|
+
|
|
2288
|
+
var styles$5 = function styles(theme) {
|
|
2289
|
+
return {
|
|
2290
|
+
/* Styles applied to the root element. */
|
|
2291
|
+
root: _extends({}, theme.typography.body2, {
|
|
2292
|
+
borderRadius: 32 / 2,
|
|
2293
|
+
textAlign: 'center',
|
|
2294
|
+
boxSizing: 'border-box',
|
|
2295
|
+
minWidth: 32,
|
|
2296
|
+
height: 32,
|
|
2297
|
+
padding: '0 6px',
|
|
2298
|
+
margin: '0 3px',
|
|
2299
|
+
color: theme.palette.text.primary
|
|
2300
|
+
}),
|
|
2301
|
+
|
|
2302
|
+
/* Styles applied to the root element if `type="page"`. */
|
|
2303
|
+
page: {
|
|
2304
|
+
transition: theme.transitions.create(['color', 'background-color'], {
|
|
2305
|
+
duration: theme.transitions.duration.short
|
|
2306
|
+
}),
|
|
2307
|
+
'&:hover': {
|
|
2308
|
+
backgroundColor: theme.palette.action.hover,
|
|
2309
|
+
// Reset on touch devices, it doesn't add specificity
|
|
2310
|
+
'@media (hover: none)': {
|
|
2311
|
+
backgroundColor: 'transparent'
|
|
2312
|
+
}
|
|
2313
|
+
},
|
|
2314
|
+
'&$focusVisible': {
|
|
2315
|
+
backgroundColor: theme.palette.action.focus
|
|
2316
|
+
},
|
|
2317
|
+
'&$selected': {
|
|
2318
|
+
backgroundColor: theme.palette.action.selected,
|
|
2319
|
+
'&:hover, &$focusVisible': {
|
|
2320
|
+
backgroundColor: alpha(theme.palette.action.selected, theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity),
|
|
2321
|
+
// Reset on touch devices, it doesn't add specificity
|
|
2322
|
+
'@media (hover: none)': {
|
|
2323
|
+
backgroundColor: theme.palette.action.selected
|
|
2324
|
+
}
|
|
2325
|
+
},
|
|
2326
|
+
'&$disabled': {
|
|
2327
|
+
opacity: 1,
|
|
2328
|
+
color: theme.palette.action.disabled,
|
|
2329
|
+
backgroundColor: theme.palette.action.selected
|
|
2330
|
+
}
|
|
2331
|
+
},
|
|
2332
|
+
'&$disabled': {
|
|
2333
|
+
opacity: theme.palette.action.disabledOpacity
|
|
2334
|
+
}
|
|
2335
|
+
},
|
|
2336
|
+
|
|
2337
|
+
/* Styles applied applied to the root element if `size="small"`. */
|
|
2338
|
+
sizeSmall: {
|
|
2339
|
+
minWidth: 26,
|
|
2340
|
+
height: 26,
|
|
2341
|
+
borderRadius: 26 / 2,
|
|
2342
|
+
margin: '0 1px',
|
|
2343
|
+
padding: '0 4px',
|
|
2344
|
+
'& $icon': {
|
|
2345
|
+
fontSize: theme.typography.pxToRem(18)
|
|
2346
|
+
}
|
|
2347
|
+
},
|
|
2348
|
+
|
|
2349
|
+
/* Styles applied applied to the root element if `size="large"`. */
|
|
2350
|
+
sizeLarge: {
|
|
2351
|
+
minWidth: 40,
|
|
2352
|
+
height: 40,
|
|
2353
|
+
borderRadius: 40 / 2,
|
|
2354
|
+
padding: '0 10px',
|
|
2355
|
+
fontSize: theme.typography.pxToRem(15),
|
|
2356
|
+
'& $icon': {
|
|
2357
|
+
fontSize: theme.typography.pxToRem(22)
|
|
2358
|
+
}
|
|
2359
|
+
},
|
|
2360
|
+
|
|
2361
|
+
/* Styles applied to the root element if `variant="text"` and `color="primary"`. */
|
|
2362
|
+
textPrimary: {
|
|
2363
|
+
'&$selected': {
|
|
2364
|
+
color: theme.palette.primary.contrastText,
|
|
2365
|
+
backgroundColor: theme.palette.primary.main,
|
|
2366
|
+
'&:hover, &$focusVisible': {
|
|
2367
|
+
backgroundColor: theme.palette.primary.dark,
|
|
2368
|
+
// Reset on touch devices, it doesn't add specificity
|
|
2369
|
+
'@media (hover: none)': {
|
|
2370
|
+
backgroundColor: theme.palette.primary.main
|
|
2371
|
+
}
|
|
2372
|
+
},
|
|
2373
|
+
'&$disabled': {
|
|
2374
|
+
color: theme.palette.action.disabled
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
},
|
|
2378
|
+
|
|
2379
|
+
/* Styles applied to the root element if `variant="text"` and `color="secondary"`. */
|
|
2380
|
+
textSecondary: {
|
|
2381
|
+
'&$selected': {
|
|
2382
|
+
color: theme.palette.secondary.contrastText,
|
|
2383
|
+
backgroundColor: theme.palette.secondary.main,
|
|
2384
|
+
'&:hover, &$focusVisible': {
|
|
2385
|
+
backgroundColor: theme.palette.secondary.dark,
|
|
2386
|
+
// Reset on touch devices, it doesn't add specificity
|
|
2387
|
+
'@media (hover: none)': {
|
|
2388
|
+
backgroundColor: theme.palette.secondary.main
|
|
2389
|
+
}
|
|
2390
|
+
},
|
|
2391
|
+
'&$disabled': {
|
|
2392
|
+
color: theme.palette.action.disabled
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
},
|
|
2396
|
+
|
|
2397
|
+
/* Styles applied to the root element if `outlined="true"`. */
|
|
2398
|
+
outlined: {
|
|
2399
|
+
border: "1px solid ".concat(theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)'),
|
|
2400
|
+
'&$selected': {
|
|
2401
|
+
'&$disabled': {
|
|
2402
|
+
border: "1px solid ".concat(theme.palette.action.disabledBackground)
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
},
|
|
2406
|
+
|
|
2407
|
+
/* Styles applied to the root element if `variant="outlined"` and `color="primary"`. */
|
|
2408
|
+
outlinedPrimary: {
|
|
2409
|
+
'&$selected': {
|
|
2410
|
+
color: theme.palette.primary.main,
|
|
2411
|
+
border: "1px solid ".concat(alpha(theme.palette.primary.main, 0.5)),
|
|
2412
|
+
backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
|
|
2413
|
+
'&:hover, &$focusVisible': {
|
|
2414
|
+
backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity + theme.palette.action.hoverOpacity),
|
|
2415
|
+
// Reset on touch devices, it doesn't add specificity
|
|
2416
|
+
'@media (hover: none)': {
|
|
2417
|
+
backgroundColor: 'transparent'
|
|
2418
|
+
}
|
|
2419
|
+
},
|
|
2420
|
+
'&$disabled': {
|
|
2421
|
+
color: theme.palette.action.disabled
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
},
|
|
2425
|
+
|
|
2426
|
+
/* Styles applied to the root element if `variant="outlined"` and `color="secondary"`. */
|
|
2427
|
+
outlinedSecondary: {
|
|
2428
|
+
'&$selected': {
|
|
2429
|
+
color: theme.palette.secondary.main,
|
|
2430
|
+
border: "1px solid ".concat(alpha(theme.palette.secondary.main, 0.5)),
|
|
2431
|
+
backgroundColor: alpha(theme.palette.secondary.main, theme.palette.action.activatedOpacity),
|
|
2432
|
+
'&:hover, &$focusVisible': {
|
|
2433
|
+
backgroundColor: alpha(theme.palette.secondary.main, theme.palette.action.activatedOpacity + theme.palette.action.hoverOpacity),
|
|
2434
|
+
// Reset on touch devices, it doesn't add specificity
|
|
2435
|
+
'@media (hover: none)': {
|
|
2436
|
+
backgroundColor: 'transparent'
|
|
2437
|
+
}
|
|
2438
|
+
},
|
|
2439
|
+
'&$disabled': {
|
|
2440
|
+
color: theme.palette.action.disabled
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
},
|
|
2444
|
+
|
|
2445
|
+
/* Styles applied to the root element if `rounded="true"`. */
|
|
2446
|
+
rounded: {
|
|
2447
|
+
borderRadius: theme.shape.borderRadius
|
|
2448
|
+
},
|
|
2449
|
+
|
|
2450
|
+
/* Styles applied to the root element if `type="start-ellipsis"` or `type="end-ellipsis"`. */
|
|
2451
|
+
ellipsis: {
|
|
2452
|
+
height: 'auto',
|
|
2453
|
+
'&$disabled': {
|
|
2454
|
+
opacity: theme.palette.action.disabledOpacity
|
|
2455
|
+
}
|
|
2456
|
+
},
|
|
2457
|
+
|
|
2458
|
+
/* Pseudo-class applied to the root element if keyboard focused. */
|
|
2459
|
+
focusVisible: {},
|
|
2460
|
+
|
|
2461
|
+
/* Pseudo-class applied to the root element if `disabled={true}`. */
|
|
2462
|
+
disabled: {},
|
|
2463
|
+
|
|
2464
|
+
/* Pseudo-class applied to the root element if `selected={true}`. */
|
|
2465
|
+
selected: {},
|
|
2466
|
+
|
|
2467
|
+
/* Styles applied to the icon element. */
|
|
2468
|
+
icon: {
|
|
2469
|
+
fontSize: theme.typography.pxToRem(20),
|
|
2470
|
+
margin: '0 -8px'
|
|
2471
|
+
}
|
|
2472
|
+
};
|
|
2473
|
+
};
|
|
2474
|
+
var PaginationItem = /*#__PURE__*/React$2.forwardRef(function PaginationItem(props, ref) {
|
|
2475
|
+
var classes = props.classes,
|
|
2476
|
+
className = props.className,
|
|
2477
|
+
_props$color = props.color,
|
|
2478
|
+
color = _props$color === void 0 ? 'standard' : _props$color,
|
|
2479
|
+
component = props.component,
|
|
2480
|
+
_props$disabled = props.disabled,
|
|
2481
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
2482
|
+
page = props.page,
|
|
2483
|
+
_props$selected = props.selected,
|
|
2484
|
+
selected = _props$selected === void 0 ? false : _props$selected,
|
|
2485
|
+
_props$shape = props.shape,
|
|
2486
|
+
shape = _props$shape === void 0 ? 'round' : _props$shape,
|
|
2487
|
+
_props$size = props.size,
|
|
2488
|
+
size = _props$size === void 0 ? 'medium' : _props$size,
|
|
2489
|
+
_props$type = props.type,
|
|
2490
|
+
type = _props$type === void 0 ? 'page' : _props$type,
|
|
2491
|
+
_props$variant = props.variant,
|
|
2492
|
+
variant = _props$variant === void 0 ? 'text' : _props$variant,
|
|
2493
|
+
other = _objectWithoutProperties(props, ["classes", "className", "color", "component", "disabled", "page", "selected", "shape", "size", "type", "variant"]);
|
|
2494
|
+
|
|
2495
|
+
var theme = useTheme();
|
|
2496
|
+
var normalizedIcons = theme.direction === 'rtl' ? {
|
|
2497
|
+
previous: NavigateNextIcon,
|
|
2498
|
+
next: NavigateBeforeIcon,
|
|
2499
|
+
last: FirstPageIcon,
|
|
2500
|
+
first: LastPageIcon
|
|
2501
|
+
} : {
|
|
2502
|
+
previous: NavigateBeforeIcon,
|
|
2503
|
+
next: NavigateNextIcon,
|
|
2504
|
+
first: FirstPageIcon,
|
|
2505
|
+
last: LastPageIcon
|
|
2506
|
+
};
|
|
2507
|
+
var Icon = normalizedIcons[type];
|
|
2508
|
+
return type === 'start-ellipsis' || type === 'end-ellipsis' ? /*#__PURE__*/React$2.createElement("div", {
|
|
2509
|
+
ref: ref,
|
|
2510
|
+
className: clsx(classes.root, classes.ellipsis, disabled && classes.disabled, size !== 'medium' && classes["size".concat(capitalize(size))])
|
|
2511
|
+
}, "\u2026") : /*#__PURE__*/React$2.createElement(ButtonBase$1, _extends({
|
|
2512
|
+
ref: ref,
|
|
2513
|
+
component: component,
|
|
2514
|
+
disabled: disabled,
|
|
2515
|
+
focusVisibleClassName: classes.focusVisible,
|
|
2516
|
+
className: clsx(classes.root, classes.page, classes[variant], classes[shape], className, color !== 'standard' && classes["".concat(variant).concat(capitalize(color))], disabled && classes.disabled, selected && classes.selected, size !== 'medium' && classes["size".concat(capitalize(size))])
|
|
2517
|
+
}, other), type === 'page' && page, Icon ? /*#__PURE__*/React$2.createElement(Icon, {
|
|
2518
|
+
className: classes.icon
|
|
2519
|
+
}) : null);
|
|
2520
|
+
});
|
|
2521
|
+
var PaginationItem$1 = withStyles(styles$5, {
|
|
2522
|
+
name: 'MuiPaginationItem'
|
|
2523
|
+
})(PaginationItem);
|
|
2524
|
+
|
|
2525
|
+
var styles$4 = {
|
|
2526
|
+
/* Styles applied to the root element. */
|
|
2527
|
+
root: {},
|
|
2528
|
+
|
|
2529
|
+
/* Styles applied to the ul element. */
|
|
2530
|
+
ul: {
|
|
2531
|
+
display: 'flex',
|
|
2532
|
+
flexWrap: 'wrap',
|
|
2533
|
+
alignItems: 'center',
|
|
2534
|
+
padding: 0,
|
|
2535
|
+
margin: 0,
|
|
2536
|
+
listStyle: 'none'
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2540
|
+
function defaultGetAriaLabel(type, page, selected) {
|
|
2541
|
+
if (type === 'page') {
|
|
2542
|
+
return "".concat(selected ? '' : 'Go to ', "page ").concat(page);
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
return "Go to ".concat(type, " page");
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
var Pagination$1 = /*#__PURE__*/React$2.forwardRef(function Pagination(props, ref) {
|
|
2549
|
+
props.boundaryCount;
|
|
2550
|
+
var classes = props.classes,
|
|
2551
|
+
className = props.className,
|
|
2552
|
+
_props$color = props.color,
|
|
2553
|
+
color = _props$color === void 0 ? 'standard' : _props$color;
|
|
2554
|
+
props.count;
|
|
2555
|
+
props.defaultPage;
|
|
2556
|
+
props.disabled;
|
|
2557
|
+
var _props$getItemAriaLab = props.getItemAriaLabel,
|
|
2558
|
+
getItemAriaLabel = _props$getItemAriaLab === void 0 ? defaultGetAriaLabel : _props$getItemAriaLab;
|
|
2559
|
+
props.hideNextButton;
|
|
2560
|
+
props.hidePrevButton;
|
|
2561
|
+
props.onChange;
|
|
2562
|
+
props.page;
|
|
2563
|
+
var _props$renderItem = props.renderItem,
|
|
2564
|
+
renderItem = _props$renderItem === void 0 ? function (item) {
|
|
2565
|
+
return /*#__PURE__*/React$2.createElement(PaginationItem$1, item);
|
|
2566
|
+
} : _props$renderItem,
|
|
2567
|
+
_props$shape = props.shape,
|
|
2568
|
+
shape = _props$shape === void 0 ? 'round' : _props$shape;
|
|
2569
|
+
props.showFirstButton;
|
|
2570
|
+
props.showLastButton;
|
|
2571
|
+
props.siblingCount;
|
|
2572
|
+
var _props$size = props.size,
|
|
2573
|
+
size = _props$size === void 0 ? 'medium' : _props$size,
|
|
2574
|
+
_props$variant = props.variant,
|
|
2575
|
+
variant = _props$variant === void 0 ? 'text' : _props$variant,
|
|
2576
|
+
other = _objectWithoutProperties(props, ["boundaryCount", "classes", "className", "color", "count", "defaultPage", "disabled", "getItemAriaLabel", "hideNextButton", "hidePrevButton", "onChange", "page", "renderItem", "shape", "showFirstButton", "showLastButton", "siblingCount", "size", "variant"]);
|
|
2577
|
+
|
|
2578
|
+
var _usePagination = usePagination(_extends({}, props, {
|
|
2579
|
+
componentName: 'Pagination'
|
|
2580
|
+
})),
|
|
2581
|
+
items = _usePagination.items;
|
|
2582
|
+
|
|
2583
|
+
return /*#__PURE__*/React$2.createElement("nav", _extends({
|
|
2584
|
+
"aria-label": "pagination navigation",
|
|
2585
|
+
className: clsx(classes.root, className),
|
|
2586
|
+
ref: ref
|
|
2587
|
+
}, other), /*#__PURE__*/React$2.createElement("ul", {
|
|
2588
|
+
className: classes.ul
|
|
2589
|
+
}, items.map(function (item, index) {
|
|
2590
|
+
return /*#__PURE__*/React$2.createElement("li", {
|
|
2591
|
+
key: index
|
|
2592
|
+
}, renderItem(_extends({}, item, {
|
|
2593
|
+
color: color,
|
|
2594
|
+
'aria-label': getItemAriaLabel(item.type, item.page, item.selected),
|
|
2595
|
+
shape: shape,
|
|
2596
|
+
size: size,
|
|
2597
|
+
variant: variant
|
|
2598
|
+
})));
|
|
2599
|
+
})));
|
|
2600
|
+
}); // @default tags synced with default values from usePagination
|
|
2601
|
+
var MUIPagination = withStyles(styles$4, {
|
|
2602
|
+
name: 'MuiPagination'
|
|
2603
|
+
})(Pagination$1);
|
|
2604
|
+
|
|
2605
|
+
/**
|
|
2606
|
+
* @ignore - internal component.
|
|
2607
|
+
*/
|
|
2608
|
+
|
|
2609
|
+
var NativeSelectInput = /*#__PURE__*/React$2.forwardRef(function NativeSelectInput(props, ref) {
|
|
2610
|
+
var classes = props.classes,
|
|
2611
|
+
className = props.className,
|
|
2612
|
+
disabled = props.disabled,
|
|
2613
|
+
IconComponent = props.IconComponent,
|
|
2614
|
+
inputRef = props.inputRef,
|
|
2615
|
+
_props$variant = props.variant,
|
|
2616
|
+
variant = _props$variant === void 0 ? 'standard' : _props$variant,
|
|
2617
|
+
other = _objectWithoutProperties(props, ["classes", "className", "disabled", "IconComponent", "inputRef", "variant"]);
|
|
2618
|
+
|
|
2619
|
+
return /*#__PURE__*/React$2.createElement(React$2.Fragment, null, /*#__PURE__*/React$2.createElement("select", _extends({
|
|
2620
|
+
className: clsx(classes.root, // TODO v5: merge root and select
|
|
2621
|
+
classes.select, classes[variant], className, disabled && classes.disabled),
|
|
2622
|
+
disabled: disabled,
|
|
2623
|
+
ref: inputRef || ref
|
|
2624
|
+
}, other)), props.multiple ? null : /*#__PURE__*/React$2.createElement(IconComponent, {
|
|
2625
|
+
className: clsx(classes.icon, classes["icon".concat(capitalize(variant))], disabled && classes.disabled)
|
|
2626
|
+
}));
|
|
2627
|
+
});
|
|
2628
|
+
|
|
2629
|
+
function formControlState(_ref) {
|
|
2630
|
+
var props = _ref.props,
|
|
2631
|
+
states = _ref.states,
|
|
2632
|
+
muiFormControl = _ref.muiFormControl;
|
|
2633
|
+
return states.reduce(function (acc, state) {
|
|
2634
|
+
acc[state] = props[state];
|
|
2635
|
+
|
|
2636
|
+
if (muiFormControl) {
|
|
2637
|
+
if (typeof props[state] === 'undefined') {
|
|
2638
|
+
acc[state] = muiFormControl[state];
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
return acc;
|
|
2643
|
+
}, {});
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
/**
|
|
2647
|
+
* @ignore - internal component.
|
|
2648
|
+
*/
|
|
2649
|
+
|
|
2650
|
+
var FormControlContext = React$2.createContext();
|
|
2651
|
+
|
|
2652
|
+
function useFormControl$1() {
|
|
2653
|
+
return React$2.useContext(FormControlContext);
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
function useFormControl() {
|
|
2657
|
+
return React$2.useContext(FormControlContext);
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
/**
|
|
2661
|
+
* @ignore - internal component.
|
|
2662
|
+
*/
|
|
2663
|
+
|
|
2664
|
+
var ArrowDropDownIcon = createSvgIcon( /*#__PURE__*/React$2.createElement("path", {
|
|
2665
|
+
d: "M7 10l5 5 5-5z"
|
|
2666
|
+
}));
|
|
2667
|
+
|
|
2668
|
+
function getStyleValue(computedStyle, property) {
|
|
2669
|
+
return parseInt(computedStyle[property], 10) || 0;
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
var useEnhancedEffect$1 = typeof window !== 'undefined' ? React$2.useLayoutEffect : React$2.useEffect;
|
|
2673
|
+
var styles$3 = {
|
|
2674
|
+
/* Styles applied to the shadow textarea element. */
|
|
2675
|
+
shadow: {
|
|
2676
|
+
// Visibility needed to hide the extra text area on iPads
|
|
2677
|
+
visibility: 'hidden',
|
|
2678
|
+
// Remove from the content flow
|
|
2679
|
+
position: 'absolute',
|
|
2680
|
+
// Ignore the scrollbar width
|
|
2681
|
+
overflow: 'hidden',
|
|
2682
|
+
height: 0,
|
|
2683
|
+
top: 0,
|
|
2684
|
+
left: 0,
|
|
2685
|
+
// Create a new layer, increase the isolation of the computed values
|
|
2686
|
+
transform: 'translateZ(0)'
|
|
2687
|
+
}
|
|
2688
|
+
};
|
|
2689
|
+
var TextareaAutosize = /*#__PURE__*/React$2.forwardRef(function TextareaAutosize(props, ref) {
|
|
2690
|
+
var onChange = props.onChange,
|
|
2691
|
+
rows = props.rows,
|
|
2692
|
+
rowsMax = props.rowsMax,
|
|
2693
|
+
rowsMinProp = props.rowsMin,
|
|
2694
|
+
maxRowsProp = props.maxRows,
|
|
2695
|
+
_props$minRows = props.minRows,
|
|
2696
|
+
minRowsProp = _props$minRows === void 0 ? 1 : _props$minRows,
|
|
2697
|
+
style = props.style,
|
|
2698
|
+
value = props.value,
|
|
2699
|
+
other = _objectWithoutProperties(props, ["onChange", "rows", "rowsMax", "rowsMin", "maxRows", "minRows", "style", "value"]);
|
|
2700
|
+
|
|
2701
|
+
var maxRows = maxRowsProp || rowsMax;
|
|
2702
|
+
var minRows = rows || rowsMinProp || minRowsProp;
|
|
2703
|
+
|
|
2704
|
+
var _React$useRef = React$2.useRef(value != null),
|
|
2705
|
+
isControlled = _React$useRef.current;
|
|
2706
|
+
|
|
2707
|
+
var inputRef = React$2.useRef(null);
|
|
2708
|
+
var handleRef = useForkRef(ref, inputRef);
|
|
2709
|
+
var shadowRef = React$2.useRef(null);
|
|
2710
|
+
var renders = React$2.useRef(0);
|
|
2711
|
+
|
|
2712
|
+
var _React$useState = React$2.useState({}),
|
|
2713
|
+
state = _React$useState[0],
|
|
2714
|
+
setState = _React$useState[1];
|
|
2715
|
+
|
|
2716
|
+
var syncHeight = React$2.useCallback(function () {
|
|
2717
|
+
var input = inputRef.current;
|
|
2718
|
+
var computedStyle = window.getComputedStyle(input);
|
|
2719
|
+
var inputShallow = shadowRef.current;
|
|
2720
|
+
inputShallow.style.width = computedStyle.width;
|
|
2721
|
+
inputShallow.value = input.value || props.placeholder || 'x';
|
|
2722
|
+
|
|
2723
|
+
if (inputShallow.value.slice(-1) === '\n') {
|
|
2724
|
+
// Certain fonts which overflow the line height will cause the textarea
|
|
2725
|
+
// to report a different scrollHeight depending on whether the last line
|
|
2726
|
+
// is empty. Make it non-empty to avoid this issue.
|
|
2727
|
+
inputShallow.value += ' ';
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
var boxSizing = computedStyle['box-sizing'];
|
|
2731
|
+
var padding = getStyleValue(computedStyle, 'padding-bottom') + getStyleValue(computedStyle, 'padding-top');
|
|
2732
|
+
var border = getStyleValue(computedStyle, 'border-bottom-width') + getStyleValue(computedStyle, 'border-top-width'); // The height of the inner content
|
|
2733
|
+
|
|
2734
|
+
var innerHeight = inputShallow.scrollHeight - padding; // Measure height of a textarea with a single row
|
|
2735
|
+
|
|
2736
|
+
inputShallow.value = 'x';
|
|
2737
|
+
var singleRowHeight = inputShallow.scrollHeight - padding; // The height of the outer content
|
|
2738
|
+
|
|
2739
|
+
var outerHeight = innerHeight;
|
|
2740
|
+
|
|
2741
|
+
if (minRows) {
|
|
2742
|
+
outerHeight = Math.max(Number(minRows) * singleRowHeight, outerHeight);
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
if (maxRows) {
|
|
2746
|
+
outerHeight = Math.min(Number(maxRows) * singleRowHeight, outerHeight);
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
outerHeight = Math.max(outerHeight, singleRowHeight); // Take the box sizing into account for applying this value as a style.
|
|
2750
|
+
|
|
2751
|
+
var outerHeightStyle = outerHeight + (boxSizing === 'border-box' ? padding + border : 0);
|
|
2752
|
+
var overflow = Math.abs(outerHeight - innerHeight) <= 1;
|
|
2753
|
+
setState(function (prevState) {
|
|
2754
|
+
// Need a large enough difference to update the height.
|
|
2755
|
+
// This prevents infinite rendering loop.
|
|
2756
|
+
if (renders.current < 20 && (outerHeightStyle > 0 && Math.abs((prevState.outerHeightStyle || 0) - outerHeightStyle) > 1 || prevState.overflow !== overflow)) {
|
|
2757
|
+
renders.current += 1;
|
|
2758
|
+
return {
|
|
2759
|
+
overflow: overflow,
|
|
2760
|
+
outerHeightStyle: outerHeightStyle
|
|
2761
|
+
};
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
return prevState;
|
|
2765
|
+
});
|
|
2766
|
+
}, [maxRows, minRows, props.placeholder]);
|
|
2767
|
+
React$2.useEffect(function () {
|
|
2768
|
+
var handleResize = debounce(function () {
|
|
2769
|
+
renders.current = 0;
|
|
2770
|
+
syncHeight();
|
|
2771
|
+
});
|
|
2772
|
+
window.addEventListener('resize', handleResize);
|
|
2773
|
+
return function () {
|
|
2774
|
+
handleResize.clear();
|
|
2775
|
+
window.removeEventListener('resize', handleResize);
|
|
2776
|
+
};
|
|
2777
|
+
}, [syncHeight]);
|
|
2778
|
+
useEnhancedEffect$1(function () {
|
|
2779
|
+
syncHeight();
|
|
2780
|
+
});
|
|
2781
|
+
React$2.useEffect(function () {
|
|
2782
|
+
renders.current = 0;
|
|
2783
|
+
}, [value]);
|
|
2784
|
+
|
|
2785
|
+
var handleChange = function handleChange(event) {
|
|
2786
|
+
renders.current = 0;
|
|
2787
|
+
|
|
2788
|
+
if (!isControlled) {
|
|
2789
|
+
syncHeight();
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
if (onChange) {
|
|
2793
|
+
onChange(event);
|
|
2794
|
+
}
|
|
2795
|
+
};
|
|
2796
|
+
|
|
2797
|
+
return /*#__PURE__*/React$2.createElement(React$2.Fragment, null, /*#__PURE__*/React$2.createElement("textarea", _extends({
|
|
2798
|
+
value: value,
|
|
2799
|
+
onChange: handleChange,
|
|
2800
|
+
ref: handleRef // Apply the rows prop to get a "correct" first SSR paint
|
|
2801
|
+
,
|
|
2802
|
+
rows: minRows,
|
|
2803
|
+
style: _extends({
|
|
2804
|
+
height: state.outerHeightStyle,
|
|
2805
|
+
// Need a large enough difference to allow scrolling.
|
|
2806
|
+
// This prevents infinite rendering loop.
|
|
2807
|
+
overflow: state.overflow ? 'hidden' : null
|
|
2808
|
+
}, style)
|
|
2809
|
+
}, other)), /*#__PURE__*/React$2.createElement("textarea", {
|
|
2810
|
+
"aria-hidden": true,
|
|
2811
|
+
className: props.className,
|
|
2812
|
+
readOnly: true,
|
|
2813
|
+
ref: shadowRef,
|
|
2814
|
+
tabIndex: -1,
|
|
2815
|
+
style: _extends({}, styles$3.shadow, style)
|
|
2816
|
+
}));
|
|
2817
|
+
});
|
|
2818
|
+
|
|
2819
|
+
// Supports determination of isControlled().
|
|
2820
|
+
// Controlled input accepts its current value as a prop.
|
|
2821
|
+
//
|
|
2822
|
+
// @see https://facebook.github.io/react/docs/forms.html#controlled-components
|
|
2823
|
+
// @param value
|
|
2824
|
+
// @returns {boolean} true if string (including '') or number (including zero)
|
|
2825
|
+
function hasValue(value) {
|
|
2826
|
+
return value != null && !(Array.isArray(value) && value.length === 0);
|
|
2827
|
+
} // Determine if field is empty or filled.
|
|
2828
|
+
// Response determines if label is presented above field or as placeholder.
|
|
2829
|
+
//
|
|
2830
|
+
// @param obj
|
|
2831
|
+
// @param SSR
|
|
2832
|
+
// @returns {boolean} False when not present or empty string.
|
|
2833
|
+
// True when any number or string with length.
|
|
2834
|
+
|
|
2835
|
+
function isFilled(obj) {
|
|
2836
|
+
var SSR = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2837
|
+
return obj && (hasValue(obj.value) && obj.value !== '' || SSR && hasValue(obj.defaultValue) && obj.defaultValue !== '');
|
|
2838
|
+
} // Determine if an Input is adorned on start.
|
|
2839
|
+
|
|
2840
|
+
var styles$2 = function styles(theme) {
|
|
2841
|
+
var light = theme.palette.type === 'light';
|
|
2842
|
+
var placeholder = {
|
|
2843
|
+
color: 'currentColor',
|
|
2844
|
+
opacity: light ? 0.42 : 0.5,
|
|
2845
|
+
transition: theme.transitions.create('opacity', {
|
|
2846
|
+
duration: theme.transitions.duration.shorter
|
|
2847
|
+
})
|
|
2848
|
+
};
|
|
2849
|
+
var placeholderHidden = {
|
|
2850
|
+
opacity: '0 !important'
|
|
2851
|
+
};
|
|
2852
|
+
var placeholderVisible = {
|
|
2853
|
+
opacity: light ? 0.42 : 0.5
|
|
2854
|
+
};
|
|
2855
|
+
return {
|
|
2856
|
+
'@global': {
|
|
2857
|
+
'@keyframes mui-auto-fill': {},
|
|
2858
|
+
'@keyframes mui-auto-fill-cancel': {}
|
|
2859
|
+
},
|
|
2860
|
+
|
|
2861
|
+
/* Styles applied to the root element. */
|
|
2862
|
+
root: _extends({}, theme.typography.body1, {
|
|
2863
|
+
color: theme.palette.text.primary,
|
|
2864
|
+
lineHeight: '1.1876em',
|
|
2865
|
+
// Reset (19px), match the native input line-height
|
|
2866
|
+
boxSizing: 'border-box',
|
|
2867
|
+
// Prevent padding issue with fullWidth.
|
|
2868
|
+
position: 'relative',
|
|
2869
|
+
cursor: 'text',
|
|
2870
|
+
display: 'inline-flex',
|
|
2871
|
+
alignItems: 'center',
|
|
2872
|
+
'&$disabled': {
|
|
2873
|
+
color: theme.palette.text.disabled,
|
|
2874
|
+
cursor: 'default'
|
|
2875
|
+
}
|
|
2876
|
+
}),
|
|
2877
|
+
|
|
2878
|
+
/* Styles applied to the root element if the component is a descendant of `FormControl`. */
|
|
2879
|
+
formControl: {},
|
|
2880
|
+
|
|
2881
|
+
/* Styles applied to the root element if the component is focused. */
|
|
2882
|
+
focused: {},
|
|
2883
|
+
|
|
2884
|
+
/* Styles applied to the root element if `disabled={true}`. */
|
|
2885
|
+
disabled: {},
|
|
2886
|
+
|
|
2887
|
+
/* Styles applied to the root element if `startAdornment` is provided. */
|
|
2888
|
+
adornedStart: {},
|
|
2889
|
+
|
|
2890
|
+
/* Styles applied to the root element if `endAdornment` is provided. */
|
|
2891
|
+
adornedEnd: {},
|
|
2892
|
+
|
|
2893
|
+
/* Pseudo-class applied to the root element if `error={true}`. */
|
|
2894
|
+
error: {},
|
|
2895
|
+
|
|
2896
|
+
/* Styles applied to the `input` element if `margin="dense"`. */
|
|
2897
|
+
marginDense: {},
|
|
2898
|
+
|
|
2899
|
+
/* Styles applied to the root element if `multiline={true}`. */
|
|
2900
|
+
multiline: {
|
|
2901
|
+
padding: "".concat(8 - 2, "px 0 ").concat(8 - 1, "px"),
|
|
2902
|
+
'&$marginDense': {
|
|
2903
|
+
paddingTop: 4 - 1
|
|
2904
|
+
}
|
|
2905
|
+
},
|
|
2906
|
+
|
|
2907
|
+
/* Styles applied to the root element if the color is secondary. */
|
|
2908
|
+
colorSecondary: {},
|
|
2909
|
+
|
|
2910
|
+
/* Styles applied to the root element if `fullWidth={true}`. */
|
|
2911
|
+
fullWidth: {
|
|
2912
|
+
width: '100%'
|
|
2913
|
+
},
|
|
2914
|
+
|
|
2915
|
+
/* Styles applied to the `input` element. */
|
|
2916
|
+
input: {
|
|
2917
|
+
font: 'inherit',
|
|
2918
|
+
letterSpacing: 'inherit',
|
|
2919
|
+
color: 'currentColor',
|
|
2920
|
+
padding: "".concat(8 - 2, "px 0 ").concat(8 - 1, "px"),
|
|
2921
|
+
border: 0,
|
|
2922
|
+
boxSizing: 'content-box',
|
|
2923
|
+
background: 'none',
|
|
2924
|
+
height: '1.1876em',
|
|
2925
|
+
// Reset (19px), match the native input line-height
|
|
2926
|
+
margin: 0,
|
|
2927
|
+
// Reset for Safari
|
|
2928
|
+
WebkitTapHighlightColor: 'transparent',
|
|
2929
|
+
display: 'block',
|
|
2930
|
+
// Make the flex item shrink with Firefox
|
|
2931
|
+
minWidth: 0,
|
|
2932
|
+
width: '100%',
|
|
2933
|
+
// Fix IE 11 width issue
|
|
2934
|
+
animationName: 'mui-auto-fill-cancel',
|
|
2935
|
+
animationDuration: '10ms',
|
|
2936
|
+
'&::-webkit-input-placeholder': placeholder,
|
|
2937
|
+
'&::-moz-placeholder': placeholder,
|
|
2938
|
+
// Firefox 19+
|
|
2939
|
+
'&:-ms-input-placeholder': placeholder,
|
|
2940
|
+
// IE 11
|
|
2941
|
+
'&::-ms-input-placeholder': placeholder,
|
|
2942
|
+
// Edge
|
|
2943
|
+
'&:focus': {
|
|
2944
|
+
outline: 0
|
|
2945
|
+
},
|
|
2946
|
+
// Reset Firefox invalid required input style
|
|
2947
|
+
'&:invalid': {
|
|
2948
|
+
boxShadow: 'none'
|
|
2949
|
+
},
|
|
2950
|
+
'&::-webkit-search-decoration': {
|
|
2951
|
+
// Remove the padding when type=search.
|
|
2952
|
+
'-webkit-appearance': 'none'
|
|
2953
|
+
},
|
|
2954
|
+
// Show and hide the placeholder logic
|
|
2955
|
+
'label[data-shrink=false] + $formControl &': {
|
|
2956
|
+
'&::-webkit-input-placeholder': placeholderHidden,
|
|
2957
|
+
'&::-moz-placeholder': placeholderHidden,
|
|
2958
|
+
// Firefox 19+
|
|
2959
|
+
'&:-ms-input-placeholder': placeholderHidden,
|
|
2960
|
+
// IE 11
|
|
2961
|
+
'&::-ms-input-placeholder': placeholderHidden,
|
|
2962
|
+
// Edge
|
|
2963
|
+
'&:focus::-webkit-input-placeholder': placeholderVisible,
|
|
2964
|
+
'&:focus::-moz-placeholder': placeholderVisible,
|
|
2965
|
+
// Firefox 19+
|
|
2966
|
+
'&:focus:-ms-input-placeholder': placeholderVisible,
|
|
2967
|
+
// IE 11
|
|
2968
|
+
'&:focus::-ms-input-placeholder': placeholderVisible // Edge
|
|
2969
|
+
|
|
2970
|
+
},
|
|
2971
|
+
'&$disabled': {
|
|
2972
|
+
opacity: 1 // Reset iOS opacity
|
|
2973
|
+
|
|
2974
|
+
},
|
|
2975
|
+
'&:-webkit-autofill': {
|
|
2976
|
+
animationDuration: '5000s',
|
|
2977
|
+
animationName: 'mui-auto-fill'
|
|
2978
|
+
}
|
|
2979
|
+
},
|
|
2980
|
+
|
|
2981
|
+
/* Styles applied to the `input` element if `margin="dense"`. */
|
|
2982
|
+
inputMarginDense: {
|
|
2983
|
+
paddingTop: 4 - 1
|
|
2984
|
+
},
|
|
2985
|
+
|
|
2986
|
+
/* Styles applied to the `input` element if `multiline={true}`. */
|
|
2987
|
+
inputMultiline: {
|
|
2988
|
+
height: 'auto',
|
|
2989
|
+
resize: 'none',
|
|
2990
|
+
padding: 0
|
|
2991
|
+
},
|
|
2992
|
+
|
|
2993
|
+
/* Styles applied to the `input` element if `type="search"`. */
|
|
2994
|
+
inputTypeSearch: {
|
|
2995
|
+
// Improve type search style.
|
|
2996
|
+
'-moz-appearance': 'textfield',
|
|
2997
|
+
'-webkit-appearance': 'textfield'
|
|
2998
|
+
},
|
|
2999
|
+
|
|
3000
|
+
/* Styles applied to the `input` element if `startAdornment` is provided. */
|
|
3001
|
+
inputAdornedStart: {},
|
|
3002
|
+
|
|
3003
|
+
/* Styles applied to the `input` element if `endAdornment` is provided. */
|
|
3004
|
+
inputAdornedEnd: {},
|
|
3005
|
+
|
|
3006
|
+
/* Styles applied to the `input` element if `hiddenLabel={true}`. */
|
|
3007
|
+
inputHiddenLabel: {}
|
|
3008
|
+
};
|
|
3009
|
+
};
|
|
3010
|
+
var useEnhancedEffect = typeof window === 'undefined' ? React$2.useEffect : React$2.useLayoutEffect;
|
|
3011
|
+
/**
|
|
3012
|
+
* `InputBase` contains as few styles as possible.
|
|
3013
|
+
* It aims to be a simple building block for creating an input.
|
|
3014
|
+
* It contains a load of style reset and some state logic.
|
|
3015
|
+
*/
|
|
3016
|
+
|
|
3017
|
+
var InputBase = /*#__PURE__*/React$2.forwardRef(function InputBase(props, ref) {
|
|
3018
|
+
var ariaDescribedby = props['aria-describedby'],
|
|
3019
|
+
autoComplete = props.autoComplete,
|
|
3020
|
+
autoFocus = props.autoFocus,
|
|
3021
|
+
classes = props.classes,
|
|
3022
|
+
className = props.className;
|
|
3023
|
+
props.color;
|
|
3024
|
+
var defaultValue = props.defaultValue,
|
|
3025
|
+
disabled = props.disabled,
|
|
3026
|
+
endAdornment = props.endAdornment;
|
|
3027
|
+
props.error;
|
|
3028
|
+
var _props$fullWidth = props.fullWidth,
|
|
3029
|
+
fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
|
|
3030
|
+
id = props.id,
|
|
3031
|
+
_props$inputComponent = props.inputComponent,
|
|
3032
|
+
inputComponent = _props$inputComponent === void 0 ? 'input' : _props$inputComponent,
|
|
3033
|
+
_props$inputProps = props.inputProps,
|
|
3034
|
+
inputPropsProp = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
3035
|
+
inputRefProp = props.inputRef;
|
|
3036
|
+
props.margin;
|
|
3037
|
+
var _props$multiline = props.multiline,
|
|
3038
|
+
multiline = _props$multiline === void 0 ? false : _props$multiline,
|
|
3039
|
+
name = props.name,
|
|
3040
|
+
onBlur = props.onBlur,
|
|
3041
|
+
onChange = props.onChange,
|
|
3042
|
+
onClick = props.onClick,
|
|
3043
|
+
onFocus = props.onFocus,
|
|
3044
|
+
onKeyDown = props.onKeyDown,
|
|
3045
|
+
onKeyUp = props.onKeyUp,
|
|
3046
|
+
placeholder = props.placeholder,
|
|
3047
|
+
readOnly = props.readOnly,
|
|
3048
|
+
renderSuffix = props.renderSuffix,
|
|
3049
|
+
rows = props.rows,
|
|
3050
|
+
rowsMax = props.rowsMax,
|
|
3051
|
+
rowsMin = props.rowsMin,
|
|
3052
|
+
maxRows = props.maxRows,
|
|
3053
|
+
minRows = props.minRows,
|
|
3054
|
+
startAdornment = props.startAdornment,
|
|
3055
|
+
_props$type = props.type,
|
|
3056
|
+
type = _props$type === void 0 ? 'text' : _props$type,
|
|
3057
|
+
valueProp = props.value,
|
|
3058
|
+
other = _objectWithoutProperties(props, ["aria-describedby", "autoComplete", "autoFocus", "classes", "className", "color", "defaultValue", "disabled", "endAdornment", "error", "fullWidth", "id", "inputComponent", "inputProps", "inputRef", "margin", "multiline", "name", "onBlur", "onChange", "onClick", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "readOnly", "renderSuffix", "rows", "rowsMax", "rowsMin", "maxRows", "minRows", "startAdornment", "type", "value"]);
|
|
3059
|
+
|
|
3060
|
+
var value = inputPropsProp.value != null ? inputPropsProp.value : valueProp;
|
|
3061
|
+
|
|
3062
|
+
var _React$useRef = React$2.useRef(value != null),
|
|
3063
|
+
isControlled = _React$useRef.current;
|
|
3064
|
+
|
|
3065
|
+
var inputRef = React$2.useRef();
|
|
3066
|
+
var handleInputRefWarning = React$2.useCallback(function (instance) {
|
|
3067
|
+
}, []);
|
|
3068
|
+
var handleInputPropsRefProp = useForkRef(inputPropsProp.ref, handleInputRefWarning);
|
|
3069
|
+
var handleInputRefProp = useForkRef(inputRefProp, handleInputPropsRefProp);
|
|
3070
|
+
var handleInputRef = useForkRef(inputRef, handleInputRefProp);
|
|
3071
|
+
|
|
3072
|
+
var _React$useState = React$2.useState(false),
|
|
3073
|
+
focused = _React$useState[0],
|
|
3074
|
+
setFocused = _React$useState[1];
|
|
3075
|
+
|
|
3076
|
+
var muiFormControl = useFormControl$1();
|
|
3077
|
+
|
|
3078
|
+
var fcs = formControlState({
|
|
3079
|
+
props: props,
|
|
3080
|
+
muiFormControl: muiFormControl,
|
|
3081
|
+
states: ['color', 'disabled', 'error', 'hiddenLabel', 'margin', 'required', 'filled']
|
|
3082
|
+
});
|
|
3083
|
+
fcs.focused = muiFormControl ? muiFormControl.focused : focused; // The blur won't fire when the disabled state is set on a focused input.
|
|
3084
|
+
// We need to book keep the focused state manually.
|
|
3085
|
+
|
|
3086
|
+
React$2.useEffect(function () {
|
|
3087
|
+
if (!muiFormControl && disabled && focused) {
|
|
3088
|
+
setFocused(false);
|
|
3089
|
+
|
|
3090
|
+
if (onBlur) {
|
|
3091
|
+
onBlur();
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
}, [muiFormControl, disabled, focused, onBlur]);
|
|
3095
|
+
var onFilled = muiFormControl && muiFormControl.onFilled;
|
|
3096
|
+
var onEmpty = muiFormControl && muiFormControl.onEmpty;
|
|
3097
|
+
var checkDirty = React$2.useCallback(function (obj) {
|
|
3098
|
+
if (isFilled(obj)) {
|
|
3099
|
+
if (onFilled) {
|
|
3100
|
+
onFilled();
|
|
3101
|
+
}
|
|
3102
|
+
} else if (onEmpty) {
|
|
3103
|
+
onEmpty();
|
|
3104
|
+
}
|
|
3105
|
+
}, [onFilled, onEmpty]);
|
|
3106
|
+
useEnhancedEffect(function () {
|
|
3107
|
+
if (isControlled) {
|
|
3108
|
+
checkDirty({
|
|
3109
|
+
value: value
|
|
3110
|
+
});
|
|
3111
|
+
}
|
|
3112
|
+
}, [value, checkDirty, isControlled]);
|
|
3113
|
+
|
|
3114
|
+
var handleFocus = function handleFocus(event) {
|
|
3115
|
+
// Fix a bug with IE 11 where the focus/blur events are triggered
|
|
3116
|
+
// while the input is disabled.
|
|
3117
|
+
if (fcs.disabled) {
|
|
3118
|
+
event.stopPropagation();
|
|
3119
|
+
return;
|
|
3120
|
+
}
|
|
3121
|
+
|
|
3122
|
+
if (onFocus) {
|
|
3123
|
+
onFocus(event);
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
if (inputPropsProp.onFocus) {
|
|
3127
|
+
inputPropsProp.onFocus(event);
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
if (muiFormControl && muiFormControl.onFocus) {
|
|
3131
|
+
muiFormControl.onFocus(event);
|
|
3132
|
+
} else {
|
|
3133
|
+
setFocused(true);
|
|
3134
|
+
}
|
|
3135
|
+
};
|
|
3136
|
+
|
|
3137
|
+
var handleBlur = function handleBlur(event) {
|
|
3138
|
+
if (onBlur) {
|
|
3139
|
+
onBlur(event);
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
if (inputPropsProp.onBlur) {
|
|
3143
|
+
inputPropsProp.onBlur(event);
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
if (muiFormControl && muiFormControl.onBlur) {
|
|
3147
|
+
muiFormControl.onBlur(event);
|
|
3148
|
+
} else {
|
|
3149
|
+
setFocused(false);
|
|
3150
|
+
}
|
|
3151
|
+
};
|
|
3152
|
+
|
|
3153
|
+
var handleChange = function handleChange(event) {
|
|
3154
|
+
if (!isControlled) {
|
|
3155
|
+
var element = event.target || inputRef.current;
|
|
3156
|
+
|
|
3157
|
+
if (element == null) {
|
|
3158
|
+
throw new Error(formatMuiErrorMessage(1));
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
checkDirty({
|
|
3162
|
+
value: element.value
|
|
3163
|
+
});
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
3167
|
+
args[_key - 1] = arguments[_key];
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
if (inputPropsProp.onChange) {
|
|
3171
|
+
inputPropsProp.onChange.apply(inputPropsProp, [event].concat(args));
|
|
3172
|
+
} // Perform in the willUpdate
|
|
3173
|
+
|
|
3174
|
+
|
|
3175
|
+
if (onChange) {
|
|
3176
|
+
onChange.apply(void 0, [event].concat(args));
|
|
3177
|
+
}
|
|
3178
|
+
}; // Check the input state on mount, in case it was filled by the user
|
|
3179
|
+
// or auto filled by the browser before the hydration (for SSR).
|
|
3180
|
+
|
|
3181
|
+
|
|
3182
|
+
React$2.useEffect(function () {
|
|
3183
|
+
checkDirty(inputRef.current);
|
|
3184
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
3185
|
+
|
|
3186
|
+
var handleClick = function handleClick(event) {
|
|
3187
|
+
if (inputRef.current && event.currentTarget === event.target) {
|
|
3188
|
+
inputRef.current.focus();
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
if (onClick) {
|
|
3192
|
+
onClick(event);
|
|
3193
|
+
}
|
|
3194
|
+
};
|
|
3195
|
+
|
|
3196
|
+
var InputComponent = inputComponent;
|
|
3197
|
+
|
|
3198
|
+
var inputProps = _extends({}, inputPropsProp, {
|
|
3199
|
+
ref: handleInputRef
|
|
3200
|
+
});
|
|
3201
|
+
|
|
3202
|
+
if (typeof InputComponent !== 'string') {
|
|
3203
|
+
inputProps = _extends({
|
|
3204
|
+
// Rename ref to inputRef as we don't know the
|
|
3205
|
+
// provided `inputComponent` structure.
|
|
3206
|
+
inputRef: handleInputRef,
|
|
3207
|
+
type: type
|
|
3208
|
+
}, inputProps, {
|
|
3209
|
+
ref: null
|
|
3210
|
+
});
|
|
3211
|
+
} else if (multiline) {
|
|
3212
|
+
if (rows && !maxRows && !minRows && !rowsMax && !rowsMin) {
|
|
3213
|
+
InputComponent = 'textarea';
|
|
3214
|
+
} else {
|
|
3215
|
+
inputProps = _extends({
|
|
3216
|
+
minRows: rows || minRows,
|
|
3217
|
+
rowsMax: rowsMax,
|
|
3218
|
+
maxRows: maxRows
|
|
3219
|
+
}, inputProps);
|
|
3220
|
+
InputComponent = TextareaAutosize;
|
|
3221
|
+
}
|
|
3222
|
+
} else {
|
|
3223
|
+
inputProps = _extends({
|
|
3224
|
+
type: type
|
|
3225
|
+
}, inputProps);
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
var handleAutoFill = function handleAutoFill(event) {
|
|
3229
|
+
// Provide a fake value as Chrome might not let you access it for security reasons.
|
|
3230
|
+
checkDirty(event.animationName === 'mui-auto-fill-cancel' ? inputRef.current : {
|
|
3231
|
+
value: 'x'
|
|
3232
|
+
});
|
|
3233
|
+
};
|
|
3234
|
+
|
|
3235
|
+
React$2.useEffect(function () {
|
|
3236
|
+
if (muiFormControl) {
|
|
3237
|
+
muiFormControl.setAdornedStart(Boolean(startAdornment));
|
|
3238
|
+
}
|
|
3239
|
+
}, [muiFormControl, startAdornment]);
|
|
3240
|
+
return /*#__PURE__*/React$2.createElement("div", _extends({
|
|
3241
|
+
className: clsx(classes.root, classes["color".concat(capitalize(fcs.color || 'primary'))], className, fcs.disabled && classes.disabled, fcs.error && classes.error, fullWidth && classes.fullWidth, fcs.focused && classes.focused, muiFormControl && classes.formControl, multiline && classes.multiline, startAdornment && classes.adornedStart, endAdornment && classes.adornedEnd, fcs.margin === 'dense' && classes.marginDense),
|
|
3242
|
+
onClick: handleClick,
|
|
3243
|
+
ref: ref
|
|
3244
|
+
}, other), startAdornment, /*#__PURE__*/React$2.createElement(FormControlContext.Provider, {
|
|
3245
|
+
value: null
|
|
3246
|
+
}, /*#__PURE__*/React$2.createElement(InputComponent, _extends({
|
|
3247
|
+
"aria-invalid": fcs.error,
|
|
3248
|
+
"aria-describedby": ariaDescribedby,
|
|
3249
|
+
autoComplete: autoComplete,
|
|
3250
|
+
autoFocus: autoFocus,
|
|
3251
|
+
defaultValue: defaultValue,
|
|
3252
|
+
disabled: fcs.disabled,
|
|
3253
|
+
id: id,
|
|
3254
|
+
onAnimationStart: handleAutoFill,
|
|
3255
|
+
name: name,
|
|
3256
|
+
placeholder: placeholder,
|
|
3257
|
+
readOnly: readOnly,
|
|
3258
|
+
required: fcs.required,
|
|
3259
|
+
rows: rows,
|
|
3260
|
+
value: value,
|
|
3261
|
+
onKeyDown: onKeyDown,
|
|
3262
|
+
onKeyUp: onKeyUp
|
|
3263
|
+
}, inputProps, {
|
|
3264
|
+
className: clsx(classes.input, inputPropsProp.className, fcs.disabled && classes.disabled, multiline && classes.inputMultiline, fcs.hiddenLabel && classes.inputHiddenLabel, startAdornment && classes.inputAdornedStart, endAdornment && classes.inputAdornedEnd, type === 'search' && classes.inputTypeSearch, fcs.margin === 'dense' && classes.inputMarginDense),
|
|
3265
|
+
onBlur: handleBlur,
|
|
3266
|
+
onChange: handleChange,
|
|
3267
|
+
onFocus: handleFocus
|
|
3268
|
+
}))), endAdornment, renderSuffix ? renderSuffix(_extends({}, fcs, {
|
|
3269
|
+
startAdornment: startAdornment
|
|
3270
|
+
})) : null);
|
|
3271
|
+
});
|
|
3272
|
+
var InputBase$1 = withStyles(styles$2, {
|
|
3273
|
+
name: 'MuiInputBase'
|
|
3274
|
+
})(InputBase);
|
|
3275
|
+
|
|
3276
|
+
var styles$1 = function styles(theme) {
|
|
3277
|
+
var light = theme.palette.type === 'light';
|
|
3278
|
+
var bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
|
|
3279
|
+
return {
|
|
3280
|
+
/* Styles applied to the root element. */
|
|
3281
|
+
root: {
|
|
3282
|
+
position: 'relative'
|
|
3283
|
+
},
|
|
3284
|
+
|
|
3285
|
+
/* Styles applied to the root element if the component is a descendant of `FormControl`. */
|
|
3286
|
+
formControl: {
|
|
3287
|
+
'label + &': {
|
|
3288
|
+
marginTop: 16
|
|
3289
|
+
}
|
|
3290
|
+
},
|
|
3291
|
+
|
|
3292
|
+
/* Styles applied to the root element if the component is focused. */
|
|
3293
|
+
focused: {},
|
|
3294
|
+
|
|
3295
|
+
/* Styles applied to the root element if `disabled={true}`. */
|
|
3296
|
+
disabled: {},
|
|
3297
|
+
|
|
3298
|
+
/* Styles applied to the root element if color secondary. */
|
|
3299
|
+
colorSecondary: {
|
|
3300
|
+
'&$underline:after': {
|
|
3301
|
+
borderBottomColor: theme.palette.secondary.main
|
|
3302
|
+
}
|
|
3303
|
+
},
|
|
3304
|
+
|
|
3305
|
+
/* Styles applied to the root element if `disableUnderline={false}`. */
|
|
3306
|
+
underline: {
|
|
3307
|
+
'&:after': {
|
|
3308
|
+
borderBottom: "2px solid ".concat(theme.palette.primary.main),
|
|
3309
|
+
left: 0,
|
|
3310
|
+
bottom: 0,
|
|
3311
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
3312
|
+
content: '""',
|
|
3313
|
+
position: 'absolute',
|
|
3314
|
+
right: 0,
|
|
3315
|
+
transform: 'scaleX(0)',
|
|
3316
|
+
transition: theme.transitions.create('transform', {
|
|
3317
|
+
duration: theme.transitions.duration.shorter,
|
|
3318
|
+
easing: theme.transitions.easing.easeOut
|
|
3319
|
+
}),
|
|
3320
|
+
pointerEvents: 'none' // Transparent to the hover style.
|
|
3321
|
+
|
|
3322
|
+
},
|
|
3323
|
+
'&$focused:after': {
|
|
3324
|
+
transform: 'scaleX(1)'
|
|
3325
|
+
},
|
|
3326
|
+
'&$error:after': {
|
|
3327
|
+
borderBottomColor: theme.palette.error.main,
|
|
3328
|
+
transform: 'scaleX(1)' // error is always underlined in red
|
|
3329
|
+
|
|
3330
|
+
},
|
|
3331
|
+
'&:before': {
|
|
3332
|
+
borderBottom: "1px solid ".concat(bottomLineColor),
|
|
3333
|
+
left: 0,
|
|
3334
|
+
bottom: 0,
|
|
3335
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
3336
|
+
content: '"\\00a0"',
|
|
3337
|
+
position: 'absolute',
|
|
3338
|
+
right: 0,
|
|
3339
|
+
transition: theme.transitions.create('border-bottom-color', {
|
|
3340
|
+
duration: theme.transitions.duration.shorter
|
|
3341
|
+
}),
|
|
3342
|
+
pointerEvents: 'none' // Transparent to the hover style.
|
|
3343
|
+
|
|
3344
|
+
},
|
|
3345
|
+
'&:hover:not($disabled):before': {
|
|
3346
|
+
borderBottom: "2px solid ".concat(theme.palette.text.primary),
|
|
3347
|
+
// Reset on touch devices, it doesn't add specificity
|
|
3348
|
+
'@media (hover: none)': {
|
|
3349
|
+
borderBottom: "1px solid ".concat(bottomLineColor)
|
|
3350
|
+
}
|
|
3351
|
+
},
|
|
3352
|
+
'&$disabled:before': {
|
|
3353
|
+
borderBottomStyle: 'dotted'
|
|
3354
|
+
}
|
|
3355
|
+
},
|
|
3356
|
+
|
|
3357
|
+
/* Pseudo-class applied to the root element if `error={true}`. */
|
|
3358
|
+
error: {},
|
|
3359
|
+
|
|
3360
|
+
/* Styles applied to the `input` element if `margin="dense"`. */
|
|
3361
|
+
marginDense: {},
|
|
3362
|
+
|
|
3363
|
+
/* Styles applied to the root element if `multiline={true}`. */
|
|
3364
|
+
multiline: {},
|
|
3365
|
+
|
|
3366
|
+
/* Styles applied to the root element if `fullWidth={true}`. */
|
|
3367
|
+
fullWidth: {},
|
|
3368
|
+
|
|
3369
|
+
/* Styles applied to the `input` element. */
|
|
3370
|
+
input: {},
|
|
3371
|
+
|
|
3372
|
+
/* Styles applied to the `input` element if `margin="dense"`. */
|
|
3373
|
+
inputMarginDense: {},
|
|
3374
|
+
|
|
3375
|
+
/* Styles applied to the `input` element if `multiline={true}`. */
|
|
3376
|
+
inputMultiline: {},
|
|
3377
|
+
|
|
3378
|
+
/* Styles applied to the `input` element if `type="search"`. */
|
|
3379
|
+
inputTypeSearch: {}
|
|
3380
|
+
};
|
|
3381
|
+
};
|
|
3382
|
+
var Input = /*#__PURE__*/React$2.forwardRef(function Input(props, ref) {
|
|
3383
|
+
var disableUnderline = props.disableUnderline,
|
|
3384
|
+
classes = props.classes,
|
|
3385
|
+
_props$fullWidth = props.fullWidth,
|
|
3386
|
+
fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
|
|
3387
|
+
_props$inputComponent = props.inputComponent,
|
|
3388
|
+
inputComponent = _props$inputComponent === void 0 ? 'input' : _props$inputComponent,
|
|
3389
|
+
_props$multiline = props.multiline,
|
|
3390
|
+
multiline = _props$multiline === void 0 ? false : _props$multiline,
|
|
3391
|
+
_props$type = props.type,
|
|
3392
|
+
type = _props$type === void 0 ? 'text' : _props$type,
|
|
3393
|
+
other = _objectWithoutProperties(props, ["disableUnderline", "classes", "fullWidth", "inputComponent", "multiline", "type"]);
|
|
3394
|
+
|
|
3395
|
+
return /*#__PURE__*/React$2.createElement(InputBase$1, _extends({
|
|
3396
|
+
classes: _extends({}, classes, {
|
|
3397
|
+
root: clsx(classes.root, !disableUnderline && classes.underline),
|
|
3398
|
+
underline: null
|
|
3399
|
+
}),
|
|
3400
|
+
fullWidth: fullWidth,
|
|
3401
|
+
inputComponent: inputComponent,
|
|
3402
|
+
multiline: multiline,
|
|
3403
|
+
ref: ref,
|
|
3404
|
+
type: type
|
|
3405
|
+
}, other));
|
|
3406
|
+
});
|
|
3407
|
+
Input.muiName = 'Input';
|
|
3408
|
+
var Input$1 = withStyles(styles$1, {
|
|
3409
|
+
name: 'MuiInput'
|
|
3410
|
+
})(Input);
|
|
3411
|
+
|
|
3412
|
+
var styles = function styles(theme) {
|
|
3413
|
+
return {
|
|
3414
|
+
/* Styles applied to the select component `root` class. */
|
|
3415
|
+
root: {},
|
|
3416
|
+
|
|
3417
|
+
/* Styles applied to the select component `select` class. */
|
|
3418
|
+
select: {
|
|
3419
|
+
'-moz-appearance': 'none',
|
|
3420
|
+
// Reset
|
|
3421
|
+
'-webkit-appearance': 'none',
|
|
3422
|
+
// Reset
|
|
3423
|
+
// When interacting quickly, the text can end up selected.
|
|
3424
|
+
// Native select can't be selected either.
|
|
3425
|
+
userSelect: 'none',
|
|
3426
|
+
borderRadius: 0,
|
|
3427
|
+
// Reset
|
|
3428
|
+
minWidth: 16,
|
|
3429
|
+
// So it doesn't collapse.
|
|
3430
|
+
cursor: 'pointer',
|
|
3431
|
+
'&:focus': {
|
|
3432
|
+
// Show that it's not an text input
|
|
3433
|
+
backgroundColor: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.05)',
|
|
3434
|
+
borderRadius: 0 // Reset Chrome style
|
|
3435
|
+
|
|
3436
|
+
},
|
|
3437
|
+
// Remove IE 11 arrow
|
|
3438
|
+
'&::-ms-expand': {
|
|
3439
|
+
display: 'none'
|
|
3440
|
+
},
|
|
3441
|
+
'&$disabled': {
|
|
3442
|
+
cursor: 'default'
|
|
3443
|
+
},
|
|
3444
|
+
'&[multiple]': {
|
|
3445
|
+
height: 'auto'
|
|
3446
|
+
},
|
|
3447
|
+
'&:not([multiple]) option, &:not([multiple]) optgroup': {
|
|
3448
|
+
backgroundColor: theme.palette.background.paper
|
|
3449
|
+
},
|
|
3450
|
+
'&&': {
|
|
3451
|
+
paddingRight: 24
|
|
3452
|
+
}
|
|
3453
|
+
},
|
|
3454
|
+
|
|
3455
|
+
/* Styles applied to the select component if `variant="filled"`. */
|
|
3456
|
+
filled: {
|
|
3457
|
+
'&&': {
|
|
3458
|
+
paddingRight: 32
|
|
3459
|
+
}
|
|
3460
|
+
},
|
|
3461
|
+
|
|
3462
|
+
/* Styles applied to the select component if `variant="outlined"`. */
|
|
3463
|
+
outlined: {
|
|
3464
|
+
borderRadius: theme.shape.borderRadius,
|
|
3465
|
+
'&&': {
|
|
3466
|
+
paddingRight: 32
|
|
3467
|
+
}
|
|
3468
|
+
},
|
|
3469
|
+
|
|
3470
|
+
/* Styles applied to the select component `selectMenu` class. */
|
|
3471
|
+
selectMenu: {
|
|
3472
|
+
height: 'auto',
|
|
3473
|
+
// Resets for multpile select with chips
|
|
3474
|
+
minHeight: '1.1876em',
|
|
3475
|
+
// Required for select\text-field height consistency
|
|
3476
|
+
textOverflow: 'ellipsis',
|
|
3477
|
+
whiteSpace: 'nowrap',
|
|
3478
|
+
overflow: 'hidden'
|
|
3479
|
+
},
|
|
3480
|
+
|
|
3481
|
+
/* Pseudo-class applied to the select component `disabled` class. */
|
|
3482
|
+
disabled: {},
|
|
3483
|
+
|
|
3484
|
+
/* Styles applied to the icon component. */
|
|
3485
|
+
icon: {
|
|
3486
|
+
// We use a position absolute over a flexbox in order to forward the pointer events
|
|
3487
|
+
// to the input and to support wrapping tags..
|
|
3488
|
+
position: 'absolute',
|
|
3489
|
+
right: 0,
|
|
3490
|
+
top: 'calc(50% - 12px)',
|
|
3491
|
+
// Center vertically
|
|
3492
|
+
pointerEvents: 'none',
|
|
3493
|
+
// Don't block pointer events on the select under the icon.
|
|
3494
|
+
color: theme.palette.action.active,
|
|
3495
|
+
'&$disabled': {
|
|
3496
|
+
color: theme.palette.action.disabled
|
|
3497
|
+
}
|
|
3498
|
+
},
|
|
3499
|
+
|
|
3500
|
+
/* Styles applied to the icon component if the popup is open. */
|
|
3501
|
+
iconOpen: {
|
|
3502
|
+
transform: 'rotate(180deg)'
|
|
3503
|
+
},
|
|
3504
|
+
|
|
3505
|
+
/* Styles applied to the icon component if `variant="filled"`. */
|
|
3506
|
+
iconFilled: {
|
|
3507
|
+
right: 7
|
|
3508
|
+
},
|
|
3509
|
+
|
|
3510
|
+
/* Styles applied to the icon component if `variant="outlined"`. */
|
|
3511
|
+
iconOutlined: {
|
|
3512
|
+
right: 7
|
|
3513
|
+
},
|
|
3514
|
+
|
|
3515
|
+
/* Styles applied to the underlying native input component. */
|
|
3516
|
+
nativeInput: {
|
|
3517
|
+
bottom: 0,
|
|
3518
|
+
left: 0,
|
|
3519
|
+
position: 'absolute',
|
|
3520
|
+
opacity: 0,
|
|
3521
|
+
pointerEvents: 'none',
|
|
3522
|
+
width: '100%'
|
|
3523
|
+
}
|
|
3524
|
+
};
|
|
3525
|
+
};
|
|
3526
|
+
var defaultInput = /*#__PURE__*/React$2.createElement(Input$1, null);
|
|
3527
|
+
/**
|
|
3528
|
+
* An alternative to `<Select native />` with a much smaller bundle size footprint.
|
|
3529
|
+
*/
|
|
3530
|
+
|
|
3531
|
+
var NativeSelect = /*#__PURE__*/React$2.forwardRef(function NativeSelect(props, ref) {
|
|
3532
|
+
var children = props.children,
|
|
3533
|
+
classes = props.classes,
|
|
3534
|
+
_props$IconComponent = props.IconComponent,
|
|
3535
|
+
IconComponent = _props$IconComponent === void 0 ? ArrowDropDownIcon : _props$IconComponent,
|
|
3536
|
+
_props$input = props.input,
|
|
3537
|
+
input = _props$input === void 0 ? defaultInput : _props$input,
|
|
3538
|
+
inputProps = props.inputProps;
|
|
3539
|
+
props.variant;
|
|
3540
|
+
var other = _objectWithoutProperties(props, ["children", "classes", "IconComponent", "input", "inputProps", "variant"]);
|
|
3541
|
+
|
|
3542
|
+
var muiFormControl = useFormControl();
|
|
3543
|
+
var fcs = formControlState({
|
|
3544
|
+
props: props,
|
|
3545
|
+
muiFormControl: muiFormControl,
|
|
3546
|
+
states: ['variant']
|
|
3547
|
+
});
|
|
3548
|
+
return /*#__PURE__*/React$2.cloneElement(input, _extends({
|
|
3549
|
+
// Most of the logic is implemented in `NativeSelectInput`.
|
|
3550
|
+
// The `Select` component is a simple API wrapper to expose something better to play with.
|
|
3551
|
+
inputComponent: NativeSelectInput,
|
|
3552
|
+
inputProps: _extends({
|
|
3553
|
+
children: children,
|
|
3554
|
+
classes: classes,
|
|
3555
|
+
IconComponent: IconComponent,
|
|
3556
|
+
variant: fcs.variant,
|
|
3557
|
+
type: undefined
|
|
3558
|
+
}, inputProps, input ? input.props.inputProps : {}),
|
|
3559
|
+
ref: ref
|
|
3560
|
+
}, other));
|
|
3561
|
+
});
|
|
3562
|
+
NativeSelect.muiName = 'Select';
|
|
3563
|
+
var NativeSelect$1 = withStyles(styles, {
|
|
3564
|
+
name: 'MuiNativeSelect'
|
|
3565
|
+
})(NativeSelect);
|
|
3566
|
+
|
|
3567
|
+
var ArrowLeft = {};
|
|
3568
|
+
|
|
3569
|
+
var _interopRequireDefault$1 = interopRequireDefault.exports;
|
|
3570
|
+
|
|
3571
|
+
var _interopRequireWildcard$1 = interopRequireWildcard.exports;
|
|
3572
|
+
|
|
3573
|
+
Object.defineProperty(ArrowLeft, "__esModule", {
|
|
3574
|
+
value: true
|
|
3575
|
+
});
|
|
3576
|
+
var default_1$1 = ArrowLeft.default = void 0;
|
|
3577
|
+
|
|
3578
|
+
var React$1 = _interopRequireWildcard$1(React__default);
|
|
3579
|
+
|
|
3580
|
+
var _createSvgIcon$1 = _interopRequireDefault$1(requireCreateSvgIcon());
|
|
3581
|
+
|
|
3582
|
+
var _default$1 = (0, _createSvgIcon$1.default)( /*#__PURE__*/React$1.createElement("path", {
|
|
3583
|
+
d: "M14 7l-5 5 5 5V7z"
|
|
3584
|
+
}), 'ArrowLeft');
|
|
3585
|
+
|
|
3586
|
+
default_1$1 = ArrowLeft.default = _default$1;
|
|
3587
|
+
|
|
3588
|
+
var ArrowRight = {};
|
|
3589
|
+
|
|
3590
|
+
var _interopRequireDefault = interopRequireDefault.exports;
|
|
3591
|
+
|
|
3592
|
+
var _interopRequireWildcard = interopRequireWildcard.exports;
|
|
3593
|
+
|
|
3594
|
+
Object.defineProperty(ArrowRight, "__esModule", {
|
|
3595
|
+
value: true
|
|
3596
|
+
});
|
|
3597
|
+
var default_1 = ArrowRight.default = void 0;
|
|
3598
|
+
|
|
3599
|
+
var React = _interopRequireWildcard(React__default);
|
|
3600
|
+
|
|
3601
|
+
var _createSvgIcon = _interopRequireDefault(requireCreateSvgIcon());
|
|
3602
|
+
|
|
3603
|
+
var _default = (0, _createSvgIcon.default)( /*#__PURE__*/React.createElement("path", {
|
|
3604
|
+
d: "M10 17l5-5-5-5v10z"
|
|
3605
|
+
}), 'ArrowRight');
|
|
3606
|
+
|
|
3607
|
+
default_1 = ArrowRight.default = _default;
|
|
3608
|
+
|
|
3609
|
+
var css_248z = ".ntml-pagination__center {\n display: flex;\n justify-content: center; }\n .ntml-pagination__center .MuiSvgIcon-colorSecondary {\n color: #509891; }\n\n.ntml-pagination__rightSide {\n position: relative;\n float: right;\n top: -36px; }\n .ntml-pagination__rightSide-showTotal {\n display: flex;\n align-items: center; }\n .ntml-pagination__rightSide-showTotal .MuiInput-root {\n width: 90px;\n height: 34px;\n margin: 0 8px;\n padding: 2px 8px 3px 20px;\n border-radius: 17px;\n background-color: rgba(222, 219, 202, 0.4);\n border: 0px; }\n .ntml-pagination__rightSide-showTotal .MuiNativeSelect-icon {\n color: #509891; }\n .ntml-pagination__rightSide-showTotal .MuiNativeSelect-select:not([multiple]) option,\n .ntml-pagination__rightSide-showTotal .MuiNativeSelect-select:not([multiple]) optgroup {\n background-color: rgba(222, 219, 202, 0.4); }\n\n@media only screen and (max-width: 767px) {\n .ntml-pagination__center-page {\n width: 48px;\n height: 48px;\n display: flex;\n background-color: rgba(222, 219, 202, 0.4);\n border-radius: 50%;\n align-items: center;\n justify-content: center; }\n .ntml-pagination__rightSide {\n position: relative;\n float: initial;\n top: 0;\n display: flex;\n justify-content: center;\n margin-top: 28px; } }\n";
|
|
3610
|
+
styleInject(css_248z);
|
|
3611
|
+
|
|
3612
|
+
var _excluded = ["className", "pageSize", "total", "onChange"];
|
|
3613
|
+
var Pagination = function Pagination(_ref) {
|
|
3614
|
+
var className = _ref.className,
|
|
3615
|
+
pageSize = _ref.pageSize,
|
|
3616
|
+
total = _ref.total,
|
|
3617
|
+
_onChange = _ref.onChange,
|
|
3618
|
+
props = _objectWithoutProperties$1(_ref, _excluded);
|
|
3619
|
+
var count = Math.ceil(total / pageSize);
|
|
3620
|
+
var pages = Array.from(Array(count).keys(), function (x) {
|
|
3621
|
+
return x + 1;
|
|
3622
|
+
});
|
|
3623
|
+
|
|
3624
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
3625
|
+
var current = Number.parseInt(props.current, 10) || 1;
|
|
3626
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
3627
|
+
var defaultCurrent = Number.parseInt(props.defaultCurrent, 10) || 1;
|
|
3628
|
+
var handlePageSelected = function handlePageSelected(event) {
|
|
3629
|
+
var page = Number.parseInt(event.target.value, 10);
|
|
3630
|
+
_onChange(page);
|
|
3631
|
+
};
|
|
3632
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
3633
|
+
className: classNames('ntml-pagination', className)
|
|
3634
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3635
|
+
className: "ntml-pagination__center"
|
|
3636
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3637
|
+
style: {
|
|
3638
|
+
display: 'flex',
|
|
3639
|
+
alignItems: 'center'
|
|
3640
|
+
}
|
|
3641
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
3642
|
+
disabled: current === 1,
|
|
3643
|
+
onClick: function onClick() {
|
|
3644
|
+
return _onChange(current - 1);
|
|
3645
|
+
}
|
|
3646
|
+
}, /*#__PURE__*/React__default.createElement(default_1$1, {
|
|
3647
|
+
color: "secondary"
|
|
3648
|
+
})), /*#__PURE__*/React__default.createElement(MUIPagination, {
|
|
3649
|
+
color: "secondary",
|
|
3650
|
+
count: count,
|
|
3651
|
+
boundaryCount: 1,
|
|
3652
|
+
siblingCount: 0,
|
|
3653
|
+
page: current,
|
|
3654
|
+
defaultPage: defaultCurrent,
|
|
3655
|
+
hideNextButton: true,
|
|
3656
|
+
hidePrevButton: true,
|
|
3657
|
+
onChange: function onChange(event, value) {
|
|
3658
|
+
return _onChange(value);
|
|
3659
|
+
}
|
|
3660
|
+
}), /*#__PURE__*/React__default.createElement(IconButton, {
|
|
3661
|
+
disabled: current === count,
|
|
3662
|
+
onClick: function onClick() {
|
|
3663
|
+
return _onChange(current + 1);
|
|
3664
|
+
}
|
|
3665
|
+
}, /*#__PURE__*/React__default.createElement(default_1, {
|
|
3666
|
+
color: "secondary"
|
|
3667
|
+
})))), /*#__PURE__*/React__default.createElement("div", {
|
|
3668
|
+
className: "ntml-pagination__rightSide"
|
|
3669
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3670
|
+
className: "ntml-pagination__rightSide-showTotal"
|
|
3671
|
+
}, /*#__PURE__*/React__default.createElement("span", null, "\u76EE\u524D\u5728\u7B2C"), /*#__PURE__*/React__default.createElement(NativeSelect$1, {
|
|
3672
|
+
value: current,
|
|
3673
|
+
onChange: handlePageSelected
|
|
3674
|
+
}, pages.map(function (page, idx) {
|
|
3675
|
+
return /*#__PURE__*/React__default.createElement("option", {
|
|
3676
|
+
value: page,
|
|
3677
|
+
key: idx.toString()
|
|
3678
|
+
}, page);
|
|
3679
|
+
})), /*#__PURE__*/React__default.createElement("span", null, "\u9801\uFF0C\u5171"), count, /*#__PURE__*/React__default.createElement("span", null, "\u9801"))));
|
|
3680
|
+
};
|
|
3681
|
+
Pagination.defaultProps = {
|
|
3682
|
+
className: undefined,
|
|
3683
|
+
current: undefined,
|
|
3684
|
+
defaultCurrent: 1,
|
|
3685
|
+
pageSize: 10,
|
|
3686
|
+
total: undefined,
|
|
3687
|
+
onChange: undefined
|
|
3688
|
+
};
|
|
3689
|
+
|
|
3690
|
+
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
3691
|
+
Pagination.propTypes = {
|
|
3692
|
+
/** Css Name */
|
|
3693
|
+
className: PropTypes.string,
|
|
3694
|
+
/** 当前页数 */
|
|
3695
|
+
current: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
3696
|
+
/** 默认的当前页数 */
|
|
3697
|
+
defaultCurrent: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
3698
|
+
/** 每页条数 */
|
|
3699
|
+
pageSize: PropTypes.number,
|
|
3700
|
+
/** 数据总数 */
|
|
3701
|
+
total: PropTypes.number,
|
|
3702
|
+
/** 页码或 pageSize 改变的回调,参数是改变后的页码及每页条数 */
|
|
3703
|
+
onChange: PropTypes.func
|
|
3704
|
+
};
|
|
3705
|
+
|
|
3706
|
+
export { Pagination as default };
|