@veritone-ce/design-system 2.8.7 → 2.8.9
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/dist/cjs/Accordion/Accordion.js +111 -0
- package/dist/cjs/Accordion/AccordionGroup.js +61 -0
- package/dist/cjs/Accordion/Context.js +39 -0
- package/dist/cjs/Accordion/styles.module.scss.js +7 -0
- package/dist/cjs/Badge/index.js +12 -3
- package/dist/cjs/bundled_modules/@react-spring/animated/dist/react-spring_animated.modern.js +338 -0
- package/dist/cjs/bundled_modules/@react-spring/core/dist/react-spring_core.modern.js +1799 -0
- package/dist/cjs/bundled_modules/@react-spring/rafz/dist/react-spring_rafz.modern.js +160 -0
- package/dist/cjs/bundled_modules/@react-spring/shared/dist/react-spring_shared.modern.js +775 -0
- package/dist/cjs/bundled_modules/@react-spring/web/dist/react-spring_web.modern.js +382 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/styles.css +1 -1
- package/dist/cjs/utils/isNil.js +8 -0
- package/dist/esm/Accordion/Accordion.js +107 -0
- package/dist/esm/Accordion/AccordionGroup.js +57 -0
- package/dist/esm/Accordion/Context.js +33 -0
- package/dist/esm/Accordion/styles.module.scss.js +3 -0
- package/dist/esm/Badge/index.js +12 -3
- package/dist/esm/bundled_modules/@react-spring/animated/dist/react-spring_animated.modern.js +308 -0
- package/dist/esm/bundled_modules/@react-spring/core/dist/react-spring_core.modern.js +1765 -0
- package/dist/esm/bundled_modules/@react-spring/rafz/dist/react-spring_rafz.modern.js +158 -0
- package/dist/esm/bundled_modules/@react-spring/shared/dist/react-spring_shared.modern.js +730 -0
- package/dist/esm/bundled_modules/@react-spring/web/dist/react-spring_web.modern.js +365 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/styles.css +1 -1
- package/dist/esm/utils/isNil.js +6 -0
- package/dist/types/Accordion/index.d.ts +3 -0
- package/dist/types/Badge/index.d.ts +6 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/utils/isNil.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1799 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactSpring_shared_modern = require('../../shared/dist/react-spring_shared.modern.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactSpring_animated_modern = require('../../animated/dist/react-spring_animated.modern.js');
|
|
6
|
+
var reactSpring_rafz_modern = require('../../rafz/dist/react-spring_rafz.modern.js');
|
|
7
|
+
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
+
|
|
27
|
+
// src/hooks/useChain.ts
|
|
28
|
+
function callProp(value, ...args) {
|
|
29
|
+
return reactSpring_shared_modern.is.fun(value) ? value(...args) : value;
|
|
30
|
+
}
|
|
31
|
+
var matchProp = (value, key) => value === true || !!(key && value && (reactSpring_shared_modern.is.fun(value) ? value(key) : reactSpring_shared_modern.toArray(value).includes(key)));
|
|
32
|
+
var resolveProp = (prop, key) => reactSpring_shared_modern.is.obj(prop) ? key && prop[key] : prop;
|
|
33
|
+
var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
|
|
34
|
+
var noopTransform = (value) => value;
|
|
35
|
+
var getDefaultProps = (props, transform = noopTransform) => {
|
|
36
|
+
let keys = DEFAULT_PROPS;
|
|
37
|
+
if (props.default && props.default !== true) {
|
|
38
|
+
props = props.default;
|
|
39
|
+
keys = Object.keys(props);
|
|
40
|
+
}
|
|
41
|
+
const defaults2 = {};
|
|
42
|
+
for (const key of keys) {
|
|
43
|
+
const value = transform(props[key], key);
|
|
44
|
+
if (!reactSpring_shared_modern.is.und(value)) {
|
|
45
|
+
defaults2[key] = value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return defaults2;
|
|
49
|
+
};
|
|
50
|
+
var DEFAULT_PROPS = [
|
|
51
|
+
"config",
|
|
52
|
+
"onProps",
|
|
53
|
+
"onStart",
|
|
54
|
+
"onChange",
|
|
55
|
+
"onPause",
|
|
56
|
+
"onResume",
|
|
57
|
+
"onRest"
|
|
58
|
+
];
|
|
59
|
+
var RESERVED_PROPS = {
|
|
60
|
+
config: 1,
|
|
61
|
+
from: 1,
|
|
62
|
+
to: 1,
|
|
63
|
+
ref: 1,
|
|
64
|
+
loop: 1,
|
|
65
|
+
reset: 1,
|
|
66
|
+
pause: 1,
|
|
67
|
+
cancel: 1,
|
|
68
|
+
reverse: 1,
|
|
69
|
+
immediate: 1,
|
|
70
|
+
default: 1,
|
|
71
|
+
delay: 1,
|
|
72
|
+
onProps: 1,
|
|
73
|
+
onStart: 1,
|
|
74
|
+
onChange: 1,
|
|
75
|
+
onPause: 1,
|
|
76
|
+
onResume: 1,
|
|
77
|
+
onRest: 1,
|
|
78
|
+
onResolve: 1,
|
|
79
|
+
// Transition props
|
|
80
|
+
items: 1,
|
|
81
|
+
trail: 1,
|
|
82
|
+
sort: 1,
|
|
83
|
+
expires: 1,
|
|
84
|
+
initial: 1,
|
|
85
|
+
enter: 1,
|
|
86
|
+
update: 1,
|
|
87
|
+
leave: 1,
|
|
88
|
+
children: 1,
|
|
89
|
+
onDestroyed: 1,
|
|
90
|
+
// Internal props
|
|
91
|
+
keys: 1,
|
|
92
|
+
callId: 1,
|
|
93
|
+
parentId: 1
|
|
94
|
+
};
|
|
95
|
+
function getForwardProps(props) {
|
|
96
|
+
const forward = {};
|
|
97
|
+
let count = 0;
|
|
98
|
+
reactSpring_shared_modern.eachProp(props, (value, prop) => {
|
|
99
|
+
if (!RESERVED_PROPS[prop]) {
|
|
100
|
+
forward[prop] = value;
|
|
101
|
+
count++;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
if (count) {
|
|
105
|
+
return forward;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function inferTo(props) {
|
|
109
|
+
const to2 = getForwardProps(props);
|
|
110
|
+
if (to2) {
|
|
111
|
+
const out = { to: to2 };
|
|
112
|
+
reactSpring_shared_modern.eachProp(props, (val, key) => key in to2 || (out[key] = val));
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
return { ...props };
|
|
116
|
+
}
|
|
117
|
+
function computeGoal(value) {
|
|
118
|
+
value = reactSpring_shared_modern.getFluidValue(value);
|
|
119
|
+
return reactSpring_shared_modern.is.arr(value) ? value.map(computeGoal) : reactSpring_shared_modern.isAnimatedString(value) ? reactSpring_shared_modern.Globals.createStringInterpolator({
|
|
120
|
+
range: [0, 1],
|
|
121
|
+
output: [value, value]
|
|
122
|
+
})(1) : value;
|
|
123
|
+
}
|
|
124
|
+
function hasProps(props) {
|
|
125
|
+
for (const _ in props) return true;
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
function isAsyncTo(to2) {
|
|
129
|
+
return reactSpring_shared_modern.is.fun(to2) || reactSpring_shared_modern.is.arr(to2) && reactSpring_shared_modern.is.obj(to2[0]);
|
|
130
|
+
}
|
|
131
|
+
function detachRefs(ctrl, ref) {
|
|
132
|
+
ctrl.ref?.delete(ctrl);
|
|
133
|
+
ref?.delete(ctrl);
|
|
134
|
+
}
|
|
135
|
+
function replaceRef(ctrl, ref) {
|
|
136
|
+
if (ref && ctrl.ref !== ref) {
|
|
137
|
+
ctrl.ref?.delete(ctrl);
|
|
138
|
+
ref.add(ctrl);
|
|
139
|
+
ctrl.ref = ref;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/constants.ts
|
|
144
|
+
var config = {
|
|
145
|
+
default: { tension: 170, friction: 26 }};
|
|
146
|
+
|
|
147
|
+
// src/AnimationConfig.ts
|
|
148
|
+
var defaults = {
|
|
149
|
+
...config.default,
|
|
150
|
+
mass: 1,
|
|
151
|
+
damping: 1,
|
|
152
|
+
easing: reactSpring_shared_modern.easings.linear,
|
|
153
|
+
clamp: false
|
|
154
|
+
};
|
|
155
|
+
var AnimationConfig = class {
|
|
156
|
+
constructor() {
|
|
157
|
+
/**
|
|
158
|
+
* The initial velocity of one or more values.
|
|
159
|
+
*
|
|
160
|
+
* @default 0
|
|
161
|
+
*/
|
|
162
|
+
this.velocity = 0;
|
|
163
|
+
Object.assign(this, defaults);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
function mergeConfig(config2, newConfig, defaultConfig) {
|
|
167
|
+
if (defaultConfig) {
|
|
168
|
+
defaultConfig = { ...defaultConfig };
|
|
169
|
+
sanitizeConfig(defaultConfig, newConfig);
|
|
170
|
+
newConfig = { ...defaultConfig, ...newConfig };
|
|
171
|
+
}
|
|
172
|
+
sanitizeConfig(config2, newConfig);
|
|
173
|
+
Object.assign(config2, newConfig);
|
|
174
|
+
for (const key in defaults) {
|
|
175
|
+
if (config2[key] == null) {
|
|
176
|
+
config2[key] = defaults[key];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
let { frequency, damping } = config2;
|
|
180
|
+
const { mass } = config2;
|
|
181
|
+
if (!reactSpring_shared_modern.is.und(frequency)) {
|
|
182
|
+
if (frequency < 0.01) frequency = 0.01;
|
|
183
|
+
if (damping < 0) damping = 0;
|
|
184
|
+
config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
|
|
185
|
+
config2.friction = 4 * Math.PI * damping * mass / frequency;
|
|
186
|
+
}
|
|
187
|
+
return config2;
|
|
188
|
+
}
|
|
189
|
+
function sanitizeConfig(config2, props) {
|
|
190
|
+
if (!reactSpring_shared_modern.is.und(props.decay)) {
|
|
191
|
+
config2.duration = void 0;
|
|
192
|
+
} else {
|
|
193
|
+
const isTensionConfig = !reactSpring_shared_modern.is.und(props.tension) || !reactSpring_shared_modern.is.und(props.friction);
|
|
194
|
+
if (isTensionConfig || !reactSpring_shared_modern.is.und(props.frequency) || !reactSpring_shared_modern.is.und(props.damping) || !reactSpring_shared_modern.is.und(props.mass)) {
|
|
195
|
+
config2.duration = void 0;
|
|
196
|
+
config2.decay = void 0;
|
|
197
|
+
}
|
|
198
|
+
if (isTensionConfig) {
|
|
199
|
+
config2.frequency = void 0;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/Animation.ts
|
|
205
|
+
var emptyArray = [];
|
|
206
|
+
var Animation = class {
|
|
207
|
+
constructor() {
|
|
208
|
+
this.changed = false;
|
|
209
|
+
this.values = emptyArray;
|
|
210
|
+
this.toValues = null;
|
|
211
|
+
this.fromValues = emptyArray;
|
|
212
|
+
this.config = new AnimationConfig();
|
|
213
|
+
this.immediate = false;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
function scheduleProps(callId, { key, props, defaultProps, state, actions }) {
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
let delay;
|
|
219
|
+
let timeout;
|
|
220
|
+
let cancel = matchProp(props.cancel ?? defaultProps?.cancel, key);
|
|
221
|
+
if (cancel) {
|
|
222
|
+
onStart();
|
|
223
|
+
} else {
|
|
224
|
+
if (!reactSpring_shared_modern.is.und(props.pause)) {
|
|
225
|
+
state.paused = matchProp(props.pause, key);
|
|
226
|
+
}
|
|
227
|
+
let pause = defaultProps?.pause;
|
|
228
|
+
if (pause !== true) {
|
|
229
|
+
pause = state.paused || matchProp(pause, key);
|
|
230
|
+
}
|
|
231
|
+
delay = callProp(props.delay || 0, key);
|
|
232
|
+
if (pause) {
|
|
233
|
+
state.resumeQueue.add(onResume);
|
|
234
|
+
actions.pause();
|
|
235
|
+
} else {
|
|
236
|
+
actions.resume();
|
|
237
|
+
onResume();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function onPause() {
|
|
241
|
+
state.resumeQueue.add(onResume);
|
|
242
|
+
state.timeouts.delete(timeout);
|
|
243
|
+
timeout.cancel();
|
|
244
|
+
delay = timeout.time - reactSpring_rafz_modern.raf.now();
|
|
245
|
+
}
|
|
246
|
+
function onResume() {
|
|
247
|
+
if (delay > 0 && !reactSpring_shared_modern.Globals.skipAnimation) {
|
|
248
|
+
state.delayed = true;
|
|
249
|
+
timeout = reactSpring_rafz_modern.raf.setTimeout(onStart, delay);
|
|
250
|
+
state.pauseQueue.add(onPause);
|
|
251
|
+
state.timeouts.add(timeout);
|
|
252
|
+
} else {
|
|
253
|
+
onStart();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function onStart() {
|
|
257
|
+
if (state.delayed) {
|
|
258
|
+
state.delayed = false;
|
|
259
|
+
}
|
|
260
|
+
state.pauseQueue.delete(onPause);
|
|
261
|
+
state.timeouts.delete(timeout);
|
|
262
|
+
if (callId <= (state.cancelId || 0)) {
|
|
263
|
+
cancel = true;
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
actions.start({ ...props, callId, cancel }, resolve);
|
|
267
|
+
} catch (err) {
|
|
268
|
+
reject(err);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/AnimationResult.ts
|
|
275
|
+
var getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(
|
|
276
|
+
target.get(),
|
|
277
|
+
results.every((result) => result.finished)
|
|
278
|
+
);
|
|
279
|
+
var getNoopResult = (value) => ({
|
|
280
|
+
value,
|
|
281
|
+
noop: true,
|
|
282
|
+
finished: true,
|
|
283
|
+
cancelled: false
|
|
284
|
+
});
|
|
285
|
+
var getFinishedResult = (value, finished, cancelled = false) => ({
|
|
286
|
+
value,
|
|
287
|
+
finished,
|
|
288
|
+
cancelled
|
|
289
|
+
});
|
|
290
|
+
var getCancelledResult = (value) => ({
|
|
291
|
+
value,
|
|
292
|
+
cancelled: true,
|
|
293
|
+
finished: false
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// src/runAsync.ts
|
|
297
|
+
function runAsync(to2, props, state, target) {
|
|
298
|
+
const { callId, parentId, onRest } = props;
|
|
299
|
+
const { asyncTo: prevTo, promise: prevPromise } = state;
|
|
300
|
+
if (!parentId && to2 === prevTo && !props.reset) {
|
|
301
|
+
return prevPromise;
|
|
302
|
+
}
|
|
303
|
+
return state.promise = (async () => {
|
|
304
|
+
state.asyncId = callId;
|
|
305
|
+
state.asyncTo = to2;
|
|
306
|
+
const defaultProps = getDefaultProps(
|
|
307
|
+
props,
|
|
308
|
+
(value, key) => (
|
|
309
|
+
// The `onRest` prop is only called when the `runAsync` promise is resolved.
|
|
310
|
+
key === "onRest" ? void 0 : value
|
|
311
|
+
)
|
|
312
|
+
);
|
|
313
|
+
let preventBail;
|
|
314
|
+
let bail;
|
|
315
|
+
const bailPromise = new Promise(
|
|
316
|
+
(resolve, reject) => (preventBail = resolve, bail = reject)
|
|
317
|
+
);
|
|
318
|
+
const bailIfEnded = (bailSignal) => {
|
|
319
|
+
const bailResult = (
|
|
320
|
+
// The `cancel` prop or `stop` method was used.
|
|
321
|
+
callId <= (state.cancelId || 0) && getCancelledResult(target) || // The async `to` prop was replaced.
|
|
322
|
+
callId !== state.asyncId && getFinishedResult(target, false)
|
|
323
|
+
);
|
|
324
|
+
if (bailResult) {
|
|
325
|
+
bailSignal.result = bailResult;
|
|
326
|
+
bail(bailSignal);
|
|
327
|
+
throw bailSignal;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const animate = (arg1, arg2) => {
|
|
331
|
+
const bailSignal = new BailSignal();
|
|
332
|
+
const skipAnimationSignal = new SkipAnimationSignal();
|
|
333
|
+
return (async () => {
|
|
334
|
+
if (reactSpring_shared_modern.Globals.skipAnimation) {
|
|
335
|
+
stopAsync(state);
|
|
336
|
+
skipAnimationSignal.result = getFinishedResult(target, false);
|
|
337
|
+
bail(skipAnimationSignal);
|
|
338
|
+
throw skipAnimationSignal;
|
|
339
|
+
}
|
|
340
|
+
bailIfEnded(bailSignal);
|
|
341
|
+
const props2 = reactSpring_shared_modern.is.obj(arg1) ? { ...arg1 } : { ...arg2, to: arg1 };
|
|
342
|
+
props2.parentId = callId;
|
|
343
|
+
reactSpring_shared_modern.eachProp(defaultProps, (value, key) => {
|
|
344
|
+
if (reactSpring_shared_modern.is.und(props2[key])) {
|
|
345
|
+
props2[key] = value;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
const result2 = await target.start(props2);
|
|
349
|
+
bailIfEnded(bailSignal);
|
|
350
|
+
if (state.paused) {
|
|
351
|
+
await new Promise((resume) => {
|
|
352
|
+
state.resumeQueue.add(resume);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return result2;
|
|
356
|
+
})();
|
|
357
|
+
};
|
|
358
|
+
let result;
|
|
359
|
+
if (reactSpring_shared_modern.Globals.skipAnimation) {
|
|
360
|
+
stopAsync(state);
|
|
361
|
+
return getFinishedResult(target, false);
|
|
362
|
+
}
|
|
363
|
+
try {
|
|
364
|
+
let animating;
|
|
365
|
+
if (reactSpring_shared_modern.is.arr(to2)) {
|
|
366
|
+
animating = (async (queue) => {
|
|
367
|
+
for (const props2 of queue) {
|
|
368
|
+
await animate(props2);
|
|
369
|
+
}
|
|
370
|
+
})(to2);
|
|
371
|
+
} else {
|
|
372
|
+
animating = Promise.resolve(to2(animate, target.stop.bind(target)));
|
|
373
|
+
}
|
|
374
|
+
await Promise.all([animating.then(preventBail), bailPromise]);
|
|
375
|
+
result = getFinishedResult(target.get(), true, false);
|
|
376
|
+
} catch (err) {
|
|
377
|
+
if (err instanceof BailSignal) {
|
|
378
|
+
result = err.result;
|
|
379
|
+
} else if (err instanceof SkipAnimationSignal) {
|
|
380
|
+
result = err.result;
|
|
381
|
+
} else {
|
|
382
|
+
throw err;
|
|
383
|
+
}
|
|
384
|
+
} finally {
|
|
385
|
+
if (callId == state.asyncId) {
|
|
386
|
+
state.asyncId = parentId;
|
|
387
|
+
state.asyncTo = parentId ? prevTo : void 0;
|
|
388
|
+
state.promise = parentId ? prevPromise : void 0;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (reactSpring_shared_modern.is.fun(onRest)) {
|
|
392
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => {
|
|
393
|
+
onRest(result, target, target.item);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return result;
|
|
397
|
+
})();
|
|
398
|
+
}
|
|
399
|
+
function stopAsync(state, cancelId) {
|
|
400
|
+
reactSpring_shared_modern.flush(state.timeouts, (t) => t.cancel());
|
|
401
|
+
state.pauseQueue.clear();
|
|
402
|
+
state.resumeQueue.clear();
|
|
403
|
+
state.asyncId = state.asyncTo = state.promise = void 0;
|
|
404
|
+
if (cancelId) state.cancelId = cancelId;
|
|
405
|
+
}
|
|
406
|
+
var BailSignal = class extends Error {
|
|
407
|
+
constructor() {
|
|
408
|
+
super(
|
|
409
|
+
"An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var SkipAnimationSignal = class extends Error {
|
|
414
|
+
constructor() {
|
|
415
|
+
super("SkipAnimationSignal");
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
var isFrameValue = (value) => value instanceof FrameValue;
|
|
419
|
+
var nextId = 1;
|
|
420
|
+
var FrameValue = class extends reactSpring_shared_modern.FluidValue {
|
|
421
|
+
constructor() {
|
|
422
|
+
super(...arguments);
|
|
423
|
+
this.id = nextId++;
|
|
424
|
+
this._priority = 0;
|
|
425
|
+
}
|
|
426
|
+
get priority() {
|
|
427
|
+
return this._priority;
|
|
428
|
+
}
|
|
429
|
+
set priority(priority) {
|
|
430
|
+
if (this._priority != priority) {
|
|
431
|
+
this._priority = priority;
|
|
432
|
+
this._onPriorityChange(priority);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/** Get the current value */
|
|
436
|
+
get() {
|
|
437
|
+
const node = reactSpring_animated_modern.getAnimated(this);
|
|
438
|
+
return node && node.getValue();
|
|
439
|
+
}
|
|
440
|
+
/** Create a spring that maps our value to another value */
|
|
441
|
+
to(...args) {
|
|
442
|
+
return reactSpring_shared_modern.Globals.to(this, args);
|
|
443
|
+
}
|
|
444
|
+
/** @deprecated Use the `to` method instead. */
|
|
445
|
+
interpolate(...args) {
|
|
446
|
+
reactSpring_shared_modern.deprecateInterpolate();
|
|
447
|
+
return reactSpring_shared_modern.Globals.to(this, args);
|
|
448
|
+
}
|
|
449
|
+
toJSON() {
|
|
450
|
+
return this.get();
|
|
451
|
+
}
|
|
452
|
+
observerAdded(count) {
|
|
453
|
+
if (count == 1) this._attach();
|
|
454
|
+
}
|
|
455
|
+
observerRemoved(count) {
|
|
456
|
+
if (count == 0) this._detach();
|
|
457
|
+
}
|
|
458
|
+
/** Called when the first child is added. */
|
|
459
|
+
_attach() {
|
|
460
|
+
}
|
|
461
|
+
/** Called when the last child is removed. */
|
|
462
|
+
_detach() {
|
|
463
|
+
}
|
|
464
|
+
/** Tell our children about our new value */
|
|
465
|
+
_onChange(value, idle = false) {
|
|
466
|
+
reactSpring_shared_modern.callFluidObservers(this, {
|
|
467
|
+
type: "change",
|
|
468
|
+
parent: this,
|
|
469
|
+
value,
|
|
470
|
+
idle
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
/** Tell our children about our new priority */
|
|
474
|
+
_onPriorityChange(priority) {
|
|
475
|
+
if (!this.idle) {
|
|
476
|
+
reactSpring_shared_modern.frameLoop.sort(this);
|
|
477
|
+
}
|
|
478
|
+
reactSpring_shared_modern.callFluidObservers(this, {
|
|
479
|
+
type: "priority",
|
|
480
|
+
parent: this,
|
|
481
|
+
priority
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
// src/SpringPhase.ts
|
|
487
|
+
var $P = Symbol.for("SpringPhase");
|
|
488
|
+
var HAS_ANIMATED = 1;
|
|
489
|
+
var IS_ANIMATING = 2;
|
|
490
|
+
var IS_PAUSED = 4;
|
|
491
|
+
var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
|
|
492
|
+
var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
|
|
493
|
+
var isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
|
|
494
|
+
var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= -3;
|
|
495
|
+
var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= -5;
|
|
496
|
+
|
|
497
|
+
// src/SpringValue.ts
|
|
498
|
+
var SpringValue = class extends FrameValue {
|
|
499
|
+
constructor(arg1, arg2) {
|
|
500
|
+
super();
|
|
501
|
+
/** The animation state */
|
|
502
|
+
this.animation = new Animation();
|
|
503
|
+
/** Some props have customizable default values */
|
|
504
|
+
this.defaultProps = {};
|
|
505
|
+
/** The state for `runAsync` calls */
|
|
506
|
+
this._state = {
|
|
507
|
+
paused: false,
|
|
508
|
+
delayed: false,
|
|
509
|
+
pauseQueue: /* @__PURE__ */ new Set(),
|
|
510
|
+
resumeQueue: /* @__PURE__ */ new Set(),
|
|
511
|
+
timeouts: /* @__PURE__ */ new Set()
|
|
512
|
+
};
|
|
513
|
+
/** The promise resolvers of pending `start` calls */
|
|
514
|
+
this._pendingCalls = /* @__PURE__ */ new Set();
|
|
515
|
+
/** The counter for tracking `scheduleProps` calls */
|
|
516
|
+
this._lastCallId = 0;
|
|
517
|
+
/** The last `scheduleProps` call that changed the `to` prop */
|
|
518
|
+
this._lastToId = 0;
|
|
519
|
+
this._memoizedDuration = 0;
|
|
520
|
+
if (!reactSpring_shared_modern.is.und(arg1) || !reactSpring_shared_modern.is.und(arg2)) {
|
|
521
|
+
const props = reactSpring_shared_modern.is.obj(arg1) ? { ...arg1 } : { ...arg2, from: arg1 };
|
|
522
|
+
if (reactSpring_shared_modern.is.und(props.default)) {
|
|
523
|
+
props.default = true;
|
|
524
|
+
}
|
|
525
|
+
this.start(props);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
/** Equals true when not advancing on each frame. */
|
|
529
|
+
get idle() {
|
|
530
|
+
return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
|
|
531
|
+
}
|
|
532
|
+
get goal() {
|
|
533
|
+
return reactSpring_shared_modern.getFluidValue(this.animation.to);
|
|
534
|
+
}
|
|
535
|
+
get velocity() {
|
|
536
|
+
const node = reactSpring_animated_modern.getAnimated(this);
|
|
537
|
+
return node instanceof reactSpring_animated_modern.AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* When true, this value has been animated at least once.
|
|
541
|
+
*/
|
|
542
|
+
get hasAnimated() {
|
|
543
|
+
return hasAnimated(this);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* When true, this value has an unfinished animation,
|
|
547
|
+
* which is either active or paused.
|
|
548
|
+
*/
|
|
549
|
+
get isAnimating() {
|
|
550
|
+
return isAnimating(this);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* When true, all current and future animations are paused.
|
|
554
|
+
*/
|
|
555
|
+
get isPaused() {
|
|
556
|
+
return isPaused(this);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
*
|
|
560
|
+
*
|
|
561
|
+
*/
|
|
562
|
+
get isDelayed() {
|
|
563
|
+
return this._state.delayed;
|
|
564
|
+
}
|
|
565
|
+
/** Advance the current animation by a number of milliseconds */
|
|
566
|
+
advance(dt) {
|
|
567
|
+
let idle = true;
|
|
568
|
+
let changed = false;
|
|
569
|
+
const anim = this.animation;
|
|
570
|
+
let { toValues } = anim;
|
|
571
|
+
const { config: config2 } = anim;
|
|
572
|
+
const payload = reactSpring_animated_modern.getPayload(anim.to);
|
|
573
|
+
if (!payload && reactSpring_shared_modern.hasFluidValue(anim.to)) {
|
|
574
|
+
toValues = reactSpring_shared_modern.toArray(reactSpring_shared_modern.getFluidValue(anim.to));
|
|
575
|
+
}
|
|
576
|
+
anim.values.forEach((node2, i) => {
|
|
577
|
+
if (node2.done) return;
|
|
578
|
+
const to2 = (
|
|
579
|
+
// Animated strings always go from 0 to 1.
|
|
580
|
+
node2.constructor == reactSpring_animated_modern.AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i]
|
|
581
|
+
);
|
|
582
|
+
let finished = anim.immediate;
|
|
583
|
+
let position = to2;
|
|
584
|
+
if (!finished) {
|
|
585
|
+
position = node2.lastPosition;
|
|
586
|
+
if (config2.tension <= 0) {
|
|
587
|
+
node2.done = true;
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
let elapsed = node2.elapsedTime += dt;
|
|
591
|
+
const from = anim.fromValues[i];
|
|
592
|
+
const v0 = node2.v0 != null ? node2.v0 : node2.v0 = reactSpring_shared_modern.is.arr(config2.velocity) ? config2.velocity[i] : config2.velocity;
|
|
593
|
+
let velocity;
|
|
594
|
+
const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
|
|
595
|
+
if (!reactSpring_shared_modern.is.und(config2.duration)) {
|
|
596
|
+
let p = 1;
|
|
597
|
+
if (config2.duration > 0) {
|
|
598
|
+
if (this._memoizedDuration !== config2.duration) {
|
|
599
|
+
this._memoizedDuration = config2.duration;
|
|
600
|
+
if (node2.durationProgress > 0) {
|
|
601
|
+
node2.elapsedTime = config2.duration * node2.durationProgress;
|
|
602
|
+
elapsed = node2.elapsedTime += dt;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
p = (config2.progress || 0) + elapsed / this._memoizedDuration;
|
|
606
|
+
p = p > 1 ? 1 : p < 0 ? 0 : p;
|
|
607
|
+
node2.durationProgress = p;
|
|
608
|
+
}
|
|
609
|
+
position = from + config2.easing(p) * (to2 - from);
|
|
610
|
+
velocity = (position - node2.lastPosition) / dt;
|
|
611
|
+
finished = p == 1;
|
|
612
|
+
} else if (config2.decay) {
|
|
613
|
+
const decay = config2.decay === true ? 0.998 : config2.decay;
|
|
614
|
+
const e = Math.exp(-(1 - decay) * elapsed);
|
|
615
|
+
position = from + v0 / (1 - decay) * (1 - e);
|
|
616
|
+
finished = Math.abs(node2.lastPosition - position) <= precision;
|
|
617
|
+
velocity = v0 * e;
|
|
618
|
+
} else {
|
|
619
|
+
velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
|
|
620
|
+
const restVelocity = config2.restVelocity || precision / 10;
|
|
621
|
+
const bounceFactor = config2.clamp ? 0 : config2.bounce;
|
|
622
|
+
const canBounce = !reactSpring_shared_modern.is.und(bounceFactor);
|
|
623
|
+
const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
|
|
624
|
+
let isMoving;
|
|
625
|
+
let isBouncing = false;
|
|
626
|
+
const step = 1;
|
|
627
|
+
const numSteps = Math.ceil(dt / step);
|
|
628
|
+
for (let n = 0; n < numSteps; ++n) {
|
|
629
|
+
isMoving = Math.abs(velocity) > restVelocity;
|
|
630
|
+
if (!isMoving) {
|
|
631
|
+
finished = Math.abs(to2 - position) <= precision;
|
|
632
|
+
if (finished) {
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (canBounce) {
|
|
637
|
+
isBouncing = position == to2 || position > to2 == isGrowing;
|
|
638
|
+
if (isBouncing) {
|
|
639
|
+
velocity = -velocity * bounceFactor;
|
|
640
|
+
position = to2;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const springForce = -config2.tension * 1e-6 * (position - to2);
|
|
644
|
+
const dampingForce = -config2.friction * 1e-3 * velocity;
|
|
645
|
+
const acceleration = (springForce + dampingForce) / config2.mass;
|
|
646
|
+
velocity = velocity + acceleration * step;
|
|
647
|
+
position = position + velocity * step;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
node2.lastVelocity = velocity;
|
|
651
|
+
if (Number.isNaN(position)) {
|
|
652
|
+
console.warn(`Got NaN while animating:`, this);
|
|
653
|
+
finished = true;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (payload && !payload[i].done) {
|
|
657
|
+
finished = false;
|
|
658
|
+
}
|
|
659
|
+
if (finished) {
|
|
660
|
+
node2.done = true;
|
|
661
|
+
} else {
|
|
662
|
+
idle = false;
|
|
663
|
+
}
|
|
664
|
+
if (node2.setValue(position, config2.round)) {
|
|
665
|
+
changed = true;
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
const node = reactSpring_animated_modern.getAnimated(this);
|
|
669
|
+
const currVal = node.getValue();
|
|
670
|
+
if (idle) {
|
|
671
|
+
const finalVal = reactSpring_shared_modern.getFluidValue(anim.to);
|
|
672
|
+
if ((currVal !== finalVal || changed) && !config2.decay) {
|
|
673
|
+
node.setValue(finalVal);
|
|
674
|
+
this._onChange(finalVal);
|
|
675
|
+
} else if (changed && config2.decay) {
|
|
676
|
+
this._onChange(currVal);
|
|
677
|
+
}
|
|
678
|
+
this._stop();
|
|
679
|
+
} else if (changed) {
|
|
680
|
+
this._onChange(currVal);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/** Set the current value, while stopping the current animation */
|
|
684
|
+
set(value) {
|
|
685
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => {
|
|
686
|
+
this._stop();
|
|
687
|
+
this._focus(value);
|
|
688
|
+
this._set(value);
|
|
689
|
+
});
|
|
690
|
+
return this;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Freeze the active animation in time, as well as any updates merged
|
|
694
|
+
* before `resume` is called.
|
|
695
|
+
*/
|
|
696
|
+
pause() {
|
|
697
|
+
this._update({ pause: true });
|
|
698
|
+
}
|
|
699
|
+
/** Resume the animation if paused. */
|
|
700
|
+
resume() {
|
|
701
|
+
this._update({ pause: false });
|
|
702
|
+
}
|
|
703
|
+
/** Skip to the end of the current animation. */
|
|
704
|
+
finish() {
|
|
705
|
+
if (isAnimating(this)) {
|
|
706
|
+
const { to: to2, config: config2 } = this.animation;
|
|
707
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => {
|
|
708
|
+
this._onStart();
|
|
709
|
+
if (!config2.decay) {
|
|
710
|
+
this._set(to2, false);
|
|
711
|
+
}
|
|
712
|
+
this._stop();
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
return this;
|
|
716
|
+
}
|
|
717
|
+
/** Push props into the pending queue. */
|
|
718
|
+
update(props) {
|
|
719
|
+
const queue = this.queue || (this.queue = []);
|
|
720
|
+
queue.push(props);
|
|
721
|
+
return this;
|
|
722
|
+
}
|
|
723
|
+
start(to2, arg2) {
|
|
724
|
+
let queue;
|
|
725
|
+
if (!reactSpring_shared_modern.is.und(to2)) {
|
|
726
|
+
queue = [reactSpring_shared_modern.is.obj(to2) ? to2 : { ...arg2, to: to2 }];
|
|
727
|
+
} else {
|
|
728
|
+
queue = this.queue || [];
|
|
729
|
+
this.queue = [];
|
|
730
|
+
}
|
|
731
|
+
return Promise.all(
|
|
732
|
+
queue.map((props) => {
|
|
733
|
+
const up = this._update(props);
|
|
734
|
+
return up;
|
|
735
|
+
})
|
|
736
|
+
).then((results) => getCombinedResult(this, results));
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Stop the current animation, and cancel any delayed updates.
|
|
740
|
+
*
|
|
741
|
+
* Pass `true` to call `onRest` with `cancelled: true`.
|
|
742
|
+
*/
|
|
743
|
+
stop(cancel) {
|
|
744
|
+
const { to: to2 } = this.animation;
|
|
745
|
+
this._focus(this.get());
|
|
746
|
+
stopAsync(this._state, cancel && this._lastCallId);
|
|
747
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => this._stop(to2, cancel));
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
/** Restart the animation. */
|
|
751
|
+
reset() {
|
|
752
|
+
this._update({ reset: true });
|
|
753
|
+
}
|
|
754
|
+
/** @internal */
|
|
755
|
+
eventObserved(event) {
|
|
756
|
+
if (event.type == "change") {
|
|
757
|
+
this._start();
|
|
758
|
+
} else if (event.type == "priority") {
|
|
759
|
+
this.priority = event.priority + 1;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Parse the `to` and `from` range from the given `props` object.
|
|
764
|
+
*
|
|
765
|
+
* This also ensures the initial value is available to animated components
|
|
766
|
+
* during the render phase.
|
|
767
|
+
*/
|
|
768
|
+
_prepareNode(props) {
|
|
769
|
+
const key = this.key || "";
|
|
770
|
+
let { to: to2, from } = props;
|
|
771
|
+
to2 = reactSpring_shared_modern.is.obj(to2) ? to2[key] : to2;
|
|
772
|
+
if (to2 == null || isAsyncTo(to2)) {
|
|
773
|
+
to2 = void 0;
|
|
774
|
+
}
|
|
775
|
+
from = reactSpring_shared_modern.is.obj(from) ? from[key] : from;
|
|
776
|
+
if (from == null) {
|
|
777
|
+
from = void 0;
|
|
778
|
+
}
|
|
779
|
+
const range = { to: to2, from };
|
|
780
|
+
if (!hasAnimated(this)) {
|
|
781
|
+
if (props.reverse) [to2, from] = [from, to2];
|
|
782
|
+
from = reactSpring_shared_modern.getFluidValue(from);
|
|
783
|
+
if (!reactSpring_shared_modern.is.und(from)) {
|
|
784
|
+
this._set(from);
|
|
785
|
+
} else if (!reactSpring_animated_modern.getAnimated(this)) {
|
|
786
|
+
this._set(to2);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return range;
|
|
790
|
+
}
|
|
791
|
+
/** Every update is processed by this method before merging. */
|
|
792
|
+
_update({ ...props }, isLoop) {
|
|
793
|
+
const { key, defaultProps } = this;
|
|
794
|
+
if (props.default)
|
|
795
|
+
Object.assign(
|
|
796
|
+
defaultProps,
|
|
797
|
+
getDefaultProps(
|
|
798
|
+
props,
|
|
799
|
+
(value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value
|
|
800
|
+
)
|
|
801
|
+
);
|
|
802
|
+
mergeActiveFn(this, props, "onProps");
|
|
803
|
+
sendEvent(this, "onProps", props, this);
|
|
804
|
+
const range = this._prepareNode(props);
|
|
805
|
+
if (Object.isFrozen(this)) {
|
|
806
|
+
throw Error(
|
|
807
|
+
"Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
const state = this._state;
|
|
811
|
+
return scheduleProps(++this._lastCallId, {
|
|
812
|
+
key,
|
|
813
|
+
props,
|
|
814
|
+
defaultProps,
|
|
815
|
+
state,
|
|
816
|
+
actions: {
|
|
817
|
+
pause: () => {
|
|
818
|
+
if (!isPaused(this)) {
|
|
819
|
+
setPausedBit(this, true);
|
|
820
|
+
reactSpring_shared_modern.flushCalls(state.pauseQueue);
|
|
821
|
+
sendEvent(
|
|
822
|
+
this,
|
|
823
|
+
"onPause",
|
|
824
|
+
getFinishedResult(this, checkFinished(this, this.animation.to)),
|
|
825
|
+
this
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
resume: () => {
|
|
830
|
+
if (isPaused(this)) {
|
|
831
|
+
setPausedBit(this, false);
|
|
832
|
+
if (isAnimating(this)) {
|
|
833
|
+
this._resume();
|
|
834
|
+
}
|
|
835
|
+
reactSpring_shared_modern.flushCalls(state.resumeQueue);
|
|
836
|
+
sendEvent(
|
|
837
|
+
this,
|
|
838
|
+
"onResume",
|
|
839
|
+
getFinishedResult(this, checkFinished(this, this.animation.to)),
|
|
840
|
+
this
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
start: this._merge.bind(this, range)
|
|
845
|
+
}
|
|
846
|
+
}).then((result) => {
|
|
847
|
+
if (props.loop && result.finished && !(isLoop && result.noop)) {
|
|
848
|
+
const nextProps = createLoopUpdate(props);
|
|
849
|
+
if (nextProps) {
|
|
850
|
+
return this._update(nextProps, true);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
return result;
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
/** Merge props into the current animation */
|
|
857
|
+
_merge(range, props, resolve) {
|
|
858
|
+
if (props.cancel) {
|
|
859
|
+
this.stop(true);
|
|
860
|
+
return resolve(getCancelledResult(this));
|
|
861
|
+
}
|
|
862
|
+
const hasToProp = !reactSpring_shared_modern.is.und(range.to);
|
|
863
|
+
const hasFromProp = !reactSpring_shared_modern.is.und(range.from);
|
|
864
|
+
if (hasToProp || hasFromProp) {
|
|
865
|
+
if (props.callId > this._lastToId) {
|
|
866
|
+
this._lastToId = props.callId;
|
|
867
|
+
} else {
|
|
868
|
+
return resolve(getCancelledResult(this));
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
const { key, defaultProps, animation: anim } = this;
|
|
872
|
+
const { to: prevTo, from: prevFrom } = anim;
|
|
873
|
+
let { to: to2 = prevTo, from = prevFrom } = range;
|
|
874
|
+
if (hasFromProp && !hasToProp && (!props.default || reactSpring_shared_modern.is.und(to2))) {
|
|
875
|
+
to2 = from;
|
|
876
|
+
}
|
|
877
|
+
if (props.reverse) [to2, from] = [from, to2];
|
|
878
|
+
const hasFromChanged = !reactSpring_shared_modern.isEqual(from, prevFrom);
|
|
879
|
+
if (hasFromChanged) {
|
|
880
|
+
anim.from = from;
|
|
881
|
+
}
|
|
882
|
+
from = reactSpring_shared_modern.getFluidValue(from);
|
|
883
|
+
const hasToChanged = !reactSpring_shared_modern.isEqual(to2, prevTo);
|
|
884
|
+
if (hasToChanged) {
|
|
885
|
+
this._focus(to2);
|
|
886
|
+
}
|
|
887
|
+
const hasAsyncTo = isAsyncTo(props.to);
|
|
888
|
+
const { config: config2 } = anim;
|
|
889
|
+
const { decay, velocity } = config2;
|
|
890
|
+
if (hasToProp || hasFromProp) {
|
|
891
|
+
config2.velocity = 0;
|
|
892
|
+
}
|
|
893
|
+
if (props.config && !hasAsyncTo) {
|
|
894
|
+
mergeConfig(
|
|
895
|
+
config2,
|
|
896
|
+
callProp(props.config, key),
|
|
897
|
+
// Avoid calling the same "config" prop twice.
|
|
898
|
+
props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
let node = reactSpring_animated_modern.getAnimated(this);
|
|
902
|
+
if (!node || reactSpring_shared_modern.is.und(to2)) {
|
|
903
|
+
return resolve(getFinishedResult(this, true));
|
|
904
|
+
}
|
|
905
|
+
const reset = (
|
|
906
|
+
// When `reset` is undefined, the `from` prop implies `reset: true`,
|
|
907
|
+
// except for declarative updates. When `reset` is defined, there
|
|
908
|
+
// must exist a value to animate from.
|
|
909
|
+
reactSpring_shared_modern.is.und(props.reset) ? hasFromProp && !props.default : !reactSpring_shared_modern.is.und(from) && matchProp(props.reset, key)
|
|
910
|
+
);
|
|
911
|
+
const value = reset ? from : this.get();
|
|
912
|
+
const goal = computeGoal(to2);
|
|
913
|
+
const isAnimatable = reactSpring_shared_modern.is.num(goal) || reactSpring_shared_modern.is.arr(goal) || reactSpring_shared_modern.isAnimatedString(goal);
|
|
914
|
+
const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
|
|
915
|
+
if (hasToChanged) {
|
|
916
|
+
const nodeType = reactSpring_animated_modern.getAnimatedType(to2);
|
|
917
|
+
if (nodeType !== node.constructor) {
|
|
918
|
+
if (immediate) {
|
|
919
|
+
node = this._set(goal);
|
|
920
|
+
} else
|
|
921
|
+
throw Error(
|
|
922
|
+
`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
const goalType = node.constructor;
|
|
927
|
+
let started = reactSpring_shared_modern.hasFluidValue(to2);
|
|
928
|
+
let finished = false;
|
|
929
|
+
if (!started) {
|
|
930
|
+
const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
|
|
931
|
+
if (hasToChanged || hasValueChanged) {
|
|
932
|
+
finished = reactSpring_shared_modern.isEqual(computeGoal(value), goal);
|
|
933
|
+
started = !finished;
|
|
934
|
+
}
|
|
935
|
+
if (!reactSpring_shared_modern.isEqual(anim.immediate, immediate) && !immediate || !reactSpring_shared_modern.isEqual(config2.decay, decay) || !reactSpring_shared_modern.isEqual(config2.velocity, velocity)) {
|
|
936
|
+
started = true;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (finished && isAnimating(this)) {
|
|
940
|
+
if (anim.changed && !reset) {
|
|
941
|
+
started = true;
|
|
942
|
+
} else if (!started) {
|
|
943
|
+
this._stop(prevTo);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
if (!hasAsyncTo) {
|
|
947
|
+
if (started || reactSpring_shared_modern.hasFluidValue(prevTo)) {
|
|
948
|
+
anim.values = node.getPayload();
|
|
949
|
+
anim.toValues = reactSpring_shared_modern.hasFluidValue(to2) ? null : goalType == reactSpring_animated_modern.AnimatedString ? [1] : reactSpring_shared_modern.toArray(goal);
|
|
950
|
+
}
|
|
951
|
+
if (anim.immediate != immediate) {
|
|
952
|
+
anim.immediate = immediate;
|
|
953
|
+
if (!immediate && !reset) {
|
|
954
|
+
this._set(prevTo);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
if (started) {
|
|
958
|
+
const { onRest } = anim;
|
|
959
|
+
reactSpring_shared_modern.each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
|
|
960
|
+
const result = getFinishedResult(this, checkFinished(this, prevTo));
|
|
961
|
+
reactSpring_shared_modern.flushCalls(this._pendingCalls, result);
|
|
962
|
+
this._pendingCalls.add(resolve);
|
|
963
|
+
if (anim.changed)
|
|
964
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => {
|
|
965
|
+
anim.changed = !reset;
|
|
966
|
+
onRest?.(result, this);
|
|
967
|
+
if (reset) {
|
|
968
|
+
callProp(defaultProps.onRest, result);
|
|
969
|
+
} else {
|
|
970
|
+
anim.onStart?.(result, this);
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
if (reset) {
|
|
976
|
+
this._set(value);
|
|
977
|
+
}
|
|
978
|
+
if (hasAsyncTo) {
|
|
979
|
+
resolve(runAsync(props.to, props, this._state, this));
|
|
980
|
+
} else if (started) {
|
|
981
|
+
this._start();
|
|
982
|
+
} else if (isAnimating(this) && !hasToChanged) {
|
|
983
|
+
this._pendingCalls.add(resolve);
|
|
984
|
+
} else {
|
|
985
|
+
resolve(getNoopResult(value));
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
/** Update the `animation.to` value, which might be a `FluidValue` */
|
|
989
|
+
_focus(value) {
|
|
990
|
+
const anim = this.animation;
|
|
991
|
+
if (value !== anim.to) {
|
|
992
|
+
if (reactSpring_shared_modern.getFluidObservers(this)) {
|
|
993
|
+
this._detach();
|
|
994
|
+
}
|
|
995
|
+
anim.to = value;
|
|
996
|
+
if (reactSpring_shared_modern.getFluidObservers(this)) {
|
|
997
|
+
this._attach();
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
_attach() {
|
|
1002
|
+
let priority = 0;
|
|
1003
|
+
const { to: to2 } = this.animation;
|
|
1004
|
+
if (reactSpring_shared_modern.hasFluidValue(to2)) {
|
|
1005
|
+
reactSpring_shared_modern.addFluidObserver(to2, this);
|
|
1006
|
+
if (isFrameValue(to2)) {
|
|
1007
|
+
priority = to2.priority + 1;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
this.priority = priority;
|
|
1011
|
+
}
|
|
1012
|
+
_detach() {
|
|
1013
|
+
const { to: to2 } = this.animation;
|
|
1014
|
+
if (reactSpring_shared_modern.hasFluidValue(to2)) {
|
|
1015
|
+
reactSpring_shared_modern.removeFluidObserver(to2, this);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Update the current value from outside the frameloop,
|
|
1020
|
+
* and return the `Animated` node.
|
|
1021
|
+
*/
|
|
1022
|
+
_set(arg, idle = true) {
|
|
1023
|
+
const value = reactSpring_shared_modern.getFluidValue(arg);
|
|
1024
|
+
if (!reactSpring_shared_modern.is.und(value)) {
|
|
1025
|
+
const oldNode = reactSpring_animated_modern.getAnimated(this);
|
|
1026
|
+
if (!oldNode || !reactSpring_shared_modern.isEqual(value, oldNode.getValue())) {
|
|
1027
|
+
const nodeType = reactSpring_animated_modern.getAnimatedType(value);
|
|
1028
|
+
if (!oldNode || oldNode.constructor != nodeType) {
|
|
1029
|
+
reactSpring_animated_modern.setAnimated(this, nodeType.create(value));
|
|
1030
|
+
} else {
|
|
1031
|
+
oldNode.setValue(value);
|
|
1032
|
+
}
|
|
1033
|
+
if (oldNode) {
|
|
1034
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => {
|
|
1035
|
+
this._onChange(value, idle);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return reactSpring_animated_modern.getAnimated(this);
|
|
1041
|
+
}
|
|
1042
|
+
_onStart() {
|
|
1043
|
+
const anim = this.animation;
|
|
1044
|
+
if (!anim.changed) {
|
|
1045
|
+
anim.changed = true;
|
|
1046
|
+
sendEvent(
|
|
1047
|
+
this,
|
|
1048
|
+
"onStart",
|
|
1049
|
+
getFinishedResult(this, checkFinished(this, anim.to)),
|
|
1050
|
+
this
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
_onChange(value, idle) {
|
|
1055
|
+
if (!idle) {
|
|
1056
|
+
this._onStart();
|
|
1057
|
+
callProp(this.animation.onChange, value, this);
|
|
1058
|
+
}
|
|
1059
|
+
callProp(this.defaultProps.onChange, value, this);
|
|
1060
|
+
super._onChange(value, idle);
|
|
1061
|
+
}
|
|
1062
|
+
// This method resets the animation state (even if already animating) to
|
|
1063
|
+
// ensure the latest from/to range is used, and it also ensures this spring
|
|
1064
|
+
// is added to the frameloop.
|
|
1065
|
+
_start() {
|
|
1066
|
+
const anim = this.animation;
|
|
1067
|
+
reactSpring_animated_modern.getAnimated(this).reset(reactSpring_shared_modern.getFluidValue(anim.to));
|
|
1068
|
+
if (!anim.immediate) {
|
|
1069
|
+
anim.fromValues = anim.values.map((node) => node.lastPosition);
|
|
1070
|
+
}
|
|
1071
|
+
if (!isAnimating(this)) {
|
|
1072
|
+
setActiveBit(this, true);
|
|
1073
|
+
if (!isPaused(this)) {
|
|
1074
|
+
this._resume();
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
_resume() {
|
|
1079
|
+
if (reactSpring_shared_modern.Globals.skipAnimation) {
|
|
1080
|
+
this.finish();
|
|
1081
|
+
} else {
|
|
1082
|
+
reactSpring_shared_modern.frameLoop.start(this);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Exit the frameloop and notify `onRest` listeners.
|
|
1087
|
+
*
|
|
1088
|
+
* Always wrap `_stop` calls with `batchedUpdates`.
|
|
1089
|
+
*/
|
|
1090
|
+
_stop(goal, cancel) {
|
|
1091
|
+
if (isAnimating(this)) {
|
|
1092
|
+
setActiveBit(this, false);
|
|
1093
|
+
const anim = this.animation;
|
|
1094
|
+
reactSpring_shared_modern.each(anim.values, (node) => {
|
|
1095
|
+
node.done = true;
|
|
1096
|
+
});
|
|
1097
|
+
if (anim.toValues) {
|
|
1098
|
+
anim.onChange = anim.onPause = anim.onResume = void 0;
|
|
1099
|
+
}
|
|
1100
|
+
reactSpring_shared_modern.callFluidObservers(this, {
|
|
1101
|
+
type: "idle",
|
|
1102
|
+
parent: this
|
|
1103
|
+
});
|
|
1104
|
+
const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal ?? anim.to));
|
|
1105
|
+
reactSpring_shared_modern.flushCalls(this._pendingCalls, result);
|
|
1106
|
+
if (anim.changed) {
|
|
1107
|
+
anim.changed = false;
|
|
1108
|
+
sendEvent(this, "onRest", result, this);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
function checkFinished(target, to2) {
|
|
1114
|
+
const goal = computeGoal(to2);
|
|
1115
|
+
const value = computeGoal(target.get());
|
|
1116
|
+
return reactSpring_shared_modern.isEqual(value, goal);
|
|
1117
|
+
}
|
|
1118
|
+
function createLoopUpdate(props, loop = props.loop, to2 = props.to) {
|
|
1119
|
+
const loopRet = callProp(loop);
|
|
1120
|
+
if (loopRet) {
|
|
1121
|
+
const overrides = loopRet !== true && inferTo(loopRet);
|
|
1122
|
+
const reverse = (overrides || props).reverse;
|
|
1123
|
+
const reset = !overrides || overrides.reset;
|
|
1124
|
+
return createUpdate({
|
|
1125
|
+
...props,
|
|
1126
|
+
loop,
|
|
1127
|
+
// Avoid updating default props when looping.
|
|
1128
|
+
default: false,
|
|
1129
|
+
// Never loop the `pause` prop.
|
|
1130
|
+
pause: void 0,
|
|
1131
|
+
// For the "reverse" prop to loop as expected, the "to" prop
|
|
1132
|
+
// must be undefined. The "reverse" prop is ignored when the
|
|
1133
|
+
// "to" prop is an array or function.
|
|
1134
|
+
to: !reverse || isAsyncTo(to2) ? to2 : void 0,
|
|
1135
|
+
// Ignore the "from" prop except on reset.
|
|
1136
|
+
from: reset ? props.from : void 0,
|
|
1137
|
+
reset,
|
|
1138
|
+
// The "loop" prop can return a "useSpring" props object to
|
|
1139
|
+
// override any of the original props.
|
|
1140
|
+
...overrides
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
function createUpdate(props) {
|
|
1145
|
+
const { to: to2, from } = props = inferTo(props);
|
|
1146
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1147
|
+
if (reactSpring_shared_modern.is.obj(to2)) findDefined(to2, keys);
|
|
1148
|
+
if (reactSpring_shared_modern.is.obj(from)) findDefined(from, keys);
|
|
1149
|
+
props.keys = keys.size ? Array.from(keys) : null;
|
|
1150
|
+
return props;
|
|
1151
|
+
}
|
|
1152
|
+
function declareUpdate(props) {
|
|
1153
|
+
const update2 = createUpdate(props);
|
|
1154
|
+
if (reactSpring_shared_modern.is.und(update2.default)) {
|
|
1155
|
+
update2.default = getDefaultProps(update2);
|
|
1156
|
+
}
|
|
1157
|
+
return update2;
|
|
1158
|
+
}
|
|
1159
|
+
function findDefined(values, keys) {
|
|
1160
|
+
reactSpring_shared_modern.eachProp(values, (value, key) => value != null && keys.add(key));
|
|
1161
|
+
}
|
|
1162
|
+
var ACTIVE_EVENTS = [
|
|
1163
|
+
"onStart",
|
|
1164
|
+
"onRest",
|
|
1165
|
+
"onChange",
|
|
1166
|
+
"onPause",
|
|
1167
|
+
"onResume"
|
|
1168
|
+
];
|
|
1169
|
+
function mergeActiveFn(target, props, type) {
|
|
1170
|
+
target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
|
|
1171
|
+
}
|
|
1172
|
+
function sendEvent(target, type, ...args) {
|
|
1173
|
+
target.animation[type]?.(...args);
|
|
1174
|
+
target.defaultProps[type]?.(...args);
|
|
1175
|
+
}
|
|
1176
|
+
var BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
|
|
1177
|
+
var nextId2 = 1;
|
|
1178
|
+
var Controller = class {
|
|
1179
|
+
constructor(props, flush3) {
|
|
1180
|
+
this.id = nextId2++;
|
|
1181
|
+
/** The animated values */
|
|
1182
|
+
this.springs = {};
|
|
1183
|
+
/** The queue of props passed to the `update` method. */
|
|
1184
|
+
this.queue = [];
|
|
1185
|
+
/** The counter for tracking `scheduleProps` calls */
|
|
1186
|
+
this._lastAsyncId = 0;
|
|
1187
|
+
/** The values currently being animated */
|
|
1188
|
+
this._active = /* @__PURE__ */ new Set();
|
|
1189
|
+
/** The values that changed recently */
|
|
1190
|
+
this._changed = /* @__PURE__ */ new Set();
|
|
1191
|
+
/** Equals false when `onStart` listeners can be called */
|
|
1192
|
+
this._started = false;
|
|
1193
|
+
/** State used by the `runAsync` function */
|
|
1194
|
+
this._state = {
|
|
1195
|
+
paused: false,
|
|
1196
|
+
pauseQueue: /* @__PURE__ */ new Set(),
|
|
1197
|
+
resumeQueue: /* @__PURE__ */ new Set(),
|
|
1198
|
+
timeouts: /* @__PURE__ */ new Set()
|
|
1199
|
+
};
|
|
1200
|
+
/** The event queues that are flushed once per frame maximum */
|
|
1201
|
+
this._events = {
|
|
1202
|
+
onStart: /* @__PURE__ */ new Map(),
|
|
1203
|
+
onChange: /* @__PURE__ */ new Map(),
|
|
1204
|
+
onRest: /* @__PURE__ */ new Map()
|
|
1205
|
+
};
|
|
1206
|
+
this._onFrame = this._onFrame.bind(this);
|
|
1207
|
+
if (flush3) {
|
|
1208
|
+
this._flush = flush3;
|
|
1209
|
+
}
|
|
1210
|
+
if (props) {
|
|
1211
|
+
this.start({ default: true, ...props });
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Equals `true` when no spring values are in the frameloop, and
|
|
1216
|
+
* no async animation is currently active.
|
|
1217
|
+
*/
|
|
1218
|
+
get idle() {
|
|
1219
|
+
return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
|
|
1220
|
+
return spring.idle && !spring.isDelayed && !spring.isPaused;
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
get item() {
|
|
1224
|
+
return this._item;
|
|
1225
|
+
}
|
|
1226
|
+
set item(item) {
|
|
1227
|
+
this._item = item;
|
|
1228
|
+
}
|
|
1229
|
+
/** Get the current values of our springs */
|
|
1230
|
+
get() {
|
|
1231
|
+
const values = {};
|
|
1232
|
+
this.each((spring, key) => values[key] = spring.get());
|
|
1233
|
+
return values;
|
|
1234
|
+
}
|
|
1235
|
+
/** Set the current values without animating. */
|
|
1236
|
+
set(values) {
|
|
1237
|
+
for (const key in values) {
|
|
1238
|
+
const value = values[key];
|
|
1239
|
+
if (!reactSpring_shared_modern.is.und(value)) {
|
|
1240
|
+
this.springs[key].set(value);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
/** Push an update onto the queue of each value. */
|
|
1245
|
+
update(props) {
|
|
1246
|
+
if (props) {
|
|
1247
|
+
this.queue.push(createUpdate(props));
|
|
1248
|
+
}
|
|
1249
|
+
return this;
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Start the queued animations for every spring, and resolve the returned
|
|
1253
|
+
* promise once all queued animations have finished or been cancelled.
|
|
1254
|
+
*
|
|
1255
|
+
* When you pass a queue (instead of nothing), that queue is used instead of
|
|
1256
|
+
* the queued animations added with the `update` method, which are left alone.
|
|
1257
|
+
*/
|
|
1258
|
+
start(props) {
|
|
1259
|
+
let { queue } = this;
|
|
1260
|
+
if (props) {
|
|
1261
|
+
queue = reactSpring_shared_modern.toArray(props).map(createUpdate);
|
|
1262
|
+
} else {
|
|
1263
|
+
this.queue = [];
|
|
1264
|
+
}
|
|
1265
|
+
if (this._flush) {
|
|
1266
|
+
return this._flush(this, queue);
|
|
1267
|
+
}
|
|
1268
|
+
prepareKeys(this, queue);
|
|
1269
|
+
return flushUpdateQueue(this, queue);
|
|
1270
|
+
}
|
|
1271
|
+
/** @internal */
|
|
1272
|
+
stop(arg, keys) {
|
|
1273
|
+
if (arg !== !!arg) {
|
|
1274
|
+
keys = arg;
|
|
1275
|
+
}
|
|
1276
|
+
if (keys) {
|
|
1277
|
+
const springs = this.springs;
|
|
1278
|
+
reactSpring_shared_modern.each(reactSpring_shared_modern.toArray(keys), (key) => springs[key].stop(!!arg));
|
|
1279
|
+
} else {
|
|
1280
|
+
stopAsync(this._state, this._lastAsyncId);
|
|
1281
|
+
this.each((spring) => spring.stop(!!arg));
|
|
1282
|
+
}
|
|
1283
|
+
return this;
|
|
1284
|
+
}
|
|
1285
|
+
/** Freeze the active animation in time */
|
|
1286
|
+
pause(keys) {
|
|
1287
|
+
if (reactSpring_shared_modern.is.und(keys)) {
|
|
1288
|
+
this.start({ pause: true });
|
|
1289
|
+
} else {
|
|
1290
|
+
const springs = this.springs;
|
|
1291
|
+
reactSpring_shared_modern.each(reactSpring_shared_modern.toArray(keys), (key) => springs[key].pause());
|
|
1292
|
+
}
|
|
1293
|
+
return this;
|
|
1294
|
+
}
|
|
1295
|
+
/** Resume the animation if paused. */
|
|
1296
|
+
resume(keys) {
|
|
1297
|
+
if (reactSpring_shared_modern.is.und(keys)) {
|
|
1298
|
+
this.start({ pause: false });
|
|
1299
|
+
} else {
|
|
1300
|
+
const springs = this.springs;
|
|
1301
|
+
reactSpring_shared_modern.each(reactSpring_shared_modern.toArray(keys), (key) => springs[key].resume());
|
|
1302
|
+
}
|
|
1303
|
+
return this;
|
|
1304
|
+
}
|
|
1305
|
+
/** Call a function once per spring value */
|
|
1306
|
+
each(iterator) {
|
|
1307
|
+
reactSpring_shared_modern.eachProp(this.springs, iterator);
|
|
1308
|
+
}
|
|
1309
|
+
/** @internal Called at the end of every animation frame */
|
|
1310
|
+
_onFrame() {
|
|
1311
|
+
const { onStart, onChange, onRest } = this._events;
|
|
1312
|
+
const active = this._active.size > 0;
|
|
1313
|
+
const changed = this._changed.size > 0;
|
|
1314
|
+
if (active && !this._started || changed && !this._started) {
|
|
1315
|
+
this._started = true;
|
|
1316
|
+
reactSpring_shared_modern.flush(onStart, ([onStart2, result]) => {
|
|
1317
|
+
result.value = this.get();
|
|
1318
|
+
onStart2(result, this, this._item);
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
const idle = !active && this._started;
|
|
1322
|
+
const values = changed || idle && onRest.size ? this.get() : null;
|
|
1323
|
+
if (changed && onChange.size) {
|
|
1324
|
+
reactSpring_shared_modern.flush(onChange, ([onChange2, result]) => {
|
|
1325
|
+
result.value = values;
|
|
1326
|
+
onChange2(result, this, this._item);
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
if (idle) {
|
|
1330
|
+
this._started = false;
|
|
1331
|
+
reactSpring_shared_modern.flush(onRest, ([onRest2, result]) => {
|
|
1332
|
+
result.value = values;
|
|
1333
|
+
onRest2(result, this, this._item);
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
/** @internal */
|
|
1338
|
+
eventObserved(event) {
|
|
1339
|
+
if (event.type == "change") {
|
|
1340
|
+
this._changed.add(event.parent);
|
|
1341
|
+
if (!event.idle) {
|
|
1342
|
+
this._active.add(event.parent);
|
|
1343
|
+
}
|
|
1344
|
+
} else if (event.type == "idle") {
|
|
1345
|
+
this._active.delete(event.parent);
|
|
1346
|
+
} else return;
|
|
1347
|
+
reactSpring_rafz_modern.raf.onFrame(this._onFrame);
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
function flushUpdateQueue(ctrl, queue) {
|
|
1351
|
+
return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then(
|
|
1352
|
+
(results) => getCombinedResult(ctrl, results)
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
async function flushUpdate(ctrl, props, isLoop) {
|
|
1356
|
+
const { keys, to: to2, from, loop, onRest, onResolve } = props;
|
|
1357
|
+
const defaults2 = reactSpring_shared_modern.is.obj(props.default) && props.default;
|
|
1358
|
+
if (loop) {
|
|
1359
|
+
props.loop = false;
|
|
1360
|
+
}
|
|
1361
|
+
if (to2 === false) props.to = null;
|
|
1362
|
+
if (from === false) props.from = null;
|
|
1363
|
+
const asyncTo = reactSpring_shared_modern.is.arr(to2) || reactSpring_shared_modern.is.fun(to2) ? to2 : void 0;
|
|
1364
|
+
if (asyncTo) {
|
|
1365
|
+
props.to = void 0;
|
|
1366
|
+
props.onRest = void 0;
|
|
1367
|
+
if (defaults2) {
|
|
1368
|
+
defaults2.onRest = void 0;
|
|
1369
|
+
}
|
|
1370
|
+
} else {
|
|
1371
|
+
reactSpring_shared_modern.each(BATCHED_EVENTS, (key) => {
|
|
1372
|
+
const handler = props[key];
|
|
1373
|
+
if (reactSpring_shared_modern.is.fun(handler)) {
|
|
1374
|
+
const queue = ctrl["_events"][key];
|
|
1375
|
+
props[key] = ({ finished, cancelled }) => {
|
|
1376
|
+
const result2 = queue.get(handler);
|
|
1377
|
+
if (result2) {
|
|
1378
|
+
if (!finished) result2.finished = false;
|
|
1379
|
+
if (cancelled) result2.cancelled = true;
|
|
1380
|
+
} else {
|
|
1381
|
+
queue.set(handler, {
|
|
1382
|
+
value: null,
|
|
1383
|
+
finished: finished || false,
|
|
1384
|
+
cancelled: cancelled || false
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
if (defaults2) {
|
|
1389
|
+
defaults2[key] = props[key];
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
const state = ctrl["_state"];
|
|
1395
|
+
if (props.pause === !state.paused) {
|
|
1396
|
+
state.paused = props.pause;
|
|
1397
|
+
reactSpring_shared_modern.flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
|
|
1398
|
+
} else if (state.paused) {
|
|
1399
|
+
props.pause = true;
|
|
1400
|
+
}
|
|
1401
|
+
const promises = (keys || Object.keys(ctrl.springs)).map(
|
|
1402
|
+
(key) => ctrl.springs[key].start(props)
|
|
1403
|
+
);
|
|
1404
|
+
const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
|
|
1405
|
+
if (asyncTo || cancel && state.asyncId) {
|
|
1406
|
+
promises.push(
|
|
1407
|
+
scheduleProps(++ctrl["_lastAsyncId"], {
|
|
1408
|
+
props,
|
|
1409
|
+
state,
|
|
1410
|
+
actions: {
|
|
1411
|
+
pause: reactSpring_shared_modern.noop,
|
|
1412
|
+
resume: reactSpring_shared_modern.noop,
|
|
1413
|
+
start(props2, resolve) {
|
|
1414
|
+
if (cancel) {
|
|
1415
|
+
stopAsync(state, ctrl["_lastAsyncId"]);
|
|
1416
|
+
resolve(getCancelledResult(ctrl));
|
|
1417
|
+
} else {
|
|
1418
|
+
props2.onRest = onRest;
|
|
1419
|
+
resolve(
|
|
1420
|
+
runAsync(
|
|
1421
|
+
asyncTo,
|
|
1422
|
+
props2,
|
|
1423
|
+
state,
|
|
1424
|
+
ctrl
|
|
1425
|
+
)
|
|
1426
|
+
);
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
})
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1433
|
+
if (state.paused) {
|
|
1434
|
+
await new Promise((resume) => {
|
|
1435
|
+
state.resumeQueue.add(resume);
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
const result = getCombinedResult(ctrl, await Promise.all(promises));
|
|
1439
|
+
if (loop && result.finished && !(isLoop && result.noop)) {
|
|
1440
|
+
const nextProps = createLoopUpdate(props, loop, to2);
|
|
1441
|
+
if (nextProps) {
|
|
1442
|
+
prepareKeys(ctrl, [nextProps]);
|
|
1443
|
+
return flushUpdate(ctrl, nextProps, true);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
if (onResolve) {
|
|
1447
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
|
|
1448
|
+
}
|
|
1449
|
+
return result;
|
|
1450
|
+
}
|
|
1451
|
+
function getSprings(ctrl, props) {
|
|
1452
|
+
const springs = { ...ctrl.springs };
|
|
1453
|
+
if (props) {
|
|
1454
|
+
reactSpring_shared_modern.each(reactSpring_shared_modern.toArray(props), (props2) => {
|
|
1455
|
+
if (reactSpring_shared_modern.is.und(props2.keys)) {
|
|
1456
|
+
props2 = createUpdate(props2);
|
|
1457
|
+
}
|
|
1458
|
+
if (!reactSpring_shared_modern.is.obj(props2.to)) {
|
|
1459
|
+
props2 = { ...props2, to: void 0 };
|
|
1460
|
+
}
|
|
1461
|
+
prepareSprings(springs, props2, (key) => {
|
|
1462
|
+
return createSpring(key);
|
|
1463
|
+
});
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
setSprings(ctrl, springs);
|
|
1467
|
+
return springs;
|
|
1468
|
+
}
|
|
1469
|
+
function setSprings(ctrl, springs) {
|
|
1470
|
+
reactSpring_shared_modern.eachProp(springs, (spring, key) => {
|
|
1471
|
+
if (!ctrl.springs[key]) {
|
|
1472
|
+
ctrl.springs[key] = spring;
|
|
1473
|
+
reactSpring_shared_modern.addFluidObserver(spring, ctrl);
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
function createSpring(key, observer) {
|
|
1478
|
+
const spring = new SpringValue();
|
|
1479
|
+
spring.key = key;
|
|
1480
|
+
if (observer) {
|
|
1481
|
+
reactSpring_shared_modern.addFluidObserver(spring, observer);
|
|
1482
|
+
}
|
|
1483
|
+
return spring;
|
|
1484
|
+
}
|
|
1485
|
+
function prepareSprings(springs, props, create) {
|
|
1486
|
+
if (props.keys) {
|
|
1487
|
+
reactSpring_shared_modern.each(props.keys, (key) => {
|
|
1488
|
+
const spring = springs[key] || (springs[key] = create(key));
|
|
1489
|
+
spring["_prepareNode"](props);
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
function prepareKeys(ctrl, queue) {
|
|
1494
|
+
reactSpring_shared_modern.each(queue, (props) => {
|
|
1495
|
+
prepareSprings(ctrl.springs, props, (key) => {
|
|
1496
|
+
return createSpring(key, ctrl);
|
|
1497
|
+
});
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
var SpringContext = React__namespace.createContext({
|
|
1501
|
+
pause: false,
|
|
1502
|
+
immediate: false
|
|
1503
|
+
});
|
|
1504
|
+
var SpringRef = () => {
|
|
1505
|
+
const current = [];
|
|
1506
|
+
const SpringRef2 = function(props) {
|
|
1507
|
+
reactSpring_shared_modern.deprecateDirectCall();
|
|
1508
|
+
const results = [];
|
|
1509
|
+
reactSpring_shared_modern.each(current, (ctrl, i) => {
|
|
1510
|
+
if (reactSpring_shared_modern.is.und(props)) {
|
|
1511
|
+
results.push(ctrl.start());
|
|
1512
|
+
} else {
|
|
1513
|
+
const update2 = _getProps(props, ctrl, i);
|
|
1514
|
+
if (update2) {
|
|
1515
|
+
results.push(ctrl.start(update2));
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
return results;
|
|
1520
|
+
};
|
|
1521
|
+
SpringRef2.current = current;
|
|
1522
|
+
SpringRef2.add = function(ctrl) {
|
|
1523
|
+
if (!current.includes(ctrl)) {
|
|
1524
|
+
current.push(ctrl);
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
SpringRef2.delete = function(ctrl) {
|
|
1528
|
+
const i = current.indexOf(ctrl);
|
|
1529
|
+
if (~i) current.splice(i, 1);
|
|
1530
|
+
};
|
|
1531
|
+
SpringRef2.pause = function() {
|
|
1532
|
+
reactSpring_shared_modern.each(current, (ctrl) => ctrl.pause(...arguments));
|
|
1533
|
+
return this;
|
|
1534
|
+
};
|
|
1535
|
+
SpringRef2.resume = function() {
|
|
1536
|
+
reactSpring_shared_modern.each(current, (ctrl) => ctrl.resume(...arguments));
|
|
1537
|
+
return this;
|
|
1538
|
+
};
|
|
1539
|
+
SpringRef2.set = function(values) {
|
|
1540
|
+
reactSpring_shared_modern.each(current, (ctrl, i) => {
|
|
1541
|
+
const update2 = reactSpring_shared_modern.is.fun(values) ? values(i, ctrl) : values;
|
|
1542
|
+
if (update2) {
|
|
1543
|
+
ctrl.set(update2);
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
};
|
|
1547
|
+
SpringRef2.start = function(props) {
|
|
1548
|
+
const results = [];
|
|
1549
|
+
reactSpring_shared_modern.each(current, (ctrl, i) => {
|
|
1550
|
+
if (reactSpring_shared_modern.is.und(props)) {
|
|
1551
|
+
results.push(ctrl.start());
|
|
1552
|
+
} else {
|
|
1553
|
+
const update2 = this._getProps(props, ctrl, i);
|
|
1554
|
+
if (update2) {
|
|
1555
|
+
results.push(ctrl.start(update2));
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
return results;
|
|
1560
|
+
};
|
|
1561
|
+
SpringRef2.stop = function() {
|
|
1562
|
+
reactSpring_shared_modern.each(current, (ctrl) => ctrl.stop(...arguments));
|
|
1563
|
+
return this;
|
|
1564
|
+
};
|
|
1565
|
+
SpringRef2.update = function(props) {
|
|
1566
|
+
reactSpring_shared_modern.each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i)));
|
|
1567
|
+
return this;
|
|
1568
|
+
};
|
|
1569
|
+
const _getProps = function(arg, ctrl, index) {
|
|
1570
|
+
return reactSpring_shared_modern.is.fun(arg) ? arg(index, ctrl) : arg;
|
|
1571
|
+
};
|
|
1572
|
+
SpringRef2._getProps = _getProps;
|
|
1573
|
+
return SpringRef2;
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1576
|
+
// src/hooks/useSprings.ts
|
|
1577
|
+
function useSprings(length, props, deps) {
|
|
1578
|
+
const propsFn = reactSpring_shared_modern.is.fun(props) && props;
|
|
1579
|
+
if (propsFn && !deps) deps = [];
|
|
1580
|
+
const ref = React.useMemo(
|
|
1581
|
+
() => propsFn || arguments.length == 3 ? SpringRef() : void 0,
|
|
1582
|
+
[]
|
|
1583
|
+
);
|
|
1584
|
+
const layoutId = React.useRef(0);
|
|
1585
|
+
const forceUpdate = reactSpring_shared_modern.useForceUpdate();
|
|
1586
|
+
const state = React.useMemo(
|
|
1587
|
+
() => ({
|
|
1588
|
+
ctrls: [],
|
|
1589
|
+
queue: [],
|
|
1590
|
+
flush(ctrl, updates2) {
|
|
1591
|
+
const springs2 = getSprings(ctrl, updates2);
|
|
1592
|
+
const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs2).some((key) => !ctrl.springs[key]);
|
|
1593
|
+
return canFlushSync ? flushUpdateQueue(ctrl, updates2) : new Promise((resolve) => {
|
|
1594
|
+
setSprings(ctrl, springs2);
|
|
1595
|
+
state.queue.push(() => {
|
|
1596
|
+
resolve(flushUpdateQueue(ctrl, updates2));
|
|
1597
|
+
});
|
|
1598
|
+
forceUpdate();
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
}),
|
|
1602
|
+
[]
|
|
1603
|
+
);
|
|
1604
|
+
const ctrls = React.useRef([...state.ctrls]);
|
|
1605
|
+
const updates = React.useRef([]);
|
|
1606
|
+
const prevLength = reactSpring_shared_modern.usePrev(length) || 0;
|
|
1607
|
+
React.useMemo(() => {
|
|
1608
|
+
reactSpring_shared_modern.each(ctrls.current.slice(length, prevLength), (ctrl) => {
|
|
1609
|
+
detachRefs(ctrl, ref);
|
|
1610
|
+
ctrl.stop(true);
|
|
1611
|
+
});
|
|
1612
|
+
ctrls.current.length = length;
|
|
1613
|
+
declareUpdates(prevLength, length);
|
|
1614
|
+
}, [length]);
|
|
1615
|
+
React.useMemo(() => {
|
|
1616
|
+
declareUpdates(0, Math.min(prevLength, length));
|
|
1617
|
+
}, deps);
|
|
1618
|
+
function declareUpdates(startIndex, endIndex) {
|
|
1619
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
1620
|
+
const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush));
|
|
1621
|
+
const update2 = propsFn ? propsFn(i, ctrl) : props[i];
|
|
1622
|
+
if (update2) {
|
|
1623
|
+
updates.current[i] = declareUpdate(update2);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
const springs = ctrls.current.map(
|
|
1628
|
+
(ctrl, i) => getSprings(ctrl, updates.current[i])
|
|
1629
|
+
);
|
|
1630
|
+
const context = React.useContext(SpringContext);
|
|
1631
|
+
const prevContext = reactSpring_shared_modern.usePrev(context);
|
|
1632
|
+
const hasContext = context !== prevContext && hasProps(context);
|
|
1633
|
+
reactSpring_shared_modern.useIsomorphicLayoutEffect(() => {
|
|
1634
|
+
layoutId.current++;
|
|
1635
|
+
state.ctrls = ctrls.current;
|
|
1636
|
+
const { queue } = state;
|
|
1637
|
+
if (queue.length) {
|
|
1638
|
+
state.queue = [];
|
|
1639
|
+
reactSpring_shared_modern.each(queue, (cb) => cb());
|
|
1640
|
+
}
|
|
1641
|
+
reactSpring_shared_modern.each(ctrls.current, (ctrl, i) => {
|
|
1642
|
+
ref?.add(ctrl);
|
|
1643
|
+
if (hasContext) {
|
|
1644
|
+
ctrl.start({ default: context });
|
|
1645
|
+
}
|
|
1646
|
+
const update2 = updates.current[i];
|
|
1647
|
+
if (update2) {
|
|
1648
|
+
replaceRef(ctrl, update2.ref);
|
|
1649
|
+
if (ctrl.ref) {
|
|
1650
|
+
ctrl.queue.push(update2);
|
|
1651
|
+
} else {
|
|
1652
|
+
ctrl.start(update2);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
});
|
|
1657
|
+
reactSpring_shared_modern.useOnce(() => () => {
|
|
1658
|
+
reactSpring_shared_modern.each(state.ctrls, (ctrl) => ctrl.stop(true));
|
|
1659
|
+
});
|
|
1660
|
+
const values = springs.map((x) => ({ ...x }));
|
|
1661
|
+
return ref ? [values, ref] : values;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
// src/hooks/useSpring.ts
|
|
1665
|
+
function useSpring(props, deps) {
|
|
1666
|
+
const isFn = reactSpring_shared_modern.is.fun(props);
|
|
1667
|
+
const [[values], ref] = useSprings(
|
|
1668
|
+
1,
|
|
1669
|
+
isFn ? props : [props],
|
|
1670
|
+
isFn ? [] : deps
|
|
1671
|
+
);
|
|
1672
|
+
return isFn || arguments.length == 2 ? [values, ref] : values;
|
|
1673
|
+
}
|
|
1674
|
+
var Interpolation = class extends FrameValue {
|
|
1675
|
+
constructor(source, args) {
|
|
1676
|
+
super();
|
|
1677
|
+
this.source = source;
|
|
1678
|
+
/** Equals false when in the frameloop */
|
|
1679
|
+
this.idle = true;
|
|
1680
|
+
/** The inputs which are currently animating */
|
|
1681
|
+
this._active = /* @__PURE__ */ new Set();
|
|
1682
|
+
this.calc = reactSpring_shared_modern.createInterpolator(...args);
|
|
1683
|
+
const value = this._get();
|
|
1684
|
+
const nodeType = reactSpring_animated_modern.getAnimatedType(value);
|
|
1685
|
+
reactSpring_animated_modern.setAnimated(this, nodeType.create(value));
|
|
1686
|
+
}
|
|
1687
|
+
advance(_dt) {
|
|
1688
|
+
const value = this._get();
|
|
1689
|
+
const oldValue = this.get();
|
|
1690
|
+
if (!reactSpring_shared_modern.isEqual(value, oldValue)) {
|
|
1691
|
+
reactSpring_animated_modern.getAnimated(this).setValue(value);
|
|
1692
|
+
this._onChange(value, this.idle);
|
|
1693
|
+
}
|
|
1694
|
+
if (!this.idle && checkIdle(this._active)) {
|
|
1695
|
+
becomeIdle(this);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
_get() {
|
|
1699
|
+
const inputs = reactSpring_shared_modern.is.arr(this.source) ? this.source.map(reactSpring_shared_modern.getFluidValue) : reactSpring_shared_modern.toArray(reactSpring_shared_modern.getFluidValue(this.source));
|
|
1700
|
+
return this.calc(...inputs);
|
|
1701
|
+
}
|
|
1702
|
+
_start() {
|
|
1703
|
+
if (this.idle && !checkIdle(this._active)) {
|
|
1704
|
+
this.idle = false;
|
|
1705
|
+
reactSpring_shared_modern.each(reactSpring_animated_modern.getPayload(this), (node) => {
|
|
1706
|
+
node.done = false;
|
|
1707
|
+
});
|
|
1708
|
+
if (reactSpring_shared_modern.Globals.skipAnimation) {
|
|
1709
|
+
reactSpring_rafz_modern.raf.batchedUpdates(() => this.advance());
|
|
1710
|
+
becomeIdle(this);
|
|
1711
|
+
} else {
|
|
1712
|
+
reactSpring_shared_modern.frameLoop.start(this);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
// Observe our sources only when we're observed.
|
|
1717
|
+
_attach() {
|
|
1718
|
+
let priority = 1;
|
|
1719
|
+
reactSpring_shared_modern.each(reactSpring_shared_modern.toArray(this.source), (source) => {
|
|
1720
|
+
if (reactSpring_shared_modern.hasFluidValue(source)) {
|
|
1721
|
+
reactSpring_shared_modern.addFluidObserver(source, this);
|
|
1722
|
+
}
|
|
1723
|
+
if (isFrameValue(source)) {
|
|
1724
|
+
if (!source.idle) {
|
|
1725
|
+
this._active.add(source);
|
|
1726
|
+
}
|
|
1727
|
+
priority = Math.max(priority, source.priority + 1);
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
this.priority = priority;
|
|
1731
|
+
this._start();
|
|
1732
|
+
}
|
|
1733
|
+
// Stop observing our sources once we have no observers.
|
|
1734
|
+
_detach() {
|
|
1735
|
+
reactSpring_shared_modern.each(reactSpring_shared_modern.toArray(this.source), (source) => {
|
|
1736
|
+
if (reactSpring_shared_modern.hasFluidValue(source)) {
|
|
1737
|
+
reactSpring_shared_modern.removeFluidObserver(source, this);
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
this._active.clear();
|
|
1741
|
+
becomeIdle(this);
|
|
1742
|
+
}
|
|
1743
|
+
/** @internal */
|
|
1744
|
+
eventObserved(event) {
|
|
1745
|
+
if (event.type == "change") {
|
|
1746
|
+
if (event.idle) {
|
|
1747
|
+
this.advance();
|
|
1748
|
+
} else {
|
|
1749
|
+
this._active.add(event.parent);
|
|
1750
|
+
this._start();
|
|
1751
|
+
}
|
|
1752
|
+
} else if (event.type == "idle") {
|
|
1753
|
+
this._active.delete(event.parent);
|
|
1754
|
+
} else if (event.type == "priority") {
|
|
1755
|
+
this.priority = reactSpring_shared_modern.toArray(this.source).reduce(
|
|
1756
|
+
(highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1),
|
|
1757
|
+
0
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
function isIdle(source) {
|
|
1763
|
+
return source.idle !== false;
|
|
1764
|
+
}
|
|
1765
|
+
function checkIdle(active) {
|
|
1766
|
+
return !active.size || Array.from(active).every(isIdle);
|
|
1767
|
+
}
|
|
1768
|
+
function becomeIdle(self) {
|
|
1769
|
+
if (!self.idle) {
|
|
1770
|
+
self.idle = true;
|
|
1771
|
+
reactSpring_shared_modern.each(reactSpring_animated_modern.getPayload(self), (node) => {
|
|
1772
|
+
node.done = true;
|
|
1773
|
+
});
|
|
1774
|
+
reactSpring_shared_modern.callFluidObservers(self, {
|
|
1775
|
+
type: "idle",
|
|
1776
|
+
parent: self
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
reactSpring_shared_modern.Globals.assign({
|
|
1781
|
+
createStringInterpolator: reactSpring_shared_modern.createStringInterpolator,
|
|
1782
|
+
to: (source, args) => new Interpolation(source, args)
|
|
1783
|
+
});
|
|
1784
|
+
|
|
1785
|
+
exports.Globals = reactSpring_shared_modern.Globals;
|
|
1786
|
+
exports.createInterpolator = reactSpring_shared_modern.createInterpolator;
|
|
1787
|
+
exports.easings = reactSpring_shared_modern.easings;
|
|
1788
|
+
exports.useIsomorphicLayoutEffect = reactSpring_shared_modern.useIsomorphicLayoutEffect;
|
|
1789
|
+
exports.BailSignal = BailSignal;
|
|
1790
|
+
exports.Controller = Controller;
|
|
1791
|
+
exports.FrameValue = FrameValue;
|
|
1792
|
+
exports.Interpolation = Interpolation;
|
|
1793
|
+
exports.SpringContext = SpringContext;
|
|
1794
|
+
exports.SpringRef = SpringRef;
|
|
1795
|
+
exports.SpringValue = SpringValue;
|
|
1796
|
+
exports.config = config;
|
|
1797
|
+
exports.inferTo = inferTo;
|
|
1798
|
+
exports.useSpring = useSpring;
|
|
1799
|
+
exports.useSprings = useSprings;
|