@gravity-ui/navigation 3.0.0-beta.2 → 3.0.0-beta.4
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/build/cjs/{index-B6c8DVdr.js → index-D5mnpi6c.js} +8 -8
- package/build/cjs/{index-B6c8DVdr.js.map → index-D5mnpi6c.js.map} +1 -1
- package/build/cjs/index-DOLqlMz4.js +5732 -0
- package/build/cjs/index-DOLqlMz4.js.map +1 -0
- package/build/cjs/index.js +28 -4
- package/build/cjs/index.js.map +1 -1
- package/build/esm/{index-BLdwsphX.js → index-CO69JxhQ.js} +5 -5
- package/build/esm/{index-BLdwsphX.js.map → index-CO69JxhQ.js.map} +1 -1
- package/build/esm/index-Cj3tqMQo.js +5687 -0
- package/build/esm/index-Cj3tqMQo.js.map +1 -0
- package/build/esm/index.js +5 -3
- package/build/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/build/cjs/ActionBar-_qjZ9IMA.js +0 -59
- package/build/cjs/ActionBar-_qjZ9IMA.js.map +0 -1
- package/build/cjs/AsideFallback.js +0 -25
- package/build/cjs/AsideFallback.js.map +0 -1
- package/build/cjs/AsideHeader.js +0 -33
- package/build/cjs/AsideHeader.js.map +0 -1
- package/build/cjs/AsideHeaderContext.js +0 -38
- package/build/cjs/AsideHeaderContext.js.map +0 -1
- package/build/cjs/Content-Dy2XkiRi.js +0 -16
- package/build/cjs/Content-Dy2XkiRi.js.map +0 -1
- package/build/cjs/Drawer.js +0 -2493
- package/build/cjs/Drawer.js.map +0 -1
- package/build/cjs/FooterItem-CLk0aHrc.js +0 -332
- package/build/cjs/FooterItem-CLk0aHrc.js.map +0 -1
- package/build/cjs/FooterItem.js +0 -26
- package/build/cjs/FooterItem.js.map +0 -1
- package/build/cjs/HotkeysPanel-C436myZY.js +0 -63
- package/build/cjs/HotkeysPanel-C436myZY.js.map +0 -1
- package/build/cjs/Item-CLHysLDd.js +0 -328
- package/build/cjs/Item-CLHysLDd.js.map +0 -1
- package/build/cjs/PageLayout.js +0 -34
- package/build/cjs/PageLayout.js.map +0 -1
- package/build/cjs/PageLayoutAside-SMHlPBAO.js +0 -979
- package/build/cjs/PageLayoutAside-SMHlPBAO.js.map +0 -1
- package/build/cjs/PageLayoutAside.js +0 -24
- package/build/cjs/PageLayoutAside.js.map +0 -1
- package/build/cjs/Settings-x0a3P0Vr.js +0 -586
- package/build/cjs/Settings-x0a3P0Vr.js.map +0 -1
- package/build/cjs/Title-CzxcSMoP.js +0 -36
- package/build/cjs/Title-CzxcSMoP.js.map +0 -1
- package/build/cjs/_commonjsHelpers-BJu3ubxk.js +0 -11
- package/build/cjs/_commonjsHelpers-BJu3ubxk.js.map +0 -1
- package/build/cjs/cn-DSlPZbcs.js +0 -11
- package/build/cjs/cn-DSlPZbcs.js.map +0 -1
- package/build/cjs/constants-B0DLAQY9.js +0 -14
- package/build/cjs/constants-B0DLAQY9.js.map +0 -1
- package/build/cjs/debounce-RFF04eVR.js +0 -660
- package/build/cjs/debounce-RFF04eVR.js.map +0 -1
- package/build/cjs/divider-collapsed-BLSp99lJ.js +0 -39
- package/build/cjs/divider-collapsed-BLSp99lJ.js.map +0 -1
- package/build/cjs/index2.js +0 -15
- package/build/cjs/index2.js.map +0 -1
- package/build/cjs/index3.js +0 -17
- package/build/cjs/index3.js.map +0 -1
- package/build/cjs/index4.js +0 -21
- package/build/cjs/index4.js.map +0 -1
- package/build/cjs/index5.js +0 -22
- package/build/cjs/index5.js.map +0 -1
- package/build/cjs/index6.js +0 -194
- package/build/cjs/index6.js.map +0 -1
- package/build/cjs/style-inject.es-CsU6UJbw.js +0 -31
- package/build/cjs/style-inject.es-CsU6UJbw.js.map +0 -1
- package/build/cjs/tslib.es6-D25eJ2i9.js +0 -38
- package/build/cjs/tslib.es6-D25eJ2i9.js.map +0 -1
- package/build/cjs/utils-BrRoop7o.js +0 -8
- package/build/cjs/utils-BrRoop7o.js.map +0 -1
- package/build/esm/ActionBar-BD_roj92.js +0 -57
- package/build/esm/ActionBar-BD_roj92.js.map +0 -1
- package/build/esm/AsideFallback.js +0 -23
- package/build/esm/AsideFallback.js.map +0 -1
- package/build/esm/AsideHeader.js +0 -31
- package/build/esm/AsideHeader.js.map +0 -1
- package/build/esm/AsideHeaderContext.js +0 -31
- package/build/esm/AsideHeaderContext.js.map +0 -1
- package/build/esm/Content-c3e3OunO.js +0 -14
- package/build/esm/Content-c3e3OunO.js.map +0 -1
- package/build/esm/Drawer.js +0 -2472
- package/build/esm/Drawer.js.map +0 -1
- package/build/esm/FooterItem-DuFjLZPI.js +0 -326
- package/build/esm/FooterItem-DuFjLZPI.js.map +0 -1
- package/build/esm/FooterItem.js +0 -24
- package/build/esm/FooterItem.js.map +0 -1
- package/build/esm/HotkeysPanel-BWL1Xkqi.js +0 -61
- package/build/esm/HotkeysPanel-BWL1Xkqi.js.map +0 -1
- package/build/esm/Item-BU0M-jfC.js +0 -318
- package/build/esm/Item-BU0M-jfC.js.map +0 -1
- package/build/esm/PageLayout.js +0 -32
- package/build/esm/PageLayout.js.map +0 -1
- package/build/esm/PageLayoutAside-Bd3aJNrH.js +0 -958
- package/build/esm/PageLayoutAside-Bd3aJNrH.js.map +0 -1
- package/build/esm/PageLayoutAside.js +0 -18
- package/build/esm/PageLayoutAside.js.map +0 -1
- package/build/esm/Settings-BC6Kmplf.js +0 -564
- package/build/esm/Settings-BC6Kmplf.js.map +0 -1
- package/build/esm/Title-CRlzgg4r.js +0 -34
- package/build/esm/Title-CRlzgg4r.js.map +0 -1
- package/build/esm/_commonjsHelpers-BFTU3MAI.js +0 -8
- package/build/esm/_commonjsHelpers-BFTU3MAI.js.map +0 -1
- package/build/esm/cn-CgiqTV3v.js +0 -8
- package/build/esm/cn-CgiqTV3v.js.map +0 -1
- package/build/esm/constants-ChYDZ5F2.js +0 -8
- package/build/esm/constants-ChYDZ5F2.js.map +0 -1
- package/build/esm/debounce-DW3XyyUs.js +0 -658
- package/build/esm/debounce-DW3XyyUs.js.map +0 -1
- package/build/esm/divider-collapsed-BgKmR8h9.js +0 -18
- package/build/esm/divider-collapsed-BgKmR8h9.js.map +0 -1
- package/build/esm/index2.js +0 -9
- package/build/esm/index2.js.map +0 -1
- package/build/esm/index3.js +0 -11
- package/build/esm/index3.js.map +0 -1
- package/build/esm/index4.js +0 -13
- package/build/esm/index4.js.map +0 -1
- package/build/esm/index5.js +0 -13
- package/build/esm/index5.js.map +0 -1
- package/build/esm/index6.js +0 -171
- package/build/esm/index6.js.map +0 -1
- package/build/esm/style-inject.es-Bff-fD1R.js +0 -29
- package/build/esm/style-inject.es-Bff-fD1R.js.map +0 -1
- package/build/esm/tslib.es6-BCqiemNI.js +0 -36
- package/build/esm/tslib.es6-BCqiemNI.js.map +0 -1
- package/build/esm/utils-D0s6YtvW.js +0 -6
- package/build/esm/utils-D0s6YtvW.js.map +0 -1
package/build/cjs/Drawer.js
DELETED
|
@@ -1,2493 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var uikit = require('@gravity-ui/uikit');
|
|
5
|
-
var cn = require('./cn-DSlPZbcs.js');
|
|
6
|
-
var styleInject_es = require('./style-inject.es-CsU6UJbw.js');
|
|
7
|
-
var _commonjsHelpers = require('./_commonjsHelpers-BJu3ubxk.js');
|
|
8
|
-
var ReactDOM = require('react-dom');
|
|
9
|
-
require('@bem-react/classname');
|
|
10
|
-
|
|
11
|
-
function _interopNamespaceDefault(e) {
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n.default = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
29
|
-
|
|
30
|
-
function _extends() {
|
|
31
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
32
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
33
|
-
var t = arguments[e];
|
|
34
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
35
|
-
}
|
|
36
|
-
return n;
|
|
37
|
-
}, _extends.apply(null, arguments);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
41
|
-
if (null == r) return {};
|
|
42
|
-
var t = {};
|
|
43
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
44
|
-
if (e.indexOf(n) >= 0) continue;
|
|
45
|
-
t[n] = r[n];
|
|
46
|
-
}
|
|
47
|
-
return t;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _setPrototypeOf(t, e) {
|
|
51
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
52
|
-
return t.__proto__ = e, t;
|
|
53
|
-
}, _setPrototypeOf(t, e);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _inheritsLoose(t, o) {
|
|
57
|
-
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var propTypes = {exports: {}};
|
|
61
|
-
|
|
62
|
-
var reactIs = {exports: {}};
|
|
63
|
-
|
|
64
|
-
var reactIs_production_min = {};
|
|
65
|
-
|
|
66
|
-
/** @license React v16.13.1
|
|
67
|
-
* react-is.production.min.js
|
|
68
|
-
*
|
|
69
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
70
|
-
*
|
|
71
|
-
* This source code is licensed under the MIT license found in the
|
|
72
|
-
* LICENSE file in the root directory of this source tree.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
var hasRequiredReactIs_production_min;
|
|
76
|
-
|
|
77
|
-
function requireReactIs_production_min () {
|
|
78
|
-
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
79
|
-
hasRequiredReactIs_production_min = 1;
|
|
80
|
-
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
81
|
-
Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
|
|
82
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n;reactIs_production_min.Fragment=e;reactIs_production_min.Lazy=t;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
|
|
83
|
-
reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n};reactIs_production_min.isFragment=function(a){return z(a)===e};reactIs_production_min.isLazy=function(a){return z(a)===t};
|
|
84
|
-
reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
|
|
85
|
-
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
|
|
86
|
-
return reactIs_production_min;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
var reactIs_development = {};
|
|
90
|
-
|
|
91
|
-
/** @license React v16.13.1
|
|
92
|
-
* react-is.development.js
|
|
93
|
-
*
|
|
94
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
95
|
-
*
|
|
96
|
-
* This source code is licensed under the MIT license found in the
|
|
97
|
-
* LICENSE file in the root directory of this source tree.
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
var hasRequiredReactIs_development;
|
|
101
|
-
|
|
102
|
-
function requireReactIs_development () {
|
|
103
|
-
if (hasRequiredReactIs_development) return reactIs_development;
|
|
104
|
-
hasRequiredReactIs_development = 1;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (process.env.NODE_ENV !== "production") {
|
|
109
|
-
(function() {
|
|
110
|
-
|
|
111
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
112
|
-
// nor polyfill, then a plain number is used for performance.
|
|
113
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
114
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
115
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
116
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
117
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
118
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
119
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
120
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
121
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
122
|
-
|
|
123
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
124
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
125
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
126
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
127
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
128
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
129
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
130
|
-
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
131
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
132
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
133
|
-
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
134
|
-
|
|
135
|
-
function isValidElementType(type) {
|
|
136
|
-
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
137
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function typeOf(object) {
|
|
141
|
-
if (typeof object === 'object' && object !== null) {
|
|
142
|
-
var $$typeof = object.$$typeof;
|
|
143
|
-
|
|
144
|
-
switch ($$typeof) {
|
|
145
|
-
case REACT_ELEMENT_TYPE:
|
|
146
|
-
var type = object.type;
|
|
147
|
-
|
|
148
|
-
switch (type) {
|
|
149
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
150
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
151
|
-
case REACT_FRAGMENT_TYPE:
|
|
152
|
-
case REACT_PROFILER_TYPE:
|
|
153
|
-
case REACT_STRICT_MODE_TYPE:
|
|
154
|
-
case REACT_SUSPENSE_TYPE:
|
|
155
|
-
return type;
|
|
156
|
-
|
|
157
|
-
default:
|
|
158
|
-
var $$typeofType = type && type.$$typeof;
|
|
159
|
-
|
|
160
|
-
switch ($$typeofType) {
|
|
161
|
-
case REACT_CONTEXT_TYPE:
|
|
162
|
-
case REACT_FORWARD_REF_TYPE:
|
|
163
|
-
case REACT_LAZY_TYPE:
|
|
164
|
-
case REACT_MEMO_TYPE:
|
|
165
|
-
case REACT_PROVIDER_TYPE:
|
|
166
|
-
return $$typeofType;
|
|
167
|
-
|
|
168
|
-
default:
|
|
169
|
-
return $$typeof;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
case REACT_PORTAL_TYPE:
|
|
175
|
-
return $$typeof;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return undefined;
|
|
180
|
-
} // AsyncMode is deprecated along with isAsyncMode
|
|
181
|
-
|
|
182
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
183
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
184
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
185
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
186
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
187
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
188
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
189
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
190
|
-
var Memo = REACT_MEMO_TYPE;
|
|
191
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
192
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
193
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
194
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
195
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
196
|
-
|
|
197
|
-
function isAsyncMode(object) {
|
|
198
|
-
{
|
|
199
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
200
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
201
|
-
|
|
202
|
-
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
207
|
-
}
|
|
208
|
-
function isConcurrentMode(object) {
|
|
209
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
210
|
-
}
|
|
211
|
-
function isContextConsumer(object) {
|
|
212
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
213
|
-
}
|
|
214
|
-
function isContextProvider(object) {
|
|
215
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
216
|
-
}
|
|
217
|
-
function isElement(object) {
|
|
218
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
219
|
-
}
|
|
220
|
-
function isForwardRef(object) {
|
|
221
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
222
|
-
}
|
|
223
|
-
function isFragment(object) {
|
|
224
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
225
|
-
}
|
|
226
|
-
function isLazy(object) {
|
|
227
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
228
|
-
}
|
|
229
|
-
function isMemo(object) {
|
|
230
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
231
|
-
}
|
|
232
|
-
function isPortal(object) {
|
|
233
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
234
|
-
}
|
|
235
|
-
function isProfiler(object) {
|
|
236
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
237
|
-
}
|
|
238
|
-
function isStrictMode(object) {
|
|
239
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
240
|
-
}
|
|
241
|
-
function isSuspense(object) {
|
|
242
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
reactIs_development.AsyncMode = AsyncMode;
|
|
246
|
-
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
247
|
-
reactIs_development.ContextConsumer = ContextConsumer;
|
|
248
|
-
reactIs_development.ContextProvider = ContextProvider;
|
|
249
|
-
reactIs_development.Element = Element;
|
|
250
|
-
reactIs_development.ForwardRef = ForwardRef;
|
|
251
|
-
reactIs_development.Fragment = Fragment;
|
|
252
|
-
reactIs_development.Lazy = Lazy;
|
|
253
|
-
reactIs_development.Memo = Memo;
|
|
254
|
-
reactIs_development.Portal = Portal;
|
|
255
|
-
reactIs_development.Profiler = Profiler;
|
|
256
|
-
reactIs_development.StrictMode = StrictMode;
|
|
257
|
-
reactIs_development.Suspense = Suspense;
|
|
258
|
-
reactIs_development.isAsyncMode = isAsyncMode;
|
|
259
|
-
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
260
|
-
reactIs_development.isContextConsumer = isContextConsumer;
|
|
261
|
-
reactIs_development.isContextProvider = isContextProvider;
|
|
262
|
-
reactIs_development.isElement = isElement;
|
|
263
|
-
reactIs_development.isForwardRef = isForwardRef;
|
|
264
|
-
reactIs_development.isFragment = isFragment;
|
|
265
|
-
reactIs_development.isLazy = isLazy;
|
|
266
|
-
reactIs_development.isMemo = isMemo;
|
|
267
|
-
reactIs_development.isPortal = isPortal;
|
|
268
|
-
reactIs_development.isProfiler = isProfiler;
|
|
269
|
-
reactIs_development.isStrictMode = isStrictMode;
|
|
270
|
-
reactIs_development.isSuspense = isSuspense;
|
|
271
|
-
reactIs_development.isValidElementType = isValidElementType;
|
|
272
|
-
reactIs_development.typeOf = typeOf;
|
|
273
|
-
})();
|
|
274
|
-
}
|
|
275
|
-
return reactIs_development;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
var hasRequiredReactIs;
|
|
279
|
-
|
|
280
|
-
function requireReactIs () {
|
|
281
|
-
if (hasRequiredReactIs) return reactIs.exports;
|
|
282
|
-
hasRequiredReactIs = 1;
|
|
283
|
-
|
|
284
|
-
if (process.env.NODE_ENV === 'production') {
|
|
285
|
-
reactIs.exports = requireReactIs_production_min();
|
|
286
|
-
} else {
|
|
287
|
-
reactIs.exports = requireReactIs_development();
|
|
288
|
-
}
|
|
289
|
-
return reactIs.exports;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/*
|
|
293
|
-
object-assign
|
|
294
|
-
(c) Sindre Sorhus
|
|
295
|
-
@license MIT
|
|
296
|
-
*/
|
|
297
|
-
|
|
298
|
-
var objectAssign;
|
|
299
|
-
var hasRequiredObjectAssign;
|
|
300
|
-
|
|
301
|
-
function requireObjectAssign () {
|
|
302
|
-
if (hasRequiredObjectAssign) return objectAssign;
|
|
303
|
-
hasRequiredObjectAssign = 1;
|
|
304
|
-
/* eslint-disable no-unused-vars */
|
|
305
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
306
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
307
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
308
|
-
|
|
309
|
-
function toObject(val) {
|
|
310
|
-
if (val === null || val === undefined) {
|
|
311
|
-
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return Object(val);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function shouldUseNative() {
|
|
318
|
-
try {
|
|
319
|
-
if (!Object.assign) {
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// Detect buggy property enumeration order in older V8 versions.
|
|
324
|
-
|
|
325
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
326
|
-
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
327
|
-
test1[5] = 'de';
|
|
328
|
-
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
333
|
-
var test2 = {};
|
|
334
|
-
for (var i = 0; i < 10; i++) {
|
|
335
|
-
test2['_' + String.fromCharCode(i)] = i;
|
|
336
|
-
}
|
|
337
|
-
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
338
|
-
return test2[n];
|
|
339
|
-
});
|
|
340
|
-
if (order2.join('') !== '0123456789') {
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
345
|
-
var test3 = {};
|
|
346
|
-
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
347
|
-
test3[letter] = letter;
|
|
348
|
-
});
|
|
349
|
-
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
350
|
-
'abcdefghijklmnopqrst') {
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return true;
|
|
355
|
-
} catch (err) {
|
|
356
|
-
// We don't expect any of the above to throw, but better to be safe.
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
362
|
-
var from;
|
|
363
|
-
var to = toObject(target);
|
|
364
|
-
var symbols;
|
|
365
|
-
|
|
366
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
367
|
-
from = Object(arguments[s]);
|
|
368
|
-
|
|
369
|
-
for (var key in from) {
|
|
370
|
-
if (hasOwnProperty.call(from, key)) {
|
|
371
|
-
to[key] = from[key];
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (getOwnPropertySymbols) {
|
|
376
|
-
symbols = getOwnPropertySymbols(from);
|
|
377
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
378
|
-
if (propIsEnumerable.call(from, symbols[i])) {
|
|
379
|
-
to[symbols[i]] = from[symbols[i]];
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
return to;
|
|
386
|
-
};
|
|
387
|
-
return objectAssign;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
392
|
-
*
|
|
393
|
-
* This source code is licensed under the MIT license found in the
|
|
394
|
-
* LICENSE file in the root directory of this source tree.
|
|
395
|
-
*/
|
|
396
|
-
|
|
397
|
-
var ReactPropTypesSecret_1;
|
|
398
|
-
var hasRequiredReactPropTypesSecret;
|
|
399
|
-
|
|
400
|
-
function requireReactPropTypesSecret () {
|
|
401
|
-
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
|
402
|
-
hasRequiredReactPropTypesSecret = 1;
|
|
403
|
-
|
|
404
|
-
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
405
|
-
|
|
406
|
-
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
407
|
-
return ReactPropTypesSecret_1;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
var has;
|
|
411
|
-
var hasRequiredHas;
|
|
412
|
-
|
|
413
|
-
function requireHas () {
|
|
414
|
-
if (hasRequiredHas) return has;
|
|
415
|
-
hasRequiredHas = 1;
|
|
416
|
-
has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
417
|
-
return has;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
422
|
-
*
|
|
423
|
-
* This source code is licensed under the MIT license found in the
|
|
424
|
-
* LICENSE file in the root directory of this source tree.
|
|
425
|
-
*/
|
|
426
|
-
|
|
427
|
-
var checkPropTypes_1;
|
|
428
|
-
var hasRequiredCheckPropTypes;
|
|
429
|
-
|
|
430
|
-
function requireCheckPropTypes () {
|
|
431
|
-
if (hasRequiredCheckPropTypes) return checkPropTypes_1;
|
|
432
|
-
hasRequiredCheckPropTypes = 1;
|
|
433
|
-
|
|
434
|
-
var printWarning = function() {};
|
|
435
|
-
|
|
436
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
437
|
-
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
438
|
-
var loggedTypeFailures = {};
|
|
439
|
-
var has = /*@__PURE__*/ requireHas();
|
|
440
|
-
|
|
441
|
-
printWarning = function(text) {
|
|
442
|
-
var message = 'Warning: ' + text;
|
|
443
|
-
if (typeof console !== 'undefined') {
|
|
444
|
-
console.error(message);
|
|
445
|
-
}
|
|
446
|
-
try {
|
|
447
|
-
// --- Welcome to debugging React ---
|
|
448
|
-
// This error was thrown as a convenience so that you can use this stack
|
|
449
|
-
// to find the callsite that caused this warning to fire.
|
|
450
|
-
throw new Error(message);
|
|
451
|
-
} catch (x) { /**/ }
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Assert that the values match with the type specs.
|
|
457
|
-
* Error messages are memorized and will only be shown once.
|
|
458
|
-
*
|
|
459
|
-
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
460
|
-
* @param {object} values Runtime values that need to be type-checked
|
|
461
|
-
* @param {string} location e.g. "prop", "context", "child context"
|
|
462
|
-
* @param {string} componentName Name of the component for error messages.
|
|
463
|
-
* @param {?Function} getStack Returns the component stack.
|
|
464
|
-
* @private
|
|
465
|
-
*/
|
|
466
|
-
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
467
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
468
|
-
for (var typeSpecName in typeSpecs) {
|
|
469
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
470
|
-
var error;
|
|
471
|
-
// Prop type validation may throw. In case they do, we don't want to
|
|
472
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
473
|
-
// After these have been cleaned up, we'll let them throw.
|
|
474
|
-
try {
|
|
475
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
476
|
-
// behavior as without this statement except with a better message.
|
|
477
|
-
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
478
|
-
var err = Error(
|
|
479
|
-
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
480
|
-
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
|
|
481
|
-
'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
|
|
482
|
-
);
|
|
483
|
-
err.name = 'Invariant Violation';
|
|
484
|
-
throw err;
|
|
485
|
-
}
|
|
486
|
-
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
487
|
-
} catch (ex) {
|
|
488
|
-
error = ex;
|
|
489
|
-
}
|
|
490
|
-
if (error && !(error instanceof Error)) {
|
|
491
|
-
printWarning(
|
|
492
|
-
(componentName || 'React class') + ': type specification of ' +
|
|
493
|
-
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
494
|
-
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
495
|
-
'You may have forgotten to pass an argument to the type checker ' +
|
|
496
|
-
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
497
|
-
'shape all require an argument).'
|
|
498
|
-
);
|
|
499
|
-
}
|
|
500
|
-
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
501
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
502
|
-
// same error.
|
|
503
|
-
loggedTypeFailures[error.message] = true;
|
|
504
|
-
|
|
505
|
-
var stack = getStack ? getStack() : '';
|
|
506
|
-
|
|
507
|
-
printWarning(
|
|
508
|
-
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Resets warning cache when testing.
|
|
518
|
-
*
|
|
519
|
-
* @private
|
|
520
|
-
*/
|
|
521
|
-
checkPropTypes.resetWarningCache = function() {
|
|
522
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
523
|
-
loggedTypeFailures = {};
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
checkPropTypes_1 = checkPropTypes;
|
|
528
|
-
return checkPropTypes_1;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
533
|
-
*
|
|
534
|
-
* This source code is licensed under the MIT license found in the
|
|
535
|
-
* LICENSE file in the root directory of this source tree.
|
|
536
|
-
*/
|
|
537
|
-
|
|
538
|
-
var factoryWithTypeCheckers;
|
|
539
|
-
var hasRequiredFactoryWithTypeCheckers;
|
|
540
|
-
|
|
541
|
-
function requireFactoryWithTypeCheckers () {
|
|
542
|
-
if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
|
|
543
|
-
hasRequiredFactoryWithTypeCheckers = 1;
|
|
544
|
-
|
|
545
|
-
var ReactIs = requireReactIs();
|
|
546
|
-
var assign = requireObjectAssign();
|
|
547
|
-
|
|
548
|
-
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
549
|
-
var has = /*@__PURE__*/ requireHas();
|
|
550
|
-
var checkPropTypes = /*@__PURE__*/ requireCheckPropTypes();
|
|
551
|
-
|
|
552
|
-
var printWarning = function() {};
|
|
553
|
-
|
|
554
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
555
|
-
printWarning = function(text) {
|
|
556
|
-
var message = 'Warning: ' + text;
|
|
557
|
-
if (typeof console !== 'undefined') {
|
|
558
|
-
console.error(message);
|
|
559
|
-
}
|
|
560
|
-
try {
|
|
561
|
-
// --- Welcome to debugging React ---
|
|
562
|
-
// This error was thrown as a convenience so that you can use this stack
|
|
563
|
-
// to find the callsite that caused this warning to fire.
|
|
564
|
-
throw new Error(message);
|
|
565
|
-
} catch (x) {}
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
function emptyFunctionThatReturnsNull() {
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
574
|
-
/* global Symbol */
|
|
575
|
-
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
576
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Returns the iterator method function contained on the iterable object.
|
|
580
|
-
*
|
|
581
|
-
* Be sure to invoke the function with the iterable as context:
|
|
582
|
-
*
|
|
583
|
-
* var iteratorFn = getIteratorFn(myIterable);
|
|
584
|
-
* if (iteratorFn) {
|
|
585
|
-
* var iterator = iteratorFn.call(myIterable);
|
|
586
|
-
* ...
|
|
587
|
-
* }
|
|
588
|
-
*
|
|
589
|
-
* @param {?object} maybeIterable
|
|
590
|
-
* @return {?function}
|
|
591
|
-
*/
|
|
592
|
-
function getIteratorFn(maybeIterable) {
|
|
593
|
-
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
594
|
-
if (typeof iteratorFn === 'function') {
|
|
595
|
-
return iteratorFn;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* Collection of methods that allow declaration and validation of props that are
|
|
601
|
-
* supplied to React components. Example usage:
|
|
602
|
-
*
|
|
603
|
-
* var Props = require('ReactPropTypes');
|
|
604
|
-
* var MyArticle = React.createClass({
|
|
605
|
-
* propTypes: {
|
|
606
|
-
* // An optional string prop named "description".
|
|
607
|
-
* description: Props.string,
|
|
608
|
-
*
|
|
609
|
-
* // A required enum prop named "category".
|
|
610
|
-
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
611
|
-
*
|
|
612
|
-
* // A prop named "dialog" that requires an instance of Dialog.
|
|
613
|
-
* dialog: Props.instanceOf(Dialog).isRequired
|
|
614
|
-
* },
|
|
615
|
-
* render: function() { ... }
|
|
616
|
-
* });
|
|
617
|
-
*
|
|
618
|
-
* A more formal specification of how these methods are used:
|
|
619
|
-
*
|
|
620
|
-
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
621
|
-
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
622
|
-
*
|
|
623
|
-
* Each and every declaration produces a function with the same signature. This
|
|
624
|
-
* allows the creation of custom validation functions. For example:
|
|
625
|
-
*
|
|
626
|
-
* var MyLink = React.createClass({
|
|
627
|
-
* propTypes: {
|
|
628
|
-
* // An optional string or URI prop named "href".
|
|
629
|
-
* href: function(props, propName, componentName) {
|
|
630
|
-
* var propValue = props[propName];
|
|
631
|
-
* if (propValue != null && typeof propValue !== 'string' &&
|
|
632
|
-
* !(propValue instanceof URI)) {
|
|
633
|
-
* return new Error(
|
|
634
|
-
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
635
|
-
* componentName
|
|
636
|
-
* );
|
|
637
|
-
* }
|
|
638
|
-
* }
|
|
639
|
-
* },
|
|
640
|
-
* render: function() {...}
|
|
641
|
-
* });
|
|
642
|
-
*
|
|
643
|
-
* @internal
|
|
644
|
-
*/
|
|
645
|
-
|
|
646
|
-
var ANONYMOUS = '<<anonymous>>';
|
|
647
|
-
|
|
648
|
-
// Important!
|
|
649
|
-
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
650
|
-
var ReactPropTypes = {
|
|
651
|
-
array: createPrimitiveTypeChecker('array'),
|
|
652
|
-
bigint: createPrimitiveTypeChecker('bigint'),
|
|
653
|
-
bool: createPrimitiveTypeChecker('boolean'),
|
|
654
|
-
func: createPrimitiveTypeChecker('function'),
|
|
655
|
-
number: createPrimitiveTypeChecker('number'),
|
|
656
|
-
object: createPrimitiveTypeChecker('object'),
|
|
657
|
-
string: createPrimitiveTypeChecker('string'),
|
|
658
|
-
symbol: createPrimitiveTypeChecker('symbol'),
|
|
659
|
-
|
|
660
|
-
any: createAnyTypeChecker(),
|
|
661
|
-
arrayOf: createArrayOfTypeChecker,
|
|
662
|
-
element: createElementTypeChecker(),
|
|
663
|
-
elementType: createElementTypeTypeChecker(),
|
|
664
|
-
instanceOf: createInstanceTypeChecker,
|
|
665
|
-
node: createNodeChecker(),
|
|
666
|
-
objectOf: createObjectOfTypeChecker,
|
|
667
|
-
oneOf: createEnumTypeChecker,
|
|
668
|
-
oneOfType: createUnionTypeChecker,
|
|
669
|
-
shape: createShapeTypeChecker,
|
|
670
|
-
exact: createStrictShapeTypeChecker,
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
675
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
676
|
-
*/
|
|
677
|
-
/*eslint-disable no-self-compare*/
|
|
678
|
-
function is(x, y) {
|
|
679
|
-
// SameValue algorithm
|
|
680
|
-
if (x === y) {
|
|
681
|
-
// Steps 1-5, 7-10
|
|
682
|
-
// Steps 6.b-6.e: +0 != -0
|
|
683
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
684
|
-
} else {
|
|
685
|
-
// Step 6.a: NaN == NaN
|
|
686
|
-
return x !== x && y !== y;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
/*eslint-enable no-self-compare*/
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* We use an Error-like object for backward compatibility as people may call
|
|
693
|
-
* PropTypes directly and inspect their output. However, we don't use real
|
|
694
|
-
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
695
|
-
* is prohibitively expensive if they are created too often, such as what
|
|
696
|
-
* happens in oneOfType() for any type before the one that matched.
|
|
697
|
-
*/
|
|
698
|
-
function PropTypeError(message, data) {
|
|
699
|
-
this.message = message;
|
|
700
|
-
this.data = data && typeof data === 'object' ? data: {};
|
|
701
|
-
this.stack = '';
|
|
702
|
-
}
|
|
703
|
-
// Make `instanceof Error` still work for returned errors.
|
|
704
|
-
PropTypeError.prototype = Error.prototype;
|
|
705
|
-
|
|
706
|
-
function createChainableTypeChecker(validate) {
|
|
707
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
708
|
-
var manualPropTypeCallCache = {};
|
|
709
|
-
var manualPropTypeWarningCount = 0;
|
|
710
|
-
}
|
|
711
|
-
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
712
|
-
componentName = componentName || ANONYMOUS;
|
|
713
|
-
propFullName = propFullName || propName;
|
|
714
|
-
|
|
715
|
-
if (secret !== ReactPropTypesSecret) {
|
|
716
|
-
if (throwOnDirectAccess) {
|
|
717
|
-
// New behavior only for users of `prop-types` package
|
|
718
|
-
var err = new Error(
|
|
719
|
-
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
720
|
-
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
721
|
-
'Read more at http://fb.me/use-check-prop-types'
|
|
722
|
-
);
|
|
723
|
-
err.name = 'Invariant Violation';
|
|
724
|
-
throw err;
|
|
725
|
-
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
726
|
-
// Old behavior for people using React.PropTypes
|
|
727
|
-
var cacheKey = componentName + ':' + propName;
|
|
728
|
-
if (
|
|
729
|
-
!manualPropTypeCallCache[cacheKey] &&
|
|
730
|
-
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
731
|
-
manualPropTypeWarningCount < 3
|
|
732
|
-
) {
|
|
733
|
-
printWarning(
|
|
734
|
-
'You are manually calling a React.PropTypes validation ' +
|
|
735
|
-
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
|
736
|
-
'and will throw in the standalone `prop-types` package. ' +
|
|
737
|
-
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
738
|
-
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
|
739
|
-
);
|
|
740
|
-
manualPropTypeCallCache[cacheKey] = true;
|
|
741
|
-
manualPropTypeWarningCount++;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
if (props[propName] == null) {
|
|
746
|
-
if (isRequired) {
|
|
747
|
-
if (props[propName] === null) {
|
|
748
|
-
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
749
|
-
}
|
|
750
|
-
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
751
|
-
}
|
|
752
|
-
return null;
|
|
753
|
-
} else {
|
|
754
|
-
return validate(props, propName, componentName, location, propFullName);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
var chainedCheckType = checkType.bind(null, false);
|
|
759
|
-
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
760
|
-
|
|
761
|
-
return chainedCheckType;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
function createPrimitiveTypeChecker(expectedType) {
|
|
765
|
-
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
766
|
-
var propValue = props[propName];
|
|
767
|
-
var propType = getPropType(propValue);
|
|
768
|
-
if (propType !== expectedType) {
|
|
769
|
-
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
770
|
-
// check, but we can offer a more precise error message here rather than
|
|
771
|
-
// 'of type `object`'.
|
|
772
|
-
var preciseType = getPreciseType(propValue);
|
|
773
|
-
|
|
774
|
-
return new PropTypeError(
|
|
775
|
-
'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
|
|
776
|
-
{expectedType: expectedType}
|
|
777
|
-
);
|
|
778
|
-
}
|
|
779
|
-
return null;
|
|
780
|
-
}
|
|
781
|
-
return createChainableTypeChecker(validate);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
function createAnyTypeChecker() {
|
|
785
|
-
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
function createArrayOfTypeChecker(typeChecker) {
|
|
789
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
790
|
-
if (typeof typeChecker !== 'function') {
|
|
791
|
-
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
792
|
-
}
|
|
793
|
-
var propValue = props[propName];
|
|
794
|
-
if (!Array.isArray(propValue)) {
|
|
795
|
-
var propType = getPropType(propValue);
|
|
796
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
797
|
-
}
|
|
798
|
-
for (var i = 0; i < propValue.length; i++) {
|
|
799
|
-
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
|
800
|
-
if (error instanceof Error) {
|
|
801
|
-
return error;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
return null;
|
|
805
|
-
}
|
|
806
|
-
return createChainableTypeChecker(validate);
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
function createElementTypeChecker() {
|
|
810
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
811
|
-
var propValue = props[propName];
|
|
812
|
-
if (!isValidElement(propValue)) {
|
|
813
|
-
var propType = getPropType(propValue);
|
|
814
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
815
|
-
}
|
|
816
|
-
return null;
|
|
817
|
-
}
|
|
818
|
-
return createChainableTypeChecker(validate);
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
function createElementTypeTypeChecker() {
|
|
822
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
823
|
-
var propValue = props[propName];
|
|
824
|
-
if (!ReactIs.isValidElementType(propValue)) {
|
|
825
|
-
var propType = getPropType(propValue);
|
|
826
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
827
|
-
}
|
|
828
|
-
return null;
|
|
829
|
-
}
|
|
830
|
-
return createChainableTypeChecker(validate);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
function createInstanceTypeChecker(expectedClass) {
|
|
834
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
835
|
-
if (!(props[propName] instanceof expectedClass)) {
|
|
836
|
-
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
837
|
-
var actualClassName = getClassName(props[propName]);
|
|
838
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
839
|
-
}
|
|
840
|
-
return null;
|
|
841
|
-
}
|
|
842
|
-
return createChainableTypeChecker(validate);
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
function createEnumTypeChecker(expectedValues) {
|
|
846
|
-
if (!Array.isArray(expectedValues)) {
|
|
847
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
848
|
-
if (arguments.length > 1) {
|
|
849
|
-
printWarning(
|
|
850
|
-
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
|
851
|
-
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
|
852
|
-
);
|
|
853
|
-
} else {
|
|
854
|
-
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
return emptyFunctionThatReturnsNull;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
861
|
-
var propValue = props[propName];
|
|
862
|
-
for (var i = 0; i < expectedValues.length; i++) {
|
|
863
|
-
if (is(propValue, expectedValues[i])) {
|
|
864
|
-
return null;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
869
|
-
var type = getPreciseType(value);
|
|
870
|
-
if (type === 'symbol') {
|
|
871
|
-
return String(value);
|
|
872
|
-
}
|
|
873
|
-
return value;
|
|
874
|
-
});
|
|
875
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
876
|
-
}
|
|
877
|
-
return createChainableTypeChecker(validate);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
function createObjectOfTypeChecker(typeChecker) {
|
|
881
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
882
|
-
if (typeof typeChecker !== 'function') {
|
|
883
|
-
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
884
|
-
}
|
|
885
|
-
var propValue = props[propName];
|
|
886
|
-
var propType = getPropType(propValue);
|
|
887
|
-
if (propType !== 'object') {
|
|
888
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
889
|
-
}
|
|
890
|
-
for (var key in propValue) {
|
|
891
|
-
if (has(propValue, key)) {
|
|
892
|
-
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
893
|
-
if (error instanceof Error) {
|
|
894
|
-
return error;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
return null;
|
|
899
|
-
}
|
|
900
|
-
return createChainableTypeChecker(validate);
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
904
|
-
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
905
|
-
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : undefined;
|
|
906
|
-
return emptyFunctionThatReturnsNull;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
910
|
-
var checker = arrayOfTypeCheckers[i];
|
|
911
|
-
if (typeof checker !== 'function') {
|
|
912
|
-
printWarning(
|
|
913
|
-
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
914
|
-
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
|
915
|
-
);
|
|
916
|
-
return emptyFunctionThatReturnsNull;
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
921
|
-
var expectedTypes = [];
|
|
922
|
-
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
923
|
-
var checker = arrayOfTypeCheckers[i];
|
|
924
|
-
var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
|
925
|
-
if (checkerResult == null) {
|
|
926
|
-
return null;
|
|
927
|
-
}
|
|
928
|
-
if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
|
|
929
|
-
expectedTypes.push(checkerResult.data.expectedType);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
|
|
933
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
|
934
|
-
}
|
|
935
|
-
return createChainableTypeChecker(validate);
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
function createNodeChecker() {
|
|
939
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
940
|
-
if (!isNode(props[propName])) {
|
|
941
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
942
|
-
}
|
|
943
|
-
return null;
|
|
944
|
-
}
|
|
945
|
-
return createChainableTypeChecker(validate);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
949
|
-
return new PropTypeError(
|
|
950
|
-
(componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
|
|
951
|
-
'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
function createShapeTypeChecker(shapeTypes) {
|
|
956
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
957
|
-
var propValue = props[propName];
|
|
958
|
-
var propType = getPropType(propValue);
|
|
959
|
-
if (propType !== 'object') {
|
|
960
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
961
|
-
}
|
|
962
|
-
for (var key in shapeTypes) {
|
|
963
|
-
var checker = shapeTypes[key];
|
|
964
|
-
if (typeof checker !== 'function') {
|
|
965
|
-
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
966
|
-
}
|
|
967
|
-
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
968
|
-
if (error) {
|
|
969
|
-
return error;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
return null;
|
|
973
|
-
}
|
|
974
|
-
return createChainableTypeChecker(validate);
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
function createStrictShapeTypeChecker(shapeTypes) {
|
|
978
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
979
|
-
var propValue = props[propName];
|
|
980
|
-
var propType = getPropType(propValue);
|
|
981
|
-
if (propType !== 'object') {
|
|
982
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
983
|
-
}
|
|
984
|
-
// We need to check all keys in case some are required but missing from props.
|
|
985
|
-
var allKeys = assign({}, props[propName], shapeTypes);
|
|
986
|
-
for (var key in allKeys) {
|
|
987
|
-
var checker = shapeTypes[key];
|
|
988
|
-
if (has(shapeTypes, key) && typeof checker !== 'function') {
|
|
989
|
-
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
990
|
-
}
|
|
991
|
-
if (!checker) {
|
|
992
|
-
return new PropTypeError(
|
|
993
|
-
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
|
994
|
-
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
|
995
|
-
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
996
|
-
);
|
|
997
|
-
}
|
|
998
|
-
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
999
|
-
if (error) {
|
|
1000
|
-
return error;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
return null;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
return createChainableTypeChecker(validate);
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
function isNode(propValue) {
|
|
1010
|
-
switch (typeof propValue) {
|
|
1011
|
-
case 'number':
|
|
1012
|
-
case 'string':
|
|
1013
|
-
case 'undefined':
|
|
1014
|
-
return true;
|
|
1015
|
-
case 'boolean':
|
|
1016
|
-
return !propValue;
|
|
1017
|
-
case 'object':
|
|
1018
|
-
if (Array.isArray(propValue)) {
|
|
1019
|
-
return propValue.every(isNode);
|
|
1020
|
-
}
|
|
1021
|
-
if (propValue === null || isValidElement(propValue)) {
|
|
1022
|
-
return true;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
var iteratorFn = getIteratorFn(propValue);
|
|
1026
|
-
if (iteratorFn) {
|
|
1027
|
-
var iterator = iteratorFn.call(propValue);
|
|
1028
|
-
var step;
|
|
1029
|
-
if (iteratorFn !== propValue.entries) {
|
|
1030
|
-
while (!(step = iterator.next()).done) {
|
|
1031
|
-
if (!isNode(step.value)) {
|
|
1032
|
-
return false;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
} else {
|
|
1036
|
-
// Iterator will provide entry [k,v] tuples rather than values.
|
|
1037
|
-
while (!(step = iterator.next()).done) {
|
|
1038
|
-
var entry = step.value;
|
|
1039
|
-
if (entry) {
|
|
1040
|
-
if (!isNode(entry[1])) {
|
|
1041
|
-
return false;
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
} else {
|
|
1047
|
-
return false;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
return true;
|
|
1051
|
-
default:
|
|
1052
|
-
return false;
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
function isSymbol(propType, propValue) {
|
|
1057
|
-
// Native Symbol.
|
|
1058
|
-
if (propType === 'symbol') {
|
|
1059
|
-
return true;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
// falsy value can't be a Symbol
|
|
1063
|
-
if (!propValue) {
|
|
1064
|
-
return false;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
1068
|
-
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
1069
|
-
return true;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
1073
|
-
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
1074
|
-
return true;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
return false;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
1081
|
-
function getPropType(propValue) {
|
|
1082
|
-
var propType = typeof propValue;
|
|
1083
|
-
if (Array.isArray(propValue)) {
|
|
1084
|
-
return 'array';
|
|
1085
|
-
}
|
|
1086
|
-
if (propValue instanceof RegExp) {
|
|
1087
|
-
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
1088
|
-
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
1089
|
-
// passes PropTypes.object.
|
|
1090
|
-
return 'object';
|
|
1091
|
-
}
|
|
1092
|
-
if (isSymbol(propType, propValue)) {
|
|
1093
|
-
return 'symbol';
|
|
1094
|
-
}
|
|
1095
|
-
return propType;
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
// This handles more types than `getPropType`. Only used for error messages.
|
|
1099
|
-
// See `createPrimitiveTypeChecker`.
|
|
1100
|
-
function getPreciseType(propValue) {
|
|
1101
|
-
if (typeof propValue === 'undefined' || propValue === null) {
|
|
1102
|
-
return '' + propValue;
|
|
1103
|
-
}
|
|
1104
|
-
var propType = getPropType(propValue);
|
|
1105
|
-
if (propType === 'object') {
|
|
1106
|
-
if (propValue instanceof Date) {
|
|
1107
|
-
return 'date';
|
|
1108
|
-
} else if (propValue instanceof RegExp) {
|
|
1109
|
-
return 'regexp';
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
return propType;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
// Returns a string that is postfixed to a warning about an invalid type.
|
|
1116
|
-
// For example, "undefined" or "of type array"
|
|
1117
|
-
function getPostfixForTypeWarning(value) {
|
|
1118
|
-
var type = getPreciseType(value);
|
|
1119
|
-
switch (type) {
|
|
1120
|
-
case 'array':
|
|
1121
|
-
case 'object':
|
|
1122
|
-
return 'an ' + type;
|
|
1123
|
-
case 'boolean':
|
|
1124
|
-
case 'date':
|
|
1125
|
-
case 'regexp':
|
|
1126
|
-
return 'a ' + type;
|
|
1127
|
-
default:
|
|
1128
|
-
return type;
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
// Returns class name of the object, if any.
|
|
1133
|
-
function getClassName(propValue) {
|
|
1134
|
-
if (!propValue.constructor || !propValue.constructor.name) {
|
|
1135
|
-
return ANONYMOUS;
|
|
1136
|
-
}
|
|
1137
|
-
return propValue.constructor.name;
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
1141
|
-
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
1142
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1143
|
-
|
|
1144
|
-
return ReactPropTypes;
|
|
1145
|
-
};
|
|
1146
|
-
return factoryWithTypeCheckers;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1151
|
-
*
|
|
1152
|
-
* This source code is licensed under the MIT license found in the
|
|
1153
|
-
* LICENSE file in the root directory of this source tree.
|
|
1154
|
-
*/
|
|
1155
|
-
|
|
1156
|
-
var factoryWithThrowingShims;
|
|
1157
|
-
var hasRequiredFactoryWithThrowingShims;
|
|
1158
|
-
|
|
1159
|
-
function requireFactoryWithThrowingShims () {
|
|
1160
|
-
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
|
|
1161
|
-
hasRequiredFactoryWithThrowingShims = 1;
|
|
1162
|
-
|
|
1163
|
-
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
1164
|
-
|
|
1165
|
-
function emptyFunction() {}
|
|
1166
|
-
function emptyFunctionWithReset() {}
|
|
1167
|
-
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
1168
|
-
|
|
1169
|
-
factoryWithThrowingShims = function() {
|
|
1170
|
-
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
1171
|
-
if (secret === ReactPropTypesSecret) {
|
|
1172
|
-
// It is still safe when called from React.
|
|
1173
|
-
return;
|
|
1174
|
-
}
|
|
1175
|
-
var err = new Error(
|
|
1176
|
-
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
1177
|
-
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
1178
|
-
'Read more at http://fb.me/use-check-prop-types'
|
|
1179
|
-
);
|
|
1180
|
-
err.name = 'Invariant Violation';
|
|
1181
|
-
throw err;
|
|
1182
|
-
} shim.isRequired = shim;
|
|
1183
|
-
function getShim() {
|
|
1184
|
-
return shim;
|
|
1185
|
-
} // Important!
|
|
1186
|
-
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
1187
|
-
var ReactPropTypes = {
|
|
1188
|
-
array: shim,
|
|
1189
|
-
bigint: shim,
|
|
1190
|
-
bool: shim,
|
|
1191
|
-
func: shim,
|
|
1192
|
-
number: shim,
|
|
1193
|
-
object: shim,
|
|
1194
|
-
string: shim,
|
|
1195
|
-
symbol: shim,
|
|
1196
|
-
|
|
1197
|
-
any: shim,
|
|
1198
|
-
arrayOf: getShim,
|
|
1199
|
-
element: shim,
|
|
1200
|
-
elementType: shim,
|
|
1201
|
-
instanceOf: getShim,
|
|
1202
|
-
node: shim,
|
|
1203
|
-
objectOf: getShim,
|
|
1204
|
-
oneOf: getShim,
|
|
1205
|
-
oneOfType: getShim,
|
|
1206
|
-
shape: getShim,
|
|
1207
|
-
exact: getShim,
|
|
1208
|
-
|
|
1209
|
-
checkPropTypes: emptyFunctionWithReset,
|
|
1210
|
-
resetWarningCache: emptyFunction
|
|
1211
|
-
};
|
|
1212
|
-
|
|
1213
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1214
|
-
|
|
1215
|
-
return ReactPropTypes;
|
|
1216
|
-
};
|
|
1217
|
-
return factoryWithThrowingShims;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
/**
|
|
1221
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1222
|
-
*
|
|
1223
|
-
* This source code is licensed under the MIT license found in the
|
|
1224
|
-
* LICENSE file in the root directory of this source tree.
|
|
1225
|
-
*/
|
|
1226
|
-
|
|
1227
|
-
var hasRequiredPropTypes;
|
|
1228
|
-
|
|
1229
|
-
function requirePropTypes () {
|
|
1230
|
-
if (hasRequiredPropTypes) return propTypes.exports;
|
|
1231
|
-
hasRequiredPropTypes = 1;
|
|
1232
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1233
|
-
var ReactIs = requireReactIs();
|
|
1234
|
-
|
|
1235
|
-
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
1236
|
-
// http://fb.me/prop-types-in-prod
|
|
1237
|
-
var throwOnDirectAccess = true;
|
|
1238
|
-
propTypes.exports = /*@__PURE__*/ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
|
1239
|
-
} else {
|
|
1240
|
-
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1241
|
-
// http://fb.me/prop-types-in-prod
|
|
1242
|
-
propTypes.exports = /*@__PURE__*/ requireFactoryWithThrowingShims()();
|
|
1243
|
-
}
|
|
1244
|
-
return propTypes.exports;
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
var propTypesExports = /*@__PURE__*/ requirePropTypes();
|
|
1248
|
-
var PropTypes = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(propTypesExports);
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* Checks if a given element has a CSS class.
|
|
1252
|
-
*
|
|
1253
|
-
* @param element the element
|
|
1254
|
-
* @param className the CSS class name
|
|
1255
|
-
*/
|
|
1256
|
-
function hasClass(element, className) {
|
|
1257
|
-
if (element.classList) return !!className && element.classList.contains(className);
|
|
1258
|
-
return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* Adds a CSS class to a given element.
|
|
1263
|
-
*
|
|
1264
|
-
* @param element the element
|
|
1265
|
-
* @param className the CSS class name
|
|
1266
|
-
*/
|
|
1267
|
-
|
|
1268
|
-
function addClass(element, className) {
|
|
1269
|
-
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);
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
function replaceClassName(origClass, classToRemove) {
|
|
1273
|
-
return origClass.replace(new RegExp("(^|\\s)" + classToRemove + "(?:\\s|$)", 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
|
|
1274
|
-
}
|
|
1275
|
-
/**
|
|
1276
|
-
* Removes a CSS class from a given element.
|
|
1277
|
-
*
|
|
1278
|
-
* @param element the element
|
|
1279
|
-
* @param className the CSS class name
|
|
1280
|
-
*/
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
function removeClass$1(element, className) {
|
|
1284
|
-
if (element.classList) {
|
|
1285
|
-
element.classList.remove(className);
|
|
1286
|
-
} else if (typeof element.className === 'string') {
|
|
1287
|
-
element.className = replaceClassName(element.className, className);
|
|
1288
|
-
} else {
|
|
1289
|
-
element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
var config = {
|
|
1294
|
-
disabled: false
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1297
|
-
var timeoutsShape = process.env.NODE_ENV !== 'production' ? PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
1298
|
-
enter: PropTypes.number,
|
|
1299
|
-
exit: PropTypes.number,
|
|
1300
|
-
appear: PropTypes.number
|
|
1301
|
-
}).isRequired]) : null;
|
|
1302
|
-
var classNamesShape = process.env.NODE_ENV !== 'production' ? PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1303
|
-
enter: PropTypes.string,
|
|
1304
|
-
exit: PropTypes.string,
|
|
1305
|
-
active: PropTypes.string
|
|
1306
|
-
}), PropTypes.shape({
|
|
1307
|
-
enter: PropTypes.string,
|
|
1308
|
-
enterDone: PropTypes.string,
|
|
1309
|
-
enterActive: PropTypes.string,
|
|
1310
|
-
exit: PropTypes.string,
|
|
1311
|
-
exitDone: PropTypes.string,
|
|
1312
|
-
exitActive: PropTypes.string
|
|
1313
|
-
})]) : null;
|
|
1314
|
-
|
|
1315
|
-
var TransitionGroupContext = React.createContext(null);
|
|
1316
|
-
|
|
1317
|
-
var forceReflow = function forceReflow(node) {
|
|
1318
|
-
return node.scrollTop;
|
|
1319
|
-
};
|
|
1320
|
-
|
|
1321
|
-
var UNMOUNTED = 'unmounted';
|
|
1322
|
-
var EXITED = 'exited';
|
|
1323
|
-
var ENTERING = 'entering';
|
|
1324
|
-
var ENTERED = 'entered';
|
|
1325
|
-
var EXITING = 'exiting';
|
|
1326
|
-
/**
|
|
1327
|
-
* The Transition component lets you describe a transition from one component
|
|
1328
|
-
* state to another _over time_ with a simple declarative API. Most commonly
|
|
1329
|
-
* it's used to animate the mounting and unmounting of a component, but can also
|
|
1330
|
-
* be used to describe in-place transition states as well.
|
|
1331
|
-
*
|
|
1332
|
-
* ---
|
|
1333
|
-
*
|
|
1334
|
-
* **Note**: `Transition` is a platform-agnostic base component. If you're using
|
|
1335
|
-
* transitions in CSS, you'll probably want to use
|
|
1336
|
-
* [`CSSTransition`](https://reactcommunity.org/react-transition-group/css-transition)
|
|
1337
|
-
* instead. It inherits all the features of `Transition`, but contains
|
|
1338
|
-
* additional features necessary to play nice with CSS transitions (hence the
|
|
1339
|
-
* name of the component).
|
|
1340
|
-
*
|
|
1341
|
-
* ---
|
|
1342
|
-
*
|
|
1343
|
-
* By default the `Transition` component does not alter the behavior of the
|
|
1344
|
-
* component it renders, it only tracks "enter" and "exit" states for the
|
|
1345
|
-
* components. It's up to you to give meaning and effect to those states. For
|
|
1346
|
-
* example we can add styles to a component when it enters or exits:
|
|
1347
|
-
*
|
|
1348
|
-
* ```jsx
|
|
1349
|
-
* import { Transition } from 'react-transition-group';
|
|
1350
|
-
*
|
|
1351
|
-
* const duration = 300;
|
|
1352
|
-
*
|
|
1353
|
-
* const defaultStyle = {
|
|
1354
|
-
* transition: `opacity ${duration}ms ease-in-out`,
|
|
1355
|
-
* opacity: 0,
|
|
1356
|
-
* }
|
|
1357
|
-
*
|
|
1358
|
-
* const transitionStyles = {
|
|
1359
|
-
* entering: { opacity: 1 },
|
|
1360
|
-
* entered: { opacity: 1 },
|
|
1361
|
-
* exiting: { opacity: 0 },
|
|
1362
|
-
* exited: { opacity: 0 },
|
|
1363
|
-
* };
|
|
1364
|
-
*
|
|
1365
|
-
* const Fade = ({ in: inProp }) => (
|
|
1366
|
-
* <Transition in={inProp} timeout={duration}>
|
|
1367
|
-
* {state => (
|
|
1368
|
-
* <div style={{
|
|
1369
|
-
* ...defaultStyle,
|
|
1370
|
-
* ...transitionStyles[state]
|
|
1371
|
-
* }}>
|
|
1372
|
-
* I'm a fade Transition!
|
|
1373
|
-
* </div>
|
|
1374
|
-
* )}
|
|
1375
|
-
* </Transition>
|
|
1376
|
-
* );
|
|
1377
|
-
* ```
|
|
1378
|
-
*
|
|
1379
|
-
* There are 4 main states a Transition can be in:
|
|
1380
|
-
* - `'entering'`
|
|
1381
|
-
* - `'entered'`
|
|
1382
|
-
* - `'exiting'`
|
|
1383
|
-
* - `'exited'`
|
|
1384
|
-
*
|
|
1385
|
-
* Transition state is toggled via the `in` prop. When `true` the component
|
|
1386
|
-
* begins the "Enter" stage. During this stage, the component will shift from
|
|
1387
|
-
* its current transition state, to `'entering'` for the duration of the
|
|
1388
|
-
* transition and then to the `'entered'` stage once it's complete. Let's take
|
|
1389
|
-
* the following example (we'll use the
|
|
1390
|
-
* [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):
|
|
1391
|
-
*
|
|
1392
|
-
* ```jsx
|
|
1393
|
-
* function App() {
|
|
1394
|
-
* const [inProp, setInProp] = useState(false);
|
|
1395
|
-
* return (
|
|
1396
|
-
* <div>
|
|
1397
|
-
* <Transition in={inProp} timeout={500}>
|
|
1398
|
-
* {state => (
|
|
1399
|
-
* // ...
|
|
1400
|
-
* )}
|
|
1401
|
-
* </Transition>
|
|
1402
|
-
* <button onClick={() => setInProp(true)}>
|
|
1403
|
-
* Click to Enter
|
|
1404
|
-
* </button>
|
|
1405
|
-
* </div>
|
|
1406
|
-
* );
|
|
1407
|
-
* }
|
|
1408
|
-
* ```
|
|
1409
|
-
*
|
|
1410
|
-
* When the button is clicked the component will shift to the `'entering'` state
|
|
1411
|
-
* and stay there for 500ms (the value of `timeout`) before it finally switches
|
|
1412
|
-
* to `'entered'`.
|
|
1413
|
-
*
|
|
1414
|
-
* When `in` is `false` the same thing happens except the state moves from
|
|
1415
|
-
* `'exiting'` to `'exited'`.
|
|
1416
|
-
*/
|
|
1417
|
-
|
|
1418
|
-
var Transition = /*#__PURE__*/function (_React$Component) {
|
|
1419
|
-
_inheritsLoose(Transition, _React$Component);
|
|
1420
|
-
|
|
1421
|
-
function Transition(props, context) {
|
|
1422
|
-
var _this;
|
|
1423
|
-
|
|
1424
|
-
_this = _React$Component.call(this, props, context) || this;
|
|
1425
|
-
var parentGroup = context; // In the context of a TransitionGroup all enters are really appears
|
|
1426
|
-
|
|
1427
|
-
var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;
|
|
1428
|
-
var initialStatus;
|
|
1429
|
-
_this.appearStatus = null;
|
|
1430
|
-
|
|
1431
|
-
if (props.in) {
|
|
1432
|
-
if (appear) {
|
|
1433
|
-
initialStatus = EXITED;
|
|
1434
|
-
_this.appearStatus = ENTERING;
|
|
1435
|
-
} else {
|
|
1436
|
-
initialStatus = ENTERED;
|
|
1437
|
-
}
|
|
1438
|
-
} else {
|
|
1439
|
-
if (props.unmountOnExit || props.mountOnEnter) {
|
|
1440
|
-
initialStatus = UNMOUNTED;
|
|
1441
|
-
} else {
|
|
1442
|
-
initialStatus = EXITED;
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
_this.state = {
|
|
1447
|
-
status: initialStatus
|
|
1448
|
-
};
|
|
1449
|
-
_this.nextCallback = null;
|
|
1450
|
-
return _this;
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {
|
|
1454
|
-
var nextIn = _ref.in;
|
|
1455
|
-
|
|
1456
|
-
if (nextIn && prevState.status === UNMOUNTED) {
|
|
1457
|
-
return {
|
|
1458
|
-
status: EXITED
|
|
1459
|
-
};
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
return null;
|
|
1463
|
-
} // getSnapshotBeforeUpdate(prevProps) {
|
|
1464
|
-
// let nextStatus = null
|
|
1465
|
-
// if (prevProps !== this.props) {
|
|
1466
|
-
// const { status } = this.state
|
|
1467
|
-
// if (this.props.in) {
|
|
1468
|
-
// if (status !== ENTERING && status !== ENTERED) {
|
|
1469
|
-
// nextStatus = ENTERING
|
|
1470
|
-
// }
|
|
1471
|
-
// } else {
|
|
1472
|
-
// if (status === ENTERING || status === ENTERED) {
|
|
1473
|
-
// nextStatus = EXITING
|
|
1474
|
-
// }
|
|
1475
|
-
// }
|
|
1476
|
-
// }
|
|
1477
|
-
// return { nextStatus }
|
|
1478
|
-
// }
|
|
1479
|
-
;
|
|
1480
|
-
|
|
1481
|
-
var _proto = Transition.prototype;
|
|
1482
|
-
|
|
1483
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
1484
|
-
this.updateStatus(true, this.appearStatus);
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
1488
|
-
var nextStatus = null;
|
|
1489
|
-
|
|
1490
|
-
if (prevProps !== this.props) {
|
|
1491
|
-
var status = this.state.status;
|
|
1492
|
-
|
|
1493
|
-
if (this.props.in) {
|
|
1494
|
-
if (status !== ENTERING && status !== ENTERED) {
|
|
1495
|
-
nextStatus = ENTERING;
|
|
1496
|
-
}
|
|
1497
|
-
} else {
|
|
1498
|
-
if (status === ENTERING || status === ENTERED) {
|
|
1499
|
-
nextStatus = EXITING;
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
this.updateStatus(false, nextStatus);
|
|
1505
|
-
};
|
|
1506
|
-
|
|
1507
|
-
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
1508
|
-
this.cancelNextCallback();
|
|
1509
|
-
};
|
|
1510
|
-
|
|
1511
|
-
_proto.getTimeouts = function getTimeouts() {
|
|
1512
|
-
var timeout = this.props.timeout;
|
|
1513
|
-
var exit, enter, appear;
|
|
1514
|
-
exit = enter = appear = timeout;
|
|
1515
|
-
|
|
1516
|
-
if (timeout != null && typeof timeout !== 'number') {
|
|
1517
|
-
exit = timeout.exit;
|
|
1518
|
-
enter = timeout.enter; // TODO: remove fallback for next major
|
|
1519
|
-
|
|
1520
|
-
appear = timeout.appear !== undefined ? timeout.appear : enter;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
return {
|
|
1524
|
-
exit: exit,
|
|
1525
|
-
enter: enter,
|
|
1526
|
-
appear: appear
|
|
1527
|
-
};
|
|
1528
|
-
};
|
|
1529
|
-
|
|
1530
|
-
_proto.updateStatus = function updateStatus(mounting, nextStatus) {
|
|
1531
|
-
if (mounting === undefined) {
|
|
1532
|
-
mounting = false;
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
if (nextStatus !== null) {
|
|
1536
|
-
// nextStatus will always be ENTERING or EXITING.
|
|
1537
|
-
this.cancelNextCallback();
|
|
1538
|
-
|
|
1539
|
-
if (nextStatus === ENTERING) {
|
|
1540
|
-
if (this.props.unmountOnExit || this.props.mountOnEnter) {
|
|
1541
|
-
var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM.findDOMNode(this); // https://github.com/reactjs/react-transition-group/pull/749
|
|
1542
|
-
// With unmountOnExit or mountOnEnter, the enter animation should happen at the transition between `exited` and `entering`.
|
|
1543
|
-
// To make the animation happen, we have to separate each rendering and avoid being processed as batched.
|
|
1544
|
-
|
|
1545
|
-
if (node) forceReflow(node);
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
this.performEnter(mounting);
|
|
1549
|
-
} else {
|
|
1550
|
-
this.performExit();
|
|
1551
|
-
}
|
|
1552
|
-
} else if (this.props.unmountOnExit && this.state.status === EXITED) {
|
|
1553
|
-
this.setState({
|
|
1554
|
-
status: UNMOUNTED
|
|
1555
|
-
});
|
|
1556
|
-
}
|
|
1557
|
-
};
|
|
1558
|
-
|
|
1559
|
-
_proto.performEnter = function performEnter(mounting) {
|
|
1560
|
-
var _this2 = this;
|
|
1561
|
-
|
|
1562
|
-
var enter = this.props.enter;
|
|
1563
|
-
var appearing = this.context ? this.context.isMounting : mounting;
|
|
1564
|
-
|
|
1565
|
-
var _ref2 = this.props.nodeRef ? [appearing] : [ReactDOM.findDOMNode(this), appearing],
|
|
1566
|
-
maybeNode = _ref2[0],
|
|
1567
|
-
maybeAppearing = _ref2[1];
|
|
1568
|
-
|
|
1569
|
-
var timeouts = this.getTimeouts();
|
|
1570
|
-
var enterTimeout = appearing ? timeouts.appear : timeouts.enter; // no enter animation skip right to ENTERED
|
|
1571
|
-
// if we are mounting and running this it means appear _must_ be set
|
|
1572
|
-
|
|
1573
|
-
if (!mounting && !enter || config.disabled) {
|
|
1574
|
-
this.safeSetState({
|
|
1575
|
-
status: ENTERED
|
|
1576
|
-
}, function () {
|
|
1577
|
-
_this2.props.onEntered(maybeNode);
|
|
1578
|
-
});
|
|
1579
|
-
return;
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
this.props.onEnter(maybeNode, maybeAppearing);
|
|
1583
|
-
this.safeSetState({
|
|
1584
|
-
status: ENTERING
|
|
1585
|
-
}, function () {
|
|
1586
|
-
_this2.props.onEntering(maybeNode, maybeAppearing);
|
|
1587
|
-
|
|
1588
|
-
_this2.onTransitionEnd(enterTimeout, function () {
|
|
1589
|
-
_this2.safeSetState({
|
|
1590
|
-
status: ENTERED
|
|
1591
|
-
}, function () {
|
|
1592
|
-
_this2.props.onEntered(maybeNode, maybeAppearing);
|
|
1593
|
-
});
|
|
1594
|
-
});
|
|
1595
|
-
});
|
|
1596
|
-
};
|
|
1597
|
-
|
|
1598
|
-
_proto.performExit = function performExit() {
|
|
1599
|
-
var _this3 = this;
|
|
1600
|
-
|
|
1601
|
-
var exit = this.props.exit;
|
|
1602
|
-
var timeouts = this.getTimeouts();
|
|
1603
|
-
var maybeNode = this.props.nodeRef ? undefined : ReactDOM.findDOMNode(this); // no exit animation skip right to EXITED
|
|
1604
|
-
|
|
1605
|
-
if (!exit || config.disabled) {
|
|
1606
|
-
this.safeSetState({
|
|
1607
|
-
status: EXITED
|
|
1608
|
-
}, function () {
|
|
1609
|
-
_this3.props.onExited(maybeNode);
|
|
1610
|
-
});
|
|
1611
|
-
return;
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
this.props.onExit(maybeNode);
|
|
1615
|
-
this.safeSetState({
|
|
1616
|
-
status: EXITING
|
|
1617
|
-
}, function () {
|
|
1618
|
-
_this3.props.onExiting(maybeNode);
|
|
1619
|
-
|
|
1620
|
-
_this3.onTransitionEnd(timeouts.exit, function () {
|
|
1621
|
-
_this3.safeSetState({
|
|
1622
|
-
status: EXITED
|
|
1623
|
-
}, function () {
|
|
1624
|
-
_this3.props.onExited(maybeNode);
|
|
1625
|
-
});
|
|
1626
|
-
});
|
|
1627
|
-
});
|
|
1628
|
-
};
|
|
1629
|
-
|
|
1630
|
-
_proto.cancelNextCallback = function cancelNextCallback() {
|
|
1631
|
-
if (this.nextCallback !== null) {
|
|
1632
|
-
this.nextCallback.cancel();
|
|
1633
|
-
this.nextCallback = null;
|
|
1634
|
-
}
|
|
1635
|
-
};
|
|
1636
|
-
|
|
1637
|
-
_proto.safeSetState = function safeSetState(nextState, callback) {
|
|
1638
|
-
// This shouldn't be necessary, but there are weird race conditions with
|
|
1639
|
-
// setState callbacks and unmounting in testing, so always make sure that
|
|
1640
|
-
// we can cancel any pending setState callbacks after we unmount.
|
|
1641
|
-
callback = this.setNextCallback(callback);
|
|
1642
|
-
this.setState(nextState, callback);
|
|
1643
|
-
};
|
|
1644
|
-
|
|
1645
|
-
_proto.setNextCallback = function setNextCallback(callback) {
|
|
1646
|
-
var _this4 = this;
|
|
1647
|
-
|
|
1648
|
-
var active = true;
|
|
1649
|
-
|
|
1650
|
-
this.nextCallback = function (event) {
|
|
1651
|
-
if (active) {
|
|
1652
|
-
active = false;
|
|
1653
|
-
_this4.nextCallback = null;
|
|
1654
|
-
callback(event);
|
|
1655
|
-
}
|
|
1656
|
-
};
|
|
1657
|
-
|
|
1658
|
-
this.nextCallback.cancel = function () {
|
|
1659
|
-
active = false;
|
|
1660
|
-
};
|
|
1661
|
-
|
|
1662
|
-
return this.nextCallback;
|
|
1663
|
-
};
|
|
1664
|
-
|
|
1665
|
-
_proto.onTransitionEnd = function onTransitionEnd(timeout, handler) {
|
|
1666
|
-
this.setNextCallback(handler);
|
|
1667
|
-
var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM.findDOMNode(this);
|
|
1668
|
-
var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;
|
|
1669
|
-
|
|
1670
|
-
if (!node || doesNotHaveTimeoutOrListener) {
|
|
1671
|
-
setTimeout(this.nextCallback, 0);
|
|
1672
|
-
return;
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
if (this.props.addEndListener) {
|
|
1676
|
-
var _ref3 = this.props.nodeRef ? [this.nextCallback] : [node, this.nextCallback],
|
|
1677
|
-
maybeNode = _ref3[0],
|
|
1678
|
-
maybeNextCallback = _ref3[1];
|
|
1679
|
-
|
|
1680
|
-
this.props.addEndListener(maybeNode, maybeNextCallback);
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
if (timeout != null) {
|
|
1684
|
-
setTimeout(this.nextCallback, timeout);
|
|
1685
|
-
}
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
_proto.render = function render() {
|
|
1689
|
-
var status = this.state.status;
|
|
1690
|
-
|
|
1691
|
-
if (status === UNMOUNTED) {
|
|
1692
|
-
return null;
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
var _this$props = this.props,
|
|
1696
|
-
children = _this$props.children;
|
|
1697
|
-
_this$props.in;
|
|
1698
|
-
_this$props.mountOnEnter;
|
|
1699
|
-
_this$props.unmountOnExit;
|
|
1700
|
-
_this$props.appear;
|
|
1701
|
-
_this$props.enter;
|
|
1702
|
-
_this$props.exit;
|
|
1703
|
-
_this$props.timeout;
|
|
1704
|
-
_this$props.addEndListener;
|
|
1705
|
-
_this$props.onEnter;
|
|
1706
|
-
_this$props.onEntering;
|
|
1707
|
-
_this$props.onEntered;
|
|
1708
|
-
_this$props.onExit;
|
|
1709
|
-
_this$props.onExiting;
|
|
1710
|
-
_this$props.onExited;
|
|
1711
|
-
_this$props.nodeRef;
|
|
1712
|
-
var childProps = _objectWithoutPropertiesLoose(_this$props, ["children", "in", "mountOnEnter", "unmountOnExit", "appear", "enter", "exit", "timeout", "addEndListener", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "nodeRef"]);
|
|
1713
|
-
|
|
1714
|
-
return (
|
|
1715
|
-
/*#__PURE__*/
|
|
1716
|
-
// allows for nested Transitions
|
|
1717
|
-
React.createElement(TransitionGroupContext.Provider, {
|
|
1718
|
-
value: null
|
|
1719
|
-
}, typeof children === 'function' ? children(status, childProps) : React.cloneElement(React.Children.only(children), childProps))
|
|
1720
|
-
);
|
|
1721
|
-
};
|
|
1722
|
-
|
|
1723
|
-
return Transition;
|
|
1724
|
-
}(React.Component);
|
|
1725
|
-
|
|
1726
|
-
Transition.contextType = TransitionGroupContext;
|
|
1727
|
-
Transition.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
1728
|
-
/**
|
|
1729
|
-
* A React reference to DOM element that need to transition:
|
|
1730
|
-
* https://stackoverflow.com/a/51127130/4671932
|
|
1731
|
-
*
|
|
1732
|
-
* - When `nodeRef` prop is used, `node` is not passed to callback functions
|
|
1733
|
-
* (e.g. `onEnter`) because user already has direct access to the node.
|
|
1734
|
-
* - When changing `key` prop of `Transition` in a `TransitionGroup` a new
|
|
1735
|
-
* `nodeRef` need to be provided to `Transition` with changed `key` prop
|
|
1736
|
-
* (see
|
|
1737
|
-
* [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)).
|
|
1738
|
-
*/
|
|
1739
|
-
nodeRef: PropTypes.shape({
|
|
1740
|
-
current: typeof Element === 'undefined' ? PropTypes.any : function (propValue, key, componentName, location, propFullName, secret) {
|
|
1741
|
-
var value = propValue[key];
|
|
1742
|
-
return PropTypes.instanceOf(value && 'ownerDocument' in value ? value.ownerDocument.defaultView.Element : Element)(propValue, key, componentName, location, propFullName, secret);
|
|
1743
|
-
}
|
|
1744
|
-
}),
|
|
1745
|
-
|
|
1746
|
-
/**
|
|
1747
|
-
* A `function` child can be used instead of a React element. This function is
|
|
1748
|
-
* called with the current transition status (`'entering'`, `'entered'`,
|
|
1749
|
-
* `'exiting'`, `'exited'`), which can be used to apply context
|
|
1750
|
-
* specific props to a component.
|
|
1751
|
-
*
|
|
1752
|
-
* ```jsx
|
|
1753
|
-
* <Transition in={this.state.in} timeout={150}>
|
|
1754
|
-
* {state => (
|
|
1755
|
-
* <MyComponent className={`fade fade-${state}`} />
|
|
1756
|
-
* )}
|
|
1757
|
-
* </Transition>
|
|
1758
|
-
* ```
|
|
1759
|
-
*/
|
|
1760
|
-
children: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.element.isRequired]).isRequired,
|
|
1761
|
-
|
|
1762
|
-
/**
|
|
1763
|
-
* Show the component; triggers the enter or exit states
|
|
1764
|
-
*/
|
|
1765
|
-
in: PropTypes.bool,
|
|
1766
|
-
|
|
1767
|
-
/**
|
|
1768
|
-
* By default the child component is mounted immediately along with
|
|
1769
|
-
* the parent `Transition` component. If you want to "lazy mount" the component on the
|
|
1770
|
-
* first `in={true}` you can set `mountOnEnter`. After the first enter transition the component will stay
|
|
1771
|
-
* mounted, even on "exited", unless you also specify `unmountOnExit`.
|
|
1772
|
-
*/
|
|
1773
|
-
mountOnEnter: PropTypes.bool,
|
|
1774
|
-
|
|
1775
|
-
/**
|
|
1776
|
-
* By default the child component stays mounted after it reaches the `'exited'` state.
|
|
1777
|
-
* Set `unmountOnExit` if you'd prefer to unmount the component after it finishes exiting.
|
|
1778
|
-
*/
|
|
1779
|
-
unmountOnExit: PropTypes.bool,
|
|
1780
|
-
|
|
1781
|
-
/**
|
|
1782
|
-
* By default the child component does not perform the enter transition when
|
|
1783
|
-
* it first mounts, regardless of the value of `in`. If you want this
|
|
1784
|
-
* behavior, set both `appear` and `in` to `true`.
|
|
1785
|
-
*
|
|
1786
|
-
* > **Note**: there are no special appear states like `appearing`/`appeared`, this prop
|
|
1787
|
-
* > only adds an additional enter transition. However, in the
|
|
1788
|
-
* > `<CSSTransition>` component that first enter transition does result in
|
|
1789
|
-
* > additional `.appear-*` classes, that way you can choose to style it
|
|
1790
|
-
* > differently.
|
|
1791
|
-
*/
|
|
1792
|
-
appear: PropTypes.bool,
|
|
1793
|
-
|
|
1794
|
-
/**
|
|
1795
|
-
* Enable or disable enter transitions.
|
|
1796
|
-
*/
|
|
1797
|
-
enter: PropTypes.bool,
|
|
1798
|
-
|
|
1799
|
-
/**
|
|
1800
|
-
* Enable or disable exit transitions.
|
|
1801
|
-
*/
|
|
1802
|
-
exit: PropTypes.bool,
|
|
1803
|
-
|
|
1804
|
-
/**
|
|
1805
|
-
* The duration of the transition, in milliseconds.
|
|
1806
|
-
* Required unless `addEndListener` is provided.
|
|
1807
|
-
*
|
|
1808
|
-
* You may specify a single timeout for all transitions:
|
|
1809
|
-
*
|
|
1810
|
-
* ```jsx
|
|
1811
|
-
* timeout={500}
|
|
1812
|
-
* ```
|
|
1813
|
-
*
|
|
1814
|
-
* or individually:
|
|
1815
|
-
*
|
|
1816
|
-
* ```jsx
|
|
1817
|
-
* timeout={{
|
|
1818
|
-
* appear: 500,
|
|
1819
|
-
* enter: 300,
|
|
1820
|
-
* exit: 500,
|
|
1821
|
-
* }}
|
|
1822
|
-
* ```
|
|
1823
|
-
*
|
|
1824
|
-
* - `appear` defaults to the value of `enter`
|
|
1825
|
-
* - `enter` defaults to `0`
|
|
1826
|
-
* - `exit` defaults to `0`
|
|
1827
|
-
*
|
|
1828
|
-
* @type {number | { enter?: number, exit?: number, appear?: number }}
|
|
1829
|
-
*/
|
|
1830
|
-
timeout: function timeout(props) {
|
|
1831
|
-
var pt = timeoutsShape;
|
|
1832
|
-
if (!props.addEndListener) pt = pt.isRequired;
|
|
1833
|
-
|
|
1834
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1835
|
-
args[_key - 1] = arguments[_key];
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
return pt.apply(undefined, [props].concat(args));
|
|
1839
|
-
},
|
|
1840
|
-
|
|
1841
|
-
/**
|
|
1842
|
-
* Add a custom transition end trigger. Called with the transitioning
|
|
1843
|
-
* DOM node and a `done` callback. Allows for more fine grained transition end
|
|
1844
|
-
* logic. Timeouts are still used as a fallback if provided.
|
|
1845
|
-
*
|
|
1846
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
1847
|
-
*
|
|
1848
|
-
* ```jsx
|
|
1849
|
-
* addEndListener={(node, done) => {
|
|
1850
|
-
* // use the css transitionend event to mark the finish of a transition
|
|
1851
|
-
* node.addEventListener('transitionend', done, false);
|
|
1852
|
-
* }}
|
|
1853
|
-
* ```
|
|
1854
|
-
*/
|
|
1855
|
-
addEndListener: PropTypes.func,
|
|
1856
|
-
|
|
1857
|
-
/**
|
|
1858
|
-
* Callback fired before the "entering" status is applied. An extra parameter
|
|
1859
|
-
* `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
|
|
1860
|
-
*
|
|
1861
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
1862
|
-
*
|
|
1863
|
-
* @type Function(node: HtmlElement, isAppearing: bool) -> void
|
|
1864
|
-
*/
|
|
1865
|
-
onEnter: PropTypes.func,
|
|
1866
|
-
|
|
1867
|
-
/**
|
|
1868
|
-
* Callback fired after the "entering" status is applied. An extra parameter
|
|
1869
|
-
* `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
|
|
1870
|
-
*
|
|
1871
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
1872
|
-
*
|
|
1873
|
-
* @type Function(node: HtmlElement, isAppearing: bool)
|
|
1874
|
-
*/
|
|
1875
|
-
onEntering: PropTypes.func,
|
|
1876
|
-
|
|
1877
|
-
/**
|
|
1878
|
-
* Callback fired after the "entered" status is applied. An extra parameter
|
|
1879
|
-
* `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
|
|
1880
|
-
*
|
|
1881
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
1882
|
-
*
|
|
1883
|
-
* @type Function(node: HtmlElement, isAppearing: bool) -> void
|
|
1884
|
-
*/
|
|
1885
|
-
onEntered: PropTypes.func,
|
|
1886
|
-
|
|
1887
|
-
/**
|
|
1888
|
-
* Callback fired before the "exiting" status is applied.
|
|
1889
|
-
*
|
|
1890
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
1891
|
-
*
|
|
1892
|
-
* @type Function(node: HtmlElement) -> void
|
|
1893
|
-
*/
|
|
1894
|
-
onExit: PropTypes.func,
|
|
1895
|
-
|
|
1896
|
-
/**
|
|
1897
|
-
* Callback fired after the "exiting" status is applied.
|
|
1898
|
-
*
|
|
1899
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
1900
|
-
*
|
|
1901
|
-
* @type Function(node: HtmlElement) -> void
|
|
1902
|
-
*/
|
|
1903
|
-
onExiting: PropTypes.func,
|
|
1904
|
-
|
|
1905
|
-
/**
|
|
1906
|
-
* Callback fired after the "exited" status is applied.
|
|
1907
|
-
*
|
|
1908
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed
|
|
1909
|
-
*
|
|
1910
|
-
* @type Function(node: HtmlElement) -> void
|
|
1911
|
-
*/
|
|
1912
|
-
onExited: PropTypes.func
|
|
1913
|
-
} : {}; // Name the function so it is clearer in the documentation
|
|
1914
|
-
|
|
1915
|
-
function noop() {}
|
|
1916
|
-
|
|
1917
|
-
Transition.defaultProps = {
|
|
1918
|
-
in: false,
|
|
1919
|
-
mountOnEnter: false,
|
|
1920
|
-
unmountOnExit: false,
|
|
1921
|
-
appear: false,
|
|
1922
|
-
enter: true,
|
|
1923
|
-
exit: true,
|
|
1924
|
-
onEnter: noop,
|
|
1925
|
-
onEntering: noop,
|
|
1926
|
-
onEntered: noop,
|
|
1927
|
-
onExit: noop,
|
|
1928
|
-
onExiting: noop,
|
|
1929
|
-
onExited: noop
|
|
1930
|
-
};
|
|
1931
|
-
Transition.UNMOUNTED = UNMOUNTED;
|
|
1932
|
-
Transition.EXITED = EXITED;
|
|
1933
|
-
Transition.ENTERING = ENTERING;
|
|
1934
|
-
Transition.ENTERED = ENTERED;
|
|
1935
|
-
Transition.EXITING = EXITING;
|
|
1936
|
-
|
|
1937
|
-
var _addClass = function addClass$1(node, classes) {
|
|
1938
|
-
return node && classes && classes.split(' ').forEach(function (c) {
|
|
1939
|
-
return addClass(node, c);
|
|
1940
|
-
});
|
|
1941
|
-
};
|
|
1942
|
-
|
|
1943
|
-
var removeClass = function removeClass(node, classes) {
|
|
1944
|
-
return node && classes && classes.split(' ').forEach(function (c) {
|
|
1945
|
-
return removeClass$1(node, c);
|
|
1946
|
-
});
|
|
1947
|
-
};
|
|
1948
|
-
/**
|
|
1949
|
-
* A transition component inspired by the excellent
|
|
1950
|
-
* [ng-animate](https://docs.angularjs.org/api/ngAnimate) library, you should
|
|
1951
|
-
* use it if you're using CSS transitions or animations. It's built upon the
|
|
1952
|
-
* [`Transition`](https://reactcommunity.org/react-transition-group/transition)
|
|
1953
|
-
* component, so it inherits all of its props.
|
|
1954
|
-
*
|
|
1955
|
-
* `CSSTransition` applies a pair of class names during the `appear`, `enter`,
|
|
1956
|
-
* and `exit` states of the transition. The first class is applied and then a
|
|
1957
|
-
* second `*-active` class in order to activate the CSS transition. After the
|
|
1958
|
-
* transition, matching `*-done` class names are applied to persist the
|
|
1959
|
-
* transition state.
|
|
1960
|
-
*
|
|
1961
|
-
* ```jsx
|
|
1962
|
-
* function App() {
|
|
1963
|
-
* const [inProp, setInProp] = useState(false);
|
|
1964
|
-
* return (
|
|
1965
|
-
* <div>
|
|
1966
|
-
* <CSSTransition in={inProp} timeout={200} classNames="my-node">
|
|
1967
|
-
* <div>
|
|
1968
|
-
* {"I'll receive my-node-* classes"}
|
|
1969
|
-
* </div>
|
|
1970
|
-
* </CSSTransition>
|
|
1971
|
-
* <button type="button" onClick={() => setInProp(true)}>
|
|
1972
|
-
* Click to Enter
|
|
1973
|
-
* </button>
|
|
1974
|
-
* </div>
|
|
1975
|
-
* );
|
|
1976
|
-
* }
|
|
1977
|
-
* ```
|
|
1978
|
-
*
|
|
1979
|
-
* When the `in` prop is set to `true`, the child component will first receive
|
|
1980
|
-
* the class `example-enter`, then the `example-enter-active` will be added in
|
|
1981
|
-
* the next tick. `CSSTransition` [forces a
|
|
1982
|
-
* reflow](https://github.com/reactjs/react-transition-group/blob/5007303e729a74be66a21c3e2205e4916821524b/src/CSSTransition.js#L208-L215)
|
|
1983
|
-
* between before adding the `example-enter-active`. This is an important trick
|
|
1984
|
-
* because it allows us to transition between `example-enter` and
|
|
1985
|
-
* `example-enter-active` even though they were added immediately one after
|
|
1986
|
-
* another. Most notably, this is what makes it possible for us to animate
|
|
1987
|
-
* _appearance_.
|
|
1988
|
-
*
|
|
1989
|
-
* ```css
|
|
1990
|
-
* .my-node-enter {
|
|
1991
|
-
* opacity: 0;
|
|
1992
|
-
* }
|
|
1993
|
-
* .my-node-enter-active {
|
|
1994
|
-
* opacity: 1;
|
|
1995
|
-
* transition: opacity 200ms;
|
|
1996
|
-
* }
|
|
1997
|
-
* .my-node-exit {
|
|
1998
|
-
* opacity: 1;
|
|
1999
|
-
* }
|
|
2000
|
-
* .my-node-exit-active {
|
|
2001
|
-
* opacity: 0;
|
|
2002
|
-
* transition: opacity 200ms;
|
|
2003
|
-
* }
|
|
2004
|
-
* ```
|
|
2005
|
-
*
|
|
2006
|
-
* `*-active` classes represent which styles you want to animate **to**, so it's
|
|
2007
|
-
* important to add `transition` declaration only to them, otherwise transitions
|
|
2008
|
-
* might not behave as intended! This might not be obvious when the transitions
|
|
2009
|
-
* are symmetrical, i.e. when `*-enter-active` is the same as `*-exit`, like in
|
|
2010
|
-
* the example above (minus `transition`), but it becomes apparent in more
|
|
2011
|
-
* complex transitions.
|
|
2012
|
-
*
|
|
2013
|
-
* **Note**: If you're using the
|
|
2014
|
-
* [`appear`](http://reactcommunity.org/react-transition-group/transition#Transition-prop-appear)
|
|
2015
|
-
* prop, make sure to define styles for `.appear-*` classes as well.
|
|
2016
|
-
*/
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
var CSSTransition = /*#__PURE__*/function (_React$Component) {
|
|
2020
|
-
_inheritsLoose(CSSTransition, _React$Component);
|
|
2021
|
-
|
|
2022
|
-
function CSSTransition() {
|
|
2023
|
-
var _this;
|
|
2024
|
-
|
|
2025
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2026
|
-
args[_key] = arguments[_key];
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
2030
|
-
_this.appliedClasses = {
|
|
2031
|
-
appear: {},
|
|
2032
|
-
enter: {},
|
|
2033
|
-
exit: {}
|
|
2034
|
-
};
|
|
2035
|
-
|
|
2036
|
-
_this.onEnter = function (maybeNode, maybeAppearing) {
|
|
2037
|
-
var _this$resolveArgument = _this.resolveArguments(maybeNode, maybeAppearing),
|
|
2038
|
-
node = _this$resolveArgument[0],
|
|
2039
|
-
appearing = _this$resolveArgument[1];
|
|
2040
|
-
|
|
2041
|
-
_this.removeClasses(node, 'exit');
|
|
2042
|
-
|
|
2043
|
-
_this.addClass(node, appearing ? 'appear' : 'enter', 'base');
|
|
2044
|
-
|
|
2045
|
-
if (_this.props.onEnter) {
|
|
2046
|
-
_this.props.onEnter(maybeNode, maybeAppearing);
|
|
2047
|
-
}
|
|
2048
|
-
};
|
|
2049
|
-
|
|
2050
|
-
_this.onEntering = function (maybeNode, maybeAppearing) {
|
|
2051
|
-
var _this$resolveArgument2 = _this.resolveArguments(maybeNode, maybeAppearing),
|
|
2052
|
-
node = _this$resolveArgument2[0],
|
|
2053
|
-
appearing = _this$resolveArgument2[1];
|
|
2054
|
-
|
|
2055
|
-
var type = appearing ? 'appear' : 'enter';
|
|
2056
|
-
|
|
2057
|
-
_this.addClass(node, type, 'active');
|
|
2058
|
-
|
|
2059
|
-
if (_this.props.onEntering) {
|
|
2060
|
-
_this.props.onEntering(maybeNode, maybeAppearing);
|
|
2061
|
-
}
|
|
2062
|
-
};
|
|
2063
|
-
|
|
2064
|
-
_this.onEntered = function (maybeNode, maybeAppearing) {
|
|
2065
|
-
var _this$resolveArgument3 = _this.resolveArguments(maybeNode, maybeAppearing),
|
|
2066
|
-
node = _this$resolveArgument3[0],
|
|
2067
|
-
appearing = _this$resolveArgument3[1];
|
|
2068
|
-
|
|
2069
|
-
var type = appearing ? 'appear' : 'enter';
|
|
2070
|
-
|
|
2071
|
-
_this.removeClasses(node, type);
|
|
2072
|
-
|
|
2073
|
-
_this.addClass(node, type, 'done');
|
|
2074
|
-
|
|
2075
|
-
if (_this.props.onEntered) {
|
|
2076
|
-
_this.props.onEntered(maybeNode, maybeAppearing);
|
|
2077
|
-
}
|
|
2078
|
-
};
|
|
2079
|
-
|
|
2080
|
-
_this.onExit = function (maybeNode) {
|
|
2081
|
-
var _this$resolveArgument4 = _this.resolveArguments(maybeNode),
|
|
2082
|
-
node = _this$resolveArgument4[0];
|
|
2083
|
-
|
|
2084
|
-
_this.removeClasses(node, 'appear');
|
|
2085
|
-
|
|
2086
|
-
_this.removeClasses(node, 'enter');
|
|
2087
|
-
|
|
2088
|
-
_this.addClass(node, 'exit', 'base');
|
|
2089
|
-
|
|
2090
|
-
if (_this.props.onExit) {
|
|
2091
|
-
_this.props.onExit(maybeNode);
|
|
2092
|
-
}
|
|
2093
|
-
};
|
|
2094
|
-
|
|
2095
|
-
_this.onExiting = function (maybeNode) {
|
|
2096
|
-
var _this$resolveArgument5 = _this.resolveArguments(maybeNode),
|
|
2097
|
-
node = _this$resolveArgument5[0];
|
|
2098
|
-
|
|
2099
|
-
_this.addClass(node, 'exit', 'active');
|
|
2100
|
-
|
|
2101
|
-
if (_this.props.onExiting) {
|
|
2102
|
-
_this.props.onExiting(maybeNode);
|
|
2103
|
-
}
|
|
2104
|
-
};
|
|
2105
|
-
|
|
2106
|
-
_this.onExited = function (maybeNode) {
|
|
2107
|
-
var _this$resolveArgument6 = _this.resolveArguments(maybeNode),
|
|
2108
|
-
node = _this$resolveArgument6[0];
|
|
2109
|
-
|
|
2110
|
-
_this.removeClasses(node, 'exit');
|
|
2111
|
-
|
|
2112
|
-
_this.addClass(node, 'exit', 'done');
|
|
2113
|
-
|
|
2114
|
-
if (_this.props.onExited) {
|
|
2115
|
-
_this.props.onExited(maybeNode);
|
|
2116
|
-
}
|
|
2117
|
-
};
|
|
2118
|
-
|
|
2119
|
-
_this.resolveArguments = function (maybeNode, maybeAppearing) {
|
|
2120
|
-
return _this.props.nodeRef ? [_this.props.nodeRef.current, maybeNode] // here `maybeNode` is actually `appearing`
|
|
2121
|
-
: [maybeNode, maybeAppearing];
|
|
2122
|
-
};
|
|
2123
|
-
|
|
2124
|
-
_this.getClassNames = function (type) {
|
|
2125
|
-
var classNames = _this.props.classNames;
|
|
2126
|
-
var isStringClassNames = typeof classNames === 'string';
|
|
2127
|
-
var prefix = isStringClassNames && classNames ? classNames + "-" : '';
|
|
2128
|
-
var baseClassName = isStringClassNames ? "" + prefix + type : classNames[type];
|
|
2129
|
-
var activeClassName = isStringClassNames ? baseClassName + "-active" : classNames[type + "Active"];
|
|
2130
|
-
var doneClassName = isStringClassNames ? baseClassName + "-done" : classNames[type + "Done"];
|
|
2131
|
-
return {
|
|
2132
|
-
baseClassName: baseClassName,
|
|
2133
|
-
activeClassName: activeClassName,
|
|
2134
|
-
doneClassName: doneClassName
|
|
2135
|
-
};
|
|
2136
|
-
};
|
|
2137
|
-
|
|
2138
|
-
return _this;
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2141
|
-
var _proto = CSSTransition.prototype;
|
|
2142
|
-
|
|
2143
|
-
_proto.addClass = function addClass(node, type, phase) {
|
|
2144
|
-
var className = this.getClassNames(type)[phase + "ClassName"];
|
|
2145
|
-
|
|
2146
|
-
var _this$getClassNames = this.getClassNames('enter'),
|
|
2147
|
-
doneClassName = _this$getClassNames.doneClassName;
|
|
2148
|
-
|
|
2149
|
-
if (type === 'appear' && phase === 'done' && doneClassName) {
|
|
2150
|
-
className += " " + doneClassName;
|
|
2151
|
-
} // This is to force a repaint,
|
|
2152
|
-
// which is necessary in order to transition styles when adding a class name.
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
if (phase === 'active') {
|
|
2156
|
-
if (node) forceReflow(node);
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
if (className) {
|
|
2160
|
-
this.appliedClasses[type][phase] = className;
|
|
2161
|
-
|
|
2162
|
-
_addClass(node, className);
|
|
2163
|
-
}
|
|
2164
|
-
};
|
|
2165
|
-
|
|
2166
|
-
_proto.removeClasses = function removeClasses(node, type) {
|
|
2167
|
-
var _this$appliedClasses$ = this.appliedClasses[type],
|
|
2168
|
-
baseClassName = _this$appliedClasses$.base,
|
|
2169
|
-
activeClassName = _this$appliedClasses$.active,
|
|
2170
|
-
doneClassName = _this$appliedClasses$.done;
|
|
2171
|
-
this.appliedClasses[type] = {};
|
|
2172
|
-
|
|
2173
|
-
if (baseClassName) {
|
|
2174
|
-
removeClass(node, baseClassName);
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
if (activeClassName) {
|
|
2178
|
-
removeClass(node, activeClassName);
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
if (doneClassName) {
|
|
2182
|
-
removeClass(node, doneClassName);
|
|
2183
|
-
}
|
|
2184
|
-
};
|
|
2185
|
-
|
|
2186
|
-
_proto.render = function render() {
|
|
2187
|
-
var _this$props = this.props;
|
|
2188
|
-
_this$props.classNames;
|
|
2189
|
-
var props = _objectWithoutPropertiesLoose(_this$props, ["classNames"]);
|
|
2190
|
-
|
|
2191
|
-
return /*#__PURE__*/React.createElement(Transition, _extends({}, props, {
|
|
2192
|
-
onEnter: this.onEnter,
|
|
2193
|
-
onEntered: this.onEntered,
|
|
2194
|
-
onEntering: this.onEntering,
|
|
2195
|
-
onExit: this.onExit,
|
|
2196
|
-
onExiting: this.onExiting,
|
|
2197
|
-
onExited: this.onExited
|
|
2198
|
-
}));
|
|
2199
|
-
};
|
|
2200
|
-
|
|
2201
|
-
return CSSTransition;
|
|
2202
|
-
}(React.Component);
|
|
2203
|
-
|
|
2204
|
-
CSSTransition.defaultProps = {
|
|
2205
|
-
classNames: ''
|
|
2206
|
-
};
|
|
2207
|
-
CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, Transition.propTypes, {
|
|
2208
|
-
/**
|
|
2209
|
-
* The animation classNames applied to the component as it appears, enters,
|
|
2210
|
-
* exits or has finished the transition. A single name can be provided, which
|
|
2211
|
-
* will be suffixed for each stage, e.g. `classNames="fade"` applies:
|
|
2212
|
-
*
|
|
2213
|
-
* - `fade-appear`, `fade-appear-active`, `fade-appear-done`
|
|
2214
|
-
* - `fade-enter`, `fade-enter-active`, `fade-enter-done`
|
|
2215
|
-
* - `fade-exit`, `fade-exit-active`, `fade-exit-done`
|
|
2216
|
-
*
|
|
2217
|
-
* A few details to note about how these classes are applied:
|
|
2218
|
-
*
|
|
2219
|
-
* 1. They are _joined_ with the ones that are already defined on the child
|
|
2220
|
-
* component, so if you want to add some base styles, you can use
|
|
2221
|
-
* `className` without worrying that it will be overridden.
|
|
2222
|
-
*
|
|
2223
|
-
* 2. If the transition component mounts with `in={false}`, no classes are
|
|
2224
|
-
* applied yet. You might be expecting `*-exit-done`, but if you think
|
|
2225
|
-
* about it, a component cannot finish exiting if it hasn't entered yet.
|
|
2226
|
-
*
|
|
2227
|
-
* 2. `fade-appear-done` and `fade-enter-done` will _both_ be applied. This
|
|
2228
|
-
* allows you to define different behavior for when appearing is done and
|
|
2229
|
-
* when regular entering is done, using selectors like
|
|
2230
|
-
* `.fade-enter-done:not(.fade-appear-done)`. For example, you could apply
|
|
2231
|
-
* an epic entrance animation when element first appears in the DOM using
|
|
2232
|
-
* [Animate.css](https://daneden.github.io/animate.css/). Otherwise you can
|
|
2233
|
-
* simply use `fade-enter-done` for defining both cases.
|
|
2234
|
-
*
|
|
2235
|
-
* Each individual classNames can also be specified independently like:
|
|
2236
|
-
*
|
|
2237
|
-
* ```js
|
|
2238
|
-
* classNames={{
|
|
2239
|
-
* appear: 'my-appear',
|
|
2240
|
-
* appearActive: 'my-active-appear',
|
|
2241
|
-
* appearDone: 'my-done-appear',
|
|
2242
|
-
* enter: 'my-enter',
|
|
2243
|
-
* enterActive: 'my-active-enter',
|
|
2244
|
-
* enterDone: 'my-done-enter',
|
|
2245
|
-
* exit: 'my-exit',
|
|
2246
|
-
* exitActive: 'my-active-exit',
|
|
2247
|
-
* exitDone: 'my-done-exit',
|
|
2248
|
-
* }}
|
|
2249
|
-
* ```
|
|
2250
|
-
*
|
|
2251
|
-
* If you want to set these classes using CSS Modules:
|
|
2252
|
-
*
|
|
2253
|
-
* ```js
|
|
2254
|
-
* import styles from './styles.css';
|
|
2255
|
-
* ```
|
|
2256
|
-
*
|
|
2257
|
-
* you might want to use camelCase in your CSS file, that way could simply
|
|
2258
|
-
* spread them instead of listing them one by one:
|
|
2259
|
-
*
|
|
2260
|
-
* ```js
|
|
2261
|
-
* classNames={{ ...styles }}
|
|
2262
|
-
* ```
|
|
2263
|
-
*
|
|
2264
|
-
* @type {string | {
|
|
2265
|
-
* appear?: string,
|
|
2266
|
-
* appearActive?: string,
|
|
2267
|
-
* appearDone?: string,
|
|
2268
|
-
* enter?: string,
|
|
2269
|
-
* enterActive?: string,
|
|
2270
|
-
* enterDone?: string,
|
|
2271
|
-
* exit?: string,
|
|
2272
|
-
* exitActive?: string,
|
|
2273
|
-
* exitDone?: string,
|
|
2274
|
-
* }}
|
|
2275
|
-
*/
|
|
2276
|
-
classNames: classNamesShape,
|
|
2277
|
-
|
|
2278
|
-
/**
|
|
2279
|
-
* A `<Transition>` callback fired immediately after the 'enter' or 'appear' class is
|
|
2280
|
-
* applied.
|
|
2281
|
-
*
|
|
2282
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
2283
|
-
*
|
|
2284
|
-
* @type Function(node: HtmlElement, isAppearing: bool)
|
|
2285
|
-
*/
|
|
2286
|
-
onEnter: PropTypes.func,
|
|
2287
|
-
|
|
2288
|
-
/**
|
|
2289
|
-
* A `<Transition>` callback fired immediately after the 'enter-active' or
|
|
2290
|
-
* 'appear-active' class is applied.
|
|
2291
|
-
*
|
|
2292
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
2293
|
-
*
|
|
2294
|
-
* @type Function(node: HtmlElement, isAppearing: bool)
|
|
2295
|
-
*/
|
|
2296
|
-
onEntering: PropTypes.func,
|
|
2297
|
-
|
|
2298
|
-
/**
|
|
2299
|
-
* A `<Transition>` callback fired immediately after the 'enter' or
|
|
2300
|
-
* 'appear' classes are **removed** and the `done` class is added to the DOM node.
|
|
2301
|
-
*
|
|
2302
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed.
|
|
2303
|
-
*
|
|
2304
|
-
* @type Function(node: HtmlElement, isAppearing: bool)
|
|
2305
|
-
*/
|
|
2306
|
-
onEntered: PropTypes.func,
|
|
2307
|
-
|
|
2308
|
-
/**
|
|
2309
|
-
* A `<Transition>` callback fired immediately after the 'exit' class is
|
|
2310
|
-
* applied.
|
|
2311
|
-
*
|
|
2312
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed
|
|
2313
|
-
*
|
|
2314
|
-
* @type Function(node: HtmlElement)
|
|
2315
|
-
*/
|
|
2316
|
-
onExit: PropTypes.func,
|
|
2317
|
-
|
|
2318
|
-
/**
|
|
2319
|
-
* A `<Transition>` callback fired immediately after the 'exit-active' is applied.
|
|
2320
|
-
*
|
|
2321
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed
|
|
2322
|
-
*
|
|
2323
|
-
* @type Function(node: HtmlElement)
|
|
2324
|
-
*/
|
|
2325
|
-
onExiting: PropTypes.func,
|
|
2326
|
-
|
|
2327
|
-
/**
|
|
2328
|
-
* A `<Transition>` callback fired immediately after the 'exit' classes
|
|
2329
|
-
* are **removed** and the `exit-done` class is added to the DOM node.
|
|
2330
|
-
*
|
|
2331
|
-
* **Note**: when `nodeRef` prop is passed, `node` is not passed
|
|
2332
|
-
*
|
|
2333
|
-
* @type Function(node: HtmlElement)
|
|
2334
|
-
*/
|
|
2335
|
-
onExited: PropTypes.func
|
|
2336
|
-
}) : {};
|
|
2337
|
-
|
|
2338
|
-
const DRAWER_ITEM_MIN_RESIZE_WIDTH = 200;
|
|
2339
|
-
const DRAWER_ITEM_MAX_RESIZE_WIDTH = 800;
|
|
2340
|
-
const DRAWER_ITEM_INITIAL_RESIZE_WIDTH = 400;
|
|
2341
|
-
function getEventClientX(e) {
|
|
2342
|
-
var _a, _b;
|
|
2343
|
-
return 'touches' in e ? ((_b = (_a = e.touches[0]) === null || _a === undefined ? undefined : _a.clientX) !== null && _b !== undefined ? _b : 0) : e.clientX;
|
|
2344
|
-
}
|
|
2345
|
-
function useResizeHandlers({ onStart, onMove, onEnd }) {
|
|
2346
|
-
const initialXPosition = React__namespace.useRef(0);
|
|
2347
|
-
const currentXPosition = React__namespace.useRef(0);
|
|
2348
|
-
const handleMove = React__namespace.useCallback((e) => {
|
|
2349
|
-
const currentX = getEventClientX(e);
|
|
2350
|
-
if (currentXPosition.current === currentX) {
|
|
2351
|
-
return;
|
|
2352
|
-
}
|
|
2353
|
-
currentXPosition.current = currentX;
|
|
2354
|
-
const delta = initialXPosition.current - currentX;
|
|
2355
|
-
onMove(delta);
|
|
2356
|
-
}, [onMove]);
|
|
2357
|
-
const handleEnd = React__namespace.useCallback((e) => {
|
|
2358
|
-
window.removeEventListener('mousemove', handleMove);
|
|
2359
|
-
window.removeEventListener('touchmove', handleMove);
|
|
2360
|
-
document.body.style.removeProperty('user-select');
|
|
2361
|
-
document.body.style.removeProperty('-webkit-user-select');
|
|
2362
|
-
document.body.style.removeProperty('cursor');
|
|
2363
|
-
const currentX = getEventClientX(e);
|
|
2364
|
-
const delta = initialXPosition.current - currentX;
|
|
2365
|
-
onEnd(delta);
|
|
2366
|
-
}, [handleMove, onEnd]);
|
|
2367
|
-
const handleStart = React__namespace.useCallback((e) => {
|
|
2368
|
-
const currentX = getEventClientX(e);
|
|
2369
|
-
initialXPosition.current = currentX;
|
|
2370
|
-
currentXPosition.current = currentX;
|
|
2371
|
-
window.addEventListener('mouseup', handleEnd, { once: true });
|
|
2372
|
-
window.addEventListener('touchend', handleEnd, { once: true });
|
|
2373
|
-
window.addEventListener('touchcancel', handleEnd, { once: true });
|
|
2374
|
-
window.addEventListener('mousemove', handleMove);
|
|
2375
|
-
window.addEventListener('touchmove', handleMove);
|
|
2376
|
-
document.body.style.setProperty('user-select', 'none');
|
|
2377
|
-
document.body.style.setProperty('-webkit-user-select', 'none');
|
|
2378
|
-
document.body.style.setProperty('cursor', 'col-resize');
|
|
2379
|
-
onStart();
|
|
2380
|
-
}, [handleEnd, handleMove, onStart]);
|
|
2381
|
-
return {
|
|
2382
|
-
onMouseDown: handleStart,
|
|
2383
|
-
onTouchStart: handleStart,
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2386
|
-
function useResizableDrawerItem(params) {
|
|
2387
|
-
const { direction, width, minResizeWidth = DRAWER_ITEM_MIN_RESIZE_WIDTH, maxResizeWidth = DRAWER_ITEM_MAX_RESIZE_WIDTH, onResizeStart, onResize, } = params;
|
|
2388
|
-
const [isResizing, setIsResizing] = React__namespace.useState(false);
|
|
2389
|
-
const [resizeDelta, setResizeDelta] = React__namespace.useState(0);
|
|
2390
|
-
const [internalWidth, setInternalWidth] = React__namespace.useState(width !== null && width !== undefined ? width : DRAWER_ITEM_INITIAL_RESIZE_WIDTH);
|
|
2391
|
-
const getClampedWidth = React__namespace.useCallback((width) => Math.min(Math.max(width, minResizeWidth), maxResizeWidth), [minResizeWidth, maxResizeWidth]);
|
|
2392
|
-
const getResizedWidth = React__namespace.useCallback((delta) => {
|
|
2393
|
-
const signedDelta = direction === 'right' ? delta : -delta;
|
|
2394
|
-
const newWidth = (width !== null && width !== undefined ? width : internalWidth) + signedDelta;
|
|
2395
|
-
return getClampedWidth(newWidth);
|
|
2396
|
-
}, [width, internalWidth, direction, getClampedWidth]);
|
|
2397
|
-
const onStart = React__namespace.useCallback(() => {
|
|
2398
|
-
setIsResizing(true);
|
|
2399
|
-
setResizeDelta(0);
|
|
2400
|
-
onResizeStart === null || onResizeStart === undefined ? undefined : onResizeStart();
|
|
2401
|
-
}, [onResizeStart]);
|
|
2402
|
-
const onMove = React__namespace.useCallback((delta) => {
|
|
2403
|
-
setResizeDelta(delta);
|
|
2404
|
-
}, []);
|
|
2405
|
-
const onEnd = React__namespace.useCallback((delta) => {
|
|
2406
|
-
const newWidth = getResizedWidth(delta);
|
|
2407
|
-
setIsResizing(false);
|
|
2408
|
-
setInternalWidth(newWidth);
|
|
2409
|
-
onResize === null || onResize === undefined ? undefined : onResize(newWidth);
|
|
2410
|
-
}, [getResizedWidth, onResize]);
|
|
2411
|
-
const displayWidth = isResizing
|
|
2412
|
-
? getResizedWidth(resizeDelta)
|
|
2413
|
-
: getClampedWidth(width !== null && width !== undefined ? width : internalWidth);
|
|
2414
|
-
const handlers = useResizeHandlers({ onStart, onMove, onEnd });
|
|
2415
|
-
return { resizedWidth: displayWidth, resizerHandlers: handlers };
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
var css_248z = ".gn-drawer{--_--item-shadow-default:0 1px 5px 0 var(--g-color-sfx-shadow);--_--item-position:fixed;--_--resizer-width:8px;--_--resizer-color:var(--g-color-base-generic);--_--resizer-handle-color:var(--g-color-line-generic);--_--resizer-handle-color-hover:var(--g-color-line-generic-hover);--_--resizer-z-index:100;--_--veil-background-color:var(--g-color-sfx-veil);pointer-events:none}.gn-drawer_hideVeil{--_--item-shadow:var(--gn-drawer-item-shadow,var(--_--item-shadow-default))}.gn-drawer__item{background-color:var(--g-color-base-background);bottom:0;box-shadow:var(--_--item-shadow,none);height:100%;left:var(--gn-aside-header-size);pointer-events:auto;position:var(--gn-drawer-item-position,var(--_--item-position));top:0;will-change:transform;z-index:var(--gn-drawer-item-z-index)}.gn-drawer__item_direction_right{left:auto;right:0}.gn-drawer__item-transition-enter{transform:translate(-100%)}.gn-drawer__item-transition_direction_right-enter{transform:translate(100%)}.gn-drawer__item-transition-enter-active,.gn-drawer__item-transition_direction_right-enter-active{transform:translate(0);transition:transform .3s}.gn-drawer__item-transition-enter-done,.gn-drawer__item-transition_direction_right-enter-done{filter:blur(0);transform:translateZ(0)}.gn-drawer__item-transition-exit,.gn-drawer__item-transition_direction_right-exit{transform:translate(0)}.gn-drawer__item-transition-exit-active,.gn-drawer__item-transition_direction_right-exit-active{transition:transform .3s}.gn-drawer__item-transition-exit-active{transform:translate(-100%)}.gn-drawer__item-transition_direction_right-exit-active{transform:translate(100%)}.gn-drawer__item-transition-exit-done,.gn-drawer__item-transition_direction_right-exit-done,.gn-drawer__item_hidden{visibility:hidden}.gn-drawer__veil{background-color:var(--gn-drawer-veil-background-color,var(--_--veil-background-color));inset:0;pointer-events:auto;position:absolute;z-index:var(--gn-drawer-veil-z-index)}.gn-drawer__veil_hidden{display:none}.gn-drawer__veil-transition-enter{opacity:0}.gn-drawer__veil-transition-enter-active{opacity:1;transition:opacity .3s}.gn-drawer__veil-transition-exit{opacity:1}.gn-drawer__veil-transition-exit-active{opacity:0;transition:opacity .3s}.gn-drawer__veil-transition-exit-done{visibility:hidden}.gn-drawer__resizer-handle{background:var(--gn-drawer-item-resizer-handle-color,var(--_--resizer-handle-color));border-radius:2px;height:28px;width:2px}.gn-drawer__resizer{align-items:center;background:var(--gn-drawer-item-resizer-color,var(--_--resizer-color));cursor:col-resize;display:flex;flex-direction:column;height:100%;justify-content:center;position:absolute;top:0;width:var(--gn-drawer-item-resizer-width,var(--_--resizer-width));z-index:var(--gn-drawer-item-resizer-z-index,var(--_--resizer-z-index))}.gn-drawer__resizer_direction_right{left:0}.gn-drawer__resizer_direction_left{right:0}.gn-drawer__resizer:hover .gn-drawer__resizer-handle{background:var(--gn-drawer-item-resizer-handle-color-hover,var(--_--resizer-handle-color-hover))}";
|
|
2419
|
-
styleInject_es.styleInject(css_248z);
|
|
2420
|
-
|
|
2421
|
-
const b = cn.block('drawer');
|
|
2422
|
-
const TIMEOUT = 300;
|
|
2423
|
-
const DrawerItem = React.forwardRef(function DrawerItem(props, ref) {
|
|
2424
|
-
const { visible, content, children, direction = 'left', className, resizable, width, minResizeWidth, maxResizeWidth, onResizeStart, onResize, keepMounted = false, } = props;
|
|
2425
|
-
const [isInitialRender, setInitialRender] = React.useState(true);
|
|
2426
|
-
const itemRef = React.useRef(null);
|
|
2427
|
-
const handleRef = uikit.useForkRef(ref, itemRef);
|
|
2428
|
-
const cssDirection = direction === 'left' ? undefined : direction;
|
|
2429
|
-
const { resizedWidth, resizerHandlers } = useResizableDrawerItem({
|
|
2430
|
-
direction,
|
|
2431
|
-
width,
|
|
2432
|
-
minResizeWidth,
|
|
2433
|
-
maxResizeWidth,
|
|
2434
|
-
onResizeStart,
|
|
2435
|
-
onResize,
|
|
2436
|
-
});
|
|
2437
|
-
React.useEffect(() => {
|
|
2438
|
-
setInitialRender(true);
|
|
2439
|
-
}, [direction]);
|
|
2440
|
-
const resizerElement = resizable ? (React.createElement("div", Object.assign({ className: b('resizer', { direction }) }, resizerHandlers),
|
|
2441
|
-
React.createElement("div", { className: b('resizer-handle') }))) : null;
|
|
2442
|
-
return (React.createElement(CSSTransition, { in: visible, timeout: TIMEOUT, mountOnEnter: !keepMounted, unmountOnExit: !keepMounted, classNames: b('item-transition', { direction: cssDirection }), nodeRef: itemRef, onEnter: () => setInitialRender(false), onExit: () => setInitialRender(false) },
|
|
2443
|
-
React.createElement("div", { ref: handleRef, className: b('item', { direction: cssDirection, hidden: isInitialRender && !visible }, [className]), style: { width: resizable ? `${resizedWidth}px` : undefined } },
|
|
2444
|
-
resizerElement, children !== null && children !== undefined ? children : content)));
|
|
2445
|
-
});
|
|
2446
|
-
const Drawer = ({ className, veilClassName, children, style, onVeilClick, onEscape, hideVeil, disablePortal = true, keepMounted = false, }) => {
|
|
2447
|
-
let someItemVisible = false;
|
|
2448
|
-
React.Children.forEach(children, (child) => {
|
|
2449
|
-
if (React.isValidElement(child) && child.type === DrawerItem) {
|
|
2450
|
-
const childVisible = Boolean(child.props.visible);
|
|
2451
|
-
if (childVisible) {
|
|
2452
|
-
someItemVisible = true;
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
});
|
|
2456
|
-
React.useEffect(() => {
|
|
2457
|
-
function onKeyDown(event) {
|
|
2458
|
-
if (event.key === 'Escape') {
|
|
2459
|
-
onEscape === null || onEscape === undefined ? undefined : onEscape();
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2462
|
-
if (someItemVisible) {
|
|
2463
|
-
window.addEventListener('keydown', onKeyDown);
|
|
2464
|
-
}
|
|
2465
|
-
return () => {
|
|
2466
|
-
window.removeEventListener('keydown', onKeyDown);
|
|
2467
|
-
};
|
|
2468
|
-
}, [onEscape, someItemVisible]);
|
|
2469
|
-
const containerRef = React.useRef(null);
|
|
2470
|
-
const veilRef = React.useRef(null);
|
|
2471
|
-
const drawer = (React.createElement(Transition, { in: someItemVisible, timeout: { enter: 0, exit: TIMEOUT }, mountOnEnter: !keepMounted, unmountOnExit: !keepMounted, nodeRef: containerRef }, (state) => {
|
|
2472
|
-
const childrenVisible = someItemVisible && state === 'entered';
|
|
2473
|
-
return (React.createElement("div", { ref: containerRef, className: b({ hideVeil }, className), style: style },
|
|
2474
|
-
React.createElement(CSSTransition, { in: childrenVisible, timeout: TIMEOUT, unmountOnExit: true, classNames: b('veil-transition'), nodeRef: veilRef },
|
|
2475
|
-
React.createElement("div", { ref: veilRef, className: b('veil', { hidden: hideVeil }, veilClassName), onClick: onVeilClick })),
|
|
2476
|
-
React.Children.map(children, (child) => {
|
|
2477
|
-
if (React.isValidElement(child) &&
|
|
2478
|
-
child.type === DrawerItem) {
|
|
2479
|
-
const childVisible = Boolean(child.props.visible);
|
|
2480
|
-
return React.cloneElement(child, Object.assign(Object.assign({ keepMounted }, child.props), { visible: childVisible && childrenVisible }));
|
|
2481
|
-
}
|
|
2482
|
-
return child;
|
|
2483
|
-
})));
|
|
2484
|
-
}));
|
|
2485
|
-
if (disablePortal) {
|
|
2486
|
-
return drawer;
|
|
2487
|
-
}
|
|
2488
|
-
return React.createElement(uikit.Portal, null, drawer);
|
|
2489
|
-
};
|
|
2490
|
-
|
|
2491
|
-
exports.Drawer = Drawer;
|
|
2492
|
-
exports.DrawerItem = DrawerItem;
|
|
2493
|
-
//# sourceMappingURL=Drawer.js.map
|