@nil-/xit 0.1.27 → 0.1.28
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/assets/bundler.js +257 -91
- package/assets/index.js +1954 -1930
- package/assets/svelte/index.js +1617 -1356
- package/assets/svelte/internal/client.js +1329 -1195
- package/assets/svelte/motion.js +399 -133
- package/assets/svelte/store.js +99 -93
- package/components/layouts/Container.svelte +24 -0
- package/components/layouts/Container.svelte.d.ts +7 -0
- package/components/layouts/Scrollable.svelte +22 -0
- package/components/layouts/Scrollable.svelte.d.ts +5 -0
- package/components/layouts/Split.svelte +114 -0
- package/components/layouts/Split.svelte.d.ts +19 -0
- package/components/utilities/DividerOverlay.svelte +78 -0
- package/components/utilities/DividerOverlay.svelte.d.ts +8 -0
- package/components/utilities/draggable.d.ts +17 -0
- package/components/utilities/draggable.js +67 -0
- package/index.d.ts +2 -2
- package/package.json +5 -1
package/assets/svelte/motion.js
CHANGED
|
@@ -1,195 +1,461 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var et = (e) => {
|
|
2
|
+
throw TypeError(e);
|
|
3
|
+
};
|
|
4
|
+
var W = (e, t, s) => t.has(e) || et("Cannot " + s);
|
|
5
|
+
var r = (e, t, s) => (W(e, t, "read from private field"), s ? s.call(e) : t.get(e)), c = (e, t, s) => t.has(e) ? et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, s), h = (e, t, s, i) => (W(e, t, "write to private field"), i ? i.call(e, s) : t.set(e, s), s), st = (e, t, s) => (W(e, t, "access private method"), s);
|
|
6
|
+
import "./internal/client.js";
|
|
7
|
+
import { o as ht, c as O, b as rt, a as g, f as ut, n as dt, g as _ } from "./index.js";
|
|
8
|
+
import { c as lt, w as nt } from "./store.js";
|
|
9
|
+
import { linear as it } from "./easing.js";
|
|
10
|
+
const mt = () => performance.now(), l = {
|
|
4
11
|
// don't access requestAnimationFrame eagerly outside method
|
|
5
12
|
// this allows basic testing of user code without JSDOM
|
|
6
13
|
// bunder will eval and remove ternary when the user's app is built
|
|
7
14
|
tick: (
|
|
8
15
|
/** @param {any} _ */
|
|
9
|
-
(
|
|
16
|
+
(e) => requestAnimationFrame(e)
|
|
10
17
|
),
|
|
11
|
-
now: () =>
|
|
18
|
+
now: () => mt(),
|
|
12
19
|
tasks: /* @__PURE__ */ new Set()
|
|
13
20
|
};
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
function ot() {
|
|
22
|
+
const e = l.now();
|
|
23
|
+
l.tasks.forEach((t) => {
|
|
24
|
+
t.c(e) || (l.tasks.delete(t), t.f());
|
|
25
|
+
}), l.tasks.size !== 0 && l.tick(ot);
|
|
18
26
|
}
|
|
19
|
-
function
|
|
20
|
-
let
|
|
21
|
-
return
|
|
22
|
-
promise: new Promise((
|
|
23
|
-
|
|
27
|
+
function N(e) {
|
|
28
|
+
let t;
|
|
29
|
+
return l.tasks.size === 0 && l.tick(ot), {
|
|
30
|
+
promise: new Promise((s) => {
|
|
31
|
+
l.tasks.add(t = { c: e, f: s });
|
|
24
32
|
}),
|
|
25
33
|
abort() {
|
|
26
|
-
|
|
34
|
+
l.tasks.delete(t);
|
|
27
35
|
}
|
|
28
36
|
};
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
var Q, V;
|
|
39
|
+
class pt {
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param {() => T} fn
|
|
43
|
+
* @param {(update: () => void) => void} onsubscribe
|
|
44
|
+
*/
|
|
45
|
+
constructor(t, s) {
|
|
46
|
+
c(this, Q);
|
|
47
|
+
c(this, V);
|
|
48
|
+
h(this, Q, t), h(this, V, lt(s));
|
|
49
|
+
}
|
|
50
|
+
get current() {
|
|
51
|
+
return r(this, V).call(this), r(this, Q).call(this);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
Q = new WeakMap(), V = new WeakMap();
|
|
55
|
+
const gt = /\(.+\)/;
|
|
56
|
+
class bt extends pt {
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} query A media query string
|
|
59
|
+
* @param {boolean} [fallback] Fallback value for the server
|
|
60
|
+
*/
|
|
61
|
+
constructor(t, s) {
|
|
62
|
+
let i = gt.test(t) ? t : `(${t})`;
|
|
63
|
+
const o = window.matchMedia(i);
|
|
64
|
+
super(
|
|
65
|
+
() => o.matches,
|
|
66
|
+
(n) => ht(o, "change", n)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function I(e) {
|
|
71
|
+
return Object.prototype.toString.call(e) === "[object Date]";
|
|
32
72
|
}
|
|
33
|
-
function
|
|
34
|
-
if (typeof
|
|
35
|
-
const
|
|
36
|
-
return Math.abs(
|
|
73
|
+
function J(e, t, s, i) {
|
|
74
|
+
if (typeof s == "number" || I(s)) {
|
|
75
|
+
const o = i - s, n = (s - t) / (e.dt || 1 / 60), f = e.opts.stiffness * o, a = e.opts.damping * n, u = (f - a) * e.inv_mass, m = (n + u) * e.dt;
|
|
76
|
+
return Math.abs(m) < e.opts.precision && Math.abs(o) < e.opts.precision ? i : (e.settled = !1, I(s) ? new Date(s.getTime() + m) : s + m);
|
|
37
77
|
} else {
|
|
38
|
-
if (Array.isArray(
|
|
39
|
-
return
|
|
40
|
-
(
|
|
78
|
+
if (Array.isArray(s))
|
|
79
|
+
return s.map(
|
|
80
|
+
(o, n) => (
|
|
41
81
|
// @ts-ignore
|
|
42
|
-
|
|
82
|
+
J(e, t[n], s[n], i[n])
|
|
43
83
|
)
|
|
44
84
|
);
|
|
45
|
-
if (typeof
|
|
46
|
-
const
|
|
47
|
-
for (const
|
|
48
|
-
n
|
|
49
|
-
return
|
|
85
|
+
if (typeof s == "object") {
|
|
86
|
+
const o = {};
|
|
87
|
+
for (const n in s)
|
|
88
|
+
o[n] = J(e, t[n], s[n], i[n]);
|
|
89
|
+
return o;
|
|
50
90
|
} else
|
|
51
|
-
throw new Error(`Cannot spring ${typeof
|
|
91
|
+
throw new Error(`Cannot spring ${typeof s} values`);
|
|
52
92
|
}
|
|
53
93
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
let
|
|
94
|
+
function yt(e, t = {}) {
|
|
95
|
+
const s = nt(e), { stiffness: i = 0.15, damping: o = 0.8, precision: n = 0.01 } = t;
|
|
96
|
+
let f, a, u, m = (
|
|
57
97
|
/** @type {T} */
|
|
58
|
-
|
|
59
|
-
),
|
|
98
|
+
e
|
|
99
|
+
), b = (
|
|
60
100
|
/** @type {T | undefined} */
|
|
61
|
-
|
|
62
|
-
),
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
inv_mass:
|
|
72
|
-
opts:
|
|
101
|
+
e
|
|
102
|
+
), d = 1, j = 0, y = !1;
|
|
103
|
+
function x(P, w = {}) {
|
|
104
|
+
b = P;
|
|
105
|
+
const at = u = {};
|
|
106
|
+
return e == null || w.hard || E.stiffness >= 1 && E.damping >= 1 ? (y = !0, f = l.now(), m = P, s.set(e = b), Promise.resolve()) : (w.soft && (j = 1 / ((w.soft === !0 ? 0.5 : +w.soft) * 60), d = 0), a || (f = l.now(), y = !1, a = N((F) => {
|
|
107
|
+
if (y)
|
|
108
|
+
return y = !1, a = null, !1;
|
|
109
|
+
d = Math.min(d + j, 1);
|
|
110
|
+
const U = {
|
|
111
|
+
inv_mass: d,
|
|
112
|
+
opts: E,
|
|
73
113
|
settled: !0,
|
|
74
|
-
dt: (
|
|
75
|
-
},
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
})), new Promise((
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
dt: (F - f) * 60 / 1e3
|
|
115
|
+
}, ct = J(U, m, e, b);
|
|
116
|
+
return f = F, m = /** @type {T} */
|
|
117
|
+
e, s.set(e = /** @type {T} */
|
|
118
|
+
ct), U.settled && (a = null), !U.settled;
|
|
119
|
+
})), new Promise((F) => {
|
|
120
|
+
a.promise.then(() => {
|
|
121
|
+
at === u && F();
|
|
82
122
|
});
|
|
83
123
|
}));
|
|
84
124
|
}
|
|
85
|
-
const
|
|
86
|
-
set:
|
|
87
|
-
update: (
|
|
125
|
+
const E = {
|
|
126
|
+
set: x,
|
|
127
|
+
update: (P, w) => x(P(
|
|
88
128
|
/** @type {T} */
|
|
89
|
-
|
|
129
|
+
b,
|
|
90
130
|
/** @type {T} */
|
|
91
|
-
|
|
92
|
-
),
|
|
93
|
-
subscribe:
|
|
131
|
+
e
|
|
132
|
+
), w),
|
|
133
|
+
subscribe: s.subscribe,
|
|
94
134
|
stiffness: i,
|
|
95
|
-
damping:
|
|
96
|
-
precision:
|
|
135
|
+
damping: o,
|
|
136
|
+
precision: n
|
|
97
137
|
};
|
|
98
|
-
return
|
|
138
|
+
return E;
|
|
139
|
+
}
|
|
140
|
+
var S, z, C, p, M, D, $, T, B, k, R, L, ft;
|
|
141
|
+
const Z = class Z {
|
|
142
|
+
/**
|
|
143
|
+
* @param {T} value
|
|
144
|
+
* @param {SpringOpts} [options]
|
|
145
|
+
*/
|
|
146
|
+
constructor(t, s = {}) {
|
|
147
|
+
c(this, L);
|
|
148
|
+
c(this, S, O(0.15));
|
|
149
|
+
c(this, z, O(0.8));
|
|
150
|
+
c(this, C, O(0.01));
|
|
151
|
+
c(this, p, O(
|
|
152
|
+
/** @type {T} */
|
|
153
|
+
void 0
|
|
154
|
+
));
|
|
155
|
+
c(this, M, O(
|
|
156
|
+
/** @type {T} */
|
|
157
|
+
void 0
|
|
158
|
+
));
|
|
159
|
+
c(this, D);
|
|
160
|
+
c(this, $, 0);
|
|
161
|
+
c(this, T, 1);
|
|
162
|
+
c(this, B, 0);
|
|
163
|
+
/** @type {import('../internal/client/types').Task | null} */
|
|
164
|
+
c(this, k, null);
|
|
165
|
+
/** @type {ReturnType<typeof deferred> | null} */
|
|
166
|
+
c(this, R, null);
|
|
167
|
+
r(this, p).v = r(this, M).v = t, typeof s.stiffness == "number" && (r(this, S).v = H(s.stiffness, 0, 1)), typeof s.damping == "number" && (r(this, z).v = H(s.damping, 0, 1)), typeof s.precision == "number" && (r(this, C).v = s.precision);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create a spring whose value is bound to the return value of `fn`. This must be called
|
|
171
|
+
* inside an effect root (for example, during component initialisation).
|
|
172
|
+
*
|
|
173
|
+
* ```svelte
|
|
174
|
+
* <script>
|
|
175
|
+
* import { Spring } from 'svelte/motion';
|
|
176
|
+
*
|
|
177
|
+
* let { number } = $props();
|
|
178
|
+
*
|
|
179
|
+
* const spring = Spring.of(() => number);
|
|
180
|
+
* <\/script>
|
|
181
|
+
* ```
|
|
182
|
+
* @template U
|
|
183
|
+
* @param {() => U} fn
|
|
184
|
+
* @param {SpringOpts} [options]
|
|
185
|
+
*/
|
|
186
|
+
static of(t, s) {
|
|
187
|
+
const i = new Z(t(), s);
|
|
188
|
+
return rt(() => {
|
|
189
|
+
i.set(t());
|
|
190
|
+
}), i;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Sets `spring.target` to `value` and returns a `Promise` that resolves if and when `spring.current` catches up to it.
|
|
194
|
+
*
|
|
195
|
+
* If `options.instant` is `true`, `spring.current` immediately matches `spring.target`.
|
|
196
|
+
*
|
|
197
|
+
* If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
|
|
198
|
+
* the specified number of milliseconds. This is useful for things like 'fling' gestures.
|
|
199
|
+
*
|
|
200
|
+
* @param {T} value
|
|
201
|
+
* @param {SpringUpdateOpts} [options]
|
|
202
|
+
*/
|
|
203
|
+
set(t, s) {
|
|
204
|
+
var o, n;
|
|
205
|
+
if ((o = r(this, R)) == null || o.reject(new Error("Aborted")), s != null && s.instant || r(this, p).v === void 0)
|
|
206
|
+
return (n = r(this, k)) == null || n.abort(), h(this, k, null), g(r(this, p), g(r(this, M), t)), h(this, D, t), Promise.resolve();
|
|
207
|
+
s != null && s.preserveMomentum && (h(this, T, 0), h(this, B, s.preserveMomentum));
|
|
208
|
+
var i = h(this, R, ut());
|
|
209
|
+
return i.promise.catch(dt), st(this, L, ft).call(this, t).then(() => {
|
|
210
|
+
i === r(this, R) && i.resolve(void 0);
|
|
211
|
+
}), i.promise;
|
|
212
|
+
}
|
|
213
|
+
get current() {
|
|
214
|
+
return _(r(this, p));
|
|
215
|
+
}
|
|
216
|
+
get damping() {
|
|
217
|
+
return _(r(this, z));
|
|
218
|
+
}
|
|
219
|
+
set damping(t) {
|
|
220
|
+
g(r(this, z), H(t, 0, 1));
|
|
221
|
+
}
|
|
222
|
+
get precision() {
|
|
223
|
+
return _(r(this, C));
|
|
224
|
+
}
|
|
225
|
+
set precision(t) {
|
|
226
|
+
g(r(this, C), t);
|
|
227
|
+
}
|
|
228
|
+
get stiffness() {
|
|
229
|
+
return _(r(this, S));
|
|
230
|
+
}
|
|
231
|
+
set stiffness(t) {
|
|
232
|
+
g(r(this, S), H(t, 0, 1));
|
|
233
|
+
}
|
|
234
|
+
get target() {
|
|
235
|
+
return _(r(this, M));
|
|
236
|
+
}
|
|
237
|
+
set target(t) {
|
|
238
|
+
this.set(t);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
S = new WeakMap(), z = new WeakMap(), C = new WeakMap(), p = new WeakMap(), M = new WeakMap(), D = new WeakMap(), $ = new WeakMap(), T = new WeakMap(), B = new WeakMap(), k = new WeakMap(), R = new WeakMap(), L = new WeakSet(), /** @param {T} value */
|
|
242
|
+
ft = function(t) {
|
|
243
|
+
var i;
|
|
244
|
+
if (g(r(this, M), t), (i = r(this, p)).v ?? (i.v = t), r(this, D) ?? h(this, D, r(this, p).v), !r(this, k)) {
|
|
245
|
+
h(this, $, l.now());
|
|
246
|
+
var s = 1e3 / (r(this, B) * 60);
|
|
247
|
+
r(this, k) ?? h(this, k, N((o) => {
|
|
248
|
+
h(this, T, Math.min(r(this, T) + s, 1));
|
|
249
|
+
const n = {
|
|
250
|
+
inv_mass: r(this, T),
|
|
251
|
+
opts: {
|
|
252
|
+
stiffness: r(this, S).v,
|
|
253
|
+
damping: r(this, z).v,
|
|
254
|
+
precision: r(this, C).v
|
|
255
|
+
},
|
|
256
|
+
settled: !0,
|
|
257
|
+
dt: (o - r(this, $)) * 60 / 1e3
|
|
258
|
+
};
|
|
259
|
+
var f = J(n, r(this, D), r(this, p).v, r(this, M).v);
|
|
260
|
+
return h(this, D, r(this, p).v), h(this, $, o), g(r(this, p), f), n.settled && h(this, k, null), !n.settled;
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
return r(this, k).promise;
|
|
264
|
+
};
|
|
265
|
+
let X = Z;
|
|
266
|
+
function H(e, t, s) {
|
|
267
|
+
return Math.max(t, Math.min(s, e));
|
|
99
268
|
}
|
|
100
|
-
function
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
269
|
+
function K(e, t) {
|
|
270
|
+
if (e === t || e !== e) return () => e;
|
|
271
|
+
const s = typeof e;
|
|
272
|
+
if (s !== typeof t || Array.isArray(e) !== Array.isArray(t))
|
|
104
273
|
throw new Error("Cannot interpolate values of different type");
|
|
105
|
-
if (Array.isArray(
|
|
274
|
+
if (Array.isArray(e)) {
|
|
106
275
|
const i = (
|
|
107
276
|
/** @type {Array<any>} */
|
|
108
|
-
|
|
277
|
+
t.map((o, n) => K(
|
|
109
278
|
/** @type {Array<any>} */
|
|
110
|
-
|
|
111
|
-
|
|
279
|
+
e[n],
|
|
280
|
+
o
|
|
112
281
|
))
|
|
113
282
|
);
|
|
114
|
-
return (
|
|
283
|
+
return (o) => i.map((n) => n(o));
|
|
115
284
|
}
|
|
116
|
-
if (
|
|
117
|
-
if (!
|
|
285
|
+
if (s === "object") {
|
|
286
|
+
if (!e || !t)
|
|
118
287
|
throw new Error("Object cannot be null");
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
return (
|
|
288
|
+
if (I(e) && I(t)) {
|
|
289
|
+
const n = e.getTime(), a = t.getTime() - n;
|
|
290
|
+
return (u) => new Date(n + u * a);
|
|
122
291
|
}
|
|
123
|
-
const i = Object.keys(
|
|
124
|
-
return i.forEach((
|
|
125
|
-
n
|
|
126
|
-
}), (
|
|
127
|
-
const
|
|
128
|
-
return i.forEach((
|
|
129
|
-
|
|
130
|
-
}),
|
|
292
|
+
const i = Object.keys(t), o = {};
|
|
293
|
+
return i.forEach((n) => {
|
|
294
|
+
o[n] = K(e[n], t[n]);
|
|
295
|
+
}), (n) => {
|
|
296
|
+
const f = {};
|
|
297
|
+
return i.forEach((a) => {
|
|
298
|
+
f[a] = o[a](n);
|
|
299
|
+
}), f;
|
|
131
300
|
};
|
|
132
301
|
}
|
|
133
|
-
if (
|
|
302
|
+
if (s === "number") {
|
|
134
303
|
const i = (
|
|
135
304
|
/** @type {number} */
|
|
136
|
-
|
|
137
|
-
|
|
305
|
+
t - /** @type {number} */
|
|
306
|
+
e
|
|
138
307
|
);
|
|
139
|
-
return (
|
|
308
|
+
return (o) => e + o * i;
|
|
140
309
|
}
|
|
141
|
-
throw new Error(`Cannot interpolate ${
|
|
310
|
+
throw new Error(`Cannot interpolate ${s} values`);
|
|
142
311
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
let i,
|
|
146
|
-
function
|
|
147
|
-
if (
|
|
148
|
-
return
|
|
149
|
-
let
|
|
150
|
-
delay:
|
|
151
|
-
duration:
|
|
152
|
-
easing:
|
|
153
|
-
interpolate:
|
|
154
|
-
} = { ...
|
|
155
|
-
if (
|
|
156
|
-
return
|
|
157
|
-
const
|
|
158
|
-
let
|
|
159
|
-
return i =
|
|
160
|
-
if (
|
|
161
|
-
|
|
312
|
+
function wt(e, t = {}) {
|
|
313
|
+
const s = nt(e);
|
|
314
|
+
let i, o = e;
|
|
315
|
+
function n(f, a) {
|
|
316
|
+
if (o = f, e == null)
|
|
317
|
+
return s.set(e = f), Promise.resolve();
|
|
318
|
+
let u = i, m = !1, {
|
|
319
|
+
delay: b = 0,
|
|
320
|
+
duration: d = 400,
|
|
321
|
+
easing: j = it,
|
|
322
|
+
interpolate: y = K
|
|
323
|
+
} = { ...t, ...a };
|
|
324
|
+
if (d === 0)
|
|
325
|
+
return u && (u.abort(), u = null), s.set(e = o), Promise.resolve();
|
|
326
|
+
const x = l.now() + b;
|
|
327
|
+
let E;
|
|
328
|
+
return i = N((P) => {
|
|
329
|
+
if (P < x) return !0;
|
|
330
|
+
m || (E = y(
|
|
162
331
|
/** @type {any} */
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
), typeof
|
|
332
|
+
e,
|
|
333
|
+
f
|
|
334
|
+
), typeof d == "function" && (d = d(
|
|
166
335
|
/** @type {any} */
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)),
|
|
170
|
-
const
|
|
171
|
-
return
|
|
172
|
-
|
|
336
|
+
e,
|
|
337
|
+
f
|
|
338
|
+
)), m = !0), u && (u.abort(), u = null);
|
|
339
|
+
const w = P - x;
|
|
340
|
+
return w > /** @type {number} */
|
|
341
|
+
d ? (s.set(e = f), !1) : (s.set(e = E(j(w / d))), !0);
|
|
173
342
|
}), i.promise;
|
|
174
343
|
}
|
|
175
344
|
return {
|
|
176
|
-
set:
|
|
177
|
-
update: (
|
|
345
|
+
set: n,
|
|
346
|
+
update: (f, a) => n(f(
|
|
178
347
|
/** @type {any} */
|
|
179
|
-
|
|
348
|
+
o,
|
|
180
349
|
/** @type {any} */
|
|
181
|
-
|
|
182
|
-
),
|
|
183
|
-
subscribe:
|
|
350
|
+
e
|
|
351
|
+
), a),
|
|
352
|
+
subscribe: s.subscribe
|
|
184
353
|
};
|
|
185
354
|
}
|
|
186
|
-
|
|
355
|
+
var A, q, G, v;
|
|
356
|
+
const tt = class tt {
|
|
357
|
+
/**
|
|
358
|
+
* @param {T} value
|
|
359
|
+
* @param {TweenedOptions<T>} options
|
|
360
|
+
*/
|
|
361
|
+
constructor(t, s = {}) {
|
|
362
|
+
c(this, A, O(
|
|
363
|
+
/** @type {T} */
|
|
364
|
+
void 0
|
|
365
|
+
));
|
|
366
|
+
c(this, q, O(
|
|
367
|
+
/** @type {T} */
|
|
368
|
+
void 0
|
|
369
|
+
));
|
|
370
|
+
/** @type {TweenedOptions<T>} */
|
|
371
|
+
c(this, G);
|
|
372
|
+
/** @type {import('../internal/client/types').Task | null} */
|
|
373
|
+
c(this, v, null);
|
|
374
|
+
r(this, A).v = r(this, q).v = t, h(this, G, s);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Create a tween whose value is bound to the return value of `fn`. This must be called
|
|
378
|
+
* inside an effect root (for example, during component initialisation).
|
|
379
|
+
*
|
|
380
|
+
* ```svelte
|
|
381
|
+
* <script>
|
|
382
|
+
* import { Tween } from 'svelte/motion';
|
|
383
|
+
*
|
|
384
|
+
* let { number } = $props();
|
|
385
|
+
*
|
|
386
|
+
* const tween = Tween.of(() => number);
|
|
387
|
+
* <\/script>
|
|
388
|
+
* ```
|
|
389
|
+
* @template U
|
|
390
|
+
* @param {() => U} fn
|
|
391
|
+
* @param {TweenedOptions<U>} [options]
|
|
392
|
+
*/
|
|
393
|
+
static of(t, s) {
|
|
394
|
+
const i = new tt(t(), s);
|
|
395
|
+
return rt(() => {
|
|
396
|
+
i.set(t());
|
|
397
|
+
}), i;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Sets `tween.target` to `value` and returns a `Promise` that resolves if and when `tween.current` catches up to it.
|
|
401
|
+
*
|
|
402
|
+
* If `options` are provided, they will override the tween's defaults.
|
|
403
|
+
* @param {T} value
|
|
404
|
+
* @param {TweenedOptions<T>} [options]
|
|
405
|
+
* @returns
|
|
406
|
+
*/
|
|
407
|
+
set(t, s) {
|
|
408
|
+
g(r(this, q), t);
|
|
409
|
+
let i = r(this, A).v, o = r(this, v), n = !1, {
|
|
410
|
+
delay: f = 0,
|
|
411
|
+
duration: a = 400,
|
|
412
|
+
easing: u = it,
|
|
413
|
+
interpolate: m = K
|
|
414
|
+
} = { ...r(this, G), ...s };
|
|
415
|
+
const b = l.now() + f;
|
|
416
|
+
let d;
|
|
417
|
+
return h(this, v, N((j) => {
|
|
418
|
+
if (j < b)
|
|
419
|
+
return !0;
|
|
420
|
+
n || (n = !0, d = m(
|
|
421
|
+
/** @type {any} */
|
|
422
|
+
i,
|
|
423
|
+
t
|
|
424
|
+
), typeof a == "function" && (a = a(
|
|
425
|
+
/** @type {any} */
|
|
426
|
+
i,
|
|
427
|
+
t
|
|
428
|
+
)), o == null || o.abort());
|
|
429
|
+
const y = j - b;
|
|
430
|
+
return y > /** @type {number} */
|
|
431
|
+
a ? (g(r(this, A), t), !1) : (g(r(this, A), d(u(y / /** @type {number} */
|
|
432
|
+
a))), !0);
|
|
433
|
+
})), r(this, v).promise;
|
|
434
|
+
}
|
|
435
|
+
get current() {
|
|
436
|
+
return _(r(this, A));
|
|
437
|
+
}
|
|
438
|
+
get target() {
|
|
439
|
+
return _(r(this, q));
|
|
440
|
+
}
|
|
441
|
+
set target(t) {
|
|
442
|
+
this.set(t);
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
A = new WeakMap(), q = new WeakMap(), G = new WeakMap(), v = new WeakMap();
|
|
446
|
+
let Y = tt;
|
|
447
|
+
const kt = /* @__PURE__ */ new bt(
|
|
448
|
+
"(prefers-reduced-motion: reduce)"
|
|
449
|
+
), Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
187
450
|
__proto__: null,
|
|
188
|
-
|
|
189
|
-
|
|
451
|
+
Spring: X,
|
|
452
|
+
Tween: Y,
|
|
453
|
+
prefersReducedMotion: kt,
|
|
454
|
+
spring: yt,
|
|
455
|
+
tweened: wt
|
|
190
456
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
191
457
|
export {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
458
|
+
Ot as i,
|
|
459
|
+
N as l,
|
|
460
|
+
l as r
|
|
195
461
|
};
|