perspective-layered-ui 1.0.5 → 1.0.7
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/LayeredScene.d.ts +1 -0
- package/dist/LayeredScene.d.ts.map +1 -1
- package/dist/index.es.js +83 -81
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/LayeredScene.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export type LayeredSceneProps = {
|
|
|
18
18
|
export type LayeredSceneRef = {
|
|
19
19
|
goToPrev: () => void;
|
|
20
20
|
goToNext: () => void;
|
|
21
|
+
goToFirst: () => void;
|
|
21
22
|
};
|
|
22
23
|
export declare const LayeredScene: import("react").ForwardRefExoticComponent<LayeredSceneProps & import("react").RefAttributes<LayeredSceneRef>>;
|
|
23
24
|
export interface LayerProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayeredScene.d.ts","sourceRoot":"","sources":["../src/LayeredScene.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,SAAS,EAQf,MAAM,OAAO,CAAA;AAEd,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"LayeredScene.d.ts","sourceRoot":"","sources":["../src/LayeredScene.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,SAAS,EAQf,MAAM,OAAO,CAAA;AAEd,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,YAAY,+GA8OvB,CAAA;AAEF,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,EAAE,UAAU,2CAE7C"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import fe, { forwardRef as me, useMemo as de, Children as ge, useState as P, useRef as Q, useCallback as pe, useEffect as H, useImperativeHandle as
|
|
1
|
+
import fe, { forwardRef as me, useMemo as de, Children as ge, useState as P, useRef as Q, useCallback as pe, useEffect as H, useImperativeHandle as Ee, isValidElement as ee } from "react";
|
|
2
2
|
var Z = { exports: {} }, Y = {};
|
|
3
3
|
var re;
|
|
4
|
-
function
|
|
4
|
+
function ve() {
|
|
5
5
|
if (re) return Y;
|
|
6
6
|
re = 1;
|
|
7
|
-
var f = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
8
|
-
function
|
|
9
|
-
var
|
|
10
|
-
if (s !== void 0 && (
|
|
7
|
+
var f = /* @__PURE__ */ Symbol.for("react.transitional.element"), y = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function T(m, l, s) {
|
|
9
|
+
var h = null;
|
|
10
|
+
if (s !== void 0 && (h = "" + s), l.key !== void 0 && (h = "" + l.key), "key" in l) {
|
|
11
11
|
s = {};
|
|
12
|
-
for (var
|
|
13
|
-
|
|
12
|
+
for (var k in l)
|
|
13
|
+
k !== "key" && (s[k] = l[k]);
|
|
14
14
|
} else s = l;
|
|
15
15
|
return l = s.ref, {
|
|
16
16
|
$$typeof: f,
|
|
17
17
|
type: m,
|
|
18
|
-
key:
|
|
18
|
+
key: h,
|
|
19
19
|
ref: l !== void 0 ? l : null,
|
|
20
20
|
props: s
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return Y.Fragment =
|
|
23
|
+
return Y.Fragment = y, Y.jsx = T, Y.jsxs = T, Y;
|
|
24
24
|
}
|
|
25
25
|
var D = {};
|
|
26
26
|
var te;
|
|
@@ -34,13 +34,13 @@ function _e() {
|
|
|
34
34
|
switch (e) {
|
|
35
35
|
case j:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case
|
|
37
|
+
case q:
|
|
38
38
|
return "Profiler";
|
|
39
39
|
case U:
|
|
40
40
|
return "StrictMode";
|
|
41
41
|
case I:
|
|
42
42
|
return "Suspense";
|
|
43
|
-
case
|
|
43
|
+
case B:
|
|
44
44
|
return "SuspenseList";
|
|
45
45
|
case w:
|
|
46
46
|
return "Activity";
|
|
@@ -49,13 +49,13 @@ function _e() {
|
|
|
49
49
|
switch (typeof e.tag == "number" && console.error(
|
|
50
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
51
|
), e.$$typeof) {
|
|
52
|
-
case
|
|
52
|
+
case g:
|
|
53
53
|
return "Portal";
|
|
54
54
|
case $:
|
|
55
55
|
return e.displayName || "Context";
|
|
56
56
|
case a:
|
|
57
57
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
-
case
|
|
58
|
+
case z:
|
|
59
59
|
var r = e.render;
|
|
60
60
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
61
|
case x:
|
|
@@ -69,12 +69,12 @@ function _e() {
|
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function y(e) {
|
|
73
73
|
return "" + e;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function T(e) {
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
y(e);
|
|
78
78
|
var r = !1;
|
|
79
79
|
} catch {
|
|
80
80
|
r = !0;
|
|
@@ -86,7 +86,7 @@ function _e() {
|
|
|
86
86
|
r,
|
|
87
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
88
|
n
|
|
89
|
-
),
|
|
89
|
+
), y(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function m(e) {
|
|
@@ -101,20 +101,20 @@ function _e() {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function l() {
|
|
104
|
-
var e =
|
|
104
|
+
var e = b.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
107
|
function s() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (
|
|
110
|
+
function h(e) {
|
|
111
|
+
if (u.call(e, "key")) {
|
|
112
112
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
113
|
if (r && r.isReactWarning) return !1;
|
|
114
114
|
}
|
|
115
115
|
return e.key !== void 0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function k(e, r) {
|
|
118
118
|
function t() {
|
|
119
119
|
N || (N = !0, console.error(
|
|
120
120
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
@@ -128,7 +128,7 @@ function _e() {
|
|
|
128
128
|
}
|
|
129
129
|
function F() {
|
|
130
130
|
var e = f(this.type);
|
|
131
|
-
return
|
|
131
|
+
return E[e] || (E[e] = !0, console.error(
|
|
132
132
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
133
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
@@ -178,12 +178,12 @@ function _e() {
|
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
180
|
else A(o);
|
|
181
|
-
if (
|
|
181
|
+
if (u.call(r, "key")) {
|
|
182
182
|
o = f(e);
|
|
183
|
-
var
|
|
183
|
+
var _ = Object.keys(r).filter(function(K) {
|
|
184
184
|
return K !== "key";
|
|
185
185
|
});
|
|
186
|
-
n = 0 <
|
|
186
|
+
n = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", V[o + n] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
188
188
|
let props = %s;
|
|
189
189
|
<%s {...props} />
|
|
@@ -192,16 +192,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
192
192
|
<%s key={someKey} {...props} />`,
|
|
193
193
|
n,
|
|
194
194
|
o,
|
|
195
|
-
|
|
195
|
+
_,
|
|
196
196
|
o
|
|
197
197
|
), V[o + n] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (o = null, t !== void 0 && (
|
|
199
|
+
if (o = null, t !== void 0 && (T(t), o = "" + t), h(r) && (T(r.key), o = "" + r.key), "key" in r) {
|
|
200
200
|
t = {};
|
|
201
201
|
for (var G in r)
|
|
202
202
|
G !== "key" && (t[G] = r[G]);
|
|
203
203
|
} else t = r;
|
|
204
|
-
return o &&
|
|
204
|
+
return o && k(
|
|
205
205
|
t,
|
|
206
206
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
207
|
), X(
|
|
@@ -219,142 +219,144 @@ React keys must be passed directly to JSX without using spread:
|
|
|
219
219
|
function C(e) {
|
|
220
220
|
return typeof e == "object" && e !== null && e.$$typeof === W;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var d = fe, W = /* @__PURE__ */ Symbol.for("react.transitional.element"), g = /* @__PURE__ */ Symbol.for("react.portal"), j = /* @__PURE__ */ Symbol.for("react.fragment"), U = /* @__PURE__ */ Symbol.for("react.strict_mode"), q = /* @__PURE__ */ Symbol.for("react.profiler"), a = /* @__PURE__ */ Symbol.for("react.consumer"), $ = /* @__PURE__ */ Symbol.for("react.context"), z = /* @__PURE__ */ Symbol.for("react.forward_ref"), I = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), x = /* @__PURE__ */ Symbol.for("react.memo"), S = /* @__PURE__ */ Symbol.for("react.lazy"), w = /* @__PURE__ */ Symbol.for("react.activity"), J = /* @__PURE__ */ Symbol.for("react.client.reference"), b = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, u = Object.prototype.hasOwnProperty, M = Array.isArray, p = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
d = {
|
|
226
226
|
react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var N,
|
|
231
|
-
|
|
230
|
+
var N, E = {}, v = d.react_stack_bottom_frame.bind(
|
|
231
|
+
d,
|
|
232
232
|
s
|
|
233
|
-
)(),
|
|
233
|
+
)(), i = p(m(s)), V = {};
|
|
234
234
|
D.Fragment = j, D.jsx = function(e, r, t) {
|
|
235
|
-
var n = 1e4 >
|
|
235
|
+
var n = 1e4 > b.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return L(
|
|
237
237
|
e,
|
|
238
238
|
r,
|
|
239
239
|
t,
|
|
240
240
|
!1,
|
|
241
241
|
n ? Error("react-stack-top-frame") : v,
|
|
242
|
-
n ?
|
|
242
|
+
n ? p(m(e)) : i
|
|
243
243
|
);
|
|
244
244
|
}, D.jsxs = function(e, r, t) {
|
|
245
|
-
var n = 1e4 >
|
|
245
|
+
var n = 1e4 > b.recentlyCreatedOwnerStacks++;
|
|
246
246
|
return L(
|
|
247
247
|
e,
|
|
248
248
|
r,
|
|
249
249
|
t,
|
|
250
250
|
!0,
|
|
251
251
|
n ? Error("react-stack-top-frame") : v,
|
|
252
|
-
n ?
|
|
252
|
+
n ? p(m(e)) : i
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
255
|
})()), D;
|
|
256
256
|
}
|
|
257
257
|
var ne;
|
|
258
258
|
function be() {
|
|
259
|
-
return ne || (ne = 1, process.env.NODE_ENV === "production" ? Z.exports =
|
|
259
|
+
return ne || (ne = 1, process.env.NODE_ENV === "production" ? Z.exports = ve() : Z.exports = _e()), Z.exports;
|
|
260
260
|
}
|
|
261
|
-
var
|
|
261
|
+
var R = be();
|
|
262
262
|
const Pe = me(({
|
|
263
263
|
children: f,
|
|
264
|
-
className:
|
|
265
|
-
style:
|
|
264
|
+
className: y,
|
|
265
|
+
style: T,
|
|
266
266
|
transitionMs: m = 250,
|
|
267
267
|
easing: l = "linear",
|
|
268
268
|
depthSpacingPx: s = 200,
|
|
269
|
-
perspectivePx:
|
|
270
|
-
blurAt1Px:
|
|
269
|
+
perspectivePx: h = 3e3,
|
|
270
|
+
blurAt1Px: k = 6,
|
|
271
271
|
blurAt2Px: F = 10,
|
|
272
272
|
opacityAt1: X = 0.7,
|
|
273
273
|
opacityAt2: L = 0.45,
|
|
274
274
|
minVisibleOpacity: A = 0.2,
|
|
275
275
|
initialIndex: C = 0,
|
|
276
|
-
disableNavigationButtons:
|
|
276
|
+
disableNavigationButtons: d = !1
|
|
277
277
|
}, W) => {
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
278
|
+
const g = de(() => ge.toArray(f), [f]), j = (r) => Math.max(0, Math.min(1, r)), U = (r, t, n) => r + (t - r) * n, q = (r, t, n, c) => r <= 0 ? t : r >= 2 ? c : r <= 1 ? U(t, n, j(r)) : U(n, c, j(r - 1)), [a, $] = P(() => Number.isNaN(C) ? 0 : Math.max(0, Math.min(g.length - 1, C))), [z, I] = P(null), [B, x] = P(null), [S, w] = P(1), [J, b] = P(1), [u, M] = P(!1), [p, N] = P(1), E = Q(null), v = Q(null), i = pe((r) => {
|
|
279
|
+
if (u || r < 0 || r >= g.length || r === a) return;
|
|
280
280
|
const t = r > a ? 1 : -1;
|
|
281
|
-
M(!0), I(a),
|
|
282
|
-
|
|
283
|
-
}),
|
|
284
|
-
M(!1), I(null), x(null), w(1),
|
|
281
|
+
M(!0), I(a), b(0), N(t), t === -1 ? (x(r), w(0)) : (x(null), w(1)), $(r), v.current !== null && window.cancelAnimationFrame(v.current), v.current = window.requestAnimationFrame(() => {
|
|
282
|
+
b(1), t === -1 && w(1), v.current = null;
|
|
283
|
+
}), E.current !== null && window.clearTimeout(E.current), E.current = window.setTimeout(() => {
|
|
284
|
+
M(!1), I(null), x(null), w(1), b(1), N(1), E.current = null;
|
|
285
285
|
}, m + 60);
|
|
286
|
-
}, [
|
|
286
|
+
}, [u, a, g.length, m, M, I, b, N, x, w, $]);
|
|
287
287
|
H(() => () => {
|
|
288
|
-
|
|
288
|
+
E.current !== null && window.clearTimeout(E.current), v.current !== null && window.cancelAnimationFrame(v.current);
|
|
289
289
|
}, []), H(() => {
|
|
290
|
-
$((r) => Math.max(0, Math.min(
|
|
291
|
-
}, [
|
|
290
|
+
$((r) => Math.max(0, Math.min(g.length - 1, r)));
|
|
291
|
+
}, [g.length]), H(() => {
|
|
292
|
+
if (d) return;
|
|
292
293
|
const r = (t) => {
|
|
293
|
-
t.key === "PageUp" ?
|
|
294
|
+
t.key === "PageUp" ? i(a - 1) : t.key === "PageDown" && i(a + 1);
|
|
294
295
|
};
|
|
295
296
|
return window.addEventListener("keydown", r), () => {
|
|
296
297
|
window.removeEventListener("keydown", r);
|
|
297
298
|
};
|
|
298
|
-
}, [a,
|
|
299
|
-
goToPrev: () =>
|
|
300
|
-
goToNext: () =>
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
299
|
+
}, [d, a, i]), Ee(W, () => ({
|
|
300
|
+
goToPrev: () => i(a - 1),
|
|
301
|
+
goToNext: () => i(a + 1),
|
|
302
|
+
goToFirst: () => i(0)
|
|
303
|
+
}), [a, i]);
|
|
304
|
+
const V = u, e = s * a;
|
|
305
|
+
return /* @__PURE__ */ R.jsx(
|
|
304
306
|
"div",
|
|
305
307
|
{
|
|
306
|
-
className: `layeredScene ${V ? "is-transitioning" : ""}${
|
|
308
|
+
className: `layeredScene ${V ? "is-transitioning" : ""}${y ? ` ${y}` : ""}`,
|
|
307
309
|
"aria-label": "3D layered scene",
|
|
308
310
|
style: {
|
|
309
311
|
"--camera-z": `${e}px`,
|
|
310
312
|
"--transition-ms": `${m}ms`,
|
|
311
313
|
"--transition-easing": l,
|
|
312
|
-
"--perspective": `${
|
|
313
|
-
...
|
|
314
|
+
"--perspective": `${h}px`,
|
|
315
|
+
...T
|
|
314
316
|
},
|
|
315
|
-
children:
|
|
316
|
-
const n = Math.abs(t - a), c =
|
|
317
|
-
if (o +
|
|
317
|
+
children: g.map((r, t) => {
|
|
318
|
+
const n = Math.abs(t - a), c = z !== null && t === z, O = B !== null && t === B, o = -s * t, _ = c && p === 1 ? s * 2 : 0;
|
|
319
|
+
if (o + _ + e > 0 && !c && !(O && u && p === -1))
|
|
318
320
|
return null;
|
|
319
|
-
const oe =
|
|
320
|
-
return /* @__PURE__ */
|
|
321
|
+
const oe = q(n, 1, X, L), ae = c && u ? p === -1 ? J === 0 ? 1 : A : J === 0 ? 1 : A : O && u && p === -1 ? S === 0 ? 0 : 1 : t === a ? 1 : oe, se = q(n, 0, k, F), le = O && u && p === -1 ? S === 0 ? F : 0 : se, ce = 1e4 - Math.round(n * 10) + (c ? 1e3 : 0), ue = ee(r) ? r : /* @__PURE__ */ R.jsx(R.Fragment, { children: r }), ie = (ee(r) ? r.key : null) ?? t;
|
|
322
|
+
return /* @__PURE__ */ R.jsx(
|
|
321
323
|
"div",
|
|
322
324
|
{
|
|
323
325
|
className: `layeredLayer ${n === 0 ? "is-focused" : ""} ${t === a ? "is-active" : ""} ${c ? "is-outgoing" : ""}`,
|
|
324
326
|
style: {
|
|
325
327
|
"--z": `${o}px`,
|
|
326
|
-
"--outgoing-offset": `${
|
|
328
|
+
"--outgoing-offset": `${_}px`,
|
|
327
329
|
"--stack": ce,
|
|
328
330
|
"--layer-blur": `${le}px`,
|
|
329
331
|
opacity: Math.max(A, ae)
|
|
330
332
|
},
|
|
331
|
-
children: /* @__PURE__ */
|
|
332
|
-
|
|
333
|
-
/* @__PURE__ */
|
|
334
|
-
!
|
|
333
|
+
children: /* @__PURE__ */ R.jsxs("div", { className: "layeredLayerInner", children: [
|
|
334
|
+
ue,
|
|
335
|
+
/* @__PURE__ */ R.jsxs("div", { className: "layeredControls", children: [
|
|
336
|
+
!d && t !== 0 ? /* @__PURE__ */ R.jsx(
|
|
335
337
|
"button",
|
|
336
338
|
{
|
|
337
339
|
type: "button",
|
|
338
340
|
className: "layeredBtn",
|
|
339
|
-
onClick: () =>
|
|
340
|
-
disabled:
|
|
341
|
+
onClick: () => i(a - 1),
|
|
342
|
+
disabled: u || t !== a,
|
|
341
343
|
children: "Previous"
|
|
342
344
|
}
|
|
343
345
|
) : null,
|
|
344
|
-
!
|
|
346
|
+
!d && t !== g.length - 1 ? /* @__PURE__ */ R.jsx(
|
|
345
347
|
"button",
|
|
346
348
|
{
|
|
347
349
|
type: "button",
|
|
348
350
|
className: "layeredBtn",
|
|
349
|
-
onClick: () =>
|
|
350
|
-
disabled:
|
|
351
|
+
onClick: () => i(a + 1),
|
|
352
|
+
disabled: u || t !== a,
|
|
351
353
|
children: "Next"
|
|
352
354
|
}
|
|
353
355
|
) : null
|
|
354
356
|
] })
|
|
355
357
|
] })
|
|
356
358
|
},
|
|
357
|
-
|
|
359
|
+
ie
|
|
358
360
|
);
|
|
359
361
|
})
|
|
360
362
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");var Z={exports:{}},Y={};var K;function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");var Z={exports:{}},Y={};var K;function ce(){if(K)return Y;K=1;var m=Symbol.for("react.transitional.element"),T=Symbol.for("react.fragment");function h(d,c,l){var k=null;if(l!==void 0&&(k=""+l),c.key!==void 0&&(k=""+c.key),"key"in c){l={};for(var w in c)w!=="key"&&(l[w]=c[w])}else l=c;return c=l.ref,{$$typeof:m,type:d,key:k,ref:c!==void 0?c:null,props:l}}return Y.Fragment=T,Y.jsx=h,Y.jsxs=h,Y}var D={};var Q;function ue(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&(function(){function m(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===J?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case A:return"Fragment";case q:return"Profiler";case U:return"StrictMode";case I:return"Suspense";case B:return"SuspenseList";case O:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case E:return"Portal";case $:return e.displayName||"Context";case o:return(e._context.displayName||"Context")+".Consumer";case z:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case j:return r=e.displayName||null,r!==null?r:m(e.type)||"Memo";case x:r=e._payload,e=e._init;try{return m(e(r))}catch{}}return null}function T(e){return""+e}function h(e){try{T(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),T(e)}}function d(e){if(e===A)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===x)return"<...>";try{var r=m(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function c(){var e=y.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function k(e){if(i.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function w(e,r){function t(){N||(N=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function F(){var e=m(this.type);return v[e]||(v[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function X(e,r,t,n,u,S){var a=t.ref;return e={$$typeof:W,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:F}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:u}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function L(e,r,t,n,u,S){var a=r.children;if(a!==void 0)if(n)if(M(a)){for(n=0;n<a.length;n++)P(a[n]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else P(a);if(i.call(r,"key")){a=m(e);var b=Object.keys(r).filter(function(H){return H!=="key"});n=0<b.length?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}",V[a+n]||(b=0<b.length?"{"+b.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,n,a,
|
|
6
|
+
<%s key={someKey} {...props} />`,n,a,b,a),V[a+n]=!0)}if(a=null,t!==void 0&&(h(t),a=""+t),k(r)&&(h(r.key),a=""+r.key),"key"in r){t={};for(var G in r)G!=="key"&&(t[G]=r[G])}else t=r;return a&&w(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),X(e,a,t,c(),u,S)}function P(e){C(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===x&&(e._payload.status==="fulfilled"?C(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function C(e){return typeof e=="object"&&e!==null&&e.$$typeof===W}var g=s,W=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),$=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),y=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,i=Object.prototype.hasOwnProperty,M=Array.isArray,p=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(e){return e()}};var N,v={},_=g.react_stack_bottom_frame.bind(g,l)(),f=p(d(l)),V={};D.Fragment=A,D.jsx=function(e,r,t){var n=1e4>y.recentlyCreatedOwnerStacks++;return L(e,r,t,!1,n?Error("react-stack-top-frame"):_,n?p(d(e)):f)},D.jsxs=function(e,r,t){var n=1e4>y.recentlyCreatedOwnerStacks++;return L(e,r,t,!0,n?Error("react-stack-top-frame"):_,n?p(d(e)):f)}})()),D}var ee;function ie(){return ee||(ee=1,process.env.NODE_ENV==="production"?Z.exports=ce():Z.exports=ue()),Z.exports}var R=ie();const fe=s.forwardRef(({children:m,className:T,style:h,transitionMs:d=250,easing:c="linear",depthSpacingPx:l=200,perspectivePx:k=3e3,blurAt1Px:w=6,blurAt2Px:F=10,opacityAt1:X=.7,opacityAt2:L=.45,minVisibleOpacity:P=.2,initialIndex:C=0,disableNavigationButtons:g=!1},W)=>{const E=s.useMemo(()=>s.Children.toArray(m),[m]),A=r=>Math.max(0,Math.min(1,r)),U=(r,t,n)=>r+(t-r)*n,q=(r,t,n,u)=>r<=0?t:r>=2?u:r<=1?U(t,n,A(r)):U(n,u,A(r-1)),[o,$]=s.useState(()=>Number.isNaN(C)?0:Math.max(0,Math.min(E.length-1,C))),[z,I]=s.useState(null),[B,j]=s.useState(null),[x,O]=s.useState(1),[J,y]=s.useState(1),[i,M]=s.useState(!1),[p,N]=s.useState(1),v=s.useRef(null),_=s.useRef(null),f=s.useCallback(r=>{if(i||r<0||r>=E.length||r===o)return;const t=r>o?1:-1;M(!0),I(o),y(0),N(t),t===-1?(j(r),O(0)):(j(null),O(1)),$(r),_.current!==null&&window.cancelAnimationFrame(_.current),_.current=window.requestAnimationFrame(()=>{y(1),t===-1&&O(1),_.current=null}),v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{M(!1),I(null),j(null),O(1),y(1),N(1),v.current=null},d+60)},[i,o,E.length,d,M,I,y,N,j,O,$]);s.useEffect(()=>()=>{v.current!==null&&window.clearTimeout(v.current),_.current!==null&&window.cancelAnimationFrame(_.current)},[]),s.useEffect(()=>{$(r=>Math.max(0,Math.min(E.length-1,r)))},[E.length]),s.useEffect(()=>{if(g)return;const r=t=>{t.key==="PageUp"?f(o-1):t.key==="PageDown"&&f(o+1)};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[g,o,f]),s.useImperativeHandle(W,()=>({goToPrev:()=>f(o-1),goToNext:()=>f(o+1),goToFirst:()=>f(0)}),[o,f]);const V=i,e=l*o;return R.jsx("div",{className:`layeredScene ${V?"is-transitioning":""}${T?` ${T}`:""}`,"aria-label":"3D layered scene",style:{"--camera-z":`${e}px`,"--transition-ms":`${d}ms`,"--transition-easing":c,"--perspective":`${k}px`,...h},children:E.map((r,t)=>{const n=Math.abs(t-o),u=z!==null&&t===z,S=B!==null&&t===B,a=-l*t,b=u&&p===1?l*2:0;if(a+b+e>0&&!u&&!(S&&i&&p===-1))return null;const re=q(n,1,X,L),te=u&&i?p===-1?J===0?1:P:J===0?1:P:S&&i&&p===-1?x===0?0:1:t===o?1:re,ne=q(n,0,w,F),ae=S&&i&&p===-1?x===0?F:0:ne,oe=1e4-Math.round(n*10)+(u?1e3:0),se=s.isValidElement(r)?r:R.jsx(R.Fragment,{children:r}),le=(s.isValidElement(r)?r.key:null)??t;return R.jsx("div",{className:`layeredLayer ${n===0?"is-focused":""} ${t===o?"is-active":""} ${u?"is-outgoing":""}`,style:{"--z":`${a}px`,"--outgoing-offset":`${b}px`,"--stack":oe,"--layer-blur":`${ae}px`,opacity:Math.max(P,te)},children:R.jsxs("div",{className:"layeredLayerInner",children:[se,R.jsxs("div",{className:"layeredControls",children:[!g&&t!==0?R.jsx("button",{type:"button",className:"layeredBtn",onClick:()=>f(o-1),disabled:i||t!==o,children:"Previous"}):null,!g&&t!==E.length-1?R.jsx("button",{type:"button",className:"layeredBtn",onClick:()=>f(o+1),disabled:i||t!==o,children:"Next"}):null]})]})},le)})})});exports.LayeredScene=fe;
|