@douyinfe/semi-animation-react 2.1.0-alpha.1 → 2.1.0-alpha.2

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.
@@ -1,208 +0,0 @@
1
- "use strict";
2
-
3
- var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
4
-
5
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
-
7
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
8
-
9
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
10
-
11
- _Object$defineProperty(exports, "__esModule", {
12
- value: true
13
- });
14
-
15
- exports.default = void 0;
16
-
17
- var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
18
-
19
- var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
20
-
21
- var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
22
-
23
- var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
24
-
25
- var _Animation = _interopRequireDefault(require("./Animation"));
26
-
27
- var _propTypes = _interopRequireDefault(require("prop-types"));
28
-
29
- var _react = _interopRequireWildcard(require("react"));
30
-
31
- var _noop = _interopRequireDefault(require("./utils/noop"));
32
-
33
- function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
34
-
35
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
36
-
37
- var __rest = void 0 && (void 0).__rest || function (s, e) {
38
- var t = {};
39
-
40
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && (0, _indexOf.default)(e).call(e, p) < 0) t[p] = s[p];
41
-
42
- if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
43
- if ((0, _indexOf.default)(e).call(e, p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
44
- }
45
- return t;
46
- };
47
- /* eslint-disable eqeqeq */
48
-
49
-
50
- class Transition extends _react.Component {
51
- constructor() {
52
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
53
- super(props);
54
-
55
- this._isControlled = () => {
56
- var _context;
57
-
58
- return (0, _includes.default)(_context = [true, false, 'enter', 'leave']).call(_context, this.props.state);
59
- };
60
-
61
- this.forwardInstance = instance => {
62
- this.instance = instance;
63
- };
64
-
65
- this.onRest = props => {
66
- const {
67
- state
68
- } = this.state;
69
-
70
- if (state === 'enter') {
71
- this.props.didEnter(props);
72
- } else if (state === 'leave') {
73
- this.setState({
74
- currentChildren: null,
75
- lastChildren: null
76
- });
77
- this.props.didLeave(props);
78
- }
79
-
80
- this.props.onRest(props);
81
- };
82
-
83
- this.onStart = props => {
84
- const {
85
- state
86
- } = this.state;
87
-
88
- if (state === 'enter') {
89
- this.props.willEnter(props);
90
- } else if (state === 'leave') {
91
- this.props.willLeave(props);
92
- }
93
-
94
- this.props.onStart(props);
95
- };
96
-
97
- this.state = {
98
- state: '',
99
- lastChildren: null,
100
- currentChildren: null
101
- };
102
- }
103
-
104
- static getDerivedStateFromProps(props, state) {
105
- const willUpdateStates = {};
106
-
107
- if (props.children !== state.currentChildren // && (props.children == null || state.currentChildren == null)
108
- ) {
109
- willUpdateStates.lastChildren = state.currentChildren;
110
- willUpdateStates.currentChildren = props.children;
111
-
112
- if (props.children == null) {
113
- willUpdateStates.state = 'leave';
114
- } else {
115
- willUpdateStates.state = 'enter';
116
- }
117
- }
118
-
119
- if (props.state != null) {
120
- willUpdateStates.state = props.state;
121
- }
122
-
123
- return willUpdateStates;
124
- }
125
-
126
- componentWillUnmount() {
127
- if (this.instance) {
128
- this.instance.destroy();
129
- this.instance = null;
130
- }
131
- }
132
-
133
- render() {
134
- const _a = this.props,
135
- {
136
- from: propsFrom,
137
- enter,
138
- leave
139
- } = _a,
140
- restProps = __rest(_a, ["from", "enter", "leave"]);
141
-
142
- let children; // eslint-disable-next-line prefer-const
143
-
144
- let {
145
- currentChildren,
146
- lastChildren,
147
- state
148
- } = this.state;
149
- let from = {};
150
- let to = {};
151
-
152
- const isControlled = this._isControlled();
153
-
154
- if (isControlled) {
155
- children = this.props.children;
156
- state = this.props.state;
157
- } else if (currentChildren == null && lastChildren == null) {
158
- return null;
159
- }
160
-
161
- if (state === 'enter') {
162
- from = propsFrom;
163
- to = enter;
164
-
165
- if (!isControlled) {
166
- children = currentChildren;
167
- }
168
- } else if (state === 'leave') {
169
- from = enter;
170
- to = leave;
171
-
172
- if (!isControlled) {
173
- children = lastChildren;
174
- }
175
- }
176
-
177
- return /*#__PURE__*/_react.default.createElement(_Animation.default, (0, _assign.default)({}, restProps, {
178
- force: true,
179
- from: from,
180
- to: to,
181
- onRest: this.onRest,
182
- onStart: this.onStart
183
- }), props => // eslint-disable-next-line no-nested-ternary
184
- typeof children === 'function' ? children(props) : /*#__PURE__*/(0, _react.isValidElement)(children) ? children : null);
185
- }
186
-
187
- }
188
-
189
- exports.default = Transition;
190
- Transition.propTypes = {
191
- children: _propTypes.default.any,
192
- from: _propTypes.default.object,
193
- enter: _propTypes.default.object,
194
- leave: _propTypes.default.object,
195
- willEnter: _propTypes.default.func,
196
- didEnter: _propTypes.default.func,
197
- willLeave: _propTypes.default.func,
198
- didLeave: _propTypes.default.func,
199
- state: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool])
200
- };
201
- Transition.defaultProps = {
202
- willEnter: _noop.default,
203
- didEnter: _noop.default,
204
- willLeave: _noop.default,
205
- didLeave: _noop.default,
206
- onStart: _noop.default,
207
- onRest: _noop.default
208
- };
@@ -1 +0,0 @@
1
- export default function invokeFns(fns: any[], args?: any[]): void;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
- _Object$defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
-
11
- exports.default = invokeFns;
12
-
13
- var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
14
-
15
- var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
16
-
17
- function invokeFns(fns) {
18
- let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
19
-
20
- if ((0, _isArray.default)(fns) && fns.length) {
21
- (0, _forEach.default)(fns).call(fns, fn => {
22
- if (typeof fn === 'function') {
23
- fn(...args);
24
- }
25
- });
26
- }
27
- }
@@ -1 +0,0 @@
1
- export default function noop(): void;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
-
9
- exports.default = noop;
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-empty-function
12
- function noop() {}
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,2 +0,0 @@
1
- export declare function upperCase(str: string, pos: number): string;
2
- export declare function lowerCase(str: string, pos: number): string;
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
- _Object$defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
-
11
- exports.lowerCase = lowerCase;
12
- exports.upperCase = upperCase;
13
-
14
- var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
15
-
16
- /* eslint-disable eqeqeq */
17
- function upperCase(str, pos) {
18
- if (typeof str === 'string') {
19
- var _context;
20
-
21
- return (0, _reduce.default)(_context = str // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
- // @ts-ignore
23
- .split()).call(_context, (total, cur, index) => pos == null || pos === index ? total + cur.toUpperCase() : total + cur, '');
24
- }
25
-
26
- return str;
27
- }
28
-
29
- function lowerCase(str, pos) {
30
- if (typeof str === 'string') {
31
- var _context2;
32
-
33
- return (0, _reduce.default)(_context2 = str // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
- // @ts-ignore
35
- .split()).call(_context2, (total, cur, index) => pos == null || pos === index ? total + cur.toLowerCase() : total + cur, '');
36
- }
37
-
38
- return str;
39
- }